Fixes
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
# Refined Storage Changelog
|
# Refined Storage Changelog
|
||||||
|
|
||||||
|
### 0.7.9
|
||||||
|
**Bugfixes**
|
||||||
|
- Fixed not being able to place sugar cane
|
||||||
|
- Fixed not being able to place seeds
|
||||||
|
|
||||||
### 0.7.8
|
### 0.7.8
|
||||||
**Bugfixes**
|
**Bugfixes**
|
||||||
- Updated to Forge 1951
|
- Updated to Forge 1951
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
package refinedstorage.container.slot;
|
package refinedstorage.container.slot;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemBlockSpecial;
|
import net.minecraft.item.ItemBlockSpecial;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.IBlockAccess;
|
||||||
|
import net.minecraftforge.common.IPlantable;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
import net.minecraftforge.items.SlotItemHandler;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class SlotSpecimen extends SlotItemHandler {
|
public class SlotSpecimen extends SlotItemHandler {
|
||||||
public static final int SPECIMEN_SIZE = 1;
|
public static final int SPECIMEN_SIZE = 1;
|
||||||
public static final int SPECIMEN_BLOCK = 2;
|
public static final int SPECIMEN_BLOCK = 2;
|
||||||
@@ -30,7 +38,7 @@ public class SlotSpecimen extends SlotItemHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(ItemStack stack) {
|
public boolean isItemValid(ItemStack stack) {
|
||||||
return isBlockOnly() ? (stack.getItem() instanceof ItemBlock || stack.getItem() instanceof ItemBlockSpecial) : true;
|
return isBlockOnly() ? (stack.getItem() instanceof ItemBlock || stack.getItem() instanceof ItemBlockSpecial || stack.getItem() instanceof IPlantable) : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -49,4 +57,28 @@ public class SlotSpecimen extends SlotItemHandler {
|
|||||||
public boolean isBlockOnly() {
|
public boolean isBlockOnly() {
|
||||||
return (flags & SPECIMEN_BLOCK) == SPECIMEN_BLOCK;
|
return (flags & SPECIMEN_BLOCK) == SPECIMEN_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IBlockState getBlockState(IBlockAccess world, BlockPos pos, ItemStack stack) {
|
||||||
|
if (stack != null) {
|
||||||
|
Item item = stack.getItem();
|
||||||
|
|
||||||
|
if (item instanceof ItemBlockSpecial) {
|
||||||
|
try {
|
||||||
|
Field f = ((ItemBlockSpecial) item).getClass().getDeclaredField("block");
|
||||||
|
f.setAccessible(true);
|
||||||
|
return ((Block) f.get(item)).getDefaultState();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
// NO OP
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
// NO OP
|
||||||
|
}
|
||||||
|
} else if (item instanceof ItemBlock) {
|
||||||
|
return (((ItemBlock) item).getBlock()).getDefaultState();
|
||||||
|
} else if (item instanceof IPlantable) {
|
||||||
|
return ((IPlantable) item).getPlant(world, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
package refinedstorage.tile;
|
package refinedstorage.tile;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.inventory.Container;
|
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.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
@@ -19,13 +16,12 @@ import refinedstorage.RefinedStorageItems;
|
|||||||
import refinedstorage.RefinedStorageUtils;
|
import refinedstorage.RefinedStorageUtils;
|
||||||
import refinedstorage.autocrafting.CraftingTaskScheduler;
|
import refinedstorage.autocrafting.CraftingTaskScheduler;
|
||||||
import refinedstorage.container.ContainerConstructor;
|
import refinedstorage.container.ContainerConstructor;
|
||||||
|
import refinedstorage.container.slot.SlotSpecimen;
|
||||||
import refinedstorage.inventory.BasicItemHandler;
|
import refinedstorage.inventory.BasicItemHandler;
|
||||||
import refinedstorage.inventory.BasicItemValidator;
|
import refinedstorage.inventory.BasicItemValidator;
|
||||||
import refinedstorage.item.ItemUpgrade;
|
import refinedstorage.item.ItemUpgrade;
|
||||||
import refinedstorage.tile.config.ICompareConfig;
|
import refinedstorage.tile.config.ICompareConfig;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
public class TileConstructor extends TileMachine implements ICompareConfig {
|
public class TileConstructor extends TileMachine implements ICompareConfig {
|
||||||
public static final String NBT_COMPARE = "Compare";
|
public static final String NBT_COMPARE = "Compare";
|
||||||
|
|
||||||
@@ -36,29 +32,7 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
|||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|
||||||
ItemStack stack = getStackInSlot(0);
|
block = SlotSpecimen.getBlockState(worldObj, pos.offset(getDirection()), 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(
|
private BasicItemHandler upgrades = new BasicItemHandler(
|
||||||
@@ -69,7 +43,7 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private int compare = 0;
|
private int compare = 0;
|
||||||
private Block block;
|
private IBlockState block;
|
||||||
|
|
||||||
private CraftingTaskScheduler scheduler = new CraftingTaskScheduler();
|
private CraftingTaskScheduler scheduler = new CraftingTaskScheduler();
|
||||||
|
|
||||||
@@ -83,14 +57,14 @@ public class TileConstructor extends TileMachine implements ICompareConfig {
|
|||||||
if (block != null && ticks % RefinedStorageUtils.getSpeed(upgrades, BASE_SPEED, 4) == 0) {
|
if (block != null && ticks % RefinedStorageUtils.getSpeed(upgrades, BASE_SPEED, 4) == 0) {
|
||||||
BlockPos front = pos.offset(getDirection());
|
BlockPos front = pos.offset(getDirection());
|
||||||
|
|
||||||
if (worldObj.isAirBlock(front) && block.canPlaceBlockAt(worldObj, front)) {
|
if (worldObj.isAirBlock(front) && block.getBlock().canPlaceBlockAt(worldObj, front)) {
|
||||||
ItemStack took = controller.take(filter.getStackInSlot(0), 1, compare);
|
ItemStack took = controller.take(filter.getStackInSlot(0), 1, compare);
|
||||||
|
|
||||||
if (took != null) {
|
if (took != null) {
|
||||||
scheduler.resetSchedule();
|
scheduler.resetSchedule();
|
||||||
worldObj.setBlockState(front, block.getStateFromMeta(took.getItemDamage()), 1 | 2);
|
worldObj.setBlockState(front, block.getBlock().getStateFromMeta(took.getMetadata()), 1 | 2);
|
||||||
// From ItemBlock.onItemUse
|
// From ItemBlock.onItemUse
|
||||||
SoundType blockSound = block.getSoundType();
|
SoundType blockSound = block.getBlock().getSoundType();
|
||||||
worldObj.playSound(null, front, blockSound.getPlaceSound(), SoundCategory.BLOCKS, (blockSound.getVolume() + 1.0F) / 2.0F, blockSound.getPitch() * 0.8F);
|
worldObj.playSound(null, front, blockSound.getPlaceSound(), SoundCategory.BLOCKS, (blockSound.getVolume() + 1.0F) / 2.0F, blockSound.getPitch() * 0.8F);
|
||||||
} else if (RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_CRAFTING)) {
|
} else if (RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_CRAFTING)) {
|
||||||
ItemStack craft = filter.getStackInSlot(0);
|
ItemStack craft = filter.getStackInSlot(0);
|
||||||
|
|||||||
Reference in New Issue
Block a user