Finish fixing errors in apiimpl/network/node

This commit is contained in:
raoulvdberge
2019-08-29 16:07:13 +02:00
parent 8e1aa6738f
commit f5d9019517
12 changed files with 148 additions and 177 deletions

View File

@@ -5,6 +5,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.handler.IItemGridHandler
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache; import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener; import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener;
import com.raoulvdberge.refinedstorage.api.util.IFilter; import com.raoulvdberge.refinedstorage.api.util.IFilter;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.CraftResultInventory; import net.minecraft.inventory.CraftResultInventory;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
@@ -201,14 +202,14 @@ public interface IGrid {
* *
* @param player the player that crafted the item * @param player the player that crafted the item
*/ */
void onCrafted(ServerPlayerEntity player); void onCrafted(PlayerEntity player);
/** /**
* Called when an item is crafted with shift click (up to 64 items) in a crafting grid. * Called when an item is crafted with shift click (up to 64 items) in a crafting grid.
* *
* @param player the player that crafted the item * @param player the player that crafted the item
*/ */
void onCraftedShift(ServerPlayerEntity player); void onCraftedShift(PlayerEntity player);
/** /**
* Called when a JEI recipe transfer occurs. * Called when a JEI recipe transfer occurs.
@@ -216,14 +217,14 @@ public interface IGrid {
* @param player the player * @param player the player
* @param recipe a 9*x array stack array, where x is the possible combinations for the given slot * @param recipe a 9*x array stack array, where x is the possible combinations for the given slot
*/ */
void onRecipeTransfer(ServerPlayerEntity player, ItemStack[][] recipe); void onRecipeTransfer(PlayerEntity player, ItemStack[][] recipe);
/** /**
* Called when the grid is closed. * Called when the grid is closed.
* *
* @param player the player * @param player the player
*/ */
void onClosed(ServerPlayerEntity player); void onClosed(PlayerEntity player);
/** /**
* @return true if the grid is active, false otherwise * @return true if the grid is active, false otherwise

View File

@@ -12,12 +12,10 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTaskError;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode; import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.util.IComparer; import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.tile.TileController; import com.raoulvdberge.refinedstorage.tile.TileController;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
@@ -298,17 +296,13 @@ public class CraftingManager implements ICraftingManager {
return null; return null;
} }
private void throttle(@Nullable Object source) { private void throttle(Object source) {
OneSixMigrationHelper.removalHook(); // Remove @Nullable source
if (source != null) { if (source != null) {
throttledRequesters.put(source, System.currentTimeMillis()); throttledRequesters.put(source, System.currentTimeMillis());
} }
} }
private boolean isThrottled(@Nullable Object source) { private boolean isThrottled(Object source) {
OneSixMigrationHelper.removalHook(); // Remove @Nullable source
if (source == null) { if (source == null) {
return false; return false;
} }

View File

@@ -5,7 +5,6 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternContaine
import com.raoulvdberge.refinedstorage.api.util.IComparer; import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactory; import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactory;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.item.ItemPattern; import com.raoulvdberge.refinedstorage.item.ItemPattern;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
@@ -34,12 +33,6 @@ public class CraftingPattern implements ICraftingPattern {
private NonNullList<FluidStack> fluidOutputs = NonNullList.create(); private NonNullList<FluidStack> fluidOutputs = NonNullList.create();
public CraftingPattern(World world, ICraftingPatternContainer container, ItemStack stack) { public CraftingPattern(World world, ICraftingPatternContainer container, ItemStack stack) {
if (!OneSixMigrationHelper.isValidOneSixPattern(stack)) {
this.valid = false;
return;
}
this.container = container; this.container = container;
this.stack = stack; this.stack = stack;
this.processing = ItemPattern.isProcessing(stack); this.processing = ItemPattern.isProcessing(stack);

View File

@@ -23,11 +23,9 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryFl
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryItem;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFluid; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFluid;
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskItem; import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskItem;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -64,7 +62,7 @@ public class CraftingTask implements ICraftingTask {
private static final String NBT_PATTERN_STACK = "Stack"; private static final String NBT_PATTERN_STACK = "Stack";
private static final String NBT_PATTERN_CONTAINER_POS = "ContainerPos"; private static final String NBT_PATTERN_CONTAINER_POS = "ContainerPos";
private static final int DEFAULT_EXTRACT_FLAGS = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE; private static final int DEFAULT_EXTRACT_FLAGS = IComparer.COMPARE_NBT;
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
@@ -108,12 +106,6 @@ public class CraftingTask implements ICraftingTask {
} }
public CraftingTask(INetwork network, CompoundNBT tag) throws CraftingTaskReadException { public CraftingTask(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
OneSixMigrationHelper.removalHook();
if (!tag.contains(NBT_INTERNAL_STORAGE)) {
throw new CraftingTaskReadException("Couldn't read crafting task from before RS v1.6.4, skipping...");
}
this.network = network; this.network = network;
this.requested = API.instance().createCraftingRequestInfo(tag.getCompound(NBT_REQUESTED)); this.requested = API.instance().createCraftingRequestInfo(tag.getCompound(NBT_REQUESTED));
@@ -856,9 +848,9 @@ public class CraftingTask implements ICraftingTask {
toPerform.add(() -> { toPerform.add(() -> {
if (remainder == null) { if (remainder == null) {
internalStorage.extract(stack, stack.getCount(), IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, Action.PERFORM); internalStorage.extract(stack, stack.getCount(), IComparer.COMPARE_NBT, Action.PERFORM);
} else { } else {
internalStorage.extract(stack, stack.getCount() - remainder.getCount(), IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, Action.PERFORM); internalStorage.extract(stack, stack.getCount() - remainder.getCount(), IComparer.COMPARE_NBT, Action.PERFORM);
} }
}); });
} }
@@ -868,9 +860,9 @@ public class CraftingTask implements ICraftingTask {
toPerform.add(() -> { toPerform.add(() -> {
if (remainder == null) { if (remainder == null) {
internalFluidStorage.extract(stack, stack.getAmount(), IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, Action.PERFORM); internalFluidStorage.extract(stack, stack.getAmount(), IComparer.COMPARE_NBT, Action.PERFORM);
} else { } else {
internalFluidStorage.extract(stack, stack.getAmount() - remainder.getAmount(), IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, Action.PERFORM); internalFluidStorage.extract(stack, stack.getAmount() - remainder.getAmount(), IComparer.COMPARE_NBT, Action.PERFORM);
} }
}); });
} }

View File

@@ -15,36 +15,27 @@ import com.raoulvdberge.refinedstorage.tile.TileConstructor;
import com.raoulvdberge.refinedstorage.tile.config.IComparable; import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IType; import com.raoulvdberge.refinedstorage.tile.config.IType;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.block.Block; import net.minecraft.block.BlockState;
import net.minecraft.block.BlockSkull;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.state.IBlockState; import net.minecraft.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.Position;
import net.minecraft.dispenser.PositionImpl; import net.minecraft.entity.item.FireworkRocketEntity;
import net.minecraft.entity.item.EntityFireworkRocket; import net.minecraft.item.BlockItem;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.server.management.PlayerProfileCache; import net.minecraft.server.management.PlayerProfileCache;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.BlockSnapshot; import net.minecraftforge.common.util.BlockSnapshot;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper; import net.minecraftforge.items.wrapper.CombinedInvWrapper;
@@ -91,7 +82,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
if (type == IType.ITEMS && !itemFilters.getStackInSlot(0).isEmpty()) { if (type == IType.ITEMS && !itemFilters.getStackInSlot(0).isEmpty()) {
ItemStack item = itemFilters.getStackInSlot(0); ItemStack item = itemFilters.getStackInSlot(0);
IBlockState block = SlotFilter.getBlockState(world, pos.offset(getDirection()), item); BlockState block = SlotFilter.getBlockState(world, pos.offset(getDirection()), item);
if (block != null) { if (block != null) {
if (drop) { if (drop) {
@@ -100,23 +91,23 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
placeBlock(); placeBlock();
} }
} else { } else {
if (item.getItem() == Items.FIREWORKS && !drop) { if (item.getItem() == Items.FIREWORK_ROCKET && !drop) {
ItemStack took = network.extractItem(item, 1, Action.PERFORM); ItemStack took = network.extractItem(item, 1, Action.PERFORM);
if (took != null) { if (took != null) {
world.spawnEntity(new EntityFireworkRocket(world, getDispensePositionX(), getDispensePositionY(), getDispensePositionZ(), took)); world.addEntity(new FireworkRocketEntity(world, getDispensePositionX(), getDispensePositionY(), getDispensePositionZ(), took));
} }
} else { } else {
dropItem(); dropItem();
} }
} }
} else if (type == IType.FLUIDS && fluidFilters.getFluid(0) != null) { } else if (type == IType.FLUIDS && fluidFilters.getFluid(0) != null) {
FluidStack stack = fluidFilters.getFluid(0); /*TODO FluidStack stack = fluidFilters.getFluid(0);
if (stack != null && stack.getFluid().canBePlacedInWorld()) { if (stack != null && stack.getFluid().getAttributes().canBePlacedInWorld()) {
BlockPos front = pos.offset(getDirection()); BlockPos front = pos.offset(getDirection());
Block block = stack.getFluid().getBlock(); Block block = stack.getFluid().getAttributes();
if (world.isAirBlock(front) && block.canPlaceBlockAt(world, front)) { if (world.isAirBlock(front) && block.canPlaceBlockAt(world, front)) {
FluidStack stored = network.getFluidStorageCache().getList().get(stack, compare); FluidStack stored = network.getFluidStorageCache().getList().get(stack, compare);
@@ -143,25 +134,30 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
network.getCraftingManager().request(this, stack, Fluid.BUCKET_VOLUME); network.getCraftingManager().request(this, stack, Fluid.BUCKET_VOLUME);
} }
} }
} }*/
} }
} }
} }
private FakePlayer getFakePlayer() { private FakePlayer getFakePlayer() {
WorldServer world = (WorldServer) this.world; ServerWorld world = (ServerWorld) this.world;
UUID owner = getOwner(); UUID owner = getOwner();
if (owner != null) { if (owner != null) {
PlayerProfileCache profileCache = world.getMinecraftServer().getPlayerProfileCache(); PlayerProfileCache profileCache = world.getServer().getPlayerProfileCache();
GameProfile profile = profileCache.getProfileByUUID(owner); GameProfile profile = profileCache.getProfileByUUID(owner);
if (profile != null) { if (profile != null) {
return FakePlayerFactory.get(world, profile); return FakePlayerFactory.get(world, profile);
} }
} }
return FakePlayerFactory.getMinecraft(world); return FakePlayerFactory.getMinecraft(world);
} }
private boolean canPlace(BlockPos pos, IBlockState state) { private boolean canPlace(BlockPos pos, BlockState state) {
BlockEvent.EntityPlaceEvent e = new BlockEvent.EntityPlaceEvent(new BlockSnapshot(world, pos, state), world.getBlockState(pos), getFakePlayer()); BlockEvent.EntityPlaceEvent e = new BlockEvent.EntityPlaceEvent(new BlockSnapshot(world, pos, state), world.getBlockState(pos), getFakePlayer());
return !MinecraftForge.EVENT_BUS.post(e); return !MinecraftForge.EVENT_BUS.post(e);
@@ -175,10 +171,11 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
ItemStack took = network.extractItem(item, 1, compare, Action.SIMULATE); ItemStack took = network.extractItem(item, 1, compare, Action.SIMULATE);
if (took != null) { if (took != null) {
IBlockState state = SlotFilter.getBlockState(world, front, took); BlockState state = SlotFilter.getBlockState(world, front, took);
if (state != null && world.isAirBlock(front) && state.getBlock().canPlaceBlockAt(world, front)) { // TODO if (state != null && world.isAirBlock(front) && state.getBlock().canPlaceBlockAt(world, front)) {
state = state.getBlock().getStateForPlacement(world, front, getDirection(), 0.5F, 0.5F, 0.5F, took.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) world), EnumHand.MAIN_HAND); if (false) {
// TODO state = state.getBlock().getStateForPlacement(world, front, getDirection(), 0.5F, 0.5F, 0.5F, took.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) world), EnumHand.MAIN_HAND);
if (!canPlace(front, state)) { if (!canPlace(front, state)) {
return; return;
@@ -187,8 +184,8 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
took = network.extractItem(item, 1, compare, Action.PERFORM); took = network.extractItem(item, 1, compare, Action.PERFORM);
if (took != null) { if (took != null) {
if (item.getItem() instanceof ItemBlock) { if (item.getItem() instanceof BlockItem) {
((ItemBlock) item.getItem()).placeBlockAt( /*((BlockItem) item.getItem()).tryPlace(new BlockItemUseContext(
took, took,
getFakePlayer(), getFakePlayer(),
world, world,
@@ -198,24 +195,25 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
0, 0,
0, 0,
state state
); )); TODO! */
} else { } else {
world.setBlockState(front, state, 1 | 2); world.setBlockState(front, state, 1 | 2);
state.getBlock().onBlockPlacedBy(world, front, state, FakePlayerFactory.getMinecraft((WorldServer) world), took); state.getBlock().onBlockPlacedBy(world, front, state, FakePlayerFactory.getMinecraft((ServerWorld) world), took);
} }
// From ItemBlock#onItemUse // From ItemBlock#onItemUse
SoundType blockSound = state.getBlock().getSoundType(state, world, pos, null); SoundType blockSound = state.getBlock().getSoundType(state, world, pos, null);
world.playSound(null, front, blockSound.getPlaceSound(), SoundCategory.BLOCKS, (blockSound.getVolume() + 1.0F) / 2.0F, blockSound.getPitch() * 0.8F); world.playSound(null, front, blockSound.getPlaceSound(), SoundCategory.BLOCKS, (blockSound.getVolume() + 1.0F) / 2.0F, blockSound.getPitch() * 0.8F);
/* TODO
if (state.getBlock() == Blocks.SKULL) { if (state.getBlock() == Blocks.SKULL) {
world.setBlockState(front, world.getBlockState(front).withProperty(BlockSkull.FACING, getDirection())); world.setBlockState(front, world.getBlockState(front).withProperty(BlockSkull.FACING, getDirection()));
TileEntity tile = world.getTileEntity(front); TileEntity tile = world.getTileEntity(front);
if (tile instanceof TileEntitySkull) { if (tile instanceof SkullTileEntity) {
TileEntitySkull skullTile = (TileEntitySkull) tile; SkullTileEntity skullTile = (SkullTileEntity) tile;
if (item.getItemDamage() == 3) { if (item.getItemDamage() == 3) {
GameProfile playerInfo = null; GameProfile playerInfo = null;
@@ -237,7 +235,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
Blocks.SKULL.checkWitherSpawn(world, front, skullTile); Blocks.SKULL.checkWitherSpawn(world, front, skullTile);
} }
} }*/
} }
} }
} else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) { } else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
@@ -251,7 +249,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
ItemStack took = network.extractItem(itemFilters.getStackInSlot(0), upgrades.getItemInteractCount(), Action.PERFORM); ItemStack took = network.extractItem(itemFilters.getStackInSlot(0), upgrades.getItemInteractCount(), Action.PERFORM);
if (took != null) { if (took != null) {
BehaviorDefaultDispenseItem.doDispense(world, took, 6, getDirection(), new PositionImpl(getDispensePositionX(), getDispensePositionY(), getDispensePositionZ())); DefaultDispenseItemBehavior.doDispense(world, took, 6, getDirection(), new Position(getDispensePositionX(), getDispensePositionY(), getDispensePositionZ()));
} else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) { } else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
ItemStack craft = itemFilters.getStackInSlot(0); ItemStack craft = itemFilters.getStackInSlot(0);

View File

@@ -5,7 +5,6 @@ import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.api.util.Action; import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.api.util.IComparer; import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager; import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory; import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerUpgrade; import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerUpgrade;
@@ -17,37 +16,26 @@ import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
import com.raoulvdberge.refinedstorage.tile.config.IType; import com.raoulvdberge.refinedstorage.tile.config.IType;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockLiquid; import net.minecraft.block.BlockState;
import net.minecraft.block.BlockShulkerBox;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.ItemEntity;
import net.minecraft.inventory.InventoryHelper; import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.server.management.PlayerProfileCache; import net.minecraft.server.management.PlayerProfileCache;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityShulkerBox;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.Constants;
import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidBlock;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.wrappers.BlockLiquidWrapper;
import net.minecraftforge.fluids.capability.wrappers.FluidBlockWrapper;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper; import net.minecraftforge.items.wrapper.CombinedInvWrapper;
@@ -74,7 +62,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_SILK_TOUCH, ItemUpgrade.TYPE_FORTUNE_1, ItemUpgrade.TYPE_FORTUNE_2, ItemUpgrade.TYPE_FORTUNE_3); private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_SILK_TOUCH, ItemUpgrade.TYPE_FORTUNE_1, ItemUpgrade.TYPE_FORTUNE_2, ItemUpgrade.TYPE_FORTUNE_3);
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE; private int compare = IComparer.COMPARE_NBT;
private int mode = IFilterable.BLACKLIST; private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS; private int type = IType.ITEMS;
private boolean pickupItem = false; private boolean pickupItem = false;
@@ -91,15 +79,20 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
} }
private FakePlayer getFakePlayer() { private FakePlayer getFakePlayer() {
WorldServer world = (WorldServer) this.world; ServerWorld world = (ServerWorld) this.world;
UUID owner = getOwner(); UUID owner = getOwner();
if (owner != null) { if (owner != null) {
PlayerProfileCache profileCache = world.getMinecraftServer().getPlayerProfileCache(); PlayerProfileCache profileCache = world.getServer().getPlayerProfileCache();
GameProfile profile = profileCache.getProfileByUUID(owner); GameProfile profile = profileCache.getProfileByUUID(owner);
if (profile != null) { if (profile != null) {
return FakePlayerFactory.get(world, profile); return FakePlayerFactory.get(world, profile);
} }
} }
return FakePlayerFactory.getMinecraft(world); return FakePlayerFactory.getMinecraft(world);
} }
@@ -113,29 +106,30 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
if (pickupItem && type == IType.ITEMS) { if (pickupItem && type == IType.ITEMS) {
List<Entity> droppedItems = new ArrayList<>(); List<Entity> droppedItems = new ArrayList<>();
Chunk chunk = world.getChunk(front); Chunk chunk = world.getChunkAt(front);
chunk.getEntitiesWithinAABBForEntity(null, new AxisAlignedBB(front), droppedItems, null); chunk.getEntitiesWithinAABBForEntity(null, new AxisAlignedBB(front), droppedItems, null);
for (Entity entity : droppedItems) { for (Entity entity : droppedItems) {
if (entity instanceof EntityItem) { if (entity instanceof ItemEntity) {
ItemStack droppedItem = ((EntityItem) entity).getItem(); ItemStack droppedItem = ((ItemEntity) entity).getItem();
if (IFilterable.acceptsItem(itemFilters, mode, compare, droppedItem) && network.insertItem(droppedItem, droppedItem.getCount(), Action.SIMULATE) == null) { if (IFilterable.acceptsItem(itemFilters, mode, compare, droppedItem) && network.insertItem(droppedItem, droppedItem.getCount(), Action.SIMULATE) == null) {
network.insertItemTracked(droppedItem.copy(), droppedItem.getCount()); network.insertItemTracked(droppedItem.copy(), droppedItem.getCount());
world.removeEntity(entity); // TODO world.removeEntity(entity);
break; break;
} }
} }
} }
} else if (type == IType.ITEMS) { } else if (type == IType.ITEMS) {
IBlockState frontBlockState = world.getBlockState(front); BlockState frontBlockState = world.getBlockState(front);
Block frontBlock = frontBlockState.getBlock(); Block frontBlock = frontBlockState.getBlock();
ItemStack frontStack = frontBlock.getPickBlock( ItemStack frontStack = frontBlock.getPickBlock(
frontBlockState, frontBlockState,
new RayTraceResult(new Vec3d(pos.getX(), pos.getY(), pos.getZ()), getDirection().getOpposite()), null,
// TODO new BlockRayTraceResult(new Vec3d(pos.getX(), pos.getY(), pos.getZ()), getDirection().getOpposite()),
world, world,
front, front,
getFakePlayer() getFakePlayer()
@@ -145,7 +139,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
if (IFilterable.acceptsItem(itemFilters, mode, compare, frontStack) && frontBlockState.getBlockHardness(world, front) != -1.0) { if (IFilterable.acceptsItem(itemFilters, mode, compare, frontStack) && frontBlockState.getBlockHardness(world, front) != -1.0) {
NonNullList<ItemStack> drops = NonNullList.create(); NonNullList<ItemStack> drops = NonNullList.create();
if (frontBlock instanceof BlockShulkerBox) { /* TODO if (frontBlock instanceof ShulkerBoxTileEntity) {
drops.add(((BlockShulkerBox) frontBlock).getItem(world, front, frontBlockState)); drops.add(((BlockShulkerBox) frontBlock).getItem(world, front, frontBlockState));
TileEntity shulkerBoxTile = world.getTileEntity(front); TileEntity shulkerBoxTile = world.getTileEntity(front);
@@ -159,7 +153,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
drops.add(frontStack); drops.add(frontStack);
} else { } else {
frontBlock.getDrops(drops, world, front, frontBlockState, upgrades.getFortuneLevel()); frontBlock.getDrops(drops, world, front, frontBlockState, upgrades.getFortuneLevel());
} }*/
for (ItemStack drop : drops) { for (ItemStack drop : drops) {
if (network.insertItem(drop, drop.getCount(), Action.SIMULATE) != null) { if (network.insertItem(drop, drop.getCount(), Action.SIMULATE) != null) {
@@ -171,7 +165,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
if (!MinecraftForge.EVENT_BUS.post(e)) { if (!MinecraftForge.EVENT_BUS.post(e)) {
world.playEvent(null, 2001, front, Block.getStateId(frontBlockState)); world.playEvent(null, 2001, front, Block.getStateId(frontBlockState));
world.setBlockToAir(front); world.removeBlock(front, false);
for (ItemStack drop : drops) { for (ItemStack drop : drops) {
// We check if the controller isn't null here because when a destructor faces a node and removes it // We check if the controller isn't null here because when a destructor faces a node and removes it
@@ -189,7 +183,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
Block frontBlock = world.getBlockState(front).getBlock(); Block frontBlock = world.getBlockState(front).getBlock();
IFluidHandler handler = null; IFluidHandler handler = null;
/* TODO
if (frontBlock instanceof BlockLiquid) { if (frontBlock instanceof BlockLiquid) {
handler = new BlockLiquidWrapper((BlockLiquid) frontBlock, world, front); handler = new BlockLiquidWrapper((BlockLiquid) frontBlock, world, front);
} else if (frontBlock instanceof IFluidBlock) { } else if (frontBlock instanceof IFluidBlock) {
@@ -204,7 +198,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
network.insertFluidTracked(drained, drained.amount); network.insertFluidTracked(drained, drained.amount);
} }
} }*/
} }
} }
} }
@@ -301,8 +295,6 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
if (tag.contains(NBT_FLUID_FILTERS)) { if (tag.contains(NBT_FLUID_FILTERS)) {
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS)); fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
} }
OneSixMigrationHelper.migrateEmptyWhitelistToEmptyBlacklist(version, this, itemFilters);
} }
public IItemHandler getUpgrades() { public IItemHandler getUpgrades() {

View File

@@ -20,9 +20,10 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.templates.FluidTank;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.CombinedInvWrapper; import net.minecraftforge.items.wrapper.CombinedInvWrapper;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@@ -59,12 +60,6 @@ public class NetworkNodeFluidInterface extends NetworkNode {
public NetworkNodeFluidInterface(World world, BlockPos pos) { public NetworkNodeFluidInterface(World world, BlockPos pos) {
super(world, pos); super(world, pos);
tankIn.setCanDrain(false);
tankIn.setCanFill(true);
tankOut.setCanDrain(true);
tankOut.setCanFill(false);
} }
@Override @Override
@@ -77,24 +72,24 @@ public class NetworkNodeFluidInterface extends NetworkNode {
if (!container.isEmpty()) { if (!container.isEmpty()) {
Pair<ItemStack, FluidStack> result = StackUtils.getFluid(container, true); Pair<ItemStack, FluidStack> result = StackUtils.getFluid(container, true);
if (result.getValue() != null && tankIn.fillInternal(result.getValue(), false) == result.getValue().amount) { if (result.getValue() != null && tankIn.fill(result.getValue(), IFluidHandler.FluidAction.SIMULATE) == result.getValue().getAmount()) {
result = StackUtils.getFluid(container, false); result = StackUtils.getFluid(container, false);
tankIn.fillInternal(result.getValue(), true); tankIn.fill(result.getValue(), IFluidHandler.FluidAction.EXECUTE);
in.setStackInSlot(0, result.getLeft()); in.setStackInSlot(0, result.getLeft());
} }
} }
if (ticks % upgrades.getSpeed() == 0) { if (ticks % upgrades.getSpeed() == 0) {
FluidStack drained = tankIn.drainInternal(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), true); FluidStack drained = tankIn.drain(FluidAttributes.BUCKET_VOLUME * upgrades.getItemInteractCount(), IFluidHandler.FluidAction.EXECUTE);
// Drain in tank // Drain in tank
if (drained != null) { if (drained != null) {
FluidStack remainder = network.insertFluidTracked(drained, drained.amount); FluidStack remainder = network.insertFluidTracked(drained, drained.getAmount());
if (remainder != null) { if (remainder != null) {
tankIn.fillInternal(remainder, true); tankIn.fill(remainder, IFluidHandler.FluidAction.EXECUTE);
} }
} }
} }
@@ -104,16 +99,16 @@ public class NetworkNodeFluidInterface extends NetworkNode {
if (wanted == null) { if (wanted == null) {
if (got != null) { if (got != null) {
tankOut.setFluid(network.insertFluidTracked(got, got.amount)); tankOut.setFluid(network.insertFluidTracked(got, got.getAmount()));
onTankOutChanged(); onTankOutChanged();
} }
} else if (got != null && !API.instance().getComparer().isEqual(wanted, got, IComparer.COMPARE_NBT)) { } else if (got != null && !API.instance().getComparer().isEqual(wanted, got, IComparer.COMPARE_NBT)) {
tankOut.setFluid(network.insertFluidTracked(got, got.amount)); tankOut.setFluid(network.insertFluidTracked(got, got.getAmount()));
onTankOutChanged(); onTankOutChanged();
} else { } else {
int delta = got == null ? wanted.amount : (wanted.amount - got.amount); int delta = got == null ? wanted.getAmount() : (wanted.getAmount() - got.getAmount());
if (delta > 0) { if (delta > 0) {
final boolean actingAsStorage = isActingAsStorage(); final boolean actingAsStorage = isActingAsStorage();
@@ -133,7 +128,7 @@ public class NetworkNodeFluidInterface extends NetworkNode {
if (tankOut.getFluid() == null) { if (tankOut.getFluid() == null) {
tankOut.setFluid(result); tankOut.setFluid(result);
} else { } else {
tankOut.getFluid().amount += result.amount; tankOut.getFluid().grow(result.getAmount());
} }
onTankOutChanged(); onTankOutChanged();
@@ -141,7 +136,7 @@ public class NetworkNodeFluidInterface extends NetworkNode {
// Example: our delta is 5, we extracted 3 fluids. // Example: our delta is 5, we extracted 3 fluids.
// That means we still have to autocraft 2 fluids. // That means we still have to autocraft 2 fluids.
delta -= result == null ? 0 : result.amount; delta -= result == null ? 0 : result.getAmount();
if (delta > 0 && upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) { if (delta > 0 && upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
network.getCraftingManager().request(this, wanted, delta); network.getCraftingManager().request(this, wanted, delta);
@@ -150,9 +145,9 @@ public class NetworkNodeFluidInterface extends NetworkNode {
FluidStack remainder = network.insertFluidTracked(got, Math.abs(delta)); FluidStack remainder = network.insertFluidTracked(got, Math.abs(delta));
if (remainder == null) { if (remainder == null) {
tankOut.getFluid().amount -= Math.abs(delta); tankOut.getFluid().shrink(Math.abs(delta));
} else { } else {
tankOut.getFluid().amount -= Math.abs(delta) - remainder.amount; tankOut.getFluid().shrink(Math.abs(delta) - remainder.getAmount());
} }
onTankOutChanged(); onTankOutChanged();
@@ -162,7 +157,7 @@ public class NetworkNodeFluidInterface extends NetworkNode {
} }
private boolean isActingAsStorage() { private boolean isActingAsStorage() {
for (Direction facing : Direction.VALUES) { for (Direction facing : Direction.values()) {
INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing)); INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing));
if (facingNode instanceof NetworkNodeExternalStorage && if (facingNode instanceof NetworkNodeExternalStorage &&

View File

@@ -28,24 +28,23 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid; import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.*; import net.minecraft.inventory.CraftResultInventory;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.NonNullList; import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
@@ -412,7 +411,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
if (!found) { if (!found) {
for (ItemStack possibility : possibilities) { for (ItemStack possibility : possibilities) {
for (int j = 0; j < player.inventory.getSizeInventory(); ++j) { for (int j = 0; j < player.inventory.getSizeInventory(); ++j) {
if (API.instance().getComparer().isEqual(possibility, player.inventory.getStackInSlot(j), IComparer.COMPARE_NBT | (possibility.getItem().isDamageable() ? 0 : IComparer.COMPARE_DAMAGE))) { if (API.instance().getComparer().isEqual(possibility, player.inventory.getStackInSlot(j), IComparer.COMPARE_NBT)) {
grid.getCraftingMatrix().setInventorySlotContents(i, ItemHandlerHelper.copyStackWithSize(player.inventory.getStackInSlot(j), 1)); grid.getCraftingMatrix().setInventorySlotContents(i, ItemHandlerHelper.copyStackWithSize(player.inventory.getStackInSlot(j), 1));
player.inventory.decrStackSize(j, 1); player.inventory.decrStackSize(j, 1);
@@ -461,11 +460,12 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
} }
public static void onCrafted(IGridNetworkAware grid, World world, PlayerEntity player) { public static void onCrafted(IGridNetworkAware grid, World world, PlayerEntity player) {
NonNullList<ItemStack> remainder = CraftingManager.getRemainingItems(grid.getCraftingMatrix(), world); // TODO: NonNullList<ItemStack> remainder = CraftingManager.getRemainingItems(grid.getCraftingMatrix(), world);
NonNullList<ItemStack> remainder = NonNullList.create();
INetwork network = grid.getNetwork(); INetwork network = grid.getNetwork();
InventoryCrafting matrix = grid.getCraftingMatrix(); CraftingInventory matrix = grid.getCraftingMatrix();
for (int i = 0; i < grid.getCraftingMatrix().getSizeInventory(); ++i) { for (int i = 0; i < grid.getCraftingMatrix().getSizeInventory(); ++i) {
ItemStack slot = matrix.getStackInSlot(i); ItemStack slot = matrix.getStackInSlot(i);
@@ -537,7 +537,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
} }
} }
FMLCommonHandler.instance().firePlayerCraftingEvent(player, ItemHandlerHelper.copyStackWithSize(crafted, craftedItems), grid.getCraftingMatrix()); // TODO FMLCommonHandler.instance().firePlayerCraftingEvent(player, ItemHandlerHelper.copyStackWithSize(crafted, craftedItems), grid.getCraftingMatrix());
} }
public void onCreatePattern() { public void onCreatePattern() {

View File

@@ -7,18 +7,11 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCable; import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCable;
import com.raoulvdberge.refinedstorage.item.ItemCover; import com.raoulvdberge.refinedstorage.item.ItemCover;
import net.minecraft.block.Block; import net.minecraft.block.*;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.BlockStainedGlass;
import net.minecraft.block.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT; import net.minecraft.nbt.ListNBT;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.items.IItemHandlerModifiable; import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler; import net.minecraftforge.items.ItemStackHandler;
@@ -155,15 +148,16 @@ public class CoverManager {
BlockState state = getBlockState(item); BlockState state = getBlockState(item);
return block != null && state != null && ((isModelSupported(state) && block.isTopSolid(state) && !block.getTickRandomly() && !block.hasTileEntity(state)) || block instanceof BlockGlass || block instanceof BlockStainedGlass); // TODO: block.isSolid was isTopSolid! correct?
return block != null && state != null && ((isModelSupported(state) && block.isSolid(state) && !block.ticksRandomly(state) && !block.hasTileEntity(state)) || block instanceof GlassBlock || block instanceof StainedGlassBlock);
} }
private static boolean isModelSupported(IBlockState state) { private static boolean isModelSupported(BlockState state) {
if (state.getRenderType() != EnumBlockRenderType.MODEL || state instanceof IExtendedBlockState) { if (state.getRenderType() != BlockRenderType.MODEL) {
return false; return false;
} }
return state.isFullCube(); return state.isSolid(); // TODO: correct? was isFullCube
} }
@Nullable @Nullable
@@ -191,7 +185,7 @@ public class CoverManager {
} }
try { try {
return block.getStateFromMeta(item.getItem().getMetadata(item)); return block.getDefaultState(); // TODO: is still correct?
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }

View File

@@ -1,11 +1,13 @@
package com.raoulvdberge.refinedstorage.container.slot.filter; package com.raoulvdberge.refinedstorage.container.slot.filter;
import com.raoulvdberge.refinedstorage.container.slot.SlotBase; import com.raoulvdberge.refinedstorage.container.slot.SlotBase;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.BlockState;
import net.minecraft.init.Blocks; import net.minecraft.item.BlockItem;
import net.minecraft.item.*; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SkullItem;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.IPlantable;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@@ -32,7 +34,8 @@ public class SlotFilter extends SlotBase {
public boolean isItemValid(@Nonnull ItemStack stack) { public boolean isItemValid(@Nonnull ItemStack stack) {
if (super.isItemValid(stack)) { if (super.isItemValid(stack)) {
if (isBlockAllowed()) { if (isBlockAllowed()) {
return stack.getItem() instanceof ItemBlock || stack.getItem() instanceof ItemBlockSpecial || stack.getItem() instanceof IPlantable || stack.getItem() instanceof ItemSkull; // TODO!
return stack.getItem() instanceof BlockItem || /*stack.getItem() instanceof ItemBlockSpecial ||*/ stack.getItem() instanceof IPlantable || stack.getItem() instanceof SkullItem;
} }
return true; return true;
@@ -59,18 +62,20 @@ public class SlotFilter extends SlotBase {
} }
@Nullable @Nullable
public static IBlockState getBlockState(IBlockAccess world, BlockPos pos, @Nullable ItemStack stack) { public static BlockState getBlockState(World world, BlockPos pos, @Nullable ItemStack stack) {
if (stack != null) { if (stack != null) {
Item item = stack.getItem(); Item item = stack.getItem();
if (item instanceof ItemBlockSpecial) { // TODO if (item instanceof ItemBlockSpecial) {
return ((ItemBlockSpecial) item).getBlock().getDefaultState(); // return ((ItemBlockSpecial) item).getBlock().getDefaultState();
} else if (item instanceof ItemBlock) { /*} else*/
return (((ItemBlock) item).getBlock()).getDefaultState(); /*if (item instanceof SkullItem) {
return Blocks.SKELETON_SKULL.getDefaultState();
} else */
if (item instanceof BlockItem) {
return (((BlockItem) item).getBlock()).getDefaultState();
} else if (item instanceof IPlantable) { } else if (item instanceof IPlantable) {
return ((IPlantable) item).getPlant(world, pos); return ((IPlantable) item).getPlant(world, pos);
} else if (item instanceof ItemSkull) {
return Blocks.SKULL.getDefaultState();
} }
} }

View File

@@ -1,46 +1,56 @@
package com.raoulvdberge.refinedstorage.inventory.fluid; package com.raoulvdberge.refinedstorage.inventory.fluid;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.capability.FluidTankPropertiesWrapper;
import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fluids.capability.templates.FluidTank;
import javax.annotation.Nullable; import javax.annotation.Nonnull;
public class FluidHandlerProxy implements IFluidHandler { public class FluidHandlerProxy implements IFluidHandler {
private FluidTank insertHandler; private FluidTank insertHandler;
private FluidTank extractHandler; private FluidTank extractHandler;
private IFluidTankProperties[] properties;
public FluidHandlerProxy(FluidTank insertHandler, FluidTank extractHandler) { public FluidHandlerProxy(FluidTank insertHandler, FluidTank extractHandler) {
this.insertHandler = insertHandler; this.insertHandler = insertHandler;
this.extractHandler = extractHandler; this.extractHandler = extractHandler;
this.properties = new IFluidTankProperties[]{
new FluidTankPropertiesWrapper(insertHandler),
new FluidTankPropertiesWrapper(extractHandler)
};
} }
@Override @Override
public IFluidTankProperties[] getTankProperties() { public int getTanks() {
return properties; return 2;
}
@Nonnull
@Override
public FluidStack getFluidInTank(int tank) {
return tank == 0 ? insertHandler.getFluidInTank(0) : extractHandler.getFluidInTank(0);
} }
@Override @Override
public int fill(FluidStack resource, boolean doFill) { public int getTankCapacity(int tank) {
return insertHandler.fill(resource, doFill); return tank == 0 ? insertHandler.getTankCapacity(0) : extractHandler.getTankCapacity(0);
} }
@Nullable
@Override @Override
public FluidStack drain(FluidStack resource, boolean doDrain) { public boolean isFluidValid(int tank, @Nonnull FluidStack stack) {
return extractHandler.drain(resource, doDrain); return tank == 0 ? insertHandler.isFluidValid(0, stack) : extractHandler.isFluidValid(0, stack);
} }
@Nullable
@Override @Override
public FluidStack drain(int maxDrain, boolean doDrain) { public int fill(FluidStack resource, FluidAction action) {
return extractHandler.drain(maxDrain, doDrain); return insertHandler.fill(resource, action);
}
@Nonnull
@Override
public FluidStack drain(FluidStack resource, FluidAction action) {
return extractHandler.drain(resource, action);
}
@Nonnull
@Override
public FluidStack drain(int maxDrain, FluidAction action) {
return extractHandler.drain(maxDrain, action);
} }
} }

View File

@@ -46,14 +46,11 @@ import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter; import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import com.raoulvdberge.refinedstorage.util.WorldUtils; import com.raoulvdberge.refinedstorage.util.WorldUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;