mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-10-25 20:22:30 +00:00
fix(fences): connection to logic
Fix ExtraTrees fences to connect correctly to other wooden fences and fence gates. Address issue: [Extra Trees fences are buggy #5694](https://github.com/GTNewHorizons/NewHorizons/issues/5694) Works even better with https://github.com/mitchej123/Hodgepodge/pull/2 witch patches vanilla fences to connect with other mod fences.
This commit is contained in:
3 files changed
+27
-26
No files matched your search
@@ -1,6 +1,5 @@
|
||||
package binnie.extratrees.block.decor;
|
||||
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.block.BlockMetadata;
|
||||
import binnie.core.block.IBlockMetadata;
|
||||
import binnie.core.block.TileEntityMetadata;
|
||||
@@ -19,7 +18,6 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -41,15 +39,6 @@ public class BlockFence extends net.minecraft.block.BlockFence implements IBlock
|
||||
setStepSound(Block.soundTypeWood);
|
||||
}
|
||||
|
||||
public static boolean canConnect(Block block) {
|
||||
return block == ((ItemBlock) Mods.forestry.item("fences")).field_150939_a
|
||||
|| block == Blocks.fence
|
||||
|| block == Blocks.fence_gate
|
||||
|| block == Blocks.nether_brick_fence
|
||||
|| block instanceof IBlockFence
|
||||
|| block == ExtraTrees.blockGate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for (IFenceProvider type : PlankType.ExtraTreePlanks.values()) {
|
||||
@@ -146,16 +135,10 @@ public class BlockFence extends net.minecraft.block.BlockFence implements IBlock
|
||||
|
||||
@Override
|
||||
public boolean canConnectFenceTo(IBlockAccess world, int x, int y, int z) {
|
||||
if (!isFence(world, x, y, z)) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block != null && block.getMaterial().isOpaque() && block.renderAsNormalBlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isFence(IBlockAccess world, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return canConnect(block);
|
||||
Material material = block.getMaterial();
|
||||
return IBlockFence.isFence(block) && material == this.blockMaterial
|
||||
|| material.isOpaque() && block.renderAsNormalBlock() && material != Material.gourd;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,10 +29,6 @@ public class BlockHedge extends Block implements IBlockFence {
|
||||
setBlockName("hedge");
|
||||
}
|
||||
|
||||
public static boolean func_149825_a(Block block) {
|
||||
return BlockFence.canConnect(block);
|
||||
}
|
||||
|
||||
public static int getColor(int meta) {
|
||||
LeafType type = LeafType.values()[meta % 6];
|
||||
if (type == LeafType.CONIFER) {
|
||||
@@ -130,11 +126,11 @@ public class BlockHedge extends Block implements IBlockFence {
|
||||
return ModuleBlocks.hedgeRenderID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectFenceTo(IBlockAccess world, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return block == this
|
||||
|| block == Blocks.fence_gate
|
||||
|| func_149825_a(block)
|
||||
|| IBlockFence.isFence(block)
|
||||
|| block.isLeaves(world, x, y, z)
|
||||
|| (block.getMaterial().isOpaque() && block.renderAsNormalBlock() && block.getMaterial() != Material.gourd);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,26 @@
|
||||
package binnie.extratrees.block.decor;
|
||||
|
||||
import binnie.core.Mods;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public interface IBlockFence {
|
||||
|
||||
/**
|
||||
* Test if the specified block is a fence
|
||||
*
|
||||
* @param block the block to test
|
||||
* @return {@code true} if the specified block is a fence
|
||||
*/
|
||||
static boolean isFence(Block block) {
|
||||
return block == ((ItemBlock) Mods.forestry.item("fences")).field_150939_a
|
||||
|| block instanceof BlockFence && block != Blocks.nether_brick_fence
|
||||
|| block instanceof BlockFenceGate;
|
||||
}
|
||||
|
||||
boolean canConnectFenceTo(IBlockAccess world, int x, int y, int z);
|
||||
}
|
||||
Reference in new issue
Block a user