From 5b9935f737c226847e668bde0185adbc6a5a8b7b Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Wed, 5 Apr 2017 20:41:13 +0300 Subject: some experiments --- assets/ihl/lang/en_US.lang | 11 + assets/ihl/textures/blocks/dosingPumpBack.png | Bin 0 -> 870 bytes assets/ihl/textures/blocks/dosingPumpFront.png | Bin 0 -> 1009 bytes assets/ihl/textures/blocks/dosingPumpLeft.png | Bin 0 -> 747 bytes assets/ihl/textures/blocks/dosingPumpRight.png | Bin 0 -> 836 bytes assets/ihl/textures/blocks/dosingPumpTop.png | Bin 0 -> 687 bytes assets/ihl/textures/gui/GUIChemicalReactor.png | Bin 3329 -> 3325 bytes assets/ihl/textures/gui/GUIDosingPump.png | Bin 0 -> 4440 bytes ihl/ClientProxy.java | 30 + ihl/IHLMod.java | 22 +- ihl/IHLModInfo.java | 2 +- ihl/ServerProxy.java | 16 +- ihl/enviroment/LightBulbBlock.java | 5 +- ihl/enviroment/LightBulbTileEntity.java | 40 +- ihl/enviroment/LightHandler.java | 134 +++ ihl/enviroment/LightSource.java | 78 ++ ihl/enviroment/SpotlightTileEntity.java | 4 +- ihl/explosion/ExplosionVectorBlockV2.java | 12 +- ihl/items_blocks/FlexibleCableItem.java | 16 +- ihl/items_blocks/IHLTool.java | 4 +- ihl/items_blocks/ItemSubstance.java | 1 + ihl/items_blocks/MachineBaseBlock.java | 950 ++++++++++----------- .../CableHolderSelectionBoxSpecialRenderer.java | 4 + ihl/model/FlexibleCableItemRender.java | 4 + ihl/model/FluidRenderer.java | 4 + ihl/model/IHLBlockRenderer.java | 4 + ihl/model/IHLModelRenderer.java | 3 + ihl/model/IHLToolRenderer.java | 3 + ihl/model/ImpregnatingMachineBlockRender.java | 3 + ihl/model/IronWorkbenchBlockRender.java | 3 + ihl/model/ModelKnee.java | 3 + ihl/model/ModelToplessBox.java | 3 + ihl/model/ModelTube.java | 3 + ihl/model/RectifierTransformerUnitBlockRender.java | 3 + ...TransformerUnitSelectionBoxSpecialRenderer.java | 4 + ihl/model/RefluxCondenserBlockRender.java | 3 + ihl/model/RenderBlocksExt.java | 126 +-- ihl/model/RenderInfo.java | 3 + ihl/model/UniversalTileRender.java | 3 + .../chemistry/ChemicalReactorTileEntity.java | 2 +- ihl/processing/chemistry/DosingPumpContainer.java | 95 +++ ihl/processing/chemistry/DosingPumpGui.java | 101 +++ ihl/processing/chemistry/DosingPumpTileEntity.java | 226 +++++ .../chemistry/FluidizedBedReactorTileEntity.java | 2 +- .../metallurgy/BasicElectricMotorTileEntity.java | 3 +- ihl/worldgen/IHLWorldGenerator.java | 4 +- ihl/worldgen/WorldGeneratorBase.java | 23 +- ihl/worldgen/WorldGeneratorSurfaceLake.java | 11 +- ihl/worldgen/WorldGeneratorUndergroundLake.java | 18 +- ihl_coremod/IHLCoremod.java | 48 ++ ihl_coremod/IHLCoremodContainer.java | 29 + ihl_coremod/WorldRendererClassTransformer.java | 22 + ihl_coremod/WorldRendererClassVisitor.java | 25 + ...WorldRendererRenderBlocksInitMethodVisitor.java | 34 + 54 files changed, 1558 insertions(+), 589 deletions(-) create mode 100644 assets/ihl/textures/blocks/dosingPumpBack.png create mode 100644 assets/ihl/textures/blocks/dosingPumpFront.png create mode 100644 assets/ihl/textures/blocks/dosingPumpLeft.png create mode 100644 assets/ihl/textures/blocks/dosingPumpRight.png create mode 100644 assets/ihl/textures/blocks/dosingPumpTop.png create mode 100644 assets/ihl/textures/gui/GUIDosingPump.png create mode 100644 ihl/enviroment/LightHandler.java create mode 100644 ihl/enviroment/LightSource.java create mode 100644 ihl/processing/chemistry/DosingPumpContainer.java create mode 100644 ihl/processing/chemistry/DosingPumpGui.java create mode 100644 ihl/processing/chemistry/DosingPumpTileEntity.java create mode 100644 ihl_coremod/IHLCoremod.java create mode 100644 ihl_coremod/IHLCoremodContainer.java create mode 100644 ihl_coremod/WorldRendererClassTransformer.java create mode 100644 ihl_coremod/WorldRendererClassVisitor.java create mode 100644 ihl_coremod/WorldRendererRenderBlocksInitMethodVisitor.java diff --git a/assets/ihl/lang/en_US.lang b/assets/ihl/lang/en_US.lang index c373c8d..1a5bb4a 100644 --- a/assets/ihl/lang/en_US.lang +++ b/assets/ihl/lang/en_US.lang @@ -2,12 +2,23 @@ language.name=HAYO language.region=US language.code=en_US +ihl.dosingPump.tip=Type desired amount of fluids /n to be injected to fluid tank near /n dosing pump. Use redstone impulse /n signal to perform injection. /n Press [enter] to accept number. +ihl.detonatorHint=RMB while crafting this to set detonator delay +ihl.setOfDiesHint=RMB while crafting this to set transverse section +ihl.lenght=Length +ihl.resistivity=Resistivity +ihl.wire_material=Wire material +ihl.transverse_section=Transverse section +ihl.insulation_material=Insulation material +ihl.insulation_thickness=Insulation thickness +ihl.insulation_beakdown_voltage=Insulation breakdown voltage ihl.powerCableTooltip=This cable could be used to provide power thru unloaded chunks. ihl.detonator_delay=Detonation delay: ihl.explosionPower=Explosion power: ihl.mTNT=gram of TNT ihl.seconds=s tile.pileBlock.name=Pile of something +tile.dosingPump.name=Dosing pump detonator.name=Detonator dustPentaerythritolTetranitrate.name=Pentaerythritol tetranitrate dustPentaerythritol.name=Pentaerythritol diff --git a/assets/ihl/textures/blocks/dosingPumpBack.png b/assets/ihl/textures/blocks/dosingPumpBack.png new file mode 100644 index 0000000..4064af6 Binary files /dev/null and b/assets/ihl/textures/blocks/dosingPumpBack.png differ diff --git a/assets/ihl/textures/blocks/dosingPumpFront.png b/assets/ihl/textures/blocks/dosingPumpFront.png new file mode 100644 index 0000000..1a98225 Binary files /dev/null and b/assets/ihl/textures/blocks/dosingPumpFront.png differ diff --git a/assets/ihl/textures/blocks/dosingPumpLeft.png b/assets/ihl/textures/blocks/dosingPumpLeft.png new file mode 100644 index 0000000..8cb9d8a Binary files /dev/null and b/assets/ihl/textures/blocks/dosingPumpLeft.png differ diff --git a/assets/ihl/textures/blocks/dosingPumpRight.png b/assets/ihl/textures/blocks/dosingPumpRight.png new file mode 100644 index 0000000..603d57e Binary files /dev/null and b/assets/ihl/textures/blocks/dosingPumpRight.png differ diff --git a/assets/ihl/textures/blocks/dosingPumpTop.png b/assets/ihl/textures/blocks/dosingPumpTop.png new file mode 100644 index 0000000..711ab59 Binary files /dev/null and b/assets/ihl/textures/blocks/dosingPumpTop.png differ diff --git a/assets/ihl/textures/gui/GUIChemicalReactor.png b/assets/ihl/textures/gui/GUIChemicalReactor.png index 2af8f55..20a76dc 100644 Binary files a/assets/ihl/textures/gui/GUIChemicalReactor.png and b/assets/ihl/textures/gui/GUIChemicalReactor.png differ diff --git a/assets/ihl/textures/gui/GUIDosingPump.png b/assets/ihl/textures/gui/GUIDosingPump.png new file mode 100644 index 0000000..5d204d5 Binary files /dev/null and b/assets/ihl/textures/gui/GUIDosingPump.png differ diff --git a/ihl/ClientProxy.java b/ihl/ClientProxy.java index 974a7c4..b3583db 100644 --- a/ihl/ClientProxy.java +++ b/ihl/ClientProxy.java @@ -15,6 +15,7 @@ import ihl.crop_harvestors.SackTileEntity; import ihl.enviroment.LightBulbModel; import ihl.enviroment.LightBulbRender; import ihl.enviroment.LightBulbTileEntity; +import ihl.enviroment.LightHandler; import ihl.enviroment.MirrorRender; import ihl.enviroment.MirrorTileEntity; import ihl.enviroment.SpotlightModel; @@ -41,6 +42,7 @@ import ihl.items_blocks.FlexibleCableItem; import ihl.items_blocks.IHLTool; import ihl.items_blocks.MachineBaseBlock.MachineType; import ihl.model.*; +import ihl.processing.chemistry.DosingPumpTileEntity; import ihl.processing.chemistry.ElectrolysisBathModel; import ihl.processing.chemistry.ElectrolysisBathTileEntity; import ihl.processing.chemistry.FractionatorBottomModel; @@ -121,18 +123,28 @@ import cpw.mods.fml.common.network.internal.FMLProxyPacket; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +@SideOnly(value = Side.CLIENT) public class ClientProxy extends ServerProxy { public boolean loadMirrorRender = true; public IHLRenderUtils renderUtils; public Map sharedBlockRenders = new HashMap(); public Map, ISelectionBoxSpecialRenderer> selectionBoxSpecialRendererRegistry = new HashMap, ISelectionBoxSpecialRenderer>(); + public LightHandler lightHandler; public ClientProxy() { } + public LightHandler getLightHandler() { + + return this.lightHandler; + } + @Override public void load() throws ParserConfigurationException { + if (lightHandler == null) { + lightHandler = new LightHandler(); + } if (channel == null) { channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(IHLModInfo.MODID); channel.register(this); @@ -477,4 +489,22 @@ public class ClientProxy extends ServerProxy { } } + public void sendIntegerFieldValueFromClientToServer(int value, String fieldName, TileEntity tileEntity) { + ByteBuf bb = Unpooled.buffer(64); + ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb); + try { + byteBufOutputStream.write(2); + byteBufOutputStream.writeInt(tileEntity.getWorldObj().provider.dimensionId); + byteBufOutputStream.writeInt(tileEntity.xCoord); + byteBufOutputStream.writeInt(tileEntity.yCoord); + byteBufOutputStream.writeInt(tileEntity.zCoord); + byteBufOutputStream.writeInt(value); + byteBufOutputStream.writeUTF(fieldName); + channel.sendToServer(new FMLProxyPacket(byteBufOutputStream.buffer(), IHLModInfo.MODID)); + byteBufOutputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } diff --git a/ihl/IHLMod.java b/ihl/IHLMod.java index 6483856..7a8323b 100644 --- a/ihl/IHLMod.java +++ b/ihl/IHLMod.java @@ -249,6 +249,10 @@ public class IHLMod implements IFuelHandler { GameRegistry.registerBlock(tditBlock, "tditBlock"); GameRegistry.registerTileEntity(TDITTileEntity.class, "tditTileEntity"); GameRegistry.registerItem(tditft, "tditftItem"); + MinecraftForge.EVENT_BUS.register(new ChunkAndWorldLoadEventHandler()); + IHLMod.log.info("IHL precalculating explosion."); + IHLMod.explosionHandler = new ExplosionVectorBlockV2(); + IHLMod.log.info("Explosion calculated."); proxy.load(); registerEntities(); OreDictionary.registerOre("ingotBrick", Items.brick); @@ -260,10 +264,6 @@ public class IHLMod implements IFuelHandler { OreDictionary.registerOre("platePaper", new ItemStack(Items.paper, 1, OreDictionary.WILDCARD_VALUE)); OreDictionary.registerOre("dustGunpowder", new ItemStack(Items.gunpowder, 1, OreDictionary.WILDCARD_VALUE)); OreDictionary.registerOre("blockExplosive", IHLUtils.getThisModItemStack("ihlExplosive")); - MinecraftForge.EVENT_BUS.register(new ChunkAndWorldLoadEventHandler()); - IHLMod.log.info("IHL precalculating explosion."); - IHLMod.explosionHandler = new ExplosionVectorBlockV2(); - IHLMod.log.info("Explosion calculated."); } @EventHandler @@ -836,6 +836,20 @@ public class IHLMod implements IFuelHandler { IHLUtils.getThisModItemStackWithSize("barD10Steel", 4) }), Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("chemicalReactor") }), Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new IRecipeInput[] { + new RecipeInputItemStack(IHLUtils.getThisModItemStack("handDrillBronze")), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("drillSteelHardened")) + }), + Arrays.asList(new IRecipeInput[] { + new RecipeInputItemStack(IHLUtils.getThisModItemStack("electricMotorLVLEDC")), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("pipelineAccessoriesSteel")), + new RecipeInputOreDict("foilRubber"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("highPressureVesselSteel")), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("pistonCylinderSteel")), + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("boltM10x1Steel",8)), + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("nutM10x1Steel",8))}), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("dosingPump") }))); IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hammer"), IHLUtils.getThisModItemStack("handDrillBronze"), IHLUtils.getThisModItemStack("hackSawSteel"), IHLUtils.getThisModItemStack("drillSteelHardened"), diff --git a/ihl/IHLModInfo.java b/ihl/IHLModInfo.java index 42fcd88..2e05255 100644 --- a/ihl/IHLModInfo.java +++ b/ihl/IHLModInfo.java @@ -3,5 +3,5 @@ package ihl; public class IHLModInfo { public static final String MODID = "ihl"; public static final String MODNAME = "IHL Tools & Machines for IC2V2"; - public static final String MODVERSION = "0.624"; + public static final String MODVERSION = "0.628"; } diff --git a/ihl/ServerProxy.java b/ihl/ServerProxy.java index 24fa937..385bcec 100644 --- a/ihl/ServerProxy.java +++ b/ihl/ServerProxy.java @@ -183,7 +183,7 @@ public class ServerProxy { } @SubscribeEvent - public void onPacketFromClientToServer(FMLNetworkEvent.ServerCustomPacketEvent event) throws IOException + public void onPacketFromClientToServer(FMLNetworkEvent.ServerCustomPacketEvent event) throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { ByteBuf data = event.packet.payload(); ByteBufInputStream byteBufInputStream = new ByteBufInputStream(data); @@ -216,6 +216,20 @@ public class ServerProxy { player.playerNetServerHandler.sendPacket(new S35PacketUpdateTileEntity(x,y,z,6,nbt)); } break; + case 2: + worldDimensionId = byteBufInputStream.readInt(); + x = byteBufInputStream.readInt(); + y = byteBufInputStream.readInt(); + z = byteBufInputStream.readInt(); + world = MinecraftServer.getServer().worldServerForDimension(worldDimensionId); + te = world.getTileEntity(x, y, z); + if(te!=null && !te.isInvalid()) + { + int value = byteBufInputStream.readInt(); + fieldName = byteBufInputStream.readUTF(); + te.getClass().getDeclaredField(fieldName).set(te, value); + } + break; } byteBufInputStream.close(); diff --git a/ihl/enviroment/LightBulbBlock.java b/ihl/enviroment/LightBulbBlock.java index 77ee8f8..720ca4e 100644 --- a/ihl/enviroment/LightBulbBlock.java +++ b/ihl/enviroment/LightBulbBlock.java @@ -25,6 +25,7 @@ public class LightBulbBlock extends Block implements ITileEntityProvider { this.setResistance(0.5F); this.setCreativeTab(IHLCreativeTab.tab); this.setBlockTextureName("glass"); + this.setLightOpacity(16); } @Override @@ -108,11 +109,11 @@ public class LightBulbBlock extends Block implements ITileEntityProvider { } public int getLightValue(IBlockAccess world, int x, int y, int z) { - TileEntity te = world.getTileEntity(x, y, z); +/* TileEntity te = world.getTileEntity(x, y, z); if (te != null && te instanceof LightBulbTileEntity) { LightBulbTileEntity ate = (LightBulbTileEntity) te; return ate.getActive() ? 15 : 0; - } + }*/ return 0; } } diff --git a/ihl/enviroment/LightBulbTileEntity.java b/ihl/enviroment/LightBulbTileEntity.java index 283a72f..f2c229b 100644 --- a/ihl/enviroment/LightBulbTileEntity.java +++ b/ihl/enviroment/LightBulbTileEntity.java @@ -3,6 +3,8 @@ package ihl.enviroment; import java.util.List; import java.util.Vector; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -14,12 +16,17 @@ import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergySink; import ic2.api.network.INetworkDataProvider; +import ic2.api.network.INetworkTileEntityEventListener; import ic2.api.tile.IWrenchable; import ic2.core.IC2; import ic2.core.ITickCallback; +import ihl.ClientProxy; +import ihl.IHLMod; +import ihl.IHLModInfo; +import ihl.model.RenderBlocksExt; import ihl.utils.IHLUtils; -public class LightBulbTileEntity extends TileEntity implements IEnergySink, IWrenchable, INetworkDataProvider { +public class LightBulbTileEntity extends TileEntity implements IEnergySink, IWrenchable, INetworkDataProvider, INetworkTileEntityEventListener { private boolean active = false; private short facing = 0; public boolean prevActive = false; @@ -28,6 +35,8 @@ public class LightBulbTileEntity extends TileEntity implements IEnergySink, IWre public boolean addedToEnergyNet = false; private boolean loaded = false; private int ticker; + @SideOnly(value = Side.CLIENT) + LightSource lightSource; @Override public void readFromNBT(NBTTagCompound nbttagcompound) { @@ -99,7 +108,7 @@ public class LightBulbTileEntity extends TileEntity implements IEnergySink, IWre this.addedToEnergyNet = false; } this.active = false; - this.updateLightState(true); + this.updateLightState(); } } @@ -123,9 +132,18 @@ public class LightBulbTileEntity extends TileEntity implements IEnergySink, IWre } } - protected void updateLightState(boolean spreadDarkness) { + protected void updateLightState() { if (IC2.platform.isSimulating()) { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } else if (IC2.platform.isRendering()) { + if (lightSource == null && this.getActive()) { + lightSource = ((ClientProxy) IHLMod.proxy).getLightHandler().calculateOmniLightSource(worldObj, xCoord, + yCoord, zCoord, 8096, 255, 255, 0); + ((ClientProxy) IHLMod.proxy).getLightHandler().addLightSource(lightSource); + } else if (lightSource != null) { + ((ClientProxy) IHLMod.proxy).getLightHandler().removeLightSource(lightSource); + lightSource = null; + } } } @@ -230,10 +248,10 @@ public class LightBulbTileEntity extends TileEntity implements IEnergySink, IWre public void setActive(boolean active1) { this.active = active1; - if (this.prevActive != active1) { IC2.network.get().updateTileEntityField(this, "active"); - updateLightState(!active1); + IC2.network.get().initiateTileEntityEvent(this, active1?1:0, true); + updateLightState(); } this.prevActive = active1; } @@ -242,4 +260,16 @@ public class LightBulbTileEntity extends TileEntity implements IEnergySink, IWre this.active = active1; this.prevActive = active1; } + + @Override + public void onNetworkEvent(int event) + { + boolean active1 = event==1; + this.active = active1; + if (this.prevActive != active1) { + updateLightState(); + } + this.prevActive = active1; + } + } diff --git a/ihl/enviroment/LightHandler.java b/ihl/enviroment/LightHandler.java new file mode 100644 index 0000000..b3f8da6 --- /dev/null +++ b/ihl/enviroment/LightHandler.java @@ -0,0 +1,134 @@ +package ihl.enviroment; + +import java.util.BitSet; +import java.util.HashSet; +import java.util.Set; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLMod; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; + +@SideOnly(value = Side.CLIENT) +public class LightHandler { + + private int[][] directionMasks; + private int[][] vectors; + private int bits; + private int halfValue; + + private int lightBitsPerDimension = 10; + private int maxLightRadius = (1 << lightBitsPerDimension - 1) - 1; + private int bitmask = (1 << lightBitsPerDimension) - 1; + public final Set lightSources = new HashSet(); + + public LightHandler() { + this.directionMasks = IHLMod.explosionHandler.directionMasks; + this.vectors = IHLMod.explosionHandler.vectors; + this.bits = IHLMod.explosionHandler.bits; + this.halfValue = IHLMod.explosionHandler.halfValue; + } + + public int encodeXYZ(int x, int y, int z) { + return x + maxLightRadius << lightBitsPerDimension * 2 | y + maxLightRadius << lightBitsPerDimension + | z + maxLightRadius; + } + + public int[] decodeXYZ(int l) { + return new int[] { (l >>> lightBitsPerDimension * 2) - maxLightRadius, + ((l >>> lightBitsPerDimension) & bitmask) - maxLightRadius, (l & bitmask) - maxLightRadius }; + } + + public LightSource calculateOmniLightSource(World world, int sourceX, int sourceY, int sourceZ, int power, int red, + int green, int blue) { + LightSource lightSource = new LightSource(sourceX, sourceY, sourceZ, red, green, blue, power); + int[] borders = { sourceX, sourceY, sourceZ, sourceX, sourceY, sourceZ }; + int[] evSource = { sourceX, sourceY, sourceZ }; + int[] lightSourceXYZ = { sourceX, sourceY, sourceZ }; + for (int i = 0; i < directionMasks.length; i++) { + int[] directionMask = directionMasks[i]; + this.litBlocksAndGetDescendants(world, evSource, lightSourceXYZ, lightSource.illuminatedBlocks, 0, power, + directionMask, borders); + } + lightSource.setBorders(borders[0], borders[1], borders[2], borders[3], borders[4], borders[5]); + return lightSource; + } + + private void litBlocksAndGetDescendants(World world, int[] evSource, int[] lightSource, BitSet illuminatedBlocksSet, + int ev, int power, int[] directionMask, int[] borders) { + power = this.getNewPower(world, ev, evSource, lightSource, power, directionMask, illuminatedBlocksSet, borders); + power = (power<<1)/3 - 1; + if (power > 1) { + if (vectors[ev][0] == 0) { + int[] xyz = IHLMod.explosionHandler.decodeXYZ(ev); + int xb = xyz[0] >> bits - 1; + int yb = xyz[1] >> bits - 1; + int zb = xyz[2] >> bits - 1; + int hashb = xb << 2 | yb << 1 | zb; + xyz[0] -= xb * halfValue; + xyz[1] -= yb * halfValue; + xyz[2] -= zb * halfValue; + if (hashb == 0 || xb > 1 || yb > 1 || zb > 1) { + throw new ArithmeticException("End vectors shall be higher than half value"); + } + int ev2 = IHLMod.explosionHandler.encodeXYZ(xyz[0], xyz[1], xyz[2]); + int[] nextEVSource = { evSource[0] + xb * halfValue * directionMask[0], + evSource[1] + yb * halfValue * directionMask[1], + evSource[2] + zb * halfValue * directionMask[2] }; + litBlocksAndGetDescendants(world, nextEVSource, lightSource, illuminatedBlocksSet, ev2, power, + directionMask, borders); + } else { + for (int d1 : this.vectors[ev]) { + if (d1 != 0) { + litBlocksAndGetDescendants(world, evSource, lightSource, illuminatedBlocksSet, d1, power, + directionMask, borders); + } + } + } + } + + } + + private int getNewPower(World world, int ev, int[] evSource, int[] lightSource, int power, int[] directionMask, + BitSet illuminatedBlocksSet, int[] borders) { + int power1 = power; + int[] xyz = IHLMod.explosionHandler.decodeXYZ(ev); + int absX = xyz[0] * directionMask[0] + evSource[0]; + int absY = xyz[1] * directionMask[1] + evSource[1]; + int absZ = xyz[2] * directionMask[2] + evSource[2]; + if (absX < borders[0]) { + borders[0] = absX; + } else if (absY < borders[1]) { + borders[1] = absY; + } else if (absZ < borders[2]) { + borders[2] = absZ; + } else if (absX > borders[3]) { + borders[3] = absX; + } else if (absY > borders[4]) { + borders[4] = absY; + } else if (absZ > borders[5]) { + borders[5] = absZ; + } + Block block = world.getBlock(absX, absY, absZ); + if (block.equals(Blocks.air) || block.isAir(world, absX, absY, absZ)) { + return power; + } + power1 *= world.getBlockLightOpacity(absX, absY, absZ) / 16; + int lightBitAddress = this.encodeXYZ(absX - lightSource[0], absY - lightSource[1], absZ - lightSource[2]); + illuminatedBlocksSet.set(lightBitAddress); + return power1; + } + + public void addLightSource(LightSource lightSource) { + System.out.println("Adding light source. Borders:"); + System.out.println("from " + lightSource.fromX + ";" + lightSource.fromY + ";" + lightSource.fromZ); + System.out.println("to " + lightSource.toX + ";" + lightSource.toY + ";" + lightSource.toZ); + this.lightSources.add(lightSource); + } + + public void removeLightSource(LightSource lightSource) { + this.lightSources.remove(lightSource); + } +} diff --git a/ihl/enviroment/LightSource.java b/ihl/enviroment/LightSource.java new file mode 100644 index 0000000..291b15a --- /dev/null +++ b/ihl/enviroment/LightSource.java @@ -0,0 +1,78 @@ +package ihl.enviroment; + +import java.util.BitSet; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.ClientProxy; +import ihl.IHLMod; + +@SideOnly(value=Side.CLIENT) +public class LightSource { + private final int centerX; + private final int centerY; + private final int centerZ; + public int fromX; + public int fromY; + public int fromZ; + public int toX; + public int toY; + public int toZ; + private final int red; + private final int green; + private final int blue; + private final int power; + public final BitSet illuminatedBlocks = new BitSet(); + + public LightSource(int centerX1, int centerY1, int centerZ1, + int red1, int green1, int blue1, int power1) { + centerX = centerX1; + centerY = centerY1; + centerZ = centerZ1; + red = red1; + green = green1; + blue = blue1; + power = power1; + } + + public void setBorders(int fromX1, int fromY1, int fromZ1, + int toX1, int toY1, int toZ1) + { + fromX=fromX1; + fromY=fromY1; + fromZ=fromZ1; + toX=toX1; + toY=toY1; + toZ=toZ1; + } + + public boolean isBlockIlluminated(int x, int y, int z) { + if(xtoX || ytoY || ztoZ) + { + return false; + } + else + { + int rx = x - centerX; + int ry = y - centerY; + int rz = z - centerZ; + int l = ((ClientProxy)IHLMod.proxy).getLightHandler().encodeXYZ(rx, ry, rz); + return illuminatedBlocks.get(l); + } + } + + public int[] getLightValue(int x, int y, int z, int[] normal) { + int dx = centerX-x; + int dy = centerY-y; + int dz = centerZ-z; + int d = dx*dx+dy*dy+dz*dz; + dx=normal[0]*dx; + dy=normal[1]*dy; + dz=normal[2]*dz; + dx=dx>0?(dx<<16)/d:0; + dy=dy>0?(dy<<16)/d:0; + dz=dz>0?(dz<<16)/d:0; + int brightness = Math.min(power*(dx+dy+dz)>>16,255); + return new int[]{brightness, this.red, this.blue, this.green}; + } +} diff --git a/ihl/enviroment/SpotlightTileEntity.java b/ihl/enviroment/SpotlightTileEntity.java index 287ef9f..ab18ebe 100644 --- a/ihl/enviroment/SpotlightTileEntity.java +++ b/ihl/enviroment/SpotlightTileEntity.java @@ -111,7 +111,7 @@ public class SpotlightTileEntity extends LightBulbTileEntity implements INetwork if(needLightTargetUpdate) { this.generateGlowningAirList(); - this.updateLightState(this.getActive()); + this.updateLightState(); needLightTargetUpdate=false; } if(this.prevRotationPitch!=this.rotationPitch) @@ -214,7 +214,7 @@ public class SpotlightTileEntity extends LightBulbTileEntity implements INetwork } @Override - protected void updateLightState(boolean spreadDarkness) + protected void updateLightState() { if(this.getActive()) { diff --git a/ihl/explosion/ExplosionVectorBlockV2.java b/ihl/explosion/ExplosionVectorBlockV2.java index daa16ce..f766a09 100644 --- a/ihl/explosion/ExplosionVectorBlockV2.java +++ b/ihl/explosion/ExplosionVectorBlockV2.java @@ -32,12 +32,12 @@ import net.minecraftforge.event.world.ExplosionEvent; public class ExplosionVectorBlockV2 { final Set startVectors = new HashSet(); - private final int[][] directionMasks = new int[8][3]; - private final int bits = IHLMod.config.explosionVectorSizeBits; + public final int[][] directionMasks = new int[8][3]; + public final int bits = IHLMod.config.explosionVectorSizeBits; private final int maxValue = (1 << bits) - 1; - private final int halfValue = (1 << bits - 1) - 1; + public final int halfValue = (1 << bits - 1) - 1; private final int maxArraySize = 1 << bits * 3; - private final int[][] vectors = new int[maxArraySize][2]; + public final int[][] vectors = new int[maxArraySize][2]; private final Set chunksToUpdate = new HashSet(64); private final Map cachedDrops = new HashMap(128); final Map blastWaveByDimensionId = new HashMap(); @@ -57,11 +57,11 @@ public class ExplosionVectorBlockV2 { directionMasks[7] = new int[] { -1, -1, -1 }; } - private int encodeXYZ(int x, int y, int z) { + public int encodeXYZ(int x, int y, int z) { return x << bits * 2 | y << bits | z; } - private int[] decodeXYZ(int l) { + public int[] decodeXYZ(int l) { return new int[] { l >> bits * 2, l >> bits & maxValue, l & maxValue }; } diff --git a/ihl/items_blocks/FlexibleCableItem.java b/ihl/items_blocks/FlexibleCableItem.java index e7b7986..590f240 100644 --- a/ihl/items_blocks/FlexibleCableItem.java +++ b/ihl/items_blocks/FlexibleCableItem.java @@ -362,19 +362,19 @@ public class FlexibleCableItem extends Item implements IWire { } return 0xFFFFFF; } - + @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) { if (itemStack.stackTagCompound != null) { - info.add("Length: " + itemStack.stackTagCompound.getInteger("length") + " m"); - info.add("Wire material: " + this.getMaterial(itemStack)); - info.add("Resistivity: " + this.getResistance(itemStack) / 1000F + " V^2/(EU*m)"); - info.add("Transverse section: " + this.getTransverseSection(itemStack) / 10F + " sq. mm."); + info.add(StatCollector.translateToLocal("ihl.lenght")+": " + itemStack.stackTagCompound.getInteger("length") + " m"); + info.add(StatCollector.translateToLocal("ihl.wire_material")+"Wire material: " + this.getMaterial(itemStack)); + info.add(StatCollector.translateToLocal("ihl.resistivity")+"Resistivity: " + this.getResistance(itemStack) / 1000F + " V^2/(EU*m)"); + info.add(StatCollector.translateToLocal("ihl.transverse_section")+"Transverse section: " + this.getTransverseSection(itemStack) / 10F + " sq. mm."); if (itemStack.stackTagCompound.hasKey("insulationMaterial")) { - info.add("Insulation material: " + this.getInsulationMaterial(itemStack)); - info.add("Insulation thickness: " + this.getInsulationThickness(itemStack) / 10f + " mm"); - info.add("Insulation breakdown voltage: " + this.getVoltageLimit(itemStack) / 1000 + " kV"); + info.add(StatCollector.translateToLocal("ihl.insulation_material")+"Insulation material: " + this.getInsulationMaterial(itemStack)); + info.add(StatCollector.translateToLocal("ihl.insulation_thickness")+"Insulation thickness: " + this.getInsulationThickness(itemStack) / 10f + " mm"); + info.add(StatCollector.translateToLocal("ihl.insulation_beakdown_voltage")+"Insulation breakdown voltage: " + this.getVoltageLimit(itemStack) / 1000 + " kV"); } info.add(StatCollector.translateToLocal("ihl.powerCableTooltip")); } diff --git a/ihl/items_blocks/IHLTool.java b/ihl/items_blocks/IHLTool.java index 4a4c662..1479072 100644 --- a/ihl/items_blocks/IHLTool.java +++ b/ihl/items_blocks/IHLTool.java @@ -228,7 +228,7 @@ public class IHLTool extends Item implements IItemHasMiniGUI{ Grindstone("grindstone",4,2000,0.5f,false,null,(String[])null), Hammer("hammer",3,20000,2.5f,false,null,"craftingToolHardHammer","craftingToolForgeHammer"), TinSnipsSteel("tinSnipsSteel",2,2000,0.5f,false,null,"craftingToolWireCutter"), - SetOfDies1_5sqmm("setOfDies1_5sqmm",0,2000,0.5f,false,null,(String[])null); + SetOfDies1_5sqmm("setOfDies1_5sqmm",0,2000,0.5f,false,"ihl.setOfDiesHint",(String[])null); Type(String unlocalizedName1,int itemDamage1, int maxToolDamage1, float damageVersusEntity1, boolean isWeapon1, String hint1, String... oreDictName1) { unLocalizedName=unlocalizedName1; @@ -256,7 +256,7 @@ public class IHLTool extends Item implements IItemHasMiniGUI{ info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.attack_damage") +EnumChatFormatting.DARK_BLUE + damageVersusEntityMap.get(itemStack.getItemDamage())); if(hintMap.containsKey(itemStack.getItemDamage())) { - info.add(EnumChatFormatting.DARK_RED+StatCollector.translateToLocal(hintMap.get(itemStack.getItemDamage()))); + info.add(EnumChatFormatting.RED+StatCollector.translateToLocal(hintMap.get(itemStack.getItemDamage()))); } if(itemStack.stackTagCompound.hasKey("transverseSection")) { diff --git a/ihl/items_blocks/ItemSubstance.java b/ihl/items_blocks/ItemSubstance.java index 30ef694..9c55e36 100644 --- a/ihl/items_blocks/ItemSubstance.java +++ b/ihl/items_blocks/ItemSubstance.java @@ -178,6 +178,7 @@ public class ItemSubstance extends Item implements IItemHasMiniGUI { info.add(StatCollector.translateToLocal("ihl.detonator_delay") + " " + itemStack.stackTagCompound.getInteger("detonator_delay") + StatCollector.translateToLocal("ihl.seconds")); + info.add(StatCollector.translateToLocal("ihl.detonatorHint")); } } diff --git a/ihl/items_blocks/MachineBaseBlock.java b/ihl/items_blocks/MachineBaseBlock.java index a2d2a98..6276e93 100644 --- a/ihl/items_blocks/MachineBaseBlock.java +++ b/ihl/items_blocks/MachineBaseBlock.java @@ -14,6 +14,7 @@ import ihl.interfaces.IEnergyNetNode; import ihl.interfaces.IMultiPowerCableHolder; import ihl.processing.chemistry.ChemicalReactorTileEntity; import ihl.processing.chemistry.CryogenicDistillerTileEntity; +import ihl.processing.chemistry.DosingPumpTileEntity; import ihl.processing.chemistry.ElectrolysisBathTileEntity; import ihl.processing.chemistry.FluidizedBedReactorTileEntity; import ihl.processing.chemistry.FractionatorBottomTileEntity; @@ -67,97 +68,70 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class MachineBaseBlock extends Block implements ITileEntityProvider{ - +public class MachineBaseBlock extends Block implements ITileEntityProvider { + MachineType type; private static List instances = new ArrayList(); - + @SideOnly(Side.CLIENT) - IIcon textureSide, - textureBack, - textureFrontMuffleFurnance, - textureTop, - textureTopAchesonFurnance, - textureTopGoldFurnace, - textureFrontGoldFurnace, - textureSideGoldFurnace, - textureFrontCryogenicDistiller, - textureTopCryogenicDistiller, - textureBackCryogenicDistiller, - textureFrontChemicalReactor, - textureLeftMachineCasing, - textureTopMachineCasing, - textureRightMachineCasing, - textureFrontMachineCasing, - textureFrontPaperMachine, - textureBackMachineCasing, - bronzeTubTop, - bronzeTubSide, - steel, - redPaint, - greenPaint, - rubberInsulatedCase, - powerPort; - - public MachineBaseBlock(MachineType type1) - { + IIcon textureSide, textureBack, textureFrontMuffleFurnance, textureTop, textureTopAchesonFurnance, + textureTopGoldFurnace, textureFrontGoldFurnace, textureSideGoldFurnace, textureFrontCryogenicDistiller, + textureTopCryogenicDistiller, textureBackCryogenicDistiller, textureFrontChemicalReactor, + textureLeftMachineCasing, textureTopMachineCasing, textureRightMachineCasing, textureFrontMachineCasing, + textureFrontPaperMachine, textureBackMachineCasing, bronzeTubTop, bronzeTubSide, steel, redPaint, + greenPaint, rubberInsulatedCase, powerPort, dosingPumpBack, dosingPumpLeftSide, dosingPumpRightSide, + dosingPumpTop, dosingPumpFront; + + public MachineBaseBlock(MachineType type1) { super(Material.iron); - this.type=type1; - this.setCreativeTab(IHLCreativeTab.tab); - this.setBlockName(type.unlocalizedName); - this.setHardness(2F); - this.setResistance(1F); - instances.add(this); + this.type = type1; + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockName(type.unlocalizedName); + this.setHardness(2F); + this.setResistance(1F); + instances.add(this); } - - + @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if(IC2.platform.isSimulating()) - { - TileEntity te = world.getTileEntity(x,y,z); - if(world.getBlock(x, y+1, z)==Blocks.fire) - { - if(te instanceof DetonationSprayingMachineTileEntity) - { - ((DetonationSprayingMachineTileEntity)te).operate(); - world.setBlockToAir(x, y+1, z); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (IC2.platform.isSimulating()) { + TileEntity te = world.getTileEntity(x, y, z); + boolean isPowered = world.isBlockIndirectlyGettingPowered(x, y, z); + if (te instanceof DosingPumpTileEntity) { + DosingPumpTileEntity dpte = (DosingPumpTileEntity) te; + dpte.setPowered(isPowered); + } + + if (world.getBlock(x, y + 1, z) == Blocks.fire) { + if (te instanceof DetonationSprayingMachineTileEntity) { + ((DetonationSprayingMachineTileEntity) te).operate(); + world.setBlockToAir(x, y + 1, z); } } } } - - + @Override - public void onBlockPreDestroy(World world, int x, int y, int z, int meta) - { - if(!world.isRemote) - { + public void onBlockPreDestroy(World world, int x, int y, int z, int meta) { + if (!world.isRemote) { TileEntity te = world.getTileEntity(x, y, z); - if(te!=null) - { - if(te instanceof IEnergyNetNode) - { + if (te != null) { + if (te instanceof IEnergyNetNode) { IEnergyNetNode ate = (IEnergyNetNode) te; - ate.removeAttachedChains(); + ate.removeAttachedChains(); } - if(te instanceof IMultiPowerCableHolder) - { + if (te instanceof IMultiPowerCableHolder) { IMultiPowerCableHolder ate = (IMultiPowerCableHolder) te; - ate.removeAttachedChains(); + ate.removeAttachedChains(); } - if(te instanceof IronWorkbenchTileEntity) - { - IronWorkbenchTileEntity iwb=(IronWorkbenchTileEntity) te; + if (te instanceof IronWorkbenchTileEntity) { + IronWorkbenchTileEntity iwb = (IronWorkbenchTileEntity) te; iwb.dropContents(); - } - else if(te instanceof IInventory) - { - IInventory inventory = (IInventory)te; - for(int i = 0; i< inventory.getSizeInventory();i++) - { - if(inventory.getStackInSlot(i)!=null)world.spawnEntityInWorld(new EntityItem(world, x, y+1, z, inventory.getStackInSlot(i))); + } else if (te instanceof IInventory) { + IInventory inventory = (IInventory) te; + for (int i = 0; i < inventory.getSizeInventory(); i++) { + if (inventory.getStackInSlot(i) != null) + world.spawnEntityInWorld(new EntityItem(world, x, y + 1, z, inventory.getStackInSlot(i))); } } } @@ -167,10 +141,9 @@ public class MachineBaseBlock extends Block implements ITileEntityProvider{ @SuppressWarnings("rawtypes") @Override - public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) - { - switch(this.type) - { + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, + Entity entity) { + switch (this.type) { case BronzeTub: this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1F, 1.0F); super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); @@ -184,496 +157,483 @@ public class MachineBaseBlock extends Block implements ITileEntityProvider{ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); this.setBlockBoundsForItemRender(); break; - default: - super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); - break; + default: + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + break; } - } - - @Override - public void setBlockBoundsForItemRender() - { - this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - - public static void init() - { + } + + @Override + public void setBlockBoundsForItemRender() { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public static void init() { MachineType[] var1 = MachineType.values(); - for(int i=0;i teclass1, boolean isNormalBlock1,ItemStack itemDroppedOnBlockDestroy1) - { - unlocalizedName=unlocalizedName1; - teclass=teclass1; - isNormalBlock=isNormalBlock1; - if(isNormalBlock) - { - specialBlockRendererId=0; - } - else - { - specialBlockRendererId=-2; - } - itemDroppedOnBlockDestroy=itemDroppedOnBlockDestroy1; - } - MachineType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1,boolean hasSpecialBlockRenderer1, ItemStack itemDroppedOnBlockDestroy1) - { - unlocalizedName=unlocalizedName1; - teclass=teclass1; - isNormalBlock=isNormalBlock1; - hasSpecialBlockRenderer=hasSpecialBlockRenderer1; - itemDroppedOnBlockDestroy=itemDroppedOnBlockDestroy1; - - } + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int metadata) { + return this.isProvidingWeakPower(world, x, y, z, metadata); + } + + public enum MachineType { + DosingPump("dosingPump", DosingPumpTileEntity.class, true, null), + IronWorkbench("ironWorkbench", IronWorkbenchTileEntity.class, false, true, null), + ElectrolysisBath("electrolysisBath", ElectrolysisBathTileEntity.class, false, IHLUtils + .getThisModItemStack("plateGraphite")), + RectifierTransformerUnit("rectifierTransformerUnit", RectifierTransformerUnitTileEntity.class, false, true, IHLUtils + .getThisModItemStack("foilSteel")), + BatterySwitchUnit("batterySwitchUnit", BatterySwitchUnitTileEntity.class, false, IHLUtils + .getThisModItemStack("foilSteel")), + FractionatorBottom("fractionatorBottom", FractionatorBottomTileEntity.class, false, IHLUtils + .getThisModItemStack("foilSteel")), + FractionatorSection("fractionatorSection", FractionatorSectionTileEntity.class, false, IHLUtils + .getThisModItemStackWithSize("ringPorcelain", 16)), + FractionatorCover("fractionatorCover", FractionatorCoverTileEntity.class, false, IHLUtils + .getThisModItemStack("foilSteel")), + RefluxCondenser("refluxCondenser", RefluxCondenserTileEntity.class, false, false, IHLUtils + .getThisModItemStack("foilSteel")), + PaperMachine("paperMachine", PaperMachineTileEntity.class, true, IHLUtils.getThisModItemStack("stickSteel")), + GaedesMercuryRotaryPump("gaedesMercuryRotaryPump", GaedesMercuryRotaryPumpTileEntity.class, false, IHLUtils + .getThisModItemStack("foilSteel")), + LabElectrolyzer("labElectrolyzer", LabElectrolyzerTileEntity.class, true, IHLUtils + .getThisModItemStack("stickGraphite")), + FluidizedBedReactor("fluidizedBedReactor", FluidizedBedReactorTileEntity.class, true, IHLUtils + .getThisModItemStack("highPressureVesselSteel")), + ChemicalReactor("chemicalReactor", ChemicalReactorTileEntity.class, true, IHLUtils + .getThisModItemStack("highPressureVesselSteel")), + CryogenicDistiller("cryogenicDistiller", CryogenicDistillerTileEntity.class, true, IHLUtils + .getThisModItemStack("highPressureVesselSteel")), + GasWeldingStation("gasWeldingStation", GasWeldingStationTileEntity.class, false, null), + WoodenRollingMachine1("woodenRollingMachinePart1", WoodenRollingMachinePart1TileEntity.class, false, IHLUtils + .getThisModItemStack("barD10Steel")), + WoodenRollingMachine2("woodenRollingMachinePart2", WoodenRollingMachinePart2TileEntity.class, false, IHLUtils + .getThisModItemStack("barD10Steel")), + WireMill("wireMill", WireMillTileEntity.class, true, IHLUtils.getThisModItemStack("stickSteel")), + VulcanizationExtrudingMold("vulcanizationExtrudingMold", VulcanizationExtrudingMoldTileEntity.class, false, IHLUtils + .getThisModItemStack("dustCarborundum")), + Extruder("extruder", ExtruderTileEntity.class, false, IHLUtils.getThisModItemStack("dustCarborundum")), + RollingMachine1("rollingMachinePart1", RollingMachinePart1TileEntity.class, false, IHLUtils + .getThisModItemStack("stickSteel")), + RollingMachine2("rollingMachinePart2", RollingMachinePart2TileEntity.class, false, IHLUtils + .getThisModItemStack("stickSteel")), + Loom("loom", LoomTileEntity.class, false, new ItemStack(Items.stick)), + Coiler("coiler", CoilerTileEntity.class, false, new ItemStack(Items.stick)), + Lathe1("lathePart1", LathePart1TileEntity.class, false, IHLUtils.getThisModItemStack("stickSteel")), + Lathe2("lathePart2", LathePart2TileEntity.class, false, IHLUtils.getOreDictItemStack("plateSteel")), + LeadOven("leadOven", LeadOvenTileEntity.class, true, IHLUtils.getThisModItemStack("dustPorcelain")), + DetonationSprayingMachine("cannonBronze", DetonationSprayingMachineTileEntity.class, false, new ItemStack( + Items.stick)), + BronzeTub("tubBronze", ImpregnatingMachineTileEntity.class, false, true, null), + AchesonFurnace("achesonFurnance", AchesonFurnanceTileEntity.class, true, new ItemStack(Items.brick)), + MuffleFurnace("muffleFurnance", MuffleFurnanceTileEntity.class, true, new ItemStack(Items.brick)); + MachineType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1, + ItemStack itemDroppedOnBlockDestroy1) { + unlocalizedName = unlocalizedName1; + teclass = teclass1; + isNormalBlock = isNormalBlock1; + if (isNormalBlock) { + specialBlockRendererId = 0; + } else { + specialBlockRendererId = -2; + } + itemDroppedOnBlockDestroy = itemDroppedOnBlockDestroy1; + } + + MachineType(String unlocalizedName1, Class teclass1, boolean isNormalBlock1, + boolean hasSpecialBlockRenderer1, ItemStack itemDroppedOnBlockDestroy1) { + unlocalizedName = unlocalizedName1; + teclass = teclass1; + isNormalBlock = isNormalBlock1; + hasSpecialBlockRenderer = hasSpecialBlockRenderer1; + itemDroppedOnBlockDestroy = itemDroppedOnBlockDestroy1; + + } + public String unlocalizedName; Class teclass; - boolean isNormalBlock=true; - boolean hasSpecialBlockRenderer=false; - int specialBlockRendererId=-2; + boolean isNormalBlock = true; + boolean hasSpecialBlockRenderer = false; + int specialBlockRendererId = -2; ItemStack itemDroppedOnBlockDestroy; - } - + } + @Override - public int getRenderType() - { - if(this.type.hasSpecialBlockRenderer) - { + public int getRenderType() { + if (this.type.hasSpecialBlockRenderer) { return IHLMod.proxy.shareBlockRendererByMachineType(this.type); } return this.type.specialBlockRendererId; } - + @Override - public boolean isOpaqueCube() - { - return this.type==null?false:this.type.isNormalBlock; + public boolean isOpaqueCube() { + return this.type == null ? false : this.type.isNormalBlock; } @Override - public boolean renderAsNormalBlock() - { + public boolean renderAsNormalBlock() { return this.type.isNormalBlock; } - + @SideOnly(Side.CLIENT) - public IIcon getAdditionalIconsForBlockRenderer(int flag) - { - switch(this.type) - { - case BronzeTub: - return this.bronzeTubSide; - default: - return this.blockIcon; + public IIcon getAdditionalIconsForBlockRenderer(int flag) { + switch (this.type) { + case BronzeTub: + return this.bronzeTubSide; + default: + return this.blockIcon; } } - } \ No newline at end of file diff --git a/ihl/model/CableHolderSelectionBoxSpecialRenderer.java b/ihl/model/CableHolderSelectionBoxSpecialRenderer.java index 7d0de61..d06f050 100644 --- a/ihl/model/CableHolderSelectionBoxSpecialRenderer.java +++ b/ihl/model/CableHolderSelectionBoxSpecialRenderer.java @@ -13,6 +13,10 @@ import net.minecraft.util.MovingObjectPosition; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(value=Side.CLIENT) public class CableHolderSelectionBoxSpecialRenderer implements ISelectionBoxSpecialRenderer { @Override diff --git a/ihl/model/FlexibleCableItemRender.java b/ihl/model/FlexibleCableItemRender.java index 71a8337..fab019c 100644 --- a/ihl/model/FlexibleCableItemRender.java +++ b/ihl/model/FlexibleCableItemRender.java @@ -13,6 +13,10 @@ import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(value=Side.CLIENT) public class FlexibleCableItemRender implements IItemRenderer { private ModelTube model; private ModelTube modelThin; diff --git a/ihl/model/FluidRenderer.java b/ihl/model/FluidRenderer.java index 000dbf7..87b1abe 100644 --- a/ihl/model/FluidRenderer.java +++ b/ihl/model/FluidRenderer.java @@ -21,6 +21,9 @@ import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.init.Blocks; import net.minecraft.util.ResourceLocation; @@ -31,6 +34,7 @@ import net.minecraftforge.fluids.FluidStack; * * @author CovertJaguar */ +@SideOnly(value=Side.CLIENT) public class FluidRenderer { private static RenderBlocks renderBlocks = new RenderBlocks(); diff --git a/ihl/model/IHLBlockRenderer.java b/ihl/model/IHLBlockRenderer.java index 35c6e6c..2244ab7 100644 --- a/ihl/model/IHLBlockRenderer.java +++ b/ihl/model/IHLBlockRenderer.java @@ -11,9 +11,13 @@ import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.world.ChunkCache; import net.minecraft.world.World; +@SideOnly(value=Side.CLIENT) public class IHLBlockRenderer { private RenderBlocks renderBlocks; diff --git a/ihl/model/IHLModelRenderer.java b/ihl/model/IHLModelRenderer.java index a9168f8..0bf95d2 100644 --- a/ihl/model/IHLModelRenderer.java +++ b/ihl/model/IHLModelRenderer.java @@ -5,6 +5,8 @@ import java.util.List; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.TextureOffset; @@ -12,6 +14,7 @@ import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.Tessellator; import net.minecraftforge.common.util.ForgeDirection; +@SideOnly(value=Side.CLIENT) public class IHLModelRenderer { /** The size of the texture file's width in pixels. */ public float textureWidth; diff --git a/ihl/model/IHLToolRenderer.java b/ihl/model/IHLToolRenderer.java index 14e610b..dd64731 100644 --- a/ihl/model/IHLToolRenderer.java +++ b/ihl/model/IHLToolRenderer.java @@ -3,6 +3,8 @@ package ihl.model; import ihl.items_blocks.IHLTool; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.Tessellator; @@ -11,6 +13,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; +@SideOnly(value=Side.CLIENT) public class IHLToolRenderer implements IItemRenderer { diff --git a/ihl/model/ImpregnatingMachineBlockRender.java b/ihl/model/ImpregnatingMachineBlockRender.java index cb125cf..b36f3bd 100644 --- a/ihl/model/ImpregnatingMachineBlockRender.java +++ b/ihl/model/ImpregnatingMachineBlockRender.java @@ -10,7 +10,10 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +@SideOnly(value=Side.CLIENT) public class ImpregnatingMachineBlockRender implements ISimpleBlockRenderingHandler { public static int renderId; diff --git a/ihl/model/IronWorkbenchBlockRender.java b/ihl/model/IronWorkbenchBlockRender.java index b5bdec3..7e986c9 100644 --- a/ihl/model/IronWorkbenchBlockRender.java +++ b/ihl/model/IronWorkbenchBlockRender.java @@ -8,7 +8,10 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +@SideOnly(value=Side.CLIENT) public class IronWorkbenchBlockRender implements ISimpleBlockRenderingHandler { public static int renderId; diff --git a/ihl/model/ModelKnee.java b/ihl/model/ModelKnee.java index c352431..3f720ac 100644 --- a/ihl/model/ModelKnee.java +++ b/ihl/model/ModelKnee.java @@ -1,10 +1,13 @@ package ihl.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.PositionTextureVertex; import net.minecraft.client.model.TexturedQuad; import net.minecraft.client.renderer.Tessellator; import net.minecraftforge.common.util.ForgeDirection; +@SideOnly(value=Side.CLIENT) public class ModelKnee { /** * The (x,y,z) vertex positions and (u,v) texture coordinates for each of the 8 points on a cube diff --git a/ihl/model/ModelToplessBox.java b/ihl/model/ModelToplessBox.java index 0856ed3..09885c9 100644 --- a/ihl/model/ModelToplessBox.java +++ b/ihl/model/ModelToplessBox.java @@ -1,9 +1,12 @@ package ihl.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.PositionTextureVertex; import net.minecraft.client.model.TexturedQuad; import net.minecraft.client.renderer.Tessellator; +@SideOnly(value=Side.CLIENT) public class ModelToplessBox { /** * The (x,y,z) vertex positions and (u,v) texture coordinates for each of the 8 points on a cube diff --git a/ihl/model/ModelTube.java b/ihl/model/ModelTube.java index d4dcb08..6fd6c36 100644 --- a/ihl/model/ModelTube.java +++ b/ihl/model/ModelTube.java @@ -2,12 +2,15 @@ package ihl.model; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.PositionTextureVertex; import net.minecraft.client.model.TexturedQuad; import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.Tessellator; import net.minecraftforge.common.util.ForgeDirection; +@SideOnly(value=Side.CLIENT) public class ModelTube { /** * The (x,y,z) vertex positions and (u,v) texture coordinates for each of the 8 points on a cube diff --git a/ihl/model/RectifierTransformerUnitBlockRender.java b/ihl/model/RectifierTransformerUnitBlockRender.java index 27d8ea9..567745f 100644 --- a/ihl/model/RectifierTransformerUnitBlockRender.java +++ b/ihl/model/RectifierTransformerUnitBlockRender.java @@ -14,7 +14,10 @@ import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +@SideOnly(value=Side.CLIENT) public class RectifierTransformerUnitBlockRender implements ISimpleBlockRenderingHandler { public static int renderId; diff --git a/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java b/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java index 4cd52ea..f8a5340 100644 --- a/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java +++ b/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java @@ -11,6 +11,10 @@ import net.minecraft.util.MovingObjectPosition; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +@SideOnly(value=Side.CLIENT) public class RectifierTransformerUnitSelectionBoxSpecialRenderer implements ISelectionBoxSpecialRenderer { @Override diff --git a/ihl/model/RefluxCondenserBlockRender.java b/ihl/model/RefluxCondenserBlockRender.java index 7d78c27..ec70021 100644 --- a/ihl/model/RefluxCondenserBlockRender.java +++ b/ihl/model/RefluxCondenserBlockRender.java @@ -14,7 +14,10 @@ import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +@SideOnly(value=Side.CLIENT) public class RefluxCondenserBlockRender implements ISimpleBlockRenderingHandler { public static int renderId; diff --git a/ihl/model/RenderBlocksExt.java b/ihl/model/RenderBlocksExt.java index 6415059..f634bb0 100644 --- a/ihl/model/RenderBlocksExt.java +++ b/ihl/model/RenderBlocksExt.java @@ -5,63 +5,93 @@ import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; +import java.util.HashSet; +import java.util.Set; + +import cpw.mods.fml.relauncher.SideOnly; +import cpw.mods.fml.relauncher.Side; +import ihl.ClientProxy; +import ihl.IHLMod; +import ihl.enviroment.LightSource; + +@SideOnly(value=Side.CLIENT) public class RenderBlocksExt extends RenderBlocks { - + + public static RenderBlocksExt instance; + private final int[] YNEG = new int[] { 0, -1, 0 }; + private final int[] YPOS = new int[] { 0, 1, 0 }; + private final int[] XNEG = new int[] { -1, 0, 0 }; + private final int[] XPOS = new int[] { 1, 0, 0 }; + private final int[] ZNEG = new int[] { 0, 0, -1 }; + private final int[] ZPOS = new int[] { 0, 0, 1 }; + private final int BRIGHT = 0x0000FF; + private final int DARK = 0x000000; + public RenderBlocksExt(IBlockAccess blockAccess) { super(blockAccess); + instance = this; } - @Override - public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) - { - this.brightnessTopLeft=16711935; - this.brightnessTopRight=16711935; - super.renderFaceYNeg(block,x,y,z,icon); - } - - public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) - { - if (this.enableAO) - { - System.out.println("AO is on"); - } - else - { - System.out.println("AO is off"); - } - - this.brightnessTopLeft=16711935; - this.brightnessTopRight=16711935; - super.renderFaceYPos(block, x, y, z, icon); - } + private void transformColour(int x, int y, int z, int[] normal) { + for (LightSource lightSource : ((ClientProxy)IHLMod.proxy).getLightHandler().lightSources) { + if (lightSource.isBlockIlluminated(x, y, z)) { + int[] lightValue = lightSource.getLightValue((int) x, (int) y, (int) z, normal); + System.out.println("this.brightnessBottomRight="+this.brightnessBottomRight); +// this.brightnessTopLeft |= lightValue[0]; +// this.brightnessBottomLeft |= lightValue[0]; +// this.brightnessTopRight |= lightValue[0]; + this.brightnessBottomRight |= lightValue[0]>>4; + System.out.println("lightValue[0]="+lightValue[0]); + System.out.println("this.brightnessBottomRight|lightValue[0]="+this.brightnessBottomRight); + this.colorRedTopLeft *= (255 - lightValue[0]) * lightValue[1] / 255 / 255f; + this.colorRedBottomLeft *= (255 - lightValue[0]) * lightValue[1] / 255 / 255f; + this.colorRedTopRight *= (255 - lightValue[0]) * lightValue[1] / 255 / 255f; + this.colorRedBottomRight *= (255 - lightValue[0]) * lightValue[1] / 255 / 255f; + this.colorBlueTopLeft *= (255 - lightValue[0]) * lightValue[2] / 255 / 255f; + this.colorBlueBottomLeft *= (255 - lightValue[0]) * lightValue[2] / 255 / 255f; + this.colorBlueTopRight *= (255 - lightValue[0]) * lightValue[2] / 255 / 255f; + this.colorBlueBottomRight *= (255 - lightValue[0]) * lightValue[2] / 255 / 255f; + this.colorGreenTopLeft *= (255 - lightValue[0]) * lightValue[3] / 255 / 255f; + this.colorGreenBottomLeft *= (255 - lightValue[0]) * lightValue[3] / 255 / 255f; + this.colorGreenTopRight *= (255 - lightValue[0]) * lightValue[3] / 255 / 255f; + this.colorGreenBottomRight *= (255 - lightValue[0]) * lightValue[3] / 255 / 255f; + } + } + } - public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) - { - this.brightnessTopLeft=16711935; - this.brightnessTopRight=16711935; - super.renderFaceZNeg(block, x, y, z, icon); - } + @Override + public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) { + this.transformColour((int) x, (int) y, (int) z, YNEG); + super.renderFaceYNeg(block, x, y, z, icon); + } - public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) - { - this.brightnessTopLeft=16711935; - this.brightnessTopRight=16711935; - super.renderFaceZPos(block, x, y, z, icon); - } + @Override + public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) { + this.transformColour((int) x, (int) y, (int) z, YPOS); + super.renderFaceYPos(block, x, y, z, icon); + } - public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) - { - this.brightnessTopLeft=16711935; - this.brightnessTopRight=16711935; - super.renderFaceXNeg(block, x, y, z, icon); - } + @Override + public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) { + this.transformColour((int) x, (int) y, (int) z, ZNEG); + super.renderFaceZNeg(block, x, y, z, icon); + } - public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) - { - this.brightnessTopLeft=16711935; - this.brightnessTopRight=16711935; - super.renderFaceXPos(block, x, y, z, icon); - } + @Override + public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) { + this.transformColour((int) x, (int) y, (int) z, ZPOS); + super.renderFaceZPos(block, x, y, z, icon); + } + @Override + public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) { + this.transformColour((int) x, (int) y, (int) z, XNEG); + super.renderFaceXNeg(block, x, y, z, icon); + } + @Override + public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) { + this.transformColour((int) x, (int) y, (int) z, XPOS); + super.renderFaceXPos(block, x, y, z, icon); + } } diff --git a/ihl/model/RenderInfo.java b/ihl/model/RenderInfo.java index dde123d..4e85f6f 100644 --- a/ihl/model/RenderInfo.java +++ b/ihl/model/RenderInfo.java @@ -2,10 +2,13 @@ package ihl.model; import java.util.Arrays; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; +@SideOnly(value=Side.CLIENT) public class RenderInfo { public Block template = Blocks.stone; diff --git a/ihl/model/UniversalTileRender.java b/ihl/model/UniversalTileRender.java index 8062778..049d465 100644 --- a/ihl/model/UniversalTileRender.java +++ b/ihl/model/UniversalTileRender.java @@ -6,6 +6,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import ic2.api.tile.IWrenchable; import ihl.IHLModInfo; import ihl.flexible_cable.IronWorkbenchModel; @@ -15,6 +17,7 @@ private ModelBase model = new IronWorkbenchModel(); private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/ironWorkbench.png"); private final float scale=1F/16F; +@SideOnly(value=Side.CLIENT) public UniversalTileRender(ModelBase model1, ResourceLocation texture) { this.model=model1; diff --git a/ihl/processing/chemistry/ChemicalReactorTileEntity.java b/ihl/processing/chemistry/ChemicalReactorTileEntity.java index 2dfe31e..2630ed2 100644 --- a/ihl/processing/chemistry/ChemicalReactorTileEntity.java +++ b/ihl/processing/chemistry/ChemicalReactorTileEntity.java @@ -122,7 +122,7 @@ public class ChemicalReactorTileEntity extends BasicElectricMotorTileEntity impl @Override public boolean canFill(ForgeDirection direction, Fluid arg1) { - return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite()); + return true; } @Override diff --git a/ihl/processing/chemistry/DosingPumpContainer.java b/ihl/processing/chemistry/DosingPumpContainer.java new file mode 100644 index 0000000..5a4cb21 --- /dev/null +++ b/ihl/processing/chemistry/DosingPumpContainer.java @@ -0,0 +1,95 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.slot.SlotInvSlot; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.Slot; +import net.minecraftforge.fluids.FluidStack; + +public class DosingPumpContainer extends ContainerBase { + + protected DosingPumpTileEntity tileEntity; + public int lastFluidAmount = -1; + public int lastNumberOfFluids = -1; + public short lastProgress = -1; + public int lastFluidAmountSetpoint = -1; + public short lastEnergy = -1; + private final static int height = 166; + public List fluidTankFluidList; + + public DosingPumpContainer(EntityPlayer entityPlayer, DosingPumpTileEntity tileEntity1) { + super(tileEntity1); + this.tileEntity = tileEntity1; + fluidTankFluidList = tileEntity.getFluidTank().getFluidList(); + int col; + for (col = 0; col < 3; ++col) { + for (int col1 = 0; col1 < 9; ++col1) { + this.addSlotToContainer( + new Slot(entityPlayer.inventory, col1 + col * 9 + 9, 8 + col1 * 18, height + -82 + col * 18)); + } + } + for (col = 0; col < 9; ++col) { + this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, height + -24)); + } + this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 44, 50)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 44, 14)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 44, 32)); + this.addSlotToContainer(new SlotInvSlot(tileEntity1.dischargeSlot, 0, 8, 32)); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + for (int i = 0; i < this.crafters.size(); ++i) { + ICrafting icrafting = (ICrafting) this.crafters.get(i); + + if (this.tileEntity.getTankAmount() != this.lastFluidAmount + || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) { + IC2.network.get().sendContainerField(this, "fluidTankFluidList"); + } + + if (this.tileEntity.progress != this.lastProgress) { + icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); + } + + if (this.tileEntity.fluidAmountSetpoint != this.lastFluidAmountSetpoint) { + icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.fluidAmountSetpoint); + } + + if ((short) this.tileEntity.energy != this.lastEnergy) { + icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy); + } + } + + this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank(); + this.lastFluidAmount = this.tileEntity.getTankAmount(); + this.lastProgress = this.tileEntity.progress; + this.lastFluidAmountSetpoint = this.tileEntity.fluidAmountSetpoint; + this.lastEnergy = (short) this.tileEntity.energy; + } + + @Override + public void updateProgressBar(int index, int value) { + super.updateProgressBar(index, value); + switch (index) { + case 0: + this.tileEntity.progress = (short) value; + break; + case 1: + this.tileEntity.fluidAmountSetpoint = (short) value; + break; + case 2: + this.tileEntity.energy = value; + break; + } + } + + @Override + public boolean canInteractWith(EntityPlayer var1) { + return tileEntity.isUseableByPlayer(var1); + } +} diff --git a/ihl/processing/chemistry/DosingPumpGui.java b/ihl/processing/chemistry/DosingPumpGui.java new file mode 100644 index 0000000..090bdec --- /dev/null +++ b/ihl/processing/chemistry/DosingPumpGui.java @@ -0,0 +1,101 @@ +package ihl.processing.chemistry; + +import cpw.mods.fml.relauncher.Side; + +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.IC2; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +import java.awt.event.KeyEvent; + +import org.lwjgl.opengl.GL11; + +import ihl.ClientProxy; +import ihl.IHLMod; +import ihl.utils.IHLRenderUtils; +import ihl.utils.IHLUtils; + +@SideOnly(Side.CLIENT) +public class DosingPumpGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDosingPump.png"); + private DosingPumpContainer container; + private GuiTextField setpointTextField; + private final static int TANK_HEIGHT = 58; + + public DosingPumpGui(DosingPumpContainer container1) { + // the container is instanciated and passed to the superclass for + // handling + super(container1); + this.container = container1; + setpointTextField = new GuiTextField(Minecraft.getMinecraft().fontRenderer, 106, 34, 62, 16); + setpointTextField.setText(Integer.toString(this.container.tileEntity.fluidAmountSetpoint)); + setpointTextField.setFocused(true); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + int xOffset = (this.width - xSize) / 2; + int yOffset = (this.height - ySize) / 2; + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int i1; + if (this.container.tileEntity.getEnergy() > 0D) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + i1 = Math.min(this.container.tileEntity.getGUIEnergy(12), 12); + this.drawTexturedModalRect(12, 15 + 12 - i1, 179, 12 - i1, 14, i1 + 2); + } + i1 = TANK_HEIGHT - this.container.tileEntity.fluidAmountSetpoint * TANK_HEIGHT + / this.container.tileEntity.getFluidTank().getCapacity(); + this.drawTexturedModalRect(78, 6 + i1, 176, 14, 25, 7); + if (this.container.tileEntity.getTankAmount() > 0) { + IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 82, 10, 94, + 67, zLevel, par1, par2, xOffset, yOffset); + } + setpointTextField.drawTextBox(); + IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.dosingPump.tip")); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + // draw your Gui here, only thing you need to change is the path + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + } + + @Override + protected void keyTyped(char characterTyped, int keyIndex) { + super.keyTyped(characterTyped, keyIndex); + this.setpointTextField.textboxKeyTyped(characterTyped, keyIndex); + // 28 - enter; 156 - numpad enter + if (keyIndex == KeyEvent.VK_ACCEPT || keyIndex == KeyEvent.VK_ENTER || keyIndex == 28 || keyIndex == 156) { + int fluidAmountSetpoint = (short) Math.max(1, + Math.min(this.container.tileEntity.getFluidTank().getCapacity(), + IHLUtils.parseIntSafe(this.setpointTextField.getText(), 100))); + this.setpointTextField.setText(Integer.toString(fluidAmountSetpoint)); + this.setpointTextField.setFocused(false); + ((ClientProxy)IHLMod.proxy).sendIntegerFieldValueFromClientToServer(fluidAmountSetpoint, "fluidAmountSetpoint", this.container.tileEntity); + } + } + @Override + public void mouseClicked(int mouseX, int mouseY, int mouseButton) { + super.mouseClicked(mouseX, mouseY, mouseButton); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + if (mouseX >= x + setpointTextField.xPosition && + mouseX <= x + setpointTextField.xPosition + setpointTextField.width && + mouseY >= y + setpointTextField.yPosition && + mouseY <= y + setpointTextField.yPosition + setpointTextField.height) { + setpointTextField.setFocused(true); + } + } + + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/DosingPumpTileEntity.java b/ihl/processing/chemistry/DosingPumpTileEntity.java new file mode 100644 index 0000000..d676bf9 --- /dev/null +++ b/ihl/processing/chemistry/DosingPumpTileEntity.java @@ -0,0 +1,226 @@ +package ihl.processing.chemistry; + +import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ic2.core.block.invslot.InvSlot; +import ic2.core.block.invslot.InvSlotConsumableLiquid; +import ic2.core.block.invslot.InvSlotOutput; +import ihl.processing.invslots.InvSlotConsumableLiquidIHL; +import ihl.processing.metallurgy.BasicElectricMotorTileEntity; +import ihl.utils.IHLFluidTank; +import ihl.utils.IHLUtils; + +public class DosingPumpTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler { + public final InvSlotConsumableLiquidIHL drainInputSlot; + public final InvSlotConsumableLiquidIHL fillInputSlot; + public final InvSlotOutput emptyFluidItemsSlot; + private final IHLFluidTank fluidTank = new IHLFluidTank(8000); + public int fluidAmountSetpoint = 8000; + private boolean prevIsPowered = false; + private boolean tickFree=false; + + public DosingPumpTileEntity() { + super(); + this.drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, + InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain); + this.fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, + InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill); + this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 1); + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); + this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank")); + this.fluidAmountSetpoint = nbttagcompound.getInteger("fluidAmountSetpoint"); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); + NBTTagCompound fluidTankTag = new NBTTagCompound(); + this.fluidTank.writeToNBT(fluidTankTag); + nbttagcompound.setTag("fluidTank", fluidTankTag); + nbttagcompound.setInteger("fluidAmountSetpoint", this.fluidAmountSetpoint); + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return this.getFacing() != side; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("dosingPump"); + } + + @Override + public boolean enableUpdateEntity() { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntityServer() { + super.updateEntityServer(); + this.tickFree = true; + IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank); + } + + @Override + public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) { + switch (from) { + case UP: + return this.fluidTank.drainLightest(amount, doDrain); + case NORTH: + return this.fluidTank.drainLightest(amount, doDrain); + case SOUTH: + return this.fluidTank.drainLightest(amount, doDrain); + case WEST: + return this.fluidTank.drainLightest(amount, doDrain); + case EAST: + return this.fluidTank.drainLightest(amount, doDrain); + case DOWN: + return this.fluidTank.drain(amount, doDrain); + default: + return this.fluidTank.drain(amount, doDrain); + } + } + + // 1.7.10 API + @Override + public boolean canDrain(ForgeDirection arg0, Fluid arg1) { + return true; + } + + @Override + public boolean canFill(ForgeDirection direction, Fluid arg1) { + return !direction.equals(ForgeDirection.getOrientation(this.getFacing())); + } + + @Override + public String getInventoryName() { + return "dosingPump"; + } + + public float getRenderLiquidLevel() { + return (float) this.fluidTank.getFluidAmount() / (float) this.fluidTank.getCapacity(); + } + + @Override + public int gaugeProgressScaled(int i) { + return this.progress * i / operationLength; + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer player, boolean arg1) { + return new DosingPumpGui(new DosingPumpContainer(player, this)); + } + + @Override + public ContainerBase getGuiContainer(EntityPlayer player) { + this.fluidTank.sortFluidsByDensity(); + return new DosingPumpContainer(player, this); + } + + @Override + public void onGuiClosed(EntityPlayer player) { + } + + @Override + public boolean canOperate() { + return false; + } + + @Override + public void operate() { + int fluidAmountToDrain = fluidAmountSetpoint; + ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()); + TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ); + if (te instanceof IFluidHandler) { + IFluidHandler fhte = (IFluidHandler) te; + for (int i = 0; i < this.fluidTank.getNumberOfFluids(); i++) { + FluidStack drained = this.fluidTank.drain(fluidAmountToDrain, true); + fluidAmountToDrain -= drained.amount; + if (fhte.canFill(dir, drained.getFluid())) { + fhte.fill(dir, drained, true); + } + if (fluidAmountToDrain <= 0) { + break; + } + } + } + this.energy-=this.energyConsume/10; + } + + @Override + public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) { + if (fluidTank.getFluid() != null && fluidTank.getFluid().containsFluid(fluidStack)) { + return this.fluidTank.drain(fluidStack, doDrain); + } + return null; + } + + @Override + public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) { + return this.fluidTank.fill(arg1, arg2); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection arg0) { + return new FluidTankInfo[] { this.fluidTank.getInfo() }; + } + + public boolean needsFluid() { + return this.fluidTank.getFluidAmount() <= this.fluidTank.getCapacity(); + } + + public FluidStack getFluidStackfromTank() { + return this.fluidTank.getFluid(); + } + + public int getTankAmount() { + return this.fluidTank.getFluidAmount(); + } + + public int gaugeLiquidScaled(int i, int index) { + return this.fluidTank.getFluidAmount() <= 0 ? 0 + : this.fluidTank.getFluidAmount(index) * i / this.fluidTank.getCapacity(); + } + + public int getNumberOfFluidsInTank() { + return this.fluidTank.getNumberOfFluids(); + } + + public IHLFluidTank getFluidTank() { + return this.fluidTank; + } + + @Override + public List[] getInput() { + return null; + } + + public void setPowered(boolean isPowered) { + if (isPowered && !prevIsPowered && this.energy > 0 && this.tickFree) { + this.operate(); + } + prevIsPowered = isPowered; + this.tickFree = false; // Only one operation per tick max + } + +} \ No newline at end of file diff --git a/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java b/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java index 2d8c288..bb6cf1e 100644 --- a/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java +++ b/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java @@ -116,7 +116,7 @@ public class FluidizedBedReactorTileEntity extends BasicElectricMotorTileEntity @Override public boolean canFill(ForgeDirection direction, Fluid arg1) { - return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite()); + return true; } @Override diff --git a/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java b/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java index 7f82532..125b6be 100644 --- a/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java +++ b/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java @@ -70,7 +70,6 @@ public abstract class BasicElectricMotorTileEntity extends FlexibleCableHolderBa @SuppressWarnings("unchecked") @Override public void setFacing(short facing1) { - short facing2 = (short) Math.max(facing1, 2); double d = 0.3D; double f = -0.1D; if (IC2.platform.isSimulating() && this.addedToEnergyNet) { @@ -81,7 +80,7 @@ public abstract class BasicElectricMotorTileEntity extends FlexibleCableHolderBa AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(connectionX - range, connectionY - range, connectionZ - range, connectionX + range, connectionY + range, connectionZ + range); List nodeList = worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea); - super.setFacing(facing2); + super.setFacing(facing1); switch (getFacing()) { case 4: setConnectionX(this.xCoord + 0.5D); diff --git a/ihl/worldgen/IHLWorldGenerator.java b/ihl/worldgen/IHLWorldGenerator.java index 95a91f3..1c65b78 100644 --- a/ihl/worldgen/IHLWorldGenerator.java +++ b/ihl/worldgen/IHLWorldGenerator.java @@ -17,7 +17,7 @@ public class IHLWorldGenerator implements IWorldGenerator { private static final Block[] replaceableMinerals = new Block[] { Blocks.stone, Blocks.gravel , Blocks.gold_ore, Blocks.coal_ore, Blocks.iron_ore, Blocks.lapis_ore, Blocks.clay, Blocks.diamond_ore, Blocks.redstone_ore, Blocks.emerald_ore}; private static final Block[] replaceableSand = new Block[] { Blocks.sand }; - private static final Block[] replaceableForOil = new Block[] { Blocks.lava, Blocks.flowing_lava}; + private static final Block[] replaceableForOil = new Block[] { Blocks.lava, Blocks.flowing_lava, Blocks.obsidian}; public static IHLWorldGenerator instance; private final Set generators = new HashSet(8); @@ -74,7 +74,7 @@ public class IHLWorldGenerator implements IWorldGenerator { } if (IHLMod.config.generateOil) { - generators.add(new WorldGeneratorUndergroundLake(IHLFluid.getBlock("oil"), Blocks.clay, replaceableForOil)); + generators.add(new WorldGeneratorUndergroundLake(IHLFluid.getBlock("oil"), Blocks.obsidian, replaceableForOil)); } if (IHLMod.config.generateSaltwater) { diff --git a/ihl/worldgen/WorldGeneratorBase.java b/ihl/worldgen/WorldGeneratorBase.java index aaaaa66..b5468f5 100644 --- a/ihl/worldgen/WorldGeneratorBase.java +++ b/ihl/worldgen/WorldGeneratorBase.java @@ -6,6 +6,7 @@ import java.util.Set; import ihl.utils.IHLUtils; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; @@ -60,10 +61,30 @@ public abstract class WorldGeneratorBase { return false; } + protected boolean replaceAllExceptOre(World world, int absX, int absY, int absZ, final Block block) { + if (!world.getChunkProvider().chunkExists(absX >> 4, absZ >> 4)) { + throw new IllegalStateException("quered chunk is not yet generated!"); + } + Chunk chunk = world.getChunkFromBlockCoords(absX, absZ); + ExtendedBlockStorage ebs = chunk.getBlockStorageArray()[absY >> 4]; + if (ebs != null) { + Block olblock = ebs.getBlockByExtId(absX & 15, absY & 15, absZ & 15); + if(!olblock.equals(ore) && + !olblock.equals(Blocks.bedrock) && + !olblock.equals(Blocks.netherrack) && + !olblock.equals(Blocks.stone) && + !olblock.equals(Blocks.clay)) { + IHLUtils.setBlockRaw(ebs, absX & 15, absY & 15, absZ & 15, block); + return true; + } + } + return false; + } + private int[] getPOI(World world, int chunkX, int chunkZ, int xOffset, int zOffset) { long seed = (long) chunkX << 16 ^ chunkZ << 8 ^ Block.getIdFromBlock(ore); random.setSeed(seed); - return new int[] { random.nextInt(16) + xOffset * 16, random.nextInt(world.getActualHeight()/2), + return new int[] { random.nextInt(16) + xOffset * 16, random.nextInt(world.getActualHeight() / 2), random.nextInt(16) + zOffset * 16 }; } } diff --git a/ihl/worldgen/WorldGeneratorSurfaceLake.java b/ihl/worldgen/WorldGeneratorSurfaceLake.java index 3affdaf..11abf5e 100644 --- a/ihl/worldgen/WorldGeneratorSurfaceLake.java +++ b/ihl/worldgen/WorldGeneratorSurfaceLake.java @@ -1,12 +1,10 @@ package ihl.worldgen; import ihl.utils.IHLMathUtils; -import ihl.utils.IHLUtils; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.chunk.storage.ExtendedBlockStorage; public class WorldGeneratorSurfaceLake extends WorldGeneratorBase { @@ -25,9 +23,12 @@ public class WorldGeneratorSurfaceLake extends WorldGeneratorBase { int y2 = y += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y); for (int iz = z; iz < 16 && iz >= 0; iz += IHLMathUtils.sign(surroundPOI[2] - z)) { y2 += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y2); - if (y2 > world.getActualHeight() * 3 / 8 - && world.getBlock(ix + startX, 64, iz + startZ) == Blocks.air) { - this.replace(world, ix + startX, 63, iz + startZ, ore); + int dx = ix-x; + int dz = iz-z; + int d = dx*dx+dz*dz; + if (d < 64 && y2 > world.getActualHeight() * 3 / 8 + && world.getBlock(ix + startX, 63, iz + startZ) == Blocks.air) { + this.replace(world, ix + startX, 62, iz + startZ, ore); } if (surroundPOI[2] == z) { break; diff --git a/ihl/worldgen/WorldGeneratorUndergroundLake.java b/ihl/worldgen/WorldGeneratorUndergroundLake.java index 6cd0870..b902efa 100644 --- a/ihl/worldgen/WorldGeneratorUndergroundLake.java +++ b/ihl/worldgen/WorldGeneratorUndergroundLake.java @@ -18,11 +18,23 @@ public class WorldGeneratorUndergroundLake extends WorldGeneratorBase { int x = centralPOI[0], y = centralPOI[1] - world.getActualHeight() / 4, z = centralPOI[2]; for (int ix = x; ix < 16 && ix >= 0; ix += IHLMathUtils.sign(surroundPOI[0] - x)) { int y2 = y += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y); - for (int iz = z; iz < 16 && iz >= 0; iz += IHLMathUtils.sign(surroundPOI[2] - z)) { + nextZ:for (int iz = z; iz < 16 && iz >= 0; iz += IHLMathUtils.sign(surroundPOI[2] - z)) { y2 += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y2); - if (y2 > 1) { - this.replace(world, ix + startX, y2 + 1, iz + startZ, clayBlock); + int dx = ix - x; + int dz = iz - z; + int d = dx * dx + dz * dz; + if (y2 > 1 && d < 64) { for (int iy = y2; iy > 0; iy--) { + int[] xyz = new int[] { 0, 0, -1, 0, 0, 1, 0, 0 }; + for (int i = 2; i < xyz.length; i++) { + int absX = ix + startX + xyz[i - 2]; + int absZ = iz + startZ + xyz[i]; + if(!world.getChunkProvider().chunkExists(absX >> 4, absZ >> 4)) { + continue nextZ; + } + this.replaceAllExceptOre(world, absX, iy + xyz[i - 1],absZ, + clayBlock); + } this.replace(world, ix + startX, iy, iz + startZ, ore); } } diff --git a/ihl_coremod/IHLCoremod.java b/ihl_coremod/IHLCoremod.java new file mode 100644 index 0000000..300e27d --- /dev/null +++ b/ihl_coremod/IHLCoremod.java @@ -0,0 +1,48 @@ +package ihl_coremod; + +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import cpw.mods.fml.relauncher.IFMLLoadingPlugin; + +@IFMLLoadingPlugin.Name(value = "IHL CoreMod") +@IFMLLoadingPlugin.MCVersion(value = "1.7.10") +@IFMLLoadingPlugin.TransformerExclusions(value = "ihl_coremod.") +@IFMLLoadingPlugin.SortingIndex(value = 0) +public class IHLCoremod implements IFMLLoadingPlugin{ + public static Logger log; + + public IHLCoremod() + { + log = LogManager.getLogger("IHLCoremod"); + log.info("IHL coremod logger created."); + } + + @Override + public String[] getASMTransformerClass() { + return new String[] {WorldRendererClassTransformer.class.getName()}; + } + + @Override + public String getModContainerClass() { + return IHLCoremodContainer.class.getName(); + } + + @Override + public String getSetupClass() { + return null; + } + + @Override + public void injectData(Map data) { + + } + + @Override + public String getAccessTransformerClass() { + return null; + } + +} diff --git a/ihl_coremod/IHLCoremodContainer.java b/ihl_coremod/IHLCoremodContainer.java new file mode 100644 index 0000000..c33a58e --- /dev/null +++ b/ihl_coremod/IHLCoremodContainer.java @@ -0,0 +1,29 @@ +package ihl_coremod; + +import java.util.Arrays; + +import com.google.common.eventbus.EventBus; + +import cpw.mods.fml.common.DummyModContainer; +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.ModMetadata; + +public class IHLCoremodContainer extends DummyModContainer { + + public IHLCoremodContainer() { + super(new ModMetadata()); + ModMetadata myMeta = super.getMetadata(); + myMeta.authorList = Arrays.asList(new String[] { "Foghrye4" }); + myMeta.description = "Core mod for ASM tweaks"; + myMeta.modId = "ihl_coremod"; + myMeta.version = "1.0"; + myMeta.name = "IHL core mod"; + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) + { + bus.register(this); + return true; + } +} diff --git a/ihl_coremod/WorldRendererClassTransformer.java b/ihl_coremod/WorldRendererClassTransformer.java new file mode 100644 index 0000000..14d0ce0 --- /dev/null +++ b/ihl_coremod/WorldRendererClassTransformer.java @@ -0,0 +1,22 @@ +package ihl_coremod; + +import net.minecraft.launchwrapper.IClassTransformer; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.Opcodes; + +public class WorldRendererClassTransformer implements IClassTransformer { + + @Override + public byte[] transform(String name, String transformedName, byte[] basicClass) { + if (name.equals("blo")) { + IHLCoremod.log.info("net.minecraft.client.renderer.WorldRenderer founded."); + ClassReader cr = new ClassReader(basicClass); + ClassWriter cw = new ClassWriter(cr, 0); + WorldRendererClassVisitor cv = new WorldRendererClassVisitor(Opcodes.ASM4, cw); + cr.accept(cv, 0); + return cw.toByteArray(); + } + return basicClass; + } +} diff --git a/ihl_coremod/WorldRendererClassVisitor.java b/ihl_coremod/WorldRendererClassVisitor.java new file mode 100644 index 0000000..89ab49b --- /dev/null +++ b/ihl_coremod/WorldRendererClassVisitor.java @@ -0,0 +1,25 @@ +package ihl_coremod; + +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Type; + +import net.minecraft.client.renderer.RenderBlocks; + +public class WorldRendererClassVisitor extends ClassVisitor { + + public WorldRendererClassVisitor(int api, ClassVisitor cv) { + super(api, cv); + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); + if (name.equals("a") && desc.equals("(Lsv;)V")) { + IHLCoremod.log.info("Sucessfully founded updateRenderer(Lnet/minecraft/entity/EntityLivingBase;)V"); + IHLCoremod.log.info("Trying intercept: "+Type.getInternalName(RenderBlocks.class)+"."); + return new WorldRendererRenderBlocksInitMethodVisitor(this.api, mv); + } + return mv; + } +} diff --git a/ihl_coremod/WorldRendererRenderBlocksInitMethodVisitor.java b/ihl_coremod/WorldRendererRenderBlocksInitMethodVisitor.java new file mode 100644 index 0000000..18c655a --- /dev/null +++ b/ihl_coremod/WorldRendererRenderBlocksInitMethodVisitor.java @@ -0,0 +1,34 @@ +package ihl_coremod; + +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +public class WorldRendererRenderBlocksInitMethodVisitor extends MethodVisitor { + + private static final String RENDER_BLOCK_EXT_TYPE = "ihl/model/RenderBlocksExt"; + private static final String RENDER_BLOCK_TYPE = "blm"; + + public WorldRendererRenderBlocksInitMethodVisitor(int api, MethodVisitor mv) { + super(api, mv); + } + + @Override + public void visitTypeInsn(int opcode, String type) { + if (opcode == Opcodes.NEW && type.equals(RENDER_BLOCK_TYPE)) { + IHLCoremod.log.info("Sucessfully intercept new RenderBlocks instruction."); + super.visitTypeInsn(opcode, RENDER_BLOCK_EXT_TYPE); + } else { + super.visitTypeInsn(opcode, type); + } + } + + @Override + public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { + if (owner.equals(RENDER_BLOCK_TYPE) && name.equals("")) { + IHLCoremod.log.info("Sucessfully intercept RenderBlocks. method."); + super.visitMethodInsn(opcode, RENDER_BLOCK_EXT_TYPE, name, desc, itf); + } else { + super.visitMethodInsn(opcode, owner, name, desc, itf); + } + } +} -- cgit v1.2.3