Made dispenser behaviours 1.10 safe

This commit is contained in:
Vincent Lee committed 2016-06-24 18:55:41 -05:00
1 parent c6df7c260a
commit 6f348e7db1
4 files changed
+14 -12

No files matched your search

@@ -6,6 +6,7 @@ import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.common.block.ModBlocks;
@@ -21,7 +22,8 @@ public class BehaviourFelPumpkin extends BehaviorDefaultDispenseItem {
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
World world = source.getWorld();
BlockPos blockpos = source.getBlockPos().offset(BlockDispenser.getFacing(source.getBlockMetadata()));
EnumFacing facing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING);
BlockPos blockpos = source.getBlockPos().offset(facing);
Block blockpumpkin = ModBlocks.felPumpkin;
if (world.isAirBlock(blockpos) && world.getBlockState(blockpos.down()).getBlock() == Blocks.IRON_BARS
@@ -30,8 +30,8 @@ public class BehaviourPoolMinecart extends BehaviorDefaultDispenseItem {
@Nonnull
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
World world = source.getWorld();
EnumFacing enumfacing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING);
double d0 = source.getX() + enumfacing.getFrontOffsetX() * 1.125F;
double d1 = source.getY() + enumfacing.getFrontOffsetY() * 1.125F;
double d2 = source.getZ() + enumfacing.getFrontOffsetZ() * 1.125F;
@@ -31,10 +31,10 @@ public class BehaviourSeeds extends BehaviorDefaultDispenseItem {
@Nonnull
@Override
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
EnumFacing facing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
BlockPos pos = par1IBlockSource.getBlockPos().offset(facing);
World world = par1IBlockSource.getWorld();
public ItemStack dispenseStack(IBlockSource source, ItemStack par2ItemStack) {
World world = source.getWorld();
EnumFacing facing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
if(world.getBlockState(pos).getBlock().isAir(world.getBlockState(pos), world, pos) && block.canPlaceBlockAt(world, pos)) {
world.setBlockState(pos, block.getDefaultState());
@@ -42,7 +42,7 @@ public class BehaviourSeeds extends BehaviorDefaultDispenseItem {
return par2ItemStack;
}
return super.dispenseStack(par1IBlockSource, par2ItemStack);
return super.dispenseStack(source, par2ItemStack);
}
}
@@ -26,17 +26,17 @@ public class BehaviourWand extends BehaviorDefaultDispenseItem {
@Nonnull
@Override
protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
EnumFacing facing = BlockDispenser.getFacing(par1IBlockSource.getBlockMetadata());
BlockPos pos = par1IBlockSource.getBlockPos().offset(facing);
World world = par1IBlockSource.getWorld();
protected ItemStack dispenseStack(IBlockSource source, ItemStack par2ItemStack) {
World world = source.getWorld();
EnumFacing facing = world.getBlockState(source.getBlockPos()).getValue(BlockDispenser.FACING);
BlockPos pos = source.getBlockPos().offset(facing);
Block block = world.getBlockState(pos).getBlock();
if(block instanceof IWandable) {
((IWandable) block).onUsedByWand(null, par2ItemStack, world, pos, facing.getOpposite());
return par2ItemStack;
}
return super.dispenseStack(par1IBlockSource, par2ItemStack);
return super.dispenseStack(source, par2ItemStack);
}
}