Fix use of Fuel Registry (it is null not, 0 for unregistered items).
Fix Vibration Chamber inventory filter. Fix Molecular Assembler inventory filter.
This commit is contained in:
@@ -18,22 +18,9 @@
|
||||
|
||||
package appeng.tile.misc;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import alexiil.mc.lib.attributes.Simulation;
|
||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||
|
||||
import alexiil.mc.lib.attributes.item.LimitedFixedItemInv;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
@@ -49,8 +36,17 @@ import appeng.tile.grid.AENetworkInvBlockEntity;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperFilteredItemHandler;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
import net.fabricmc.fabric.api.registry.FuelRegistry;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
||||
public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity implements IGridTickable {
|
||||
public static final double POWER_PER_TICK = 5;
|
||||
@@ -58,7 +54,7 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
public static final int MAX_BURN_SPEED = 200;
|
||||
public static final double DILATION_SCALING = 25.0; // x4 ~ 40 AE/t at max
|
||||
private final AppEngInternalInventory inv = new AppEngInternalInventory(this, 1);
|
||||
private final FixedItemInv invExt = new WrapperFilteredItemHandler(this.inv, new FuelSlotFilter());
|
||||
private final LimitedFixedItemInv invExt;
|
||||
|
||||
private int burnSpeed = 100;
|
||||
private double burnTime = 0;
|
||||
@@ -71,6 +67,11 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
super(tileEntityTypeIn);
|
||||
this.getProxy().setIdlePowerUsage(0);
|
||||
this.getProxy().setFlags();
|
||||
|
||||
invExt = inv.createLimitedFixedInv();
|
||||
invExt.getAllRule()
|
||||
.filterInserts(stack -> FuelRegistry.INSTANCE.get(stack.getItem()) != null)
|
||||
.filterExtracts(stack -> FuelRegistry.INSTANCE.get(stack.getItem()) == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,7 +124,7 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final FixedItemInv inv, final int slot, final InvOperation mc,
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
final ItemStack removed, final ItemStack added) {
|
||||
if (this.getBurnTime() <= 0) {
|
||||
if (this.canEatFuel()) {
|
||||
try {
|
||||
@@ -138,8 +139,8 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
private boolean canEatFuel() {
|
||||
final ItemStack is = this.inv.getInvStack(0);
|
||||
if (!is.isEmpty()) {
|
||||
final int newBurnTime = FuelRegistry.INSTANCE.get(is.getItem());
|
||||
if (newBurnTime > 0 && is.getCount() > 0) {
|
||||
final Integer newBurnTime = FuelRegistry.INSTANCE.get(is.getItem());
|
||||
if (newBurnTime != null && is.getCount() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -210,8 +211,8 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
private void eatFuel() {
|
||||
final ItemStack is = this.inv.getInvStack(0);
|
||||
if (!is.isEmpty()) {
|
||||
final int newBurnTime = FuelRegistry.INSTANCE.get(is.getItem());
|
||||
if (newBurnTime > 0 && is.getCount() > 0) {
|
||||
final Integer newBurnTime = FuelRegistry.INSTANCE.get(is.getItem());
|
||||
if (newBurnTime != null && is.getCount() > 0) {
|
||||
this.setBurnTime(this.getBurnTime() + newBurnTime);
|
||||
this.setMaxBurnTime(this.getBurnTime());
|
||||
|
||||
@@ -270,15 +271,4 @@ public class VibrationChamberBlockEntity extends AENetworkInvBlockEntity impleme
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
private static class FuelSlotFilter implements IAEItemFilter {
|
||||
@Override
|
||||
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
|
||||
return FuelRegistry.INSTANCE.get(inv.getInvStack(slot).getItem()) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
|
||||
return FuelRegistry.INSTANCE.get(stack.getItem()) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user