Fixed not being able to place cake or string

This commit is contained in:
Raoul Van den Berge
2016-05-24 22:24:38 +02:00
parent 65561cef3b
commit b3bd96d9e1
5 changed files with 24 additions and 5 deletions

View File

@@ -54,7 +54,6 @@ public abstract class BlockMachine extends BlockBase {
super.neighborChanged(state, world, pos, block);
if (!world.isRemote) {
System.out.println("NeighbourChange");
((TileMachine) world.getTileEntity(pos)).searchController(world);
}
}

View File

@@ -2,6 +2,7 @@ package refinedstorage.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemBlockSpecial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler;
@@ -29,7 +30,7 @@ public class SlotSpecimen extends SlotItemHandler {
@Override
public boolean isItemValid(ItemStack stack) {
return isBlockOnly() ? (stack.getItem() instanceof ItemBlock) : true;
return isBlockOnly() ? (stack.getItem() instanceof ItemBlock || stack.getItem() instanceof ItemBlockSpecial) : true;
}
@Override

View File

@@ -78,7 +78,6 @@ public abstract class TileBase extends TileEntity implements ITickable {
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
System.out.println("READ FROM NBT " + pos);
if (tag.hasKey(NBT_UPDATE)) {
readUpdate(tag);
} else {

View File

@@ -4,7 +4,9 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemBlockSpecial;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
@@ -22,6 +24,8 @@ import refinedstorage.item.ItemUpgrade;
import refinedstorage.tile.autocrafting.task.CraftingTaskScheduler;
import refinedstorage.tile.config.ICompareConfig;
import java.lang.reflect.Field;
public class TileConstructor extends TileMachine implements ICompareConfig {
public static final String NBT_COMPARE = "Compare";
@@ -49,9 +53,24 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
if (ticks % RefinedStorageUtils.getSpeed(upgrades, BASE_SPEED, 4) == 0 && filter.getStackInSlot(0) != null) {
BlockPos front = pos.offset(getDirection());
Block block = ((ItemBlock) filter.getStackInSlot(0).getItem()).getBlock();
Item item = filter.getStackInSlot(0).getItem();
Block block = null;
if (block.canPlaceBlockAt(worldObj, front)) {
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)) {
ItemStack took = controller.take(filter.getStackInSlot(0).copy(), compare);
if (took != null) {