diff --git a/src/main/java/techreborn/Core.java b/src/main/java/techreborn/Core.java index 815dd50e4..e45e83ba1 100644 --- a/src/main/java/techreborn/Core.java +++ b/src/main/java/techreborn/Core.java @@ -95,9 +95,8 @@ public class Core { worldGen = new TechRebornWorldGen(); worldGen.configFile = (new File(configDir, "ores.json")); + CommonProxy.isChiselAround = Loader.isModLoaded("ctm"); TechRebornAPI.subItemRetriever = new SubItemRetriever(); - //Recheck here because things break at times - // Register ModBlocks ModBlocks.init(); // Register Fluids diff --git a/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java b/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java index 8fae6c76f..b7ab3fd32 100644 --- a/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java +++ b/src/main/java/techreborn/blocks/storage/BlockLSUStorage.java @@ -30,53 +30,72 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import prospector.shootingstar.ShootingStar; import prospector.shootingstar.model.ModelCompound; import reborncore.common.BaseTileBlock; -import techreborn.Core; import techreborn.client.TechRebornCreativeTab; import techreborn.lib.ModInfo; import techreborn.tiles.lesu.TileLSUStorage; -import java.util.ArrayList; -import java.util.List; - +/** + * Energy storage block for LESU + */ public class BlockLSUStorage extends BaseTileBlock { + /** + * + */ public BlockLSUStorage() { super(Material.IRON); setCreativeTab(TechRebornCreativeTab.instance); - if (Core.proxy.isCTMAvailable()) { - ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy/ctm")); - } else { - ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy")); - } + ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, "machines/energy")); } + /** + * Called by ItemBlocks after a block is set in the world, to allow post-place logic + */ @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack itemstack) { super.onBlockPlacedBy(world, pos, state, player, itemstack); if (world.getTileEntity(pos) instanceof TileLSUStorage) { - ((TileLSUStorage) world.getTileEntity(pos)).rebuildNetwork(); + TileLSUStorage tile = (TileLSUStorage) world.getTileEntity(pos); + if (tile != null) { + tile.rebuildNetwork(); + } } } + /** + * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated + */ @Override public void breakBlock(World world, BlockPos pos, IBlockState state) { if (world.getTileEntity(pos) instanceof TileLSUStorage) { - ((TileLSUStorage) world.getTileEntity(pos)).removeFromNetwork(); + TileLSUStorage tile = (TileLSUStorage) world.getTileEntity(pos); + if (tile != null) { + tile.removeFromNetwork(); + } } super.breakBlock(world, pos, state); } + /** + * This gets a complete list of items dropped from this block. + * + * @param drops add all items this block drops to this drops list + * @param world The current world + * @param pos Block position in world + * @param state Current state + * @param fortune Breakers fortune level + */ @Override - public List getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { - List items = new ArrayList<>(); - items.add(new ItemStack(this)); - return items; + public void getDrops(NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { + drops.add(new ItemStack(this)); } @Override @@ -84,7 +103,18 @@ public class BlockLSUStorage extends BaseTileBlock { return new TileLSUStorage(); } - public boolean shouldConnectToBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta) { - return block == this; + /** + * Determines if another block can connect to this block + * + * @param world The current world + * @param pos The position of this block + * @param facing The side the connecting block is on + * @return True to allow another block to connect to this block + */ + @Override + public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) + { + Block block = world.getBlockState(pos).getBlock(); + return this == block; } } diff --git a/src/main/java/techreborn/proxies/CommonProxy.java b/src/main/java/techreborn/proxies/CommonProxy.java index 503a2adfa..f8c9de035 100644 --- a/src/main/java/techreborn/proxies/CommonProxy.java +++ b/src/main/java/techreborn/proxies/CommonProxy.java @@ -39,7 +39,6 @@ public class CommonProxy implements ICompatModule { @Override public void preInit(FMLPreInitializationEvent event) { - isChiselAround = Loader.isModLoaded("chisel"); if (isChiselAround) { Core.logHelper.info("Hello chisel, shiny things will be enabled in techreborn"); } diff --git a/src/main/resources/assets/techreborn/textures/blocks/machines/energy/lapotronic_su_side.png.mcmeta b/src/main/resources/assets/techreborn/textures/blocks/machines/energy/lapotronic_su_side.png.mcmeta new file mode 100644 index 000000000..e4c81852d --- /dev/null +++ b/src/main/resources/assets/techreborn/textures/blocks/machines/energy/lapotronic_su_side.png.mcmeta @@ -0,0 +1,9 @@ +{ + "ctm":{ + "ctm_version": 1, + "type":"CTM", + "textures":[ + "techreborn:blocks/machines/energy/ev_multi_side_ctm" + ] + } +}