mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Merge remote-tracking branch 'origin/1.20.4' into 1.20.4
This commit is contained in:
commit
c866a404ea
20 changed files with 92 additions and 112 deletions
|
@ -34,7 +34,6 @@ import net.minecraft.world.level.block.LiquidBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.fluids.FluidStack;
|
import net.neoforged.neoforge.fluids.FluidStack;
|
||||||
import net.neoforged.neoforge.fluids.FluidType;
|
import net.neoforged.neoforge.fluids.FluidType;
|
||||||
import net.neoforged.neoforge.fluids.IFluidBlock;
|
import net.neoforged.neoforge.fluids.IFluidBlock;
|
||||||
|
@ -73,7 +72,6 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing
|
||||||
return super.drain(resource, action);
|
return super.drain(resource, action);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public final LazyOptional<IFluidHandler> lazyTank = LazyOptional.of(() -> this.tank);
|
|
||||||
private int lastTankAmount;
|
private int lastTankAmount;
|
||||||
private int currentTime;
|
private int currentTime;
|
||||||
private int lastCompare;
|
private int lastCompare;
|
||||||
|
@ -147,7 +145,7 @@ public class TileEntityFluidCollector extends TileEntityBase implements ISharing
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IFluidHandler getFluidHandler(Direction facing) {
|
public IFluidHandler getFluidHandler(Direction facing) {
|
||||||
return this.lazyTank;
|
return this.tank;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.MagmaBlock;
|
import net.minecraft.world.level.block.MagmaBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
@ -26,11 +26,11 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class TileEntityItemInterfaceHopping extends TileEntityItemInterface {
|
public class TileEntityItemInterfaceHopping extends TileEntityItemInterface {
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyOptional<IItemHandler> handler = tile.itemHandler.getNormalHandler();
|
Optional<IItemHandler> handler = Optional.ofNullable(tile.itemHandler.getNormalHandler());
|
||||||
handler.ifPresent(cap -> {
|
handler.ifPresent(cap -> {
|
||||||
for (int i = 0; i < cap.getSlots(); i++) {
|
for (int i = 0; i < cap.getSlots(); i++) {
|
||||||
ItemStack left = cap.insertItem(i, item.getItem(), false);
|
ItemStack left = cap.insertItem(i, item.getItem(), false);
|
||||||
|
@ -111,7 +111,7 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface {
|
||||||
|
|
||||||
BlockEntity from = this.level.getBlockEntity(this.getBlockPos().relative(Direction.UP));
|
BlockEntity from = this.level.getBlockEntity(this.getBlockPos().relative(Direction.UP));
|
||||||
if (from != null && !(from instanceof TileEntityItemInterface)) {
|
if (from != null && !(from instanceof TileEntityItemInterface)) {
|
||||||
LazyOptional<IItemHandler> normal = from.getCapability(Capabilities.ITEM_HANDLER, Direction.DOWN);
|
IItemHandler normal = this.level.getCapability(Capabilities.ItemHandler.BLOCK, from.getBlockPos(), Direction.DOWN);
|
||||||
|
|
||||||
Object slotless = null;
|
Object slotless = null;
|
||||||
// TODO: [port] add back
|
// TODO: [port] add back
|
||||||
|
@ -132,7 +132,7 @@ public class TileEntityItemInterfaceHopping extends TileEntityItemInterface {
|
||||||
if (this.level.isLoaded(toPos)) {
|
if (this.level.isLoaded(toPos)) {
|
||||||
BlockEntity to = this.level.getBlockEntity(toPos);
|
BlockEntity to = this.level.getBlockEntity(toPos);
|
||||||
if (to != null && !(to instanceof TileEntityItemInterface)) {
|
if (to != null && !(to instanceof TileEntityItemInterface)) {
|
||||||
LazyOptional<IItemHandler> normal = to.getCapability(Capabilities.ITEM_HANDLER, facing.getOpposite());
|
IItemHandler normal = this.level.getCapability(Capabilities.ItemHandler.BLOCK, to.getBlockPos(), facing.getOpposite());
|
||||||
|
|
||||||
Object slotless = null;
|
Object slotless = null;
|
||||||
// TODO: [port] Add back
|
// TODO: [port] Add back
|
||||||
|
|
|
@ -30,12 +30,12 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay {
|
||||||
// TODO: [port] this is super hacky, review and fix up
|
// TODO: [port] this is super hacky, review and fix up
|
||||||
@Override
|
@Override
|
||||||
public IEnergyStorage getEnergyStorage(Direction facing) {
|
public IEnergyStorage getEnergyStorage(Direction facing) {
|
||||||
return LazyOptional.of(() -> this.energyStorages[facing == null
|
return this.energyStorages[facing == null
|
||||||
? 0
|
? 0
|
||||||
: facing.ordinal()]);
|
: facing.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -136,7 +136,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay {
|
||||||
if (this.level.hasChunkAt(pos)) {
|
if (this.level.hasChunkAt(pos)) {
|
||||||
BlockEntity tile = this.level.getBlockEntity(pos);
|
BlockEntity tile = this.level.getBlockEntity(pos);
|
||||||
if (tile != null && !(tile instanceof TileEntityLaserRelay)) {
|
if (tile != null && !(tile instanceof TileEntityLaserRelay)) {
|
||||||
if (tile.getCapability(Capabilities.ENERGY, side.getOpposite()).isPresent()) {
|
if (this.level.getCapability(Capabilities.EnergyStorage.BLOCK, tile.getBlockPos(), side.getOpposite()) != null) {
|
||||||
this.receiversAround.put(side, tile);
|
this.receiversAround.put(side, tile);
|
||||||
|
|
||||||
BlockEntity oldTile = old.get(side);
|
BlockEntity oldTile = old.get(side);
|
||||||
|
@ -179,7 +179,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay {
|
||||||
|
|
||||||
Direction opp = facing.getOpposite();
|
Direction opp = facing.getOpposite();
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
Boolean received = tile.getCapability(Capabilities.ENERGY, opp).map(cap -> cap.receiveEnergy(maxTransfer, true) > 0).orElse(false);
|
Boolean received = Optional.ofNullable(this.level.getCapability(Capabilities.EnergyStorage.BLOCK, tile.getBlockPos(), opp)).map(cap -> cap.receiveEnergy(maxTransfer, true) > 0).orElse(false);
|
||||||
if (received) {
|
if (received) {
|
||||||
totalReceiverAmount++;
|
totalReceiverAmount++;
|
||||||
workedOnce = true;
|
workedOnce = true;
|
||||||
|
@ -213,7 +213,7 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay {
|
||||||
if (!alreadyChecked.contains(tile.getBlockPos())) {
|
if (!alreadyChecked.contains(tile.getBlockPos())) {
|
||||||
alreadyChecked.add(tile.getBlockPos());
|
alreadyChecked.add(tile.getBlockPos());
|
||||||
if (theRelay != this || side != from) {
|
if (theRelay != this || side != from) {
|
||||||
transmitted += tile.getCapability(Capabilities.ENERGY, opp).map(cap -> {
|
transmitted += Optional.ofNullable(this.level.getCapability(Capabilities.EnergyStorage.BLOCK, tile.getBlockPos(), opp)).map(cap -> {
|
||||||
int trans = 0;
|
int trans = 0;
|
||||||
int theoreticalReceived = cap.receiveEnergy(Math.min(amountPer, lowestCap), true);
|
int theoreticalReceived = cap.receiveEnergy(Math.min(amountPer, lowestCap), true);
|
||||||
if (theoreticalReceived > 0) {
|
if (theoreticalReceived > 0) {
|
||||||
|
|
|
@ -28,8 +28,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.fluids.FluidStack;
|
import net.neoforged.neoforge.fluids.FluidStack;
|
||||||
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
|
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
|
||||||
|
|
||||||
|
@ -37,6 +36,7 @@ import javax.annotation.Nonnull;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay {
|
||||||
super.serverTick();
|
super.serverTick();
|
||||||
if (this.mode == Mode.INPUT_ONLY) {
|
if (this.mode == Mode.INPUT_ONLY) {
|
||||||
for (Direction side : this.handlersAround.keySet()) {
|
for (Direction side : this.handlersAround.keySet()) {
|
||||||
WorldUtil.doFluidInteraction(this.handlersAround.get(side), this, side.getOpposite(), Integer.MAX_VALUE);
|
WorldUtil.doFluidInteraction(this.level, this.handlersAround.get(side).getBlockPos(), this.getBlockPos(), side.getOpposite(), Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay {
|
||||||
if (this.level.hasChunkAt(pos)) {
|
if (this.level.hasChunkAt(pos)) {
|
||||||
BlockEntity tile = this.level.getBlockEntity(pos);
|
BlockEntity tile = this.level.getBlockEntity(pos);
|
||||||
if (tile != null && !(tile instanceof TileEntityLaserRelay)) {
|
if (tile != null && !(tile instanceof TileEntityLaserRelay)) {
|
||||||
if (tile.getCapability(Capabilities.FLUID_HANDLER, side.getOpposite()).isPresent()) {
|
if (this.level.getCapability(Capabilities.FluidHandler.BLOCK, tile.getBlockPos(), side.getOpposite()) != null) {
|
||||||
this.handlersAround.put(side, tile);
|
this.handlersAround.put(side, tile);
|
||||||
|
|
||||||
BlockEntity oldTile = old.get(side);
|
BlockEntity oldTile = old.get(side);
|
||||||
|
@ -156,9 +156,9 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay {
|
||||||
// TODO: [port] super hacky, find better way of handling this.
|
// TODO: [port] super hacky, find better way of handling this.
|
||||||
@Override
|
@Override
|
||||||
public IFluidHandler getFluidHandler(Direction facing) {
|
public IFluidHandler getFluidHandler(Direction facing) {
|
||||||
return LazyOptional.of(() -> this.fluidHandlers[facing == null
|
return this.fluidHandlers[facing == null
|
||||||
? 0
|
? 0
|
||||||
: facing.ordinal()]);
|
: facing.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
private int transmitFluid(Direction from, FluidStack stack, IFluidHandler.FluidAction action) {
|
private int transmitFluid(Direction from, FluidStack stack, IFluidHandler.FluidAction action) {
|
||||||
|
@ -194,7 +194,8 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay {
|
||||||
BlockEntity tile = theRelay.handlersAround.get(facing);
|
BlockEntity tile = theRelay.handlersAround.get(facing);
|
||||||
Direction opp = facing.getOpposite();
|
Direction opp = facing.getOpposite();
|
||||||
|
|
||||||
boolean received = tile.getCapability(Capabilities.FLUID_HANDLER, opp).map(cap -> cap.fill(stack, IFluidHandler.FluidAction.SIMULATE) > 0).orElse(false);
|
boolean received = Optional.ofNullable(this.level.getCapability(Capabilities.FluidHandler.BLOCK, tile.getBlockPos(), opp))
|
||||||
|
.map(cap -> cap.fill(stack, IFluidHandler.FluidAction.SIMULATE) > 0).orElse(false);
|
||||||
if (received) {
|
if (received) {
|
||||||
totalReceiverAmount++;
|
totalReceiverAmount++;
|
||||||
workedOnce = true;
|
workedOnce = true;
|
||||||
|
@ -225,7 +226,8 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay {
|
||||||
if (!alreadyChecked.contains(tile.getBlockPos())) {
|
if (!alreadyChecked.contains(tile.getBlockPos())) {
|
||||||
alreadyChecked.add(tile.getBlockPos());
|
alreadyChecked.add(tile.getBlockPos());
|
||||||
if (theRelay != this || side != from) {
|
if (theRelay != this || side != from) {
|
||||||
transmitted += tile.getCapability(Capabilities.FLUID_HANDLER, opp).map(cap -> {
|
transmitted += Optional.ofNullable(this.level.getCapability(Capabilities.FluidHandler.BLOCK, tile.getBlockPos(), opp))
|
||||||
|
.map(cap -> {
|
||||||
int trans = 0;
|
int trans = 0;
|
||||||
FluidStack copy = stack.copy();
|
FluidStack copy = stack.copy();
|
||||||
copy.setAmount(amountPer);
|
copy.setAmount(amountPer);
|
||||||
|
|
|
@ -31,8 +31,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -92,7 +91,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay {
|
||||||
if (this.level.hasChunkAt(pos)) {
|
if (this.level.hasChunkAt(pos)) {
|
||||||
BlockEntity tile = this.level.getBlockEntity(pos);
|
BlockEntity tile = this.level.getBlockEntity(pos);
|
||||||
if (tile != null && !(tile instanceof TileEntityItemInterface) && !(tile instanceof TileEntityLaserRelay)) {
|
if (tile != null && !(tile instanceof TileEntityItemInterface) && !(tile instanceof TileEntityLaserRelay)) {
|
||||||
LazyOptional<IItemHandler> itemHandler = tile.getCapability(Capabilities.ITEM_HANDLER, side.getOpposite());
|
IItemHandler itemHandler = this.level.getCapability(Capabilities.ItemHandler.BLOCK, tile.getBlockPos(), side.getOpposite());
|
||||||
|
|
||||||
Object slotlessHandler = null;
|
Object slotlessHandler = null;
|
||||||
// TODO: [port] add this back maybe?
|
// TODO: [port] add this back maybe?
|
||||||
|
|
|
@ -31,6 +31,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class TileEntityLaserRelayItemAdvanced extends TileEntityLaserRelayItem implements IButtonReactor, MenuProvider {
|
public class TileEntityLaserRelayItemAdvanced extends TileEntityLaserRelayItem implements IButtonReactor, MenuProvider {
|
||||||
|
|
||||||
|
@ -99,7 +100,7 @@ public class TileEntityLaserRelayItemAdvanced extends TileEntityLaserRelayItem i
|
||||||
|
|
||||||
private void addWhitelistSmart(boolean output) {
|
private void addWhitelistSmart(boolean output) {
|
||||||
for (SlotlessableItemHandlerWrapper handler : this.handlersAround.values()) {
|
for (SlotlessableItemHandlerWrapper handler : this.handlersAround.values()) {
|
||||||
handler.getNormalHandler().ifPresent(itemHandler -> {
|
Optional.ofNullable(handler.getNormalHandler()).ifPresent(itemHandler -> {
|
||||||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||||
ItemStack stack = itemHandler.getStackInSlot(i);
|
ItemStack stack = itemHandler.getStackInSlot(i);
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.LeavesBlock;
|
import net.minecraft.world.level.block.LeavesBlock;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -32,7 +31,6 @@ import java.util.List;
|
||||||
public class TileEntityLeafGenerator extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay {
|
public class TileEntityLeafGenerator extends TileEntityBase implements ISharingEnergyProvider, IEnergyDisplay {
|
||||||
|
|
||||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(35000, 0, 450);
|
public final CustomEnergyStorage storage = new CustomEnergyStorage(35000, 0, 450);
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
|
||||||
private int nextUseCounter;
|
private int nextUseCounter;
|
||||||
private int oldEnergy;
|
private int oldEnergy;
|
||||||
|
|
||||||
|
@ -140,6 +138,6 @@ public class TileEntityLeafGenerator extends TileEntityBase implements ISharingE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnergyStorage getEnergyStorage(Direction facing) {
|
public IEnergyStorage getEnergyStorage(Direction facing) {
|
||||||
return this.lazyEnergy;
|
return this.storage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -41,7 +40,6 @@ public class TileEntityLongRangeBreaker extends TileEntityInventoryBase implemen
|
||||||
public static final int RANGE = 8;
|
public static final int RANGE = 8;
|
||||||
public static final int ENERGY_USE = 5;
|
public static final int ENERGY_USE = 5;
|
||||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(10000, 20, 0);
|
public final CustomEnergyStorage storage = new CustomEnergyStorage(10000, 20, 0);
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
|
||||||
private int lastEnergy;
|
private int lastEnergy;
|
||||||
private int currentTime;
|
private int currentTime;
|
||||||
|
|
||||||
|
@ -142,7 +140,7 @@ public class TileEntityLongRangeBreaker extends TileEntityInventoryBase implemen
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnergyStorage getEnergyStorage(Direction facing) {
|
public IEnergyStorage getEnergyStorage(Direction facing) {
|
||||||
return this.lazyEnergy;
|
return this.storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class TileEntityOilGenerator extends TileEntityBase implements ISharingEn
|
||||||
} else if (!tile.isRedstonePowered) {
|
} else if (!tile.isRedstonePowered) {
|
||||||
|
|
||||||
RecipeHolder<LiquidFuelRecipe> recipeHolder = tile.getRecipeForCurrentFluid();
|
RecipeHolder<LiquidFuelRecipe> recipeHolder = tile.getRecipeForCurrentFluid();
|
||||||
if (recipeHolder != null && tile.storage.getEnergyStored() < tile.storage.getMaxEnergyStored() && tile.tank.getFluidAmount() >= recipeHolder.getFuelAmount()) {
|
if (recipeHolder != null && tile.storage.getEnergyStored() < tile.storage.getMaxEnergyStored() && tile.tank.getFluidAmount() >= recipeHolder.value().getFuelAmount()) {
|
||||||
LiquidFuelRecipe recipe = recipeHolder.value();
|
LiquidFuelRecipe recipe = recipeHolder.value();
|
||||||
tile.fuelUsage = recipe.getFuelAmount();
|
tile.fuelUsage = recipe.getFuelAmount();
|
||||||
tile.currentEnergyProduce = recipe.getTotalEnergy() / recipe.getBurnTime();
|
tile.currentEnergyProduce = recipe.getTotalEnergy() / recipe.getBurnTime();
|
||||||
|
|
|
@ -17,8 +17,8 @@ import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ISharingEnergyProvider {
|
public class TileEntityPhantomEnergyface extends TileEntityPhantomface implements ISharingEnergyProvider {
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
||||||
BlockEntity tile = this.level.getBlockEntity(this.boundPosition);
|
BlockEntity tile = this.level.getBlockEntity(this.boundPosition);
|
||||||
if (tile != null && !(tile instanceof TileEntityLaserRelayEnergy)) {
|
if (tile != null && !(tile instanceof TileEntityLaserRelayEnergy)) {
|
||||||
for (Direction facing : Direction.values()) {
|
for (Direction facing : Direction.values()) {
|
||||||
if (tile.getCapability(Capabilities.ENERGY, facing).isPresent()) {
|
if (this.level.getCapability(Capabilities.EnergyStorage.BLOCK, tile.getBlockPos(), facing) != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,14 @@ public class TileEntityPhantomEnergyface extends TileEntityPhantomface implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isCapabilitySupported(Capability<?> capability) {
|
public IEnergyStorage getEnergyStorage(Direction facing) {
|
||||||
return capability == Capabilities.ENERGY;
|
if (this.isBoundThingInRange()) {
|
||||||
|
BlockEntity tile = this.level.getBlockEntity(this.getBoundPosition());
|
||||||
|
if (tile != null) {
|
||||||
|
return this.level.getCapability(Capabilities.EnergyStorage.BLOCK, this.getBoundPosition(), facing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,8 +19,8 @@ import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
|
|
||||||
public class TileEntityPhantomItemface extends TileEntityPhantomface {
|
public class TileEntityPhantomItemface extends TileEntityPhantomface {
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface {
|
||||||
BlockEntity tile = this.level.getBlockEntity(this.getBoundPosition());
|
BlockEntity tile = this.level.getBlockEntity(this.getBoundPosition());
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
for (Direction facing : Direction.values()) {
|
for (Direction facing : Direction.values()) {
|
||||||
if (tile.getCapability(Capabilities.ITEM_HANDLER, facing).isPresent()) {
|
if (this.level.getCapability(Capabilities.ItemHandler.BLOCK, this.getBoundPosition(), facing) != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,14 @@ public class TileEntityPhantomItemface extends TileEntityPhantomface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isCapabilitySupported(Capability<?> capability) {
|
public IItemHandler getItemHandler(Direction facing) {
|
||||||
return capability == Capabilities.ITEM_HANDLER;
|
if (this.isBoundThingInRange()) {
|
||||||
|
BlockEntity tile = this.level.getBlockEntity(this.getBoundPosition());
|
||||||
|
if (tile != null) {
|
||||||
|
return this.level.getCapability(Capabilities.ItemHandler.BLOCK, this.getBoundPosition(), facing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,8 +17,8 @@ import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
|
||||||
|
|
||||||
public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements ISharingFluidHandler {
|
public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements ISharingFluidHandler {
|
||||||
|
|
||||||
|
@ -42,10 +42,10 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
||||||
@Override
|
@Override
|
||||||
public boolean isBoundThingInRange() {
|
public boolean isBoundThingInRange() {
|
||||||
if (super.isBoundThingInRange()) {
|
if (super.isBoundThingInRange()) {
|
||||||
BlockEntity tile = this.level.getBlockEntity(this.boundPosition);
|
BlockEntity tile = this.level.getBlockEntity(this.getBoundPosition());
|
||||||
if (tile != null && !(tile instanceof TileEntityLaserRelayFluids)) {
|
if (tile != null && !(tile instanceof TileEntityLaserRelayFluids)) {
|
||||||
for (Direction facing : Direction.values()) {
|
for (Direction facing : Direction.values()) {
|
||||||
if (tile.getCapability(Capabilities.FLUID_HANDLER, facing).isPresent()) {
|
if (this.level.getCapability(Capabilities.FluidHandler.BLOCK, this.getBoundPosition(), facing) != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,14 @@ public class TileEntityPhantomLiquiface extends TileEntityPhantomface implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isCapabilitySupported(Capability<?> capability) {
|
public IFluidHandler getFluidHandler(Direction facing) {
|
||||||
return capability == Capabilities.FLUID_HANDLER;
|
if (this.isBoundThingInRange()) {
|
||||||
|
BlockEntity tile = this.level.getBlockEntity(this.getBoundPosition());
|
||||||
|
if (tile != null) {
|
||||||
|
return this.level.getCapability(Capabilities.FluidHandler.BLOCK, this.getBoundPosition(), facing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@ -71,9 +70,4 @@ public class TileEntityPhantomRedstoneface extends TileEntityPhantomface {
|
||||||
|
|
||||||
super.onUpdateSent();
|
super.onUpdateSent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isCapabilitySupported(Capability<?> capability) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,21 +14,14 @@ import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockPhantom;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
|
||||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
import net.neoforged.api.distmarker.OnlyIn;
|
import net.neoforged.api.distmarker.OnlyIn;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capability;
|
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public abstract class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile {
|
public abstract class TileEntityPhantomface extends TileEntityInventoryBase implements IPhantomTile {
|
||||||
public static final int RANGE = 16;
|
public static final int RANGE = 16;
|
||||||
|
@ -186,21 +179,6 @@ public abstract class TileEntityPhantomface extends TileEntityInventoryBase impl
|
||||||
return this.range;
|
return this.range;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean isCapabilitySupported(Capability<?> capability);
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction side) {
|
|
||||||
if (this.isBoundThingInRange() && this.isCapabilitySupported(capability)) {
|
|
||||||
BlockEntity tile = this.level.getBlockEntity(this.getBoundPosition());
|
|
||||||
if (tile != null) {
|
|
||||||
return tile.getCapability(capability, side);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return LazyOptional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getComparatorStrength() {
|
public int getComparatorStrength() {
|
||||||
if (this.isBoundThingInRange()) {
|
if (this.isBoundThingInRange()) {
|
||||||
|
|
|
@ -20,19 +20,18 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
import net.neoforged.neoforge.items.wrapper.PlayerInvWrapper;
|
import net.neoforged.neoforge.items.wrapper.PlayerInvWrapper;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TileEntityPlayerInterface extends TileEntityBase implements IEnergyDisplay {
|
public class TileEntityPlayerInterface extends TileEntityBase implements IEnergyDisplay {
|
||||||
|
|
||||||
public static final int DEFAULT_RANGE = 32;
|
public static final int DEFAULT_RANGE = 32;
|
||||||
private final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 50, 0);
|
private final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 50, 0);
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
|
||||||
public UUID connectedPlayer;
|
public UUID connectedPlayer;
|
||||||
public String playerName;
|
public String playerName;
|
||||||
private IItemHandler playerHandler;
|
private IItemHandler playerHandler;
|
||||||
|
@ -69,7 +68,7 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy
|
||||||
: new PlayerInvWrapper(player.getInventory());
|
: new PlayerInvWrapper(player.getInventory());
|
||||||
}
|
}
|
||||||
|
|
||||||
return LazyOptional.of(() -> this.playerHandler);
|
return this.playerHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends BlockEntity> void clientTick(Level level, BlockPos pos, BlockState state, T t) {
|
public static <T extends BlockEntity> void clientTick(Level level, BlockPos pos, BlockState state, T t) {
|
||||||
|
@ -93,7 +92,8 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy
|
||||||
ItemStack slot = player.getInventory().getItem(i);
|
ItemStack slot = player.getInventory().getItem(i);
|
||||||
if (StackUtil.isValid(slot) && slot.getCount() == 1) {
|
if (StackUtil.isValid(slot) && slot.getCount() == 1) {
|
||||||
|
|
||||||
int received = slot.getCapability(Capabilities.ENERGY).map(cap -> cap.receiveEnergy(tile.storage.getEnergyStored(), false)).orElse(0);
|
int received = Optional.ofNullable(slot.getCapability(Capabilities.EnergyStorage.ITEM))
|
||||||
|
.map(cap -> cap.receiveEnergy(tile.storage.getEnergyStored(), false)).orElse(0);
|
||||||
if (received > 0) {
|
if (received > 0) {
|
||||||
tile.storage.extractEnergyInternal(received, false);
|
tile.storage.extractEnergyInternal(received, false);
|
||||||
}
|
}
|
||||||
|
@ -149,6 +149,6 @@ public class TileEntityPlayerInterface extends TileEntityBase implements IEnergy
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnergyStorage getEnergyStorage(Direction facing) {
|
public IEnergyStorage getEnergyStorage(Direction facing) {
|
||||||
return this.lazyEnergy;
|
return this.storage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
import net.minecraft.world.item.crafting.RecipeType;
|
import net.minecraft.world.item.crafting.RecipeType;
|
||||||
import net.minecraft.world.item.crafting.SmeltingRecipe;
|
import net.minecraft.world.item.crafting.SmeltingRecipe;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
@ -34,7 +35,6 @@ import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -50,7 +50,6 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
|
||||||
public static final int ENERGY_USE = 25;
|
public static final int ENERGY_USE = 25;
|
||||||
private static final int SMELT_TIME = 80;
|
private static final int SMELT_TIME = 80;
|
||||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 150, 0);
|
public final CustomEnergyStorage storage = new CustomEnergyStorage(30000, 150, 0);
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
|
||||||
public int firstSmeltTime;
|
public int firstSmeltTime;
|
||||||
public int secondSmeltTime;
|
public int secondSmeltTime;
|
||||||
public boolean isAutoSplit;
|
public boolean isAutoSplit;
|
||||||
|
@ -194,10 +193,10 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ItemStack> getOutputForInput(ItemStack stack) {
|
public Optional<ItemStack> getOutputForInput(ItemStack stack) {
|
||||||
return level.getServer().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleItem(stack), level).map(recipe -> recipe.getResultItem(this.level.registryAccess()));
|
return level.getServer().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleItem(stack), level).map(recipe -> recipe.value().getResultItem(this.level.registryAccess()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<SmeltingRecipe> getRecipeForInput(ItemStack stack) {
|
public Optional<RecipeHolder<SmeltingRecipe>> getRecipeForInput(ItemStack stack) {
|
||||||
return level.getServer().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleItem(stack), level);
|
return level.getServer().getRecipeManager().getRecipeFor(RecipeType.SMELTING, new SingleItem(stack), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,8 +214,8 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
|
||||||
ItemStack input = this.inv.getStackInSlot(theInput);
|
ItemStack input = this.inv.getStackInSlot(theInput);
|
||||||
ItemStack output = this.inv.getStackInSlot(theOutput);
|
ItemStack output = this.inv.getStackInSlot(theOutput);
|
||||||
if (!input.isEmpty()) {
|
if (!input.isEmpty()) {
|
||||||
Optional<SmeltingRecipe> recipe = getRecipeForInput(input);
|
Optional<RecipeHolder<SmeltingRecipe>> recipe = getRecipeForInput(input);
|
||||||
return recipe.map($ -> output.isEmpty() || ItemStack.isSameItem(output, $.getResultItem(this.level.registryAccess())) && output.getCount() <= output.getMaxStackSize() - $.getResultItem(this.level.registryAccess()).getCount()).orElse(false);
|
return recipe.map($ -> output.isEmpty() || ItemStack.isSameItem(output, $.value().getResultItem(this.level.registryAccess())) && output.getCount() <= output.getMaxStackSize() - $.value().getResultItem(this.level.registryAccess()).getCount()).orElse(false);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +249,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnergyStorage getEnergyStorage(Direction facing) {
|
public IEnergyStorage getEnergyStorage(Direction facing) {
|
||||||
return this.lazyEnergy;
|
return this.storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
|
|
@ -17,7 +17,6 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -31,7 +30,6 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy
|
||||||
public static final int RANGE = 5;
|
public static final int RANGE = 5;
|
||||||
|
|
||||||
public CustomEnergyStorage storage = new CustomEnergyStorage(300000, 400, 0);
|
public CustomEnergyStorage storage = new CustomEnergyStorage(300000, 400, 0);
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
|
||||||
private int oldEnergy;
|
private int oldEnergy;
|
||||||
|
|
||||||
public TileEntityShockSuppressor(BlockPos pos, BlockState state) {
|
public TileEntityShockSuppressor(BlockPos pos, BlockState state) {
|
||||||
|
@ -47,14 +45,14 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public void invalidateCaps() {
|
// public void invalidateCaps() {
|
||||||
super.invalidateCaps();
|
// super.invalidateCaps();
|
||||||
|
//
|
||||||
if (!this.level.isClientSide) {
|
// if (!this.level.isClientSide) {
|
||||||
SUPPRESSORS.remove(this);
|
// SUPPRESSORS.remove(this);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public static <T extends BlockEntity> void clientTick(Level level, BlockPos pos, BlockState state, T t) {
|
public static <T extends BlockEntity> void clientTick(Level level, BlockPos pos, BlockState state, T t) {
|
||||||
if (t instanceof TileEntityShockSuppressor tile) {
|
if (t instanceof TileEntityShockSuppressor tile) {
|
||||||
|
@ -100,6 +98,6 @@ public class TileEntityShockSuppressor extends TileEntityBase implements IEnergy
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnergyStorage getEnergyStorage(Direction facing) {
|
public IEnergyStorage getEnergyStorage(Direction facing) {
|
||||||
return this.lazyEnergy;
|
return this.storage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
@ -38,10 +39,8 @@ import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.neoforged.neoforge.common.TierSortingRegistry;
|
import net.neoforged.neoforge.common.TierSortingRegistry;
|
||||||
import net.neoforged.neoforge.common.util.FakePlayerFactory;
|
import net.neoforged.neoforge.common.util.FakePlayerFactory;
|
||||||
import net.neoforged.neoforge.common.util.LazyOptional;
|
|
||||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
import net.neoforged.neoforge.fluids.IFluidBlock;
|
import net.neoforged.neoforge.fluids.IFluidBlock;
|
||||||
import net.neoforged.neoforge.registries.BuiltInRegistries;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -51,7 +50,6 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements
|
||||||
public static final int ENERGY_USE_PER_BLOCK = 650;
|
public static final int ENERGY_USE_PER_BLOCK = 650;
|
||||||
public static final int DEFAULT_RANGE = 2;
|
public static final int DEFAULT_RANGE = 2;
|
||||||
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 2000, 0);
|
public final CustomEnergyStorage storage = new CustomEnergyStorage(200000, 2000, 0);
|
||||||
public final LazyOptional<IEnergyStorage> lazyEnergy = LazyOptional.of(() -> this.storage);
|
|
||||||
public boolean onlyMineOres;
|
public boolean onlyMineOres;
|
||||||
public int checkX;
|
public int checkX;
|
||||||
public int checkY = -1;
|
public int checkY = -1;
|
||||||
|
@ -250,7 +248,7 @@ public class TileEntityVerticalDigger extends TileEntityInventoryBase implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnergyStorage getEnergyStorage(Direction facing) {
|
public IEnergyStorage getEnergyStorage(Direction facing) {
|
||||||
return this.lazyEnergy;
|
return this.storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -186,9 +186,9 @@ public final class WorldUtil {
|
||||||
//Everything else
|
//Everything else
|
||||||
try {
|
try {
|
||||||
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) level);
|
FakePlayer fake = FakePlayerFactory.getMinecraft((ServerLevel) level);
|
||||||
if (fake.connection == null) {
|
// if (fake.connection == null) {
|
||||||
fake.connection = new NetHandlerSpaghettiServer(fake);
|
// fake.connection = new NetHandlerSpaghettiServer(fake);
|
||||||
}
|
// }
|
||||||
//ItemStack heldBefore = fake.getMainHandItem();
|
//ItemStack heldBefore = fake.getMainHandItem();
|
||||||
setHandItemWithoutAnnoyingSound(fake, InteractionHand.MAIN_HAND, stack.copy());
|
setHandItemWithoutAnnoyingSound(fake, InteractionHand.MAIN_HAND, stack.copy());
|
||||||
BlockHitResult ray = new BlockHitResult(new Vec3(0.5, 0.5, 0.5), side.getOpposite(), offsetPos, true);
|
BlockHitResult ray = new BlockHitResult(new Vec3(0.5, 0.5, 0.5), side.getOpposite(), offsetPos, true);
|
||||||
|
|
Loading…
Reference in a new issue