diff --git a/src/main/java/com/hbm/blocks/BlockDummyable.java b/src/main/java/com/hbm/blocks/BlockDummyable.java index f3190a687..5fd25e4f3 100644 --- a/src/main/java/com/hbm/blocks/BlockDummyable.java +++ b/src/main/java/com/hbm/blocks/BlockDummyable.java @@ -152,6 +152,8 @@ public abstract class BlockDummyable extends BlockContainer { if(i == 3) { dir = ForgeDirection.getOrientation(4); } + + dir = getDirModified(dir); if(!checkRequirement(world, x, y, z, dir, o)) { @@ -183,6 +185,10 @@ public abstract class BlockDummyable extends BlockContainer { super.onBlockPlacedBy(world, x, y, z, player, itemStack); } + + protected ForgeDirection getDirModified(ForgeDirection dir) { + return dir; + } protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) { return MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(), x, y, z, dir); diff --git a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKBase.java b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKBase.java index 25936cbfb..9d1b768bf 100644 --- a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKBase.java +++ b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKBase.java @@ -2,14 +2,19 @@ package com.hbm.blocks.machine.rbmk; import com.hbm.blocks.BlockDummyable; import com.hbm.handler.MultiblockHandlerXR; +import com.hbm.items.ModItems; +import com.hbm.items.machine.ItemRBMKLid; import com.hbm.main.MainRegistry; import com.hbm.tileentity.machine.rbmk.RBMKDials; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; @@ -37,12 +42,27 @@ public abstract class RBMKBase extends BlockDummyable { if(world.isRemote) { return true; + } + + int[] pos = this.findCore(world, x, y, z); + + if(pos == null) + return false; + + TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]); + + if(!(te instanceof TileEntityRBMKBase)) + return false; + + TileEntityRBMKBase rbmk = (TileEntityRBMKBase) te; + + if(player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemRBMKLid) { - } else if(!player.isSneaking()) { - int[] pos = this.findCore(world, x, y, z); - - if(pos == null) + if(!rbmk.hasLid()) return false; + } + + if(!player.isSneaking()) { FMLNetworkHandler.openGui(player, MainRegistry.instance, gui, world, pos[0], pos[1], pos[2]); return true; @@ -73,21 +93,49 @@ public abstract class RBMKBase extends BlockDummyable { return AxisAlignedBB.getBoundingBox(x + this.minX, y + this.minY, z + this.minZ, x + this.maxX, y + this.maxY + height, z + this.maxZ); } + + /* + * NORTH: no cover + * EAST: concrete cover + * SOUTH: lead glass cover + * WEST: UNUSED + */ + + public static final ForgeDirection DIR_NO_LID = ForgeDirection.NORTH; + public static final ForgeDirection DIR_NORMAL_LID = ForgeDirection.EAST; + public static final ForgeDirection DIR_GLASS_LID = ForgeDirection.SOUTH; @Override - protected boolean checkRequirement(World world, int x, int y, int z, ForgeDirection dir, int o) { - return MultiblockHandlerXR.checkSpace(world, x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(world), x, y, z, dir); - } - - @Override - protected void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) { + public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) { MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o, y + dir.offsetY * o, z + dir.offsetZ * o, getDimensions(world), this, dir); + this.makeExtra(world, x, y + RBMKDials.getColumnHeight(world), z); + } + + @Override + protected ForgeDirection getDirModified(ForgeDirection dir) { + return DIR_NO_LID; } public int[] getDimensions(World world) { return new int[] {RBMKDials.getColumnHeight(world), 0, 0, 0, 0, 0}; } + @Override + public void breakBlock(World world, int x, int y, int z, Block b, int i) { + + if(!world.isRemote) { + + if(i == DIR_NORMAL_LID.ordinal() + offset) { + world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5 + RBMKDials.getColumnHeight(world), z + 0.5, new ItemStack(ModItems.rbmk_lid))); + } + if(i == DIR_GLASS_LID.ordinal() + offset) { + world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5 + RBMKDials.getColumnHeight(world), z + 0.5, new ItemStack(ModItems.rbmk_lid_glass))); + } + } + + super.breakBlock(world, x, y, z, b, i); + } + public static int renderIDRods = RenderingRegistry.getNextAvailableRenderId(); public static int renderIDPassive = RenderingRegistry.getNextAvailableRenderId(); public static int renderIDControl = RenderingRegistry.getNextAvailableRenderId(); diff --git a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKBoiler.java b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKBoiler.java index 788c35b32..3c9ab9f03 100644 --- a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKBoiler.java +++ b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKBoiler.java @@ -33,10 +33,4 @@ public class RBMKBoiler extends RBMKBase { public int getRenderType(){ return this.renderIDControl; } - - @Override - public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) { - super.fillSpace(world, x, y, z, dir, o); - this.makeExtra(world, x, y + RBMKDials.getColumnHeight(world), z); - } } diff --git a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKOutgasser.java b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKOutgasser.java index e8dded802..5a2f5dff7 100644 --- a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKOutgasser.java +++ b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKOutgasser.java @@ -2,13 +2,11 @@ package com.hbm.blocks.machine.rbmk; import com.hbm.blocks.ModBlocks; import com.hbm.tileentity.TileEntityProxyCombo; -import com.hbm.tileentity.machine.rbmk.RBMKDials; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKOutgasser; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public class RBMKOutgasser extends RBMKBase { @@ -33,10 +31,4 @@ public class RBMKOutgasser extends RBMKBase { public int getRenderType(){ return this.renderIDPassive; } - - @Override - public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) { - super.fillSpace(world, x, y, z, dir, o); - this.makeExtra(world, x, y + RBMKDials.getColumnHeight(world), z); - } } diff --git a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKRod.java b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKRod.java index 7cb340799..b266ff540 100644 --- a/src/main/java/com/hbm/blocks/machine/rbmk/RBMKRod.java +++ b/src/main/java/com/hbm/blocks/machine/rbmk/RBMKRod.java @@ -2,13 +2,11 @@ package com.hbm.blocks.machine.rbmk; import com.hbm.blocks.ModBlocks; import com.hbm.tileentity.TileEntityProxyInventory; -import com.hbm.tileentity.machine.rbmk.RBMKDials; import com.hbm.tileentity.machine.rbmk.TileEntityRBMKRod; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; public class RBMKRod extends RBMKBase { @@ -26,6 +24,7 @@ public class RBMKRod extends RBMKBase { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + return openInv(world, x, y, z, player, ModBlocks.guiID_rbmk_rod); } @@ -33,10 +32,4 @@ public class RBMKRod extends RBMKBase { public int getRenderType(){ return this.renderIDRods; } - - @Override - public void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) { - super.fillSpace(world, x, y, z, dir, o); - this.makeExtra(world, x, y + RBMKDials.getColumnHeight(world), z); - } } diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index 12d28957c..6846820ed 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -927,6 +927,7 @@ public class ModItems { public static Item rod_quad_coolant; public static Item rbmk_lid; + public static Item rbmk_lid_glass; public static Item rbmk_fuel_empty; public static ItemRBMKRod rbmk_fuel_ueu; public static ItemRBMKRod rbmk_fuel_meu; @@ -3222,7 +3223,8 @@ public class ModItems { rod_dual_tritium = new ItemHazard(1F).setUnlocalizedName("rod_dual_tritium").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_tritium"); rod_quad_tritium = new ItemHazard(2F).setUnlocalizedName("rod_quad_tritium").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_tritium"); - rbmk_lid = new Item().setUnlocalizedName("rbmk_lid").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_lid"); + rbmk_lid = new ItemRBMKLid().setUnlocalizedName("rbmk_lid").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_lid"); + rbmk_lid_glass = new ItemRBMKLid().setUnlocalizedName("rbmk_lid_glass").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_lid_glass"); rbmk_pellet_ueu = (ItemRBMKPellet) new ItemRBMKPellet("Unenriched Uranium").addRadiation(ItemHazard.u * ItemHazard.billet).toItem().setUnlocalizedName("rbmk_pellet_ueu").setTextureName(RefStrings.MODID + ":rbmk_pellet_ueu"); rbmk_pellet_meu = (ItemRBMKPellet) new ItemRBMKPellet("Medium Enriched Uranium-235").addRadiation(ItemHazard.uf * ItemHazard.billet).toItem().setUnlocalizedName("rbmk_pellet_meu").setTextureName(RefStrings.MODID + ":rbmk_pellet_meu"); @@ -6025,6 +6027,7 @@ public class ModItems { GameRegistry.registerItem(rod_quad_waste, rod_quad_waste.getUnlocalizedName()); GameRegistry.registerItem(rbmk_lid, rbmk_lid.getUnlocalizedName()); + GameRegistry.registerItem(rbmk_lid_glass, rbmk_lid_glass.getUnlocalizedName()); GameRegistry.registerItem(rbmk_fuel_empty, rbmk_fuel_empty.getUnlocalizedName()); GameRegistry.registerItem(rbmk_fuel_ueu, rbmk_fuel_ueu.getUnlocalizedName()); GameRegistry.registerItem(rbmk_fuel_meu, rbmk_fuel_meu.getUnlocalizedName()); @@ -6053,8 +6056,6 @@ public class ModItems { GameRegistry.registerItem(rbmk_pellet_mox, rbmk_pellet_mox.getUnlocalizedName()); GameRegistry.registerItem(rbmk_pellet_les, rbmk_pellet_les.getUnlocalizedName()); GameRegistry.registerItem(rbmk_pellet_mes, rbmk_pellet_mes.getUnlocalizedName()); - GameRegistry.registerItem(rbmk_pellet_mes, rbmk_pellet_mes.getUnlocalizedName()); - GameRegistry.registerItem(rbmk_pellet_mes, rbmk_pellet_mes.getUnlocalizedName()); GameRegistry.registerItem(rbmk_pellet_hes, rbmk_pellet_hes.getUnlocalizedName()); GameRegistry.registerItem(rbmk_pellet_leaus, rbmk_pellet_leaus.getUnlocalizedName()); GameRegistry.registerItem(rbmk_pellet_heaus, rbmk_pellet_heaus.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/machine/ItemRBMKLid.java b/src/main/java/com/hbm/items/machine/ItemRBMKLid.java new file mode 100644 index 000000000..6e94aa4dc --- /dev/null +++ b/src/main/java/com/hbm/items/machine/ItemRBMKLid.java @@ -0,0 +1,59 @@ +package com.hbm.items.machine; + +import com.hbm.blocks.ModBlocks; +import com.hbm.blocks.machine.rbmk.RBMKBase; +import com.hbm.items.ModItems; +import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class ItemRBMKLid extends Item { + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float fx, float fy, float fz) { + + Block b = world.getBlock(x, y, z); + + if(b instanceof RBMKBase) { + RBMKBase rbmk = (RBMKBase) b; + + int[] pos = rbmk.findCore(world, x, y, z); + + if(pos == null) + return false; + + TileEntity te = world.getTileEntity(pos[0], pos[1], pos[2]); + + if(!(te instanceof TileEntityRBMKBase)) + return false; + + TileEntityRBMKBase tile = (TileEntityRBMKBase) te; + + if(tile.hasLid()) + return false; + + int meta = RBMKBase.DIR_NORMAL_LID.ordinal(); + + if(this == ModItems.rbmk_lid_glass) { + meta = RBMKBase.DIR_GLASS_LID.ordinal(); + world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Blocks.glass.stepSound.func_150496_b(), (Blocks.glass.stepSound.getVolume() + 1.0F) / 2.0F, Blocks.glass.stepSound.getPitch() * 0.8F); + } else { + world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, ModBlocks.concrete_smooth.stepSound.func_150496_b(), (ModBlocks.concrete_smooth.stepSound.getVolume() + 1.0F) / 2.0F, ModBlocks.concrete_smooth.stepSound.getPitch() * 0.8F); + } + + world.setBlockMetadataWithNotify(pos[0], pos[1], pos[2], meta + RBMKBase.offset, 3); + stack.stackSize--; + player.inventoryContainer.detectAndSendChanges(); + + return true; + } + + return false; + } +} diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 9224c8b19..16ca9798b 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -212,6 +212,13 @@ public class ClientProxy extends ServerProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKControlManual.class, new RenderRBMKControlRod(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_control.png")); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKControlAuto.class, new RenderRBMKControlRod(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_control_auto.png")); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKConsole.class, new RenderRBMKConsole()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKAbsorber.class, new RenderRBMKLid(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_absorber")); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKBlank.class, new RenderRBMKLid(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_blank")); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKBoiler.class, new RenderRBMKLid(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_boiler")); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKModerator.class, new RenderRBMKLid(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_moderator")); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKOutgasser.class, new RenderRBMKLid(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_outgasser")); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKReflector.class, new RenderRBMKLid(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_reflector")); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRBMKRod.class, new RenderRBMKLid(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_element")); //ITER ClientRegistry.bindTileEntitySpecialRenderer(TileEntityITER.class, new RenderITER()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachinePlasmaHeater.class, new RenderPlasmaHeater()); diff --git a/src/main/java/com/hbm/main/ModEventHandler.java b/src/main/java/com/hbm/main/ModEventHandler.java index b7ca1ae28..5514aa202 100644 --- a/src/main/java/com/hbm/main/ModEventHandler.java +++ b/src/main/java/com/hbm/main/ModEventHandler.java @@ -63,10 +63,12 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.monster.EntityCaveSpider; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntityMooshroom; @@ -90,6 +92,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.FoodStats; import net.minecraft.util.Vec3; import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.AnvilUpdateEvent; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.event.entity.EntityEvent; @@ -219,25 +222,26 @@ public class ModEventHandler { if(!event.entityLiving.worldObj.isRemote) { - if(event.source instanceof EntityDamageSource && ((EntityDamageSource)event.source).getEntity() instanceof EntityPlayer) { + if(event.source instanceof EntityDamageSource && ((EntityDamageSource)event.source).getEntity() instanceof EntityPlayer + && !(((EntityDamageSource)event.source).getEntity() instanceof FakePlayer)) { if(event.entityLiving instanceof EntitySpider && event.entityLiving.getRNG().nextInt(500) == 0) { - event.entityLiving.dropItem(ModItems.spider_milk, 1); } + if(event.entityLiving instanceof EntityCaveSpider && event.entityLiving.getRNG().nextInt(100) == 0) { + event.entityLiving.dropItem(ModItems.serum, 1); + } + if(event.entityLiving instanceof EntityAnimal && event.entityLiving.getRNG().nextInt(500) == 0) { - event.entityLiving.dropItem(ModItems.bandaid, 1); } - if(event.entityLiving instanceof EntitySpider && event.entityLiving.getRNG().nextInt(1000) == 0) { - + if(event.entityLiving instanceof IMob && event.entityLiving.getRNG().nextInt(1000) == 0) { event.entityLiving.dropItem(ModItems.heart_piece, 1); } if(event.entityLiving instanceof EntityCyberCrab && event.entityLiving.getRNG().nextInt(500) == 0) { - event.entityLiving.dropItem(ModItems.wd40, 1); } } diff --git a/src/main/java/com/hbm/render/block/RenderRBMKControl.java b/src/main/java/com/hbm/render/block/RenderRBMKControl.java index 176b7be1f..f2acc8f8f 100644 --- a/src/main/java/com/hbm/render/block/RenderRBMKControl.java +++ b/src/main/java/com/hbm/render/block/RenderRBMKControl.java @@ -11,7 +11,6 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.client.model.obj.WavefrontObject; @@ -67,12 +66,6 @@ public class RenderRBMKControl implements ISimpleBlockRenderingHandler { tessellator.addTranslation(x + 0.5F, y, z + 0.5F); ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.rbmk_rods, "Column", iicon, tessellator, 0, true); - if(block == ModBlocks.rbmk_boiler && world.getBlock(x, y + 1, z) != block) { - //tessellator.addTranslation(0, 0.125F, 0); - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.rbmk_rods, "Lid", iicon, tessellator, 0, true); - //tessellator.addTranslation(0, -0.125F, 0); - } - tessellator.addTranslation(-x - 0.5F, -y, -z - 0.5F); return true; diff --git a/src/main/java/com/hbm/render/block/RenderRBMKReflector.java b/src/main/java/com/hbm/render/block/RenderRBMKReflector.java index 763e917ac..feac19f73 100644 --- a/src/main/java/com/hbm/render/block/RenderRBMKReflector.java +++ b/src/main/java/com/hbm/render/block/RenderRBMKReflector.java @@ -10,7 +10,6 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.client.model.obj.WavefrontObject; @@ -58,9 +57,6 @@ public class RenderRBMKReflector implements ISimpleBlockRenderingHandler { tessellator.addTranslation(x + 0.5F, y, z + 0.5F); ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.rbmk_reflector, "Column", iicon, tessellator, 0, true); - if(world.getBlock(x, y + 1, z) != block) - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.rbmk_element, "Lid", iicon, tessellator, 0, true); - tessellator.addTranslation(-x - 0.5F, -y, -z - 0.5F); return true; diff --git a/src/main/java/com/hbm/render/block/RenderRBMKRod.java b/src/main/java/com/hbm/render/block/RenderRBMKRod.java index b944b5ef0..d85c837ee 100644 --- a/src/main/java/com/hbm/render/block/RenderRBMKRod.java +++ b/src/main/java/com/hbm/render/block/RenderRBMKRod.java @@ -10,7 +10,6 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.client.model.obj.WavefrontObject; @@ -59,9 +58,6 @@ public class RenderRBMKRod implements ISimpleBlockRenderingHandler { tessellator.addTranslation(x + 0.5F, y, z + 0.5F); ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.rbmk_element, "Column", iicon, tessellator, 0, true); - if(world.getBlock(x, y + 1, z) != block) - ObjUtil.renderPartWithIcon((WavefrontObject) ResourceManager.rbmk_element, "Lid", iicon, tessellator, 0, true); - tessellator.addTranslation(-x - 0.5F, -y, -z - 0.5F); return true; diff --git a/src/main/java/com/hbm/render/tileentity/RenderRBMKControlRod.java b/src/main/java/com/hbm/render/tileentity/RenderRBMKControlRod.java index 5984b1818..100a5b8a1 100644 --- a/src/main/java/com/hbm/render/tileentity/RenderRBMKControlRod.java +++ b/src/main/java/com/hbm/render/tileentity/RenderRBMKControlRod.java @@ -46,7 +46,7 @@ public class RenderRBMKControlRod extends TileEntitySpecialRenderer { double level = control.lastLevel + (control.level - control.lastLevel) * i; GL11.glTranslated(0, level, 0); - ResourceManager.rbmk_rods.renderPart("Lid"); + ResourceManager.rbmk_element.renderPart("Lid"); GL11.glPopMatrix(); } diff --git a/src/main/java/com/hbm/render/tileentity/RenderRBMKLid.java b/src/main/java/com/hbm/render/tileentity/RenderRBMKLid.java new file mode 100644 index 000000000..ebf900d9c --- /dev/null +++ b/src/main/java/com/hbm/render/tileentity/RenderRBMKLid.java @@ -0,0 +1,130 @@ +package com.hbm.render.tileentity; + +import org.lwjgl.opengl.GL11; + +import com.hbm.blocks.machine.rbmk.RBMKBase; +import com.hbm.lib.RefStrings; +import com.hbm.main.ResourceManager; +import com.hbm.tileentity.machine.rbmk.TileEntityRBMKBase; +import com.hbm.tileentity.machine.rbmk.TileEntityRBMKRod; + +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +public class RenderRBMKLid extends TileEntitySpecialRenderer { + + private ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_blank.png"); + private ResourceLocation texture_glass = new ResourceLocation(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_blank_glass.png"); + private static final ResourceLocation texture_rods = new ResourceLocation(RefStrings.MODID + ":textures/blocks/rbmk/rbmk_element.png"); + + public RenderRBMKLid(String texture) { + this.texture = new ResourceLocation(texture + ".png"); + //this.texture_glass = new ResourceLocation(texture + "_glass.png"); + } + + @Override + public void renderTileEntityAt(TileEntity te, double x, double y, double z, float i) { + + TileEntityRBMKBase control = (TileEntityRBMKBase)te; + boolean hasRod = false; + boolean cherenkov = false; + + if(te instanceof TileEntityRBMKRod) { + + TileEntityRBMKRod rod = (TileEntityRBMKRod) te; + + if(rod.hasRod) + hasRod = true; + + if(rod.fluxFast + rod.fluxSlow > 5) + cherenkov = true; + } + + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y, z + 0.5); + + int offset = 1; + + for(int o = 1; o < 16; o++) { + + if(te.getWorldObj().getBlock(te.xCoord, te.yCoord + o, te.zCoord) == te.getBlockType()) { + offset = o; + + int meta = te.getWorldObj().getBlockMetadata(te.xCoord, te.yCoord + o, te.zCoord); + + if(meta > 5 && meta < 12) + break; + + } else { + break; + } + } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + + if(control.hasLid()) { + GL11.glPushMatrix(); + GL11.glTranslated(0, offset, 0); + + int meta = control.getBlockMetadata() - RBMKBase.offset; + + if(meta == RBMKBase.DIR_GLASS_LID.ordinal()) { + bindTexture(texture_glass); + } else { + bindTexture(texture); + cherenkov = false; + } + + ResourceManager.rbmk_element.renderPart("Lid"); + GL11.glPopMatrix(); + } + + if(hasRod) { + + GL11.glPushMatrix(); + bindTexture(texture_rods); + + for(int j = 0; j <= offset; j++) { + + ResourceManager.rbmk_element.renderPart("Rods"); + GL11.glTranslated(0, 1, 0); + } + GL11.glPopMatrix(); + } + + if(cherenkov) { + + GL11.glTranslated(0, 0.75, 0); + + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); + + Tessellator tess = Tessellator.instance; + tess.startDrawingQuads(); + tess.setColorRGBA_F(0.4F, 0.9F, 1.0F, 0.1F); + + for(double j = 0; j <= offset; j += 0.25) { + tess.addVertex(-0.5, j, -0.5); + tess.addVertex(-0.5, j, 0.5); + tess.addVertex(0.5, j, 0.5); + tess.addVertex(0.5, j, -0.5); + } + tess.draw(); + + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + } + + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKBase.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKBase.java index 692dc9076..1b5fb4fba 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKBase.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKBase.java @@ -30,6 +30,7 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderGameOverlayEvent; @@ -45,7 +46,7 @@ public abstract class TileEntityRBMKBase extends TileEntity implements INBTPacke public double heat; public boolean hasLid() { - return true; + return this.getBlockMetadata() != RBMKBase.DIR_NO_LID.ordinal() + RBMKBase.offset; } /** @@ -284,7 +285,7 @@ public abstract class TileEntityRBMKBase extends TileEntity implements INBTPacke worldObj.spawnEntityInWorld(debris); }*/ - if(this.hasLid()) + if(this.getBlockMetadata() == RBMKBase.DIR_NORMAL_LID.ordinal() + RBMKBase.offset) spawnDebris(DebrisType.LID); } @@ -397,4 +398,9 @@ public abstract class TileEntityRBMKBase extends TileEntity implements INBTPacke public NBTTagCompound getNBTForConsole() { return null; } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 17, zCoord + 1); + } } diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKControl.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKControl.java index 9626114fe..abd45806c 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKControl.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKControl.java @@ -7,7 +7,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; public abstract class TileEntityRBMKControl extends TileEntityRBMKSlottedBase { @@ -72,11 +71,6 @@ public abstract class TileEntityRBMKControl extends TileEntityRBMKSlottedBase { nbt.setDouble("targetLevel", this.targetLevel); } - @Override - public AxisAlignedBB getRenderBoundingBox() { - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 10, zCoord + 1); - } - @Override @SideOnly(Side.CLIENT) public double getMaxRenderDistanceSquared() { diff --git a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKRod.java b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKRod.java index 976ecf208..3eb649565 100644 --- a/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKRod.java +++ b/src/main/java/com/hbm/tileentity/machine/rbmk/TileEntityRBMKRod.java @@ -14,8 +14,9 @@ import net.minecraftforge.common.util.ForgeDirection; public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBMKFluxReceiver { //amount of "neutron energy" buffered for the next tick to use for the reaction - private double fluxFast; - private double fluxSlow; + public double fluxFast; + public double fluxSlow; + public boolean hasRod; public TileEntityRBMKRod() { super(1); @@ -65,10 +66,15 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM this.fluxSlow = 0; spreadFlux(rType, fluxOut); + + hasRod = true; + } else { this.fluxFast = 0; this.fluxSlow = 0; + + hasRod = false; } } } @@ -164,6 +170,7 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM this.fluxFast = nbt.getDouble("fluxFast"); this.fluxSlow = nbt.getDouble("fluxSlow"); + this.hasRod = nbt.getBoolean("hasRod"); } @Override @@ -172,6 +179,7 @@ public class TileEntityRBMKRod extends TileEntityRBMKSlottedBase implements IRBM nbt.setDouble("fluxFast", this.fluxFast); nbt.setDouble("fluxSlow", this.fluxSlow); + nbt.setBoolean("hasRod", this.hasRod); } public void getDiagData(NBTTagCompound nbt) { diff --git a/src/main/resources/assets/hbm/textures/blocks/glass_lead.png b/src/main/resources/assets/hbm/textures/blocks/glass_lead.png new file mode 100644 index 000000000..9b2d75a18 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/glass_lead.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_absorber_glass.png b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_absorber_glass.png new file mode 100644 index 000000000..31b150f0b Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_absorber_glass.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_blank_glass.png b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_blank_glass.png new file mode 100644 index 000000000..4842951a9 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_blank_glass.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_boiler_glass.png b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_boiler_glass.png new file mode 100644 index 000000000..60c0ab070 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_boiler_glass.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_element_glass.png b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_element_glass.png new file mode 100644 index 000000000..a89a900b5 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_element_glass.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_moderator_glass.png b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_moderator_glass.png new file mode 100644 index 000000000..c57f208c8 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_moderator_glass.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_outgasser_glass.png b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_outgasser_glass.png new file mode 100644 index 000000000..ee5ad4d26 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_outgasser_glass.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_reflector_glass.png b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_reflector_glass.png new file mode 100644 index 000000000..a4b945873 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/rbmk/rbmk_reflector_glass.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/sand_lead.png b/src/main/resources/assets/hbm/textures/blocks/sand_lead.png new file mode 100644 index 000000000..172b9d01f Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/sand_lead.png differ diff --git a/src/main/resources/assets/hbm/textures/items/rbmk_lid_glass.png b/src/main/resources/assets/hbm/textures/items/rbmk_lid_glass.png new file mode 100644 index 000000000..eee5d3ff7 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/items/rbmk_lid_glass.png differ