diff --git a/src/main/java/mekanism/client/MekanismClient.java b/src/main/java/mekanism/client/MekanismClient.java index bbe7834f8..eaf251ca9 100644 --- a/src/main/java/mekanism/client/MekanismClient.java +++ b/src/main/java/mekanism/client/MekanismClient.java @@ -7,7 +7,6 @@ import mekanism.client.sound.SoundHandler; import mekanism.client.voice.VoiceClient; import mekanism.common.Mekanism; import mekanism.common.network.PacketKey.KeyMessage; -import mekanism.generators.common.tile.turbine.TileEntityRotationalComplex; import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.common.MinecraftForge; @@ -49,8 +48,8 @@ public class MekanismClient extends Mekanism Mekanism.gasmaskOn.clear(); Mekanism.flamethrowerActive.clear(); Mekanism.activeVibrators.clear(); - - TileEntityRotationalComplex.clientRotationMap.clear(); + + //TileEntityRotationalComplex.clientRotationMap.clear(); SoundHandler.soundMaps.clear(); diff --git a/src/main/java/mekanism/client/render/MekanismRenderer.java b/src/main/java/mekanism/client/render/MekanismRenderer.java index d585f3884..21385d1ae 100644 --- a/src/main/java/mekanism/client/render/MekanismRenderer.java +++ b/src/main/java/mekanism/client/render/MekanismRenderer.java @@ -24,10 +24,14 @@ import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.ITickable; import net.minecraft.client.renderer.texture.ResourceLocation; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -48,14 +52,14 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class MekanismRenderer { - private static RenderBlocks renderBlocks = new RenderBlocks(); + //private static RenderBlocks renderBlocks = new RenderBlocks(); - public static ResourceLocation[] colors = new ResourceLocation[256]; + public static TextureAtlasSprite[] colors = new TextureAtlasSprite[256]; - public static ResourceLocation energyIcon; - public static ResourceLocation heatIcon; + public static TextureAtlasSprite energyIcon; + public static TextureAtlasSprite heatIcon; - public static Map overlays = new HashMap(); + public static Map overlays = new HashMap(); private static float lightmapLastX; private static float lightmapLastY; @@ -87,27 +91,27 @@ public class MekanismRenderer overlays.put(type, event.map.registerSprite(new ResourceLocation("mekanism:overlay/" + type.getTransmission() + "Overlay"))); } - energyIcon = event.map.registerIcon("mekanism:LiquidEnergy"); - heatIcon = event.map.registerIcon("mekanism:LiquidHeat"); + energyIcon = event.map.registerSprite("mekanism:LiquidEnergy"); + heatIcon = event.map.registerSprite("mekanism:LiquidHeat"); - GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:LiquidHydrogen")); - GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:LiquidOxygen")); - GasRegistry.getGas("water").setIcon(event.map.registerIcon("mekanism:LiquidSteam")); - GasRegistry.getGas("chlorine").setIcon(event.map.registerIcon("mekanism:LiquidChlorine")); - GasRegistry.getGas("sulfurDioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurDioxide")); - GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurTrioxide")); - GasRegistry.getGas("sulfuricAcid").setIcon(event.map.registerIcon("mekanism:LiquidSulfuricAcid")); - GasRegistry.getGas("hydrogenChloride").setIcon(event.map.registerIcon("mekanism:LiquidHydrogenChloride")); - GasRegistry.getGas("liquidOsmium").setIcon(event.map.registerIcon("mekanism:LiquidOsmium")); - GasRegistry.getGas("liquidStone").setIcon(event.map.registerIcon("mekanism:LiquidStone")); - GasRegistry.getGas("ethene").setIcon(event.map.registerIcon("mekanism:LiquidEthene")); - GasRegistry.getGas("brine").setIcon(event.map.registerIcon("mekanism:LiquidBrine")); - GasRegistry.getGas("sodium").setIcon(event.map.registerIcon("mekanism:LiquidSodium")); - GasRegistry.getGas("deuterium").setIcon(event.map.registerIcon("mekanism:LiquidDeuterium")); - GasRegistry.getGas("tritium").setIcon(event.map.registerIcon("mekanism:LiquidTritium")); - GasRegistry.getGas("fusionFuelDT").setIcon(event.map.registerIcon("mekanism:LiquidDT")); - GasRegistry.getGas("steam").setIcon(event.map.registerIcon("mekanism:LiquidSteam")); - GasRegistry.getGas("lithium").setIcon(event.map.registerIcon("mekanism:LiquidLithium")); + GasRegistry.getGas("hydrogen").setIcon(event.map.registerSprite("mekanism:LiquidHydrogen")); + GasRegistry.getGas("oxygen").setIcon(event.map.registerSprite("mekanism:LiquidOxygen")); + GasRegistry.getGas("water").setIcon(event.map.registerSprite("mekanism:LiquidSteam")); + GasRegistry.getGas("chlorine").setIcon(event.map.registerSprite("mekanism:LiquidChlorine")); + GasRegistry.getGas("sulfurDioxideGas").setIcon(event.map.registerSprite("mekanism:LiquidSulfurDioxide")); + GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map.registerSprite("mekanism:LiquidSulfurTrioxide")); + GasRegistry.getGas("sulfuricAcid").setIcon(event.map.registerSprite("mekanism:LiquidSulfuricAcid")); + GasRegistry.getGas("hydrogenChloride").setIcon(event.map.registerSprite("mekanism:LiquidHydrogenChloride")); + GasRegistry.getGas("liquidOsmium").setIcon(event.map.registerSprite("mekanism:LiquidOsmium")); + GasRegistry.getGas("liquidStone").setIcon(event.map.registerSprite("mekanism:LiquidStone")); + GasRegistry.getGas("ethene").setIcon(event.map.registerSprite("mekanism:LiquidEthene")); + GasRegistry.getGas("brine").setIcon(event.map.registerSprite("mekanism:LiquidBrine")); + GasRegistry.getGas("sodium").setIcon(event.map.registerSprite("mekanism:LiquidSodium")); + GasRegistry.getGas("deuterium").setIcon(event.map.registerSprite("mekanism:LiquidDeuterium")); + GasRegistry.getGas("tritium").setIcon(event.map.registerSprite("mekanism:LiquidTritium")); + GasRegistry.getGas("fusionFuelDT").setIcon(event.map.registerSprite("mekanism:LiquidDT")); + GasRegistry.getGas("steam").setIcon(event.map.registerSprite("mekanism:LiquidSteam")); + GasRegistry.getGas("lithium").setIcon(event.map.registerSprite("mekanism:LiquidLithium")); for(Gas gas : GasRegistry.getRegisteredGasses()) { @@ -115,16 +119,16 @@ public class MekanismRenderer { if(gas.getUnlocalizedName().contains("clean")) { - gas.setIcon(event.map.registerIcon("mekanism:LiquidCleanOre")); + gas.setIcon(event.map.registerSprite("mekanism:LiquidCleanOre")); } else { - gas.setIcon(event.map.registerIcon("mekanism:LiquidOre")); + gas.setIcon(event.map.registerSprite("mekanism:LiquidOre")); } } } - FluidRegistry.getFluid("brine").setIcons(event.map.registerIcon("mekanism:LiquidBrine")); - FluidRegistry.getFluid("heavywater").setIcons(event.map.registerIcon("mekanism:LiquidHeavyWater")); + FluidRegistry.getFluid("brine").setIcons(event.map.registerSprite("mekanism:LiquidBrine")); + FluidRegistry.getFluid("heavywater").setIcons(event.map.registerSprite("mekanism:LiquidHeavyWater")); if(RenderPartTransmitter.getInstance() != null) { @@ -150,20 +154,20 @@ public class MekanismRenderer } } - public static void loadDynamicTextures(ResourceLocationRegister register, String name, ResourceLocation[] textures, DefIcon... defaults) + public static void loadDynamicTextures(TextureMap register, String name, TextureAtlasSprite[] textures, DefIcon... defaults) { for(EnumFacing side : EnumFacing.VALUES) { - String tex = "mekanism:" + name + simpleSides[side.ordinal()]; - String texOn = tex + "On"; + ResourceLocation tex = new ResourceLocation("mekanism:" + name + simpleSides[side.ordinal()]); + ResourceLocation texOn = new ResourceLocation(tex.toString() + "On"); - if(blockIconExists(tex)) + if(blockIconExists(tex.toString())) { - textures[side.ordinal()] = register.registerIcon(tex); + textures[side.ordinal()] = register.registerSprite(tex); - if(blockIconExists(texOn)) + if(blockIconExists(texOn.toString())) { - textures[side.ordinal()+6] = register.registerIcon(texOn); + textures[side.ordinal()+6] = register.registerSprite(texOn); } else { boolean found = false; @@ -179,7 +183,7 @@ public class MekanismRenderer if(!found) { - textures[side.ordinal()+6] = register.registerIcon(tex); + textures[side.ordinal()+6] = register.registerSprite(tex); } } } @@ -202,11 +206,11 @@ public class MekanismRenderer public static class DefIcon { - public ResourceLocation defIcon; + public TextureAtlasSprite defIcon; public List icons = new ArrayList(); - public DefIcon(ResourceLocation icon, int... is) + public DefIcon(TextureAtlasSprite icon, int... is) { defIcon = icon; @@ -216,12 +220,12 @@ public class MekanismRenderer } } - public static DefIcon getAll(ResourceLocation icon) + public static DefIcon getAll(TextureAtlasSprite icon) { return new DefIcon(icon, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); } - public static DefIcon getActivePair(ResourceLocation icon, int... is) + public static DefIcon getActivePair(TextureAtlasSprite icon, int... is) { DefIcon ret = new DefIcon(icon, is); @@ -634,15 +638,15 @@ public class MekanismRenderer public static TextureMap getTextureMap(int type) { try { - List l = (List)MekanismUtils.getPrivateValue(Minecraft.getMinecraft().renderEngine, TextureManager.class, ObfuscatedNames.TextureManager_listTickables); + List l = (List)MekanismUtils.getPrivateValue(Minecraft.getMinecraft().renderEngine, TextureManager.class, ObfuscatedNames.TextureManager_listTickables); - for(Object obj : l) + for(ITickable t : l) { - if(obj instanceof TextureMap) + if(t instanceof TextureMap) { - if(((TextureMap)obj).getTextureType() == type) + if(((TextureMap)t).getTextureType() == type) { - return (TextureMap)obj; + return (TextureMap)t; } } } @@ -666,13 +670,13 @@ public class MekanismRenderer int zLevel = 0; float f = 0.00390625F; float f1 = 0.00390625F; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((par1 + 0), (par2 + par6), zLevel, ((par3 + 0) * f), ((par4 + par6) * f1)); - tessellator.addVertexWithUV((par1 + par5), (par2 + par6), zLevel, ((par3 + par5) * f), ((par4 + par6) * f1)); - tessellator.addVertexWithUV((par1 + par5), (par2 + 0), zLevel, ((par3 + par5) * f), ((par4 + 0) * f1)); - tessellator.addVertexWithUV((par1 + 0), (par2 + 0), zLevel, ((par3 + 0) * f), ((par4 + 0) * f1)); - tessellator.draw(); + WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer(); + worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + worldRenderer.pos((par1 + 0), (par2 + par6), zLevel).tex(((par3 + 0) * f), ((par4 + par6) * f1)).endVertex(); + worldRenderer.pos((par1 + par5), (par2 + par6), zLevel).tex(((par3 + par5) * f), ((par4 + par6) * f1)).endVertex(); + worldRenderer.pos((par1 + par5), (par2 + 0), zLevel).tex(((par3 + par5) * f), ((par4 + 0) * f1)).endVertex(); + worldRenderer.pos((par1 + 0), (par2 + 0), zLevel).tex(((par3 + 0) * f), ((par4 + 0) * f1)).endVertex(); + worldRenderer.finishDrawing(); } public static ResourceLocation getBlocksTexture() @@ -680,11 +684,6 @@ public class MekanismRenderer return TextureMap.locationBlocksTexture; } - public static ResourceLocation getItemsTexture() - { - return TextureMap.locationItemsTexture; - } - public static interface ICustomBlockIcon { public ResourceLocation getIcon(ItemStack stack, int side); diff --git a/src/main/java/mekanism/client/render/tileentity/RenderBin.java b/src/main/java/mekanism/client/render/tileentity/RenderBin.java index 5d923776d..826e67b96 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderBin.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderBin.java @@ -33,9 +33,9 @@ public class RenderBin extends TileEntitySpecialRenderer amount = Integer.toString(tileEntity.clientAmount); } - Coord4D obj = Coord4D.get(tileEntity).offset(EnumFacing.getFront(tileEntity.facing)); + Coord4D obj = Coord4D.get(tileEntity).offset(tileEntity.facing); - if(tileEntity.getWorld().getBlockState(obj).getBlock().isSideSolid(tileEntity.getWorld(), obj, EnumFacing.getFront(tileEntity.facing).getOpposite())) + if(tileEntity.getWorld().getBlockState(obj).getBlock().isSideSolid(tileEntity.getWorld(), obj, tileEntity.facing.getOpposite())) { return; } @@ -47,7 +47,7 @@ public class RenderBin extends TileEntitySpecialRenderer { GL11.glPushMatrix(); - switch(EnumFacing.getFront(tileEntity.facing)) + switch(tileEntity.facing) { case NORTH: GL11.glTranslated(x + 0.73, y + 0.83, z - 0.01); @@ -83,7 +83,7 @@ public class RenderBin extends TileEntitySpecialRenderer if(!amount.equals("")) { - renderText(amount, EnumFacing.getFront(tileEntity.facing), 0.02F, x, y - 0.31F, z); + renderText(amount, tileEntity.facing, 0.02F, x, y - 0.31F, z); } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderChargepad.java b/src/main/java/mekanism/client/render/tileentity/RenderChargepad.java index cbe9d2011..7a78382b3 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderChargepad.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderChargepad.java @@ -24,7 +24,7 @@ public class RenderChargepad extends TileEntitySpecialRenderer GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "GasTank.png")); - switch(tileEntity.facing) + switch(tileEntity.facing.ordinal()) /*TODO: switch the enum*/ { case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; diff --git a/src/main/java/mekanism/client/render/tileentity/RenderLaser.java b/src/main/java/mekanism/client/render/tileentity/RenderLaser.java index c00e804bc..0c114ee0d 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderLaser.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderLaser.java @@ -25,7 +25,7 @@ public class RenderLaser extends TileEntitySpecialRenderer bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Laser.png")); - switch(tileEntity.facing) + switch(tileEntity.facing.ordinal()) /*TODO: switch the enum*/ { case 0: GL11.glTranslatef(0.0F, -2.0F, 0.0F); diff --git a/src/main/java/mekanism/client/render/tileentity/RenderLaserAmplifier.java b/src/main/java/mekanism/client/render/tileentity/RenderLaserAmplifier.java index 285a4f83a..119cfe97e 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderLaserAmplifier.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderLaserAmplifier.java @@ -26,7 +26,7 @@ public class RenderLaserAmplifier extends TileEntitySpecialRenderer list) { switch(blockType) { @@ -349,9 +343,10 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } @Override - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, BlockPos pos) + public boolean canCreatureSpawn(IBlockAccess world, BlockPos pos, SpawnPlacementType type) { - int meta = world.getBlockMetadata(pos); + IBlockState state = world.getBlockState(pos); + int meta = state.getBlock().getMetaFromState(state); switch(blockType) { @@ -380,7 +375,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } } default: - return super.canCreatureSpawn(type, world, pos); + return super.canCreatureSpawn(world, pos, type); } case BASIC_BLOCK_2: switch(meta) @@ -406,26 +401,27 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } } default: - return super.canCreatureSpawn(type, world, pos); + return super.canCreatureSpawn(world, pos, type); } default: - return super.canCreatureSpawn(type, world, pos); + return super.canCreatureSpawn(world, pos, type); } } @Override public void onBlockClicked(World world, BlockPos pos, EntityPlayer player) { - int meta = world.getBlockMetadata(pos); + IBlockState state = world.getBlockState(pos); + int meta = state.getBlock().getMetaFromState(state); if(blockType == BasicBlock.BASIC_BLOCK_1) { if(!world.isRemote && meta == 6) { TileEntityBin bin = (TileEntityBin)world.getTileEntity(pos); - MovingObjectPosition pos = MekanismUtils.rayTrace(world, player); + MovingObjectPosition mop = MekanismUtils.rayTrace(world, player); - if(pos != null && pos.sideHit == bin.facing) + if(mop != null && mop.sideHit == bin.facing) { if(bin.bottomStack != null) { @@ -443,9 +439,9 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } @Override - public boolean onBlockActivated(World world, BlockPos pos, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float hitX, float hitY, float hitZ) { - int metadata = world.getBlockMetadata(pos); + int metadata = state.getBlock().getMetaFromState(state); if(blockType == BasicBlock.BASIC_BLOCK_1) { @@ -461,7 +457,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon { if(entityplayer.isSneaking()) { - entityplayer.openGui(Mekanism.instance, 1, world, pos); + entityplayer.openGui(Mekanism.instance, 1, world, pos.getX(), pos.getY(), pos.getZ()); return true; } } @@ -470,7 +466,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon { if(!entityplayer.isSneaking()) { - entityplayer.openGui(Mekanism.instance, 33, world, pos); + entityplayer.openGui(Mekanism.instance, 33, world, pos.getX(), pos.getY(), pos.getZ()); return true; } } @@ -498,10 +494,10 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon ((IToolWrench)tool).wrenchUsed(entityplayer, pos); } - int change = EnumFacing.ROTATION_MATRIX[EnumFacing.UP.ordinal()][bin.facing]; + int change = bin.facing.rotateY().ordinal(); bin.setFacing((short)change); - world.notifyBlocksOfNeighborChange(pos, this); + world.notifyNeighborsOfStateChange(pos, this); return true; } @@ -534,7 +530,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon bin.addTicks = 5; } - ((EntityPlayerMP)entityplayer).sendContainerAndContentsToPlayer(entityplayer.openContainer, entityplayer.openContainer.getInventory()); + ((EntityPlayerMP)entityplayer).sendContainerToPlayer(entityplayer.openContainer); } } } @@ -569,7 +565,8 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon @Override public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side) { - return !(blockType == BasicBlock.BASIC_BLOCK_1 && world.getBlockMetadata(pos) == 10); + IBlockState state = world.getBlockState(pos); + return !(blockType == BasicBlock.BASIC_BLOCK_1 && state.getBlock().getMetaFromState(state) == 10); } public static boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity) @@ -693,12 +690,6 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon return false; } - @Override - public boolean renderAsNormalBlock() - { - return false; - } - @Override public boolean isOpaqueCube() { @@ -708,14 +699,15 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon @Override public int getRenderType() { - return Mekanism.proxy.CTM_RENDER_ID; + return 3; } @Override public int getLightValue(IBlockAccess world, BlockPos pos) { TileEntity tileEntity = world.getTileEntity(pos); - int metadata = world.getBlockMetadata(pos); + IBlockState state = world.getBlockState(pos); + int metadata = state.getBlock().getMetaFromState(state); if(tileEntity instanceof IActiveState) { @@ -742,8 +734,9 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } @Override - public boolean hasTileEntity(int metadata) + public boolean hasTileEntity(IBlockState state) { + int metadata = state.getBlock().getMetaFromState(state); switch(blockType) { case BASIC_BLOCK_1: @@ -778,7 +771,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } @Override - public void onBlockAdded(World world, BlockPos pos) + public void onBlockAdded(World world, BlockPos pos, IBlockState state) { TileEntity tileEntity = world.getTileEntity(pos); @@ -792,8 +785,9 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } @Override - public TileEntity createTileEntity(World world, int metadata) + public TileEntity createTileEntity(World world, IBlockState state) { + int metadata = state.getBlock().getMetaFromState(state); switch(blockType) { case BASIC_BLOCK_1: @@ -836,13 +830,13 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { if(world.getTileEntity(pos) instanceof TileEntityBasicBlock) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - int side = MathHelper.floor_double((entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); + int side = MathHelper.floor_double((placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int height = Math.round(placer.rotationPitch); int change = 3; if(tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) @@ -869,7 +863,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(pos); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(pos) > 0; if(tileEntity instanceof IBoundingBlock) { @@ -877,9 +871,9 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon } } - world.func_147479_m(pos); - world.updateLightByType(EnumSkyBlock.Block, pos); - world.updateLightByType(EnumSkyBlock.Sky, pos); + world.markBlockRangeForRenderUpdate(pos, pos.add(1,1,1)); + world.checkLightFor(EnumSkyBlock.BLOCK, pos); + world.checkLightFor(EnumSkyBlock.SKY, pos); if(!world.isRemote && world.getTileEntity(pos) != null) { @@ -900,7 +894,8 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) { - ItemStack ret = new ItemStack(this, 1, world.getBlockMetadata(pos)); + IBlockState state = world.getBlockState(pos); + ItemStack ret = new ItemStack(this, 1, state.getBlock().getMetaFromState(state)); if(blockType == BasicBlock.BASIC_BLOCK_1) { @@ -988,6 +983,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon return itemStack; } +/* @Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess world, BlockPos pos, int side) @@ -1002,6 +998,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon return super.shouldSideBeRendered(world, pos, side); } } +*/ @Override public EnumFacing[] getValidRotations(World world, BlockPos pos) @@ -1044,6 +1041,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon return false; } +/* @Override public CTMData getCTMData(IBlockAccess world, BlockPos pos, int meta) { @@ -1068,12 +1066,7 @@ public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon return ctms[meta][0]; } - - @Override - public boolean shouldRenderBlock(IBlockAccess world, BlockPos pos, int meta) - { - return true; - } +*/ public static enum BasicBlock { diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index bbc6c388b..bd93438f4 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -1,7 +1,6 @@ package mekanism.common.block; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -15,16 +14,10 @@ import mekanism.api.MekanismConfig.machines; import mekanism.api.MekanismConfig.usage; import mekanism.api.energy.IEnergizedItem; import mekanism.api.energy.IStrictEnergyStorage; -import mekanism.client.render.MekanismRenderer; -import mekanism.client.render.MekanismRenderer.DefIcon; -import mekanism.client.render.MekanismRenderer.ICustomBlockIcon; -import mekanism.common.CTMData; import mekanism.common.ItemAttacher; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; -import mekanism.common.Tier.BaseTier; import mekanism.common.base.IActiveState; -import mekanism.common.base.IBlockCTM; import mekanism.common.base.IBoundingBlock; import mekanism.common.base.IElectricChest; import mekanism.common.base.IFactory; @@ -101,8 +94,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentText; +import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.util.EnumFacing; @@ -156,14 +151,9 @@ import net.minecraftforge.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlockCTM, ICustomBlockIcon +public class BlockMachine extends BlockContainer implements ISpecialBounds//, IBlockCTM, ICustomBlockIcon { - public IIcon[][] icons = new IIcon[16][16]; - public IIcon[][][] factoryIcons = new IIcon[4][16][16]; - - public CTMData[][] ctms = new CTMData[16][4]; - - public IIcon BASE_ICON; + //public CTMData[][] ctms = new CTMData[16][4]; public MachineBlock blockType; @@ -176,6 +166,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo blockType = type; } +/* @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister register) @@ -249,13 +240,14 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo return getIcon(side, stack.getItemDamage()); } +*/ @Override - public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - int side = MathHelper.floor_double((entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); + int side = MathHelper.floor_double((placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; + int height = Math.round(placer.rotationPitch); int change = 3; if(tileEntity == null) @@ -307,11 +299,11 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo else if(tileEntity instanceof TileEntityTeleporter) { TileEntityTeleporter teleporter = (TileEntityTeleporter)tileEntity; - teleporter.owner = entityliving.getName(); + teleporter.owner = placer.getName(); } tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(pos); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(pos) > 0; if(tileEntity instanceof IBoundingBlock) { @@ -320,7 +312,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } @Override - public void breakBlock(World world, BlockPos pos, Block block, int meta) + public void breakBlock(World world, BlockPos pos, IBlockState state) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); @@ -329,49 +321,48 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo ((IBoundingBlock)tileEntity).onBreak(); } - super.breakBlock(world, pos, block, meta); + super.breakBlock(world, pos, state); } @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, BlockPos pos, Random random) + public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); if(MekanismUtils.isActive(world, pos) && ((IActiveState)tileEntity).renderUpdate() && client.machineEffects) { - float xRandom = (float)x + 0.5F; - float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F; - float zRandom = (float)z + 0.5F; + float xRandom = (float)pos.getX() + 0.5F; + float yRandom = (float)pos.getY() + 0.0F + random.nextFloat() * 6.0F / 16.0F; + float zRandom = (float)pos.getZ() + 0.5F; float iRandom = 0.52F; float jRandom = random.nextFloat() * 0.6F - 0.3F; - int side = tileEntity.facing; + EnumFacing side = tileEntity.facing; if(tileEntity instanceof TileEntityMetallurgicInfuser) { - side = EnumFacing.getFront(side).getOpposite().ordinal(); + side = side.getOpposite(); } - if(side == 4) + switch(side) { - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - } - else if(side == 5) - { - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - } - else if(side == 2) - { - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); - } - else if(side == 3) - { - world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); + case WEST: + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.REDSTONE, (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); + break; + case EAST: + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.REDSTONE, (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); + break; + case NORTH: + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.REDSTONE, (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); + break; + case SOUTH: + world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); + world.spawnParticle(EnumParticleTypes.REDSTONE, (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); + break; } } } @@ -395,6 +386,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo return 0; } +/* @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) @@ -489,16 +481,17 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo return null; } +*/ @Override - public int damageDropped(int i) + public int damageDropped(IBlockState state) { - return i; + return getMetaFromState(state); } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) + public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { for(MachineType type : MachineType.getValidMachines()) { @@ -544,7 +537,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } @Override - public boolean onBlockActivated(World world, BlockPos pos, EntityPlayer entityplayer, int side, float posX, float posY, float posZ) + public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer entityplayer, EnumFacing side, float hitX, float hitY, float hitZ) { if(ItemAttacher.canAttach(entityplayer.getCurrentEquippedItem())) { @@ -557,7 +550,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - int metadata = world.getBlockMetadata(pos); + int metadata = state.getBlock().getMetaFromState(state); if(entityplayer.getCurrentEquippedItem() != null) { @@ -576,7 +569,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo ((IToolWrench)tool).wrenchUsed(entityplayer, pos); } - int change = EnumFacing.ROTATION_MATRIX[EnumFacing.UP.ordinal()][tileEntity.facing]; + int change = tileEntity.facing.rotateY().ordinal(); if(tileEntity instanceof TileEntityLogisticalSorter) { @@ -596,7 +589,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(pos, this); + world.notifyNeighborsOfStateChange(pos, this); return true; } } @@ -610,7 +603,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo case ELECTRIC_CHEST: TileEntityElectricChest electricChest = (TileEntityElectricChest)tileEntity; - if(!(entityplayer.isSneaking() || world.isSideSolid(x, y + 1, z, EnumFacing.DOWN))) + if(!(entityplayer.isSneaking() || world.isSideSolid(pos.up(), EnumFacing.DOWN))) { if(electricChest.canAccess() || MekanismUtils.isOp((EntityPlayerMP)entityplayer)) { @@ -637,7 +630,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } } else { - entityplayer.openGui(Mekanism.instance, type.guiId, world, pos); + entityplayer.openGui(Mekanism.instance, type.guiId, world, pos.getX(), pos.getY(), pos.getZ()); } return true; @@ -656,7 +649,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo if(teleporter.owner.equals(entityplayer.getName()) || MekanismUtils.isOp((EntityPlayerMP)entityplayer)) { - entityplayer.openGui(Mekanism.instance, type.guiId, world, pos); + entityplayer.openGui(Mekanism.instance, type.guiId, world, pos.getX(), pos.getY(), pos.getZ()); } else { entityplayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("gui.teleporter.noAccess"))); @@ -667,7 +660,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo default: if(!entityplayer.isSneaking() && type.guiId != -1) { - entityplayer.openGui(Mekanism.instance, type.guiId, world, pos); + entityplayer.openGui(Mekanism.instance, type.guiId, world, pos.getX(), pos.getY(), pos.getZ()); return true; } @@ -679,8 +672,9 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } @Override - public TileEntity createTileEntity(World world, int metadata) + public TileEntity createTileEntity(World world, IBlockState state) { + int metadata = getMetaFromState(state); if(MachineType.get(blockType, metadata) == null) { return null; @@ -695,12 +689,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo return null; } - @Override - public boolean renderAsNormalBlock() - { - return false; - } - @Override public boolean isOpaqueCube() { @@ -716,13 +704,14 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo @Override public int getRenderType() { - return Mekanism.proxy.CTM_RENDER_ID; + return 3; } @Override public float getBlockHardness(World world, BlockPos pos) { - if(MachineType.get(blockType, world.getBlockMetadata(pos)) != MachineType.ELECTRIC_CHEST) + IBlockState state = world.getBlockState(pos); + if(MachineType.get(blockType, state.getBlock().getMetaFromState(state)) != MachineType.ELECTRIC_CHEST) { return blockHardness; } @@ -733,9 +722,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } @Override - public float getExplosionResistance(Entity entity, World world, BlockPos pos, double explosionX, double explosionY, double explosionZ) + public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion) { - if(MachineType.get(blockType, world.getBlockMetadata(pos)) != MachineType.ELECTRIC_CHEST) + IBlockState state = world.getBlockState(pos); + if(MachineType.get(blockType, state.getBlock().getMetaFromState(state)) != MachineType.ELECTRIC_CHEST) { return blockResistance; } @@ -884,7 +874,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo if(tileEntity instanceof TileEntityBasicBlock) { - ((TileEntityBasicBlock)tileEntity).onNeighborChange(block); + ((TileEntityBasicBlock)tileEntity).onNeighborChange(neighborBlock); } if(tileEntity instanceof TileEntityLogisticalSorter) @@ -912,7 +902,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player) { TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos); - ItemStack itemStack = new ItemStack(this, 1, world.getBlockMetadata(pos)); + IBlockState state = world.getBlockState(pos); + ItemStack itemStack = new ItemStack(this, 1, state.getBlock().getMetaFromState(state)); if(itemStack.getTagCompound() == null) { @@ -983,7 +974,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } @Override - public void onBlockAdded(World world, BlockPos pos) + public void onBlockAdded(World world, BlockPos pos, IBlockState state) { TileEntity tileEntity = world.getTileEntity(pos); @@ -997,9 +988,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } @Override - public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, int side) + public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, EnumFacing side) { - MachineType type = MachineType.get(blockType, world.getBlockMetadata(pos)); + IBlockState state = world.getBlockState(pos); + MachineType type = MachineType.get(blockType, state.getBlock().getMetaFromState(state)); switch(type) { @@ -1034,7 +1026,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo @Override public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos) { - MachineType type = MachineType.get(blockType, world.getBlockMetadata(pos)); + IBlockState state = world.getBlockState(pos); + MachineType type = MachineType.get(blockType, state.getBlock().getMetaFromState(state)); switch(type) { @@ -1051,20 +1044,21 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, BlockPos pos) + public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state) { if(world.getTileEntity(pos) instanceof TileEntityChargepad) { return null; } - return super.getCollisionBoundingBoxFromPool(world, pos); + return super.getCollisionBoundingBox(world, pos, state); } @Override public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side) { - MachineType type = MachineType.get(blockType, world.getBlockMetadata(pos)); + IBlockState state = world.getBlockState(pos); + MachineType type = MachineType.get(blockType, state.getBlock().getMetaFromState(state)); switch(type) { @@ -1391,7 +1385,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo } @Override - public int isProvidingWeakPower(IBlockAccess world, BlockPos pos, int side) + public int getWeakPower(IBlockAccess world, BlockPos pos, IBlockState state, EnumFacing side) { TileEntity tile = world.getTileEntity(pos); @@ -1403,6 +1397,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo return 0; } +/* @Override public CTMData getCTMData(IBlockAccess world, BlockPos pos, int meta) { @@ -1413,10 +1408,11 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlo return ctms[meta][0]; } - + @Override public boolean shouldRenderBlock(IBlockAccess world, BlockPos pos, int meta) { return !MachineType.get(this, meta).hasModel; - } + }*/ + }