From b36e5c26238f9911f69241c4b084cf0fd1919e0a Mon Sep 17 00:00:00 2001 From: malte0811 Date: Tue, 21 Mar 2017 18:12:09 +0100 Subject: [PATCH] General refactoring, IC2 connectors no longer use BlockIEBase! --- build.gradle | 2 +- changelog.md | 2 + .../industrialWires/blocks/BlockIWBase.java | 184 ++++++++++++++++++ .../blocks/BlockJacobsLadder.java | 103 +--------- .../blocks/IBlockBoundsIW.java | 25 +++ .../blocks/TileEntityJacobsLadder.java | 26 ++- .../converter/BlockMechanicalConverter.java | 76 +------- .../blocks/wire/BlockIC2Connector.java | 107 +++++++--- .../wire/TileEntityIC2ConnectorTin.java | 33 ++-- .../assets/industrialwires/lang/en_US.lang | 6 +- .../assets/industrialwires/lang/zh_CN.lang | 6 +- 11 files changed, 356 insertions(+), 214 deletions(-) create mode 100644 src/main/java/malte0811/industrialWires/blocks/BlockIWBase.java create mode 100644 src/main/java/malte0811/industrialWires/blocks/IBlockBoundsIW.java diff --git a/build.gradle b/build.gradle index a073b54..265873b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ def mainVersion = "1.3" -def buildNumber = "7" +def buildNumber = "8" /* * This file is part of Industrial Wires. diff --git a/changelog.md b/changelog.md index 6f388e4..40cfa35 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,5 @@ +#####Version 1.3-8 + - the converters and the motor don't have missing textures any more when using Chisel #####Version 1.3-7 - added Jacob's Ladders/High voltage travelling arcs - they don't have a particular purpose aside from looking nice diff --git a/src/main/java/malte0811/industrialWires/blocks/BlockIWBase.java b/src/main/java/malte0811/industrialWires/blocks/BlockIWBase.java new file mode 100644 index 0000000..c845e93 --- /dev/null +++ b/src/main/java/malte0811/industrialWires/blocks/BlockIWBase.java @@ -0,0 +1,184 @@ +/* + * This file is part of Industrial Wires. + * Copyright (C) 2016-2017 malte0811 + * + * Industrial Wires is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Industrial Wires is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Industrial Wires. If not, see . + */ + +package malte0811.industrialWires.blocks; + +import blusunrize.immersiveengineering.api.IEProperties; +import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces; +import blusunrize.immersiveengineering.common.util.Utils; +import malte0811.industrialWires.IndustrialWires; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fml.common.registry.GameRegistry; + +import javax.annotation.Nullable; +import java.util.Arrays; +import java.util.List; + +public abstract class BlockIWBase extends Block { + private IProperty[] properties; + public BlockIWBase(Material mat, String name) { + super(mat); + setHardness(3.0F); + setResistance(15.0F); + GameRegistry.register(this, new ResourceLocation(IndustrialWires.MODID, name)); + GameRegistry.register(new ItemBlockIW(this), new ResourceLocation(IndustrialWires.MODID, name)); + setUnlocalizedName(IndustrialWires.MODID+"."+name); + setCreativeTab(IndustrialWires.creativeTab); + } + + + @Override + protected BlockStateContainer createBlockState() { + if (properties==null) { + properties = getProperties(); + } + BlockStateContainer cont = super.createBlockState(); + IProperty[] props = cont.getProperties().toArray(new IProperty[0]); + int oldLength = props.length; + props = Arrays.copyOf(props, oldLength + properties.length); + System.arraycopy(properties, 0, props, oldLength, properties.length); + return new BlockStateContainer(this, props); + } + + @Override + public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { + state = super.getActualState(state, worldIn, pos); + TileEntity tile = worldIn.getTileEntity(pos); + if (tile instanceof IHasDummyBlocksIW) { + state = applyProperty(state, IEProperties.MULTIBLOCKSLAVE, ((IHasDummyBlocksIW) tile).isDummy()); + } + if (tile instanceof IEBlockInterfaces.IDirectionalTile) { + state = state.withProperty(IEProperties.FACING_ALL, ((IEBlockInterfaces.IDirectionalTile) tile).getFacing()); + } + return state; + } + + protected > IBlockState applyProperty(IBlockState in, IProperty prop, V val) { + return in.withProperty(prop, val); + } + + @Override + public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { + TileEntity te = worldIn.getTileEntity(pos); + if (te instanceof IHasDummyBlocksIW) { + ((IHasDummyBlocksIW) te).breakDummies(); + } + super.breakBlock(worldIn, pos, state); + worldIn.removeTileEntity(pos); + } + @Override + public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, + ItemStack stack) { + super.onBlockPlacedBy(worldIn, pos, state, placer, stack); + TileEntity te = worldIn.getTileEntity(pos); + if (te instanceof IEBlockInterfaces.IDirectionalTile) { + ((IEBlockInterfaces.IDirectionalTile)te).setFacing(state.getValue(IEProperties.FACING_ALL)); + } + if (te instanceof IHasDummyBlocksIW) { + ((IHasDummyBlocksIW) te).placeDummies(state); + } + } + + @Nullable + @Override + public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { + return getBoundingBox(blockState, worldIn, pos); + } + + @Override + public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn) { + AxisAlignedBB axisalignedbb = getBoundingBox(state, worldIn, pos).offset(pos); + if (entityBox.intersectsWith(axisalignedbb)) { + collidingBoxes.add(axisalignedbb); + } + } + + @Override + public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { + TileEntity te = source.getTileEntity(pos); + if (te instanceof IBlockBoundsIW) { + AxisAlignedBB ret = ((IBlockBoundsIW) te).getBoundingBox(); + if (ret!=null) { + return ret; + } + } + return super.getBoundingBox(state, source, pos); + } + + //mostly copied from IE + @Override + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, + EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + TileEntity te = world.getTileEntity(pos); + if(te instanceof IEBlockInterfaces.IDirectionalTile && Utils.isHammer(heldItem) && !world.isRemote) { + IEBlockInterfaces.IDirectionalTile directionalTe = (IEBlockInterfaces.IDirectionalTile) te; + if (directionalTe.canHammerRotate(side, hitX, hitY, hitZ, player)) { + EnumFacing f = directionalTe.getFacing(); + final EnumFacing original = f; + int limit = directionalTe.getFacingLimitation(); + + if(limit==0) { + f = EnumFacing.VALUES[(f.ordinal() + 1) % EnumFacing.VALUES.length]; + } else if(limit==1) { + f = player.isSneaking()?f.rotateAround(side.getAxis()).getOpposite():f.rotateAround(side.getAxis()); + } else if(limit == 2 || limit == 5) { + f = player.isSneaking()?f.rotateYCCW():f.rotateY(); + } + if (f!=original) { + directionalTe.setFacing(f); + te.markDirty(); + world.notifyBlockUpdate(pos,state,state,3); + world.addBlockEvent(pos, this, 255, 0); + } + return true; + } + } else if (te instanceof IEBlockInterfaces.IPlayerInteraction) { + ((IEBlockInterfaces.IPlayerInteraction) te).interact(side, player, hand, heldItem, hitX, hitY, hitZ); + } + return false; + } + + @Override + public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) { + boolean def = super.eventReceived(state, worldIn, pos, id, param); + if ((id&255)==255) { + IBlockState s = worldIn.getBlockState(pos); + worldIn.notifyBlockUpdate(pos, s, s, 3); + return true; + } + return def; + } + + protected abstract IProperty[] getProperties(); +} diff --git a/src/main/java/malte0811/industrialWires/blocks/BlockJacobsLadder.java b/src/main/java/malte0811/industrialWires/blocks/BlockJacobsLadder.java index 5c09370..4dd1c4e 100644 --- a/src/main/java/malte0811/industrialWires/blocks/BlockJacobsLadder.java +++ b/src/main/java/malte0811/industrialWires/blocks/BlockJacobsLadder.java @@ -50,56 +50,29 @@ import javax.annotation.Nullable; import java.util.Arrays; import java.util.List; -public class BlockJacobsLadder extends Block implements IMetaEnum, IPlacementCheck { - static PropertyEnum size_property = PropertyEnum.create("size", LadderSize.class); +public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacementCheck { + private static PropertyEnum size_property = PropertyEnum.create("size", LadderSize.class); public BlockJacobsLadder() { - super(Material.IRON); - setHardness(3.0F); - setResistance(15.0F); - String name = "jacobs_ladder"; - GameRegistry.register(this, new ResourceLocation(IndustrialWires.MODID, name)); - GameRegistry.register(new ItemBlockIW(this), new ResourceLocation(IndustrialWires.MODID, name)); - setUnlocalizedName(IndustrialWires.MODID+"."+name); - setCreativeTab(IndustrialWires.creativeTab); - } - - @Override - public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { - TileEntity te = worldIn.getTileEntity(pos); - if (te instanceof IHasDummyBlocksIW) { - ((IHasDummyBlocksIW) te).breakDummies(); - } - super.breakBlock(worldIn, pos, state); - worldIn.removeTileEntity(pos); - } - - @Override - protected BlockStateContainer createBlockState() { - BlockStateContainer cont = super.createBlockState(); - IProperty[] props = cont.getProperties().toArray(new IProperty[0]); - props = Arrays.copyOf(props, props.length + 3); - props[props.length - 3] = size_property; - props[props.length - 2] = IEProperties.MULTIBLOCKSLAVE; - props[props.length - 1] = IEProperties.FACING_HORIZONTAL; - return new BlockStateContainer(this, props); + super(Material.IRON, "jacobs_ladder"); } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { + state = super.getActualState(state, worldIn, pos); TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof IHasDummyBlocksIW) { - state = applyProperty(state, IEProperties.MULTIBLOCKSLAVE, ((IHasDummyBlocksIW) tile).isDummy()); - } if (tile instanceof TileEntityJacobsLadder) { state = applyProperty(state, size_property, ((TileEntityJacobsLadder) tile).size); state = applyProperty(state, IEProperties.FACING_HORIZONTAL, ((TileEntityJacobsLadder) tile).facing); } - return super.getActualState(state, worldIn, pos); + return state; } - private > IBlockState applyProperty(IBlockState in, IProperty prop, V val) { - return in.withProperty(prop, val); + @Override + protected IProperty[] getProperties() { + return new IProperty[]{ + size_property, IEProperties.MULTIBLOCKSLAVE, IEProperties.FACING_HORIZONTAL + }; } @Override @@ -176,51 +149,6 @@ public class BlockJacobsLadder extends Block implements IMetaEnum, IPlacementChe if (te instanceof TileEntityJacobsLadder) { ((TileEntityJacobsLadder) te).facing = state.getValue(IEProperties.FACING_HORIZONTAL); } - if (te instanceof IHasDummyBlocksIW) { - ((IHasDummyBlocksIW) te).placeDummies(state); - } - } - - @Override - public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { - TileEntity te = source.getTileEntity(pos); - if (!(te instanceof TileEntityJacobsLadder)) { - return FULL_BLOCK_AABB; - } - TileEntityJacobsLadder tile = (TileEntityJacobsLadder) te; - if (!tile.isDummy()) { - //transformer - return FULL_BLOCK_AABB; - } else { - Vec3d min; - Vec3d max; - LadderSize size = tile.size; - double distX = (1 - size.topDistance) / 2; - double distZ = .5 - .0625 * (size.ordinal() + 1); - double h = Math.min(1, 1 + size.height - tile.dummy); - if (tile.facing.getAxis() == EnumFacing.Axis.Z) { - min = new Vec3d(distX, 0, distZ); - max = new Vec3d(1 - distX, h, 1 - distZ); - } else { - min = new Vec3d(distZ, 0, distX); - max = new Vec3d(1 - distZ, h, 1 - distX); - } - return new AxisAlignedBB(min.xCoord, min.yCoord, min.zCoord, max.xCoord, max.yCoord, max.zCoord); - } - } - - @Nullable - @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) { - return getBoundingBox(blockState, worldIn, pos); - } - - @Override - public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn) { - AxisAlignedBB axisalignedbb = getBoundingBox(state, worldIn, pos).offset(pos); - if (entityBox.intersectsWith(axisalignedbb)) { - collidingBoxes.add(axisalignedbb); - } } @Override @@ -262,15 +190,4 @@ public class BlockJacobsLadder extends Block implements IMetaEnum, IPlacementChe TileEntity te = world.getTileEntity(pos); return te instanceof TileEntityJacobsLadder && ((TileEntityJacobsLadder) te).rotate(world, pos, axis); } - - @Override - public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) { - boolean def = super.eventReceived(state, worldIn, pos, id, param); - if ((id&255)==255) { - IBlockState s = worldIn.getBlockState(pos); - worldIn.notifyBlockUpdate(pos, s, s, 3); - return true; - } - return def; - } } diff --git a/src/main/java/malte0811/industrialWires/blocks/IBlockBoundsIW.java b/src/main/java/malte0811/industrialWires/blocks/IBlockBoundsIW.java new file mode 100644 index 0000000..29d3585 --- /dev/null +++ b/src/main/java/malte0811/industrialWires/blocks/IBlockBoundsIW.java @@ -0,0 +1,25 @@ +/* + * This file is part of Industrial Wires. + * Copyright (C) 2016-2017 malte0811 + * + * Industrial Wires is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Industrial Wires is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Industrial Wires. If not, see . + */ + +package malte0811.industrialWires.blocks; + +import net.minecraft.util.math.AxisAlignedBB; + +public interface IBlockBoundsIW { + AxisAlignedBB getBoundingBox(); +} diff --git a/src/main/java/malte0811/industrialWires/blocks/TileEntityJacobsLadder.java b/src/main/java/malte0811/industrialWires/blocks/TileEntityJacobsLadder.java index b8f14a2..b497989 100644 --- a/src/main/java/malte0811/industrialWires/blocks/TileEntityJacobsLadder.java +++ b/src/main/java/malte0811/industrialWires/blocks/TileEntityJacobsLadder.java @@ -29,6 +29,7 @@ import malte0811.industrialWires.IndustrialWires; import malte0811.industrialWires.network.MessageTileSyncIW; import malte0811.industrialWires.util.Beziers; import malte0811.industrialWires.util.DualEnergyStorage; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; @@ -49,7 +50,7 @@ import net.minecraftforge.energy.IEnergyStorage; import javax.annotation.Nullable; -public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickable, IHasDummyBlocksIW, ISyncReceiver, IEnergySink { +public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickable, IHasDummyBlocksIW, ISyncReceiver, IEnergySink, IBlockBoundsIW { public EnumFacing facing = EnumFacing.NORTH; private DualEnergyStorage energy; public LadderSize size; @@ -447,6 +448,29 @@ public class TileEntityJacobsLadder extends TileEntityIEBase implements ITickabl return new AxisAlignedBB(pos, pos.add(1, 2, 1)); } + @Override + public AxisAlignedBB getBoundingBox() { + if (!isDummy()) { + //transformer + return Block.FULL_BLOCK_AABB; + } else { + Vec3d min; + Vec3d max; + double distX = (1 - size.topDistance) / 2; + double distZ = .5 - .0625 * (size.ordinal() + 1); + double h = Math.min(1, 1 + size.height - dummy); + if (facing.getAxis() == EnumFacing.Axis.Z) { + min = new Vec3d(distX, 0, distZ); + max = new Vec3d(1 - distX, h, 1 - distZ); + } else { + min = new Vec3d(distZ, 0, distX); + max = new Vec3d(1 - distZ, h, 1 - distX); + } + return new AxisAlignedBB(min.xCoord, min.yCoord, min.zCoord, max.xCoord, max.yCoord, max.zCoord); + } + } + + public enum LadderSize implements IStringSerializable { /* all on a block (HV transformer) diff --git a/src/main/java/malte0811/industrialWires/blocks/converter/BlockMechanicalConverter.java b/src/main/java/malte0811/industrialWires/blocks/converter/BlockMechanicalConverter.java index 1cc3f64..dc1cb5f 100644 --- a/src/main/java/malte0811/industrialWires/blocks/converter/BlockMechanicalConverter.java +++ b/src/main/java/malte0811/industrialWires/blocks/converter/BlockMechanicalConverter.java @@ -21,11 +21,13 @@ import blusunrize.immersiveengineering.api.IEProperties; import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile; import blusunrize.immersiveengineering.common.util.Utils; import malte0811.industrialWires.IndustrialWires; +import malte0811.industrialWires.blocks.BlockIWBase; import malte0811.industrialWires.blocks.IMetaEnum; import malte0811.industrialWires.blocks.ItemBlockIW; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; +import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; @@ -46,17 +48,10 @@ import net.minecraftforge.fml.common.registry.GameRegistry; import java.util.List; -public class BlockMechanicalConverter extends Block implements IMetaEnum, ITileEntityProvider { - PropertyEnum type; +public class BlockMechanicalConverter extends BlockIWBase implements IMetaEnum { + private static PropertyEnum type = PropertyEnum.create("type", MechanicalBlockType.class); public BlockMechanicalConverter() { - super(Material.IRON); - setHardness(3.0F); - setResistance(15.0F); - String name = "mechanical_converter"; - GameRegistry.register(this, new ResourceLocation(IndustrialWires.MODID, name)); - GameRegistry.register(new ItemBlockIW(this), new ResourceLocation(IndustrialWires.MODID, name)); - setUnlocalizedName(name); - setCreativeTab(IndustrialWires.creativeTab); + super(Material.IRON, "mechanical_converter"); } @Override @@ -67,20 +62,8 @@ public class BlockMechanicalConverter extends Block implements IMetaEnum, ITileE } @Override - protected BlockStateContainer createBlockState() { - type = PropertyEnum.create("type", MechanicalBlockType.class); - BlockStateContainer container = new BlockStateContainer(this, type, IEProperties.FACING_ALL); - return container; - } - - @Override - public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { - IBlockState ret = super.getActualState(state, world, pos); - TileEntity te = world.getTileEntity(pos); - if (te instanceof IDirectionalTile) { - ret = ret.withProperty(IEProperties.FACING_ALL, ((IDirectionalTile) te).getFacing()); - } - return ret; + protected IProperty[] getProperties() { + return new IProperty[]{type, IEProperties.FACING_ALL}; } @Override @@ -94,9 +77,9 @@ public class BlockMechanicalConverter extends Block implements IMetaEnum, ITileE } @Override - public TileEntity createNewTileEntity(World worldIn, int meta) { - switch (MechanicalBlockType.values[meta]) { - case IE_MOTOR: + public TileEntity createTileEntity(World world, IBlockState state) { + switch (state.getValue(type)) { + case IE_MOTOR: return new TileEntityIEMotor(); case IE_TO_IC2: return new TileEntityMechIEtoIC(); @@ -117,15 +100,6 @@ public class BlockMechanicalConverter extends Block implements IMetaEnum, ITileE return base.withProperty(IEProperties.FACING_ALL, facing.getOpposite()); } @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, - ItemStack stack) { - super.onBlockPlacedBy(worldIn, pos, state, placer, stack); - TileEntity te = worldIn.getTileEntity(pos); - if (te instanceof IDirectionalTile) { - ((IDirectionalTile)te).setFacing(state.getValue(IEProperties.FACING_ALL)); - } - } - @Override public int damageDropped(IBlockState state) { return state.getValue(type).ordinal(); } @@ -134,36 +108,6 @@ public class BlockMechanicalConverter extends Block implements IMetaEnum, ITileE EntityPlayer player) { return new ItemStack(this, 1, damageDropped(state)); } - //mostly copied from IE - @Override - public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, - EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { - TileEntity te = world.getTileEntity(pos); - if(te instanceof IDirectionalTile && Utils.isHammer(heldItem) && !world.isRemote) { - IDirectionalTile directionalTe = (IDirectionalTile) te; - if (directionalTe.canHammerRotate(side, hitX, hitY, hitZ, player)) { - EnumFacing f = directionalTe.getFacing(); - final EnumFacing original = f; - int limit = directionalTe.getFacingLimitation(); - - if(limit==0) { - f = EnumFacing.VALUES[(f.ordinal() + 1) % EnumFacing.VALUES.length]; - } else if(limit==1) { - f = player.isSneaking()?f.rotateAround(side.getAxis()).getOpposite():f.rotateAround(side.getAxis()); - } else if(limit == 2 || limit == 5) { - f = player.isSneaking()?f.rotateYCCW():f.rotateY(); - } - if (f!=original) { - directionalTe.setFacing(f); - te.markDirty(); - world.notifyBlockUpdate(pos,state,state,3); - world.addBlockEvent(pos, this, 255, 0); - } - return true; - } - } - return false; - } @Override @SuppressWarnings("deprecation") public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) { diff --git a/src/main/java/malte0811/industrialWires/blocks/wire/BlockIC2Connector.java b/src/main/java/malte0811/industrialWires/blocks/wire/BlockIC2Connector.java index fec6c15..5fe0089 100644 --- a/src/main/java/malte0811/industrialWires/blocks/wire/BlockIC2Connector.java +++ b/src/main/java/malte0811/industrialWires/blocks/wire/BlockIC2Connector.java @@ -1,6 +1,6 @@ -/******************************************************************************* +/* * This file is part of Industrial Wires. - * Copyright (C) 2016 malte0811 + * Copyright (C) 2016-2017 malte0811 * * Industrial Wires is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,16 +14,19 @@ * * You should have received a copy of the GNU General Public License * along with Industrial Wires. If not, see . - *******************************************************************************/ + */ package malte0811.industrialWires.blocks.wire; import java.util.Arrays; +import java.util.List; import blusunrize.immersiveengineering.api.IEProperties; import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable; import blusunrize.immersiveengineering.common.blocks.BlockIETileProvider; import blusunrize.immersiveengineering.common.blocks.ItemBlockIEBase; +import blusunrize.immersiveengineering.common.util.IELogger; import malte0811.industrialWires.IndustrialWires; +import malte0811.industrialWires.blocks.BlockIWBase; import malte0811.industrialWires.blocks.IMetaEnum; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -31,6 +34,9 @@ import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; @@ -41,10 +47,10 @@ import net.minecraftforge.common.property.ExtendedBlockState; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IUnlistedProperty; -public class BlockIC2Connector extends BlockIETileProvider implements IMetaEnum { - +public class BlockIC2Connector extends BlockIWBase implements IMetaEnum { + private static PropertyEnum type = PropertyEnum.create("type", BlockTypes_IC2_Connector.class); public BlockIC2Connector() { - super("ic2Connector", Material.IRON, PropertyEnum.create("type", BlockTypes_IC2_Connector.class), ItemBlockIEBase.class, IEProperties.FACING_ALL); + super(Material.IRON, "ic2Connector"); setHardness(3.0F); setResistance(15.0F); lightOpacity = 0; @@ -61,6 +67,14 @@ public class BlockIC2Connector extends BlockIETileProvider list) { + for (int i = 0;i