From b1bc8cd3783090a6b206f894edf9ee992c5f1496 Mon Sep 17 00:00:00 2001 From: Raoul Van den Berge Date: Sun, 5 Jun 2016 12:55:23 +0200 Subject: [PATCH] Version increment to 0.7.9 + Fixed not being able to place sugar cane --- build.gradle | 2 +- .../java/refinedstorage/RefinedStorage.java | 2 +- .../refinedstorage/tile/TileConstructor.java | 59 +++++++++++-------- src/main/resources/mcmod.info | 2 +- 4 files changed, 36 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index 055603bce..37f51a502 100755 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ buildscript { } apply plugin: 'net.minecraftforge.gradle.forge' -version = "0.7.8" +version = "0.7.9" group = "refinedstorage" archivesBaseName = "refinedstorage" diff --git a/src/main/java/refinedstorage/RefinedStorage.java b/src/main/java/refinedstorage/RefinedStorage.java index 23435946c..9570f6b3d 100755 --- a/src/main/java/refinedstorage/RefinedStorage.java +++ b/src/main/java/refinedstorage/RefinedStorage.java @@ -19,7 +19,7 @@ import refinedstorage.proxy.CommonProxy; @Mod(modid = RefinedStorage.ID, version = RefinedStorage.VERSION) public final class RefinedStorage { public static final String ID = "refinedstorage"; - public static final String VERSION = "0.7.8"; + public static final String VERSION = "0.7.9"; public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(ID); diff --git a/src/main/java/refinedstorage/tile/TileConstructor.java b/src/main/java/refinedstorage/tile/TileConstructor.java index eb6b54e4d..5d7c74e82 100755 --- a/src/main/java/refinedstorage/tile/TileConstructor.java +++ b/src/main/java/refinedstorage/tile/TileConstructor.java @@ -3,7 +3,6 @@ package refinedstorage.tile; import io.netty.buffer.ByteBuf; import net.minecraft.block.Block; import net.minecraft.block.SoundType; -import net.minecraft.block.state.IBlockState; import net.minecraft.inventory.Container; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; @@ -32,7 +31,36 @@ public class TileConstructor extends TileMachine implements ICompareConfig { public static final int BASE_SPEED = 20; - private BasicItemHandler filter = new BasicItemHandler(1, this); + private BasicItemHandler filter = new BasicItemHandler(1, this) { + @Override + protected void onContentsChanged(int slot) { + super.onContentsChanged(slot); + + ItemStack stack = getStackInSlot(0); + + if (stack != null) { + Item item = stack.getItem(); + + if (item instanceof ItemBlockSpecial) { + try { + Field f = ((ItemBlockSpecial) item).getClass().getDeclaredField("block"); + f.setAccessible(true); + block = (Block) f.get(item); + } catch (IllegalAccessException e) { + // NO OP + } catch (NoSuchFieldException e) { + // NO OP + } + } else if (item instanceof ItemBlock) { + block = ((ItemBlock) item).getBlock(); + } else { + block = null; + } + } else { + block = null; + } + } + }; private BasicItemHandler upgrades = new BasicItemHandler( 4, this, @@ -41,6 +69,7 @@ public class TileConstructor extends TileMachine implements ICompareConfig { ); private int compare = 0; + private Block block; private CraftingTaskScheduler scheduler = new CraftingTaskScheduler(); @@ -51,32 +80,10 @@ public class TileConstructor extends TileMachine implements ICompareConfig { @Override public void updateMachine() { - if (ticks % RefinedStorageUtils.getSpeed(upgrades, BASE_SPEED, 4) == 0 && filter.getStackInSlot(0) != null) { + if (block != null && ticks % RefinedStorageUtils.getSpeed(upgrades, BASE_SPEED, 4) == 0) { BlockPos front = pos.offset(getDirection()); - IBlockState frontBlockState = worldObj.getBlockState(front); - if (!frontBlockState.getBlock().isAir(frontBlockState, worldObj, front)) { - return; - } - - Item item = filter.getStackInSlot(0).getItem(); - Block block = null; - - if (item instanceof ItemBlockSpecial) { - try { - Field f = ((ItemBlockSpecial) item).getClass().getDeclaredField("block"); - f.setAccessible(true); - block = (Block) f.get(item); - } catch (IllegalAccessException e) { - // NO OP - } catch (NoSuchFieldException e) { - // NO OP - } - } else if (item instanceof ItemBlock) { - block = ((ItemBlock) item).getBlock(); - } - - if (block != null && block.canPlaceBlockAt(worldObj, front)) { + if (worldObj.isAirBlock(front) && block.canPlaceBlockAt(worldObj, front)) { ItemStack took = controller.take(filter.getStackInSlot(0), 1, compare); if (took != null) { diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index d3fb832ef..09eb6c7bd 100755 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,7 +3,7 @@ "modid": "refinedstorage", "name": "Refined Storage", "description": "A Minecraft mod all about storage.", - "version": "0.7.8", + "version": "0.7.9", "mcversion": "1.9.4", "url": "", "updateUrl": "",