Commit 0ee8ab15 authored by primetoxinz's avatar primetoxinz

Fix serverside crash for Block Dispenser.

parent 9db1c428
......@@ -26,7 +26,7 @@ if (System.getenv().BUILD_NUMBER != null) {//adds the build number to the end of
}
minecraft {
version = "1.12.2-14.23.4.2725"
version = "1.12.2-14.23.4.2716"
runDir = "run"
mappings = "snapshot_20171125"
replace "%VERSION%": "${project.version}"
......
......@@ -10,6 +10,8 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.dispenser.IBlockSource;
import net.minecraft.dispenser.IPosition;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemBlockSpecial;
import net.minecraft.item.ItemSeeds;
......@@ -47,7 +49,7 @@ public class BehaviorDefaultDispenseBlock extends BehaviorDefaultDispenseItem {
if (stack.getItem() instanceof ItemBlock) {
ItemBlock itemblock = (ItemBlock) stack.getItem();
if (itemblock.canPlaceBlockOnSide(world, check, facing, fake, stack)) {
if (canPlaceBlockOnSide(itemblock, world, check, facing, fake, stack)) {
Block block = ((ItemBlock) stack.getItem()).getBlock();
boolean blockAcross = !world.isAirBlock(check.offset(facing));
IBlockState state = block.getStateForPlacement(world, check, facing, getX(facing, blockAcross), getY(facing, blockAcross), getZ(facing, blockAcross), stack.getItemDamage(), fake, fake.getActiveHand());
......@@ -84,4 +86,16 @@ public class BehaviorDefaultDispenseBlock extends BehaviorDefaultDispenseItem {
private float getZ(EnumFacing facing, boolean blockAcross) {
return facing == EnumFacing.WEST && blockAcross ? 0.9F : 0.1F;
}
public boolean canPlaceBlockOnSide(ItemBlock itemBlock, World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
Block block = worldIn.getBlockState(pos).getBlock();
if (block == Blocks.SNOW_LAYER && block.isReplaceable(worldIn, pos)) {
side = EnumFacing.UP;
} else if (!block.isReplaceable(worldIn, pos)) {
pos = pos.offset(side);
}
return worldIn.mayPlace(itemBlock.getBlock(), pos, false, side, null);
}
}
Subproject commit 41a7d947c33b1c855b94ede8b53779de0b749369
Subproject commit 68bd5253e1d7aa54f6c19b690079239c717a0c7f
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment