diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2017-08-10 18:52:45 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2017-08-10 18:52:45 +0300 |
| commit | 0427ab89f1753a44b30cbc35ce021cbbdc845109 (patch) | |
| tree | abe418ff5ec174e712fe8dedd434548a945b15a3 /src/main/java/ihl | |
| parent | 877312184c472d9845e5ef1008bc538f4634059f (diff) | |
fix missing source folder
Diffstat (limited to 'src/main/java/ihl')
303 files changed, 44880 insertions, 0 deletions
diff --git a/src/main/java/ihl/ClientProxy.java b/src/main/java/ihl/ClientProxy.java new file mode 100644 index 0000000..12bccbe --- /dev/null +++ b/src/main/java/ihl/ClientProxy.java @@ -0,0 +1,496 @@ +package ihl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import cpw.mods.fml.client.registry.ClientRegistry;
+import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
+import cpw.mods.fml.client.registry.RenderingRegistry;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.common.network.FMLNetworkEvent;
+import cpw.mods.fml.common.network.NetworkRegistry;
+import cpw.mods.fml.common.network.internal.FMLProxyPacket;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.crop_harvestors.BlobEntityFX;
+import ihl.crop_harvestors.BlobEntityFX.FluidType;
+import ihl.crop_harvestors.BlobRenderFX;
+import ihl.crop_harvestors.SackRender;
+import ihl.crop_harvestors.SackTileEntity;
+import ihl.enviroment.MirrorRender;
+import ihl.enviroment.MirrorTileEntity;
+import ihl.explosion.ExplosionEntityFX;
+import ihl.explosion.ExplosionRenderFX;
+import ihl.explosion.IHLEntityFallingPile;
+import ihl.explosion.IHLEntityFallingPileRender;
+import ihl.explosion.PileBlockRender;
+import ihl.explosion.PileTileEntity;
+import ihl.flexible_cable.AnchorTileEntity;
+import ihl.flexible_cable.BatterySwitchUnitModel;
+import ihl.flexible_cable.BatterySwitchUnitTileEntity;
+import ihl.flexible_cable.BlastEntityFX;
+import ihl.flexible_cable.IronWorkbenchRender;
+import ihl.flexible_cable.IronWorkbenchTileEntity;
+import ihl.flexible_cable.NodeEntity;
+import ihl.flexible_cable.NodeRender;
+import ihl.flexible_cable.RectifierTransformerUnitTileEntity;
+import ihl.interfaces.INetworkListener;
+import ihl.interfaces.ISelectionBoxSpecialRenderer;
+import ihl.items_blocks.FlexibleCableItem;
+import ihl.items_blocks.IHLTool;
+import ihl.items_blocks.MachineBaseBlock.MachineType;
+import ihl.model.CableHolderSelectionBoxSpecialRenderer;
+import ihl.model.FlexibleCableItemRender;
+import ihl.model.IHLBlockRenderer;
+import ihl.model.IHLToolRenderer;
+import ihl.model.ImpregnatingMachineBlockRender;
+import ihl.model.IronWorkbenchBlockRender;
+import ihl.model.RectifierTransformerUnitBlockRender;
+import ihl.model.RectifierTransformerUnitSelectionBoxSpecialRenderer;
+import ihl.model.RefluxCondenserBlockRender;
+import ihl.model.UniversalTileRender;
+import ihl.processing.chemistry.ElectrolysisBathModel;
+import ihl.processing.chemistry.ElectrolysisBathTileEntity;
+import ihl.processing.chemistry.FractionatorBottomModel;
+import ihl.processing.chemistry.FractionatorBottomTileEntity;
+import ihl.processing.chemistry.FractionatorCoverModel;
+import ihl.processing.chemistry.FractionatorCoverTileEntity;
+import ihl.processing.chemistry.FractionatorSectionModel;
+import ihl.processing.chemistry.FractionatorSectionTileEntity;
+import ihl.processing.chemistry.GaedesMercuryRotaryPumpModel;
+import ihl.processing.chemistry.GaedesMercuryRotaryPumpTileEntity;
+import ihl.processing.chemistry.LoomModel;
+import ihl.processing.chemistry.LoomTileEntity;
+import ihl.processing.chemistry.RefluxCondenserModel;
+import ihl.processing.chemistry.RefluxCondenserTileEntity;
+import ihl.processing.chemistry.SolarEvaporatorTileEntity;
+import ihl.processing.metallurgy.CoilerModel;
+import ihl.processing.metallurgy.CoilerRender;
+import ihl.processing.metallurgy.CoilerTileEntity;
+import ihl.processing.metallurgy.DetonationSprayingMachineModel;
+import ihl.processing.metallurgy.DetonationSprayingMachineRender;
+import ihl.processing.metallurgy.DetonationSprayingMachineTileEntity;
+import ihl.processing.metallurgy.ExtruderModel;
+import ihl.processing.metallurgy.ExtruderTileEntity;
+import ihl.processing.metallurgy.GasWeldingStationModel;
+import ihl.processing.metallurgy.GasWeldingStationTileEntity;
+import ihl.processing.metallurgy.ImpregnatingMachineRender;
+import ihl.processing.metallurgy.ImpregnatingMachineTileEntity;
+import ihl.processing.metallurgy.LathePart1Model;
+import ihl.processing.metallurgy.LathePart1TileEntity;
+import ihl.processing.metallurgy.LathePart2Model;
+import ihl.processing.metallurgy.LathePart2TileEntity;
+import ihl.processing.metallurgy.RollingMachinePart1Model;
+import ihl.processing.metallurgy.RollingMachinePart1TileEntity;
+import ihl.processing.metallurgy.RollingMachinePart2Model;
+import ihl.processing.metallurgy.RollingMachinePart2TileEntity;
+import ihl.processing.metallurgy.RollingMachineRender;
+import ihl.processing.metallurgy.VulcanizationExtrudingMoldModel;
+import ihl.processing.metallurgy.VulcanizationExtrudingMoldTileEntity;
+import ihl.processing.metallurgy.WoodenRollingMachinePart1TileEntity;
+import ihl.processing.metallurgy.WoodenRollingMachinePart2Model;
+import ihl.processing.metallurgy.WoodenRollingMachinePart2TileEntity;
+import ihl.processing.metallurgy.WoodenRollingMachineRender;
+import ihl.servitor.FlameEntityFX;
+import ihl.servitor.FlameRenderFX;
+import ihl.servitor.LostHeadEntity;
+import ihl.servitor.LostHeadRender;
+import ihl.servitor.SkullItemRender;
+import ihl.utils.BlockItemRender;
+import ihl.utils.IHLRenderUtils;
+import ihl.utils.IHLUtils;
+import ihl.worldgen.ores.IHLFluid;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufInputStream;
+import io.netty.buffer.ByteBufOutputStream;
+import io.netty.buffer.Unpooled;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityClientPlayerMP;
+import net.minecraft.client.multiplayer.WorldClient;
+import net.minecraft.client.renderer.GLAllocation;
+import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.world.World;
+import net.minecraftforge.client.MinecraftForgeClient;
+import net.minecraftforge.client.event.TextureStitchEvent;
+import net.minecraftforge.common.MinecraftForge;
+
+@SideOnly(value = Side.CLIENT)
+public class ClientProxy extends ServerProxy {
+
+ public boolean loadMirrorRender = true;
+ public IHLRenderUtils renderUtils;
+ public Map<MachineType, Integer> sharedBlockRenders = new HashMap<MachineType, Integer>();
+ public Map<Class<? extends TileEntity>, ISelectionBoxSpecialRenderer> selectionBoxSpecialRendererRegistry = new HashMap<Class<? extends TileEntity>, ISelectionBoxSpecialRenderer>();
+
+ public ClientProxy() {
+ }
+
+ @Override
+ public void load() throws ParserConfigurationException {
+ if (channel == null) {
+ channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(IHLModInfo.MODID);
+ channel.register(this);
+ }
+ this.renderUtils = new IHLRenderUtils();
+ MinecraftForge.EVENT_BUS.register(this.renderUtils);
+ registerBlockHandler(new ImpregnatingMachineBlockRender(), MachineType.BronzeTub);
+ registerBlockHandler(new ImpregnatingMachineBlockRender(), MachineType.SolarEvaporator);
+ registerBlockHandler(new RefluxCondenserBlockRender(), MachineType.RefluxCondenser);
+ registerBlockHandler(new RectifierTransformerUnitBlockRender(), MachineType.RectifierTransformerUnit);
+ registerBlockHandler(new IronWorkbenchBlockRender(), MachineType.IronWorkbench);
+ PileBlockRender pileBlockRender = new PileBlockRender();
+ RenderingRegistry.registerBlockHandler(pileBlockRender);
+ ClientRegistry.bindTileEntitySpecialRenderer(PileTileEntity.class, pileBlockRender.pileTileEntityRender);
+
+ RenderingRegistry.registerEntityRenderingHandler(IHLEntityFallingPile.class, new IHLEntityFallingPileRender());
+ ClientRegistry.bindTileEntitySpecialRenderer(SackTileEntity.class, new SackRender());
+ ClientRegistry.bindTileEntitySpecialRenderer(LathePart1TileEntity.class, new UniversalTileRender(
+ new LathePart1Model(), new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(LathePart2TileEntity.class, new UniversalTileRender(
+ new LathePart2Model(), new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(LoomTileEntity.class, new UniversalTileRender(new LoomModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/detonationSprayingMachine.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(ImpregnatingMachineTileEntity.class,
+ new ImpregnatingMachineRender(900f));
+ ClientRegistry.bindTileEntitySpecialRenderer(SolarEvaporatorTileEntity.class,
+ new ImpregnatingMachineRender(900f));
+ ClientRegistry.bindTileEntitySpecialRenderer(DetonationSprayingMachineTileEntity.class,
+ new DetonationSprayingMachineRender());
+ ClientRegistry.bindTileEntitySpecialRenderer(CoilerTileEntity.class, new CoilerRender());
+ ClientRegistry.bindTileEntitySpecialRenderer(IronWorkbenchTileEntity.class, new IronWorkbenchRender());
+ ClientRegistry.bindTileEntitySpecialRenderer(RollingMachinePart1TileEntity.class, new RollingMachineRender());
+ ClientRegistry.bindTileEntitySpecialRenderer(RollingMachinePart2TileEntity.class,
+ new UniversalTileRender(new RollingMachinePart2Model(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(VulcanizationExtrudingMoldTileEntity.class,
+ new UniversalTileRender(new VulcanizationExtrudingMoldModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(ExtruderTileEntity.class, new UniversalTileRender(
+ new ExtruderModel(), new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(WoodenRollingMachinePart1TileEntity.class,
+ new WoodenRollingMachineRender());
+ ClientRegistry.bindTileEntitySpecialRenderer(WoodenRollingMachinePart2TileEntity.class,
+ new UniversalTileRender(new WoodenRollingMachinePart2Model(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/woodenRollingMachine.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(GasWeldingStationTileEntity.class,
+ new UniversalTileRender(new GasWeldingStationModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/gasWeldingStation.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(GaedesMercuryRotaryPumpTileEntity.class,
+ new UniversalTileRender(new GaedesMercuryRotaryPumpModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/extruder.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(FractionatorBottomTileEntity.class,
+ new UniversalTileRender(new FractionatorBottomModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/splitInjectionMold.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(FractionatorSectionTileEntity.class,
+ new UniversalTileRender(new FractionatorSectionModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/splitInjectionMold.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(FractionatorCoverTileEntity.class,
+ new UniversalTileRender(new FractionatorCoverModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/splitInjectionMold.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(RefluxCondenserTileEntity.class,
+ new UniversalTileRender(new RefluxCondenserModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/splitInjectionMold.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(BatterySwitchUnitTileEntity.class,
+ new UniversalTileRender(new BatterySwitchUnitModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/batterySwitchUnit.png")));
+ ClientRegistry.bindTileEntitySpecialRenderer(ElectrolysisBathTileEntity.class,
+ new UniversalTileRender(new ElectrolysisBathModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/electrolysisBath.png")));
+ if (loadMirrorRender && IHLMod.config.mirrorReflectionRange > 0) {
+ ClientRegistry.bindTileEntitySpecialRenderer(MirrorTileEntity.class, new MirrorRender());
+ }
+ selectionBoxSpecialRendererRegistry.put(AnchorTileEntity.class, new CableHolderSelectionBoxSpecialRenderer());
+ selectionBoxSpecialRendererRegistry.put(RectifierTransformerUnitTileEntity.class,
+ new RectifierTransformerUnitSelectionBoxSpecialRenderer());
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("cannonBronze"),
+ new BlockItemRender(new DetonationSprayingMachineModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/detonationSprayingMachine.png"), 0, 0,
+ 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("lathePart1"),
+ new BlockItemRender(new LathePart1Model(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("lathePart2"),
+ new BlockItemRender(new LathePart2Model(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("rollingMachinePart1"),
+ new BlockItemRender(new RollingMachinePart1Model(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png"), 0, 5, 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("rollingMachinePart2"),
+ new BlockItemRender(new RollingMachinePart2Model(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("coiler"),
+ new BlockItemRender(new CoilerModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png"), 0, 6, 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("loom"),
+ new BlockItemRender(new LoomModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/detonationSprayingMachine.png"), 0, 0,
+ 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("vulcanizationExtrudingMold"),
+ new BlockItemRender(new VulcanizationExtrudingMoldModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("extruder"),
+ new BlockItemRender(new ExtruderModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/coiler.png"), 0, 0, 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("woodenRollingMachinePart1"),
+ new BlockItemRender(new WoodenRollingMachinePart2Model(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/woodenRollingMachine.png"), 0, 0,
+ 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("woodenRollingMachinePart2"),
+ new BlockItemRender(new WoodenRollingMachinePart2Model(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/woodenRollingMachine.png"), 0, 0,
+ 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("gasWeldingStation"),
+ new BlockItemRender(new GasWeldingStationModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/gasWeldingStation.png"), 0, 0, 0.0F,
+ 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("gaedesMercuryRotaryPump"),
+ new BlockItemRender(new GaedesMercuryRotaryPumpModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/extruder.png"), 0, 0, 0.0F, 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLMod.ihlSkull, new SkullItemRender());
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("fractionatorBottom"),
+ new BlockItemRender(new FractionatorBottomModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/splitInjectionMold.png"), 0, 0, 0.0F,
+ 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("fractionatorSection"),
+ new BlockItemRender(new FractionatorSectionModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/splitInjectionMold.png"), 0, 0, 0.0F,
+ 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("fractionatorCover"),
+ new BlockItemRender(new FractionatorCoverModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/splitInjectionMold.png"), 0, 0, 0.0F,
+ 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("refluxCondenser"),
+ new BlockItemRender(new RefluxCondenserModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/splitInjectionMold.png"), 0, 0, 0.0F,
+ 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("batterySwitchUnit"),
+ new BlockItemRender(new BatterySwitchUnitModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/batterySwitchUnit.png"), 0, 0, 0.0F,
+ 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLUtils.getThisModItem("electrolysisBath"),
+ new BlockItemRender(new ElectrolysisBathModel(),
+ new ResourceLocation(IHLModInfo.MODID + ":textures/blocks/electrolysisBath.png"), 0, 0, 0.0F,
+ 0.0F));
+ MinecraftForgeClient.registerItemRenderer(IHLTool.instance, new IHLToolRenderer());
+ MinecraftForgeClient.registerItemRenderer(FlexibleCableItem.instance, new FlexibleCableItemRender());
+ RenderingRegistry.registerEntityRenderingHandler(LostHeadEntity.class, new LostHeadRender());
+ RenderingRegistry.registerEntityRenderingHandler(FlameEntityFX.class,
+ new FlameRenderFX(IHLModInfo.MODID + ":textures/particles/flameTongue.png"));
+ RenderingRegistry.registerEntityRenderingHandler(BlastEntityFX.class,
+ new FlameRenderFX(IHLModInfo.MODID + ":textures/particles/blast.png"));
+ RenderingRegistry.registerEntityRenderingHandler(BlobEntityFX.class, new BlobRenderFX());
+ RenderingRegistry.registerEntityRenderingHandler(ExplosionEntityFX.class,
+ new ExplosionRenderFX(IHLModInfo.MODID + ":textures/particles/explosion.png"));
+ RenderingRegistry.registerEntityRenderingHandler(NodeEntity.class, new NodeRender());
+ }
+
+ @Override
+ public void spawnParticle(int particle, World world, double x, double y, double z, double mx, double my, double mz,
+ float particleScale) {
+ switch (particle) {
+ case 0:
+ FlameEntityFX flamePEFX1 = new FlameEntityFX(world, x, y, z, mx, my, mz, particleScale);
+ world.spawnEntityInWorld(flamePEFX1);
+ break;
+ case 1:
+ BlobEntityFX blob = new BlobEntityFX(world, x, y, z, mx, my, mz, particleScale, FluidType.RESIN);
+ world.spawnEntityInWorld(blob);
+ break;
+ case 2:
+ BlobEntityFX blob2 = new BlobEntityFX(world, x, y, z, mx, my, mz, particleScale, FluidType.SAP);
+ world.spawnEntityInWorld(blob2);
+ break;
+ case 3:
+ BlastEntityFX blast = new BlastEntityFX(world, x, y, z, mx, my, mz, particleScale);
+ world.spawnEntityInWorld(blast);
+ break;
+ case 4:
+ world.spawnParticle("smoke", x, y, z, mx, my, mz);
+ break;
+ default:
+ FlameEntityFX flamePEFX2 = new FlameEntityFX(world, x, y, z, mx, my, mz, particleScale);
+ world.spawnEntityInWorld(flamePEFX2);
+ break;
+ }
+ }
+
+ @Override
+ public void createExplosionEffect(World world, int x, int y, int z, float radius) {
+ world.playSound(x, y, z, IHLModInfo.MODID + ":explosion", 100f, 1f, false);
+ ExplosionEntityFX explosionFX = new ExplosionEntityFX(world, x, y, z, radius);
+ world.spawnEntityInWorld(explosionFX);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ @SubscribeEvent
+ public void registerIcons(TextureStitchEvent.Pre event) {
+ if (event.map.getTextureType() == 0) {
+ IHLFluid.registerIcons(event.map);
+ }
+ }
+
+ @Override
+ public Render getRenderForEntityClass(Class<? extends Entity> entityClass) {
+ return (Render) RenderManager.instance.entityRenderMap.get(entityClass);
+ }
+
+ @Override
+ public void initBlockRenderer() {
+ new IHLBlockRenderer();
+ }
+
+ @Override
+ public int getGLDisplayList() {
+ return GLAllocation.generateDisplayLists(1);
+ }
+
+ @Override
+ public File getMinecraftDir() {
+ return Minecraft.getMinecraft().mcDataDir;
+ }
+
+ @Override
+ public int shareBlockRendererByMachineType(MachineType type) {
+ return sharedBlockRenders.get(type);
+ }
+
+ public void registerBlockHandler(ISimpleBlockRenderingHandler handler, MachineType... types) {
+ RenderingRegistry.registerBlockHandler(handler);
+ for (MachineType type : types) {
+ sharedBlockRenders.put(type, handler.getRenderId());
+ }
+ }
+
+ @SubscribeEvent
+ public void onPacketFromServerToClient(FMLNetworkEvent.ClientCustomPacketEvent event) throws IOException {
+ WorldClient world = Minecraft.getMinecraft().theWorld;
+ ByteBuf data = event.packet.payload();
+ ByteBufInputStream byteBufInputStream = new ByteBufInputStream(data);
+ switch (byteBufInputStream.read()) {
+ case 0:
+ int particleId = byteBufInputStream.read();
+ float x = byteBufInputStream.readFloat();
+ float y = byteBufInputStream.readFloat();
+ float z = byteBufInputStream.readFloat();
+ float mx = byteBufInputStream.readFloat();
+ float my = byteBufInputStream.readFloat();
+ float mz = byteBufInputStream.readFloat();
+ float particleScale = byteBufInputStream.readFloat();
+ this.spawnParticle(particleId, world, x, y, z, mx, my, mz, particleScale);
+ break;
+ case 1:
+ int entityId = byteBufInputStream.readInt();
+ INetworkListener listener = (INetworkListener) world.getEntityByID(entityId);
+ if (listener != null) {
+ listener.recieveData(byteBufInputStream);
+ IHLMod.log.debug("Data delivered to client");
+ } else {
+ delayedEntityDataPacket.put(entityId, data);
+ IHLMod.log.debug("Data delayed. Entity ID=" + entityId);
+ }
+ break;
+ case 2:
+ int posX = byteBufInputStream.readInt();
+ int posY = byteBufInputStream.readInt();
+ int posZ = byteBufInputStream.readInt();
+ float radius = byteBufInputStream.readFloat();
+ this.createExplosionEffect(world, posX, posY, posZ, radius);
+ break;
+ case 3:
+ int soundId = byteBufInputStream.read();
+ x = byteBufInputStream.readFloat();
+ y = byteBufInputStream.readFloat();
+ z = byteBufInputStream.readFloat();
+ float volume = byteBufInputStream.readFloat();
+ float pitch = byteBufInputStream.readFloat();
+ this.playSound(world, soundId, x, y, z, volume, pitch);
+ break;
+ }
+ byteBufInputStream.close();
+ }
+
+ private void playSound(WorldClient world, int soundId, float x, float y, float z, float volume, float pitch) {
+ world.playSound(x, y, z, IHLModInfo.MODID + ":fuse", 1f, 1f, false);
+ }
+
+ @Override
+ public boolean renderTESpecialSelectionBox(TileEntity te, EntityPlayer player, ItemStack currentItem,
+ MovingObjectPosition target, float partialTicks) {
+ ISelectionBoxSpecialRenderer ssbr = selectionBoxSpecialRendererRegistry.get(te.getClass());
+ if (ssbr != null) {
+ ssbr.drawSelectionBox(player, currentItem, target, partialTicks);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public void sendItemStackNBTTagFromClientToServerPlayer(EntityPlayer player, int slotNumber, String fieldName,
+ int fieldValue) {
+ ByteBuf bb = Unpooled.buffer(36);
+ ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb);
+ try {
+ byteBufOutputStream.write(0);
+ byteBufOutputStream.writeInt(player.getEntityId());
+ byteBufOutputStream.writeInt(player.worldObj.provider.dimensionId);
+ byteBufOutputStream.writeInt(slotNumber);
+ byteBufOutputStream.writeInt(fieldValue);
+ byteBufOutputStream.writeUTF(fieldName);
+ channel.sendToServer(new FMLProxyPacket(byteBufOutputStream.buffer(), IHLModInfo.MODID));
+ byteBufOutputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void requestTileEntityInitdataFromClientToServer(int x, int y, int z) {
+ EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
+ ByteBuf bb = Unpooled.buffer(36);
+ ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb);
+ try {
+ byteBufOutputStream.write(1);
+ byteBufOutputStream.writeInt(player.getEntityId());
+ byteBufOutputStream.writeInt(player.worldObj.provider.dimensionId);
+ byteBufOutputStream.writeInt(x);
+ byteBufOutputStream.writeInt(y);
+ byteBufOutputStream.writeInt(z);
+ channel.sendToServer(new FMLProxyPacket(byteBufOutputStream.buffer(), IHLModInfo.MODID));
+ byteBufOutputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ 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/src/main/java/ihl/IHLCreativeTab.java b/src/main/java/ihl/IHLCreativeTab.java new file mode 100644 index 0000000..ddccc5b --- /dev/null +++ b/src/main/java/ihl/IHLCreativeTab.java @@ -0,0 +1,35 @@ +package ihl;
+
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+
+public class IHLCreativeTab extends CreativeTabs {
+
+ private static ItemStack ic2_handpump;
+ public static final CreativeTabs tab = new IHLCreativeTab();
+
+ public IHLCreativeTab()
+ {
+ super("IHL");
+ }
+
+ @Override
+ public ItemStack getIconItemStack()
+ {
+ ic2_handpump = new ItemStack(IHLMod.ic2_handpump);
+ return ic2_handpump;
+ }
+
+ @Override
+ public Item getTabIconItem()
+ {
+ return null;
+ }
+
+ @Override
+ public String getTranslatedTabLabel()
+ {
+ return "IHL";
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/IHLMod.java b/src/main/java/ihl/IHLMod.java new file mode 100644 index 0000000..17f48c5 --- /dev/null +++ b/src/main/java/ihl/IHLMod.java @@ -0,0 +1,2318 @@ +package ihl; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.logging.log4j.Logger; + +import codechicken.nei.NEIModContainer; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import gregapi.data.IL; +import gregapi.data.MT; +import gregapi.data.OP; +import gregapi.oredict.OreDictManager; +import gregapi.recipes.GT_ModHandler; +import gregapi.recipes.Recipe; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_OreDictUnificator; +import ic2.api.item.IC2Items; +import ic2.api.recipe.IRecipeInput; +import ic2.api.recipe.RecipeInputFluidContainer; +import ic2.api.recipe.RecipeInputItemStack; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.api.recipe.Recipes; +import ic2.core.Ic2Items; +import ic2.core.util.StackUtil; +import ihl.crop_harvestors.RubberTreeBlock; +import ihl.crop_harvestors.SackBlock; +import ihl.crop_harvestors.SackTileEntity; +import ihl.enviroment.LaserHitMirrorEventHandler; +import ihl.enviroment.MirrorBlock; +import ihl.explosion.ChunkAndWorldLoadEventHandler; +import ihl.explosion.ExplosionVectorBlockV2; +import ihl.explosion.ExplosiveBlock; +import ihl.explosion.GroundRemoverItem; +import ihl.explosion.IHLEntityFallingPile; +import ihl.explosion.PileBlock; +import ihl.flexible_cable.AnchorBlock; +import ihl.flexible_cable.AnchorTileEntity; +import ihl.flexible_cable.IHLENet; +import ihl.flexible_cable.IronWorkbenchTileEntity; +import ihl.flexible_cable.NodeEntity; +import ihl.flexible_cable.PowerCableNodeEntity; +import ihl.handpump.AdvancedHandPump; +import ihl.handpump.IHLHandPump; +import ihl.items_blocks.FiberItem; +import ihl.items_blocks.FlexibleCableItem; +import ihl.items_blocks.FlexiblePipeItem; +import ihl.items_blocks.IHLBucketHandler; +import ihl.items_blocks.IHLTool; +import ihl.items_blocks.ItemSubstance; +import ihl.items_blocks.MachineBaseBlock; +import ihl.items_blocks.RecipeInputs; +import ihl.metallurgy.constants.ElectricConductor; +import ihl.nei_integration.NEIIHLConfig; +import ihl.processing.chemistry.BatteryItem; +import ihl.processing.chemistry.ChemicalReactorTileEntity; +import ihl.processing.chemistry.CryogenicDistillerTileEntity; +import ihl.processing.chemistry.ElectricEvaporatorBlock; +import ihl.processing.chemistry.ElectricEvaporatorTileEntity; +import ihl.processing.chemistry.ElectrolysisBathTileEntity; +import ihl.processing.chemistry.EvaporatorBlock; +import ihl.processing.chemistry.EvaporatorTileEntity; +import ihl.processing.chemistry.FluidizedBedReactorTileEntity; +import ihl.processing.chemistry.FractionatorBottomTileEntity; +import ihl.processing.chemistry.LabElectrolyzerTileEntity; +import ihl.processing.chemistry.LeadOvenTileEntity; +import ihl.processing.chemistry.LoomTileEntity; +import ihl.processing.chemistry.PaperMachineTileEntity; +import ihl.processing.metallurgy.AchesonFurnanceTileEntity; +import ihl.processing.metallurgy.Crucible; +import ihl.processing.metallurgy.DetonationSprayingMachineTileEntity; +import ihl.processing.metallurgy.ElectricEngineItem; +import ihl.processing.metallurgy.ExtruderTileEntity; +import ihl.processing.metallurgy.GasWeldingStationTileEntity; +import ihl.processing.metallurgy.ImpregnatingMachineTileEntity; +import ihl.processing.metallurgy.InjectionMoldBlock; +import ihl.processing.metallurgy.MuffleFurnanceTileEntity; +import ihl.processing.metallurgy.RollingMachinePart1TileEntity; +import ihl.processing.metallurgy.VulcanizationExtrudingMoldTileEntity; +import ihl.processing.metallurgy.WireMillTileEntity; +import ihl.processing.metallurgy.WoodenRollingMachinePart1TileEntity; +import ihl.recipes.IronWorkbenchRecipe; +import ihl.recipes.RecipeInputDetonator; +import ihl.recipes.RecipeInputDie; +import ihl.recipes.RecipeInputOreDictionaryList; +import ihl.recipes.RecipeInputWire; +import ihl.recipes.RecipeOutputItemStack; +import ihl.recipes.UniversalRecipeInput; +import ihl.recipes.UniversalRecipeOutput; +import ihl.servitor.BoneBlock; +import ihl.servitor.LostHeadEntity; +import ihl.trans_dimensional_item_teleporter.TDITBlock; +import ihl.trans_dimensional_item_teleporter.TDITFrequencyTransmitter; +import ihl.trans_dimensional_item_teleporter.TDITTileEntity; +import ihl.utils.EntityDropEventHandler; +import ihl.utils.FluidDictionary; +import ihl.utils.IHLUtils; +import ihl.worldgen.IHLWorldGenerator; +import ihl.worldgen.ores.BlockOre; +import ihl.worldgen.ores.DebugScannerBlock; +import ihl.worldgen.ores.DebugScannerTileEntity; +import ihl.worldgen.ores.IHLFluid; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeDictionary.Type; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +@Mod(modid = IHLModInfo.MODID, name = IHLModInfo.MODNAME, version = IHLModInfo.MODVERSION, dependencies = "required-after:IC2@[2.2.767-experimental,)") +public class IHLMod implements IFuelHandler { + + @SidedProxy(clientSide = "ihl.ClientProxy", serverSide = "ihl.ServerProxy") + public static ServerProxy proxy; + public static IHLModConfig config; + public static IHLENet enet; + // This used to determine if GregTech mod presented on server and load + // GregTech recipes. + public static boolean isGregTechModLoaded = false; + public static boolean isGT_API_Version_5 = false; + public static Block cableAnchorBlock; + public static Block sackBlock; + public static Block rubberTreeBlock; + public static Block spruceTreeBlock; + public static Block evaporatorBlock; + public static Block electricEvaporatorBlock; + public static Block boneBlock = (new BoneBlock(Material.coral)).setBlockName("boneBlock").setHardness(2.0F) + .setResistance(2.0F); + public static Item ic2_handpump; + public static Item ic2_advanced_handpump; + public static Item ihlSkull = (new Item()).setUnlocalizedName("skull").setFull3D() + .setCreativeTab(CreativeTabs.tabMisc).setTextureName(IHLModInfo.MODID + ":skull"); + public static Block ic2Leaves; + public static Block ic2Wood; + public static Block tditBlock = (new TDITBlock(Material.glass)).setBlockName("tditBlock") + .setBlockTextureName(IHLModInfo.MODID + ":tditRight").setHardness(0.5F).setResistance(0.5F); + public static Item tditft; + public static Block ds = new DebugScannerBlock(Material.ice).setBlockName("debugScanner") + .setBlockTextureName(IHLModInfo.MODID + ":tditTop"); + public static Item crucible; + public static Logger log; + private ItemStack pfaalimestone; + private ItemStack pfaacobblelimestone; + public static FluidDictionary fluidDictionary; + public static Map<String, Integer> moltenAmounts = new HashMap<String, Integer>(); + public static ExplosionVectorBlockV2 explosionHandler; + + @EventHandler + public void preInit(FMLPreInitializationEvent evt) throws IOException, ParserConfigurationException { + fluidDictionary = new FluidDictionary(); + log = evt.getModLog(); + IHLMod.config = new IHLModConfig(evt); + rubberTreeBlock = (new RubberTreeBlock(RubberTreeBlock.TreeType.RUBBERTREE)).setBlockName("rubberTreeBlock") + .setBlockTextureName(IHLModInfo.MODID + ":blockRubWoodFront").setHardness(2.0F).setResistance(5.0F); + spruceTreeBlock = (new RubberTreeBlock(RubberTreeBlock.TreeType.SPRUCE)).setBlockName("spruceBlock") + .setBlockTextureName(IHLModInfo.MODID + ":blockSpruceFront").setHardness(2.0F).setResistance(5.0F) + .setCreativeTab(IHLCreativeTab.tab); + GameRegistry.registerFuelHandler(this); + FiberItem.init(); + FlexiblePipeItem.init(); + InjectionMoldBlock.init(); + ElectricEngineItem.init(); + BlockOre.init(); + IHLFluid.init(); + GameRegistry.registerWorldGenerator(new IHLWorldGenerator(), 0); + ItemSubstance.init(); + BatteryItem.init(); + IHLTool.init(); + MirrorBlock.init(); + MachineBaseBlock.init();// must be first + IHLMod.enet = new IHLENet(); + MinecraftForge.EVENT_BUS.register(new EntityDropEventHandler()); + MinecraftForge.EVENT_BUS.register(new LaserHitMirrorEventHandler()); + MinecraftForge.EVENT_BUS.register(new IHLBucketHandler()); + MinecraftForge.EVENT_BUS.register(proxy); + FMLCommonHandler.instance().bus().register(proxy); + GameRegistry.registerBlock(ds, "debugScanner"); + GameRegistry.registerTileEntity(DebugScannerTileEntity.class, "DebugScanner"); + cableAnchorBlock = new AnchorBlock("cableAnchor"); + List<String> info1 = new ArrayList<String>(); + info1.add("non vulcanized rubber insulated"); + GroundRemoverItem.init(); + FlexibleCableItem.init(); + ExplosiveBlock.init(); + PileBlock.init(); + GameRegistry.registerTileEntity(AnchorTileEntity.class, "anchorTileEntity"); + + crucible = new Crucible(); + + ic2_handpump = new IHLHandPump().setUnlocalizedName("handpump"); + ic2_advanced_handpump = new AdvancedHandPump().setUnlocalizedName("advanced_handpump"); + tditft = new TDITFrequencyTransmitter().setUnlocalizedName("tditFrequencyTransmitter"); + + evaporatorBlock = (new EvaporatorBlock(Material.iron)).setBlockName("evaporatorBlock") + .setBlockTextureName(IHLModInfo.MODID + ":solidFuelEvaporatorFrontActive").setHardness(5.0F) + .setResistance(5.0F); + electricEvaporatorBlock = (new ElectricEvaporatorBlock(Material.iron)).setBlockName("electricEvaporatorBlock") + .setBlockTextureName(IHLModInfo.MODID + ":electricEvaporatorFrontActive").setHardness(5.0F) + .setResistance(5.0F); + sackBlock = (new SackBlock(Material.iron)).setBlockName("sackBlock") + .setBlockTextureName(IHLModInfo.MODID + ":sackItem").setHardness(0.5F).setResistance(0.5F); + + GameRegistry.registerBlock(boneBlock, "boneBlock"); + + GameRegistry.registerItem(ic2_handpump, "Handpump"); + GameRegistry.registerItem(ic2_advanced_handpump, ic2_advanced_handpump.getUnlocalizedName()); + GameRegistry.registerItem(ihlSkull, "skull"); + + GameRegistry.registerBlock(rubberTreeBlock, "rubberTreeBlock"); + GameRegistry.registerBlock(spruceTreeBlock, "spruceTreeBlock"); + GameRegistry.registerBlock(sackBlock, "sackBlock"); + GameRegistry.registerTileEntity(SackTileEntity.class, "sackTileEntity"); + GameRegistry.registerBlock(evaporatorBlock, "evaporatorBlock"); + GameRegistry.registerBlock(electricEvaporatorBlock, "electricEvaporatorBlock"); + GameRegistry.registerTileEntity(EvaporatorTileEntity.class, "evaporatorTileEntity"); + GameRegistry.registerTileEntity(ElectricEvaporatorTileEntity.class, "electricEvaporatorTileEntity"); + + 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); + OreDictionary.registerOre("dustGunpowder", Items.gunpowder); + OreDictionary.registerOre("toolLighter", new ItemStack(Items.flint_and_steel, 1, OreDictionary.WILDCARD_VALUE)); + OreDictionary.registerOre("charcoal", new ItemStack(Items.coal, 1, 1)); + OreDictionary.registerOre("blockDirt", new ItemStack(Blocks.dirt, 1, OreDictionary.WILDCARD_VALUE)); + OreDictionary.registerOre("blockDirt", new ItemStack(Blocks.grass, 1, OreDictionary.WILDCARD_VALUE)); + 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")); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent evt) throws IOException { + ic2Leaves = StackUtil.getBlock(IC2Items.getItem("rubberLeaves")); + ic2Wood = StackUtil.getBlock(IC2Items.getItem("rubberWood")); + if (!IHLMod.config.skipRecipeLoad) { + if (IHLMod.config.enableRubberTreeSack) { + GameRegistry.addRecipe(new ItemStack(sackBlock, 1), + new Object[] { "STS", "L L", "LLL", 'S', Items.string, 'T', Items.stick, 'L', Items.leather }); + Recipes.advRecipes.addRecipe(new ItemStack(evaporatorBlock, 1), + new Object[] { " B ", " I ", " ", Character.valueOf('B'), Items.bucket, + Character.valueOf('I'), IC2Items.getItem("ironFurnace") }); + EvaporatorTileEntity.init(); + } + if (IHLMod.config.enableTDIT) { + Recipes.advRecipes.addRecipe(new ItemStack(tditBlock, 1), + new Object[] { "AAA", "CMC", "ATA", Character.valueOf('A'), IC2Items.getItem("advancedAlloy"), + Character.valueOf('C'), new ItemStack(Blocks.chest, 1), Character.valueOf('M'), + IC2Items.getItem("advancedMachine"), Character.valueOf('T'), + IC2Items.getItem("teleporter") }); + Recipes.advRecipes.addRecipe(new ItemStack(tditft, 1), + new Object[] { " CC", "IAI", " ", Character.valueOf('I'), IC2Items.getItem("casingiron"), + Character.valueOf('C'), IC2Items.getItem("copperCableItem"), Character.valueOf('A'), + IC2Items.getItem("advancedCircuit") }); + } + GameRegistry.addRecipe(new ItemStack(boneBlock, 1), + new Object[] { "XXX", "XYX", "XXX", 'X', Items.bone, 'Y', Items.iron_ingot }); + GameRegistry.addRecipe(new ItemStack(boneBlock, 1), + new Object[] { "XZX", "XYX", "XZX", 'X', Items.bone, 'Y', Items.iron_ingot, 'Z', ihlSkull }); + GameRegistry.addShapelessRecipe(new ItemStack(Items.dye, 2, 15), new Object[] { ihlSkull }); + FurnaceRecipes.smelting().func_151394_a(IHLUtils.getThisModItemStack("bucket_SpruceResin"), + IHLUtils.getThisModItemStack("bucket_tarPitch"), 20F); + ItemStack nuggetTarPitch = OreDictionary.getOres("nuggetTarPitch").get(0).copy(); + GameRegistry.addShapelessRecipe(OreDictionary.getOres("ingotTarPitch").get(0).copy(), + new Object[] { nuggetTarPitch, nuggetTarPitch, nuggetTarPitch, nuggetTarPitch, nuggetTarPitch, + nuggetTarPitch, nuggetTarPitch, nuggetTarPitch, nuggetTarPitch }); + if (IHLUtils.hasOreDictionaryEntry("brickPeat") + && GameRegistry.findItem("Forestry", "bituminousPeat") != null) + GameRegistry.addRecipe(new ItemStack(GameRegistry.findItem("Forestry", "bituminousPeat"), 5), + new Object[] { "BBB", "BPB", "BBB", 'B', IHLUtils.getOreDictItemStack("brickPeat"), 'P', + OreDictionary.getOres("ingotTarPitch").get(0) }); + pfaalimestone = IHLUtils.getOtherModItemStackWithDamage("PFAAGeologica", "mediumStone", 0, 1); + pfaacobblelimestone = IHLUtils.getOtherModItemStackWithDamage("PFAAGeologica", "mediumCobble", 0, 1); + isGregTechModLoaded = Loader.isModLoaded("gregtech"); + if (isGregTechModLoaded) { + try { + Class.forName("gregapi.GT_API"); + } catch (ClassNotFoundException e) { + isGT_API_Version_5 = true; + } + if (isGT_API_Version_5) { + this.loadGT5Recipes(); + } else { + this.loadGT6Recipes(); + } + } else { + this.loadIC2Recipes(); + } + IHLUtils.addIC2RollingRecipe("ingotTungsten", IHLUtils.getOreDictItemStack("plateTungsten")); + IHLUtils.addIC2CentrifugeRecipe("crushedGyubnera", IHLUtils.getThisModItemStack("crushedPurifiedGyubnera"), + IHLUtils.getThisModItemStack("dustPotassiumFeldspar")); + IHLUtils.addIC2CentrifugeRecipe("crushedCinnabar", IHLUtils.getThisModItemStack("crushedPurifiedCinnabar"), + IHLUtils.getThisModItemStack("dustPotassiumFeldspar")); + IHLUtils.addIC2CentrifugeRecipe("crushedBauxite", IHLUtils.getThisModItemStack("crushedPurifiedBauxite"), + IHLUtils.getOreDictItemStack("dustClay")); + IHLUtils.addIC2CentrifugeRecipe("crushedStibnite", IHLUtils.getThisModItemStack("crushedPurifiedStibnite"), + IHLUtils.getOreDictItemStack("dustTinyGold")); + IHLUtils.addIC2MaceratorRecipe("logWood", IHLUtils.getThisModItemStack("dustWood")); + IHLUtils.addIC2MaceratorRecipe("ingotPotassium", IHLUtils.getThisModItemStack("dustPotassiumOxide")); + if (IHLUtils.hasOreDictionaryEntry("blockLimestone")) + IHLUtils.addIC2MaceratorRecipe("blockLimestone", + IHLUtils.getOreDictItemStackWithSize("dustCalcite", 4)); + if (pfaalimestone != null) + IHLUtils.addIC2MaceratorRecipe(pfaalimestone, IHLUtils.getOreDictItemStackWithSize("dustCalcite", 4)); + if (pfaacobblelimestone != null) + IHLUtils.addIC2MaceratorRecipe(pfaacobblelimestone, + IHLUtils.getOreDictItemStackWithSize("dustCalcite", 4)); + IHLUtils.addIC2MaceratorRecipe("oreGypsum", IHLUtils.getOreDictItemStack("dustGypsum")); + IHLUtils.addIC2MaceratorRecipe("orePotassiumFeldspar", + IHLUtils.getOreDictItemStack("dustPotassiumFeldspar")); + IHLUtils.addIC2MaceratorRecipe("oreLimestone", IHLUtils.getOreDictItemStackWithSize("dustCalcite", 4)); + IHLUtils.addIC2MaceratorRecipe("oreSaltpeter", IHLUtils.getOreDictItemStackWithSize("dustSaltpeter", 4)); + IHLUtils.addIC2MaceratorRecipe("oreGyubnera", IHLUtils.getThisModItemStackWithSize("crushedGyubnera", 2)); + IHLUtils.addIC2MaceratorRecipe("oreCinnabar", IHLUtils.getThisModItemStackWithSize("crushedCinnabar", 2)); + IHLUtils.addIC2MaceratorRecipe("oreBauxite", IHLUtils.getThisModItemStackWithSize("crushedBauxite", 2)); + IHLUtils.addIC2MaceratorRecipe("crushedPurifiedBauxite", IHLUtils.getThisModItemStack("dustBauxite")); + IHLUtils.addIC2MaceratorRecipe("oreStibnite", IHLUtils.getThisModItemStackWithSize("crushedStibnite", 2)); + IHLUtils.addIC2MaceratorRecipe("crushedPurifiedStibnite", IHLUtils.getThisModItemStack("dustStibnite")); + IHLUtils.addIC2MaceratorRecipe("blockGlass", IHLUtils.getOreDictItemStackWithSize("dustGlass", 1)); + IHLUtils.addIC2MaceratorRecipe("stickGraphite", 2, IHLUtils.getThisModItemStack("dustGraphite")); + IHLUtils.addIC2MaceratorRecipe("oreMica", IHLUtils.getThisModItemStackWithSize("dustMica", 4)); + IHLUtils.addIC2MaceratorRecipe("oreTrona", IHLUtils.getThisModItemStackWithSize("dustTrona", 4)); + IHLUtils.addIC2MaceratorRecipe(Ic2Items.iridiumOre, IHLUtils.getThisModItemStack("dustIridium")); + IHLUtils.addIC2MaceratorRecipe("oreDatolite", IHLUtils.getThisModItemStackWithSize("dustDatolite", 4)); + IHLUtils.addIC2MaceratorRecipe("oreBischofite", IHLUtils.getThisModItemStackWithSize("dustBischofite", 4)); + IHLUtils.addIC2MaceratorRecipe("ingotBrick", IHLUtils.getOreDictItemStackWithSize("dustBrick", 1)); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStackWithSize("dustIrongraphite", 2), + new Object[] { new RecipeInputOreDict("dustIron"), new RecipeInputOreDict("dustGraphite") }); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getOreDictItemStackWithSize("dustPorcelain", 4), + new Object[] { new RecipeInputOreDict("dustClay"), new RecipeInputOreDict("dustClay"), + new RecipeInputOreDict("dustSiliconDioxide"), + new RecipeInputOreDict("dustPotassiumFeldspar") }); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStack("chisel"), new Object[] { + IHLUtils.getThisModItemStack("grindstone"), IHLUtils.getThisModItemStack("blankChiselSteel") }); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze"), + new Object[] { IHLUtils.getThisModItemStack("grindstone"), + IHLUtils.getThisModItemStack("carvingKnifeBronze") }); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("hammer"), + new Object[] { "H ", "SC ", " ", Character.valueOf('H'), + IHLUtils.getThisModItemStack("toolHeadHammerSmallSteel"), Character.valueOf('S'), + new ItemStack(Items.stick), Character.valueOf('C'), + new RecipeInputOreDict("craftingToolKnife") }); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("grindstone", 2), + new Object[] { " H ", " Q ", " ", Character.valueOf('H'), + new RecipeInputOreDict("craftingToolForgeHammer"), Character.valueOf('Q'), + new RecipeInputOreDict("blockQuartz") }); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("grindstone", 2), + new Object[] { " H ", " Q ", " ", Character.valueOf('H'), + new RecipeInputOreDict("craftingToolHardHammer"), Character.valueOf('Q'), + new RecipeInputOreDict("blockQuartz") }); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("blankNeedleFileSteel", 64), + new Object[] { " H ", " C ", " P ", Character.valueOf('H'), + new RecipeInputOreDict("craftingToolForgeHammer"), Character.valueOf('C'), + new RecipeInputOreDict("craftingToolChisel"), Character.valueOf('P'), + IHLUtils.getThisModItemStack("plateHotSteel") }); + Recipes.metalformerExtruding.addRecipe(new RecipeInputOreDict("dustIrongraphite"), null, + IHLUtils.getThisModItemStackWithSize("linerIronGraphite", 4)); + Recipes.compressor.addRecipe(new RecipeInputOreDict("foilMica", 4), null, + IHLUtils.getThisModItemStack("plateMica")); + Recipes.metalformerExtruding.addRecipe(new RecipeInputOreDict("dustBoronCarbide"), null, + IHLUtils.getThisModItemStackWithSize("stickBoronCarbide", 2)); + Recipes.metalformerRolling.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("dustCoalElectrodePremix")), null, + IHLUtils.getThisModItemStack("plateRawCoal")); + Recipes.metalformerExtruding.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("foilRubberWithSulfur")), null, + IHLUtils.getThisModItemStack("batteryCellsEbonite")); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStack("dustAntimony"), new Object[] { + IHLUtils.getThisModItemStack("dustTinyAntimony"), IHLUtils.getThisModItemStack("dustTinyAntimony"), + IHLUtils.getThisModItemStack("dustTinyAntimony"), IHLUtils.getThisModItemStack("dustTinyAntimony"), + IHLUtils.getThisModItemStack("dustTinyAntimony"), IHLUtils.getThisModItemStack("dustTinyAntimony"), + IHLUtils.getThisModItemStack("dustTinyAntimony"), IHLUtils.getThisModItemStack("dustTinyAntimony"), + IHLUtils.getThisModItemStack("dustTinyAntimony") }); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStackWithSize("dustTinyAntimony", 9), + new Object[] { IHLUtils.getThisModItemStack("dustAntimony") }); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStack("dustSilicon"), new Object[] { + IHLUtils.getThisModItemStack("dustTinySilicon"), IHLUtils.getThisModItemStack("dustTinySilicon"), + IHLUtils.getThisModItemStack("dustTinySilicon"), IHLUtils.getThisModItemStack("dustTinySilicon"), + IHLUtils.getThisModItemStack("dustTinySilicon"), IHLUtils.getThisModItemStack("dustTinySilicon"), + IHLUtils.getThisModItemStack("dustTinySilicon"), IHLUtils.getThisModItemStack("dustTinySilicon"), + IHLUtils.getThisModItemStack("dustTinySilicon") }); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStackWithSize("dustTinySilicon", 9), + new Object[] { IHLUtils.getThisModItemStack("dustSilicon") }); + GameRegistry.addShapelessRecipe(IHLUtils.getThisModItemStack("dustSolderingAlloy"), new Object[] { + IHLUtils.getOreDictItemStack("dustTin"), IHLUtils.getThisModItemStack("dustTinyAntimony") }); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("achesonFurnance"), + new Object[] { "BPB", "S S", "B B", Character.valueOf('B'), new RecipeInputOreDict("ingotBrick"), + Character.valueOf('P'), new RecipeInputOreDict("plateSteel"), Character.valueOf('S'), + new RecipeInputOreDict("stickCoal") }); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("muffleFurnance"), + new Object[] { "BCB", "SDP", "BSB", Character.valueOf('B'), new RecipeInputOreDict("ingotBrick"), + Character.valueOf('P'), new RecipeInputOreDict("plateSteel"), Character.valueOf('C'), + IHLUtils.getThisModItemStack("crucibleMixture"), Character.valueOf('S'), + new RecipeInputOreDict("stickGraphite"), Character.valueOf('D'), + new RecipeInputOreDict("dustCarborundum") }); + + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 64), + new Object[] { "VFS", "DR ", "WT ", Character.valueOf('V'), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("viseSteel")), Character.valueOf('F'), + new RecipeInputOreDict("craftingToolFile"), Character.valueOf('S'), + new RecipeInputOreDict("stickSteel"), Character.valueOf('D'), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("handDrillBronze")), + Character.valueOf('R'), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("drillSteelHardened")), + Character.valueOf('W'), new RecipeInputOreDict("craftingToolSaw"), Character.valueOf('T'), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("tapM10x1SteelHardened")) }); + + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 8), + new Object[] { "VFS", "DR ", "W ", Character.valueOf('V'), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("viseSteel")), Character.valueOf('F'), + new RecipeInputOreDict("craftingToolFile"), Character.valueOf('S'), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("barD10Steel")), + Character.valueOf('D'), new RecipeInputOreDict("craftingToolHardHammer"), + Character.valueOf('R'), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("diceM10x1SteelHardened")), + Character.valueOf('W'), new RecipeInputOreDict("craftingToolSaw") }); + + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStackWithSize("drillSteel", 2), + new Object[] { "VFS", "DR ", " ", Character.valueOf('V'), + new RecipeInputOreDict("craftingToolHardHammer"), Character.valueOf('F'), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("viseSteel")), Character.valueOf('S'), + new RecipeInputOreDict("craftingToolFile"), Character.valueOf('D'), + new RecipeInputOreDict("craftingToolChisel"), Character.valueOf('R'), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("barD10SteelHot")) }); + + ItemStack crystal = IC2Items.getItem("lapotronCrystal").copy(); + ItemStack advBattery = IC2Items.getItem("advBattery").copy(); + ItemStack chargedReBattery = IC2Items.getItem("chargedReBattery").copy(); + crystal.setItemDamage(OreDictionary.WILDCARD_VALUE); + advBattery.setItemDamage(OreDictionary.WILDCARD_VALUE); + chargedReBattery.setItemDamage(OreDictionary.WILDCARD_VALUE); + + if (IHLMod.config.enableHandpump) { + Recipes.advRecipes.addRecipe(((IHLHandPump) ic2_handpump).getItemStack(0), + new Object[] { "T ", " C ", " P", Character.valueOf('T'), IC2Items.getItem("treetap"), + Character.valueOf('C'), IC2Items.getItem("cell"), Character.valueOf('P'), + IC2Items.getItem("powerunitsmall") }); + Recipes.advRecipes.addRecipe(((AdvancedHandPump) ic2_advanced_handpump).getItemStack(0), + new Object[] { "TK ", "KCA", " RP", Character.valueOf('T'), IC2Items.getItem("treetap"), + Character.valueOf('K'), IC2Items.getItem("advancedAlloy"), Character.valueOf('C'), + IC2Items.getItem("cell"), Character.valueOf('A'), IC2Items.getItem("advancedCircuit"), + Character.valueOf('R'), IC2Items.getItem("energyCrystal"), Character.valueOf('P'), + IC2Items.getItem("powerunitsmall") }); + } + ItemStack forestryWaxCapsule = IHLUtils.getOtherModItemStackWithDamage("Forestry", "waxCapsule", 0, 1); + ItemStack forestryWaxCast = IHLUtils.getOtherModItemStackWithDamage("Forestry", "waxCast", 0, 1); + ItemStack forestryCandle = IHLUtils.getOtherModItemStackWithDamage("Forestry", "candle", 0, 1); + ItemStack forestryBeesWax = IHLUtils.getOtherModItemStackWithDamage("Forestry", "beeswax", 0, 1); + if (forestryWaxCapsule != null) { + Recipes.advRecipes.addRecipe(forestryWaxCapsule, + new Object[] { "SBS", " ", " ", Character.valueOf('S'), + IHLUtils.getThisModItemStack("ingotStearin"), Character.valueOf('B'), + forestryBeesWax }); + } + if (forestryCandle != null) { + Recipes.advRecipes.addRecipe(forestryCandle, + new Object[] { " S ", " I ", " ", Character.valueOf('S'), new ItemStack(Items.string), + Character.valueOf('I'), IHLUtils.getThisModItemStack("ingotStearin") }); + } + if (forestryWaxCast != null) { + Recipes.advRecipes.addRecipe(forestryWaxCast, + new Object[] { "BSS", "S S", "SSB", Character.valueOf('S'), + IHLUtils.getThisModItemStack("ingotStearin"), Character.valueOf('B'), + forestryBeesWax }); + } + Iterator<ItemStack> odi = OreDictionary.getOres("dustGypsum").iterator(); + while (odi.hasNext()) { + ItemStack stack = odi.next().copy(); + stack.stackSize = 2; + FurnaceRecipes.smelting().func_151394_a(stack, IHLUtils.getThisModItemStack("dustDehydratedGypsum"), + 20F); + } + Recipes.FluidHeatGenerator.addFluid("oleicacid", 10, 16); + Recipes.FluidHeatGenerator.addFluid("mineraloil", 10, 16); + Recipes.FluidHeatGenerator.addFluid("acetylene", 10, 64); + Recipes.FluidHeatGenerator.addFluid("glycerol", 10, 16); + Recipes.FluidHeatGenerator.addFluid("turpentine", 10, 16); + Recipes.FluidHeatGenerator.addFluid("fueloil", 10, 32); + Recipes.FluidHeatGenerator.addFluid("crackinggas", 10, 32); + Recipes.semiFluidGenerator.addFluid("hydrogen", 10, 32); + Recipes.semiFluidGenerator.addFluid("crackinggas", 10, 32); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStackWithSize("breadWithLard", 4), + new Object[] { new ItemStack(Items.bread), IHLUtils.getThisModItemStack("muttonLard") }); + Recipes.advRecipes.addShapelessRecipe(IHLUtils.getThisModItemStack("dustCoalElectrodePremix"), + new Object[] { Ic2Items.coalDust, IHLUtils.getOreDictItemStack("nuggetTarPitch") }); + Recipes.metalformerExtruding.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("dustCoalElectrodePremix")), null, + IHLUtils.getThisModItemStack("stickCoalElectrodePremix")); + FurnaceRecipes.smelting().func_151394_a(IHLUtils.getThisModItemStack("stickCoalElectrodePremix"), + IHLUtils.getOreDictItemStack("stickCoal"), 20F); + FurnaceRecipes.smelting().func_151394_a(IHLUtils.getThisModItemStack("plateRawCoal"), + IHLUtils.getOreDictItemStack("plateCoal"), 20F); + FurnaceRecipes.smelting().func_151394_a(IHLUtils.getOreDictItemStackWithSize("dustCalcite", 3), + IHLUtils.getOreDictItemStack("dustQuicklime"), 2F); + FurnaceRecipes.smelting().func_151394_a(IHLUtils.getThisModItemStack("catalystRawIronOxide"), + IHLUtils.getThisModItemStack("catalystIronOxide"), 2F); + ItemSubstance.postInit(); + ItemStack lathingTool = Ic2Items.LathingTool.copy(); + lathingTool.setItemDamage(OreDictionary.WILDCARD_VALUE); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new IRecipeInput[] { new RecipeInputDie("setOfDies1_5sqmm", 240) }), + Arrays.asList(new ItemStack[] { Ic2Items.copperCableItem }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 240) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new IRecipeInput[] { new RecipeInputDie("setOfDies1_5sqmm", 240) }), + Arrays.asList(new ItemStack[] { Ic2Items.ironCableItem }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 240) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, Arrays.asList( + new ItemStack[] { IHLUtils.getThisModItemStack("bucket_tarPitch"), new ItemStack(Items.stick) }), + Arrays.asList(new ItemStack[] { new ItemStack(Items.bucket), + IHLUtils.getOreDictItemStackWithSize("nuggetTarPitch", 4), new ItemStack(Blocks.torch) }))); + List<IRecipeInput> materialList3 = new ArrayList<IRecipeInput>(); + materialList3.add(new RecipeInputItemStack(new ItemStack(Blocks.sand, 1, OreDictionary.WILDCARD_VALUE))); + materialList3.add(new RecipeInputOreDict("dustClay")); + materialList3.add(new RecipeInputFluidContainer(FluidRegistry.WATER, 1)); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays + .asList(new ItemStack[] { InjectionMoldBlock.instance.getSandInjectionMoldForResult("ingot") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays + .asList(new ItemStack[] { InjectionMoldBlock.instance.getSandInjectionMoldForResult("tub") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays.asList( + new ItemStack[] { InjectionMoldBlock.instance.getSandInjectionMoldForResult("blankChisel") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays.asList( + new ItemStack[] { InjectionMoldBlock.instance.getSandInjectionMoldForResult("carvingKnife") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays.asList(new ItemStack[] { + InjectionMoldBlock.instance.getSandInjectionMoldForResult("toolHeadHammerSmall") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays + .asList(new ItemStack[] { InjectionMoldBlock.instance.getSandInjectionMoldForResult("barD10") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays + .asList(new ItemStack[] { InjectionMoldBlock.instance.getSandInjectionMoldForResult("stick") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays.asList(new ItemStack[] { + InjectionMoldBlock.instance.getSandInjectionMoldForResult("setOfPartsForLVElemotor") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays.asList(new ItemStack[] { + InjectionMoldBlock.instance.getSandInjectionMoldForResult("pipelineAccessories") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays.asList(new ItemStack[] { + InjectionMoldBlock.instance.getSandInjectionMoldForResult("highPressureVessel") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays + .asList(new ItemStack[] { InjectionMoldBlock.instance.getSandInjectionMoldForResult("gasJet") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays.asList(new ItemStack[] { + InjectionMoldBlock.instance.getSandInjectionMoldForResult("handDrillSetOfMoldedParts") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, materialList3, + Arrays.asList(new ItemStack[] { InjectionMoldBlock.instance + .getSandInjectionMoldForResult("detonationSprayingMachineSetOfMoldedParts") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays.asList(new ItemStack[] { + InjectionMoldBlock.instance.getSandInjectionMoldForResult("viseSetOfMoldedParts") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, materialList3, Arrays + .asList(new ItemStack[] { InjectionMoldBlock.instance.getSandInjectionMoldForResult("nozzle") }))); + // Sand molds recipe section end + List<IRecipeInput> materialsForPrecisionMold = Arrays + .asList(new IRecipeInput[] { new RecipeInputItemStack(IHLUtils.getThisModItemStack("ingotStearin")), + new RecipeInputFluidContainer(FluidRegistry.getFluid("liquidglass"), 1), + new RecipeInputOreDict("dustSiliconDioxide"), + new RecipeInputItemStack(new ItemStack(Blocks.sand)) }); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + materialsForPrecisionMold, Arrays.asList(new ItemStack[] { InjectionMoldBlock.instance + .getGypsumInjectionMoldForResult("rollingMachineSetOfMoldedParts") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + materialsForPrecisionMold, Arrays.asList(new ItemStack[] { + InjectionMoldBlock.instance.getGypsumInjectionMoldForResult("polishingPucks") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + materialsForPrecisionMold, Arrays.asList(new ItemStack[] { InjectionMoldBlock.instance + .getGypsumInjectionMoldForResult("turboCompressorSetOfMoldedParts") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + materialsForPrecisionMold, Arrays.asList(new ItemStack[] { InjectionMoldBlock.instance + .getGypsumInjectionMoldForResult("extruderSetOfMoldedParts") }))); + // Precision molds recipe section end + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hammer"), + IHLUtils.getThisModItemStack("chisel"), IHLUtils.getThisModItemStack("needleFile") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("barD10SteelHot") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("sawBladeSteel", 2) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList( + new ItemStack[] { IHLUtils.getThisModItemStack("hammer"), + IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze"), + IHLUtils.getThisModItemStack("needleFile") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("barD10Steel"), + IHLUtils.getThisModItemStack("sawBladeSteelHardened"), new ItemStack(Items.stick) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hackSawSteel") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("needleFile"), + IHLUtils.getThisModItemStack("hackSawSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("plateSteel") }), Arrays.asList( + new ItemStack[] { IHLUtils.getThisModItemStackWithSize("blankSetOfFilesSteel", 4) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("viseSetOfMoldedPartsSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("viseSteel") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { + IHLUtils.getThisModItemStack("viseSteel"), IHLUtils.getThisModItemStack("setOfFilesSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("tapM10x1SteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("stickSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("diceM10x1Steel", 16) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("viseSteel"), + IHLUtils.getThisModItemStack("setOfFilesSteel"), IHLUtils.getThisModItemStack("needleFile"), + IHLUtils.getThisModItemStack("hackSawSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("barD10Steel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("tapM10x1Steel", 2) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new IRecipeInput[] {new RecipeInputOreDict("craftingToolSaw") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tubBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("solarEvaporator") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { + IHLUtils.getThisModItemStack("handDrillBronze"), IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), + IHLUtils.getThisModItemStack("tapM10x1SteelHardened"), IHLUtils.getThisModItemStack("viseSteel"), + IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 16), + IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 12), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 16), + IHLUtils.getOreDictItemStackWithSize("plateSteel", 4), + IHLUtils.getOreDictItemStack("stickSteel"), new ItemStack(Items.leather), + new ItemStack(Items.string) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("lathePart1"), + IHLUtils.getThisModItemStack("lathePart2") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { + IHLUtils.getThisModItemStack("handDrillBronze"), IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("tapM10x1SteelHardened"), IHLUtils.getThisModItemStack("viseSteel"), + IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 16), + IHLUtils.getOreDictItemStack("plateSteel"), + IHLUtils.getThisModItemStack("extruderSetOfMoldedPartsSteel"), + IHLUtils.getThisModItemStack("meshGlass"), IHLUtils.getThisModItemStack("dustCarborundum"), + new ItemStack(Items.leather), new ItemStack(Items.string) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("extruder"), + IHLUtils.getThisModItemStack("vulcanizationExtrudingMold") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList( + new ItemStack[] { IHLUtils.getThisModItemStack("chisel"), IHLUtils.getThisModItemStack("hammer") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("barD10SteelHot") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("nailSteel", 8) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { + IHLUtils.getThisModItemStack("hammer"), IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened"), IHLUtils.getThisModItemStack("hackSawSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("barD10Steel"), + IHLUtils.getThisModItemStackWithSize("nailSteel", 16), new ItemStack(Blocks.planks), + new ItemStack(Items.leather), new ItemStack(Items.string), + IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 8), + IHLUtils.getOreDictItemStack("plateSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("coiler") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("viseSteel"), + IHLUtils.getThisModItemStack("setOfFilesSteel"), IHLUtils.getThisModItemStack("hammer"), + IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), + IHLUtils.getThisModItemStack("hackSawSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("barD10Steel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 8) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("viseSteel"), + IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("handDrillSetOfMoldedPartsBronze"), + new ItemStack(Items.stick) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("handDrillBronze") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new RecipeInputOreDict[] { new RecipeInputOreDict("craftingToolFile") }), + Arrays.asList(new IRecipeInput[] { + new RecipeInputItemStack(IHLUtils.getThisModItemStack("boltM10x1Steel"), 16), + new RecipeInputOreDict("dustCarborundum"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("crucibleMixture")), + new RecipeInputOreDict("stickGraphite"), new RecipeInputOreDict("plateSteel"), + new RecipeInputOreDict("stickSteel", 4), + new RecipeInputItemStack( + IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 16)) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("wireMill") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("lathePart1") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("setOfPartsForLVElemotorSteel"), + IHLUtils.getThisModItemStack("ingotStearin"), IHLUtils.getUninsulatedWire("Copper", 4, 15), + new ItemStack(Items.paper), new ItemStack(Blocks.planks), + IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 2) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("electricMotorLVLEDC") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new IRecipeInput[] { + new RecipeInputItemStack(IHLUtils.getThisModItemStack("setOfPartsForLVElemotorSteel")), + new RecipeInputFluidContainer(FluidRegistry.getFluid("spruceresin"), 1), + new RecipeInputWire("Copper", 4, 15), new RecipeInputItemStack(new ItemStack(Items.paper)), + new RecipeInputItemStack(new ItemStack(Blocks.planks, 1, OreDictionary.WILDCARD_VALUE)), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("linerIronGraphiteGreased"), 2) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("electricMotorLVLEDC") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("linerIronGraphiteHot"), + IHLUtils.getThisModItemStack("muttonLard") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("linerIronGraphiteGreased") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList( + new IRecipeInput[] { new RecipeInputOreDict("dustBrick", 7), + new RecipeInputOreDict("dustClay", 3), new RecipeInputOreDict("dustGraphite", 2), + new RecipeInputFluidContainer(FluidRegistry.WATER, 1) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("crucibleMixture", 12) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("crucibleMixture") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("crucible") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { + IHLUtils.getThisModItemStack("viseSteel"), IHLUtils.getThisModItemStack("setOfFilesSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("tapM10x1SteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("stickSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 64) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { + IHLUtils.getThisModItemStack("hammer"), IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("hackSawSteel"), IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("diceM10x1SteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("barD10Steel", 4), + IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 8), new ItemStack(Items.leather), + new ItemStack(Items.stick, 8), IHLUtils.getThisModItemStackWithSize("nailSteel", 8) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("loom") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hammer") }), + Arrays.asList(new ItemStack[] { + IHLUtils.getThisModItemStack("detonationSprayingMachineSetOfMoldedPartsBronze"), + new ItemStack(Blocks.planks), IHLUtils.getThisModItemStackWithSize("nailSteel", 8) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("cannonBronze") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { + IHLUtils.getThisModItemStack("hammer"), lathingTool, + IHLUtils.getThisModItemStack("setOfFilesSteel"), IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), + IHLUtils.getThisModItemStack("tapM10x1SteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("ingotHotSteel"), + IHLUtils.getThisModItemStack("foilRubber"), IHLUtils.getThisModItemStack("springSteel"), + IHLUtils.getThisModItemStack("barD10Steel"), + IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 6), + IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 6) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasReducerSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("lathePart1") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hammer"), lathingTool }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("ingotHotSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("pistonCylinderSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("lathePart1") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 240), + new ItemStack(Items.stick) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("springSteel", 4) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("setOfFilesSteel"), + IHLUtils.getThisModItemStack("hammer"), IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("barD10SteelHot", 2), + IHLUtils.getThisModItemStack("springSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList(new ItemStack[] { + IHLUtils.getThisModItemStack("hammer"), IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("diceM10x1SteelHardened"), + IHLUtils.getThisModItemStack("tapM10x1SteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("foilRubber"), + IHLUtils.getThisModItemStackWithSize("gasReducerSteel", 2), + IHLUtils.getThisModItemStack("gasJetSteel"), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 10), + IHLUtils.getThisModItemStackWithSize("highPressureVesselSteel", 2), + IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 32), + IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 32), + IHLUtils.getThisModItemStack("pipeVulcanizedRubber") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("setOfFilesSteel"), + IHLUtils.getThisModItemStack("tinSnipsSteel"), IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened"), lathingTool }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("pistonCylinderSteel"), + IHLUtils.getOreDictItemStackWithSize("plateSteel", 2), + IHLUtils.getThisModItemStack("pipelineAccessoriesSteel"), + IHLUtils.getThisModItemStack("foilRubber"), + IHLUtils.getThisModItemStackWithSize("stickSteel", 2), + IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 4), + IHLUtils.getThisModItemStackWithSize("highPressureVesselSteel", 2) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("cryogenicDistiller") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("lathePart1") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("setOfFilesSteel"), + IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("meshGlass"), + IHLUtils.getThisModItemStack("dustCarborundum"), + IHLUtils.getThisModItemStack("pipelineAccessoriesSteel"), + IHLUtils.getThisModItemStack("foilRubber"), + IHLUtils.getThisModItemStack("highPressureVesselSteel"), + IHLUtils.getOreDictItemStack("stickSteel"), IHLUtils.getOreDictItemStack("plateSteel"), + 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"), + IHLUtils.getThisModItemStack("diceM10x1SteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("barD10SteelHot", 7), + IHLUtils.getOreDictItemStack("plateSteel"), new ItemStack(Items.leather), + IHLUtils.getThisModItemStackWithSize("nailSteel", 8), new ItemStack(Blocks.log) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("woodenRollingMachinePart1"), + IHLUtils.getThisModItemStack("woodenRollingMachinePart2") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("plateSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("fiberGlassDieSteel") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("plateSteel") }), + Arrays.asList(new ItemStack[] { + IHLUtils.getItemStackWithTag("setOfDies1_5sqmm", "transverseSection", 240) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("plateSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("setOfDies1_5sqmm") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("tapM10x1SteelHardened"), + IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 8), + IHLUtils.getOreDictItemStackWithSize("plateSteel", 4), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4), + IHLUtils.getThisModItemStack("rollingMachineSetOfMoldedPartsSteel"), + IHLUtils.getThisModItemStackWithSize("linerIronGraphiteGreased", 4) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("rollingMachinePart1") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("tapM10x1SteelHardened"), + IHLUtils.getThisModItemStack("setOfFilesSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 8), + IHLUtils.getOreDictItemStackWithSize("plateSteel", 4), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("rollingMachinePart2") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputFluidContainer(FluidRegistry.WATER, 1), + new RecipeInputOreDict("dustPorcelain") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("electrolysisBathRawPorcelain") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputFluidContainer(FluidRegistry.WATER, 1), + new RecipeInputOreDict("dustPorcelain") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("ovenRawPorcelain") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputFluidContainer(FluidRegistry.WATER, 1), + new RecipeInputOreDict("dustPorcelain") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gaedesPumpBarrelRawPorcelain") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputFluidContainer(FluidRegistry.WATER, 1), + new RecipeInputOreDict("dustPorcelain") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("ringRawPorcelain", 4) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputFluidContainer(FluidRegistry.WATER, 1), + new RecipeInputOreDict("dustPorcelain") }), + Arrays.asList( + new ItemStack[] { IHLUtils.getThisModItemStackWithSize("lampHolderRawPorcelain", 4) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputFluidContainer(FluidRegistry.WATER, 1), + new RecipeInputOreDict("dustPorcelain") }), + Arrays.asList( + new ItemStack[] { IHLUtils.getThisModItemStackWithSize("insulatorRawPorcelain", 4) }))); + // Raw porcelain recipes section end + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("setOfFilesSteel"), + IHLUtils.getThisModItemStack("tinSnipsSteel"), IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("foilSteel", 4), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4), + IHLUtils.getThisModItemStack("pipelineAccessoriesSteel"), + IHLUtils.getThisModItemStack("foilRubber"), IHLUtils.getOreDictItemStack("plateSteel"), + IHLUtils.getThisModItemStack("turboCompressorSetOfMoldedPartsBronze"), + IHLUtils.getThisModItemStack("highPressureVesselSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("fluidizedBedReactor") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("setOfFilesSteel"), + IHLUtils.getThisModItemStack("tinSnipsSteel"), IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new IRecipeInput[] { + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("pistonCylinderSteel", 2)), + new RecipeInputOreDict("foilSteel"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("pipelineAccessoriesSteel")), + new RecipeInputOreDict("foilRubber"), new RecipeInputOreDict("plateSteel"), + new RecipeInputItemStack( + IHLUtils.getThisModItemStackWithSize("highPressureVesselSteel", 2)), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("electrolysisBathPorcelain")), + new RecipeInputOreDict("stickGraphite", 2) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("labElectrolyzer") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("glassBlowingTubeSteel") }), + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("foilSteel"), + new RecipeInputOreDict("foilTungsten"), new RecipeInputOreDict("dustQuicklime"), + new RecipeInputOreDict("dustGlass"), new RecipeInputOreDict("stickGraphite"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("barD10Steel")) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("gu-81m", 4) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation"), + IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("foilSteel"), + IHLUtils.getThisModItemStack("barD10Steel"), new ItemStack(Items.stick) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("glassBlowingTubeSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("foilSteel"), + new RecipeInputOreDict("plateSteel"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("barD10Steel"), 4), + new RecipeInputOreDict("foilRubber"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("gaedesPumpBarrelPorcelain")), + new RecipeInputFluidContainer(FluidRegistry.getFluid("mercury"), 1) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new IRecipeInput[] { + new RecipeInputFluidContainer(FluidRegistry.getFluid("mineraloil"), 1), + new RecipeInputOreDict("foilMica"), new RecipeInputOreDict("foilCopper"), + new RecipeInputOreDict("foilSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("highVoltageCapacitor") }))); + IronWorkbenchTileEntity + .addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new IRecipeInput[] { + new RecipeInputFluidContainer(FluidRegistry.getFluid("mineraloil"), 1), + new RecipeInputOreDict("foilMica"), new RecipeInputOreDict("foilGold"), + new RecipeInputOreDict("foilSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("highVoltageCapacitor") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("ringPorcelain", 64), + IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 6), + IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 6), + IHLUtils.getOreDictItemStack("foilSteel"), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("fractionatorSection") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("stickSteel", 4), + IHLUtils.getOreDictItemStackWithSize("plateSteel", 2), + IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 6), + IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 6), + IHLUtils.getOreDictItemStack("foilSteel"), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("fractionatorBottom") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 6), + IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 6), + IHLUtils.getOreDictItemStack("foilSteel"), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("fractionatorCover") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("handDrillBronze"), + IHLUtils.getThisModItemStack("drillSteelHardened") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("boltM10x1Steel", 6), + IHLUtils.getThisModItemStackWithSize("nutM10x1Steel", 6), + IHLUtils.getOreDictItemStack("foilSteel"), + IHLUtils.getThisModItemStackWithSize("barD10Steel", 4) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("refluxCondenser") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("dustFerrite"), + IHLUtils.getThisModItemStack("ingotStearin") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("ringRawFerrite", 4) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("glassBlowingTubeSteel") }), + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("foilSteel"), + new RecipeInputFluidContainer(FluidRegistry.getFluid("mercury"), 1), + new RecipeInputOreDict("stickBoronCarbide"), new RecipeInputOreDict("dustGlass"), + new RecipeInputOreDict("stickGraphite"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("barD10Steel")) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("ignitron", 6) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation"), + IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("glassBlowingTubeSteel") }), + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("foilSteel"), + new RecipeInputOreDict("foilTungsten"), new RecipeInputOreDict("dustQuicklime"), + new RecipeInputOreDict("dustGlass"), new RecipeInputOreDict("stickGraphite"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("barD10Steel")) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("valveTube1C21P", 6) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation"), + IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel"), + IHLUtils.getThisModItemStack("glassBlowingTubeSteel") }), + Arrays.asList( + new IRecipeInput[] { new RecipeInputOreDict("foilGold"), new RecipeInputOreDict("foilMica"), + new RecipeInputFluidContainer(FluidRegistry.getFluid("cablingcolophony"), 1), + new RecipeInputOreDict("dustGlass"), new RecipeInputOreDict("foilSteel"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("springSteel")) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("vacuumSwitch", 16) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation"), + IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new IRecipeInput[] { + new RecipeInputItemStack(IHLUtils.getThisModItemStack("insulatorPorcelain"), 8), + new RecipeInputOreDict("plateMica", 2), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("highVoltageCapacitor"), 3), + new RecipeInputFluidContainer(FluidRegistry.getFluid("cablingcolophony"), 1), + new RecipeInputOreDict("dustSolderingAlloy"), new RecipeInputOreDict("foilMica"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("gu-81m"), 4), + new RecipeInputOreDict("foilSteel", 8), + new RecipeInputWire(IHLUtils.getUninsulatedWire("Copper", 288, 15)), + new RecipeInputFluidContainer(FluidRegistry.getFluid("mineraloil"), 1000), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("ignitron"), 6), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("valveTube1C21P"), 6) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("rectifierTransformerUnit") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("foilCopper"), + new RecipeInputFluidContainer(FluidRegistry.getFluid("cablingcolophony"), 1), + new RecipeInputOreDict("dustSolderingAlloy"), new RecipeInputOreDict("ringFerrite", 8), + new RecipeInputOreDict("foilMica") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("hallSensor", 8) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("insulatorPorcelain", 4), + IHLUtils.getUninsulatedWire("Copper", 4, 15), IHLUtils.getThisModItemStack("foilMica"), + IHLUtils.getThisModItemStack("leadAcidBattery"), + IHLUtils.getThisModItemStack("dustSolderingAlloy"), + IHLUtils.getThisModItemStack("vacuumSwitch"), + IHLUtils.getThisModItemStackWithSize("hallSensor", 2), + IHLUtils.getThisModItemStackWithSize("valveTube1C21P", 2) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("batterySwitchUnit") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("foilGold"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("foilRubberWithSulfur")), + new RecipeInputOreDict("foilLead"), + new RecipeInputFluidContainer(FluidRegistry.getFluid("sulfuricacid"), 1), + new RecipeInputFluidContainer(FluidRegistry.getFluid("ic2distilledwater"), 1), + new RecipeInputOreDict("dustSolderingAlloy"), new RecipeInputOreDict("dustLeadPlumbate"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("batteryCellsEbonite"), 8) }), + Arrays.asList( + new ItemStack[] { BatteryItem.getFullyChargedItemStackWithSize("leadAcidBattery", 8) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("tinSnipsSteel") }), + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("foilSteel"), + new RecipeInputOreDict("plateGraphite", 5), + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("barD10Steel", 4)), + new RecipeInputOreDict("stickGraphite"), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("dustCoalElectrodePremix")), + new RecipeInputOreDict("foilRubber") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("electrolysisBath") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("dustTin"), + new RecipeInputItemStack(new ItemStack(Blocks.glass_pane), 16), + new RecipeInputFluidContainer(FluidRegistry.getFluid("mercury"), 1), + new RecipeInputFluidContainer(FluidRegistry.getFluid("turpentine"), 1), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("fabric")) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("mirror", 16) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("dustTin"), + new RecipeInputItemStack(new ItemStack(Blocks.glass_pane), 16), + new RecipeInputFluidContainer(FluidRegistry.getFluid("mercury"), 1), + new RecipeInputFluidContainer(FluidRegistry.getFluid("turpentine"), 1), + new RecipeInputItemStack(new ItemStack(Blocks.wool)) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("mirror", 16), }))); + if (FluidRegistry.isFluidRegistered("ethanol")) { + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("dustTin"), + new RecipeInputItemStack(new ItemStack(Blocks.glass_pane), 16), + new RecipeInputFluidContainer(FluidRegistry.getFluid("mercury"), 1), + new RecipeInputFluidContainer(FluidRegistry.getFluid("ethanol"), 1), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("fabric")) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("mirror", 16) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("dustTin"), + new RecipeInputItemStack(new ItemStack(Blocks.glass_pane), 16), + new RecipeInputFluidContainer(FluidRegistry.getFluid("mercury"), 1), + new RecipeInputFluidContainer(FluidRegistry.getFluid("ethanol"), 1), + new RecipeInputItemStack(new ItemStack(Blocks.wool)) }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("mirror", 16) }))); + } + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(Arrays.asList( + new IRecipeInput[] { RecipeInputs.cutter, RecipeInputs.saw, RecipeInputs.vise, RecipeInputs.file }), + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("plateSteel", 2), + new RecipeInputOreDict("foilSteel", 2), RecipeInputs.get("boltM10x1Steel", 8), + RecipeInputs.get("nutM10x1Steel", 8), RecipeInputs.get("barD10Steel", 16), + RecipeInputs.get("rollingMachineSetOfMoldedPartsSteel"), + RecipeInputs.get("linerIronGraphiteGreased", 4), + RecipeInputs.get("turboCompressorSetOfMoldedPartsBronze"), + RecipeInputs.get("foilRubber") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("paperMachine") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("gasWeldingStation") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("dustIronOxide", 8), + new RecipeInputOreDict("dustBauxite"), new RecipeInputOreDict("dustPotassiumOxide"), }), + Arrays.asList( + new ItemStack[] { IHLUtils.getThisModItemStackWithSize("catalystRawIronOxide", 10) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("hackSawSteel"), + IHLUtils.getThisModItemStack("viseSteel"), IHLUtils.getThisModItemStack("setOfFilesSteel"), + IHLUtils.getThisModItemStack("drillSteelHardened"), + IHLUtils.getThisModItemStack("handDrillBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getOreDictItemStack("plateSteel") }), + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStackWithSize("incisorSteel", 4) }))); + if (IHLMod.isGregTechModLoaded && IHLMod.isGT_API_Version_5) { + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 15), + IHLUtils.getOreDictItemStack("dustRawRubber") }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 15, "RawRubber", 100) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 240), + IHLUtils.getOreDictItemStack("dustRawRubber") }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 240, "RawRubber", 100) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 15), + IHLUtils.getOreDictItemStack("dustRawRubber") }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 15, "RawRubber", 100) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 240), + IHLUtils.getOreDictItemStack("dustRawRubber") }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 240, "RawRubber", 100) }))); + + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 15, "RawRubber", 100) }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 15), + IHLUtils.getOreDictItemStack("dustRawRubber") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 240, "RawRubber", 100) }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 240), + IHLUtils.getOreDictItemStack("dustRawRubber") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 15, "RawRubber", 100) }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 15), + IHLUtils.getOreDictItemStack("dustRawRubber") }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 240, "RawRubber", 100) }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 240), + IHLUtils.getOreDictItemStack("dustRawRubber") }))); + } else { + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList( + new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 15), Ic2Items.rubber }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 15, "RawRubber", 100) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList( + new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 240), Ic2Items.rubber }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 240, "RawRubber", 100) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 15), Ic2Items.rubber }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 15, "RawRubber", 100) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList( + new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 240), Ic2Items.rubber }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 240, "RawRubber", 100) }))); + + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 15, "RawRubber", 100) }), + Arrays.asList( + new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 15), Ic2Items.rubber }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList( + new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 240, "RawRubber", 100) }), + Arrays.asList( + new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 240), Ic2Items.rubber }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 15, "RawRubber", 100) }), + Arrays.asList( + new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 15), Ic2Items.rubber }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 240, "RawRubber", 100) }), + Arrays.asList( + new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 240), Ic2Items.rubber }))); + } + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 15, "Rubber", 100) }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 15) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Copper", 1, 240, "Rubber", 100) }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Copper", 1, 240) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 15, "Rubber", 100) }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 15) }))); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe( + Arrays.asList(new ItemStack[] { IHLUtils.getThisModItemStack("sharpenedCarvingKnifeBronze") }), + Arrays.asList(new ItemStack[] { IHLUtils.getInsulatedWire("Steel", 1, 240, "Rubber", 100) }), + Arrays.asList(new ItemStack[] { IHLUtils.getUninsulatedWire("Steel", 1, 240) }))); + ItemStack detonator = IHLUtils.getItemStackWithTag("detonator", "detonator_delay", 5); + detonator.stackSize = 16; + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("platePaper", 2), + new RecipeInputItemStack(new ItemStack(Items.string)), + new RecipeInputOreDict("dustGunpowder", 1), + new RecipeInputOreDictionaryList( + new String[] { "dustPentaerythritolTetranitrate", "dustMercuryFulminate" }, 1), + new RecipeInputOreDict("ingotTarPitch", 1) }), + Arrays.asList(new ItemStack[] { detonator }), null)); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("platePaper", 2), + new RecipeInputOreDict("dustPentaerythritolTetranitrate", 4), + new RecipeInputOreDict("ingotTarPitch", 1), new RecipeInputDetonator(detonator) }), + Arrays.asList(new ItemStack[] { IHLUtils.getItemStackWithTag("ihlExplosive", "explosionPower", + 15 * config.explosionPowerBase) }), + null)); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("platePaper", 2), + new RecipeInputOreDict("dustWood", 4), + new RecipeInputFluidContainer(FluidRegistry.getFluid("nitroglycerin"), 1), + new RecipeInputOreDict("ingotTarPitch", 1), new RecipeInputDetonator(detonator) }), + Arrays.asList(new ItemStack[] { IHLUtils.getItemStackWithTag("ihlExplosive", "explosionPower", + 10 * config.explosionPowerBase) }), + null)); + IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(null, + Arrays.asList(new IRecipeInput[] { new RecipeInputOreDict("platePaper", 2), + new RecipeInputOreDict("dustGunpowder", 8), new RecipeInputOreDict("ingotTarPitch", 1), + new RecipeInputDetonator(detonator) }), + Arrays.asList(new ItemStack[] { IHLUtils.getItemStackWithTag("ihlExplosive", "explosionPower", + 3 * config.explosionPowerBase) }), + null)); + + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustSiliconDioxide", 2), + new RecipeInputOreDict("dustCoal", 4), "dustCarborundum"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustQuicklime"), + new RecipeInputOreDict("dustCoal", 4), "dustCalciumCarbide"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("stickCoal"), new RecipeInputOreDict("dustCoal"), + "stickGraphite"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustTungsten"), + new RecipeInputOreDict("dustCoal"), "ingotTungsten"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustBoricAcid", 4), + new RecipeInputOreDict("dustCoal", 8), "dustBoronCarbide"); + AchesonFurnanceTileEntity.addRecipe(new RecipeInputOreDict("plateCoal"), + new RecipeInputOreDict("dustCoal", 1), "plateGraphite"); + LeadOvenTileEntity.addRecipe( + new UniversalRecipeInput(new FluidStack[] { IHLUtils.getFluidStackWithSize("water", 400) }, + new IRecipeInput[] { new RecipeInputOreDict("dustSulfur"), + new RecipeInputOreDict("dustSaltpeter") }), + IHLUtils.getFluidStackWithSize("sulfuricacid", 100)); + LeadOvenTileEntity.addRecipe( + new UniversalRecipeInput(new FluidStack[] { IHLUtils.getFluidStackWithSize("water", 100) }, + new IRecipeInput[] { new RecipeInputOreDict("crushedPurifiedCinnabar") }), + IHLUtils.getFluidStackWithSize("mercury", 36)); + LeadOvenTileEntity.addRecipe(new RecipeInputOreDict("dustStibnite", 1), + IHLUtils.getThisModItemStack("dustAntimonyOxide")); + LeadOvenTileEntity.addRecipe(new RecipeInputOreDict("dustSodiumHydrogenSulfate", 2), + IHLUtils.getFluidStackWithSize("sulfuricacid", 20), + IHLUtils.getOreDictItemStack("dustSodiumSulfate")); + LeadOvenTileEntity.addRecipe(new RecipeInputOreDict("dustSodiumZeoliteCoked", 2), + IHLUtils.getThisModItemStack("dustSodiumZeolite")); + ImpregnatingMachineTileEntity.addChemicalRecipe( + new UniversalRecipeInput((new FluidStack[] { new FluidStack(FluidRegistry.WATER, 1500) }), + (new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("dustQuicklime", 1) })), + new UniversalRecipeOutput((new FluidStack[] { IHLUtils.getFluidStackWithSize("limemilk", 2500) }), + null, 20)); + ImpregnatingMachineTileEntity.addChemicalRecipe( + new UniversalRecipeInput( + (new FluidStack[] { new FluidStack(FluidRegistry.WATER, 130), + IHLUtils.getFluidStackWithSize("limemilk", 142) }), + (new ItemStack[] { IHLUtils.getThisModItemStackWithSize("muttonLard", 6) })), + new UniversalRecipeOutput((new FluidStack[] { IHLUtils.getFluidStackWithSize("glycerol", 130) }), + (new ItemStack[] { IHLUtils.getThisModItemStackWithSize("ingotCalciumSoap", 5) }), 200)); + ImpregnatingMachineTileEntity.addChemicalRecipe( + new UniversalRecipeInput( + (new FluidStack[] { new FluidStack(FluidRegistry.WATER, 600), + IHLUtils.getFluidStackWithSize("sulfuricacid", 284) }), + (new ItemStack[] { IHLUtils.getThisModItemStackWithSize("ingotCalciumSoap", 6) })), + new UniversalRecipeOutput((new FluidStack[] { IHLUtils.getFluidStackWithSize("oleicacid", 280) }), + (new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getThisModItemStackWithSize("ingotStearin", 4)), + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustGypsum"), 0.48f) }), + 200)); + ImpregnatingMachineTileEntity.addChemicalRecipe( + new UniversalRecipeInput((new FluidStack[] { IHLUtils.getFluidStackWithSize("limemilk", 1000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustTrona") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 1000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustCalcite") }), 200)); + DetonationSprayingMachineTileEntity.addRecipe(IHLUtils.getThisModItemStack("blankNeedleFileSteel"), + IHLUtils.getThisModItemStack("needleFile")); + DetonationSprayingMachineTileEntity.addRecipe(IHLUtils.getThisModItemStack("blankSetOfFilesSteel"), + IHLUtils.getThisModItemStack("setOfFilesSteel")); + DetonationSprayingMachineTileEntity.addRecipe(IHLUtils.getThisModItemStack("incisorSteel"), + IHLUtils.getThisModItemStack("incisorSteelDiamondCoated")); + ItemStack drill = Ic2Items.miningDrill.copy(); + drill.setItemDamage(OreDictionary.WILDCARD_VALUE); + DetonationSprayingMachineTileEntity.addRecipe(drill, Ic2Items.diamondDrill.copy()); + MuffleFurnanceTileEntity.addRecipe(new RecipeInputOreDict("plateSteel", 1), + IHLUtils.getThisModItemStack("plateHotSteel")); + MuffleFurnanceTileEntity.addRecipe(new RecipeInputOreDict("ingotSteel", 1), + IHLUtils.getOreDictItemStack("ingotHotSteel")); + MuffleFurnanceTileEntity.addRecipe(new RecipeInputOreDict("plateTungsten", 1), + IHLUtils.getThisModItemStack("plateHotTungsten")); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("gaedesPumpBarrelRawPorcelain"), 1), + IHLUtils.getThisModItemStack("gaedesPumpBarrelPorcelain")); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(new ItemStack(IHLMod.crucible, 1, OreDictionary.WILDCARD_VALUE), 1), + new ItemStack(IHLMod.crucible, 1, 1)); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("injectionMold", 1), 1), + IHLUtils.getThisModItemStackWithSize("injectionMold", 1)); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("sawBladeSteel"), 1), + IHLUtils.getThisModItemStack("sawBladeSteelHot")); + MuffleFurnanceTileEntity.addRecipe(new RecipeInputItemStack(IHLUtils.getThisModItemStack("barD10Steel"), 1), + IHLUtils.getThisModItemStack("barD10SteelHot")); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("linerIronGraphite"), 1), + IHLUtils.getThisModItemStack("linerIronGraphiteHot")); + MuffleFurnanceTileEntity.addRecipe( + new UniversalRecipeInput(null, + new IRecipeInput[] { new RecipeInputOreDict("dustIronOxide", 1), + new RecipeInputOreDict("dustLithiumOxide", 1) }), + new UniversalRecipeOutput(null, + new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStackWithSize("dustFerrite", 2)) }, + 200)); + MuffleFurnanceTileEntity.addRecipe( + new UniversalRecipeInput(null, + new IRecipeInput[] { new RecipeInputOreDict("dustBauxite"), + new RecipeInputOreDict("dustSodiumHydroxide") }), + new UniversalRecipeOutput(null, + new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustSodiumAluminate")) }, + 200)); + MuffleFurnanceTileEntity.addRecipe(new RecipeInputItemStack(IHLUtils.getThisModItemStack("drillSteel")), + IHLUtils.getThisModItemStack("drillSteelHot")); + MuffleFurnanceTileEntity.addRecipe(new RecipeInputItemStack(IHLUtils.getThisModItemStack("tapM10x1Steel")), + IHLUtils.getThisModItemStack("tapM10x1SteelHot")); + MuffleFurnanceTileEntity.addRecipe(new RecipeInputItemStack(IHLUtils.getThisModItemStack("diceM10x1Steel")), + IHLUtils.getThisModItemStack("diceM10x1SteelHot")); + LoomTileEntity.addRecipe(IHLUtils.getThisModWireItemStackWithLength("fiberGlass", 1024), + IHLUtils.getThisModItemStack("meshGlass")); + LoomTileEntity.addRecipe(new ItemStack(Items.string, 4), IHLUtils.getThisModItemStack("fabric")); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getThisModItemStack("plateHotSteel"), + IHLUtils.getOreDictItemStackWithSize("foilSteel", 4)); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getThisModItemStack("plateHotTungsten"), + IHLUtils.getOreDictItemStackWithSize("foilTungsten", 4)); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getOreDictItemStack("plateGold"), + IHLUtils.getOreDictItemStackWithSize("foilGold", 4)); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getOreDictItemStack("plateCopper"), + IHLUtils.getOreDictItemStackWithSize("foilCopper", 4)); + RollingMachinePart1TileEntity.addRecipe(IHLUtils.getOreDictItemStack("plateLead"), + IHLUtils.getOreDictItemStackWithSize("foilLead", 4)); + ImpregnatingMachineTileEntity.addQuenchingRecipe("diceM10x1SteelHot", "diceM10x1SteelHardened"); + ImpregnatingMachineTileEntity.addQuenchingRecipe("tapM10x1SteelHot", "tapM10x1SteelHardened"); + ImpregnatingMachineTileEntity.addQuenchingRecipe("drillSteelHot", "drillSteelHardened"); + ImpregnatingMachineTileEntity.addQuenchingRecipe("sawBladeSteelHot", "sawBladeSteelHardened"); + ImpregnatingMachineTileEntity.addRecipe( + new UniversalRecipeInput((new FluidStack[] { IHLUtils.getFluidStackWithSize("oleicacid", 1) }), + (new ItemStack[] { IHLUtils.getThisModItemStack("linerIronGraphiteHot") })), + new UniversalRecipeOutput(null, + (new ItemStack[] { IHLUtils.getThisModItemStack("linerIronGraphiteGreased") }), 2)); + ImpregnatingMachineTileEntity.addRecipe( + new UniversalRecipeInput((new FluidStack[] { IHLUtils.getFluidStackWithSize("seedoil", 1) }), + (new ItemStack[] { IHLUtils.getThisModItemStack("linerIronGraphiteHot") })), + new UniversalRecipeOutput(null, + (new ItemStack[] { IHLUtils.getThisModItemStack("linerIronGraphiteGreased") }), 2)); + ImpregnatingMachineTileEntity.addRecipe( + new UniversalRecipeInput((new FluidStack[] { IHLUtils.getFluidStackWithSize("mineraloil", 1) }), + (new ItemStack[] { IHLUtils.getThisModItemStack("linerIronGraphiteHot") })), + new UniversalRecipeOutput(null, + (new ItemStack[] { IHLUtils.getThisModItemStack("linerIronGraphiteGreased") }), 2)); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("foilRubberWithSulfur")), + IHLUtils.getThisModItemStack("foilRubber")); + MuffleFurnanceTileEntity + .addRecipe( + new UniversalRecipeInput(null, + (new IRecipeInput[] { new RecipeInputItemStack( + IHLUtils.getThisModItemStack("pipeRubberWithSulfur")) })), + new UniversalRecipeOutput(null, + (new ItemStack[] { IHLUtils.getThisModItemStack("pipeVulcanizedRubber") }), 20)); + GasWeldingStationTileEntity.addGasRecipe(IHLUtils.getOreDictItemStack("dustCalciumCarbide"), + IHLUtils.getFluidStackWithSize("water", 666), IHLUtils.getFluidStackWithSize("acetylene", 1333), + IHLUtils.getFluidStackWithSize("limemilk", 333)); + ChemicalReactorTileEntity + .addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { + IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 500) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustSiliconDioxide") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("liquidglass", 500) }), null, + 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput((new FluidStack[] { IHLUtils.getFluidStackWithSize("spruceresin", 1000), + IHLUtils.getFluidStackWithSize("glycerol", 50) }), null), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("cablingcolophony", 600) }), null, 200, + true)); + CryogenicDistillerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("spruceresin", 1000), + IHLUtils.getFluidStackWithSize("ic2distilledwater", 150), + IHLUtils.getFluidStackWithSize("turpentine", 300), true); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput((new FluidStack[] { IHLUtils.getFluidStackWithSize("fueloil", 2000) }), + null), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("molten.tarpitch", 144) }), null, 200, + true)); + CryogenicDistillerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("fueloil", 2000), + IHLUtils.getFluidStackWithSize("mineraloil", 1000), null, true); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 4000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("crushedPurifiedGyubnera") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("solution.natriumtungstate", 4000) }), + (new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyManganeseOxide"), + 3.75f), + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyIronOxide"), + 9f / 12f) }), + 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("sulfuricacid", 1750) }), + (new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("dustRockSalt", 1) })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("hydrogenchloride", 1000) }), + (new RecipeOutputItemStack[] { new RecipeOutputItemStack( + IHLUtils.getOreDictItemStack("dustPotassiumSulphate"), 1.75f) }), + 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("sulfuricacid", 3500) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustSalt") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("hydrogenchloride", 1000) }), + (new RecipeOutputItemStack[] { new RecipeOutputItemStack( + IHLUtils.getOreDictItemStack("dustSodiumHydrogenSulfate"), 3.5f) }), + 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("sulfuricacid", 7000 / 9), + new FluidStack(FluidRegistry.WATER, 6000 / 9 + 1000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustDatolite") })), + new UniversalRecipeOutput((new FluidStack[] { IHLUtils.getFluidStackWithSize("boricacid", 1777) }), + (new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustGypsum"), 12f / 9f), + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinySiliconDioxide"), + 3f) }), + 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput((new FluidStack[] { IHLUtils.getFluidStackWithSize("limemilk", 1667), + IHLUtils.getFluidStackWithSize("hydrogenchloride", 1334) }), null), + new UniversalRecipeOutput(null, + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustCalciumChloride") }), 200)); + ChemicalReactorTileEntity + .addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { + IHLUtils.getFluidStackWithSize("solution.natriumtungstate", 6667) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustCalciumChloride") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("saltwater", 6000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustCalciumTungstate") }), 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 2000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustWood"), + IHLUtils.getOreDictItemStack("dustSodiumSulfide") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("pulp.cellulose", 1500), + IHLUtils.getFluidStackWithSize("ic2biomass", 500) }), + null, 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("cablingcolophony", 50), + new FluidStack(FluidRegistry.WATER, 2000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustMica") })), + new UniversalRecipeOutput((new FluidStack[] { IHLUtils.getFluidStackWithSize("pulp.mica", 2000) }), + null, 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("hydrogenchloride", 500), + new FluidStack(FluidRegistry.WATER, 7500) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustMagnesiumOxide") })), + new UniversalRecipeOutput(null, + (new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustBischofite"), 8.75f) }), + 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("liquidglass", 1000), + new FluidStack(FluidRegistry.WATER, 2000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustSodiumAluminate") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("pulp.sodiumzeolite", 4000) }), null, + 200)); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("saltwater", 4000), + IHLUtils.getOreDictItemStack("dustSalt")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("boricacid", 2288), + IHLUtils.getOreDictItemStack("dustBoricAcid")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 2000), + IHLUtils.getOreDictItemStack("dustSodiumHydroxide")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("pulp.sodiumzeolite", 4000), + IHLUtils.getOreDictItemStack("dustSodiumZeolite")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("solution.lithiumchloride", 4000), + IHLUtils.getOreDictItemStack("dustLithiumChloride")); + EvaporatorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("solution.calciumchloride", 4000), + IHLUtils.getOreDictItemStack("dustCalciumChloride")); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("water", 2000), + IHLUtils.getFluidStackWithSize("hydrogenchloride", 667) }), + (new IRecipeInput[] { new RecipeInputOreDict("dustCalciumTungstate") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("solution.calciumchloride", 2000) }), + (new RecipeOutputItemStack[] { new RecipeOutputItemStack( + IHLUtils.getOreDictItemStack("dustTungsticAcid"), 1.16f) }), + 200)); + if (IHLUtils.hasOreDictionaryEntry("dustTungstate")) + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("water", 1000), + IHLUtils.getFluidStackWithSize("hydrogenchloride", 140) }), + (new IRecipeInput[] { new RecipeInputOreDict("dustTungstate") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("solution.lithiumchloride", 560) }), + (new RecipeOutputItemStack[] { new RecipeOutputItemStack( + IHLUtils.getOreDictItemStack("dustTungsticAcid"), 1.0f) }), + 200)); + MuffleFurnanceTileEntity.addRecipe(new RecipeInputOreDict("dustTungsticAcid", 2), + IHLUtils.getOreDictItemStack("dustTungstenOxide"), 1.14f); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("electrolysisBathRawPorcelain")), + IHLUtils.getThisModItemStack("electrolysisBathPorcelain")); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("ovenRawPorcelain")), + IHLUtils.getThisModItemStack("leadOven")); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("ringRawPorcelain")), + IHLUtils.getThisModItemStack("ringPorcelain")); + MuffleFurnanceTileEntity.addRecipe(new RecipeInputItemStack(IHLUtils.getThisModItemStack("ringRawFerrite")), + IHLUtils.getThisModItemStack("ringFerrite")); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("insulatorRawPorcelain")), + IHLUtils.getThisModItemStack("insulatorPorcelain")); + MuffleFurnanceTileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStack("lampHolderRawPorcelain")), + IHLUtils.getThisModItemStack("lampHolderPorcelain")); + LabElectrolyzerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("water", 300), + IHLUtils.getFluidStackWithSize("hydrogen", 200), IHLUtils.getFluidStackWithSize("oxygen", 100), + null); + LabElectrolyzerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("saltwater", 1000), + IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 875), + IHLUtils.getFluidStackWithSize("chlorine", 100), null); + if (IHLUtils.hasOreDictionaryEntry("dustSilicon")) + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 1333), + IHLUtils.getOreDictItemStackWithSize("dustSiliconDioxide", 1), + IHLUtils.getFluidStackWithSize("water", 2000), + IHLUtils.getOreDictItemStackWithSize("dustTinySilicon", 3)); + if (IHLUtils.hasOreDictionaryEntry("dustManganese")) + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 2000), + IHLUtils.getOreDictItemStackWithSize("dustManganeseOxide", 2), + IHLUtils.getFluidStackWithSize("water", 3000), + IHLUtils.getOreDictItemStack("dustManganese")); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 1200), + IHLUtils.getOreDictItemStack("dustIronOxide"), + IHLUtils.getFluidStackWithSize("water", 1800), + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyIron"), 3.6f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 1500), + IHLUtils.getOreDictItemStack("dustTungstenOxide"), + IHLUtils.getFluidStackWithSize("water", 2250), + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyTungsten"), 2.25f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 4000), + IHLUtils.getOreDictItemStackWithSize("dustSodiumSulfate", 3), + IHLUtils.getFluidStackWithSize("water", 6000), + IHLUtils.getOreDictItemStack("dustSodiumSulfide")); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("hydrogen", 1200), + IHLUtils.getOreDictItemStack("dustAntimonyOxide"), + IHLUtils.getFluidStackWithSize("water", 1800), + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustTinyAntimony"), 3.6f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("oxygen", 1500), + IHLUtils.getOreDictItemStack("dustIron"), null, + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustIronOxide"), 2.5f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("oxygen", 500), + IHLUtils.getOreDictItemStack("dustLithium"), null, + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustLithiumOxide"), 1.5f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("oxygen", 1333), + IHLUtils.getOreDictItemStack("dustLead"), null, + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustLeadPlumbate"), 2.333f)); + FluidizedBedReactorTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("chlorine", 2000), + IHLUtils.getOreDictItemStack("dustCarborundum"), + IHLUtils.getFluidStackWithSize("silicontetrachloride", 2500), + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustCoal"), 0.5f)); + FluidizedBedReactorTileEntity.addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("hydrogen", 445), + IHLUtils.getFluidStackWithSize("silicontetrachloride", 1667) }), + (new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("dustIridium", 0), + IHLUtils.getOreDictItemStack("dustTinySilicon") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("trichlorosilane", 2112) }), null, 200)); + FluidizedBedReactorTileEntity.addRecipe( + new UniversalRecipeInput((new FluidStack[] { IHLUtils.getFluidStackWithSize("fueloil", 6000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustSodiumZeolite") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("fuel", 4500), + IHLUtils.getFluidStackWithSize("crackinggas", 500) }), + (new RecipeOutputItemStack[] { new RecipeOutputItemStack( + IHLUtils.getOreDictItemStack("dustSodiumZeoliteCoked"), 1.9f) }), + 2000)); + FluidizedBedReactorTileEntity.addRecipe(new UniversalRecipeInput( + null, (new IRecipeInput[] { new RecipeInputOreDict("dustWood") })), new UniversalRecipeOutput( + (new FluidStack[] { + IHLUtils.getFluidStackWithSize("molten.tarpitch", 8), IHLUtils + .getFluidStackWithSize("tarwater", 39), + IHLUtils.getFluidStackWithSize("crackinggas", 31) }), + (new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustCoal"), 0.25f) }), + 2000)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput((new FluidStack[] { IHLUtils.getFluidStackWithSize("tarwater", 50) }), + (new IRecipeInput[] { + new RecipeInputOreDict("dustQuicklime") })), + new UniversalRecipeOutput((new FluidStack[] { IHLUtils.getFluidStackWithSize("water", 10) }), + (new RecipeOutputItemStack[] { new RecipeOutputItemStack( + IHLUtils.getOreDictItemStack("dustCalciumAcetate"), 1f) }), + 200, true)); + CryogenicDistillerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("tarwater", 50), + IHLUtils.getFluidStackWithSize("ic2distilledwater", 30), + IHLUtils.getFluidStackWithSize("methanol", 10), true); + FluidizedBedReactorTileEntity.addRecipe( + new UniversalRecipeInput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("methanol", 200), + IHLUtils.getFluidStackWithSize("oxygen", 100) }, + new IRecipeInput[] { new RecipeInputOreDict("dustSilver", 0) }), + new UniversalRecipeOutput(new FluidStack[] { IHLUtils.getFluidStackWithSize("formaldehyde", 300) }, + null, 200)); + FluidizedBedReactorTileEntity.addRecipe( + new UniversalRecipeInput(new FluidStack[] { IHLUtils.getFluidStackWithSize("chlorine", 110), + IHLUtils.getFluidStackWithSize("mercury", 50) }, null), + new UniversalRecipeOutput(null, new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustMercuryChloride"), 1f) }, 200)); + FluidizedBedReactorTileEntity.addRecipe( + new UniversalRecipeInput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("acetylene", 100), + IHLUtils.getFluidStackWithSize("ic2distilledwater", 100), + IHLUtils.getFluidStackWithSize("hydrogenchloride", 2) }, + new IRecipeInput[] { new RecipeInputOreDict("dustMercuryChloride", 0) }), + new UniversalRecipeOutput(new FluidStack[] { IHLUtils.getFluidStackWithSize("acetaldehyde", 200) }, + null, 200)); + ChemicalReactorTileEntity + .addRecipe(new UniversalRecipeInput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("acetaldehyde", 100), + IHLUtils.getFluidStackWithSize("formaldehyde", + 400), + IHLUtils.getFluidStackWithSize("solution.natriumhydroxide", 100) }, + null), + new UniversalRecipeOutput(null, new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustSodiumFormate"), 1f), + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustPentaerythritol"), + 1f) }, + 200, false)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput(new FluidStack[] { IHLUtils.getFluidStackWithSize("sulfuricacid", 288) }, + new IRecipeInput[] { + new RecipeInputOreDict("dustSaltpeter") }), + new UniversalRecipeOutput(null, new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getOreDictItemStack("dustPotassiumSulphate"), 2f) }, 200, + true)); + CryogenicDistillerTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("sulfuricacid", 288), + IHLUtils.getFluidStackWithSize("nitricacid", 120), null, true); + FluidizedBedReactorTileEntity + .addRecipe( + new UniversalRecipeInput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("hydrogen", 90) }, + new IRecipeInput[] { new RecipeInputItemStack( + IHLUtils.getThisModItemStack("catalystIronOxide")) }), + new UniversalRecipeOutput(null, new RecipeOutputItemStack[] { + new RecipeOutputItemStack(IHLUtils.getThisModItemStack("catalystIron"), 1f) }, + 200)); + FluidizedBedReactorTileEntity.addRecipe( + new UniversalRecipeInput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("nitrogen", 100), + IHLUtils.getFluidStackWithSize("hydrogen", 300) }, + new IRecipeInput[] { new RecipeInputItemStack( + IHLUtils.getThisModItemStackWithSize("catalystIron", 0), 0) }), + new UniversalRecipeOutput(new FluidStack[] { IHLUtils.getFluidStackWithSize("ammonia", 400) }, null, + 200)); + FluidizedBedReactorTileEntity.addRecipe( + new UniversalRecipeInput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("ammonia", 100), + IHLUtils.getFluidStackWithSize("oxygen", 150) }, + new IRecipeInput[] { new RecipeInputOreDict("dustIridium", 0) }), + new UniversalRecipeOutput(new FluidStack[] { IHLUtils.getFluidStackWithSize("nitricacid", 250) }, + null, 200)); + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("nitricacid", 50), + IHLUtils.getFluidStackWithSize("sulfuricacid", 50) }, + new IRecipeInput[] { new RecipeInputOreDict("dustPentaerythritol"), + new RecipeInputItemStack(new ItemStack(Items.snowball, 8)) }), + new UniversalRecipeOutput(null, + new RecipeOutputItemStack[] { new RecipeOutputItemStack( + IHLUtils.getOreDictItemStack("dustPentaerythritolTetranitrate"), 1f) }, + 200, false)); + if (FluidRegistry.isFluidRegistered("bioethanol")) { + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput(new FluidStack[] { IHLUtils.getFluidStackWithSize("bioethanol", 450), + IHLUtils.getFluidStackWithSize("mercury", 144), + IHLUtils.getFluidStackWithSize("nitricacid", 300) }, null), + new UniversalRecipeOutput( + new FluidStack[] { IHLUtils.getFluidStackWithSize("acetaldehyde", 300) }, + new RecipeOutputItemStack[] { new RecipeOutputItemStack( + IHLUtils.getOreDictItemStack("dustMercuryFulminate"), 1f) }, + 200)); + } + ChemicalReactorTileEntity.addRecipe( + new UniversalRecipeInput(new FluidStack[] { IHLUtils.getFluidStackWithSize("glycerol", 100), + IHLUtils.getFluidStackWithSize("nitricacid", 300) }, null), + new UniversalRecipeOutput(new FluidStack[] { IHLUtils.getFluidStackWithSize("nitroglycerin", 400) }, + null, 200)); + + Crucible.addRecipe("ingotSteel", IHLUtils.getFluidStackWithSize("molten.steel", 144)); + Crucible.addRecipe("ingotBronze", IHLUtils.getFluidStackWithSize("molten.bronze", 144)); + Crucible.addRecipe("ingotGold", IHLUtils.getFluidStackWithSize("molten.gold", 144)); + Crucible.addRecipe("ingotMagnesium", IHLUtils.getFluidStackWithSize("molten.magnesium", 144)); + Crucible.addRecipe("dustGold", IHLUtils.getFluidStackWithSize("molten.gold", 144)); + Crucible.addRecipe("dustSalt", IHLUtils.getFluidStackWithSize("molten.sodiumchloride", 144)); + Crucible.addRecipe("dustGlass", IHLUtils.getFluidStackWithSize("molten.glass", 144)); + Crucible.addRecipe("dustRockSalt", IHLUtils.getFluidStackWithSize("molten.potassiumchloride", 144)); + PaperMachineTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("pulp.cellulose", 1500), + new ItemStack(Items.paper)); + PaperMachineTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("pulp.mica", 500), + IHLUtils.getThisModItemStack("foilMica")); + FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("oil", 100), + IHLUtils.getFluidStackWithSize("fueloil", 60), IHLUtils.getFluidStackWithSize("fuel", 40)); + if (FluidRegistry.isFluidRegistered("liquid_light_oil")) + FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("liquid_light_oil", 100), + IHLUtils.getFluidStackWithSize("fueloil", 40), IHLUtils.getFluidStackWithSize("fuel", 60)); + if (FluidRegistry.isFluidRegistered("liquid_medium_oil")) + FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("liquid_medium_oil", 100), + IHLUtils.getFluidStackWithSize("fueloil", 60), IHLUtils.getFluidStackWithSize("fuel", 40)); + if (FluidRegistry.isFluidRegistered("liquid_heavy_oil")) + FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("liquid_heavy_oil", 100), + IHLUtils.getFluidStackWithSize("fueloil", 70), IHLUtils.getFluidStackWithSize("fuel", 30)); + if (FluidRegistry.isFluidRegistered("liquid_extra_heavy_oil")) + FractionatorBottomTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("liquid_extra_heavy_oil", 100), + IHLUtils.getFluidStackWithSize("fueloil", 80), IHLUtils.getFluidStackWithSize("fuel", 20)); + ElectrolysisBathTileEntity + .addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { + IHLUtils.getFluidStackWithSize("molten.sodiumchloride", 1000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustBischofite") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("molten.magnesium", 6) }), null, + 200)); + ElectrolysisBathTileEntity + .addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { + IHLUtils.getFluidStackWithSize("molten.sodiumchloride", 1000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustLithiumChloride") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("molten.lithium", 72) }), null, + 200)); + ElectrolysisBathTileEntity + .addRecipe( + new UniversalRecipeInput( + (new FluidStack[] { + IHLUtils.getFluidStackWithSize("molten.potassiumchloride", 1000) }), + (new ItemStack[] { IHLUtils.getOreDictItemStack("dustRockSalt") })), + new UniversalRecipeOutput( + (new FluidStack[] { IHLUtils.getFluidStackWithSize("molten.potassium", 72) }), null, + 200)); + // 1 mb of molten metal per 1 m of cable with transverse section + // equals to 1.5 sq. mm. + fluidDictionary.registerFluidStack("water", IHLUtils.getFluidStackWithSize("water", 1000)); + fluidDictionary.registerFluidStack("water", IHLUtils.getFluidStackWithSize("ic2distilledwater", 1000)); + fluidDictionary.registerFluidStack("lubricant", IHLUtils.getFluidStackWithSize("seedoil", 1000)); + fluidDictionary.registerFluidStack("lubricant", IHLUtils.getFluidStackWithSize("oleicacid", 1000)); + fluidDictionary.registerFluidStack("lubricant", IHLUtils.getFluidStackWithSize("mineraloil", 1000)); + if (FluidRegistry.isFluidRegistered("lubricant")) + fluidDictionary.registerFluidStack("lubricant", IHLUtils.getFluidStackWithSize("lubricant", 1000)); + WireMillTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("molten.glass", 1), + new RecipeInputItemStack(IHLUtils.getThisModItemStack("fiberGlassDieSteel"), 0), + IHLUtils.getThisModWireItemStackWithLength("fiberGlass", 64)); + WireMillTileEntity.addRecipe("dustGlass", IHLUtils.getFluidStackWithSize("molten.glass", 144)); + for (ElectricConductor ec : ElectricConductor.values()) { + String fluidName = "molten." + ec.toString().toLowerCase(); + if (FluidRegistry.isFluidRegistered(fluidName)) { + WireMillTileEntity.addRecipe(IHLUtils.getFluidStackWithSize(fluidName, 1), + new RecipeInputDie("setOfDies1_5sqmm", 15), + IHLUtils.getUninsulatedWire(ec.toString(), 1, 15)); + log.debug("added recipe for " + fluidName); + if (ec.meltingPoint < 500) { + WireMillTileEntity.addRecipe("ingot" + ec.toString(), + IHLUtils.getFluidStackWithSize(fluidName, 144)); + } + } + } + VulcanizationExtrudingMoldTileEntity.addRecipe(IHLUtils.getFluidStackWithSize("molten.rubber", 32), + IHLUtils.getUninsulatedWire("Copper", 1, 15), + IHLUtils.getInsulatedWire("Copper", 1, 15, "Rubber", 100)); + IHLMod.config.loadRecipeModificators(); + } + if (Loader.isModLoaded("NotEnoughItems")) { + NEIModContainer.plugins.add(new NEIIHLConfig()); + } + IHLMod.proxy.initBlockRenderer(); + IHLMod.log.info("IHL loaded."); + } + + private void registerEntities() { + EntityRegistry.registerModEntity(PowerCableNodeEntity.class, "PowerCableNodeEntity", 2, this, 80, 3, true); + EntityRegistry.registerModEntity(NodeEntity.class, "NodeEntity", 3, this, 80, 3, true); + EntityRegistry.registerModEntity(IHLEntityFallingPile.class, "IHLEntityFallingPile", 4, this, 80, 3, true); + EntityRegistry.registerGlobalEntityID(LostHeadEntity.class, "LostHead", + EntityRegistry.findGlobalUniqueEntityId(), 0x0033FF, 0x00CCFF); + if (IHLMod.config.enableWailers) { + BiomeGenBase[] biomes = BiomeDictionary.getBiomesForType(Type.END); + for (int i = 0; i < biomes.length; i++) { + if (biomes[i].biomeName.equals("Sky")) { + EntityRegistry.addSpawn(LostHeadEntity.class, 50, 1, 10, EnumCreatureType.monster, biomes[i]); + } + } + } + } + + @Override + public int getBurnTime(ItemStack stack) { + if (IHLUtils.getFirstOreDictName(stack) == "ingotTarPitch") { + return 2000; + } + if (IHLUtils.getFirstOreDictName(stack) == "dustSodiumZeoliteCoked") { + return 500; + } else if (IHLUtils.getFirstOreDictName(stack) == "nuggetTarPitch") { + return 222; + } else if (IHLUtils.getFirstOreDictName(stack) == "dustSulfur") { + return 160; + } + return 0; + } + + @SuppressWarnings("deprecation") + private void loadGT5Recipes() { + ItemStack battery_mv_c = ItemList.Battery_RE_MV_Cadmium.get(1L, new Object[] { null }); + ItemStack battery_mv_l = ItemList.Battery_RE_MV_Lithium.get(1L, new Object[] { null }); + ItemStack battery_mv_s = ItemList.Battery_RE_MV_Sodium.get(1L, new Object[] { null }); + ItemStack energy_crystal = gregtech.api.util.GT_ModHandler.getIC2Item("energyCrystal", 1L, 32767); + ItemStack pump = ItemList.Electric_Pump_MV.get(1L, new Object[] { null }); + ItemStack pump_hv = ItemList.Electric_Pump_HV.get(1L, new Object[] { null }); + int[] gypsumOreList1; + int[] oreListIterator1; + + if (config.enableRubberTreeSack) { + gypsumOreList1 = new int[] { 10000, 2000, 2000, 1000, 100, 0 }; + oreListIterator1 = new int[] { 10000, 10000, 10000, 5000, 500, 10000 }; + GregTech_API.sRecipeAdder.addCentrifugeRecipe((ItemStack) null, (ItemStack) null, + new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"), 200), + new FluidStack(FluidRegistry.WATER, 120), ItemList.IC2_Resin.get(1L, new Object[] { null }), + IHLUtils.getOreDictItemStack("dustRawRubber"), new ItemStack(Items.sugar, 1), + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Wood, 2L), (ItemStack) null, + (ItemStack) null, gypsumOreList1, 500, 5); + GregTech_API.sRecipeAdder.addCentrifugeRecipe(IHLFluid.getCell("fluidrubbertreesap"), (ItemStack) null, + new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"), 200), + new FluidStack(FluidRegistry.WATER, 600), ItemList.IC2_Resin.get(5L, new Object[] { null }), + IHLUtils.getOreDictItemStack("dustRawRubber"), new ItemStack(Items.sugar, 1), + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Wood, 1L), + ItemList.Cell_Empty.get(1L, new Object[] { null }), (ItemStack) null, oreListIterator1, 2500, 5); + } + + if (config.enableHandpump) { + gregtech.api.util.GT_ModHandler.addCraftingRecipe(((IHLHandPump) ic2_handpump).getItemStack(0), + new Object[] { "T ", " P ", " B", 'T', OrePrefixes.pipeSmall.get(Materials.Steel), 'P', pump, 'B', + battery_mv_c }); + gregtech.api.util.GT_ModHandler.addCraftingRecipe(((IHLHandPump) ic2_handpump).getItemStack(0), + new Object[] { "T ", " P ", " B", 'T', OrePrefixes.pipeSmall.get(Materials.Steel), 'P', pump, 'B', + battery_mv_l }); + gregtech.api.util.GT_ModHandler.addCraftingRecipe(((IHLHandPump) ic2_handpump).getItemStack(0), + new Object[] { "T ", " P ", " B", 'T', OrePrefixes.pipeSmall.get(Materials.Steel), 'P', pump, 'B', + battery_mv_s }); + gregtech.api.util.GT_ModHandler.addCraftingRecipe( + ((AdvancedHandPump) ic2_advanced_handpump).getItemStack(0), new Object[] { "T ", " P ", " B", 'T', + OrePrefixes.pipeSmall.get(Materials.TungstenSteel), 'P', pump_hv, 'B', energy_crystal }); + } + + if (config.enableFlexibleCablesCrafting) { + gregtech.api.util.GT_ModHandler.addCraftingRecipe(IHLUtils.getThisModItemStack("ironWorkbench"), + new Object[] { "PPS", "RRh", "RRd", 'P', OrePrefixes.plate.get(Materials.Iron), 'S', + OrePrefixes.screw.get(Materials.Iron), 'R', OrePrefixes.stick.get(Materials.Iron) }); + gregtech.api.util.GT_ModHandler.addCraftingRecipe(IHLUtils.getThisModItemStack("setOfDies1_5sqmm"), + new Object[] { " ", "fPs", " ", 'P', OrePrefixes.plate.get(Materials.Steel) }); + gregtech.api.util.GT_ModHandler.addCraftingRecipe( + IHLUtils.getItemStackWithTag("setOfDies1_5sqmm", "transverseSection", 240), + new Object[] { " f ", " P ", " s ", 'P', OrePrefixes.plate.get(Materials.Steel) }); + } + if (pfaalimestone != null) { + GregTech_API.sRecipeAdder.addPulveriserRecipe(pfaalimestone, + new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("dustCalcite", 4) }, new int[] { 10000 }, + 600, 30); + } + + if (pfaacobblelimestone != null) { + GregTech_API.sRecipeAdder.addPulveriserRecipe(pfaacobblelimestone, + new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("dustCalcite", 4) }, new int[] { 10000 }, + 600, 30); + } + List<ItemStack> gypsumOreList3 = IHLUtils.getEntryListForOre("oreGypsum"); + Iterator<ItemStack> oreListIterator3 = gypsumOreList3.iterator(); + while (oreListIterator3.hasNext()) { + GregTech_API.sRecipeAdder.addPulveriserRecipe((oreListIterator3.next()), + new ItemStack[] { IHLUtils.getOreDictItemStack("dustGypsum") }, new int[] { 10000 }, 600, 30); + } + GregTech_API.sRecipeAdder.addPulveriserRecipe(IHLUtils.getThisModItemStack("orePotassiumFeldspar"), + new ItemStack[] { IHLUtils.getOreDictItemStack("dustPotassiumFeldspar") }, new int[] { 10000 }, 600, + 30); + GregTech_API.sRecipeAdder.addPulveriserRecipe(IHLUtils.getThisModItemStack("oreLimestone"), + new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("dustCalcite", 4) }, new int[] { 10000 }, 600, + 30); + GregTech_API.sRecipeAdder.addPulveriserRecipe(IHLUtils.getThisModItemStack("oreSaltpeter"), + new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("dustSaltpeter", 4) }, new int[] { 10000 }, 600, + 30); + GregTech_API.sRecipeAdder.addPulveriserRecipe(IHLUtils.getThisModItemStackWithSize("stickGraphite", 2), + new ItemStack[] { IHLUtils.getOreDictItemStack("dustGraphite") }, new int[] { 10000 }, 600, 30); + GregTech_API.sRecipeAdder.addPulveriserRecipe(new ItemStack(Items.brick), + new ItemStack[] { IHLUtils.getOreDictItemStack("dustBrick") }, new int[] { 10000 }, 600, 30); + GregTech_API.sRecipeAdder.addChemicalRecipe(GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Sodium, 1L), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L), + new FluidStack(FluidRegistry.WATER, 1500), + FluidRegistry.getFluidStack("solution.natriumhydroxide", 1000), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Hydrogen, 1L), 950); + GregTech_API.sRecipeAdder.addChemicalRecipe( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.SiliconDioxide, 1L), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 2L), + FluidRegistry.getFluidStack("solution.natriumhydroxide", 1000), (FluidStack) null, + GT_OreDictUnificator.get(OrePrefixes.cell, "LiquidGlass", 2L), 950); + gregtech.api.util.GT_ModHandler.addShapelessCraftingRecipe( + IHLUtils.getThisModItemStack("dustCoalElectrodePremix"), + new Object[] { GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Coal, 1L), + IHLUtils.getOreDictItemStack("nuggetTarPitch") }); + gregtech.api.util.GT_ModHandler.addShapelessCraftingRecipe( + IHLUtils.getThisModItemStackWithSize("dustIrongraphite", 2), + new Object[] { GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Graphite, 1L) }); + gregtech.api.util.GT_ModHandler.addSmeltingRecipe(IHLUtils.getThisModItemStack("stickCoalElectrodePremix"), + GT_OreDictUnificator.get(OrePrefixes.stick, Materials.Coal, 1L)); + gregtech.api.util.GT_ModHandler.addSmeltingRecipe( + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Calcite, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Quicklime, 1L)); + GregTech_API.sRecipeAdder.addFormingPressRecipe(IHLUtils.getThisModItemStack("dustIrongraphite"), + ItemList.Shape_Mold_Cylinder.get(0L, new Object[0]), + IHLUtils.getThisModItemStackWithSize("linerIronGraphite", 4), 950, 30); + GregTech_API.sRecipeAdder.addFormingPressRecipe(IHLUtils.getThisModItemStack("dustCoalElectrodePremix"), + ItemList.Shape_Extruder_Rod.get(0L, new Object[0]), + IHLUtils.getThisModItemStack("stickCoalElectrodePremix"), 950, 30); + GregTech_API.sRecipeAdder.addDistilleryRecipe( + ItemList.Circuit_Integrated.getWithDamage(0, 0, new Object[] { null }), + IHLUtils.getFluidStackWithSize("spruceresin", 1000), IHLUtils.getFluidStackWithSize("turpentine", 50), + 3000, 30, false); + ExtruderTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("dustRawRubber", 5), + IHLUtils.getOreDictItemStackWithSize("dustTinySulfur", 1), + IHLUtils.getFluidStackWithSize("molten.rubber", 144 * 5)); + ExtruderTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("dustRawRubber", 20), + IHLUtils.getOreDictItemStackWithSize("dustSulfur", 1), + IHLUtils.getFluidStackWithSize("molten.rubber", 144 * 20)); + WoodenRollingMachinePart1TileEntity.addRecipe(new RecipeInputOreDict("dustRawRubber", 5), + new RecipeInputOreDict("dustTinySulfur", 1), + IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur", 20)); + WoodenRollingMachinePart1TileEntity.addRecipe(new RecipeInputOreDict("dustRawRubber", 20), + new RecipeInputOreDict("dustSulfur", 1), + IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur", 80)); + WoodenRollingMachinePart1TileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur", 16)), + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("fabric", 8)), + new RecipeInputOreDict("dustGraphite"), + IHLUtils.getThisModItemStack("pipeRubberWithSulfur")); + } + + @SuppressWarnings("deprecation") + private void loadGT6Recipes() { + ItemStack battery_mv_c = IL.Battery_RE_MV_Cadmium.get(1); + ItemStack battery_mv_l = IL.Battery_RE_MV_Lithium.get(1); + ItemStack battery_mv_s = IL.Battery_RE_MV_Sodium.get(1); + ItemStack energy_crystal = IC2Items.getItem("energyCrystal"); + ItemStack pump = IL.Electric_Pump_MV.get(1, (Object) null); + ItemStack pump_hv = IL.Electric_Pump_HV.get(1, (Object) null); + + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Invar_Full.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Invar_Used.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Plastic_Full.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Plastic_Used.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Platinum_Full.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Lighter_Platinum_Used.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_MatchBox_Full.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_MatchBox_Used.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Matches.get(1)); + OreDictionary.registerOre("toolLighter", IL.Tool_Fire_Starter.get(1)); + + gregapi.util.UT.Crafting.shaped( + IHLUtils.getThisModItemStack(MachineBaseBlock.MachineType.ChemicalReactor.unlocalizedName), + new Object[] { " R ", "PVP", " Mw", Character.valueOf('R'), + gregapi.data.OP.stick.dat(gregapi.data.MT.StainlessSteel), Character.valueOf('V'), + gregapi.data.OP.rotor.dat(gregapi.data.MT.StainlessSteel), Character.valueOf('P'), + gregapi.data.OP.plateCurved.dat(gregapi.data.MT.StainlessSteel), Character.valueOf('M'), + gregapi.data.OP.casingMachine.dat(gregapi.data.MT.Steel) }); + + gregapi.util.UT.Crafting.shaped( + IHLUtils.getThisModItemStack(MachineBaseBlock.MachineType.CryogenicDistiller.unlocalizedName), + new Object[] { " R ", "P P", " Mw", Character.valueOf('R'), + gregapi.data.OP.pipeTiny.dat(gregapi.data.MT.Copper), Character.valueOf('P'), + gregapi.data.OP.plateCurved.dat(gregapi.data.MT.Copper), Character.valueOf('M'), + gregapi.data.OP.casingMachine.dat(gregapi.data.MT.Steel) }); + + gregapi.util.UT.Crafting.shaped( + IHLUtils.getThisModItemStack(MachineBaseBlock.MachineType.FluidizedBedReactor.unlocalizedName), + new Object[] { " ", "RPR", "VMw", Character.valueOf('R'), + gregapi.data.OP.pipeTiny.dat(gregapi.data.MT.Titanium), Character.valueOf('P'), + gregapi.data.OP.pipeHuge.dat(gregapi.data.MT.Titanium), Character.valueOf('V'), + gregapi.data.OP.rotor.dat(gregapi.data.MT.Titanium), Character.valueOf('M'), + gregapi.data.OP.casingMachine.dat(gregapi.data.MT.Steel) }); + + IRecipeInput[] dsmInputs1 = new IRecipeInput[3]; + ItemStack gregtechfile = IHLUtils.getOtherModItemStackWithDamage("gregtech", "gt.metatool.01", 18, 1); + dsmInputs1[0] = new RecipeInputItemStack(gregtechfile); + dsmInputs1[1] = new RecipeInputOreDict("dustDiamond"); + dsmInputs1[2] = new RecipeInputOreDict("dustGunpowder"); + DetonationSprayingMachineTileEntity.addRecipe((new UniversalRecipeInput(null, dsmInputs1)), + new UniversalRecipeOutput(null, new ItemStack[] { gregtechfile.copy() }, 2)); + + if (IHLMod.config.enableRubberTreeSack) { + long[] chances = { 10000, 2000, 2000, 1000, 100, 0 }; + Recipe.RecipeMap.sCoagulatorRecipes.addRecipe(true, new ItemStack[] {}, + new ItemStack[] { OreDictManager.INSTANCE.getStack(OP.nugget, MT.Rubber, 1) }, null, chances, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"), 500) }, + new FluidStack[] {}, 64, 0, 0); + } + + if (IHLMod.config.enableHandpump) { + gregapi.util.UT.Crafting.shaped(((IHLHandPump) ic2_handpump).getItemStack(0), + new Object[] { "T ", " P ", " B", Character.valueOf('T'), OP.pipeSmall.get(MT.Steel), + Character.valueOf('P'), pump, Character.valueOf('B'), battery_mv_c }); + gregapi.util.UT.Crafting.shaped(((IHLHandPump) ic2_handpump).getItemStack(0), + new Object[] { "T ", " P ", " B", Character.valueOf('T'), OP.pipeSmall.get(MT.Steel), + Character.valueOf('P'), pump, Character.valueOf('B'), battery_mv_l }); + gregapi.util.UT.Crafting.shaped(((IHLHandPump) ic2_handpump).getItemStack(0), + new Object[] { "T ", " P ", " B", Character.valueOf('T'), OP.pipeSmall.get(MT.Steel), + Character.valueOf('P'), pump, Character.valueOf('B'), battery_mv_s }); + gregapi.util.UT.Crafting.shaped(((AdvancedHandPump) ic2_advanced_handpump).getItemStack(0), + new Object[] { "T ", " P ", " B", Character.valueOf('T'), OP.pipeSmall.get(MT.TungstenSteel), + Character.valueOf('P'), pump_hv, Character.valueOf('B'), energy_crystal }); + } + if (IHLMod.config.enableFlexibleCablesCrafting) { + gregapi.util.UT.Crafting.shaped(IHLUtils.getThisModItemStack("ironWorkbench"), + new Object[] { "PPS", "RRh", "RRd", Character.valueOf('P'), OP.plate.get(MT.Iron), + Character.valueOf('S'), OP.screw.get(MT.Iron), Character.valueOf('R'), + OP.stick.get(MT.Iron) }); + gregapi.util.UT.Crafting.shaped(IHLUtils.getThisModItemStack("setOfDies1_5sqmm"), + new Object[] { " ", "fPs", " ", Character.valueOf('P'), OP.plate.get(MT.Steel) }); + gregapi.util.UT.Crafting.shaped(IHLUtils.getItemStackWithTag("setOfDies1_5sqmm", "transverseSection", 240), + new Object[] { " f ", " P ", " s ", Character.valueOf('P'), OP.plate.get(MT.Steel) }); + } + if (pfaalimestone != null) { + Recipe.RecipeMap.sMaceratorRecipes.addRecipe(true, new ItemStack[] { pfaalimestone }, + new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("dustCalcite", 4) }, null, + new long[] { 10000 }, new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + } + if (pfaacobblelimestone != null) { + Recipe.RecipeMap.sMaceratorRecipes.addRecipe(true, new ItemStack[] { pfaacobblelimestone }, + new ItemStack[] { IHLUtils.getOreDictItemStackWithSize("dustCalcite", 4) }, null, + new long[] { 10000 }, new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + } + List<ItemStack> gypsumOreList = IHLUtils.getEntryListForOre("oreGypsum"); + Iterator<ItemStack> oreListIterator = gypsumOreList.iterator(); + while (oreListIterator.hasNext()) { + Recipe.RecipeMap.sMaceratorRecipes.addRecipe(true, new ItemStack[] { oreListIterator.next().copy() }, + new ItemStack[] { IHLUtils.getOreDictItemStack("dustGypsum") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + } + + Recipe.RecipeMap.sMaceratorRecipes.addRecipe(true, + new ItemStack[] { IHLUtils.getThisModItemStack("orePotassiumFeldspar") }, + new ItemStack[] { IHLUtils.getOreDictItemStack("dustPotassiumFeldspar") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + + Recipe.RecipeMap.sMaceratorRecipes.addRecipe(true, + new ItemStack[] { IHLUtils.getThisModItemStack("oreLimestone") }, + new ItemStack[] { IHLUtils.getOreDictItemStack("dustCalcite") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + Recipe.RecipeMap.sMaceratorRecipes.addRecipe(true, + new ItemStack[] { IHLUtils.getThisModItemStack("oreSaltpeter") }, + new ItemStack[] { IHLUtils.getOreDictItemStack("dustSaltpeter") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + Recipe.RecipeMap.sMaceratorRecipes.addRecipe(true, new ItemStack[] { new ItemStack(Items.brick) }, + new ItemStack[] { IHLUtils.getOreDictItemStack("dustBrick") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + Recipe.RecipeMap.sShredderRecipes.addRecipe(true, new ItemStack[] { new ItemStack(Items.brick) }, + new ItemStack[] { IHLUtils.getOreDictItemStack("dustBrick") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + Recipe.RecipeMap.sMaceratorRecipes.addRecipe(true, + new ItemStack[] { IHLUtils.getOreDictItemStack("stickGraphite") }, + new ItemStack[] { IHLUtils.getOreDictItemStack("dustSmallGraphite") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + GT_ModHandler.addShapelessCraftingRecipe(IHLUtils.getThisModItemStack("dustCoalElectrodePremix"), + new Object[] { OreDictManager.INSTANCE.getStack(OP.dust, MT.Coal, 1), + IHLUtils.getOreDictItemStack("nuggetTarPitch") }); + GT_ModHandler.addShapelessCraftingRecipe(IHLUtils.getThisModItemStackWithSize("dustIrongraphite", 2), + new Object[] { OreDictManager.INSTANCE.getStack(OP.dust, MT.Iron, 1), + OreDictManager.INSTANCE.getStack(OP.dust, MT.Graphite, 1) }); + GT_ModHandler.addSmeltingRecipe(IHLUtils.getThisModItemStack("stickCoalElectrodePremix"), + OreDictManager.INSTANCE.getStack(OP.stick, MT.Coal, 1)); + GT_ModHandler.addSmeltingRecipe(OreDictManager.INSTANCE.getStack(OP.dust, MT.Calcite, 1), + OreDictManager.INSTANCE.getStack("dustQuicklime", 1)); + Recipe.RecipeMap.sPressRecipes.addRecipe(true, + new ItemStack[] { OreDictManager.INSTANCE.getStack(OP.dust, MT.Iron, 1), + OreDictManager.INSTANCE.getStack(OP.dust, MT.Graphite, 1) }, + new ItemStack[] { IHLUtils.getThisModItemStackWithSize("linerIronGraphite", 4) }, null, + new long[] { 10000 }, new FluidStack[] {}, new FluidStack[] {}, 950, 30, 0); + Recipe.RecipeMap.sPressRecipes.addRecipe(true, + new ItemStack[] { IHLUtils.getThisModItemStack("dustCoalElectrodePremix"), + IL.Shape_Extruder_Rod.get(0) }, + new ItemStack[] { IHLUtils.getThisModItemStack("stickCoalElectrodePremix") }, null, + new long[] { 10000 }, new FluidStack[] {}, new FluidStack[] {}, 950, 30, 0); + Recipe.RecipeMap.sPressRecipes.addRecipe(true, + new ItemStack[] { IHLUtils.getThisModItemStack("foilRubberWithSulfur"), + IL.Shape_Extruder_Casing.get(0) }, + new ItemStack[] { IHLUtils.getThisModItemStack("batteryCellsEbonite") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 950, 30, 0); + Recipe.RecipeMap.sCompressorRecipes.addRecipe(true, + new ItemStack[] { IHLUtils.getThisModItemStackWithSize("foilMica", 4) }, + new ItemStack[] { IHLUtils.getThisModItemStack("plateMica") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 950, 30, 0); + Recipe.RecipeMap.sMaceratorRecipes.addRecipe(true, + new ItemStack[] { IHLUtils.getOreDictItemStack("oreGyubnera") }, + new ItemStack[] { IHLUtils.getOreDictItemStack("crushedGyubnera") }, null, new long[] { 10000 }, + new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + Recipe.RecipeMap.sCentrifugeRecipes.addRecipe(true, + new ItemStack[] { IHLUtils.getOreDictItemStack("crushedGyubnera") }, + new ItemStack[] { IHLUtils.getOreDictItemStack("crushedPurifiedGyubnera"), + IHLUtils.getOreDictItemStack("dustPotassiumFeldspar") }, + null, new long[] { 10000 }, new FluidStack[] {}, new FluidStack[] {}, 600, 30, 0); + Recipe.RecipeMap.sCentrifugeRecipes.addRecipe(true, new ItemStack[] {}, + new ItemStack[] { Ic2Items.resin.copy(), IHLUtils.getOreDictItemStack("dustTinyWood") }, null, + new long[] { 5000, 10000 }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"), 569) }, + new FluidStack[] { new FluidStack(FluidRegistry.getFluid("molten.latex"), 140), + new FluidStack(FluidRegistry.getFluid("glue"), 240), + new FluidStack(FluidRegistry.getFluid("water"), 100) }, + 64, 32, 0); + + ExtruderTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("dustRubber", 5), + IHLUtils.getOreDictItemStackWithSize("dustTinySulfur", 1), + IHLUtils.getFluidStackWithSize("molten.rubber", 144 * 5)); + ExtruderTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("dustRubber", 20), + IHLUtils.getOreDictItemStackWithSize("dustSulfur", 1), + IHLUtils.getFluidStackWithSize("molten.rubber", 144 * 20)); + WoodenRollingMachinePart1TileEntity.addRecipe(new RecipeInputOreDict("dustRubber", 5), + new RecipeInputOreDict("dustTinySulfur", 1), + IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur", 20)); + WoodenRollingMachinePart1TileEntity.addRecipe(new RecipeInputOreDict("dustRubber", 20), + new RecipeInputOreDict("dustSulfur", 1), + IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur", 80)); + WoodenRollingMachinePart1TileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur", 16)), + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("fabric", 8)), + new RecipeInputOreDict("dustGraphite"), + IHLUtils.getThisModItemStack("pipeRubberWithSulfur")); + } + + private void loadIC2Recipes() { + ItemStack crystal = IC2Items.getItem("lapotronCrystal").copy(); + ItemStack advBattery = IC2Items.getItem("advBattery").copy(); + ItemStack chargedReBattery = IC2Items.getItem("chargedReBattery").copy(); + crystal.setItemDamage(OreDictionary.WILDCARD_VALUE); + advBattery.setItemDamage(OreDictionary.WILDCARD_VALUE); + chargedReBattery.setItemDamage(OreDictionary.WILDCARD_VALUE); + Recipes.advRecipes.addRecipe(new ItemStack(electricEvaporatorBlock, 1), + new Object[] { "CCC", "CCC", " F ", Character.valueOf('C'), IC2Items.getItem("platecopper"), + Character.valueOf('F'), IC2Items.getItem("electroFurnace") }); + Recipes.advRecipes.addRecipe(new ItemStack(electricEvaporatorBlock, 1), + new Object[] { " ", " C ", " F ", Character.valueOf('C'), Ic2Items.electronicCircuit.copy(), + Character.valueOf('F'), new ItemStack(evaporatorBlock, 1) }); + if (IHLMod.config.enableFlexibleCablesCrafting) { + ItemStack cutter = Ic2Items.cutter.copy(); + cutter.setItemDamage(OreDictionary.WILDCARD_VALUE); + ItemStack forgeHammer = Ic2Items.ForgeHammer.copy(); + forgeHammer.setItemDamage(OreDictionary.WILDCARD_VALUE); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("setOfDies1_5sqmm"), new Object[] { " ", " PC", + " ", Character.valueOf('P'), Ic2Items.plateadviron, Character.valueOf('C'), cutter }); + Recipes.advRecipes.addRecipe(IHLUtils.getItemStackWithTag("setOfDies1_5sqmm", "transverseSection", 240), + new Object[] { " C ", " P ", " ", Character.valueOf('P'), Ic2Items.plateadviron, + Character.valueOf('C'), cutter }); + Recipes.advRecipes.addRecipe(IHLUtils.getThisModItemStack("ironWorkbench"), new Object[] { "P ", "P ", + "P H", Character.valueOf('P'), Ic2Items.plateadviron, Character.valueOf('H'), forgeHammer }); + } + ExtruderTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("itemRubber", 5), + IHLUtils.getOreDictItemStackWithSize("dustTinySulfur", 1), + IHLUtils.getFluidStackWithSize("molten.rubber", 144 * 5)); + ExtruderTileEntity.addRecipe(IHLUtils.getOreDictItemStackWithSize("itemRubber", 20), + IHLUtils.getOreDictItemStackWithSize("dustSulfur", 1), + IHLUtils.getFluidStackWithSize("molten.rubber", 144 * 20)); + WoodenRollingMachinePart1TileEntity.addRecipe(new RecipeInputOreDict("itemRubber", 5), + new RecipeInputOreDict("dustTinySulfur", 1), + IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur", 20)); + WoodenRollingMachinePart1TileEntity.addRecipe(new RecipeInputOreDict("itemRubber", 20), + new RecipeInputOreDict("dustSulfur", 1), + IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur", 80)); + WoodenRollingMachinePart1TileEntity.addRecipe( + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("foilRubberWithSulfur", 16)), + new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize("fabric", 8)), + new RecipeInputOreDict("dustGraphite"), + IHLUtils.getThisModItemStack("pipeRubberWithSulfur")); + } +} diff --git a/src/main/java/ihl/IHLModConfig.java b/src/main/java/ihl/IHLModConfig.java new file mode 100644 index 0000000..6beddfe --- /dev/null +++ b/src/main/java/ihl/IHLModConfig.java @@ -0,0 +1,562 @@ +package ihl;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+
+import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputFluidContainer;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeInputOreDict;
+import ihl.flexible_cable.IronWorkbenchTileEntity;
+import ihl.recipes.IronWorkbenchRecipe;
+import ihl.recipes.RecipeInputDie;
+import ihl.recipes.RecipeInputWire;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.config.Configuration;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+public class IHLModConfig
+{
+ public int explosionVectorSizeBits=7;
+ public int explosionPowerBase=100;
+
+ public int handpumpTier=1;
+ public int handpumpMaxCharge=30000;
+ public int handpumpOperationEUCost=180;
+
+ public int advancedHandpumpTier=3;
+ public int advancedHandpumpMaxCharge=1000000;
+ public int advancedHandpumpOperationEUCost=10000;
+
+ public int tditTier=4;
+ public int tditMaxEnergyStorage=12000;
+ public int tditEnergyConsumePerStack=12000;
+
+ public boolean enableHandpump=true;
+ public boolean enableRubberTreeSack=true;
+ public boolean enableWailers=true;
+ public boolean enableTDIT=true;
+
+ public boolean enableFlexibleCablesCrafting=true;
+ public boolean enableFlexibleCablesGridPowerLossCalculations=true;
+ public boolean generateApatiteOre=true;
+ public boolean generateSaltpeterOre=true;
+ public boolean generateLimestone=true;
+ public boolean generateGypsum=true;
+ public boolean generatePotassiumFeldspar=true;
+ public boolean generateTrona=true;
+ public boolean generateRocksalt=true;
+ public boolean generateCinnabar=true;
+ public boolean generateGyubnera=true;
+ public boolean generateBauxite=true;
+ public boolean generateChromite=true;
+ public boolean generateMuscovite=true;
+ public boolean generateOil=true;
+ public boolean generateDatolite=true;
+ public boolean generateSaltwater=true;
+ public boolean generateBischofite=true;
+ public int chanceOreWillNotBeGenerated = 100;
+ public int mirrorReflectionRange=14;
+ public int mirrorReflectionUpdateSpeed=128;
+ public String preventMachineBlockRegistrationName="null";
+ public boolean skipRecipeLoad=false;
+ public int machineryEnergyConsume=100;
+ public int maxCatalystUses = 1000;
+
+ public IHLModConfig(FMLPreInitializationEvent evt) throws IOException
+ {
+ Configuration config = new Configuration(evt.getSuggestedConfigurationFile());
+ config.load();
+ skipRecipeLoad = config.get(Configuration.CATEGORY_GENERAL, "skipRecipeLoad", skipRecipeLoad).getBoolean(skipRecipeLoad);
+ preventMachineBlockRegistrationName = config.get(Configuration.CATEGORY_GENERAL, "preventMachineBlockRegistrationName", preventMachineBlockRegistrationName).getString();
+ enableHandpump = config.get(Configuration.CATEGORY_GENERAL, "enableHandpump", enableHandpump).getBoolean(enableHandpump);
+ enableRubberTreeSack = config.get(Configuration.CATEGORY_GENERAL, "enableRubberTreeSack", enableRubberTreeSack).getBoolean(enableRubberTreeSack);
+ enableWailers = config.get(Configuration.CATEGORY_GENERAL, "enableWailers", enableWailers).getBoolean(enableWailers);
+ enableTDIT = config.get(Configuration.CATEGORY_GENERAL, "enableTDIT", enableTDIT).getBoolean(enableTDIT);
+
+ generateApatiteOre = config.get(Configuration.CATEGORY_GENERAL, "generateApatiteOre", generateApatiteOre).getBoolean(generateApatiteOre);
+ generateSaltpeterOre = config.get(Configuration.CATEGORY_GENERAL, "generateSaltpeterOre", generateSaltpeterOre).getBoolean(generateSaltpeterOre);
+ generateLimestone = config.get(Configuration.CATEGORY_GENERAL, "generateLimestone", generateLimestone).getBoolean(generateLimestone);
+ generateGypsum = config.get(Configuration.CATEGORY_GENERAL, "generateGypsum", generateGypsum).getBoolean(generateGypsum);
+ generatePotassiumFeldspar = config.get(Configuration.CATEGORY_GENERAL, "generatePotassiumFeldspar", generatePotassiumFeldspar).getBoolean(generatePotassiumFeldspar);
+ generateTrona = config.get(Configuration.CATEGORY_GENERAL, "generateTrona", generateTrona).getBoolean(generateTrona);
+ generateRocksalt = config.get(Configuration.CATEGORY_GENERAL, "generateRocksalt", generateRocksalt).getBoolean(generateRocksalt);
+ generateCinnabar = config.get(Configuration.CATEGORY_GENERAL, "generateCinnabar", generateCinnabar).getBoolean(generateCinnabar);
+ generateGyubnera = config.get(Configuration.CATEGORY_GENERAL, "generateGyubnera", generateGyubnera).getBoolean(generateGyubnera);
+ generateBauxite = config.get(Configuration.CATEGORY_GENERAL, "generateBauxite", generateBauxite).getBoolean(generateBauxite);
+ generateChromite = config.get(Configuration.CATEGORY_GENERAL, "generateChromite", generateChromite).getBoolean(generateChromite);
+ generateMuscovite = config.get(Configuration.CATEGORY_GENERAL, "generateMuscovite", generateMuscovite).getBoolean(generateMuscovite);
+ generateOil = config.get(Configuration.CATEGORY_GENERAL, "generateOil", generateOil).getBoolean(generateOil);
+ generateDatolite = config.get(Configuration.CATEGORY_GENERAL, "generateDatolite", generateDatolite).getBoolean(generateDatolite);
+ generateSaltwater = config.get(Configuration.CATEGORY_GENERAL, "generateSaltwater", generateSaltwater).getBoolean(generateSaltwater);
+ generateBischofite = config.get(Configuration.CATEGORY_GENERAL, "generateBischofite", generateBischofite).getBoolean(generateBischofite);
+
+ handpumpTier = config.get(Configuration.CATEGORY_GENERAL, "handpumpTier", handpumpTier).getInt();
+ handpumpMaxCharge = config.get(Configuration.CATEGORY_GENERAL, "handpumpMaxCharge", handpumpMaxCharge).getInt();
+ handpumpOperationEUCost = config.get(Configuration.CATEGORY_GENERAL, "handpumpOperationEUCost", handpumpOperationEUCost).getInt();
+ advancedHandpumpTier = config.get(Configuration.CATEGORY_GENERAL, "advancedHandpumpTier", advancedHandpumpTier).getInt();
+ advancedHandpumpMaxCharge = config.get(Configuration.CATEGORY_GENERAL, "advancedHandpumpMaxCharge", advancedHandpumpMaxCharge).getInt();
+ advancedHandpumpOperationEUCost = config.get(Configuration.CATEGORY_GENERAL, "advancedHandpumpOperationEUCost", advancedHandpumpOperationEUCost).getInt();
+
+ tditTier = config.get(Configuration.CATEGORY_GENERAL, "tditTier", tditTier).getInt();
+ tditMaxEnergyStorage = config.get(Configuration.CATEGORY_GENERAL, "tditMaxEnergyStorage", tditMaxEnergyStorage).getInt();
+ tditEnergyConsumePerStack = config.get(Configuration.CATEGORY_GENERAL, "tditEnergyConsumePerStack", tditEnergyConsumePerStack).getInt();
+
+ enableFlexibleCablesGridPowerLossCalculations = config.get(Configuration.CATEGORY_GENERAL, "enableFlexibleCablesGridPowerLossCalculations", enableFlexibleCablesGridPowerLossCalculations).getBoolean(enableFlexibleCablesGridPowerLossCalculations);
+ enableFlexibleCablesCrafting = config.get(Configuration.CATEGORY_GENERAL, "enableFlexibleCablesCrafting", enableFlexibleCablesCrafting).getBoolean(enableFlexibleCablesCrafting);
+ mirrorReflectionRange = config.get(Configuration.CATEGORY_GENERAL, "mirrorReflectionRange", mirrorReflectionRange).getInt();
+ mirrorReflectionUpdateSpeed = config.get(Configuration.CATEGORY_GENERAL, "mirrorReflectionUpdateSpeed", mirrorReflectionUpdateSpeed).getInt();
+
+ explosionVectorSizeBits = config.get(Configuration.CATEGORY_GENERAL, "explosionVectorSizeBits", explosionVectorSizeBits).getInt();
+ explosionPowerBase = config.get(Configuration.CATEGORY_GENERAL, "explosionPowerBase", explosionPowerBase).getInt();
+ chanceOreWillNotBeGenerated = config.get(Configuration.CATEGORY_GENERAL, "chanceOreWillNotBeGenerated", chanceOreWillNotBeGenerated).getInt();
+
+ maxCatalystUses = config.get(Configuration.CATEGORY_GENERAL, "maxCatalystUses", maxCatalystUses).getInt();
+ machineryEnergyConsume = config.get(Configuration.CATEGORY_GENERAL, "machineryEnergyConsume", machineryEnergyConsume).getInt();
+ config.save();
+ }
+
+ private void loadRecipeConfig(InputStream resourceAsStream, boolean rewriteConfig) throws IOException
+ {
+ OutputStreamWriter osWriter = null;
+ BufferedWriter writer = null;
+ if(rewriteConfig)
+ {
+ osWriter = new OutputStreamWriter(new FileOutputStream(getFile()), "UTF-8");
+ writer = new BufferedWriter(osWriter);
+ }
+ InputStreamReader isReader = new InputStreamReader(resourceAsStream, "UTF-8");
+ LineNumberReader reader = new LineNumberReader(isReader);
+ String line;
+ StringBuffer currentModificator = new StringBuffer("");
+ int bracketCounter=0;
+ boolean modificatorStart=false;
+ while ((line = reader.readLine()) != null)
+ {
+ if(osWriter!=null)
+ {
+ writer.newLine();
+ writer.append(line);
+ }
+ line = IHLUtils.trim(line);
+ if (!line.isEmpty() && !line.startsWith("//") && !line.startsWith(";"))
+ {
+ currentModificator.append(line);
+ for(int i=0;i<line.length();i++)
+ {
+ char c = line.charAt(i);
+ if(c=='(')
+ {
+ bracketCounter++;
+ modificatorStart=true;
+ }
+ else if(c==')')
+ {
+ bracketCounter--;
+ }
+ if(bracketCounter==0 && modificatorStart)
+ {
+ processModificator(currentModificator.toString());
+ modificatorStart=false;
+ currentModificator.delete(0, currentModificator.length());
+ }
+ }
+ }
+ }
+ isReader.close();
+ if(osWriter!=null)
+ {
+ writer.newLine();
+ writer.newLine();
+ writer.append("//Available machines:");
+ writer.newLine();
+ writer.append("//ironworkbench");
+ Iterator<Entry<String, UniversalRecipeManager>> urmi = UniversalRecipeManager.machineRecipeManagers.entrySet().iterator();
+ while(urmi.hasNext())
+ {
+ writer.newLine();
+ writer.append("//"+urmi.next().getKey());
+ }
+ writer.close();
+ osWriter.close();
+ }
+ }
+
+ private void processModificator(String string)
+ {
+ String action = null;
+ String machineName = null;
+ String recipeInput = null;
+ String recipeOutput = null;
+ UniversalRecipeInput uRecipeInput = null;
+ UniversalRecipeOutput uRecipeOutput = null;
+ String[] functionAndParameters = extractFunctionAndParameters(string);
+ action=functionAndParameters[0].toLowerCase();
+ List<String> parameters = splitParameters(functionAndParameters[1]);
+ Iterator<String> parametersi=parameters.iterator();
+ while(parametersi.hasNext())
+ {
+ String parameter = parametersi.next();
+ if(parameter.equalsIgnoreCase("ironworkbench"))
+ {
+ machineName=parameter;
+ }
+ else if(UniversalRecipeManager.machineRecipeManagers.containsKey(parameter))
+ {
+ machineName=parameter;
+ }
+ else if(parameter.startsWith("recipeinput"))
+ {
+ recipeInput=parameter;
+ }
+ else if(parameter.startsWith("recipeoutput"))
+ {
+ recipeOutput=parameter;
+ }
+ }
+ List<IRecipeInput> recipeInputsItems = new ArrayList<IRecipeInput>();
+ List<IRecipeInput> recipeInputsTools = new ArrayList<IRecipeInput>();
+ List<ItemStack> recipeInputsMachines = new ArrayList<ItemStack>();
+ if(recipeInput!=null)
+ {
+ List<FluidStack> recipeInputsFluids = new ArrayList<FluidStack>();
+ String[] rifunctionAndParameters = extractFunctionAndParameters(recipeInput);
+ List<String> riparameters = splitParameters(rifunctionAndParameters[1]);
+ Iterator<String> riparametersi=riparameters.iterator();
+ while(riparametersi.hasNext())
+ {
+ String parameter = riparametersi.next();
+ String[] riItemFunctionAndParameters = extractFunctionAndParameters(parameter);
+ if(riItemFunctionAndParameters[0].startsWith("itemstack"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ String[] modAndItemName = riItemStackparameters.get(0).split(":");
+ int iDamage = 0;
+ int iQuantity = Integer.parseInt(riItemStackparameters.get(1));
+ String sDamage = riItemStackparameters.get(2);
+ if(sDamage.startsWith("hash"))
+ {
+ iDamage=extractFunctionAndParameters(sDamage)[1].hashCode() & Integer.MAX_VALUE;
+ }
+ else
+ {
+ iDamage=Integer.parseInt(sDamage);
+ }
+ recipeInputsItems.add(new RecipeInputItemStack(IHLUtils.getOtherModItemStackWithDamage(modAndItemName[0], modAndItemName[1], iDamage, iQuantity),iQuantity));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("die"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeInputsItems.add(new RecipeInputDie("setOfDies1_5sqmm", Integer.parseInt(riItemStackparameters.get(0))));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("fiber"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ ItemStack stack = IHLUtils.getThisModWireItemStackWithLength(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)));
+ recipeInputsItems.add(new RecipeInputWire(stack, Integer.parseInt(riItemStackparameters.get(1))));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("wire"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeInputsItems.add(new RecipeInputWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2))));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("cable"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeInputsItems.add(new RecipeInputWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2)),riItemStackparameters.get(3),Integer.parseInt(riItemStackparameters.get(4)),Integer.parseInt(riItemStackparameters.get(5))));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("oredict"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeInputsItems.add(new RecipeInputOreDict(riItemStackparameters.get(0),Integer.parseInt(riItemStackparameters.get(1))));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("fluidcontainer"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeInputsItems.add(new RecipeInputFluidContainer(FluidRegistry.getFluid(riItemStackparameters.get(0)),Integer.parseInt(riItemStackparameters.get(1))));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("toolitemstack"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ String[] modAndItemName = riItemStackparameters.get(0).split(":");
+ ItemStack stack = IHLUtils.getOtherModItemStackWithDamage(modAndItemName[0], modAndItemName[1], Integer.parseInt(riItemStackparameters.get(2)), Integer.parseInt(riItemStackparameters.get(1)));
+ stack.stackTagCompound = new NBTTagCompound();
+ NBTTagCompound gtTagCompound = new NBTTagCompound();
+ gtTagCompound.setInteger("Damage",0);
+ gtTagCompound.setInteger("MaxDamage",2000);
+ stack.stackTagCompound.setTag("GT.ToolStats", gtTagCompound);
+ recipeInputsTools.add(new RecipeInputItemStack(stack,stack.stackSize));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("tooloredict"))
+ {
+ recipeInputsTools.add(new RecipeInputOreDict(splitParameters(riItemFunctionAndParameters[1]).get(0)));
+
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("machine"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ String[] modAndItemName = riItemStackparameters.get(0).split(":");
+ recipeInputsMachines.add(IHLUtils.getThisModItemStack(modAndItemName[1]));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("fluidstack"))
+ {
+ List<String> riFluidStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeInputsFluids.add(IHLUtils.getFluidStackWithSize(riFluidStackparameters.get(0),Integer.parseInt(riFluidStackparameters.get(1))));
+ }
+ }
+ uRecipeInput = new UniversalRecipeInput(recipeInputsFluids.toArray(),recipeInputsItems.toArray());
+ }
+ List<ItemStack> recipeOutputsItems = new ArrayList<ItemStack>();
+ List<RecipeOutputItemStack> recipeOutputsRecipeOut = new ArrayList<RecipeOutputItemStack>();
+ if(recipeOutput!=null)
+ {
+ List<FluidStack> recipeOutputsFluids = new ArrayList<FluidStack>();
+ String[] rifunctionAndParameters = extractFunctionAndParameters(recipeOutput);
+ List<String> riparameters = splitParameters(rifunctionAndParameters[1]);
+ Iterator<String> riparametersi=riparameters.iterator();
+ while(riparametersi.hasNext())
+ {
+ String parameter = riparametersi.next();
+ String[] riItemFunctionAndParameters = extractFunctionAndParameters(parameter);
+ if(riItemFunctionAndParameters[0].startsWith("itemstack"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ String[] modAndItemName = riItemStackparameters.get(0).split(":");
+ String sDamage = riItemStackparameters.get(2);
+ int iDamage = 0;
+ if(sDamage.startsWith("hash"))
+ {
+ iDamage=extractFunctionAndParameters(sDamage)[1].hashCode() & Integer.MAX_VALUE;
+ }
+ else
+ {
+ iDamage=Integer.parseInt(sDamage);
+ }
+ ItemStack stack = IHLUtils.getOtherModItemStackWithDamage(modAndItemName[0], modAndItemName[1], iDamage,Integer.parseInt(riItemStackparameters.get(1)));
+ if(stack==null)
+ {
+ throw new java.lang.IllegalArgumentException("Item not found: "+parameter);
+ }
+ if(riItemStackparameters.size()>3){
+ stack.stackTagCompound = new NBTTagCompound();
+ String[] fp = extractFunctionAndParameters(riItemStackparameters.get(3));
+ Iterator<String> iparams2 = splitParameters(fp[1]).iterator();
+ while(iparams2.hasNext()){
+ decodeNBT(iparams2.next(), stack.stackTagCompound);
+ }
+ }
+ recipeOutputsItems.add(stack);
+ recipeOutputsRecipeOut.add(new RecipeOutputItemStack(stack.copy(),Float.parseFloat(riItemStackparameters.get(1))));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("fiber"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeOutputsItems.add(IHLUtils.getThisModWireItemStackWithLength(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1))));
+ recipeOutputsRecipeOut.add(new RecipeOutputItemStack(IHLUtils.getThisModWireItemStackWithLength(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1))),1));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("wire"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeOutputsItems.add(IHLUtils.getUninsulatedWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2))));
+ recipeOutputsRecipeOut.add(new RecipeOutputItemStack(IHLUtils.getUninsulatedWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2))),1));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("cable"))
+ {
+ List<String> riItemStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeOutputsItems.add(IHLUtils.getInsulatedWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2)),riItemStackparameters.get(3),Integer.parseInt(riItemStackparameters.get(4))));
+ recipeOutputsRecipeOut.add(new RecipeOutputItemStack(IHLUtils.getInsulatedWire(riItemStackparameters.get(0), Integer.parseInt(riItemStackparameters.get(1)), Integer.parseInt(riItemStackparameters.get(2)),riItemStackparameters.get(3),Integer.parseInt(riItemStackparameters.get(4))),1));
+ }
+ else if(riItemFunctionAndParameters[0].startsWith("fluidstack"))
+ {
+ List<String> riFluidStackparameters = splitParameters(riItemFunctionAndParameters[1]);
+ recipeOutputsFluids.add(IHLUtils.getFluidStackWithSize(riFluidStackparameters.get(0),Integer.parseInt(riFluidStackparameters.get(1))));
+ }
+ }
+ uRecipeOutput = new UniversalRecipeOutput(recipeOutputsFluids,recipeOutputsRecipeOut, 200);
+ }
+ if(action.equalsIgnoreCase("addrecipe"))
+ {
+ if(machineName.equalsIgnoreCase("ironworkbench"))
+ {
+ IronWorkbenchTileEntity.addRecipe(new IronWorkbenchRecipe(recipeInputsTools,recipeInputsItems, recipeOutputsItems, recipeInputsMachines));
+ }
+ else
+ {
+ UniversalRecipeManager.machineRecipeManagers.get(machineName).addRecipe(uRecipeInput, uRecipeOutput);
+ }
+ }
+ else if(action.equalsIgnoreCase("addcasting"))
+ {
+ IHLMod.moltenAmounts.put(parameters.get(0),Integer.parseInt(parameters.get(1)));
+ }
+ else if(action.equalsIgnoreCase("removerecipe"))
+ {
+ if(machineName.equalsIgnoreCase("ironworkbench"))
+ {
+ if(recipeInputsTools.isEmpty() && recipeInputsItems.isEmpty() && recipeInputsMachines.isEmpty())
+ {
+ IronWorkbenchTileEntity.removeRecipeByOutput(recipeOutputsItems);
+ }
+ else
+ {
+ IronWorkbenchTileEntity.removeRecipeByInput(recipeInputsTools,recipeInputsItems, recipeInputsMachines);
+ }
+ }
+ else
+ {
+ if(uRecipeInput==null)
+ {
+ UniversalRecipeManager.machineRecipeManagers.get(machineName).removeRecipeByOutput(uRecipeOutput);
+ }
+ else
+ {
+ UniversalRecipeManager.machineRecipeManagers.get(machineName).removeRecipeByInput(uRecipeInput);
+ }
+ }
+ }
+ }
+
+ private void decodeNBT(String string, NBTTagCompound out) {
+ String[] fp = extractFunctionAndParameters(string);
+ List<String> params = splitParameters(fp[1]);
+ if(fp[0].equalsIgnoreCase("string")){
+ out.setString(params.get(0), params.get(1));
+ }
+ else if(fp[0].equalsIgnoreCase("boolean")){
+ out.setBoolean(params.get(0), Boolean.getBoolean(params.get(1)));
+ }
+ else if(fp[0].equalsIgnoreCase("float")){
+ out.setFloat(params.get(0), Float.parseFloat(params.get(1)));
+ }
+ else if(fp[0].equalsIgnoreCase("double")){
+ out.setDouble(params.get(0), Double.parseDouble(params.get(1)));
+ }
+ else if(fp[0].equalsIgnoreCase("integer")){
+ out.setInteger(params.get(0), Integer.parseInt(params.get(1)));
+ }
+ else if(fp[0].equalsIgnoreCase("long")){
+ out.setLong(params.get(0), Long.parseLong(params.get(1)));
+ }
+ else if(fp[0].equalsIgnoreCase("nbt")){
+ NBTTagCompound out2 = new NBTTagCompound();
+ for(int i = 1; i < params.size(); i++){
+ decodeNBT(params.get(i), out2);
+ }
+ out.setTag(params.get(0), out2);
+ }
+ }
+
+
+
+ private List<String> splitParameters(String string) {
+ ArrayList<String> result = new ArrayList<String>();
+ int bracketCounter=0;
+ boolean modificatorStart=false;
+ StringBuffer currentModificator = new StringBuffer("");
+ for(int i=0;i<string.length();i++)
+ {
+ char c = string.charAt(i);
+ if(c==',')
+ {
+ if(!modificatorStart) {
+ result.add(currentModificator.toString());
+ currentModificator.delete(0, currentModificator.length());
+ }
+ } else if(c=='(') {
+ bracketCounter++;
+ modificatorStart=true;
+ } else if(c==')') {
+ bracketCounter--;
+ }
+ if(bracketCounter==0 && modificatorStart) {
+ modificatorStart=false;
+ }
+ if(c!=',' || modificatorStart) {
+ currentModificator.append(c);
+ }
+ }
+ result.add(currentModificator.toString());
+ return result;
+ }
+
+ private String[] extractFunctionAndParameters(String string) {
+ int bracketCounter=0;
+ boolean modificatorStart=false;
+ String function = null;
+ String parameters = null;
+ StringBuffer currentModificator = new StringBuffer("");
+ for(int i=0;i<string.length();i++)
+ {
+ char c = string.charAt(i);
+ if(c=='(')
+ {
+ bracketCounter++;
+ if(!modificatorStart)
+ {
+ function=currentModificator.toString();
+ currentModificator.delete(0, currentModificator.length());
+ modificatorStart=true;
+ }
+ }
+ else if(c==')')
+ {
+ bracketCounter--;
+ }
+ if(bracketCounter==0 && modificatorStart)
+ {
+ parameters=currentModificator.substring(1, currentModificator.length());
+ break;
+ }
+ currentModificator.append(c);
+ }
+ return new String[] {function,parameters};
+ }
+
+
+ private void loadRecipeConfig(File configFile) throws IOException
+ {
+ FileInputStream is = new FileInputStream(configFile);
+ loadRecipeConfig(is, false);
+ }
+
+ private static File getFile()
+ {
+ File folder = new File(IHLMod.proxy.getMinecraftDir(), "config");
+ folder.mkdirs();
+ return new File(folder, "ihl-recipe.cfg");
+ }
+
+ public void loadRecipeModificators() throws IOException
+ {
+ File configFile = getFile();
+ if (configFile.exists())
+ {
+ loadRecipeConfig(configFile);
+ }
+ else
+ {
+ InputStream inputStream = IHLMod.class.getResourceAsStream("/assets/ihl/config/ihl-recipe.cfg");
+ loadRecipeConfig(inputStream, true);
+ }
+
+ }
+}
diff --git a/src/main/java/ihl/IHLModInfo.java b/src/main/java/ihl/IHLModInfo.java new file mode 100644 index 0000000..9b63351 --- /dev/null +++ b/src/main/java/ihl/IHLModInfo.java @@ -0,0 +1,7 @@ +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.655";
+}
diff --git a/src/main/java/ihl/ServerProxy.java b/src/main/java/ihl/ServerProxy.java new file mode 100644 index 0000000..d22751c --- /dev/null +++ b/src/main/java/ihl/ServerProxy.java @@ -0,0 +1,338 @@ +package ihl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent;
+import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent;
+import cpw.mods.fml.common.network.FMLEventChannel;
+import cpw.mods.fml.common.network.FMLNetworkEvent;
+import cpw.mods.fml.common.network.NetworkRegistry;
+import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
+import cpw.mods.fml.common.network.internal.FMLProxyPacket;
+import ihl.flexible_cable.NodeEntity;
+import ihl.interfaces.INetworkListener;
+import ihl.items_blocks.FlexibleCableItem;
+import ihl.items_blocks.MachineBaseBlock.MachineType;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufInputStream;
+import io.netty.buffer.ByteBufOutputStream;
+import io.netty.buffer.Unpooled;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import net.minecraftforge.client.event.TextureStitchEvent.Pre;
+import net.minecraftforge.event.world.BlockEvent.BreakEvent;
+import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
+
+public class ServerProxy {
+
+ protected static FMLEventChannel channel;
+ public static final int updatePeriod = 1;
+ protected Map<Integer, INetworkListener> entityList = new HashMap<Integer, INetworkListener>();
+ protected Set<INetworkListener> entityServerList = new HashSet<INetworkListener>();
+ protected Map<Integer, ByteBuf> delayedEntityDataPacket = new HashMap<Integer, ByteBuf>();
+ public Map<Integer,Set<NodeEntity>> nodeEntityRegistry = new HashMap<Integer,Set<NodeEntity>>();
+
+ public ServerProxy() {}
+
+ public void load() throws ParserConfigurationException
+ {
+ if(channel==null)
+ {
+ channel = NetworkRegistry.INSTANCE.newEventDrivenChannel(IHLModInfo.MODID);
+ channel.register(this);
+ }
+ }
+ public void spawnParticle(int particle, World world, double x, double y, double z, double mx, double my, double mz, float paticleScale){}
+
+ public void spawnParticleFromServer(int particle, World world, double x, double y, double z, double mx, double my, double mz, float paticleScale)
+ {
+ ByteBuf bb = Unpooled.buffer(36);
+ ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb);
+ try
+ {
+ byteBufOutputStream.write(0);
+ byteBufOutputStream.write(particle);
+ byteBufOutputStream.writeFloat((float) x);
+ byteBufOutputStream.writeFloat((float) y);
+ byteBufOutputStream.writeFloat((float) z);
+ byteBufOutputStream.writeFloat((float) mx);
+ byteBufOutputStream.writeFloat((float) my);
+ byteBufOutputStream.writeFloat((float) mz);
+ byteBufOutputStream.writeFloat(paticleScale);
+ channel.sendToAllAround(new FMLProxyPacket(byteBufOutputStream.buffer(),IHLModInfo.MODID), new TargetPoint(world.provider.dimensionId, x, y, z, 32d));
+ byteBufOutputStream.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void playSoundEffectFromServer(int soundId, World world, double x, double y, double z, float volume, float pitch)
+ {
+ ByteBuf bb = Unpooled.buffer(36);
+ ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb);
+ try
+ {
+ byteBufOutputStream.write(3);
+ byteBufOutputStream.write(soundId);
+ byteBufOutputStream.writeFloat((float) x);
+ byteBufOutputStream.writeFloat((float) y);
+ byteBufOutputStream.writeFloat((float) z);
+ byteBufOutputStream.writeFloat(volume);
+ byteBufOutputStream.writeFloat(pitch);
+ channel.sendToAllAround(new FMLProxyPacket(byteBufOutputStream.buffer(),IHLModInfo.MODID), new TargetPoint(world.provider.dimensionId, x, y, z, volume+32d));
+ byteBufOutputStream.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void createExplosionEffectFromServer(World world, int x, int y, int z, float radius)
+ {
+ ByteBuf bb = Unpooled.buffer(36);
+ ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb);
+ try
+ {
+ byteBufOutputStream.write(2);
+ byteBufOutputStream.writeInt(x);
+ byteBufOutputStream.writeInt(y);
+ byteBufOutputStream.writeInt(z);
+ byteBufOutputStream.writeFloat(radius);
+ channel.sendToAllAround(new FMLProxyPacket(byteBufOutputStream.buffer(),IHLModInfo.MODID), new TargetPoint(world.provider.dimensionId, x, y, z, radius+32d));
+ byteBufOutputStream.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void registerIcons(Pre event) {}
+ public void initBlockRenderer(){}
+ public Object getRenderForEntityClass(Class<? extends Entity> entityClass)
+ {
+ return null;
+ }
+ public int getGLDisplayList() {return -1;}
+
+ public File getMinecraftDir()
+ {
+ return new File(".");
+ }
+ public int shareBlockRendererByMachineType(MachineType type)
+ {
+ return 0;
+ }
+
+ public void addEntityToList(INetworkListener entity)
+ {
+ this.entityList.put(entity.getId(), entity);
+ }
+
+ public void recieveDelayedDataPacket(INetworkListener listener)
+ {
+ ByteBuf data = delayedEntityDataPacket.remove(listener.getId());
+ if(data!=null)
+ {
+ ByteBufInputStream byteBufInputStream = new ByteBufInputStream(data);
+ try
+ {
+ //byteBufInputStream.skipBytes(5);
+ listener.recieveData(byteBufInputStream);
+ byteBufInputStream.close();
+ IHLMod.log.debug("Delayed data read.");
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ IHLMod.log.debug("Delayed data is null. Entity ID="+listener.getId());
+ }
+ }
+
+ public void sendFromServerToAll(FMLProxyPacket fmlProxyPacket)
+ {
+ channel.sendToAll(fmlProxyPacket);
+ }
+
+ public void sendFromServerToPlayer(FMLProxyPacket fmlProxyPacket, EntityPlayerMP player)
+ {
+ channel.sendTo(fmlProxyPacket, player);
+ }
+
+ @SubscribeEvent
+ public void onPacketFromClientToServer(FMLNetworkEvent.ServerCustomPacketEvent event) throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException
+ {
+ ByteBuf data = event.packet.payload();
+ ByteBufInputStream byteBufInputStream = new ByteBufInputStream(data);
+ switch(byteBufInputStream.read())
+ {
+ case 0:
+ int playerEntityId = byteBufInputStream.readInt();
+ int worldDimensionId = byteBufInputStream.readInt();
+ int containerSlotNumber = byteBufInputStream.readInt();
+ int fieldValue = byteBufInputStream.readInt();
+ String fieldName = byteBufInputStream.readUTF();
+ EntityPlayerMP player = (EntityPlayerMP) MinecraftServer.getServer().worldServerForDimension(worldDimensionId).getEntityByID(playerEntityId);
+ ItemStack stack = ((Slot)player.openContainer.inventorySlots.get(containerSlotNumber)).getStack();
+ stack.stackTagCompound.setInteger(fieldName, fieldValue);
+ player.openContainer.detectAndSendChanges();
+ break;
+ case 1:
+ playerEntityId = byteBufInputStream.readInt();
+ worldDimensionId = byteBufInputStream.readInt();
+ int x = byteBufInputStream.readInt();
+ int y = byteBufInputStream.readInt();
+ int z = byteBufInputStream.readInt();
+ World world = MinecraftServer.getServer().worldServerForDimension(worldDimensionId);
+ TileEntity te = world.getTileEntity(x, y, z);
+ if(te!=null && !te.isInvalid())
+ {
+ NBTTagCompound nbt = new NBTTagCompound();
+ te.writeToNBT(nbt);
+ player = (EntityPlayerMP) world.getEntityByID(playerEntityId);
+ 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();
+
+ }
+
+ @SubscribeEvent
+ public void onPlayerConnectedToServer(PlayerLoggedInEvent event)
+ {
+ IHLMod.log.debug("player connected");
+ Iterator<INetworkListener> inli=this.entityServerList.iterator();
+ while(inli.hasNext())
+ {
+ INetworkListener inl = inli.next();
+ if(inl.isInvalid())
+ {
+ inli.remove();
+ }
+ else if(event.player instanceof EntityPlayerMP)
+ {
+ inl.registerAndSendData((EntityPlayerMP)event.player);
+ }
+ }
+ }
+
+ @SubscribeEvent
+ public void onPlayerTeleport(PlayerChangedDimensionEvent event)
+ {
+ FlexibleCableItem.instance.onPlayerTeleport(event);
+ Iterator<INetworkListener> inli=this.entityServerList.iterator();
+ while(inli.hasNext())
+ {
+ INetworkListener inl = inli.next();
+ if(inl.isInvalid())
+ {
+ inli.remove();
+ }
+ else if(event.player instanceof EntityPlayerMP)
+ {
+ inl.registerAndSendData((EntityPlayerMP)event.player);
+ }
+ }
+ }
+ @SubscribeEvent
+ public void onBlockBreak(BreakEvent event) {
+ int x = event.x;
+ int y = event.y;
+ int z = event.z;
+ ByteBuf bb = Unpooled.buffer(20);
+ ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb);
+ try
+ {
+ byteBufOutputStream.write(4);
+ byteBufOutputStream.writeInt(x);
+ byteBufOutputStream.writeInt(y);
+ byteBufOutputStream.writeInt(z);
+ channel.sendToAllAround(new FMLProxyPacket(byteBufOutputStream.buffer(),IHLModInfo.MODID), new TargetPoint(event.world.provider.dimensionId, x, y, z, 256d));
+ byteBufOutputStream.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @SubscribeEvent
+ public void onBlockPlace(PlaceEvent event) {
+ int x = event.x;
+ int y = event.y;
+ int z = event.z;
+ ByteBuf bb = Unpooled.buffer(20);
+ ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb);
+ try
+ {
+ byteBufOutputStream.write(5);
+ byteBufOutputStream.writeInt(x);
+ byteBufOutputStream.writeInt(y);
+ byteBufOutputStream.writeInt(z);
+ channel.sendToAllAround(new FMLProxyPacket(byteBufOutputStream.buffer(),IHLModInfo.MODID), new TargetPoint(event.world.provider.dimensionId, x, y, z, 256d));
+ byteBufOutputStream.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+
+ public void addEntityToServerList(INetworkListener entity)
+ {
+ this.entityServerList.add(entity);
+ }
+
+ public boolean renderTESpecialSelectionBox(TileEntity te, EntityPlayer player, ItemStack currentItem, MovingObjectPosition target, float partialTicks) {
+ return false;
+ }
+
+ public void sendItemStackNBTTagFromClientToServerPlayer(EntityPlayer player, int slotNumber, String fieldName, int fieldValue){}
+
+ public void createExplosionEffect(World world, int x, int y, int z, float radius){}
+
+ public void requestTileEntityInitdataFromClientToServer(int x, int y, int z){}
+
+}
diff --git a/src/main/java/ihl/crop_harvestors/BlobEntityFX.java b/src/main/java/ihl/crop_harvestors/BlobEntityFX.java new file mode 100644 index 0000000..60a3ad9 --- /dev/null +++ b/src/main/java/ihl/crop_harvestors/BlobEntityFX.java @@ -0,0 +1,84 @@ +package ihl.crop_harvestors;
+
+import net.minecraft.client.particle.EntityFX;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.world.World;
+
+public class BlobEntityFX extends EntityFX {
+
+ public FluidType fluid = FluidType.RESIN;
+
+ public BlobEntityFX(World world, double x, double y, double z)
+ {
+ super(world, x, y, z);
+ this.noClip = true;
+ }
+
+ public BlobEntityFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14, FluidType fluid1)
+ {
+ super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D);
+ this.motionX *= 0.1D;
+ this.motionY *= 0.1D;
+ this.motionZ *= 0.1D;
+ this.motionX += par8;
+ this.motionY += par10;
+ this.motionZ += par12;
+ this.particleScale *= par14;
+ this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D));
+ this.noClip = true;
+ fluid=fluid1;
+ }
+
+ @Override
+ public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
+ {
+ float var8 = ((float)this.particleAge) / (float)this.particleMaxAge * 32.0F;
+
+ if (var8 < 0.0F)
+ {
+ var8 = 0.0F;
+ }
+
+ if (var8 > 1.0F)
+ {
+ var8 = 1.0F;
+ }
+ this.renderParticle2(par1Tessellator, par2, par3, par4, par5, par6, par7);
+ }
+
+ public void renderParticle2(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
+ {
+ float var12 = 0.1F * this.particleScale;
+ float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
+ float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
+ float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
+ par1Tessellator.addVertexWithUV(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12, 1D, 1D);
+ par1Tessellator.addVertexWithUV(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12, 1D, 0D);
+ par1Tessellator.addVertexWithUV(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12, 0D, 0D);
+ par1Tessellator.addVertexWithUV(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12, 0D, 1D);
+ }
+
+ @Override
+ public void onUpdate()
+ {
+ this.prevPosX = this.posX;
+ this.prevPosY = this.posY;
+ this.prevPosZ = this.posZ;
+
+ if (this.particleAge++ >= this.particleMaxAge)
+ {
+ this.setDead();
+ }
+ this.motionX *= 0.5D;
+ this.motionZ *= 0.5D;
+ this.moveEntity(this.motionX, this.motionY, this.motionZ);
+ this.motionY -= 0.001D;
+ this.motionY *= 0.96D;
+ }
+
+ public enum FluidType
+ {
+ SAP,
+ RESIN
+ }
+}
diff --git a/src/main/java/ihl/crop_harvestors/BlobRenderFX.java b/src/main/java/ihl/crop_harvestors/BlobRenderFX.java new file mode 100644 index 0000000..ed54869 --- /dev/null +++ b/src/main/java/ihl/crop_harvestors/BlobRenderFX.java @@ -0,0 +1,64 @@ +package ihl.crop_harvestors;
+
+import org.lwjgl.opengl.GL11;
+
+import ihl.IHLModInfo;
+import net.minecraft.client.particle.EntityFX;
+import net.minecraft.client.renderer.ActiveRenderInfo;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.entity.Entity;
+import net.minecraft.util.ResourceLocation;
+
+public class BlobRenderFX extends Render{
+ private ResourceLocation tex, tex2;
+
+public BlobRenderFX()
+{
+ super();
+ tex = new ResourceLocation(IHLModInfo.MODID+":textures/particles/blob.png");
+ tex2 = new ResourceLocation(IHLModInfo.MODID+":textures/particles/blobOfResin.png");
+}
+
+@Override
+public void doRender(Entity entity, double x, double y, double z,
+ float arg4, float arg5)
+{
+ float var3 = ActiveRenderInfo.rotationX;
+ float var4 = ActiveRenderInfo.rotationZ;
+ float var5 = ActiveRenderInfo.rotationYZ;
+ float var6 = ActiveRenderInfo.rotationXY;
+ float var7 = ActiveRenderInfo.rotationXZ;
+ EntityFX.interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * arg4;
+ EntityFX.interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * arg4;
+ EntityFX.interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * arg4;
+ if(((BlobEntityFX)entity).fluid==BlobEntityFX.FluidType.RESIN)
+ {
+ this.renderManager.renderEngine.bindTexture(tex);
+ }
+ else
+ {
+ this.renderManager.renderEngine.bindTexture(tex2);
+ }
+ GL11.glPushMatrix();
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GL11.glTranslatef((float)x, (float)y, (float)z);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
+ Tessellator var9 = Tessellator.instance;
+ var9.startDrawingQuads();
+ EntityFX var11 = (EntityFX) entity;
+ var11.renderParticle(var9, arg4, var3, var7, var4, var5, var6);
+ var9.draw();
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
+ GL11.glPopMatrix();
+}
+
+ @Override
+ protected ResourceLocation getEntityTexture(Entity arg0)
+ {
+ return tex;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/crop_harvestors/RubberTreeBlock.java b/src/main/java/ihl/crop_harvestors/RubberTreeBlock.java new file mode 100644 index 0000000..9cfdea1 --- /dev/null +++ b/src/main/java/ihl/crop_harvestors/RubberTreeBlock.java @@ -0,0 +1,165 @@ +package ihl.crop_harvestors;
+
+import java.util.Random;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.IC2Items;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class RubberTreeBlock extends Block{
+
+ IIcon textureSide, textureTop;
+ TreeType type;
+
+ public RubberTreeBlock(TreeType type1)
+ {
+ super(Material.wood);
+ type=type1;
+ }
+
+ @Override
+ public Item getItemDropped(int var1, Random rnd, int var2)
+ {
+ switch(type)
+ {
+ case RUBBERTREE:
+ return IC2Items.getItem("rubberWood").getItem();
+ case SPRUCE:
+ return Blocks.log.getItemDropped(var1, rnd, var2);
+ default:
+ return IC2Items.getItem("rubberWood").getItem();
+ }
+
+ }
+
+ @Override
+ public boolean canSustainLeaves(IBlockAccess blockAccess, int x, int y, int z)
+ {
+ return true;
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
+ {
+ ItemStack result;
+ switch(type)
+ {
+ case RUBBERTREE:
+ result = IC2Items.getItem("rubberWood").copy();
+ case SPRUCE:
+ result = new ItemStack(Blocks.log,1,1);
+ default:
+ result = IC2Items.getItem("rubberWood").copy();
+ }
+ this.dropBlockAsItem(world, x, y, z, result);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ switch(type)
+ {
+ case RUBBERTREE:
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockRubWoodFront");
+ this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockRubWoodTop");
+ this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockRubWoodSide");
+ case SPRUCE:
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":blockSpruceFront");
+ this.textureTop = par1IconRegister.registerIcon("minecraft:log_spruce_top");
+ this.textureSide = par1IconRegister.registerIcon("minecraft:log_spruce");
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
+ {
+ int facing=3;
+ int mask[] = {
+ 0,1,2,3,4,5,
+ 1,0,3,2,4,5,
+ 3,2,0,1,4,5,
+ 2,3,1,0,4,5,
+ 2,3,5,4,0,1,
+ 2,3,4,5,1,0
+ };
+ facing=world.getBlockMetadata(x, y, z);
+ switch (mask[facing*6+side])
+ {
+ case 0:
+ return this.textureSide;
+ case 1:
+ return this.blockIcon;
+ case 2:
+ return this.textureTop;
+ case 3:
+ return this.textureTop;
+ case 4:
+ return this.textureSide;
+ case 5:
+ return this.textureSide;
+ default:
+ return this.textureSide;
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta)
+ {
+ switch (side)
+ {
+ case 0:
+ return this.textureTop;
+ case 1:
+ return this.textureTop;
+ case 2:
+ return this.blockIcon;
+ case 3:
+ return this.textureSide;
+ case 4:
+ return this.textureSide;
+ case 5:
+ return this.textureSide;
+ default:
+ return this.textureSide;
+ }
+ }
+
+ public enum TreeType
+ {
+ RUBBERTREE,
+ SPRUCE
+ }
+
+ @Override
+ public boolean isWood(IBlockAccess world, int x, int y, int z)
+ {
+ return true;
+ }
+
+ @Override
+ public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face)
+ {
+ return 4;
+ }
+
+ @Override
+ public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face)
+ {
+ return 20;
+ }
+
+}
diff --git a/src/main/java/ihl/crop_harvestors/SackBlock.java b/src/main/java/ihl/crop_harvestors/SackBlock.java new file mode 100644 index 0000000..7972dc1 --- /dev/null +++ b/src/main/java/ihl/crop_harvestors/SackBlock.java @@ -0,0 +1,169 @@ +package ihl.crop_harvestors;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+
+public class SackBlock extends Block implements ITileEntityProvider{
+
+ public SackBlock(Material material)
+ {
+ super(material);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ return new SackTileEntity();
+ }
+
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":sackItem");
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity)
+ {
+ this.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 0.1F, 0.8F);
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ this.setBlockBounds(0.2F, 0.0F, 0.2F, 0.21F, 1.0F, 0.8F);
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ this.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 1.0F, 0.21F);
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ this.setBlockBounds(0.79F, 0.0F, 0.0F, 0.8F, 1.0F, 0.8F);
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ this.setBlockBounds(0.0F, 0.0F, 0.79F, 0.8F, 1.0F, 0.8F);
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ this.setBlockBoundsForItemRender();
+ }
+
+ @Override
+ public void setBlockBoundsForItemRender()
+ {
+ this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
+ }
+
+ @Override
+ public boolean hasTileEntity(int metadata)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){
+ TileEntity te = world.getTileEntity(x,y,z);
+ if(!world.isRemote && te instanceof SackTileEntity)
+ {
+ SackTileEntity ste = (SackTileEntity)te;
+ if (ste == null || entityPlayer.isSneaking()) {
+ return false;
+ }
+ else
+ {
+ if(ste.fluidTank.getFluid()!=null)
+ {
+ if(entityPlayer.inventory.getCurrentItem()!=null)
+ {
+ if(entityPlayer.inventory.getCurrentItem().getItem() instanceof IFluidContainerItem)
+ {
+ return false;
+ }
+ FluidStack drainFS = ste.drain(ForgeDirection.UNKNOWN, ste.fluidTank.getCapacity(), false);
+ ItemStack stackToAdd = FluidContainerRegistry.fillFluidContainer(drainFS, entityPlayer.inventory.getCurrentItem());
+ if(stackToAdd!=null)
+ {
+ if (entityPlayer.inventory.addItemStackToInventory(stackToAdd))
+ {
+ entityPlayer.inventory.getCurrentItem().stackSize--;
+ entityPlayer.inventoryContainer.detectAndSendChanges();
+ ste.drain(ForgeDirection.UNKNOWN, FluidContainerRegistry.getContainerCapacity(stackToAdd),true);
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * The type of render function that is called for this block
+ */
+ @Override
+ public int getRenderType()
+ {
+ return -2;
+ }
+
+ /**
+ * Is this block (a) opaque and (B) a full 1m cube? This determines whether or not to render the shared face of two
+ * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
+ */
+ @Override
+ public boolean isOpaqueCube()
+ {
+ return false;
+ }
+
+ /**
+ * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
+ */
+ @Override
+ public boolean renderAsNormalBlock()
+ {
+ return false;
+ }
+
+ @Override
+ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack)
+ {
+ int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+ TileEntity t = world.getTileEntity(x, y, z);
+ if(t!=null && t instanceof SackTileEntity)
+ {
+ SackTileEntity te = (SackTileEntity)t;
+ switch(var7)
+ {
+ case 0:
+ te.setFacing((short) 3);
+ break;
+ case 1:
+ te.setFacing((short) 4);
+ break;
+ case 2:
+ te.setFacing((short) 2);
+ break;
+ case 3:
+ te.setFacing((short) 5);
+ break;
+ default:
+ break;
+ }
+
+ }
+ }
+}
diff --git a/src/main/java/ihl/crop_harvestors/SackModel.java b/src/main/java/ihl/crop_harvestors/SackModel.java new file mode 100644 index 0000000..a0fe780 --- /dev/null +++ b/src/main/java/ihl/crop_harvestors/SackModel.java @@ -0,0 +1,103 @@ +package ihl.crop_harvestors;
+
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.model.ModelRenderer;
+import net.minecraft.entity.Entity;
+
+public class SackModel extends ModelBase {
+ //fields
+ ModelRenderer Base;
+ ModelRenderer Top;
+ ModelRenderer Liquid;
+ ModelRenderer Liquid_overflow;
+ ModelRenderer Liquid2;
+ ModelRenderer Liquid2_overflow;
+ ModelRenderer Rope1;
+ ModelRenderer Rope2;
+
+ public SackModel()
+ {
+ textureWidth = 64;
+ textureHeight = 64;
+ setTextureOffset("Base.Shape1", 0, 0);
+ setTextureOffset("Base.Shape2", 0, 0);
+ setTextureOffset("Base.Shape3", 0, 0);
+ setTextureOffset("Base.Shape4", 0, 0);
+ setTextureOffset("Base.Shape5", 0, 0);
+ setTextureOffset("Top.Shape6", 0, 0);
+ setTextureOffset("Top.Shape7", 0, 0);
+ setTextureOffset("Top.Shape8", 0, 0);
+ setTextureOffset("Liquid.Shape9", 20, 20);
+ setTextureOffset("Liquid_overflow.Shape12", 46, 25);
+ setTextureOffset("Rope1.Shape12", 56, 17);
+ setTextureOffset("Rope2.Shape13", 48, 17);
+
+ setTextureOffset("Liquid2.Shape14", 0, 32);
+ setTextureOffset("Liquid2_overflow.Shape15", 46, 57);
+
+ Base = new ModelRenderer(this, "Base");
+ Base.setRotationPoint(0F, 8F, 0F);
+ setRotation(Base, 0F, 0F, 0F);
+ Base.mirror = true;
+ Base.addBox("Shape1", -6F, 15F, -4F, 12, 1, 12);
+ Base.addBox("Shape2", -6F, 2F, -4F, 12, 13, 1);
+ Base.addBox("Shape3", -6F, 2F, -3F, 1, 13, 10);
+ Base.addBox("Shape4", 5F, 2F, -3F, 1, 13, 10);
+ Base.addBox("Shape5", -6F, 0F, 7F, 12, 15, 1);
+ Top = new ModelRenderer(this, "Top");
+ Top.setRotationPoint(0F, 9F, 0F);
+ setRotation(Top, 0.05F, 0F, 0F);
+ Top.mirror = true;
+ Top.addBox("Shape6", -6.2F, -0.5F, -4.4F, 1, 2, 12);
+ Top.addBox("Shape7", 5.2F, -0.5F, -4.4F, 1, 2, 12);
+ Top.addBox("Shape8", -6F, -0.4F, -4.5F, 12, 2, 1);
+ Liquid = new ModelRenderer(this, "Liquid");
+ Liquid.setRotationPoint(0F, 8F, 0F);
+ setRotation(Liquid, 0F, 0F, 0F);
+ Liquid.mirror = true;
+ Liquid.addBox("Shape9", -5.5F, 0.5F, -3.5F, 11, 1, 11);
+ Liquid_overflow = new ModelRenderer(this, "Liquid_overflow");
+ Liquid_overflow.setRotationPoint(0F, 8F, 0F);
+ setRotation(Liquid_overflow, 0.051F, 0F, 0.01F);
+ Liquid_overflow.mirror = true;
+ Liquid_overflow.addBox("Shape12", -4F, 0.55F, -4.4F, 8, 2, 2);
+
+ Liquid2 = new ModelRenderer(this, "Liquid2");
+ Liquid2.setRotationPoint(0F, 8F, 0F);
+ setRotation(Liquid2, 0F, 0F, 0F);
+ Liquid2.mirror = true;
+ Liquid2.addBox("Shape14", -5.5F, 0.5F, -3.5F, 11, 1, 11);
+ Liquid2_overflow = new ModelRenderer(this, "Liquid2_overflow");
+ Liquid2_overflow.setRotationPoint(0F, 8F, 0F);
+ setRotation(Liquid2_overflow, 0.051F, 0F, 0.01F);
+ Liquid2_overflow.mirror = true;
+ Liquid2_overflow.addBox("Shape15", -4F, 0.55F, -4.4F, 8, 2, 2);
+
+
+ Rope1 = new ModelRenderer(this, "Rope1");
+ Rope1.setRotationPoint(0F, 8F, 0F);
+ setRotation(Rope1, 0F, 0F, -0.2F);
+ Rope1.mirror = true;
+ Rope1.addBox("Shape12", 5F, 0.7F, 7.9F, 3, 1, 1);
+ Rope2 = new ModelRenderer(this, "Rope2");
+ Rope2.setRotationPoint(0F, 8F, 0F);
+ setRotation(Rope2, 0F, 0F, 0.2F);
+ Rope2.mirror = true;
+ Rope2.addBox("Shape13", -8F, 0.7F, 7.9F, 3, 1, 1);
+ }
+
+ private void setRotation(ModelRenderer model, float x, float y, float z)
+ {
+ model.rotateAngleX = x;
+ model.rotateAngleY = y;
+ model.rotateAngleZ = z;
+ }
+
+ @Override
+ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
+ {
+ super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
+ }
+}
+
+
diff --git a/src/main/java/ihl/crop_harvestors/SackRender.java b/src/main/java/ihl/crop_harvestors/SackRender.java new file mode 100644 index 0000000..31798b4 --- /dev/null +++ b/src/main/java/ihl/crop_harvestors/SackRender.java @@ -0,0 +1,95 @@ +package ihl.crop_harvestors;
+import org.lwjgl.opengl.GL11;
+
+import ihl.IHLModInfo;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.fluids.FluidRegistry;
+
+public class SackRender extends TileEntitySpecialRenderer{
+private SackModel model = new SackModel();
+private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/sack.png");
+private final float maxRenderLiquidLevel=0.5F;
+private final float minRenderLiquidLevel=14.5F;
+private final float scale=1F/16F;
+private float overflow=0F;
+
+
+public SackRender(){}
+
+public void renderAModelAt(SackTileEntity tile, double d, double d1, double d2, float f) {
+int rotation = 0;
+if(tile.getWorldObj() != null)
+{
+ switch (tile.getFacing())
+ {
+ case 2:
+ rotation = 0;
+ break;
+ case 5:
+ rotation = 1;
+ break;
+ case 3:
+ rotation = 2;
+ break;
+ case 4:
+ rotation = 3;
+ break;
+ default:
+ rotation = 0;
+ }
+}
+bindTexture(tex); //texture
+GL11.glPushMatrix();
+GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F);
+GL11.glScalef(1.0F, -1F, -1F);
+GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F);
+model.Base.render(scale);
+model.Top.render(scale);
+model.Rope1.render(scale);
+model.Rope2.render(scale);
+GL11.glEnable(GL11.GL_BLEND);
+GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+GL11.glColor4f(1f,1f,1f,1f);
+model.Liquid2.offsetY=model.Liquid.offsetY=(minRenderLiquidLevel-(minRenderLiquidLevel-maxRenderLiquidLevel)*tile.getRenderLiquidLevel())*scale;
+if(tile.getRenderLiquidLevel()>0)
+{
+ if(tile.visibleFluidId!=-1)
+ {
+ if(tile.visibleFluidId==FluidRegistry.getFluid("fluidrubbertreesap").getID())
+ {
+ model.Liquid.render(scale);
+ }
+ else if(tile.visibleFluidId==FluidRegistry.getFluid("spruceresin").getID())
+ {
+ model.Liquid2.render(scale);
+ }
+ }
+}
+if(tile.getRenderLiquidLevel()>0.98F)
+{
+ if(overflow<0.5F)overflow+=0.001F;
+ model.Liquid2_overflow.offsetZ=model.Liquid_overflow.offsetZ=-overflow*scale;
+ if(tile.visibleFluidId!=-1)
+ {
+ if(tile.visibleFluidId==FluidRegistry.getFluid("fluidrubbertreesap").getID())
+ {
+ model.Liquid_overflow.render(scale);
+ }
+ else if(tile.visibleFluidId==FluidRegistry.getFluid("spruceresin").getID())
+ {
+ model.Liquid2_overflow.render(scale);
+ }
+ }
+}
+GL11.glDisable(GL11.GL_BLEND);
+GL11.glPopMatrix(); //end
+}
+
+ @Override
+ public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
+ {
+ this.renderAModelAt((SackTileEntity)par1TileEntity, par2, par4, par6, par8);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/crop_harvestors/SackTileEntity.java b/src/main/java/ihl/crop_harvestors/SackTileEntity.java new file mode 100644 index 0000000..800b2c5 --- /dev/null +++ b/src/main/java/ihl/crop_harvestors/SackTileEntity.java @@ -0,0 +1,569 @@ +package ihl.crop_harvestors;
+
+import java.util.List;
+import java.util.Random;
+
+import ic2.core.IC2;
+import ic2.core.block.TileEntityInventory;
+import ihl.IHLMod;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+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.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+
+public class SackTileEntity extends TileEntityInventory implements IFluidHandler
+{
+ private final int maxLeavesHeight=12;
+ private final int maxLeavesWidth=5;
+ public float leavesCounter=0F;
+ private int updateCounter=1100;
+ private Random rand=new Random();
+ private int blobTimer=20;
+ public byte currentTree = RUBBERTREE;
+ public final int blobCapacity = 1;
+ private final static byte RUBBERTREE=0;
+ private final static byte SPRUCE=1;
+ public final IHLFluidTank fluidTank = new IHLFluidTank(8000);
+ public int visibleFluidId = -1;
+ public int visibleFluidAmount = 1;
+
+ public SackTileEntity() {
+ super();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ fields.add("visibleFluidId");
+ fields.add("visibleFluidAmount");
+ fields.add("leavesCounter");
+ fields.add("currentTree");
+ return fields;
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return false;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return new ItemStack(IHLMod.sackBlock,1);
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return true;
+ }
+
+
+ @Override
+ public void updateEntityClient()
+ {
+ super.updateEntityClient();
+ if(IHLMod.ic2Leaves!=null && IHLMod.ic2Wood!=null)
+ {
+ if(this.blobTimer<=0)
+ {
+ if(IC2.platform.isRendering())
+ {
+ switch(this.currentTree)
+ {
+ case RUBBERTREE:
+ IHLMod.proxy.spawnParticle(1,worldObj, xCoord+0.5D+mX()*0.5D,yCoord+1.05D,zCoord+0.5D+mZ()*0.5D,-(double)mX()*0.1D,-0.03D,-(double)mZ()*0.1D,0.1F);
+ break;
+ case SPRUCE:
+ IHLMod.proxy.spawnParticle(2,worldObj, xCoord+0.5D+mX()*0.5D,yCoord+1.05D,zCoord+0.5D+mZ()*0.5D,-(double)mX()*0.1D,-0.03D,-(double)mZ()*0.1D,0.1F);
+ break;
+ }
+ }
+ if(this.fluidTank.getFluidAmount()>=this.fluidTank.getCapacity())
+ {
+ if(IC2.platform.isRendering())
+ {
+ switch(this.currentTree)
+ {
+ case RUBBERTREE:
+ IHLMod.proxy.spawnParticle(1,worldObj, xCoord+0.5D-mX()*0.3D+(rand.nextDouble()-0.5D)*mZ()*0.6D,yCoord+0.8D,zCoord+0.5D-mZ()*0.3D+(rand.nextDouble()-0.5D)*mX()*0.6D,0D,-0.05D,0D,0.1F);
+ break;
+ case SPRUCE:
+ IHLMod.proxy.spawnParticle(2,worldObj, xCoord+0.5D-mX()*0.3D+(rand.nextDouble()-0.5D)*mZ()*0.6D,yCoord+0.8D,zCoord+0.5D-mZ()*0.3D+(rand.nextDouble()-0.5D)*mX()*0.6D,0D,-0.05D,0D,0.1F);
+ break;
+ }
+ }
+ }
+ if(this.leavesCounter>1F)
+ {
+ this.blobTimer=Math.round(4000F/this.leavesCounter);
+ }
+ else
+ {
+ this.blobTimer=200;
+ }
+ }
+ else
+ {
+ if(this.leavesCounter>1F)
+ {
+ this.blobTimer--;
+ }
+ }
+ if(this.updateCounter<1200)
+ {
+ this.updateCounter++;
+ }
+ }
+
+ }
+
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ if(IHLMod.ic2Leaves!=null && IHLMod.ic2Wood!=null)
+ {
+ if(this.blobTimer<=0)
+ {
+ {
+ if(IC2.platform.isSimulating())
+ {
+ switch(this.currentTree)
+ {
+ case RUBBERTREE:
+ this.fluidTank.fill(new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"), blobCapacity), true);
+ break;
+ case SPRUCE:
+ this.fluidTank.fill(new FluidStack(FluidRegistry.getFluid("spruceresin"), blobCapacity), true);
+ break;
+ }
+ }
+ }
+ if(this.leavesCounter>1F)
+ {
+ this.blobTimer=Math.round(4000F/this.leavesCounter);
+ }
+ else
+ {
+ this.blobTimer=200;
+ }
+ }
+ else
+ {
+ if(this.leavesCounter>1F)
+ {
+ this.blobTimer--;
+ }
+ }
+ if(this.updateCounter<1200)
+ {
+ this.updateCounter++;
+ }
+ else
+ {
+ if(IC2.platform.isSimulating())
+ {
+ this.updateCounter=rand.nextInt(600);
+ if(checkCorrectPlacing())
+ {
+ countRubberTreeLeaves();
+ }
+ else
+ {
+ leavesCounter=0F;
+ }
+ IC2.network.get().updateTileEntityField(this, "currentTree");
+ IC2.network.get().updateTileEntityField(this, "leavesCounter");
+ if(this.fluidTank.getFluid()!=null)
+ {
+
+ TileEntity te = worldObj.getTileEntity(xCoord, yCoord-1, zCoord);
+ if(te!=null && te instanceof IFluidHandler)
+ {
+ IFluidHandler fte = (IFluidHandler) te;
+ FluidStack fStack = this.fluidTank.drain(Integer.MAX_VALUE, false);
+ if(fte.canFill(ForgeDirection.UP, fStack.getFluid()))
+ {
+ if(fte.fill(ForgeDirection.UP, fStack, false)>0)
+ {
+ int amount = fte.fill(ForgeDirection.UP, fStack, true);
+ this.fluidTank.drain(amount, true);
+ }
+ }
+ }
+ }
+ }
+ }
+ if(this.fluidTank.getFluid()!=null && (visibleFluidId!=this.fluidTank.getFluid().getFluid().getID() || Math.abs(visibleFluidAmount-this.fluidTank.getFluidAmount())>20))
+ {
+ visibleFluidId = this.fluidTank.getFluid().getFluid().getID();
+ visibleFluidAmount = this.fluidTank.getFluidAmount();
+ IC2.network.get().updateTileEntityField(this, "visibleFluidId");
+ IC2.network.get().updateTileEntityField(this, "visibleFluidAmount");
+ }
+ else if(this.fluidTank.getFluid()==null && visibleFluidId!=-1)
+ {
+ visibleFluidId=-1;
+ IC2.network.get().updateTileEntityField(this, "visibleFluidId");
+ }
+ }
+ }
+
+ private boolean checkCorrectPlacing()
+ {
+ int xz[]={0,1,0,-1,0};
+ Block block, block2;
+ int meta,meta2;
+ for(int i =0;i<=3;i++)
+ {
+ block=worldObj.getBlock(xCoord+xz[i], yCoord, zCoord+xz[i+1]);
+ meta=worldObj.getBlockMetadata(xCoord+xz[i], yCoord, zCoord+xz[i+1]);
+ block2=worldObj.getBlock(xCoord+xz[i], yCoord+1, zCoord+xz[i+1]);
+ meta2=worldObj.getBlockMetadata(xCoord+xz[i], yCoord+1, zCoord+xz[i+1]);
+ if(
+ meta>0 &&
+ meta2>0 &&
+ (block==IHLMod.ic2Wood||block==IHLMod.rubberTreeBlock) &&
+ (block2==IHLMod.ic2Wood||block2==IHLMod.rubberTreeBlock)
+ )
+ {
+ short newFacing = this.getFacingFromXZ(xz[i], xz[i+1]);
+ this.setFacing(newFacing);
+ if(block2==IHLMod.ic2Wood)
+ {
+ worldObj.setBlock(xCoord+xz[i], yCoord+1, zCoord+xz[i+1],IHLMod.rubberTreeBlock,newFacing,3);
+ }
+ else
+ {
+ if(newFacing!=meta2)
+ {
+ return false;
+ }
+ }
+ this.currentTree=RUBBERTREE;
+ return checkGround();
+ }
+ else if(
+ ((block==Blocks.log && meta==1) ||
+ (block==IHLMod.spruceTreeBlock && meta>0)) &&
+ ((block2==Blocks.log && meta2==1) ||
+ (block2==IHLMod.spruceTreeBlock && meta2>0))
+ )
+ {
+ short newFacing = this.getFacingFromXZ(xz[i], xz[i+1]);
+ this.setFacing(newFacing);
+ if(block2==Blocks.log)
+ {
+ worldObj.setBlock(xCoord+xz[i], yCoord+1, zCoord+xz[i+1],IHLMod.spruceTreeBlock,newFacing,3);
+ }
+ else
+ {
+ if(newFacing!=meta2)
+ {
+ return false;
+ }
+ }
+ this.currentTree=SPRUCE;
+ return checkGround();
+ }
+ }
+ return false;
+ }
+
+ private boolean checkGround()
+ {
+ Block block;
+ int meta;
+ for(int h=0; h<=this.maxLeavesHeight; h++)
+ {
+ block=worldObj.getBlock(xCoord+mX(), yCoord-h, zCoord+mZ());
+ meta=worldObj.getBlockMetadata(xCoord+mX(), yCoord-h, zCoord+mZ());
+ if(!isLogBlock(block, meta))
+ {
+ if(IHLUtils.isBlockRegisteredInOreDictionaryAs(block, "blockDirt"))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if(meta<=0)
+ {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ private boolean isLogBlock(Block block, int meta)
+ {
+ switch(this.currentTree)
+ {
+ case RUBBERTREE:
+ return block==IHLMod.ic2Wood || block==IHLMod.rubberTreeBlock;
+ case SPRUCE:
+ return (block==Blocks.log && meta==1) || (block==IHLMod.spruceTreeBlock && meta>0);
+ }
+ return false;
+ }
+
+ private boolean isLeavesBlock(Block block)
+ {
+ switch(this.currentTree)
+ {
+ case RUBBERTREE:
+ return block==IHLMod.ic2Leaves;
+ case SPRUCE:
+ return block==Blocks.leaves;
+ }
+ return false;
+ }
+
+ private boolean isIncisedLog(Block block)
+ {
+ switch(this.currentTree)
+ {
+ case RUBBERTREE:
+ return block==IHLMod.rubberTreeBlock;
+ case SPRUCE:
+ return block==IHLMod.spruceTreeBlock;
+ }
+ return false;
+ }
+
+ private void countRubberTreeLeaves()
+ {
+ this.leavesCounter=0;
+ int[][][] leavesMatrix=new int[this.maxLeavesWidth][this.maxLeavesWidth][this.maxLeavesHeight];
+ for(int iy=1;iy<this.maxLeavesHeight;iy++)
+ {
+ Block block=worldObj.getBlock(xCoord+mX(), yCoord+iy, zCoord+mZ());
+ int meta=worldObj.getBlockMetadata(xCoord+mX(), yCoord+iy, zCoord+mZ());
+ if(isLogBlock(block, meta)||isLeavesBlock(block))
+ {
+ if(isLeavesBlock(block))
+ {
+ this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX(), yCoord+iy, zCoord+mZ());
+ }
+ else if(isIncisedLog(block) && iy>=2)
+ {
+ break;
+ }
+ for(int sign=1;sign>=-1;sign-=2)
+ {
+ for(int ix=1;ix<=2;ix++)
+ {
+
+ block=worldObj.getBlock(xCoord+mX()+ix*sign, yCoord+iy, zCoord+mZ());
+ if(isLeavesBlock(block))
+ {
+ this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+ix*sign, yCoord+iy, zCoord+mZ());
+ leavesMatrix[2+ix*sign][2][iy-1]=1;
+ }
+ else
+ {
+ break;
+ }
+ }
+ for(int iz=1;iz<=2;iz++)
+ {
+ block=worldObj.getBlock(xCoord+mX(), yCoord+iy, zCoord+mZ()+iz*sign);
+ if(isLeavesBlock(block))
+ {
+ this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX(), yCoord+iy, zCoord+mZ()+iz*sign);
+ leavesMatrix[2][2+iz*sign][iy-1]=1;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ for(int signx=1;signx>=-1;signx-=2)
+ {
+ for(int signz=1;signz>=-1;signz-=2)
+ {
+ if(leavesMatrix[2][2+signz][iy-1]==1||leavesMatrix[2+signx][2][iy-1]==1)
+ {
+ block=worldObj.getBlock(xCoord+mX()+signx, yCoord+iy, zCoord+mZ()+signz);
+ if(isLeavesBlock(block))
+ {
+ this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+signx, yCoord+iy, zCoord+mZ()+signz);
+ leavesMatrix[2+signx][2+signz][iy-1]=1;
+ }
+ }
+ if(leavesMatrix[2+signx*2][2][iy-1]==1||leavesMatrix[2+signx][2+signz][iy-1]==1)
+ {
+ block=worldObj.getBlock(xCoord+mX()+signx*2, yCoord+iy, zCoord+mZ()+signz);
+ if(block==IHLMod.ic2Leaves)
+ {
+ this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+signx*2, yCoord+iy, zCoord+mZ()+signz);
+ leavesMatrix[2+signx*2][2+signz][iy-1]=1;
+ }
+ }
+ if(leavesMatrix[2][2+signz*2][iy-1]==1||leavesMatrix[2+signx][2+signz][iy-1]==1)
+ {
+ block=worldObj.getBlock(xCoord+mX()+signx, yCoord+iy, zCoord+mZ()+signz*2);
+ if(isLeavesBlock(block))
+ {
+ this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+signx, yCoord+iy, zCoord+mZ()+signz*2);
+ leavesMatrix[2+signx][2+signz*2][iy-1]=1;
+ }
+ }
+ if(leavesMatrix[2+signx*2][2+signz][iy-1]==1||leavesMatrix[2+signx][2+signz*2][iy-1]==1)
+ {
+ block=worldObj.getBlock(xCoord+mX()+signx*2, yCoord+iy, zCoord+mZ()+signz*2);
+ if(isLeavesBlock(block))
+ {
+ this.leavesCounter+=worldObj.getLightBrightness(xCoord+mX()+signx*2, yCoord+iy, zCoord+mZ()+signz*2);
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+
+ //1.7.10 API
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return true;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection arg0, Fluid arg1) {
+ return false;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "sack";
+ }
+
+ private int mX()
+ {
+ switch(this.getFacing())
+ {
+ case 4:
+ return -1;
+ case 5:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ private int mZ()
+ {
+ switch(this.getFacing())
+ {
+ case 3:
+ return 1;
+ case 2:
+ return -1;
+ case 4:
+ return 0;
+ case 5:
+ return 0;
+ default:
+ return -1;
+ }
+ }
+
+ private short getFacingFromXZ(int x, int z)
+ {
+ switch(x)
+ {
+ case -1:
+ return (short)4;
+ case 1:
+ return (short)5;
+ default:
+ switch(z)
+ {
+ case 1:
+ return (short)3;
+ case -1:
+ return (short)2;
+ default:
+ return (short)2;
+ }
+ }
+ }
+
+ public float getRenderLiquidLevel()
+ {
+ return (float)this.visibleFluidAmount/(float)this.fluidTank.getCapacity();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2)
+ {
+ if(this.canDrain(arg0, arg1.getFluid()))
+ {
+ FluidStack fStack = fluidTank.drain(arg1, arg2);
+ return fStack;
+ }
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, int arg1, boolean arg2)
+ {
+ if(this.canDrain(arg0, null))
+ {
+ FluidStack fStack = fluidTank.drain(arg1, arg2);
+ return fStack;
+ }
+ return null;
+ }
+
+ @Override
+ public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
+ return 0;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection arg0) {
+ return new FluidTankInfo[]{this.fluidTank.getInfo()};
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/enviroment/LaserHitMirrorEventHandler.java b/src/main/java/ihl/enviroment/LaserHitMirrorEventHandler.java new file mode 100644 index 0000000..6cd61fc --- /dev/null +++ b/src/main/java/ihl/enviroment/LaserHitMirrorEventHandler.java @@ -0,0 +1,48 @@ +package ihl.enviroment;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import ic2.api.event.LaserEvent;
+import ic2.core.item.tool.EntityMiningLaser;
+import net.minecraft.entity.Entity;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class LaserHitMirrorEventHandler
+{
+ public LaserHitMirrorEventHandler(){}
+
+ @SubscribeEvent
+ public void onLaserHit(LaserEvent.LaserHitsBlockEvent event)
+ {
+ TileEntity te = event.world.getTileEntity(event.x, event.y, event.z);
+ if(te instanceof MirrorTileEntity)
+ {
+ ForgeDirection mirrorDirection = ForgeDirection.getOrientation(((MirrorTileEntity)te).getFacing());
+ Entity ls = event.lasershot;
+ if((ls.motionX*mirrorDirection.offsetX+ls.motionY*mirrorDirection.offsetY+ls.motionZ*mirrorDirection.offsetZ)<0)
+ {
+ if(mirrorDirection.offsetX!=0)
+ {
+ ls.motionX=-ls.motionX;
+ }
+ if(mirrorDirection.offsetY!=0)
+ {
+ ls.motionY=-ls.motionY;
+ }
+ if(mirrorDirection.offsetZ!=0)
+ {
+ ls.motionZ=-ls.motionZ;
+ }
+ if(!event.world.isRemote)
+ {
+ EntityMiningLaser tLaser = new EntityMiningLaser(event.world, event.owner, event.range, event.power, event.blockBreaks, event.explosive, 0, 0, ls.posY);
+ tLaser.setPosition(ls.posX, ls.posY, ls.posZ);
+ tLaser.setLaserHeading(ls.motionX, ls.motionY, ls.motionZ, 1d);
+ ls.setDead();
+ event.world.spawnEntityInWorld(tLaser);
+ }
+ event.setCanceled(true);
+ }
+ }
+ }
+}
diff --git a/src/main/java/ihl/enviroment/MirrorBlock.java b/src/main/java/ihl/enviroment/MirrorBlock.java new file mode 100644 index 0000000..e996876 --- /dev/null +++ b/src/main/java/ihl/enviroment/MirrorBlock.java @@ -0,0 +1,200 @@ +package ihl.enviroment;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.utils.IHLUtils;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+public class MirrorBlock extends Block implements ITileEntityProvider {
+
+ public MirrorBlock(String unlocalizedName1)
+ {
+ super(Material.glass);
+ this.setBlockName(unlocalizedName1);
+ GameRegistry.registerBlock(this, unlocalizedName1);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setHardness(0.3f);
+ this.setResistance(0.3f);
+ this.setBlockTextureName("clay");
+ }
+
+ public static void init()
+ {
+ new MirrorBlock("mirror");
+ GameRegistry.registerTileEntity(MirrorTileEntity.class, "mirror");
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World arg0, int arg1) {
+ return new MirrorTileEntity();
+ }
+
+ @Override
+ public boolean isOpaqueCube()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock()
+ {
+ return false;
+ }
+
+ @Override
+ public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z)
+ {
+ TileEntity te = iBlockAccess.getTileEntity(x, y, z);
+ if(te!=null && te instanceof MirrorTileEntity)
+ {
+ MirrorTileEntity ate = (MirrorTileEntity) te;
+ setBlockBoundsBasedOnFacing(ate.getFacing());
+ }
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
+ {
+ TileEntity te = world.getTileEntity(x, y, z);
+ if(te!=null && te instanceof MirrorTileEntity)
+ {
+ MirrorTileEntity ate = (MirrorTileEntity) te;
+ int var2 = ate.getFacing() & 7;
+ float var6 = 0.5F;
+ float var7 = 0.09F;
+ if (var2 == 0)
+ {
+ return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+1.0F - var7,z+ 0.5F - var6, x+0.5F + var6, y+1.0F, z+0.5F + var6);
+ }
+ else if (var2 == 1)
+ {
+ return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+ 0.0F,z+ 0.5F - var6, x+0.5F + var6, y+var7, z+0.5F + var6);
+ }
+ else if (var2 == 2)
+ {
+ return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+ 0.5F - var6,z+ 1.0F - var7, x+0.5F + var6, y+0.5F + var6, z+1.0F);
+ }
+ else if (var2 == 3)
+ {
+ return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+ 0.5F - var6,z+ 0.0F, x+0.5F + var6, y+0.5F + var6, z+var7);
+ }
+ else if (var2 == 4)
+ {
+ return AxisAlignedBB.getBoundingBox(x+1.0F - var7,y+ 0.5F - var6,z+0.5F - var6, x+1.0F, y+0.5F + var6, z+0.5F + var6);
+ }
+ else if (var2 == 5)
+ {
+ return AxisAlignedBB.getBoundingBox(x+0.0F,y+ 0.5F - var6, z+0.5F - var6, x+var7, y+0.5F + var6, z+0.5F + var6);
+ }
+ }
+ return null;
+ }
+
+ private void setBlockBoundsBasedOnFacing(int facing)
+ {
+ int var2 = facing & 7;
+ float var6 = 0.5F;
+ float var7 = 0.09F;
+ if (var2 == 0)
+ {
+ this.setBlockBounds(0.5F - var6, 1.0F - var7, 0.5F - var6, 0.5F + var6, 1.0F, 0.5F + var6);
+ }
+ else if (var2 == 1)
+ {
+ this.setBlockBounds(0.5F - var6, 0.0F, 0.5F - var6, 0.5F + var6, var7, 0.5F + var6);
+ }
+ else if (var2 == 2)
+ {
+ this.setBlockBounds(0.5F - var6, 0.5F - var6, 1.0F - var7, 0.5F + var6, 0.5F + var6, 1.0F);
+ }
+ else if (var2 == 3)
+ {
+ this.setBlockBounds(0.5F - var6, 0.5F - var6, 0.0F, 0.5F + var6, 0.5F + var6, var7);
+ }
+ else if (var2 == 4)
+ {
+ this.setBlockBounds(1.0F - var7, 0.5F - var6, 0.5F - var6, 1.0F, 0.5F + var6, 0.5F + var6);
+ }
+ else if (var2 == 5)
+ {
+ this.setBlockBounds(0.0F, 0.5F - var6, 0.5F - var6, var7, 0.5F + var6, 0.5F + var6);
+ }
+ }
+
+ /**
+ * Sets the block's bounds for rendering it as an item
+ */
+ @Override
+ public void setBlockBoundsForItemRender()
+ {
+ float var1 = 0.5F;
+ float var2 = 0.5F;
+ float var3 = 0.05F;
+ this.setBlockBounds(0.5F - var1, 0.5F - var2, 0.5F - var3, 0.5F + var1, 0.5F + var2, 0.5F + var3);
+ }
+
+ @Override
+ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack)
+ {
+ int var6 = MathHelper.floor_double(player.rotationPitch * 4.0F / 360.0F + 0.5D) & 3;
+ int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+ TileEntity t = world.getTileEntity(x, y, z);
+ if(t!=null && t instanceof MirrorTileEntity)
+ {
+ MirrorTileEntity te = (MirrorTileEntity)t;
+ if(var6==1)
+ {
+ te.setFacing((short) 1);
+ }
+ else if(var6==3)
+ {
+ te.setFacing((short) 0);
+ }
+ else
+ {
+ switch(var7)
+ {
+ case 0:
+ te.setFacing((short) 2);
+ break;
+ case 1:
+ te.setFacing((short) 5);
+ break;
+ case 2:
+ te.setFacing((short) 3);
+ break;
+ case 3:
+ te.setFacing((short) 4);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":mirror");
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
+ {
+ this.dropBlockAsItem(world, x, y, z, IHLUtils.getThisModItemStack("dustGlass"));
+ }
+}
diff --git a/src/main/java/ihl/enviroment/MirrorRender.java b/src/main/java/ihl/enviroment/MirrorRender.java new file mode 100644 index 0000000..60bc501 --- /dev/null +++ b/src/main/java/ihl/enviroment/MirrorRender.java @@ -0,0 +1,416 @@ +package ihl.enviroment;
+
+import java.nio.IntBuffer;
+import java.util.Iterator;
+
+import org.lwjgl.BufferUtils;
+import org.lwjgl.opengl.Display;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL30;
+import org.lwjgl.util.glu.GLU;
+import org.lwjgl.util.glu.Project;
+
+import ihl.IHLMod;
+import ihl.model.IHLBlockRenderer;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.GLAllocation;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.entity.Entity;
+import net.minecraft.tileentity.TileEntity;
+
+public class MirrorRender extends TileEntitySpecialRenderer{
+private int texture=-1;
+private int fb=-1;
+private static final IntBuffer textureIDBuffer = BufferUtils.createIntBuffer(1);
+private static final float zNear = 1.5f;//1.5f
+private static final float zFar = 0.1f;//0.1f
+private final int textureWidth=512;
+private final int textureHeight=512;
+private final int[] xdepth;
+private final int[] ydepth;
+private final int[] textureU;
+private final int[] textureV;
+private final Minecraft mc;
+
+public MirrorRender()
+{
+ xdepth=new int[] {0,0,1,1};
+ ydepth=new int[] {0,1,1,0};
+ textureU=new int[] {0,0,1,1};
+ textureV=new int[]{0,1,1,0};
+ mc=Minecraft.getMinecraft();
+}
+
+public void renderAModelAt(MirrorTileEntity tile, double x, double y, double z, float f) {
+ float[] mAxis = tile.getMirrorAxis();
+ if(texture==-1)
+ {
+ GL11.glGenTextures(textureIDBuffer);
+ texture=textureIDBuffer.get(0);
+ fb=GL30.glGenFramebuffers();
+ GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fb);
+ GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
+ GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB8, textureWidth, textureHeight, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer)null);
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,GL11. GL_LINEAR);
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
+ int depthBuffer = GL30.glGenRenderbuffers();
+ GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthBuffer);
+ GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, textureWidth, textureHeight);
+ GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depthBuffer);
+ GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture, 0);
+ if (GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE)
+ {
+ IHLMod.log.error("Something went wrong while creating frame buffer!");
+ IHLMod.log.error(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER));
+ }
+ else
+ {
+ IHLMod.log.info("FrameBuffer loaded correctly!");
+ }
+ }
+ //Show reflection when:
+ //x>-1 when offsetX==-1
+ //x<0 when offsetX==1
+ if(tile.shouldReflect &&
+ ((x>-0.8D && mAxis[3]==-1)||
+ (x<-0.2 && mAxis[3]==1)||
+ (y>-0.8D && mAxis[4]==-1)||
+ (y<-0.2D && mAxis[4]==1)||
+ (z>-0.8D && mAxis[5]==-1)||
+ (z<-0.2D && mAxis[5]==1)))
+ {
+ GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fb);
+ drawReflection(tile, x, y, z, f);
+ mc.entityRenderer.setupCameraTransform(f, 0);
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float) x, (float) y , (float) z);
+ defineMeshAndTextureCoordinates(tile);
+ IHLRenderUtils.instance.enableAmbientLighting();
+ drawMirrorFrame(tile);
+ IHLRenderUtils.instance.disableAmbientLighting();
+ RenderHelper.enableStandardItemLighting();
+ GL11.glPopMatrix();
+ }
+}
+
+ @Override
+ public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
+ {
+ this.renderAModelAt((MirrorTileEntity)par1TileEntity, par2, par4, par6, par8);
+ }
+
+ private void drawReflection(MirrorTileEntity tile, double x, double y, double z, float f)
+ {
+ GL11.glViewport(0, 0, textureWidth, textureHeight);
+ GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
+ GL11.glColor4f(1f, 1f, 1f, 1f);
+ setMirrorView(tile, x, y, z);
+ IHLRenderUtils.instance.enableAmbientLighting();
+ mc.renderGlobal.renderSky(f);
+ mc.renderGlobal.renderClouds(f);
+ IHLRenderUtils.instance.disableAmbientLighting();
+ setMirrorView(tile, x, y, z);
+ GL11.glColor4f(1f, 1f, 1f, 1f);
+ bindTexture(TextureMap.locationBlocksTexture);
+ GL11.glTranslatef((-tile.xCoord), (-tile.yCoord), (-tile.zCoord));
+ if (tile.displayListCache != -1)
+ {
+ GL11.glCallList(tile.displayListCache);
+ if(tile.needRenderUpdate)
+ {
+ IHLBlockRenderer.instance.refreshDisplayLists(tile.displayListCache, tile.bwc, tile.chunkCache);
+ tile.needRenderUpdate=false;
+ }
+ }
+ else if(tile.chunkCache!=null)
+ {
+ tile.displayListCache=GLAllocation.generateDisplayLists(1);
+ IHLBlockRenderer.instance.refreshDisplayLists(tile.displayListCache, tile.bwc, tile.chunkCache);
+ }
+ Iterator<Entity> ientity = tile.reflectedEntity.iterator();
+ while(ientity.hasNext())
+ {
+ Entity centity = ientity.next();
+ Render render = (Render) IHLMod.proxy.getRenderForEntityClass(centity.getClass());
+ if(render!=null)
+ {
+ render.doRender(centity, centity.prevPosX, centity.prevPosY, centity.prevPosZ, 1f, f);
+ GL11.glEnable(GL11.GL_COLOR_MATERIAL);
+ GL11.glColor4f(1f, 1f, 1f, 1f);
+ }
+ }
+ Iterator<TileEntity> itentity = tile.reflectedTileEntity.iterator();
+ while(itentity.hasNext())
+ {
+ TileEntity te = itentity.next();
+ if(TileEntityRendererDispatcher.instance.hasSpecialRenderer(te))
+ {
+ TileEntitySpecialRenderer specialRenderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(te);
+ specialRenderer.renderTileEntityAt(te, te.xCoord, te.yCoord, te.zCoord, f);
+ GL11.glEnable(GL11.GL_COLOR_MATERIAL);
+ }
+ }
+ GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
+ }
+
+ private void defineMeshAndTextureCoordinates(MirrorTileEntity tile)
+ {
+ switch (tile.getFacing())
+ {
+ case 0://up
+ xdepth[0]=1+tile.reflectExtensionRight;
+ xdepth[1]=1+tile.reflectExtensionRight;
+ xdepth[2]=0;
+ xdepth[3]=0;
+ ydepth[0]=0;
+ ydepth[1]=1+tile.reflectExtensionTop;
+ ydepth[2]=1+tile.reflectExtensionTop;
+ ydepth[3]=0;
+ textureU[0]=0;
+ textureU[1]=0;
+ textureU[2]=1;
+ textureU[3]=1;
+ textureV[0]=0;
+ textureV[1]=1;
+ textureV[2]=1;
+ textureV[3]=0;
+ break;
+ case 1://down
+ xdepth[0]=-tile.reflectExtensionRight;
+ xdepth[1]=-tile.reflectExtensionRight;
+ xdepth[2]=1;
+ xdepth[3]=1;
+ ydepth[0]=-tile.reflectExtensionTop;
+ ydepth[1]=1;
+ ydepth[2]=1;
+ ydepth[3]=-tile.reflectExtensionTop;
+ textureU[0]=0;
+ textureU[1]=0;
+ textureU[2]=1;
+ textureU[3]=1;
+ textureV[0]=0;
+ textureV[1]=1;
+ textureV[2]=1;
+ textureV[3]=0;
+ break;
+ case 2:
+ xdepth[0]=0;
+ xdepth[1]=0;
+ xdepth[2]=1+tile.reflectExtensionRight;
+ xdepth[3]=1+tile.reflectExtensionRight;
+ ydepth[0]=0;
+ ydepth[1]=1+tile.reflectExtensionTop;
+ ydepth[2]=1+tile.reflectExtensionTop;
+ ydepth[3]=0;
+ textureU[0]=0;
+ textureU[1]=0;
+ textureU[2]=1;
+ textureU[3]=1;
+ textureV[0]=0;
+ textureV[1]=1;
+ textureV[2]=1;
+ textureV[3]=0;
+ break;
+ case 3:
+ xdepth[0]=-tile.reflectExtensionRight;
+ xdepth[1]=1;
+ xdepth[2]=1;
+ xdepth[3]=-tile.reflectExtensionRight;
+ ydepth[0]=0;
+ ydepth[1]=0;
+ ydepth[2]=1+tile.reflectExtensionTop;
+ ydepth[3]=1+tile.reflectExtensionTop;
+ textureU[0]=1;
+ textureU[1]=0;
+ textureU[2]=0;
+ textureU[3]=1;
+ textureV[0]=0;
+ textureV[1]=0;
+ textureV[2]=1;
+ textureV[3]=1;
+ break;
+ case 4:
+ xdepth[0]=-tile.reflectExtensionRight;
+ xdepth[1]=1;
+ xdepth[2]=1;
+ xdepth[3]=-tile.reflectExtensionRight;
+ ydepth[0]=0;
+ ydepth[1]=0;
+ ydepth[2]=1+tile.reflectExtensionTop;
+ ydepth[3]=1+tile.reflectExtensionTop;
+ textureU[0]=1;
+ textureU[1]=0;
+ textureU[2]=0;
+ textureU[3]=1;
+ textureV[0]=0;
+ textureV[1]=0;
+ textureV[2]=1;
+ textureV[3]=1;
+ break;
+ case 5:
+ xdepth[0]=0;
+ xdepth[1]=0;
+ xdepth[2]=1+tile.reflectExtensionRight;
+ xdepth[3]=1+tile.reflectExtensionRight;
+ ydepth[0]=0;
+ ydepth[1]=1+tile.reflectExtensionTop;
+ ydepth[2]=1+tile.reflectExtensionTop;
+ ydepth[3]=0;
+ textureU[0]=0;
+ textureU[1]=0;
+ textureU[2]=1;
+ textureU[3]=1;
+ textureV[0]=0;
+ textureV[1]=1;
+ textureV[2]=1;
+ textureV[3]=0;
+ break;
+ default:
+ }
+
+ }
+
+ private void drawMirrorFrame(MirrorTileEntity tile)
+ {
+ GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
+ GL11.glColor4f(1f, 1f, 1f, 1f);
+ GL11.glDisable(GL11.GL_BLEND);
+ Tessellator tessellator=Tessellator.instance;
+ tessellator.startDrawingQuads();
+ for(int i=0;i<xdepth.length;i++)
+ {
+ switch (tile.getFacing())
+ {
+ case 0:
+ tessellator.addVertexWithUV(xdepth[i], 0.9d, ydepth[i],textureU[i],textureV[i]);
+ break;
+ case 1:
+ tessellator.addVertexWithUV(xdepth[i], 0.1d, ydepth[i],textureU[i],textureV[i]);
+ break;
+ case 2:
+ tessellator.addVertexWithUV(xdepth[i], ydepth[i], 0.9d,textureU[i],textureV[i]);
+ break;
+ case 3:
+ tessellator.addVertexWithUV(xdepth[i], ydepth[i], 0.1d,textureU[i],textureV[i]);
+ break;
+ case 4:
+ tessellator.addVertexWithUV(0.9d, ydepth[i], xdepth[i],textureU[i],textureV[i]);
+ break;
+ case 5:
+ tessellator.addVertexWithUV(0.1d, ydepth[i], xdepth[i],textureU[i],textureV[i]);
+ break;
+ default:
+ }
+ }
+ tessellator.draw();
+ }
+
+ private void setMirrorView(MirrorTileEntity tile, double x, double y, double z)
+ {
+ float mirrorHeightCoorrection, mirrorWidthCoorrection, xShift, yShift, shiftCorrection,yCorrection,xCorrection,zCorrection;
+ GL11.glMatrixMode(GL11.GL_PROJECTION);
+ GL11.glLoadIdentity();
+ Project.gluPerspective(65f, (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.mc.gameSettings.renderDistanceChunks * 32F);
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ GL11.glLoadIdentity();
+ double aspectRatioMirror = Math.sqrt((tile.reflectExtensionTop+1)/(double)(tile.reflectExtensionRight+1));
+ double aspectRatio = Display.getHeight()/(double)Display.getWidth()/aspectRatioMirror;
+ shiftCorrection = tile.reflectExtensionTop*0.45f+tile.reflectExtensionRight*0.45f-0.5f;
+ float kYS = 0.5f;//0.5f;
+ float kZS = 0.0f;//0.5f;
+ switch(tile.getFacing())
+ {
+ //swap y and z
+ case 0://down facing mirror
+ mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
+ yShift = (float)(z+mirrorHeightCoorrection)*kYS;
+ yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
+ zCorrection = 2f+shiftCorrection-kZS;
+ mirrorWidthCoorrection = (-tile.reflectExtensionRight+1)*0.5f;
+ xShift = (float)(-x+mirrorWidthCoorrection)*0.5f-0.5f;
+ GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
+ xCorrection = mirrorWidthCoorrection+xShift*(tile.reflectExtensionRight*0.5f-0.375f/(tile.reflectExtensionRight+1)+1.125f);
+ GLU.gluLookAt(xCorrection+tile.reflectExtensionRight, zCorrection, yCorrection, xCorrection+tile.reflectExtensionRight/*x reference*/, -32f+zCorrection/*y reference*/, yCorrection/*z reference*/, 0.0f, 0.0f, 1.0f);
+ break;
+ case 1://up facing mirror
+ mirrorHeightCoorrection = (-tile.reflectExtensionTop+1)*0.5f;
+ yShift = (float)(z+mirrorHeightCoorrection)*kYS;
+ yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
+ zCorrection = -1f-shiftCorrection-kZS;
+ mirrorWidthCoorrection = (-tile.reflectExtensionRight+1)*0.5f;
+ xShift = (float)(x+mirrorWidthCoorrection)*0.5f;
+ GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
+ xCorrection = mirrorWidthCoorrection-xShift*(tile.reflectExtensionRight*0.5f+1f);
+ GLU.gluLookAt(xCorrection, zCorrection, yCorrection, xCorrection/*x reference*/, 32f+zCorrection/*y reference*/, yCorrection/*z reference*/, 0.0f, 0.0f, 1.0f);
+ break;
+ case 2:
+ mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
+ yShift = (float)(y+mirrorHeightCoorrection)*kYS;
+ yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
+ zCorrection = 2f+shiftCorrection-kZS;
+ mirrorWidthCoorrection = (tile.reflectExtensionRight+1)*0.5f;
+ xShift = (float)(x+mirrorWidthCoorrection)*0.5f;
+ GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
+ xCorrection = mirrorWidthCoorrection-xShift*(tile.reflectExtensionRight*0.5f+1f);
+ GLU.gluLookAt(xCorrection, yCorrection, zCorrection, xCorrection/*x reference*/, yCorrection/*y reference*/, -32f+zCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
+ break;
+ case 3:
+ mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
+ yShift = (float)(y+mirrorHeightCoorrection)*kYS;
+ yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionRight*0.5f+1f);
+ zCorrection = -1f-shiftCorrection-kZS;
+ mirrorWidthCoorrection = 0.5f-tile.reflectExtensionRight*0.5f;
+ xShift = (float)(-x-mirrorWidthCoorrection)*0.5f;
+ GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
+ xCorrection = mirrorWidthCoorrection+xShift*(tile.reflectExtensionTop*0.5f-0.375f/(tile.reflectExtensionTop+1)+1.125f);
+ GLU.gluLookAt(xCorrection, yCorrection, zCorrection, xCorrection/*x reference*/, yCorrection/*y reference*/, 32f+zCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
+ break;
+ case 4:
+ mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
+ yShift = (float)(y+mirrorHeightCoorrection)*kYS;
+ yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
+ zCorrection = 2f+shiftCorrection-kZS;
+ mirrorWidthCoorrection = 0.5f-tile.reflectExtensionRight*0.5f;
+ xShift = (float)(-z-mirrorWidthCoorrection)*0.5f;
+ GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
+ xCorrection = mirrorWidthCoorrection+xShift*(tile.reflectExtensionRight*0.5f-0.375f/(tile.reflectExtensionRight+1)+1.125f);
+ GLU.gluLookAt(zCorrection, yCorrection, xCorrection, zCorrection-32f/*x reference*/, yCorrection/*y reference*/, xCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
+ break;
+ case 5:
+ mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
+ yShift = (float)(y+mirrorHeightCoorrection)*kYS;
+ yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
+ zCorrection = -1f-shiftCorrection-kZS;
+ mirrorWidthCoorrection = (tile.reflectExtensionRight+1)*0.5f;
+ xShift = (float)(z+mirrorWidthCoorrection)*0.5f;
+ GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
+ xCorrection = mirrorWidthCoorrection-xShift*(tile.reflectExtensionRight*0.5f+1f);
+ GLU.gluLookAt(zCorrection, yCorrection, xCorrection, zCorrection+32f/*x reference*/, yCorrection/*y reference*/, xCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
+ break;
+ default:
+ mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
+ yShift = (float)(y+mirrorHeightCoorrection)*kYS;
+ yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
+ zCorrection = 2f+shiftCorrection-kZS;
+ mirrorWidthCoorrection = (tile.reflectExtensionRight+1)*0.5f;
+ xShift = (float)(x+mirrorWidthCoorrection)*0.5f;
+ GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
+ xCorrection = mirrorWidthCoorrection-xShift*(tile.reflectExtensionRight*0.5f+1f);
+ GLU.gluLookAt(xCorrection, yCorrection, zCorrection, xCorrection/*x reference*/, yCorrection/*y reference*/, -32f+zCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
+ }
+ }
+
+ public static void deleteTextures()
+ {
+ GL11.glDeleteTextures(textureIDBuffer);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/enviroment/MirrorTileEntity.java b/src/main/java/ihl/enviroment/MirrorTileEntity.java new file mode 100644 index 0000000..4060e59 --- /dev/null +++ b/src/main/java/ihl/enviroment/MirrorTileEntity.java @@ -0,0 +1,433 @@ +package ihl.enviroment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.core.block.TileEntityBlock;
+import ihl.IHLMod;
+import ihl.handpump.BlockWithCoordinates;
+import ihl.utils.IHLUtils;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityBoat;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.item.EntityMinecart;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.world.ChunkCache;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class MirrorTileEntity extends TileEntityBlock
+{
+ public final List<BlockWithCoordinates> bwc = new ArrayList<BlockWithCoordinates>();
+ public final List<Entity> reflectedEntity = new ArrayList<Entity>();
+ public final List<TileEntity> reflectedTileEntity = new ArrayList<TileEntity>();
+ private int bwcListPos=0;
+ private int reflectedTileEntityListPos=0;
+ private int reflectionVolumePos=0;
+ boolean firstTick=true;
+ public int dnx,dpx,dny,dpy,dnz,dpz;
+ boolean shouldReflect=true;
+ int reflectExtensionRight=0;
+ int reflectExtensionTop=0;
+ int timer=0;
+ int blockReflectionUpdateTimer=0;
+ int reflectionVolumeSize=-1;
+ AxisAlignedBB reflectionArea;
+ int displayListCache=-1;
+ public ChunkCache chunkCache;
+ public boolean needRenderUpdate=false;
+ private int minX;
+ private int maxX;
+ private int minY;
+ private int maxY;
+ private int minZ;
+ private int maxZ;
+ private int lastBWCSize;
+
+ public MirrorTileEntity()
+ {}
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void updateEntityClient()
+ {
+ super.updateEntityClient();
+ if(this.shouldReflect)
+ {
+ int i=0;
+ for(i=0;i<Math.min(this.reflectionVolumeSize, IHLMod.config.mirrorReflectionUpdateSpeed);i++)
+ {
+ this.checkReflectionVolume();
+ }
+ for(i=0;i<Math.min(this.bwc.size(), IHLMod.config.mirrorReflectionUpdateSpeed);i++)
+ {
+ this.checkBWCList();
+ }
+ for(i=0;i<Math.min(this.reflectedTileEntity.size(), IHLMod.config.mirrorReflectionUpdateSpeed);i++)
+ {
+ this.checkTileEntityList();
+ }
+ }
+ if(timer++>20)
+ {
+ boolean isFirst=true;
+ TileEntity t = worldObj.getTileEntity(xCoord-mXT(),yCoord-mYT(), zCoord-mZT());
+ if(t instanceof MirrorTileEntity)
+ {
+ if(((MirrorTileEntity)t).getFacing()==this.getFacing())
+ {
+ isFirst=false;
+ }
+ }
+ t = worldObj.getTileEntity(xCoord-mXR(),yCoord-mYR(), zCoord-mZR());
+ if(t instanceof MirrorTileEntity)
+ {
+ if(((MirrorTileEntity)t).getFacing()==this.getFacing())
+ {
+ isFirst=false;
+ }
+ }
+ if(isFirst)
+ {
+ this.shouldReflect=true;
+ this.reflectExtensionTop=0;
+ this.reflectExtensionRight=0;
+ for(int i=1;i<=IHLMod.config.mirrorReflectionRange+2;i++)
+ {
+ t = worldObj.getTileEntity(xCoord+mXT()*i,yCoord+mYT()*i, zCoord+mZT()*i);
+ if(t instanceof MirrorTileEntity && ((MirrorTileEntity)t).getFacing()==this.getFacing())
+ {
+ MirrorTileEntity te = (MirrorTileEntity) t;
+ te.shouldReflect=false;
+ this.reflectExtensionTop=i;
+ }
+ else
+ {
+ break;
+ }
+ }
+ a:for(int i0=1;i0<=IHLMod.config.mirrorReflectionRange+2;i0++)
+ {
+ for(int i=0;i<=this.reflectExtensionTop;i++)
+ {
+ t = worldObj.getTileEntity(xCoord+mXT()*i+mXR()*i0,yCoord+mYT()*i+mYR()*i0, zCoord+mZT()*i+mZR()*i0);
+ if(t instanceof MirrorTileEntity && ((MirrorTileEntity)t).getFacing()==this.getFacing())
+ {
+ MirrorTileEntity te = (MirrorTileEntity) t;
+ te.shouldReflect=false;
+ }
+ else
+ {
+ break a;
+ }
+ }
+ this.reflectExtensionRight=i0;
+ }
+ }
+ if(this.reflectionArea!=null)
+ {
+ this.reflectedEntity.clear();
+ this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.reflectionArea));
+ this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityBoat.class, this.reflectionArea));
+ this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityItem.class, this.reflectionArea));
+ this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityMinecart.class, this.reflectionArea));
+ }
+ timer=0;
+ }
+ if(firstTick && this.shouldReflect)
+ {
+ int ix,iy,iz;
+ int range=IHLMod.config.mirrorReflectionRange;
+ ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing());
+ bwc.clear();
+ {
+ dpx = direction.offsetX==-1?0:1;
+ dnx = direction.offsetX==1?0:1;
+ dpy = direction.offsetY==-1?0:1;
+ dny = direction.offsetY==1?0:1;
+ dpz = direction.offsetZ==-1?0:1;
+ dnz = direction.offsetZ==1?0:1;
+ reflectionVolumeSize=(range*dnx+range*dpx+dnx)*(range*dny+range*dpy+dny)*(range*dnz+range*dpz+dnz);
+ reflectionArea = AxisAlignedBB.getBoundingBox(xCoord-range*dnx-1d, yCoord-range*dny-1d, zCoord-range*dnz-1d, xCoord+range*dpx+dnx+1d, yCoord+range*dpy+dny+1d, zCoord+range*dpz+dnz+1d);
+ minX = xCoord-range*dnx;
+ maxX = xCoord+range*dpx+dnx;
+ minY = Math.max(yCoord-range*dny,0);
+ maxY = Math.min(yCoord+range*dpy+dny,this.worldObj.getActualHeight());
+ minZ = zCoord-range*dnz;
+ maxZ = zCoord+range*dpz+dnz;
+ chunkCache = new ChunkCache(worldObj, minX, minY, minZ, maxX, maxY, maxZ, 16);
+ for(ix=minX;ix<maxX;ix++)
+ {
+ for(iy=minY;iy<maxY;iy++)
+ {
+ for(iz=minZ;iz<maxZ;iz++)
+ {
+ Block block = worldObj.getBlock(ix, iy, iz);
+ if(block!=null && !block.isAir(worldObj, ix, iy, iz) && isBlockVisible(block,ix,iy,iz))
+ {
+ TileEntity te = worldObj.getTileEntity(ix, iy, iz);
+ if(te!=null && !te.isInvalid() && !reflectedTileEntity.contains(te) && TileEntityRendererDispatcher.instance.hasSpecialRenderer(te) && !(te instanceof MirrorTileEntity))
+ {
+ reflectedTileEntity.add(te);
+ }
+ if(block.getRenderType()>=0)
+ {
+ bwc.add(new BlockWithCoordinates(block, ix, iy, iz, worldObj.getBlockMetadata(ix, iy, iz)));
+ }
+ }
+
+ }
+ }
+ }
+ }
+ lastBWCSize=bwc.size();
+ firstTick=false;
+ }
+ }
+
+ private boolean isBlockVisible(Block block, int x, int y, int z)
+ {
+ if(block instanceof MirrorBlock)
+ {
+ ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing());
+ int x1=x*direction.offsetX;
+ int y1=y*direction.offsetY;
+ int z1=z*direction.offsetZ;
+ int x2=xCoord*direction.offsetX;
+ int y2=yCoord*direction.offsetY;
+ int z2=zCoord*direction.offsetZ;
+ return !(x1==x2 && y1==y2 && z1==z2);
+ }
+ if(block.shouldSideBeRendered(worldObj, x, y-1, z, 0))
+ {
+ return true;
+ }
+ if(block.shouldSideBeRendered(worldObj, x, y+1, z, 1))
+ {
+ return true;
+ }
+ if(block.shouldSideBeRendered(worldObj, x, y, z-1, 2))
+ {
+ return true;
+ }
+ if(block.shouldSideBeRendered(worldObj, x, y, z+1, 3))
+ {
+ return true;
+ }
+ if(block.shouldSideBeRendered(worldObj, x-1, y, z, 4))
+ {
+ return true;
+ }
+ if(block.shouldSideBeRendered(worldObj, x+1, y, z, 5))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return false;
+ }
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
+ return true;
+ }
+
+ @Override
+ public void setFacing(short side)
+ {
+ super.setFacing(side);
+ this.bwc.clear();
+ this.firstTick=true;
+ }
+
+ @Override
+ public float getWrenchDropRate() {
+ return 1F;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("mirror");
+ }
+
+ public float[] getMirrorAxis()
+ {
+ ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing());
+ int mx = direction.offsetX!=0?-1:1;
+ int my = direction.offsetY!=0?-1:1;
+ int mz = direction.offsetZ!=0?-1:1;
+ return new float[] {mx,my,mz,direction.offsetX,direction.offsetY,direction.offsetZ};
+ }
+
+ private void checkBWCList()
+ {
+ if(++this.bwcListPos>=bwc.size())
+ {
+ this.bwcListPos=0;
+ }
+ if(!bwc.isEmpty())
+ {
+ BlockWithCoordinates bwcEntry = bwc.get(bwcListPos);
+ if(bwcEntry.block!=worldObj.getBlock(bwcEntry.x, bwcEntry.y, bwcEntry.z))
+ {
+ bwc.remove(bwcListPos);
+ }
+ }
+ }
+
+ private void checkTileEntityList()
+ {
+ if(++this.reflectedTileEntityListPos>=reflectedTileEntity.size())
+ {
+ this.reflectedTileEntityListPos=0;
+ }
+ if(!reflectedTileEntity.isEmpty())
+ {
+ TileEntity entry = reflectedTileEntity.get(reflectedTileEntityListPos);
+ if(entry==null || entry.isInvalid() || entry!=worldObj.getTileEntity(entry.xCoord, entry.yCoord, entry.zCoord))
+ {
+ reflectedTileEntity.remove(reflectedTileEntityListPos);
+ }
+ }
+ }
+
+ private void checkReflectionVolume()
+ {
+ if(++this.reflectionVolumePos>=reflectionVolumeSize)
+ {
+ this.reflectionVolumePos=0;
+ if(lastBWCSize!=bwc.size())
+ {
+ this.needRenderUpdate=true;
+ lastBWCSize=bwc.size();
+ }
+ }
+ if(reflectionVolumeSize>0)
+ {
+ //reflectionVolumePos = x+y*maxX+z*maxX*maxY;
+ int z = reflectionVolumePos / (maxX-minX) / (maxY-minY);
+ int y = (reflectionVolumePos % ((maxX-minX) * (maxY-minY)))/ (maxX-minX);
+ int x = reflectionVolumePos - y * (maxX-minX) - z * (maxX-minX) * (maxY-minY);
+ //for example position is 69 volume is 4*5*5=100, therefore z will be 69 / (4*5)=3
+ //y will be (69 % (4*5))/4=9/4=2
+ //x will be 69 - 2*4 - 3*4*5 = 69-8-60=1
+ //for check 1+2*4+3*4*5=1+8+60
+ int ix = minX+x;
+ int iy = minY+y;
+ int iz = minZ+z;
+ Block block = worldObj.getBlock(ix, iy, iz);
+ if(block!=null && !block.isAir(worldObj, ix, iy, iz) && isBlockVisible(block,ix,iy,iz))
+ {
+ TileEntity te = worldObj.getTileEntity(ix, iy, iz);
+ if(te!=null && !te.isInvalid() && !reflectedTileEntity.contains(te) && TileEntityRendererDispatcher.instance.hasSpecialRenderer(te) && !(te instanceof MirrorTileEntity))
+ {
+ reflectedTileEntity.add(te);
+ }
+ if(block.getRenderType()>=0)
+ {
+ BlockWithCoordinates bwc1 = new BlockWithCoordinates(block, ix, iy, iz, worldObj.getBlockMetadata(ix, iy, iz));
+ if(!bwc.contains(bwc1))
+ {
+ bwc.add(bwc1);
+ }
+ }
+ }
+ }
+ }
+
+ private int mXR()
+ {
+ switch(this.getFacing())
+ {
+ case 0:
+ return 1;
+ case 1:
+ return -1;
+ case 2:
+ return 1;
+ case 3:
+ return -1;
+ default:
+ return 0;
+ }
+ }
+
+ private int mYR()
+ {
+ return 0;
+ }
+
+ private int mZR()
+ {
+ switch(this.getFacing())
+ {
+ case 4:
+ return -1;
+ case 5:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ private int mXT()
+ {
+ return 0;
+ }
+
+ private int mYT()
+ {
+ switch(this.getFacing())
+ {
+ case 2:
+ return 1;
+ case 3:
+ return 1;
+ case 4:
+ return 1;
+ case 5:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ private int mZT()
+ {
+ switch(this.getFacing())
+ {
+ case 0:
+ return 1;
+ case 1:
+ return -1;
+ default:
+ return 0;
+ }
+ }
+
+ @Override
+ public AxisAlignedBB getRenderBoundingBox()
+ {
+ double xMinD=(double)this.xCoord-this.reflectExtensionRight*Math.abs(this.mXR())-this.reflectExtensionTop*Math.abs(this.mXT());
+ double xMaxD=(double)this.xCoord+this.reflectExtensionRight*Math.abs(this.mXR())+this.reflectExtensionTop*Math.abs(this.mXT())+1d;
+ double yMinD=(double)this.yCoord-this.reflectExtensionRight*Math.abs(this.mYR())-this.reflectExtensionTop*Math.abs(this.mYT());
+ double yMaxD=(double)this.yCoord+this.reflectExtensionRight*Math.abs(this.mYR())+this.reflectExtensionTop*Math.abs(this.mYT())+1d;
+ double zMinD=(double)this.zCoord-this.reflectExtensionRight*Math.abs(this.mZR())-this.reflectExtensionTop*Math.abs(this.mZT());
+ double zMaxD=(double)this.zCoord+this.reflectExtensionRight*Math.abs(this.mZR())+this.reflectExtensionTop*Math.abs(this.mZT())+1d;
+ return AxisAlignedBB.getBoundingBox(xMinD, yMinD, zMinD, xMaxD, yMaxD, zMaxD);
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/explosion/ChunkAndWorldLoadEventHandler.java b/src/main/java/ihl/explosion/ChunkAndWorldLoadEventHandler.java new file mode 100644 index 0000000..c2f7e0b --- /dev/null +++ b/src/main/java/ihl/explosion/ChunkAndWorldLoadEventHandler.java @@ -0,0 +1,59 @@ +package ihl.explosion; + +import java.util.Iterator; +import java.util.Set; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import ihl.IHLMod; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.Explosion; + +public class ChunkAndWorldLoadEventHandler { + public static ChunkAndWorldLoadEventHandler instance; + + public ChunkAndWorldLoadEventHandler() { + instance = this; + } + + @SubscribeEvent + public void onChunkLoadEvent(net.minecraftforge.event.world.ChunkEvent.Load event) { + if (event.getChunk().isChunkLoaded + && IHLMod.explosionHandler.blastWaveByDimensionId.containsKey(event.world.provider.dimensionId)) { + WorldSavedDataBlastWave bwdata = IHLMod.explosionHandler.blastWaveByDimensionId + .get(event.world.provider.dimensionId); + long cc = ChunkCoordIntPair.chunkXZ2Int(event.getChunk().xPosition, event.getChunk().zPosition); + if (bwdata.data.containsKey(cc)) { + Set<Integer[]> bwArraySet = bwdata.data.remove(cc); + int[] directionMask = new int[3]; + Iterator<Integer[]> bwArrayI = bwArraySet.iterator(); + Integer[] bwArray = null; + while (bwArrayI.hasNext()) { + bwArray = bwArrayI.next(); + directionMask[0] = bwArray[5]; + directionMask[1] = bwArray[6]; + directionMask[2] = bwArray[7]; + Explosion explosion = new Explosion(event.world, null, bwArray[1], bwArray[2], bwArray[3], 100f); + IHLMod.explosionHandler.breakBlocksAndGetDescendants(event.world, bwArray[1], bwArray[2], + bwArray[3], explosion, bwArray[0], bwArray[4], directionMask); + } + } + } + } + + @SubscribeEvent + public void onWorldLoadEvent(net.minecraftforge.event.world.WorldEvent.Load event) { + WorldSavedDataBlastWave blastWave = (WorldSavedDataBlastWave) event.world.mapStorage + .loadData(WorldSavedDataBlastWave.class, "blastWave"); + if (blastWave != null) { + IHLMod.explosionHandler.blastWaveByDimensionId.put(event.world.provider.dimensionId, blastWave); + } + } + + @SubscribeEvent + public void onWorldSaveEvent(net.minecraftforge.event.world.WorldEvent.Save event) { + if (IHLMod.explosionHandler.blastWaveByDimensionId.containsKey(event.world.provider.dimensionId)) { + event.world.mapStorage.setData("blastWave", + IHLMod.explosionHandler.blastWaveByDimensionId.get(event.world.provider.dimensionId)); + } + } +} diff --git a/src/main/java/ihl/explosion/DetonatorMiniGUI.java b/src/main/java/ihl/explosion/DetonatorMiniGUI.java new file mode 100644 index 0000000..4a93050 --- /dev/null +++ b/src/main/java/ihl/explosion/DetonatorMiniGUI.java @@ -0,0 +1,82 @@ +package ihl.explosion; + +import java.awt.event.KeyEvent; + +import org.lwjgl.opengl.GL11; + +import ihl.IHLMod; +import ihl.interfaces.ItemMiniGUI; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class DetonatorMiniGUI extends ItemMiniGUI { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIIronWorkbench.png"); + private int detonator_delay; + private GuiTextField detonatorDelayTextField; + private int xPos; + private int yPos; + + public DetonatorMiniGUI(GuiContainer gui, Slot slot) { + super(gui, slot); + detonator_delay = slot.getStack().stackTagCompound.getInteger("detonator_delay"); + xPos = this.slotBase.xDisplayPosition - 18; + yPos = this.slotBase.yDisplayPosition + 18; + detonatorDelayTextField = new GuiTextField(this.guiBase.mc.fontRenderer, xPos + TEXT_BOX_POSX, + yPos + TEXT_BOX_POSY, TEXT_BOX_WIDTH, 11); + detonatorDelayTextField.setText(Integer.toString(detonator_delay)); + detonatorDelayTextField.setFocused(true); + } + + @Override + public void displayGUI() { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.guiBase.mc.renderEngine.bindTexture(background); + this.guiBase.drawTexturedModalRect(xPos, yPos, 0, 202, 126, HEIGHT); + int runnerXPos = xPos + 5 + 114 * detonator_delay / 1350; + this.guiBase.drawTexturedModalRect(runnerXPos, yPos + 34, 126, 202, 3, 5); + this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.detonator_delay"), + xPos + 3, yPos + 4, 0xFFCC00); + this.detonatorDelayTextField.drawTextBox(); + this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("s"), xPos + UNITS_LABEL_POSX, yPos + 18, + 0xFFCC00); + } + + @Override + public boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) { + if (mouseX >= xPos + 5 && mouseX <= xPos + 119 && mouseY >= yPos + RUNNER_POSY - 1 && mouseY <= yPos + HEIGHT) { + this.detonator_delay = Math.max(1, Math.min(1350, (mouseX - xPos - 5) * 1350 / 114)); + this.detonatorDelayTextField.setText(Integer.toString(detonator_delay)); + } + if (mouseX >= xPos + TEXT_BOX_POSX && mouseX <= xPos + TEXT_BOX_POSX + TEXT_BOX_WIDTH && mouseY >= yPos + 3 + && mouseY <= yPos + 3 + 11) { + this.detonatorDelayTextField.setFocused(true); + } + return mouseX >= xPos && mouseX <= xPos + 202 && mouseY >= yPos && mouseY <= yPos + HEIGHT; + } + + @Override + public boolean handleKeyTyped(char characterTyped, int keyIndex) { + this.detonatorDelayTextField.textboxKeyTyped(characterTyped, keyIndex); + // 28 - enter; 156 - numpad enter + if (keyIndex == KeyEvent.VK_ACCEPT || keyIndex == KeyEvent.VK_ENTER || keyIndex == 28 || keyIndex == 156) { + this.detonator_delay = Math.max(1, Math.min(1350, + (int) (IHLUtils.parseIntSafe(this.detonatorDelayTextField.getText(), this.detonator_delay)))); + this.detonatorDelayTextField.setText(Integer.toString(detonator_delay)); + this.detonatorDelayTextField.setFocused(false); + return true; + } + return false; + } + + @Override + public void onGUIClosed() { + IHLMod.proxy.sendItemStackNBTTagFromClientToServerPlayer(this.guiBase.mc.thePlayer, this.slotBase.slotNumber, + "detonator_delay", this.detonator_delay); + } + +} diff --git a/src/main/java/ihl/explosion/ExplosionEntityFX.java b/src/main/java/ihl/explosion/ExplosionEntityFX.java new file mode 100644 index 0000000..ffa91fa --- /dev/null +++ b/src/main/java/ihl/explosion/ExplosionEntityFX.java @@ -0,0 +1,177 @@ +package ihl.explosion;
+
+import java.util.Random;
+
+import ihl.utils.IHLMathUtils;
+import net.minecraft.client.particle.EntityFX;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.world.World;
+
+public class ExplosionEntityFX extends EntityFX {
+
+ private float radius;
+ private static final Random random = new Random();
+ private final int[] particlesMaxAge;
+ private final int[] particlesTextureIndexX;
+ private final int[] particlesTextureIndexY;
+ private final double[][] startPos;
+ private final double[][] pos;
+ private final double[][] prevPos;
+ private final float[][] motion;
+ private final int[] center;
+
+ public ExplosionEntityFX(World world, double x, double y, double z)
+ {
+ super(world, x, y, z);
+ this.renderDistanceWeight = 5.0D;
+ int numParticles = 1;
+ particlesMaxAge = new int[numParticles];
+ particlesTextureIndexX = new int[numParticles];
+ particlesTextureIndexY= new int[numParticles];
+ startPos = new double[numParticles][3];
+ pos = new double[numParticles][3];
+ prevPos = new double[numParticles][3];
+ motion = new float[numParticles][3];
+ center = new int[3];
+ }
+
+ public ExplosionEntityFX(World par1World, int centerX1, int centerY1, int centerZ1, float radius1)
+ {
+ super(par1World, centerX1, centerY1, centerZ1, 0.0D, 0.0D, 0.0D);
+ this.particleMaxAge = 100;
+ this.center = new int[3];
+ this.lastTickPosX=this.posX=this.prevPosX=this.center[0]=centerX1;
+ this.lastTickPosY=this.posY=this.prevPosY=this.center[1]=centerY1;
+ this.lastTickPosZ=this.posZ=this.prevPosZ=this.center[2]=centerZ1;
+ this.radius=radius1;
+ float r2 = radius*radius;
+ int numParticles = Math.min((int)(r2*radius/32)+64,512);
+ this.startPos = new double[numParticles][3];
+ this.pos = new double[numParticles][3];
+ this.prevPos = new double[numParticles][3];
+ this.particleScale *= 40f;
+ this.particlesMaxAge = new int[numParticles];
+ this.particlesTextureIndexX = new int[numParticles];
+ this.particlesTextureIndexY= new int[numParticles];
+ this.motion = new float[numParticles][3];
+ for(int i=0;i<numParticles;i++)
+ {
+ float fPosX = random.nextFloat()*2f-1f;
+ float fPosY = (random.nextFloat()*2f-1f)*IHLMathUtils.sqrt(1f-fPosX*fPosX);
+ float fPosZ = (random.nextFloat()*2f-1f)*IHLMathUtils.sqrt(1f-fPosX*fPosX-fPosY*fPosY);
+ fPosX *= radius1;
+ fPosY *= radius1;
+ fPosZ *= radius1;
+ prevPos[i][0] = pos[i][0] = startPos[i][0] = fPosX + centerX1;
+ prevPos[i][1] = pos[i][1] = startPos[i][1] = fPosY + centerY1;
+ prevPos[i][2] = pos[i][2] = startPos[i][2] = fPosZ + centerZ1;
+ particlesMaxAge[i] = random.nextInt(particleMaxAge-20)+16;
+ particlesTextureIndexY[i]=random.nextInt(8);
+ }
+ this.noClip = true;
+ this.renderDistanceWeight = 6.0D+radius1/2;
+ }
+
+ @Override
+ public void renderParticle(Tessellator tessellator, float interFrame, float rotationX, float rotationXZ, float rotationZ, float rotationYZ, float rotationXY)
+ {
+ for(int i=0;i<particlesMaxAge.length;i++)
+ {
+ float u1 = this.particlesTextureIndexX[i] / 16.0F;
+ float u2 = u1 + 1F / 16.0F;
+ float v1 = this.particlesTextureIndexY[i] / 8.0F;
+ float v2 = v1 + 1F / 8.0F;
+ float scale = 0.1F * this.particleScale;
+
+ float fPosX = (float)(this.prevPos[i][0] - this.prevPosX + (this.pos[i][0] - this.prevPos[i][0]) * interFrame);
+ float fPosY = (float)(this.prevPos[i][1] - this.prevPosY + (this.pos[i][1] - this.prevPos[i][1]) * interFrame);
+ float fPosZ = (float)(this.prevPos[i][2] - this.prevPosZ + (this.pos[i][2] - this.prevPos[i][2]) * interFrame);
+ tessellator.addVertexWithUV(
+ fPosX - rotationX * scale - rotationYZ * scale,
+ fPosY - rotationXZ * scale,
+ fPosZ - rotationZ * scale - rotationXY * scale,
+ u2, v2);
+ tessellator.addVertexWithUV(
+ fPosX - rotationX * scale + rotationYZ * scale,
+ fPosY + rotationXZ * scale,
+ fPosZ - rotationZ * scale + rotationXY * scale,
+ u2, v1);
+ tessellator.addVertexWithUV(
+ fPosX + rotationX * scale + rotationYZ * scale,
+ fPosY + rotationXZ * scale,
+ fPosZ + rotationZ * scale + rotationXY * scale,
+ u1, v1);
+ tessellator.addVertexWithUV(
+ fPosX + rotationX * scale - rotationYZ * scale,
+ fPosY - rotationXZ * scale,
+ fPosZ + rotationZ * scale - rotationXY * scale,
+ u1, v2);
+ }
+ }
+
+ @Override
+ public void onUpdate()
+ {
+ if (this.particleAge++ >= this.particleMaxAge)
+ {
+ this.setDead();
+ }
+ for(int i=0;i<particlesMaxAge.length;i++)
+ {
+ this.prevPos[i][0] = this.pos[i][0];
+ this.prevPos[i][1] = this.pos[i][1];
+ this.prevPos[i][2] = this.pos[i][2];
+
+ int maxFrameX = 15;
+ int frameX = this.particleAge * maxFrameX / this.particlesMaxAge[i];
+ if(frameX<=maxFrameX)
+ {
+ this.particlesTextureIndexX[i] = frameX;
+ }
+
+ if(this.startPos[i][1] < this.center[1])
+ {
+ IHLMathUtils.vector_add(this.motion[i],
+ (float)(this.center[0]-this.pos[i][0])*0.0004f,
+ 0.004f,
+ (float)(this.center[2]-this.pos[i][2])*0.0004f);
+ }
+ else
+ {
+ float[] ring = new float[] {
+ (float)(this.startPos[i][0]-this.center[0]),
+ 0f,
+ (float)(this.startPos[i][2]-this.center[2])};
+ IHLMathUtils.scale_vector_to_value(ring, radius*0.6f);
+ IHLMathUtils.vector_add(ring,
+ this.center[0],
+ (float)this.startPos[i][1]+this.particleAge*0.001f,
+ this.center[2]);
+ float[] from_point_to_ring = IHLMathUtils.vector_return_difference(ring,this.pos[i]);
+ float[] from_point_to_center = IHLMathUtils.vector_return_difference(this.center,this.pos[i]);
+ float[] tangent_to_ring = IHLMathUtils.vector_vector_multiply(from_point_to_ring, from_point_to_center);
+ float[] tangent_to_torus = IHLMathUtils.vector_vector_multiply(from_point_to_ring, tangent_to_ring);
+ IHLMathUtils.normalize_vector(tangent_to_torus);
+ IHLMathUtils.vector_add(this.motion[i],
+ from_point_to_ring[0]*0.01f + tangent_to_torus[0]*0.02f,
+ from_point_to_ring[1]*0.01f + tangent_to_torus[1]*0.02f + 0.004f,
+ from_point_to_ring[2]*0.01f + tangent_to_torus[2]*0.02f);
+ }
+ IHLMathUtils.vector_add(this.pos[i],this.motion[i]);
+ IHLMathUtils.multiply_vector_to_value(this.motion[i], 0.98f);
+ }
+ }
+
+ @Override
+ public void setParticleTextureIndex(int par1)
+ {
+ this.particleTextureIndexX = par1;
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==1;
+ }
+
+}
diff --git a/src/main/java/ihl/explosion/ExplosionRenderFX.java b/src/main/java/ihl/explosion/ExplosionRenderFX.java new file mode 100644 index 0000000..18bfd4f --- /dev/null +++ b/src/main/java/ihl/explosion/ExplosionRenderFX.java @@ -0,0 +1,52 @@ +package ihl.explosion;
+
+import org.lwjgl.opengl.GL11;
+
+import net.minecraft.client.particle.EntityFX;
+import net.minecraft.client.renderer.ActiveRenderInfo;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.entity.Entity;
+import net.minecraft.util.ResourceLocation;
+
+public class ExplosionRenderFX extends Render{
+ private ResourceLocation tex;
+
+public ExplosionRenderFX(String textureLocation)
+{
+ super();
+ tex = new ResourceLocation(textureLocation);
+}
+
+@Override
+public void doRender(Entity entity, double x, double y, double z,
+ float interFrame, float arg5)
+{
+ float rotationX = ActiveRenderInfo.rotationX;
+ float rotationZ = ActiveRenderInfo.rotationZ;
+ float rotationYZ = ActiveRenderInfo.rotationYZ;
+ float rotationXY = ActiveRenderInfo.rotationXY;
+ float rotationXZ = ActiveRenderInfo.rotationXZ;
+ this.renderManager.renderEngine.bindTexture(tex);
+ GL11.glPushMatrix();
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GL11.glTranslatef((float)x, (float)y, (float)z);
+ GL11.glDepthMask(false);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ Tessellator tessellator = Tessellator.instance;
+ tessellator.startDrawingQuads();
+ EntityFX entityFX = (EntityFX) entity;
+ entityFX.renderParticle(tessellator, interFrame, rotationX, rotationXZ, rotationZ, rotationYZ, rotationXY);
+ tessellator.draw();
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glDepthMask(true);
+ GL11.glPopMatrix();
+}
+
+ @Override
+ protected ResourceLocation getEntityTexture(Entity arg0)
+ {
+ return tex;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/explosion/ExplosionVectorBlockV2.java b/src/main/java/ihl/explosion/ExplosionVectorBlockV2.java new file mode 100644 index 0000000..e00e19a --- /dev/null +++ b/src/main/java/ihl/explosion/ExplosionVectorBlockV2.java @@ -0,0 +1,363 @@ +package ihl.explosion;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+
+import ihl.IHLMod;
+import ihl.utils.IHLUtils;
+import net.minecraft.block.Block;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.network.play.server.S26PacketMapChunkBulk;
+import net.minecraft.util.DamageSource;
+import net.minecraft.world.ChunkCoordIntPair;
+import net.minecraft.world.Explosion;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.world.ExplosionEvent;
+
+public class ExplosionVectorBlockV2 {
+ final Set<Integer> startVectors = new HashSet<Integer>();
+ public final int[][] directionMasks = new int[8][3];
+ public final int bits = IHLMod.config.explosionVectorSizeBits;
+ private final int maxValue = (1 << bits) - 1;
+ public final int halfValue = (1 << bits - 1) - 1;
+ private final int maxArraySize = 1 << bits * 3;
+// public final int[][] vectors = new int[maxArraySize][2];
+ public final int[][] vectors = new int[maxArraySize][0];
+ private final Set<Chunk> chunksToUpdate = new HashSet<Chunk>(64);
+ private final Map<Integer, ItemStack> cachedDrops = new HashMap<Integer, ItemStack>(128);
+ final Map<Integer, WorldSavedDataBlastWave> blastWaveByDimensionId = new HashMap<Integer, WorldSavedDataBlastWave>();
+ private final Map<ExtendedBlockStorage, Entity[]> cachedEntities = new HashMap<ExtendedBlockStorage, Entity[]>();
+ private final Random random = new Random();
+
+ public ExplosionVectorBlockV2() {
+ this.precalculateExplosion();
+ startVectors.add(0);
+ directionMasks[0] = new int[] { 1, 1, 1 };
+ directionMasks[1] = new int[] { -1, 1, 1 };
+ directionMasks[2] = new int[] { 1, -1, 1 };
+ directionMasks[3] = new int[] { 1, 1, -1 };
+ directionMasks[4] = new int[] { -1, -1, 1 };
+ directionMasks[5] = new int[] { 1, -1, -1 };
+ directionMasks[6] = new int[] { -1, 1, -1 };
+ directionMasks[7] = new int[] { -1, -1, -1 };
+ }
+
+ public int encodeXYZ(int x, int y, int z) {
+ return x << bits * 2 | y << bits | z;
+ }
+
+ public int[] decodeXYZ(int l) {
+ return new int[] { l >> bits * 2, l >> bits & maxValue, l & maxValue };
+ }
+
+ public void precalculateExplosion() {
+ for (int levelRadius = 1; levelRadius <= this.maxValue; levelRadius++)
+ for (int ix = 0; ix <= levelRadius; ix++)
+ for (int iy = 0; iy <= levelRadius; iy++) {
+ for (int iz = (ix == levelRadius || iy == levelRadius) ? 0 : levelRadius; iz <= levelRadius; iz++) {
+ int vxyz = encodeXYZ(ix, iy, iz);
+ int[] prevXYZ = new int[] { ix, iy, iz };
+ reduceCoordinate(prevXYZ, levelRadius);
+ int pvxyz = encodeXYZ(prevXYZ[0], prevXYZ[1], prevXYZ[2]);
+ findFreeSpace(pvxyz, vxyz);
+ }
+ }
+ }
+
+ private void findFreeSpace(int pvxyz, int vxyz) {
+ int[] nV = new int[vectors[pvxyz].length+1];
+ for(int i=0;i<vectors[pvxyz].length;i++){
+ nV[i]=vectors[pvxyz][i];
+ }
+ nV[vectors[pvxyz].length] = vxyz;
+ vectors[pvxyz] = nV;
+ }
+
+ private void reduceCoordinate(int[] pxyz, int levelRadius) {
+ float x = pxyz[0]+0.5f;
+ float y = pxyz[1]+0.5f;
+ float z = pxyz[2]+0.5f;
+ float rx = x/levelRadius;
+ float ry = y/levelRadius;
+ float rz = z/levelRadius;
+ while(x>=pxyz[0] && y>=pxyz[1] && z>=pxyz[2]){
+ x-=rx;
+ y-=ry;
+ z-=rz;
+ }
+ pxyz[0]=x<0?0:(int)x;
+ pxyz[1]=y<0?0:(int)y;
+ pxyz[2]=z<0?0:(int)z;
+ }
+
+ public void breakBlocksAndGetDescendants(World world, int sourceX, int sourceY, int sourceZ, Explosion explosion,
+ int ev, int power, int[] directionMask) {
+ power = this.getNewPowerAndProcessBlocks(world, ev, sourceX, sourceY, sourceZ, explosion, power, directionMask);
+ power = (int) (power * 0.94) - 1;
+ if (power > 1) {
+ if (this.vectors[ev].length==0) {
+ int[] xyz = 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 = encodeXYZ(xyz[0], xyz[1], xyz[2]);
+ breakBlocksAndGetDescendants(world, sourceX + xb * halfValue * directionMask[0],
+ sourceY + yb * halfValue * directionMask[1], sourceZ + zb * halfValue * directionMask[2],
+ explosion, ev2, power, directionMask);
+ } else {
+ for (int d1 : this.vectors[ev]) {
+ breakBlocksAndGetDescendants(world, sourceX, sourceY, sourceZ, explosion, d1, power,
+ directionMask);
+ }
+ }
+ }
+ }
+
+ private int getNewPowerAndProcessBlocks(World world, int ev, int sourceX, int sourceY, int sourceZ,
+ Explosion explosion, int power2, int[] directionMask) {
+ int power1 = power2;
+ int[] xyz = decodeXYZ(ev);
+ int absX = xyz[0] * directionMask[0] + sourceX;
+ int absY = xyz[1] * directionMask[1] + sourceY;
+ int absZ = xyz[2] * directionMask[2] + sourceZ;
+ if (absY < 0 || absY >= 256) {
+ return 0;
+ }
+ int absEBSX = absX >> 4;
+ int absEBSZ = absZ >> 4;
+ if (world.getChunkProvider().chunkExists(absEBSX, absEBSZ)) {
+ if (world.getChunkProvider().provideChunk(absEBSX, absEBSZ).getTopFilledSegment() + 24 >= absY) {
+ int remainingPower = this.tryDestroyBlock(world, absX, absY, absZ, sourceX, sourceY, sourceZ, power1,
+ explosion);
+ return remainingPower;
+ } else {
+ return 0;
+ }
+ } else {
+ WorldSavedDataBlastWave blastWave = null;
+ int dimensionId = world.provider.dimensionId;
+ if (this.blastWaveByDimensionId.containsKey(dimensionId)) {
+ blastWave = this.blastWaveByDimensionId.get(dimensionId);
+ } else {
+ blastWave = new WorldSavedDataBlastWave("blastWave");
+ this.blastWaveByDimensionId.put(dimensionId, blastWave);
+ }
+ long chunkXZKey = ChunkCoordIntPair.chunkXZ2Int(absEBSX, absEBSZ);
+ blastWave.scheduleExplosionEffectsOnChunkLoad(chunkXZKey, ev, sourceX, sourceY, sourceZ, power1,
+ directionMask);
+ return 0;
+ }
+ }
+
+ public int tryDestroyBlock(World world, int absX, int absY, int absZ, int sourceX, int sourceY, int sourceZ,
+ int power, Explosion explosion) {
+ Chunk chunk = world.getChunkProvider().provideChunk(absX >> 4, absZ >> 4);
+ ExtendedBlockStorage ebs = this.getEBS(chunk, absX, absY, absZ);
+ if (ebs == null) {
+ return power;
+ } else {
+ Block block = ebs.getBlockByExtId(absX & 15, absY & 15, absZ & 15);
+ if (block.getBlockHardness(world, absX, absY, absZ) < 0) {
+ return 0;
+ } else if (absX == sourceX && absY == sourceY && absZ == sourceZ) {
+ int array_index = (absY & 15) << 8 | (absZ & 15) << 4 | (absX & 15);
+ if (ebs.getBlockLSBArray()[array_index] != 0 && ebs.getBlockMSBArray() != null
+ && ebs.getBlockMSBArray().get(absX & 15, absY & 15, absZ & 15) != 0) {
+ ebs.blockRefCount--;
+ }
+ ebs.getBlockLSBArray()[array_index] = 0;
+ if (ebs.getBlockMSBArray() != null) {
+ ebs.getBlockMSBArray().set(absX & 15, absY & 15, absZ & 15, 0);
+ }
+ return power;
+ } else {
+ int remainingPower = power
+ - (int) (block.getExplosionResistance(null, world, absX, absY, absZ, sourceX, sourceY, sourceZ)
+ * 10f + 0.5f);
+ if (remainingPower >= 0) {
+ int array_index = (absY & 15) << 8 | (absZ & 15) << 4 | (absX & 15);
+ if (ebs.getBlockLSBArray()[array_index] != 0 && ebs.getBlockMSBArray() != null
+ && ebs.getBlockMSBArray().get(absX & 15, absY & 15, absZ & 15) != 0) {
+ ebs.blockRefCount--;
+ }
+ ebs.getBlockLSBArray()[array_index] = 0;
+ if (ebs.getBlockMSBArray() != null) {
+ ebs.getBlockMSBArray().set(absX & 15, absY & 15, absZ & 15, 0);
+ }
+ List<ItemStack> dropsList = block.getDrops(world, absX, absY, absZ,
+ ebs.getExtBlockMetadata(absX & 15, absY & 15, absZ & 15), 0);
+ Iterator<ItemStack> drops = dropsList.iterator();
+ while (drops.hasNext()) {
+ ItemStack drop = drops.next();
+ int key = Item.getIdFromItem(drop.getItem()) ^ (drop.getItemDamage() << 16);
+ if (this.cachedDrops.containsKey(key)) {
+ this.cachedDrops.get(key).stackSize += drop.stackSize;
+ } else {
+ this.cachedDrops.put(key, drop);
+ }
+ }
+ Entity[] entities = this.getFromOrCreateCache(world, ebs, absX, absY, absZ);
+ if (entities != null && entities[array_index] != null) {
+ entities[array_index].attackEntityFrom(DamageSource.setExplosionSource(explosion), power / 10f);
+ }
+ } else {
+ block.onNeighborBlockChange(world, absX, absY, absZ, block);
+ if (random.nextInt(8) == 0) {
+ if ((++absY & 15) != 0) {
+ int array_index = (absY & 15) << 8 | (absZ & 15) << 4 | (absX & 15);
+ if (ebs.getBlockLSBArray()[array_index] == 0 && (ebs.getBlockMSBArray() == null
+ || ebs.getBlockMSBArray().get(absX & 15, absY & 15, absZ & 15) == 0)) {
+ this.placeDrops(world, absX, absY, absZ);
+ }
+ }
+ }
+ }
+ return remainingPower;
+ }
+ }
+ }
+
+ public Entity[] getFromOrCreateCache(World world, ExtendedBlockStorage ebs, int absX, int absY, int absZ) {
+ Entity[] entities = this.cachedEntities.get(ebs);
+ if (entities == null) {
+ Chunk chunk = world.getChunkProvider().provideChunk(absX >> 4, absZ >> 4);
+ List<Entity> eList = this.getEntityList(chunk, absX, absY, absZ);
+ if (eList != null && !eList.isEmpty()) {
+ entities = new Entity[4096];
+ Iterator<Entity> eListI = eList.iterator();
+ this.cachedEntities.put(ebs, entities);
+ while (eListI.hasNext()) {
+ Entity entity = eListI.next();
+ int entityX = (int) entity.boundingBox.minX;
+ int entityY = (int) entity.boundingBox.minY;
+ int entityZ = (int) entity.boundingBox.minZ;
+ int rx = entityX & 15;
+ int ry = entityY & 15;
+ int rz = entityZ & 15;
+ int array_index = ry << 8 | rz << 4 | rx;
+ entities[array_index] = entity;
+ }
+ }
+ }
+ return entities;
+ }
+
+ public ExtendedBlockStorage getEBS(Chunk chunk, int absX, int absY, int absZ) {
+ ExtendedBlockStorage[] ebsA = chunk.getBlockStorageArray();
+ ExtendedBlockStorage ebs = ebsA[absY >> 4];
+ if (ebs != null) {
+ this.chunksToUpdate.add(chunk);
+ }
+ return ebs;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Entity> getEntityList(Chunk chunk, int absX, int absY, int absZ) {
+ return chunk.entityLists[absY >> 4];
+ }
+
+ private void placeDrops(World world, int x, int y, int z) {
+ Iterator<Entry<Integer, ItemStack>> di = this.cachedDrops.entrySet().iterator();
+ if (di.hasNext()) {
+ Entry<Integer, ItemStack> cde = di.next();
+ while (di.hasNext()) {
+ cde = di.next();
+ }
+ ItemStack stack = cde.getValue();
+ if (stack != null && stack.getItem() != null && stack.stackSize > 0) {
+ if (stack.stackSize <= stack.getMaxStackSize()) {
+ if (stack.stackSize > 0) {
+ PileTileEntity pte = new PileTileEntity();
+ pte.xCoord = x;
+ pte.yCoord = y;
+ pte.zCoord = z;
+ pte.setWorldObj(world);
+ pte.validate();
+ pte.setContent(stack);
+ IHLUtils.setBlockAndTileEntityRaw(world, x, y, z, PileBlock.instance, pte);
+ }
+ di.remove();
+ } else {
+ ItemStack stack1 = stack.copy();
+ stack1.stackSize = stack.getMaxStackSize();
+ PileTileEntity pte = new PileTileEntity();
+ pte.content = stack1;
+ IHLUtils.setBlockAndTileEntityRaw(world, x, y, z, PileBlock.instance, pte);
+ stack.stackSize -= stack.getMaxStackSize();
+ }
+ }
+ }
+ }
+
+ public void sendChunkUpdateToPlayersInExplosionAffectedZone(World world, int sourceX, int sourceY, int sourceZ) {
+ Iterator<Chunk> ci = this.chunksToUpdate.iterator();
+ while (ci.hasNext()) {
+ Chunk chunk = ci.next();
+ chunk.generateSkylightMap();
+ Arrays.fill(chunk.updateSkylightColumns, true);
+ chunk.func_150804_b(false);
+ }
+ List<Chunk> chunks = new ArrayList<Chunk>();
+ chunks.addAll(this.chunksToUpdate);
+ for (Object player : world.playerEntities) {
+ if (player instanceof EntityPlayerMP) {
+ EntityPlayerMP playerMP = (EntityPlayerMP) player;
+ playerMP.playerNetServerHandler.sendPacket(new S26PacketMapChunkBulk(chunks));
+ }
+ }
+ this.chunksToUpdate.clear();
+ }
+
+ public void doExplosion(World world, int sourceX, int sourceY, int sourceZ, final Set<Integer> startVectors1,
+ int startPower, int[] directionMask, Explosion explosion) {
+ for (int sv : startVectors1) {
+ this.breakBlocksAndGetDescendants(world, sourceX - (directionMask[0] < 0 ? 1 : 0),
+ sourceY - (directionMask[1] < 0 ? 1 : 0), sourceZ - (directionMask[2] < 0 ? 1 : 0), explosion, sv,
+ startPower, directionMask);
+ }
+ // Free and clean resources
+ this.cachedEntities.clear();
+ }
+
+ public void doExplosion(World world, int sourceX, int sourceY, int sourceZ, final Set<Integer> startVectors1,
+ int startPower) {
+ IHLMod.log.info("Starting explosion server");
+ Explosion explosion = new Explosion(world, null, sourceX, sourceY, sourceZ, 100f);
+ if (!MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Start(world, explosion))) {
+ for (int[] directionMask : directionMasks) {
+ this.doExplosion(world, sourceX, sourceY, sourceZ, startVectors1, startPower, directionMask, explosion);
+ }
+ sendChunkUpdateToPlayersInExplosionAffectedZone(world, sourceX, sourceY, sourceZ);
+ for (Entry<Integer, ItemStack> entry : this.cachedDrops.entrySet()) {
+ IHLEntityFallingPile fallingPile = new IHLEntityFallingPile(world);
+ fallingPile.setPosition(sourceX + 0.5d, sourceY + 0.5d, sourceZ + 0.5d);
+ fallingPile.setEntityItemStack(entry.getValue());
+ fallingPile.setVelocity(random.nextDouble() - 0.5d, random.nextDouble() * 2,
+ random.nextDouble() - 0.5d);
+ world.spawnEntityInWorld(fallingPile);
+ }
+ this.cachedDrops.clear();
+ }
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/explosion/ExplosiveBlock.java b/src/main/java/ihl/explosion/ExplosiveBlock.java new file mode 100644 index 0000000..d6b1c71 --- /dev/null +++ b/src/main/java/ihl/explosion/ExplosiveBlock.java @@ -0,0 +1,252 @@ +package ihl.explosion; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.IC2; +import ihl.IHLCreativeTab; +import ihl.IHLModInfo; +import ihl.items_blocks.IHLItemBlock; +import ihl.processing.metallurgy.MuffleFurnanceTileEntity; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class ExplosiveBlock extends Block implements ITileEntityProvider{ + + IIcon[] textures = new IIcon[6]; + + public ExplosiveBlock() + { + super(Material.tnt); + this.setCreativeTab(IHLCreativeTab.tab); + this.setBlockName("ihlExplosive"); + this.setHardness(2F); + this.setResistance(1F); + } + + @Override + @SuppressWarnings({ "rawtypes", "unchecked" }) + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) + { + ItemStack result = new ItemStack(item); + result.stackTagCompound=new NBTTagCompound(); + result.stackTagCompound.setInteger("explosionType", 1);//0 - IC2; 1- IHL + result.stackTagCompound.setInteger("explosionPower", 31000); + itemList.add(result); + result = new ItemStack(item); + result.stackTagCompound=new NBTTagCompound(); + result.stackTagCompound.setInteger("explosionType", 1);//0 - IC2; 1- IHL + result.stackTagCompound.setInteger("explosionPower", Integer.MAX_VALUE);//31000 + itemList.add(result); + } + + @Override + @SuppressWarnings("rawtypes") + public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.1F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.9F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBounds(0.0F, 0.0F, 0.9F, 1.0F, 1.0F, 1.0F); + super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); + this.setBlockBoundsForItemRender(); + } + + @Override + public void setBlockBoundsForItemRender() + { + this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + + public static void init() + { + GameRegistry.registerBlock(new ExplosiveBlock(), IHLItemBlock.class,"ihlExplosive"); + GameRegistry.registerTileEntity(ExplosiveTileEntity.class, "explosiveTileEntity"); + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) + { + super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag); + } + + @Override + public TileEntity createNewTileEntity(World world, int var2) { + return new ExplosiveTileEntity(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":explosiveBlockSide"); + this.textures[0] = par1IconRegister.registerIcon(IHLModInfo.MODID + ":explosiveBlockBottom"); + this.textures[1] = par1IconRegister.registerIcon(IHLModInfo.MODID + ":explosiveBlockTop"); + this.textures[2] = this.textures[3] = this.textures[4] = this.textures[5] = this.blockIcon; + } + + @Override + public boolean hasTileEntity(int metadata) + { + return true; + } + + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z){ + TileEntity te = world.getTileEntity(x,y,z); + if(IC2.platform.isSimulating() && te instanceof ExplosiveTileEntity) + { + return ((ExplosiveTileEntity)te).ignite(player); + } + return false; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + { + TileEntity te = world.getTileEntity(x,y,z); + if(IC2.platform.isSimulating() && te instanceof ExplosiveTileEntity) + { + int[] xyz = {0,0,1,0,0,-1,0,0}; + for(int i=2;i<xyz.length;i++) + { + if(world.getBlock(x+xyz[i-2], y+xyz[i-1], z+xyz[i])==Blocks.fire && !te.isInvalid()) + { + ((ExplosiveTileEntity)te).ignite(); + } + } + } + } + + /** + * Called when the block is placed in the world. + */ + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) + { + TileEntity t = world.getTileEntity(x, y, z); + if(t!=null) + { + t.readFromNBT(itemStack.stackTagCompound); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) + { + return this.getIcon(side, 0); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) + { + return this.textures[side]; + } + + @Override + public boolean onBlockEventReceived(World world, int x, int y, int z, int metadata, int flag) + { + return true; + } + + public enum ExplosiveType + { + MuffleFurnace("muffleFurnance",MuffleFurnanceTileEntity.class, true, new ItemStack(Items.brick)); + ExplosiveType(String unlocalizedName1, Class<?> teclass1, boolean isNormalBlock1,ItemStack itemDroppedOnBlockDestroy1) + { + unlocalizedName=unlocalizedName1; + teclass=teclass1; + isNormalBlock=isNormalBlock1; + itemDroppedOnBlockDestroy=itemDroppedOnBlockDestroy1; + } + String unlocalizedName; + Class<?> teclass; + boolean isNormalBlock=true; + ItemStack itemDroppedOnBlockDestroy; + } + + @Override + public int getRenderType() + { + return 0; + } + + @Override + public boolean isOpaqueCube() + { + return true; + } + + @Override + public boolean renderAsNormalBlock() + { + return true; + } + + @SideOnly(Side.CLIENT) + public IIcon getInnerTextureForBlockRenderer() + { + return this.blockIcon; + } + + @Override + public boolean canDropFromExplosion(Explosion explosion) + { + return false; + } + + @Override + public float getExplosionResistance(Entity entity) + { + return -1f; + } + + @Override + public float getExplosionResistance(Entity entity, World world, int x, int y ,int z, double explosionX, double explosionY, double explosionZ) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof ExplosiveTileEntity && !((ExplosiveTileEntity)te).isInvalid()) + { + return -((ExplosiveTileEntity)te).explosionPower; + } + return -1f; + } + + @Override + public void onBlockDestroyedByExplosion(World world, int x, int y ,int z, Explosion explosion) + { + TileEntity te = world.getTileEntity(x, y, z); + if(te instanceof ExplosiveTileEntity) + { + ((ExplosiveTileEntity)te).createExplosion(null); + } + } + + +} diff --git a/src/main/java/ihl/explosion/ExplosiveTileEntity.java b/src/main/java/ihl/explosion/ExplosiveTileEntity.java new file mode 100644 index 0000000..b211d3b --- /dev/null +++ b/src/main/java/ihl/explosion/ExplosiveTileEntity.java @@ -0,0 +1,78 @@ +package ihl.explosion; + +import ic2.core.IC2; +import ihl.IHLMod; +import ihl.utils.IHLMathUtils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.oredict.OreDictionary; + +public class ExplosiveTileEntity extends TileEntity { + + public int explosionPower = 10000; + private int explosionType = 1; + private int detonator_delay = 1; + private int burn_time = 0; + public boolean is_detonator_burning = false; + + public void createExplosion(EntityPlayer player) { + this.invalidate(); + int power = this.explosionPower; + this.explosionPower = 0; + IHLMod.explosionHandler.doExplosion(worldObj, xCoord, yCoord, zCoord, IHLMod.explosionHandler.startVectors, + power); + IHLMod.proxy.createExplosionEffectFromServer(worldObj, xCoord, yCoord, zCoord, + 32f * IHLMathUtils.sqrt(power / 16384f)); + } + + @Override + public boolean canUpdate() { + return IC2.platform.isSimulating(); + } + + @Override + public void updateEntity() { + if (is_detonator_burning) { + IHLMod.proxy.spawnParticleFromServer(4, worldObj, xCoord + 0.5d, yCoord + 1d, zCoord + 0.5d, 0d, 0.2d, 0d, + 1f); + if (this.burn_time++ > detonator_delay * 20) { + this.createExplosion(null); + } + } + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + if (nbt != null) { + explosionPower = nbt.getInteger("explosionPower"); + explosionType = nbt.getInteger("explosionType"); + detonator_delay = nbt.getInteger("detonator_delay"); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + nbt.setInteger("explosionPower", explosionPower); + nbt.setInteger("explosionType", explosionType); + nbt.setInteger("detonator_delay", detonator_delay); + } + + public boolean ignite(EntityPlayer player) { + if (player != null && player.getCurrentEquippedItem() != null) { + for (int oid : OreDictionary.getOreIDs(player.getCurrentEquippedItem())) { + if (OreDictionary.getOreName(oid).matches("toolLighter")) { + ignite(); + return false; + } + } + } + return true; + } + + public void ignite() { + IHLMod.proxy.playSoundEffectFromServer(0, this.worldObj, this.xCoord + 0.5D, this.yCoord + 0.5D, + this.zCoord + 0.5D, 10.0F, 1.0F); + this.is_detonator_burning = true; + } +} diff --git a/src/main/java/ihl/explosion/GroundRemoverItem.java b/src/main/java/ihl/explosion/GroundRemoverItem.java new file mode 100644 index 0000000..ddbc884 --- /dev/null +++ b/src/main/java/ihl/explosion/GroundRemoverItem.java @@ -0,0 +1,105 @@ +package ihl.explosion;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+
+public class GroundRemoverItem extends Item{
+
+ private String registryName;
+ private final Set<Block> removableBlockSet = new HashSet<Block>();
+ private final Random random = new Random();
+
+ public GroundRemoverItem(String registryName1)
+ {
+ super();
+ this.registryName=registryName1;
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setMaxStackSize(1);
+ this.setUnlocalizedName(registryName);
+ removableBlockSet.add(Blocks.sandstone);
+ removableBlockSet.add(Blocks.sand);
+ removableBlockSet.add(Blocks.stone);
+ removableBlockSet.add(Blocks.flowing_water);
+ removableBlockSet.add(Blocks.flowing_lava);
+ removableBlockSet.add(Blocks.water);
+ removableBlockSet.add(Blocks.lava);
+ removableBlockSet.add(Blocks.clay);
+ removableBlockSet.add(Blocks.gravel);
+ removableBlockSet.add(Blocks.dirt);
+ }
+
+ public GroundRemoverItem()
+ {
+ super();
+ }
+
+ public static void init()
+ {
+ //GameRegistry.registerItem(new GroundRemoverItem("groundRemover"),"groundRemover");
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag)
+ {
+ info.add("Vanilla block remover tool");
+ }
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister par1IconRegister)
+ {
+ this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":vacuumSwitch");
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
+ {
+ TileEntity t = world.getTileEntity(x, y, z);
+ if(world.isRemote)
+ {
+ IHLMod.proxy.createExplosionEffect(world, x, y, z, 16f);
+ }
+ return true;
+ }
+
+ @Override
+ public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem)
+ {
+/* if(entity instanceof EntityPlayer && isCurrentItem && MinecraftServer.getServer().getTickCounter()%100==99)
+ {
+ int x = (int)entity.posX;
+ int y = (int)entity.posY;
+ int z = (int)entity.posZ;
+ for(int ix = x-16;ix < x+16;ix++)
+ {
+ for(int iz = z-16;iz < z+16;iz++)
+ {
+ for(int iy = 4;iy < y;iy++)
+ {
+ if(!(world.getBlock(ix, iy, iz) instanceof BlockOre || world.getBlock(ix, iy, iz) instanceof IHLFluidBlock))
+ {
+ world.setBlockToAir(ix, iy, iz);
+ }
+ }
+ }
+ }
+ }*/
+ }
+}
diff --git a/src/main/java/ihl/explosion/IHLEntityFallingPile.java b/src/main/java/ihl/explosion/IHLEntityFallingPile.java new file mode 100644 index 0000000..79973d8 --- /dev/null +++ b/src/main/java/ihl/explosion/IHLEntityFallingPile.java @@ -0,0 +1,152 @@ +package ihl.explosion; + +import ihl.utils.IHLUtils; +import net.minecraft.block.material.Material; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.item.ItemExpireEvent; + +public class IHLEntityFallingPile extends EntityItem{ + + public IHLEntityFallingPile(World world) { + super(world); + } + + @Override + public void onUpdate() + { + ItemStack stack = this.getDataWatcher().getWatchableObjectItemStack(10); + if (stack != null && stack.getItem() != null) + { + if (stack.getItem().onEntityItemUpdate(this)) + { + return; + } + } + + if (this.getEntityItem() == null) + { + this.setDead(); + } + else + { + this.onEntityUpdate(); + + if (this.delayBeforeCanPickup > 0) + { + --this.delayBeforeCanPickup; + } + + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.motionY -= 0.03999999910593033D; + this.noClip = this.func_145771_j(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ); + this.moveEntity(this.motionX, this.motionY, this.motionZ); + boolean flag = (int)this.prevPosX != (int)this.posX || (int)this.prevPosY != (int)this.posY || (int)this.prevPosZ != (int)this.posZ; + + if (flag || this.ticksExisted % 25 == 0) + { + if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial() == Material.lava) + { + this.motionY = 0.20000000298023224D; + this.motionX = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); + this.motionZ = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); + this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F); + } + + } + + this.motionX *= 0.98D; + this.motionY *= 0.98D; + this.motionZ *= 0.98D; + + if (this.onGround) + { + this.motionY *= -0.5D; + } + + ++this.age; + + ItemStack item = this.getEntityItem(); + + if (!this.worldObj.isRemote && + (this.age >= lifespan || this.onGround)) + { + if (item != null) + { + ItemExpireEvent event = new ItemExpireEvent(this, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, worldObj))); + if (MinecraftForge.EVENT_BUS.post(event)) + { + lifespan += event.extraLife; + } + else + { + int x = (int)(this.boundingBox.minX); + int y = (int)(this.boundingBox.minY); + int z = (int)(this.boundingBox.minZ); + int i=1; + do + { + int[] xz = new int[] {0,0,1,0,-1,0}; + if(i<xz.length) + { + if(IHLUtils.isBlockCanBeReplaced(worldObj, x+xz[i-1], y, z+xz[i])) + { + x+=xz[i-1]; + z+=xz[i]; + if(IHLUtils.isBlockCanBeReplaced(worldObj, x, y-1, z)) + { + this.setPosition(x+0.5d, y-0.5d, z+0.5d); + return; + } + PileTileEntity pte = new PileTileEntity(); + pte.content=this.getEntityItem(); + IHLUtils.setBlockAndTileEntityRaw(worldObj, x, y, z, PileBlock.instance, pte); + for(Object player:worldObj.playerEntities) + { + if(player instanceof EntityPlayerMP) + { + EntityPlayerMP playerMP = (EntityPlayerMP)player; + playerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x,y,z,worldObj)); + } + } + + break; + } + else + { + i++; + } + } + else + { + i=1; + y++; + } + } + while(!IHLUtils.isBlockCanBeReplaced(worldObj, x, y, z) && y < 254); + this.setDead(); + } + } + else + { + this.setDead(); + } + } + + if (item != null && item.stackSize <= 0) + { + this.setDead(); + } + } + } + + public void applyEntityCollision(Entity entity){} +} diff --git a/src/main/java/ihl/explosion/IHLEntityFallingPileRender.java b/src/main/java/ihl/explosion/IHLEntityFallingPileRender.java new file mode 100644 index 0000000..02cca5d --- /dev/null +++ b/src/main/java/ihl/explosion/IHLEntityFallingPileRender.java @@ -0,0 +1,51 @@ +package ihl.explosion;
+import java.util.Random;
+
+import org.lwjgl.opengl.GL11;
+
+import ihl.utils.IHLItemRenderer;
+import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.entity.Entity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+
+public class IHLEntityFallingPileRender extends Render{
+
+ private final IHLItemRenderer itemRenderer;
+ private final Random random = new Random(400);
+
+ public IHLEntityFallingPileRender()
+ {
+ super();
+ this.itemRenderer=new IHLItemRenderer(true);
+ }
+
+ @Override
+ public void doRender(Entity entity, double x, double y, double z, float arg4, float arg5)
+ {
+ GL11.glTranslated(x, y, z);
+ random.setSeed(entity.getEntityId());
+ IHLEntityFallingPile fp = (IHLEntityFallingPile) entity;
+ ItemStack stack = fp.getEntityItem();
+ for (int i = 0; i < 16; i++)
+ {
+ GL11.glPushMatrix();
+ GL11.glRotatef(90f,random.nextFloat()*2f-1f,random.nextFloat()*2f-1f,random.nextFloat()*2f-1f);
+ float tx = random.nextFloat()-0.5f;
+ float ty = random.nextFloat()-0.5f;
+ float tz = random.nextFloat()-0.5f;
+ GL11.glTranslatef(tx, ty, tz);
+ itemRenderer.doRender(RenderManager.instance,stack, 0, 0, 0);
+ GL11.glTranslatef(-tx, -ty, tz);
+ GL11.glPopMatrix();
+ }
+ }
+
+ @Override
+ protected ResourceLocation getEntityTexture(Entity arg0) {
+ return TextureMap.locationItemsTexture;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/explosion/PileBlock.java b/src/main/java/ihl/explosion/PileBlock.java new file mode 100644 index 0000000..f9ea862 --- /dev/null +++ b/src/main/java/ihl/explosion/PileBlock.java @@ -0,0 +1,133 @@ +package ihl.explosion; + +import java.util.ArrayList; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.IHLModInfo; +import ihl.items_blocks.IHLItemBlock; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class PileBlock extends Block implements ITileEntityProvider +{ + public static PileBlock instance; + public static int id; + protected PileBlock(Material material) { + super(material); + this.setBlockName("pileBlock"); + this.setBlockTextureName("tubBronzeIcon"); + instance = this; + this.setBlockBounds(0f, 0f, 0f, 1f, 0.5f, 1f); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) + { + if(!world.isRemote) + { + PileTileEntity pte = (PileTileEntity)world.getTileEntity(x, y, z); + pte.checkAndFall(); + } + } + + @Override + public int getRenderType() + { + return PileBlockRender.renderId; + } + + @Override + public TileEntity createNewTileEntity(World word, int metadata) { + return new PileTileEntity(); + } + + public static void init() + { + GameRegistry.registerBlock(new PileBlock(Material.sand), IHLItemBlock.class,"pileBlock"); + GameRegistry.registerTileEntity(PileTileEntity.class, "pileBlockTileEntity"); + id = Block.getIdFromBlock(instance); + } + + @Override + public boolean isOpaqueCube() + { + return false; + } + + @Override + public boolean renderAsNormalBlock() + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":pileTextureSpace"); + } + + @Override + public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z) + { + if(!world.isRemote && world.getTileEntity(x,y,z) instanceof PileTileEntity) + { + PileTileEntity te = (PileTileEntity)world.getTileEntity(x,y,z); + if(entityPlayer.inventory.addItemStackToInventory(te.content)) + { + te.content=null; + world.setBlockToAir(x, y, z); + entityPlayer.inventoryContainer.detectAndSendChanges(); + return true; + } + } + return false; + } + + @Override + public void onBlockHarvested(World world,int x,int y,int z,int meta, EntityPlayer entityPlayer) + { + if(!world.isRemote && world.getTileEntity(x,y,z) instanceof PileTileEntity) + { + PileTileEntity te = (PileTileEntity)world.getTileEntity(x,y,z); + if(entityPlayer.inventory.addItemStackToInventory(te.content)) + { + te.content=null; + entityPlayer.inventoryContainer.detectAndSendChanges(); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x,int y,int z,int meta) + { + if(world.getTileEntity(x,y,z) instanceof PileTileEntity) + { + PileTileEntity te = (PileTileEntity)world.getTileEntity(x,y,z); + if(te.content!=null) + { + return te.content.getIconIndex(); + } + } + return this.blockIcon; + } + + @Override + public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag){} + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<ItemStack>(); + } +} diff --git a/src/main/java/ihl/explosion/PileBlockRender.java b/src/main/java/ihl/explosion/PileBlockRender.java new file mode 100644 index 0000000..c5c8060 --- /dev/null +++ b/src/main/java/ihl/explosion/PileBlockRender.java @@ -0,0 +1,285 @@ +package ihl.explosion;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
+import cpw.mods.fml.client.registry.RenderingRegistry;
+import ihl.utils.IHLMathUtils;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.IBlockAccess;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class PileBlockRender implements ISimpleBlockRenderingHandler {
+ public static int renderId;
+ public final PileTileEntityRender pileTileEntityRender;
+
+ public PileBlockRender() {
+ renderId = RenderingRegistry.getNextAvailableRenderId();
+ pileTileEntityRender = new PileTileEntityRender(this);
+ }
+
+ @Override
+ public int getRenderId() {
+ return renderId;
+ }
+
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderblocks) {
+ Tessellator tessellator = Tessellator.instance;
+ block.setBlockBoundsForItemRender();
+ renderblocks.setRenderBoundsFromBlock(block);
+ GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, -1.0F, 0.0F);
+ renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 0, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 1.0F, 0.0F);
+ renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 1, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 0.0F, -1.0F);
+ renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 2, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 0.0F, 1.0F);
+ renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 3, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(-1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 4, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 5, metadata));
+ tessellator.draw();
+ GL11.glTranslatef(0.5F, 0.5F, 0.5F);
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta,
+ RenderBlocks blockRenderer) {
+ TileEntity te = blockAccess.getTileEntity(x, y, z);
+ if (te instanceof PileTileEntity) {
+ PileTileEntity pte = (PileTileEntity) te;
+ long itemHash = getItemStackHash(pte.content);
+ if (this.pileTileEntityRender.subIconIdMap.containsKey(itemHash)) {
+ Tessellator tessellator = Tessellator.instance;
+ int subIconId = this.pileTileEntityRender.subIconIdMap.get(itemHash);
+ int[][][] brightness = new int[3][3][3];
+ this.generateBrightnessMatrix(blockAccess, x, y, z, brightness);
+ tessellator.setColorOpaque_F(1f, 1f, 1f);
+ boolean[] blocksViewAround = this.getBlocksViewAround(blockAccess, x, y, z);
+ if (blocksViewAround[0] && blocksViewAround[1] && blocksViewAround[2] && blocksViewAround[3]) {
+ this.addFlatTop(tessellator, x, y, z, brightness, subIconId);
+ } else if (!blocksViewAround[0] && blocksViewAround[1] && blocksViewAround[2] && blocksViewAround[3]) {
+ this.addSlope(tessellator, x, y, z, 0, brightness, subIconId);
+ } else if (blocksViewAround[0] && !blocksViewAround[1] && blocksViewAround[2] && blocksViewAround[3]) {
+ this.addSlope(tessellator, x, y, z, 1, brightness, subIconId);
+ } else if (blocksViewAround[0] && blocksViewAround[1] && !blocksViewAround[2] && blocksViewAround[3]) {
+ this.addSlope(tessellator, x, y, z, 2, brightness, subIconId);
+ } else if (blocksViewAround[0] && blocksViewAround[1] && blocksViewAround[2] && !blocksViewAround[3]) {
+ this.addSlope(tessellator, x, y, z, 3, brightness, subIconId);
+ }
+ // 2-sided piramid
+ else if (blocksViewAround[0] && blocksViewAround[1] && !blocksViewAround[2] && !blocksViewAround[3]) {
+ this.addTwoSidedPyramid(tessellator, x, y, z, 2, brightness, subIconId);
+ } else if (!blocksViewAround[0] && blocksViewAround[1] && blocksViewAround[2] && !blocksViewAround[3]) {
+ this.addTwoSidedPyramid(tessellator, x, y, z, 3, brightness, subIconId);
+ } else if (!blocksViewAround[0] && !blocksViewAround[1] && blocksViewAround[2] && blocksViewAround[3]) {
+ this.addTwoSidedPyramid(tessellator, x, y, z, 0, brightness, subIconId);
+ } else if (blocksViewAround[0] && !blocksViewAround[1] && !blocksViewAround[2] && blocksViewAround[3]) {
+ this.addTwoSidedPyramid(tessellator, x, y, z, 1, brightness, subIconId);
+ } else {
+ this.addPyramid(tessellator, x, y, z, brightness, subIconId);
+ }
+ if (!blockAccess.getBlock(x, y - 1, z).isOpaqueCube()) {
+ this.addBottom(tessellator, x, y, z, brightness, subIconId);
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ private boolean[] getBlocksViewAround(IBlockAccess blockAccess, int x, int y, int z) {
+ // +Z
+ // ^
+ // [ ][0][ ]
+ // [3][x][1] ->+X
+ // [ ][2][ ]
+ return new boolean[] { blockAccess.getBlock(x, y, z + 1).isOpaqueCube(),
+ blockAccess.getBlock(x + 1, y, z).isOpaqueCube(), blockAccess.getBlock(x, y, z - 1).isOpaqueCube(),
+ blockAccess.getBlock(x - 1, y, z).isOpaqueCube(), };
+ }
+
+ private void addBottom(Tessellator tessellator, int x, int y, int z, int[][][] brightness, int subIconId) {
+ double[][] quad1 = new double[4][3];
+ quad1[0] = new double[] { 0D, 0D, 1D };
+ quad1[1] = new double[] { 0D, 0D, 0D };
+ quad1[2] = new double[] { 1D, 0D, 0D };
+ quad1[3] = new double[] { 1D, 0D, 1D };
+ this.addQuad(tessellator, quad1, x, y, z, ForgeDirection.UP, brightness, subIconId);
+ }
+
+ private void addFlatTop(Tessellator tessellator, int x, int y, int z, int[][][] brightness, int subIconId) {
+ double[][] quad1 = new double[4][3];
+ double height = 0.9D;
+ quad1[0] = new double[] { 1D, height, 0D };
+ quad1[1] = new double[] { 0D, height, 0D };
+ quad1[2] = new double[] { 0D, height, 1D };
+ quad1[3] = new double[] { 1D, height, 1D };
+ this.addQuad(tessellator, quad1, x, y, z, ForgeDirection.UP, brightness, subIconId);
+ }
+
+ private void addSlope(Tessellator tessellator, int x, int y, int z, int rotation,
+ int[][][] brightness, int subIconId) {
+ double[][] quad = new double[4][3];
+ quad[0] = new double[] { 1D,1D, 0D }; // +X -Z
+ quad[1] = new double[] { 0D, 1D, 0D }; // -X -Z
+ quad[2] = new double[] { 0D, 0D, 1D }; // -X +Z
+ quad[3] = new double[] { 1D, 0D, 1D };
+ while (rotation-- > 0) {
+ rotateQuadByYAxis(quad);
+ }
+ this.addQuad(tessellator, quad, x, y, z, ForgeDirection.UP, brightness, subIconId);
+ }
+
+ private void addTwoSidedPyramid(Tessellator tessellator, int x, int y, int z, int rotation,
+ int[][][] brightness, int subIconId) {
+ double[][] quad = new double[4][3];
+ quad[0] = new double[] { 1D, 0D, 0D }; // +X -Z
+ quad[1] = new double[] { 0D, 1D, 0D }; // -X -Z
+ quad[2] = new double[] { 0D, 0D, 1D }; // -X +Z
+ quad[3] = new double[] { 1D, 0D, 1D };
+ while (rotation-- > 0) {
+ rotateQuadByYAxis(quad);
+ }
+ this.addQuad(tessellator, quad, x, y, z, ForgeDirection.UP, brightness, subIconId);
+ }
+
+ private void addPyramid(Tessellator tessellator, int x, int y, int z, int[][][] brightness, int subIconId) {
+ double[][] quad1 = new double[4][3];
+ double[][] quad2 = new double[4][3];
+ double pileHeight = 0.3D;
+ quad1[0] = new double[] { 1D, 0D, 1D };
+ quad1[1] = new double[] { 1D, 0D, 0D };
+ quad1[2] = new double[] { 0D, 0D, 0D };
+ quad1[3] = new double[] { 0.5D, pileHeight, 0.5D };
+ quad2 = copyAndRotateQuadByYAxis(quad1,2);
+ this.addQuad(tessellator, quad1, x, y, z, ForgeDirection.UP, brightness, subIconId);
+ this.addQuad(tessellator, quad2, x, y, z, ForgeDirection.UP, brightness, subIconId);
+ }
+
+ private void rotateQuadByYAxis(double[][] quad) {
+ for (double[] v : quad) {
+ double newV2 = 1 - v[0];
+ v[0] = v[2];
+ v[2] = newV2;
+ }
+ }
+
+ private double[][] copyAndRotateQuadByYAxis(double[][] quad, int rotation) {
+ double[][] quadOut = new double[4][3];
+ for (int i = 0; i < quad.length * 3; i++) {
+ quadOut[i / 3][i % 3] = quad[i / 3][i % 3];
+ }
+
+ while (rotation-- > 0) {
+ rotateQuadByYAxis(quadOut);
+ }
+ return quadOut;
+ }
+
+ private void addQuad(Tessellator tessellator, double[][] quad, int x, int y, int z, ForgeDirection uvmapping,
+ int[][][] brightness, int subIconId) {
+ int iu = 0;
+ int iv = 2;
+ if (uvmapping.offsetY == 0) {
+ iv = 1;
+ if (uvmapping.offsetZ == 0) {
+ iu = 2;
+ }
+ }
+ float[] normal = IHLMathUtils.get_triangle_normal(quad);
+ float minu = pileTileEntityRender.getSubIconMinU(subIconId);
+ float minv = pileTileEntityRender.getSubIconMinV(subIconId);
+ float du = pileTileEntityRender.getSubIconDU(subIconId);
+ float dv = pileTileEntityRender.getSubIconDV(subIconId);
+
+ double u1 = minu + quad[0][iu] * du;
+ double u2 = minu + quad[1][iu] * du;
+ double u3 = minu + quad[2][iu] * du;
+ double u4 = minu + quad[3][iu] * du;
+ double v1 = minv + quad[0][iv] * dv;
+ double v2 = minv + quad[1][iv] * dv;
+ double v3 = minv + quad[2][iv] * dv;
+ double v4 = minv + quad[3][iv] * dv;
+
+ tessellator.setNormal(normal[0], normal[1], normal[2]);
+ tessellator.setBrightness(this.getBrightness(quad[0], brightness));
+ tessellator.addVertexWithUV(x + quad[0][0], y + quad[0][1], z + quad[0][2], u1, v1);
+ tessellator.setBrightness(this.getBrightness(quad[1], brightness));
+ tessellator.addVertexWithUV(x + quad[1][0], y + quad[1][1], z + quad[1][2], u2, v2);
+ tessellator.setBrightness(this.getBrightness(quad[2], brightness));
+ tessellator.addVertexWithUV(x + quad[2][0], y + quad[2][1], z + quad[2][2], u3, v3);
+ tessellator.setBrightness(this.getBrightness(quad[3], brightness));
+ tessellator.addVertexWithUV(x + quad[3][0], y + quad[3][1], z + quad[3][2], u4, v4);
+ }
+
+ public long getItemStackHash(ItemStack stack) {
+ if (stack == null) {
+ return 0;
+ }
+ return ((long) Item.getIdFromItem(stack.getItem()) << 31 ^ stack.getItemDamage());
+ }
+
+ private void generateBrightnessMatrix(IBlockAccess blockAccess, int x, int y, int z, int[][][] brightness) {
+ for (int ix = -1; ix <= 1; ix++)
+ for (int iy = -1; iy <= 1; iy++)
+ for (int iz = -1; iz <= 1; iz++) {
+ Block block = blockAccess.getBlock(ix + x, iy + y, iz + z);
+ if (block != null && block != Blocks.air) {
+ brightness[ix + 1][iy + 1][iz + 1] = block.getMixedBrightnessForBlock(blockAccess, ix + x,
+ iy + y, iz + z);
+ } else {
+ brightness[ix + 1][iy + 1][iz + 1] = block.getMixedBrightnessForBlock(blockAccess, x, y, z);
+ }
+ }
+ }
+
+ private int getBrightness(double v[], int[][][] brightness) {
+ int x1 = v[0] < 0.5d ? 0 : 1;
+ int x2 = x1 + 1;
+ int y1 = v[1] < 0.5d ? 0 : 1;
+ int y2 = y1 + 1;
+ int z1 = v[2] < 0.5d ? 0 : 1;
+ int z2 = z1 + 1;
+ float dx = v[0] < 0.5d ? (float) v[0] * 2f : (float) v[0] * 2f - 1f;
+ float dy = v[1] < 0.5d ? (float) v[1] * 2f : (float) v[1] * 2f - 1f;
+ float dz = v[2] < 0.5d ? (float) v[2] * 2f : (float) v[2] * 2f - 1f;
+ int brightness1 = brightness[x1][y1][z1];
+ int brightness2 = brightness[x2][y2][z2];
+ float d = IHLMathUtils.sqrt(dx * dx + dy * dy + dz * dz);
+ return (int) (brightness1 * (1f - d) * 0.8f + brightness2 * d * 0.8f + brightness[1][1][1] * 0.2f) & 16711935;
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory(int arg0) {
+ return true;
+ }
+}
diff --git a/src/main/java/ihl/explosion/PileTileEntity.java b/src/main/java/ihl/explosion/PileTileEntity.java new file mode 100644 index 0000000..67f430a --- /dev/null +++ b/src/main/java/ihl/explosion/PileTileEntity.java @@ -0,0 +1,78 @@ +package ihl.explosion; + +import ic2.core.IC2; +import ihl.IHLMod; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +public class PileTileEntity extends TileEntity { + public ItemStack content = new ItemStack(Blocks.sandstone); + private boolean firstTick = true; + + @Override + public boolean canUpdate() { + return IC2.platform.isRendering(); + } + + @Override + public void updateEntity() { + if (firstTick && this.content != null) { + if (this.worldObj.isRemote) { + IHLMod.proxy.requestTileEntityInitdataFromClientToServer(xCoord, yCoord, zCoord); + } else { + checkAndFall(); + } + firstTick = false; + } + } + + public void setContent(ItemStack other) { + this.content = other; + } + + public boolean checkAndFall() { + Block underblock = this.worldObj.getBlock(xCoord, yCoord - 1, zCoord); + if (underblock.isAir(worldObj, xCoord, yCoord - 1, zCoord) || underblock == Blocks.air + || underblock.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord - 1, zCoord) == null) { + IHLEntityFallingPile fallingPile = new IHLEntityFallingPile(worldObj); + fallingPile.setPosition(xCoord + 0.5d, yCoord + 0.5d, zCoord + 0.5d); + fallingPile.setEntityItemStack(content); + this.worldObj.setBlockToAir(xCoord, yCoord, zCoord); + this.worldObj.spawnEntityInWorld(fallingPile); + return false; + } + return true; + } + + @Override + public void readFromNBT(NBTTagCompound nbttagcompound) { + super.readFromNBT(nbttagcompound); + this.content = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("content")); + } + + @Override + public void writeToNBT(NBTTagCompound nbttagcompound) { + super.writeToNBT(nbttagcompound); + NBTTagCompound contentNBT = new NBTTagCompound(); + this.content.writeToNBT(contentNBT); + nbttagcompound.setTag("content", contentNBT); + } + + public void updateBlockRender() { + Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + this.readFromNBT(pkt.func_148857_g()); + if (checkAndFall()) { + Minecraft.getMinecraft().renderGlobal.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + } + } +} diff --git a/src/main/java/ihl/explosion/PileTileEntityRender.java b/src/main/java/ihl/explosion/PileTileEntityRender.java new file mode 100644 index 0000000..56fc72f --- /dev/null +++ b/src/main/java/ihl/explosion/PileTileEntityRender.java @@ -0,0 +1,187 @@ +package ihl.explosion;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+import org.lwjgl.opengl.Display;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL30;
+import org.lwjgl.util.glu.GLU;
+
+import ihl.IHLMod;
+import ihl.utils.IHLItemRenderer;
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+
+public class PileTileEntityRender extends TileEntitySpecialRenderer {
+
+ private int fb = -1;
+ private final int textureWidth = 64;
+ private final int textureHeight = 64;
+ private final PileBlockRender pileBlockRender;
+ public final Map<Long, Integer> subIconIdMap = new HashMap<Long, Integer>();
+ private int nextAvailableId = -1;
+ private boolean framebufferReady = false;
+ private Minecraft mc;
+ private final IHLItemRenderer ihlItemRenderer = new IHLItemRenderer(false);
+ private final Random random = new Random();
+
+ public PileTileEntityRender(PileBlockRender pileBlockRender1) {
+ pileBlockRender = pileBlockRender1;
+ mc = Minecraft.getMinecraft();
+ }
+
+ public void renderAModelAt(PileTileEntity tile, double x, double y, double z, float f) {
+ ItemStack stack = tile.content;
+ if (!framebufferReady) {
+ this.generateFrameBuffer();
+ Minecraft.getMinecraft().entityRenderer.setupCameraTransform(f, 0);
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ } else if (stack != null) {
+ long hash = this.pileBlockRender.getItemStackHash(stack);
+ if (!subIconIdMap.containsKey(hash)) {
+
+ subIconIdMap.put(hash, ++nextAvailableId);
+ this.preparetexture();
+ this.drawTexture(tile, nextAvailableId);
+ Minecraft.getMinecraft().entityRenderer.setupCameraTransform(f, 0);
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ tile.updateBlockRender();
+ }
+ }
+ }
+
+ private void generateFrameBuffer() {
+ fb = GL30.glGenFramebuffers();
+ this.preparetexture();
+ if (GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE) {
+ IHLMod.log.error("Something went wrong while creating frame buffer!");
+ IHLMod.log.error(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER));
+ } else {
+ IHLMod.log.info("FrameBuffer loaded correctly!");
+ }
+ this.framebufferReady = true;
+ }
+
+ private void preparetexture() {
+ GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fb);
+ int texture = Minecraft.getMinecraft().renderEngine.getTexture(TextureMap.locationBlocksTexture)
+ .getGlTextureId();
+ GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
+ GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture, 0);
+ }
+
+ private void drawTexture(PileTileEntity tile, int subIconId) {
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ float minu = picon.getMinU();
+ float minv = picon.getMinV();
+ float maxu = picon.getMaxU();
+ float maxv = picon.getMaxV();
+ int iconwidth = picon.getIconWidth();
+ int iconheight = picon.getIconHeight();
+ float du = maxu - minu;
+ float dv = maxv - minv;
+ int iconNumU = picon.getIconWidth()/this.textureWidth;
+ int posu = (int) (minu * iconwidth / du) + subIconId % iconNumU * textureWidth;
+ int posv = (int) (minv * iconheight / dv) + subIconId / iconNumU * textureHeight;
+
+ GL11.glViewport(posu, posv, textureWidth, textureHeight);
+ GL11.glMatrixMode(GL11.GL_PROJECTION);
+ GL11.glLoadIdentity();
+ GL11.glOrtho(-1d, 1d, -1d, 1d, 0.05F, this.mc.gameSettings.renderDistanceChunks * 32F);
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ GL11.glLoadIdentity();
+ ItemStack stack = tile.content;
+ GL11.glTranslatef(0, 0, -1f);
+ GLU.gluLookAt(0, 0, 0, -32f/* x reference */, 0f/* y reference */, 0f/* z reference */, 0.0f, 1.0f, 0.0f);
+ GL11.glColor4f(1f, 1f, 1f, 1f);
+ GL11.glRotatef(90f, 0, 1f, 0);
+ GL11.glScalef(2f, 2f, 2f);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 0xf0, 0xf0);
+ if (stack.getItem() instanceof ItemBlock) {
+ Block block = ((ItemBlock) stack.getItem()).field_150939_a;
+ IIcon icon = block.getIcon(0, stack.getItemDamage());
+ double u1 = (double) icon.getInterpolatedU(0D);
+ double u2 = (double) icon.getInterpolatedU(16.0D);
+ double v1 = (double) icon.getInterpolatedV(0D);
+ double v2 = (double) icon.getInterpolatedV(16.0D);
+ Tessellator tessellator = Tessellator.instance;
+ bindTexture(TextureMap.locationBlocksTexture);
+ tessellator.startDrawingQuads();
+ tessellator.setColorOpaque_F(1f, 1f, 1f);
+ tessellator.addVertexWithUV(-0.5, -0.5, 0, u1, v1);
+ tessellator.addVertexWithUV(0.5, -0.5, 0, u1, v2);
+ tessellator.addVertexWithUV(0.5, 0.5, 0, u2, v2);
+ tessellator.addVertexWithUV(-0.5, 0.5, 0, u2, v1);
+ tessellator.draw();
+ }
+ for (int i = 0; i < 128; i++) {
+ GL11.glPushMatrix();
+ float tx = random.nextFloat() - 0.5f;
+ float ty = random.nextFloat() - 0.5f;
+ GL11.glTranslatef(tx, ty, 0);
+ this.ihlItemRenderer.doRender(RenderManager.instance, stack, 0f, 0f, 0f);
+ GL11.glTranslatef(-tx, -ty, 0);
+ GL11.glPopMatrix();
+ }
+ GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
+ }
+
+ public float getSubIconMinU(int index)
+ {
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ int iconNumU = picon.getIconWidth()/this.textureWidth;
+ float minu = picon.getMinU();
+ float maxu = picon.getMaxU();
+ float du = (maxu - minu)/iconNumU;
+ return minu + index%iconNumU*du;
+ }
+
+ public float getSubIconMinV(int index)
+ {
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ int iconNumU = picon.getIconWidth()/this.textureWidth;
+ int iconNumV = picon.getIconHeight()/this.textureHeight;
+ float minv = picon.getMinV();
+ float maxv = picon.getMaxV();
+ float dv = (maxv - minv)/iconNumV;
+ return minv + index/iconNumU*dv;
+ }
+ public float getSubIconDU(int index)
+ {
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ int iconNumU = picon.getIconWidth()/this.textureWidth;
+ float minu = picon.getMinU();
+ float maxu = picon.getMaxU();
+ float du = (maxu - minu)/iconNumU;
+ return du;
+ }
+
+ public float getSubIconDV(int index)
+ {
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ int iconNumV = picon.getIconHeight()/this.textureHeight;
+ float minv = picon.getMinV();
+ float maxv = picon.getMaxV();
+ float dv = (maxv - minv)/iconNumV;
+ return dv;
+ }
+
+
+
+ @Override
+ public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) {
+ this.renderAModelAt((PileTileEntity) par1TileEntity, par2, par4, par6, par8);
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/explosion/WorldSavedDataBlastWave.java b/src/main/java/ihl/explosion/WorldSavedDataBlastWave.java new file mode 100644 index 0000000..73019b9 --- /dev/null +++ b/src/main/java/ihl/explosion/WorldSavedDataBlastWave.java @@ -0,0 +1,108 @@ +package ihl.explosion; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.world.WorldSavedData; + +public class WorldSavedDataBlastWave extends WorldSavedData { + Map<Long,Set<Integer[]>> data = new HashMap<Long,Set<Integer[]>>(256); + + public WorldSavedDataBlastWave(String name) + { + super(name); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) + { + if(nbt.hasKey("entryList")) + { + NBTTagList entryList=nbt.getTagList("entryList", 10); + for(int i=0;i<entryList.tagCount();i++) + { + NBTTagCompound chunk = entryList.getCompoundTagAt(i); + long chunkXZKey = chunk.getLong("chunkXZKey"); + NBTTagList blastWaveList = chunk.getTagList("blastWaveList", 10); + Set<Integer[]> blastWaveArraySet= new HashSet<Integer[]>(); + for(int i1=0;i1<blastWaveList.tagCount();i1++) + { + NBTTagCompound blastWave = blastWaveList.getCompoundTagAt(i1); + Integer[] blastWaveArray = new Integer[5]; + blastWaveArray[0]=blastWave.getInteger("ev"); + blastWaveArray[1]=blastWave.getInteger("sourceX"); + blastWaveArray[2]=blastWave.getInteger("sourceY"); + blastWaveArray[3]=blastWave.getInteger("sourceZ"); + blastWaveArray[4]=blastWave.getInteger("power"); + blastWaveArray[5]=blastWave.getInteger("directionX"); + blastWaveArray[6]=blastWave.getInteger("directionY"); + blastWaveArray[7]=blastWave.getInteger("directionZ"); + blastWaveArraySet.add(blastWaveArray); + } + data.put(chunkXZKey, blastWaveArraySet); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbt) + { + NBTTagList entryList = new NBTTagList(); + Iterator<Entry<Long, Set<Integer[]>>> dataESI = data.entrySet().iterator(); + while(dataESI.hasNext()) + { + Entry<Long, Set<Integer[]>> dataEntry = dataESI.next(); + Iterator<Integer[]> bwArrayI = dataEntry.getValue().iterator(); + NBTTagCompound chunk = new NBTTagCompound(); + NBTTagList blastWaveList = new NBTTagList(); + while(bwArrayI.hasNext()) + { + NBTTagCompound blastWave = new NBTTagCompound(); + Integer[] bwArray = bwArrayI.next(); + blastWave.setInteger("ev", bwArray[0]); + blastWave.setInteger("sourceX", bwArray[1]); + blastWave.setInteger("sourceY", bwArray[2]); + blastWave.setInteger("sourceZ", bwArray[3]); + blastWave.setInteger("power", bwArray[4]); + blastWave.setInteger("directionX", bwArray[5]); + blastWave.setInteger("directionY", bwArray[6]); + blastWave.setInteger("directionZ", bwArray[7]); + blastWaveList.appendTag(blastWave); + } + chunk.setTag("blastWaveList", blastWaveList); + chunk.setLong("chunkHash", dataEntry.getKey()); + entryList.appendTag(chunk); + } + nbt.setTag("entryList", entryList); + } + + public void scheduleExplosionEffectsOnChunkLoad(long chunkXZKey, int ev, int sourceX, int sourceY, int sourceZ, int power1, int[] directionMask) + { + Set<Integer[]> waves; + if(data.containsKey(chunkXZKey)) + { + waves=data.get(chunkXZKey); + } + else + { + waves=new HashSet<Integer[]>(1024); + data.put(chunkXZKey, waves); + } + Integer[] wave = new Integer[8]; + wave[0]=ev; + wave[1]=sourceX; + wave[2]=sourceY; + wave[3]=sourceZ; + wave[4]=power1; + wave[5]=directionMask[0]; + wave[6]=directionMask[1]; + wave[7]=directionMask[2]; + waves.add(wave); + } +} diff --git a/src/main/java/ihl/flexible_cable/AnchorBlock.java b/src/main/java/ihl/flexible_cable/AnchorBlock.java new file mode 100644 index 0000000..207173e --- /dev/null +++ b/src/main/java/ihl/flexible_cable/AnchorBlock.java @@ -0,0 +1,111 @@ +package ihl.flexible_cable;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+public class AnchorBlock extends Block implements ITileEntityProvider {
+
+ public AnchorBlock(String unlocalizedName1) {
+ super(Material.circuits);
+ this.setBlockName(unlocalizedName1);
+ GameRegistry.registerBlock(this, unlocalizedName1);
+ }
+
+ @Override
+ public boolean hasTileEntity(int metadata) {
+ return true;
+ }
+
+ @Override
+ 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 && te instanceof AnchorTileEntity) {
+ AnchorTileEntity ate = (AnchorTileEntity) te;
+ ate.invalidate();
+ for (short i = 0; i < 6; i++) {
+ ate.energyNetNodes[i].removeAttachedChains();
+ }
+ }
+ }
+ super.onBlockPreDestroy(world, x, y, z, meta);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World arg0, int arg1) {
+ return new AnchorTileEntity();
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) {
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_,
+ int p_149668_4_) {
+ return null;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ @Override
+ public int getRenderType() {
+ return -2;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister) {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":junctionBox");
+ }
+
+ @Override
+ public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z) {
+ TileEntity te = iBlockAccess.getTileEntity(x, y, z);
+ if (te != null && te instanceof AnchorTileEntity) {
+ AnchorTileEntity ate = (AnchorTileEntity) te;
+ float portSize = 0.1f;
+ float bbMinX = 1f;
+ float bbMaxX = 0f;
+ float bbMinY = 1f;
+ float bbMaxY = 0f;
+ float bbMinZ = 1f;
+ float bbMaxZ = 0f;
+ for (short i = 0; i < 6; i++) {
+ if (ate.hasCableOnSide[i]) {
+ float pMinX = (float) (ate.energyNetNodes[i].getPortPos(null)[0] - portSize - x);
+ float pMaxX = (float) (ate.energyNetNodes[i].getPortPos(null)[0] + portSize - x);
+ float pMinY = (float) (ate.energyNetNodes[i].getPortPos(null)[1] - portSize - y);
+ float pMaxY = (float) (ate.energyNetNodes[i].getPortPos(null)[1] + portSize - y);
+ float pMinZ = (float) (ate.energyNetNodes[i].getPortPos(null)[2] - portSize - z);
+ float pMaxZ = (float) (ate.energyNetNodes[i].getPortPos(null)[2] + portSize - z);
+ bbMinX = Math.min(pMinX, bbMinX);
+ bbMaxX = Math.max(pMaxX, bbMaxX);
+ bbMinY = Math.min(pMinY, bbMinY);
+ bbMaxY = Math.max(pMaxY, bbMaxY);
+ bbMinZ = Math.min(pMinZ, bbMinZ);
+ bbMaxZ = Math.max(pMaxZ, bbMaxZ);
+ }
+ }
+ this.setBlockBounds(bbMinX, bbMinY, bbMinZ, bbMaxX, bbMaxY, bbMaxZ);
+ }
+ }
+}
diff --git a/src/main/java/ihl/flexible_cable/AnchorTileEntity.java b/src/main/java/ihl/flexible_cable/AnchorTileEntity.java new file mode 100644 index 0000000..488e89b --- /dev/null +++ b/src/main/java/ihl/flexible_cable/AnchorTileEntity.java @@ -0,0 +1,342 @@ +package ihl.flexible_cable;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import ic2.api.energy.EnergyNet;
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySink;
+import ic2.api.energy.tile.IEnergySource;
+import ic2.core.ExplosionIC2;
+import ic2.core.IC2;
+import ic2.core.block.TileEntityBlock;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.interfaces.IMultiPowerCableHolder;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class AnchorTileEntity extends TileEntityBlock implements IEnergySink, IEnergySource, IMultiPowerCableHolder {
+ public boolean addedToEnergyNet = false;
+ public final Set<TileEntity> sacrifices = new HashSet<TileEntity>();
+ public SubAnchorEnergyNetNode[] energyNetNodes = new SubAnchorEnergyNetNode[6];
+ public boolean[] hasCableOnSide = new boolean[] { false, false, false, false, false, false };
+ public int checksum = -1;
+ public boolean checkCables = true;
+
+ public AnchorTileEntity() {
+ super();
+ for (short i = 0; i < 6; i++) {
+ energyNetNodes[i] = new SubAnchorEnergyNetNode(this, i);
+ }
+ }
+
+ @Override
+ public List<String> getNetworkedFields() {
+ List<String> fields = super.getNetworkedFields();
+ fields.add("hasCableOnSide");
+ return fields;
+ }
+
+ @Override
+ public void onLoaded() {
+ super.onLoaded();
+ for (short i = 0; i < 6; i++) {
+ energyNetNodes[i].onLoaded();
+ }
+ if (IC2.platform.isSimulating() && !this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ }
+
+ @Override
+ public void onUnloaded() {
+ super.onUnloaded();
+ if (IC2.platform.isSimulating()) {
+ if (this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ for (SubAnchorEnergyNetNode sen : energyNetNodes) {
+ sen.onUnloaded();
+ }
+
+ }
+ }
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer var1) {
+ return false;
+ }
+
+ public boolean enableUpdateEntity() {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntityServer() {
+ if (!sacrifices.isEmpty()) {
+ Iterator<TileEntity> victimIterator = sacrifices.iterator();
+ while (victimIterator.hasNext()) {
+ TileEntity sacrifice = victimIterator.next();
+ ExplosionIC2 explosion = new ExplosionIC2(this.worldObj, null, sacrifice.xCoord + 0.5D,
+ sacrifice.yCoord + 0.5D, sacrifice.zCoord + 0.5D, 3F, 0.3F, ExplosionIC2.Type.Normal, null, 0);
+ explosion.doExplosion();
+ sacrifices.remove(sacrifice);
+ }
+
+ }
+ int newchecksum = 0;
+ for (short i = 0; i < 6; i++) {
+ if (this.hasCableOnSide[i]) {
+ newchecksum++;
+ }
+ }
+ if (newchecksum != checksum) {
+ IC2.network.get().updateTileEntityField(this, "hasCableOnSide");
+ checksum = newchecksum;
+ }
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ NBTTagList energyNetNodeNBTList = new NBTTagList();
+ for (SubAnchorEnergyNetNode node : this.energyNetNodes) {
+ energyNetNodeNBTList.appendTag(node.writeToNBT());
+ }
+ nbt.setTag("energyNetNodes", energyNetNodeNBTList);
+ nbt.setBoolean("checkCables", this.checkCables);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ if (!nbt.hasKey("energyNetNodes")) {
+ short facing = nbt.getShort("facing");
+ int gridID = nbt.getInteger("gridID");
+ this.energyNetNodes[facing].setGrid(gridID);
+ NBTTagList cableNBTList = nbt.getTagList("cableList", 10);
+ for (int i = 0; i < cableNBTList.tagCount(); i++) {
+ this.energyNetNodes[facing].addCable(cableNBTList.getCompoundTagAt(i));
+ }
+ } else {
+ NBTTagList energyNetNodeNBTList = nbt.getTagList("energyNetNodes", 10);
+ for (int i = 0; i < 6; i++) {
+ this.energyNetNodes[i].readFromNBT(energyNetNodeNBTList.getCompoundTagAt(i));
+ }
+ }
+ this.checkCables = nbt.getBoolean("checkCables");
+ }
+
+ @Override
+ public void setFacing(short facing) {
+ this.energyNetNodes[facing].removeAttachedChains();
+ boolean removeTE = true;
+ for (short i = 0; i < 6; i++) {
+ if (!energyNetNodes[i].getCableList().isEmpty()) {
+ removeTE = false;
+ }
+ }
+ if (removeTE) {
+ worldObj.setBlockToAir(xCoord, yCoord, zCoord);
+ }
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
+ if (direction != ForgeDirection.UNKNOWN) {
+ return this.energyNetNodes[direction.getOpposite().ordinal()].getGridID() != -1;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) {
+ return this.acceptsEnergyFrom(receiver, direction);
+ }
+
+ @Override
+ public double getOfferedEnergy() {
+ double offeredEnergy = 0d;
+ for (short i = 0; i < 6; i++) {
+ offeredEnergy += energyNetNodes[i].getEnergyOfferedByGrid();
+ }
+ return offeredEnergy;
+ }
+
+ @Override
+ public void drawEnergy(double amount) {
+ for (short i = 0; i < 6; i++) {
+ amount -= energyNetNodes[i].drawEnergyFromGrid(amount);
+ double voltage = energyNetNodes[i].getVoltage();
+ if (voltage > 500D) {
+ Set<TileEntity> teset = new HashSet<TileEntity>();
+ ForgeDirection direction = ForgeDirection.getOrientation(i).getOpposite();
+ TileEntity te = EnergyNet.instance.getNeighbor(this, direction);
+ teset.add(te);
+ TileEntity te1 = this.getSink(te, teset);
+ if (te1 instanceof IEnergyNetNode) {
+ if (((IEnergyNetNode) te1).getMaxAllowableVoltage() >= voltage) {
+ return;
+ }
+ }
+ if (te1 != null) {
+ sacrifices.add(te1);
+ }
+ }
+ if (amount <= 0d) {
+ break;
+ }
+ }
+ }
+
+ @Override
+ public int getSourceTier() {
+ return 4;
+ }
+
+ @Override
+ public double getDemandedEnergy() {
+ double amount = 0d;
+ for (short i = 0; i < 6; i++) {
+ amount += energyNetNodes[i].getDemandedEnergy();
+ }
+ return amount;
+ }
+
+ @Override
+ public int getSinkTier() {
+ return 4;
+ }
+
+ @Override
+ public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) {
+ if (directionFrom != ForgeDirection.UNKNOWN) {
+ return this.energyNetNodes[directionFrom.getOpposite().ordinal()].injectEnergyToGrid(amount);
+ }
+ return amount;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return null;
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return !this.wrenchCanRemove(entityPlayer);
+ }
+
+ public TileEntity getSink(TileEntity te, Set<TileEntity> teset) {
+ teset.add(te);
+ while (te != null && !(te instanceof IEnergySink)) {
+ TileEntity te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.NORTH);
+ if (te1 == null || teset.contains(te1)) {
+ te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.SOUTH);
+ } else {
+ TileEntity te2 = this.getSink(te1, teset);
+ if (te2 != null) {
+ return te2;
+ }
+ }
+ if (te1 == null || teset.contains(te1)) {
+ te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.UP);
+ } else {
+ TileEntity te2 = this.getSink(te1, teset);
+ if (te2 != null) {
+ return te2;
+ }
+ }
+ if (te1 == null || teset.contains(te1)) {
+ te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.DOWN);
+ } else {
+ TileEntity te2 = this.getSink(te1, teset);
+ if (te2 != null) {
+ return te2;
+ }
+ }
+ if (te1 == null || teset.contains(te1)) {
+ te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.WEST);
+ } else {
+ TileEntity te2 = this.getSink(te1, teset);
+ if (te2 != null) {
+ return te2;
+ }
+ }
+ if (te1 == null || teset.contains(te1)) {
+ te1 = EnergyNet.instance.getNeighbor(te, ForgeDirection.EAST);
+ } else {
+ TileEntity te2 = this.getSink(te1, teset);
+ if (te2 != null) {
+ return te2;
+ }
+ }
+ if (te1 != null) {
+ teset.add(te1);
+ }
+ te = te1;
+ }
+ if (te instanceof IEnergySink) {
+ return te;
+ } else {
+ return null;
+ }
+ }
+
+ public void checkIfNoCablesLeft() {
+ boolean noCables = true;
+ for (SubAnchorEnergyNetNode sen : energyNetNodes) {
+ if (!sen.getCableList().isEmpty()) {
+ noCables = false;
+ }
+ }
+ if (noCables) {
+ worldObj.setBlockToAir(xCoord, yCoord, zCoord);
+ }
+ }
+
+ @Override
+ public boolean isCableRemoved(int chainUniqueID) {
+ if (!checkCables) {
+ return false;
+ }
+ for (SubAnchorEnergyNetNode sen : energyNetNodes) {
+ if (!sen.isCableRemoved(chainUniqueID)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public IEnergyNetNode getEnergyNetNode(short facing) {
+ return energyNetNodes[facing];
+ }
+
+ @Override
+ public short getSide(EntityPlayer player) {
+ return IHLUtils.getFacingFromPlayerView(player, true);
+ }
+
+ @Override
+ public void removeAttachedChains() {
+ for (short i = 0; i < 6; i++) {
+ energyNetNodes[i].removeAttachedChains();
+ }
+
+ }
+
+ public boolean isTileEntityInvalid() {
+ return this.tileEntityInvalid;
+ }
+}
diff --git a/src/main/java/ihl/flexible_cable/BatterySwitchUnitModel.java b/src/main/java/ihl/flexible_cable/BatterySwitchUnitModel.java new file mode 100644 index 0000000..2d16ed4 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/BatterySwitchUnitModel.java @@ -0,0 +1,48 @@ +package ihl.flexible_cable; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +// Date: 07.04.2015 18:24:15 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +public class BatterySwitchUnitModel extends ModelBase +{ + //fields + IHLModelRenderer Piece1; + + public BatterySwitchUnitModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Piece1.Shape1", 0, 0); + setTextureOffset("Piece1.ConeUp01", 0, 0); + setTextureOffset("Piece1.PipeUp", 54, 0); + setTextureOffset("Piece1.ConeUp02", 0, 0); + setTextureOffset("Piece1.Shape27", 0, 0); + setTextureOffset("Piece1.ConeUp04", 0, 0); + + Piece1 = new IHLModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = true; + Piece1.addBox("Shape1", -8F, -8F, -8F, 16, 16, 16); + Piece1.addTube("ConeUp01", -2F, -16F, -2F, 4, 2, 4, 0f, 0.5f, ForgeDirection.DOWN); + Piece1.addTube("PipeUp", -0.5F, -17F, -0.5F, 1, 1, 1, 0f, 1f, ForgeDirection.DOWN); + Piece1.addTube("ConeUp02", -2F, -14F, -2F, 4, 2, 4, 0f, 0.5f, ForgeDirection.DOWN); + Piece1.addTube("Shape27", -2F, -12F, -2F, 4, 2, 4, 0f, 0.5f, ForgeDirection.DOWN); + Piece1.addTube("ConeUp04", -2F, -10F, -2F, 4, 2, 4, 0f, 0.5f, ForgeDirection.DOWN); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/flexible_cable/BatterySwitchUnitTileEntity.java b/src/main/java/ihl/flexible_cable/BatterySwitchUnitTileEntity.java new file mode 100644 index 0000000..f4fc6c1 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/BatterySwitchUnitTileEntity.java @@ -0,0 +1,295 @@ +package ihl.flexible_cable;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySource;
+import ic2.api.network.INetworkClientTileEntityEventListener;
+import ic2.core.ExplosionIC2;
+import ic2.core.IC2;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class BatterySwitchUnitTileEntity extends FlexibleCableHolderBaseTileEntity implements INetworkClientTileEntityEventListener, IEnergySource{
+
+ public short progress;
+ protected short operationLength=200;
+ public boolean isGuiScreenOpened=false;
+ protected final double energyConsume=128D;
+ public double energy;
+ public int maxStorage=65536;
+ private boolean addedToEnergyNet=false;
+ public byte mode = 0;
+ private Set<BatterySwitchUnitTileEntity> batteryChain = new HashSet<BatterySwitchUnitTileEntity>();
+ private BatterySwitchUnitTileEntity batteryChainMaster;
+ private boolean chargingMode=true;
+
+ public BatterySwitchUnitTileEntity()
+ {
+ super();
+ }
+
+ @Override
+ public void onLoaded()
+ {
+ super.onLoaded();
+ if (IC2.platform.isSimulating()&&!this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ }
+
+ @Override
+ public void onUnloaded()
+ {
+ if (IC2.platform.isSimulating()&&this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ super.onUnloaded();
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player)
+ {
+ return IHLUtils.getThisModItemStack("batterySwitchUnit");
+ }
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
+ {
+ return this.getFacing()!=(short)side;
+ }
+
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ nbt.setShort("progress", this.progress);
+ nbt.setDouble("energy", this.energy);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ this.progress = nbt.getShort("progress");
+ this.energy=nbt.getDouble("energy");
+ }
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event)
+ {
+ switch(event)
+ {
+ case 0:
+ this.isGuiScreenOpened=false;
+ break;
+ }
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ {
+ if(this.chargingMode && this.gridID!=-1 && this.energy<this.maxStorage && !this.batteryChain.isEmpty())
+ {
+ if(this.getGrid().energy>0D)
+ {
+ if(this.getGrid().getSinkVoltage(this)/this.batteryChain.size()>410D)
+ {
+ this.energy+=energyConsume;
+ this.getGrid().drawEnergy(energyConsume, this);
+ if(this.getGrid().getSinkVoltage(this)/this.batteryChain.size()>500D)
+ {
+ this.createChainOfExplosions();
+ }
+ }
+ }
+ }
+ if(this.chargingMode && this.batteryChainMaster!=null && this.gridID==-1)
+ {
+ if(this.batteryChainMaster.gridID!=-1 && this.batteryChainMaster.energy>0D && this.energy<this.maxStorage && !this.batteryChainMaster.batteryChain.isEmpty())
+ {
+ if(this.batteryChainMaster.getGrid().getSinkVoltage(this.batteryChainMaster)/this.batteryChainMaster.batteryChain.size()>410D)
+ {
+ this.energy+=energyConsume;
+ this.batteryChainMaster.drawEnergy(energyConsume);
+ }
+ }
+ }
+ if(this.chargingMode && this.gridID!=-1 && MinecraftServer.getServer().getTickCounter() % 40==0)
+ {
+ this.checkBatteryChain();
+ }
+ if(this.energy>=this.maxStorage)
+ {
+ this.chargingMode=false;
+ }
+ if(!this.chargingMode)
+ {
+ this.energy-=0.01D;
+ if(this.energy<energyConsume)
+ {
+ this.chargingMode=true;
+ }
+ }
+ }
+ }
+
+ private void createChainOfExplosions()
+ {
+ Iterator<BatterySwitchUnitTileEntity> batteryChainIterator = this.batteryChain.iterator();
+ while(batteryChainIterator.hasNext())
+ {
+ BatterySwitchUnitTileEntity bsu = batteryChainIterator.next();
+ ExplosionIC2 explosion = new ExplosionIC2(bsu.worldObj, null, bsu.xCoord+0.5D, bsu.yCoord+0.5D, bsu.zCoord+0.5D, 2F, 0.3F, ExplosionIC2.Type.Normal, null, 0);
+ explosion.doExplosion();
+ }
+ }
+
+ private boolean checkBatteryChain()
+ {
+ boolean allright=true;
+ if(!this.batteryChain.isEmpty())
+ {
+ Iterator<BatterySwitchUnitTileEntity> sectionsIterator = this.batteryChain.iterator();
+ while(sectionsIterator.hasNext())
+ {
+ BatterySwitchUnitTileEntity section = sectionsIterator.next();
+ if(section==null || section.isInvalid())
+ {
+ allright=false;
+ }
+ }
+ }
+ else
+ {
+ allright=false;
+ }
+ if(allright)
+ {
+ return true;
+ }
+ else
+ {
+ this.batteryChain.clear();
+ boolean checking = true;
+ int x=xCoord;
+ int z=zCoord;
+ List<Integer> xs = new ArrayList<Integer>();
+ List<Integer> zs = new ArrayList<Integer>();
+ xs.add(xCoord);
+ zs.add(zCoord);
+ this.batteryChain.add(this);
+ while(checking)
+ {
+ if(!xs.isEmpty() && !zs.isEmpty())
+ {
+ x=xs.remove(0);
+ z=zs.remove(0);
+ }
+ else
+ {
+ checking=false;
+ break;
+ }
+ int[] xz = new int[] {0,1,0,-1,0};
+ for(int i=0;i<xz.length-1;i++)
+ {
+ TileEntity te = worldObj.getTileEntity(x+xz[i], yCoord, z+xz[i+1]);
+ if(te instanceof BatterySwitchUnitTileEntity)
+ {
+ BatterySwitchUnitTileEntity section = (BatterySwitchUnitTileEntity)te;
+ if(this.batteryChain.add(section))
+ {
+ xs.add(section.xCoord);
+ zs.add(section.zCoord);
+ section.batteryChain.add(this);
+ section.batteryChainMaster=this;
+ }
+ }
+ }
+ }
+ return true;
+ }
+ }
+
+ @Override
+ public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) {
+ return true;
+ }
+
+ @Override
+ public double getOfferedEnergy()
+ {
+ return this.chargingMode? 0 : this.energy;
+ }
+
+ @Override
+ public void drawEnergy(double amount)
+ {
+ this.energy-=amount;
+ }
+
+ @Override
+ public double getEnergyAmountThisNodeWant()
+ {
+ return this.energy-this.maxStorage;
+ }
+
+ public double drawEnergyToGrid(double amount)
+ {
+ return 0d;
+ }
+
+ public double injectEnergy(double amount)
+ {
+ this.energy+=amount;
+ return 0d;
+ }
+
+ @Override
+ public int getSourceTier() {
+ return 4;
+ }
+
+ @Override
+ public double getMaxAllowableVoltage()
+ {
+ return 64000D;
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return null;
+ }
+
+ @Override
+ public void injectEnergyInThisNode(double amount, double voltage)
+ {
+ this.energy+=amount;
+ if(voltage/this.batteryChain.size()>500D)
+ {
+ this.createChainOfExplosions();
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/flexible_cable/BlastEntityFX.java b/src/main/java/ihl/flexible_cable/BlastEntityFX.java new file mode 100644 index 0000000..49e2a36 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/BlastEntityFX.java @@ -0,0 +1,68 @@ +package ihl.flexible_cable;
+
+import net.minecraft.client.particle.EntityFX;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.world.World;
+
+public class BlastEntityFX extends EntityFX {
+
+ public BlastEntityFX(World world, double x, double y, double z)
+ {
+ super(world, x, y, z);
+ this.renderDistanceWeight = 5.0D;
+ }
+
+ public BlastEntityFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14)
+ {
+ super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D);
+ this.motionX *= 0.10000000149011612D;
+ this.motionY *= 0.10000000149011612D;
+ this.motionZ *= 0.10000000149011612D;
+ this.motionX += par8;
+ this.motionY += par10;
+ this.motionZ += par12;
+ this.particleScale *= par14;
+ this.particleMaxAge = 3;
+ this.particleAge=0;
+ this.noClip = false;
+ this.renderDistanceWeight = 6.0D;
+ }
+
+ @Override
+ public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
+ {
+ float var8 = this.particleTextureIndexX / 2.0F;
+ float var9 = var8 + 0.5f;
+ float var10 = this.particleTextureIndexY / 2.0F;
+ float var11 = var10 + 0.5f;
+ float var12 = 0.1F * this.particleScale;
+ float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
+ float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
+ float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
+ par1Tessellator.addVertexWithUV(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12, var9, var11);
+ par1Tessellator.addVertexWithUV(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12, var9, var10);
+ par1Tessellator.addVertexWithUV(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12, var8, var10);
+ par1Tessellator.addVertexWithUV(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12, var8, var11);
+ }
+
+ @Override
+ public void onUpdate()
+ {
+ this.prevPosX = this.posX;
+ this.prevPosY = this.posY;
+ this.prevPosZ = this.posZ;
+ if (this.particleAge++ >= this.particleMaxAge)
+ {
+ this.setDead();
+ }
+ this.setParticleTextureIndex(this.particleAge * 3 / this.particleMaxAge);
+ }
+
+ @Override
+ public void setParticleTextureIndex(int par1)
+ {
+ this.particleTextureIndexX = par1 % 2;
+ this.particleTextureIndexY = par1 / 2;
+ }
+
+}
diff --git a/src/main/java/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java b/src/main/java/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java new file mode 100644 index 0000000..919e130 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/FlexibleCableHolderBaseTileEntity.java @@ -0,0 +1,237 @@ +package ihl.flexible_cable;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import ic2.core.block.TileEntityInventory;
+import ihl.IHLMod;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.util.AxisAlignedBB;
+
+public abstract class FlexibleCableHolderBaseTileEntity extends TileEntityInventory implements IEnergyNetNode{
+
+ protected double connectionX;
+ protected double connectionY;
+ protected double connectionZ;
+ protected int gridID=-1;
+ protected final Set<IHLCable> cableList;
+ public boolean checkCables=true;
+
+ public FlexibleCableHolderBaseTileEntity()
+ {
+ super();
+ cableList=new HashSet<IHLCable>();
+ }
+
+ @Override
+ public void onLoaded()
+ {
+ super.onLoaded();
+ if(gridID!=-1)
+ {
+ IHLGrid grid = IHLMod.enet.getGrid(gridID);
+ grid.add(this);
+ }
+ }
+
+ @Override
+ public void onUnloaded()
+ {
+ super.onUnloaded();
+ if(gridID!=-1)
+ {
+ IHLGrid grid = IHLMod.enet.getGrid(gridID);
+ grid.remove(this);
+ }
+ }
+
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setFacing(short facing1)
+ {
+ short facing2 = (short) Math.max(facing1, 2);
+ double range = 2D;
+ AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(connectionX-range,connectionY-range,connectionZ-range,connectionX+range,connectionY+range,connectionZ+range);
+ List<NodeEntity> nodeList = worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea);
+ super.setFacing(facing2);
+ setConnectionX(this.xCoord+0.5D);
+ setConnectionY(this.yCoord+1.5D);
+ setConnectionZ(this.zCoord+0.5D);
+ if(!nodeList.isEmpty())
+ {
+ Iterator<NodeEntity> ei = nodeList.iterator();
+ while(ei.hasNext())
+ {
+ NodeEntity ne=(NodeEntity) ei.next();
+ if((ne.prevAnchorEntity==null||ne.nextAnchorEntity==null) && this.cableListContains(ne.getChainUniqueID()))
+ {
+ ne.setVirtualNodePos(connectionX, connectionY, connectionZ);
+ }
+ }
+ }
+ }
+
+ protected boolean cableListContains(int chainUniqueID) {
+ Iterator<IHLCable> cli = this.getCableList().iterator();
+ while(cli.hasNext())
+ {
+ IHLCable c = cli.next();
+ if(c.chainUID==chainUniqueID)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
+ {
+ return this.getFacing()!=(short)side;
+ }
+
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ NBTTagList cableNBTList = new NBTTagList();
+ for(IHLCable cable:this.cableList)
+ {
+ cableNBTList.appendTag(cable.toNBT());
+ }
+ nbt.setTag("cableList", cableNBTList);
+ nbt.setDouble("connectionX", this.connectionX);
+ nbt.setDouble("connectionY", this.connectionY);
+ nbt.setDouble("connectionZ", this.connectionZ);
+ nbt.setInteger("gridID", this.gridID);
+ nbt.setBoolean("checkCables", this.checkCables);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ NBTTagList cableNBTList=nbt.getTagList("cableList", 10);
+ for(int i=0;i<cableNBTList.tagCount();i++)
+ {
+ this.cableList.add(IHLCable.fromNBT(cableNBTList.getCompoundTagAt(i)));
+ }
+ this.setConnectionX(nbt.getDouble("connectionX"));
+ this.setConnectionY(nbt.getDouble("connectionY"));
+ this.setConnectionZ(nbt.getDouble("connectionZ"));
+ this.gridID=nbt.getInteger("gridID");
+ this.checkCables=nbt.getBoolean("checkCables");
+ }
+
+ @Override
+ public void removeAttachedChains()
+ {
+ IHLUtils.removeChains(this,this.worldObj);
+ }
+
+ public void setConnectionX(double connectionX) {
+ this.connectionX = connectionX;
+ }
+
+ public void setConnectionY(double connectionY) {
+ this.connectionY = connectionY;
+ }
+
+ public void setConnectionZ(double connectionZ) {
+ this.connectionZ = connectionZ;
+ }
+
+ @Override
+ public double[] getPortPos(EntityLivingBase player)
+ {
+ return new double[] {this.connectionX,this.connectionY,this.connectionZ};
+ }
+
+ @Override
+ public boolean addCable(NBTTagCompound cable)
+ {
+ return this.cableList.add(IHLCable.fromNBT(cable));
+ }
+
+ @Override
+ public Set<IHLCable> getCableList() {
+ return cableList;
+ }
+
+ @Override
+ public void setGrid(int newGridID)
+ {
+ if(newGridID!=-1)
+ {
+ this.gridID=newGridID;
+ IHLMod.enet.getGrid(newGridID).add(this);
+ }
+ else
+ {
+ this.gridID=-1;
+ }
+ }
+
+ @Override
+ public int getGridID()
+ {
+ return this.gridID;
+ }
+
+ @Override
+ public IHLGrid getGrid()
+ {
+ return IHLMod.enet.getGrid(gridID);
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+ @Override
+ public void remove(IHLCable cable)
+ {
+ if(this.cableList.remove(cable))
+ {
+ IHLUtils.removeChain(cable, this);
+ }
+ }
+
+
+ @Override
+ public boolean isCableRemoved(int chainUniqueID)
+ {
+ if(!checkCables)
+ {
+ return false;
+ }
+ for(IHLCable cable:this.cableList)
+ {
+ if(cable.chainUID==chainUniqueID)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void setCableCheck(boolean b)
+ {
+ this.checkCables=b;
+ }
+
+ @Override
+ public boolean isTileEntityBaseInvalid(){
+ return this.tileEntityInvalid;
+ }
+}
diff --git a/src/main/java/ihl/flexible_cable/IHLCable.java b/src/main/java/ihl/flexible_cable/IHLCable.java new file mode 100644 index 0000000..e47621e --- /dev/null +++ b/src/main/java/ihl/flexible_cable/IHLCable.java @@ -0,0 +1,111 @@ +package ihl.flexible_cable; + +import ihl.metallurgy.constants.ElectricConductor; +import net.minecraft.nbt.NBTTagCompound; + +public class IHLCable { + + public final int chainUID; + public final int fullLength; + public final int length; + public final String material; + public final int transverseSection; + public final String insulationMaterial; + public final int insulationThickness; + public final int maxVoltage; + public final int connectorX1; + public final int connectorY1; + public final int connectorZ1; + public final int connectorDimensionId1; + public final short connectorFacing1; + public final int connectorX; + public final int connectorY; + public final int connectorZ; + public final int connectorDimensionId; + public final short connectorFacing; + + public IHLCable(int chainUIDIn, int fullLengthIn, int lengthIn, String materialIn, int transverseSectionIn, + String insulationMaterialIn, int insulationThicknessIn, int maxVoltageIn, int connectorX1In, + int connectorY1In, int connectorZ1In, int connectorDimensionId1In, short connectorFacing1In, + int connectorXIn, int connectorYIn, int connectorZIn, int connectorDimensionIdIn, short connectorFacingIn) { + chainUID = chainUIDIn; + fullLength = fullLengthIn; + length = lengthIn; + material = materialIn; + transverseSection = transverseSectionIn; + insulationMaterial = insulationMaterialIn; + insulationThickness = insulationThicknessIn; + maxVoltage = maxVoltageIn; + connectorX1 = connectorX1In; + connectorY1 = connectorY1In; + connectorZ1 = connectorZ1In; + connectorDimensionId1 = connectorDimensionId1In; + connectorFacing1 = connectorFacing1In; + connectorX = connectorXIn; + connectorY = connectorYIn; + connectorZ = connectorZIn; + connectorDimensionId = connectorDimensionIdIn; + connectorFacing = connectorFacingIn; + } + + public static IHLCable fromNBT(NBTTagCompound tag) { + return new IHLCable(tag.getInteger("chainUID"), + tag.getInteger("fullLength"), + tag.getInteger("length"), + tag.getString("material"), + tag.getInteger("transverseSection"), + tag.getString("insulationMaterial"), + tag.getInteger("insulationThickness"), + tag.getInteger("maxVoltage"), + tag.getInteger("connectorX1"), + tag.getInteger("connectorY1"), + tag.getInteger("connectorZ1"), + tag.getInteger("connectorDimensionId1"), + tag.getShort("connectorFacing1"), + tag.getInteger("connectorX"), + tag.getInteger("connectorY"), + tag.getInteger("connectorZ"), + tag.getInteger("connectorDimensionId"), + tag.getShort("connectorFacing")); + } + + public NBTTagCompound toNBT() { + NBTTagCompound tag = new NBTTagCompound(); + tag.setInteger("fullLength", fullLength); + tag.setInteger("length", length); + tag.setString("material", material); + tag.setInteger("transverseSection", transverseSection); + tag.setString("insulationMaterial", insulationMaterial); + tag.setInteger("insulationThickness", insulationThickness); + tag.setInteger("maxVoltage", maxVoltage); + tag.setInteger("connectorX1",connectorX1); + tag.setInteger("connectorY1",connectorY1); + tag.setInteger("connectorZ1",connectorZ1); + tag.setInteger("connectorDimensionId1",connectorDimensionId1); + tag.setShort("connectorFacing1",connectorFacing1); + tag.setInteger("connectorX",connectorX); + tag.setInteger("connectorY",connectorY); + tag.setInteger("connectorZ",connectorZ); + tag.setInteger("connectorDimensionId",connectorDimensionId); + tag.setShort("connectorFacing",connectorFacing); + return tag; + } + + @Override + public int hashCode() { + return chainUID; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof IHLCable)) + return false; + IHLCable otherCable = (IHLCable) o; + return otherCable.chainUID == this.chainUID; + } + + public long getResistance(){ + return ElectricConductor.getResistivity(material) * 100L / transverseSection; + } + +} diff --git a/src/main/java/ihl/flexible_cable/IHLENet.java b/src/main/java/ihl/flexible_cable/IHLENet.java new file mode 100644 index 0000000..de08204 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/IHLENet.java @@ -0,0 +1,168 @@ +package ihl.flexible_cable;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import ihl.IHLMod;
+import ihl.interfaces.IEnergyNetNode;
+
+public class IHLENet {
+
+ public Map<Integer, IHLGrid> grids = new HashMap<Integer, IHLGrid>();
+ public Map<Integer, IHLGrid> cablesToGrids = new HashMap<Integer, IHLGrid>();
+
+ private int griduid=0;
+
+ public IHLENet()
+ {
+ }
+
+ public int getNewUniqueGridID()
+ {
+ for(int i=0;i<Integer.MAX_VALUE;i++)
+ {
+ if(grids.get(++griduid)==null)
+ {
+ return griduid;
+ }
+ }
+ return -1;
+ }
+
+ public int mergeGrids(int gridID, int gridID2)
+ {
+ if(gridID==-1 && gridID2!=-1)
+ {
+ return gridID2;
+ }
+ else if(gridID!=-1 && gridID2==-1)
+ {
+ return gridID;
+ }
+ else if(gridID==-1 && gridID2==-1)
+ {
+ int newGridID=this.getNewUniqueGridID();
+ IHLGrid cgrid;
+ cgrid=new IHLGrid();
+ grids.put(newGridID, cgrid);
+ return newGridID;
+ }
+ else if(gridID!=gridID2)
+ {
+ Iterator<IEnergyNetNode> tei = grids.get(gridID2).telist.iterator();
+ while(tei.hasNext())
+ {
+ IEnergyNetNode te = tei.next();
+ te.setGrid(gridID);
+ }
+ grids.remove(gridID2);
+ return gridID;
+ }
+ return gridID2;
+ }
+
+
+ public IHLGrid getGrid(int gridID)
+ {
+ if(gridID==-1)
+ throw new IllegalArgumentException("Node should never ask grid with ID -1");
+ if(this.grids.get(gridID)==null)
+ {
+ IHLGrid cgrid;
+ cgrid=new IHLGrid();
+ grids.put(gridID, cgrid);
+ return cgrid;
+ }
+ else
+ {
+ return this.grids.get(gridID);
+ }
+ }
+
+ public void splitGrids(int gridID, IEnergyNetNode exclude)
+ {
+ Set<IEnergyNetNode> telist = this.grids.get(gridID).telist;
+ Set<IEnergyNetNode> telist2 = new HashSet<IEnergyNetNode>();
+ telist.remove(exclude);
+ Iterator<IEnergyNetNode> atei = telist.iterator();
+ while(atei.hasNext())
+ {
+ IEnergyNetNode cte = atei.next();
+ atei.remove();
+ telist2.add(cte);
+ cte.getCableList().removeAll(exclude.getCableList());
+ cte.setGrid(-1);
+ }
+ Iterator<IEnergyNetNode> atei2 = telist2.iterator();
+ while(atei2.hasNext())
+ {
+ IEnergyNetNode cte = atei2.next();
+ if(cte.getGridID()==-1)//Warning! Potential future bugs are hidden here!
+ {
+ Iterator<IEnergyNetNode> atei3 = telist2.iterator();
+ while(atei3.hasNext())
+ {
+ IEnergyNetNode cte2 = atei3.next();
+ if(cte2!=cte && hasSame(cte.getCableList(),cte2.getCableList()))
+ {
+ int result=this.mergeGrids(cte.getGridID(), cte2.getGridID());
+ cte.setGrid(result);
+ cte2.setGrid(result);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public void removeCableAndSplitGrids(int gridID, IHLCable cable)
+ {
+ this.grids.get(gridID).removeCableAndSplitGrids(cable);
+ }
+
+ public boolean hasSame(Set<IHLCable> set, Set<IHLCable> set2)
+ {
+ Iterator<IHLCable> i1 = set.iterator();
+ while(i1.hasNext())
+ {
+ IHLCable num1=i1.next();
+ if(set2.contains(num1))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void setOnFire(IHLCable cable)
+ {
+ Set<NodeEntity> cs = IHLMod.proxy.nodeEntityRegistry.get(cable.chainUID);
+ if(cs!=null)
+ {
+ for(NodeEntity ne:cs)
+ {
+ ne.setFire(10);
+ }
+ }
+ }
+
+ public void removeCableEntities(IHLCable cable)
+ {
+ int uid = cable.chainUID;
+ Set<NodeEntity> cs = IHLMod.proxy.nodeEntityRegistry.get(uid);
+ if(cs!=null)
+ {
+ for(NodeEntity ne:cs)
+ {
+ if(ne!=null)
+ {
+ ne.setDead();
+ }
+ }
+ }
+ cablesToGrids.remove(uid);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/flexible_cable/IHLGrid.java b/src/main/java/ihl/flexible_cable/IHLGrid.java new file mode 100644 index 0000000..0a8178e --- /dev/null +++ b/src/main/java/ihl/flexible_cable/IHLGrid.java @@ -0,0 +1,291 @@ +package ihl.flexible_cable;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import ihl.IHLMod;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.utils.IHLUtils;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
+
+public class IHLGrid {
+ private static final double powerLossLimitPerMeter = 1.6D;
+ public final Set<IEnergyNetNode> telist = new HashSet<IEnergyNetNode>();
+ public double energy = 0D;
+ private IEnergyNetNode sink;
+ private IEnergyNetNode source;
+ private double voltage = 400d;
+ private double lastVoltage;
+ public boolean isGridValid = true;
+ private double total20TicksEU;
+ private int lastTickCounter = 0;
+ private int tickCounterFireStart = 0;
+ public final List<IEnergyNetNode> calculatedSinks = new ArrayList<IEnergyNetNode>();
+ public final List<IEnergyNetNode> calculatedSources = new ArrayList<IEnergyNetNode>();
+ public final Set<IHLCable> cablesOnFire = new HashSet<IHLCable>();
+ private final Map<IEnergyNetNode, Double> energyLossSinkMap = new HashMap<IEnergyNetNode, Double>();
+ private final Map<IEnergyNetNode, Double> voltageSinkMap = new HashMap<IEnergyNetNode, Double>();
+ private double averageEUTransfered;
+ private double lastAverageEUTransfered = 0D;
+
+ public void drawEnergy(double amount, IEnergyNetNode sink1) {
+ this.energy -= amount;
+ if (energyLossSinkMap.get(sink1) != null) {
+ this.energy -= energyLossSinkMap.get(sink1) * amount * amount;
+ } else {
+ this.telist.add(sink1);
+ }
+ this.sink = sink1;
+ }
+
+ public void injectEnergy(double amount, double voltage1, IEnergyNetNode source1) {
+ this.energy += amount;
+ this.voltage = voltage1;
+ this.source = source1;
+ this.total20TicksEU += amount;
+ int tickCounter = MinecraftServer.getServer().getTickCounter();
+ if (tickCounter - lastTickCounter < 0) {
+ lastTickCounter = tickCounter;
+ this.total20TicksEU = 0D;
+ }
+ Iterator<IEnergyNetNode> i = telist.iterator();
+ while (this.energy > 1d && i.hasNext()) {
+ IEnergyNetNode eNode = i.next();
+ if (eNode.isTileEntityBaseInvalid()) {
+ if (!eNode.getCableList().isEmpty()) {
+ for (IHLCable cable : eNode.getCableList()) {
+ IHLMod.enet.cablesToGrids.remove(cable.chainUID);
+ }
+ }
+ IHLMod.log.error("Removing invalide TE " + eNode.getClass().getName());
+ i.remove();
+ continue;
+ }
+ else if(eNode.getGridID()==-1) {
+ eNode.removeAttachedChains();
+ IHLMod.log.error("Removing TE with grid ID==-1 " + eNode.getClass().getName()+ " If it happened more than a single time, report that to mod author.");
+ i.remove();
+ continue;
+ }
+ if (eNode.getEnergyAmountThisNodeWant() > 0d) {
+ double powerToInject = Math.min(energy, eNode.getEnergyAmountThisNodeWant());
+ eNode.injectEnergyInThisNode(powerToInject, this.getSinkVoltage(eNode));
+ this.energy -= powerToInject;
+ if (energyLossSinkMap.get(eNode) != null) {
+ this.energy -= energyLossSinkMap.get(eNode) * powerToInject * powerToInject;
+ } else {
+ this.sink = eNode;
+ }
+ }
+ }
+ int d = tickCounter - lastTickCounter;
+ if (d >= 40) {
+ this.averageEUTransfered = this.total20TicksEU / d;
+ lastTickCounter = tickCounter;
+ this.total20TicksEU = 0D;
+ if (IHLMod.config.enableFlexibleCablesGridPowerLossCalculations && isGridValid
+ && this.averageEUTransfered > 1D) {
+ this.telist.add(source1);
+ this.updateGrid();
+ }
+ }
+ d = tickCounter - tickCounterFireStart;
+ if (d >= 40 && !this.cablesOnFire.isEmpty()) {
+ for (IHLCable cable : this.cablesOnFire) {
+ this.removeCableAndSplitGrids(cable);
+ }
+ this.cablesOnFire.clear();
+ }
+
+ }
+
+ public void removeCableAndSplitGrids(IHLCable cable) {
+ IHLUtils.removeChain(cable, null);
+ Iterator<IEnergyNetNode> atei = this.telist.iterator();
+ Set<IEnergyNetNode> telist2 = new HashSet<IEnergyNetNode>();
+ while (atei.hasNext()) {
+ IEnergyNetNode cte = atei.next();
+ atei.remove();
+ telist2.add(cte);
+ cte.setGrid(-1);
+ }
+ IHLMod.enet.removeCableEntities(cable);
+ Iterator<IEnergyNetNode> atei2 = telist2.iterator();
+ while (atei2.hasNext()) {
+ IEnergyNetNode cte = atei2.next();
+ if (cte.getGridID() == -1) {
+ Iterator<IEnergyNetNode> atei3 = telist2.iterator();
+ while (atei3.hasNext()) {
+ IEnergyNetNode cte2 = atei3.next();
+ if (cte2 != cte && IHLMod.enet.hasSame(cte.getCableList(), cte2.getCableList())) {
+ int result = IHLMod.enet.mergeGrids(cte.getGridID(), cte2.getGridID());
+ cte.setGrid(result);
+ cte2.setGrid(result);
+ break;
+ }
+ }
+
+ }
+ }
+ }
+
+ private void updateGrid() {
+ Iterator<IEnergyNetNode> atei2 = telist.iterator();
+ while (atei2.hasNext()) {
+ IEnergyNetNode cte = atei2.next();
+ if (cte.isTileEntityBaseInvalid()) {
+ if (!cte.getCableList().isEmpty()) {
+ for (IHLCable cable : cte.getCableList()) {
+ IHLMod.enet.cablesToGrids.remove(cable.chainUID);
+ }
+ }
+ atei2.remove();
+ }
+ }
+ if (this.source != null && this.sink != null && this.source != this.sink && !this.sink.getCableList().isEmpty()
+ && !this.source.getCableList().isEmpty()
+ && (!this.calculatedSources.contains(this.source) || !this.calculatedSinks.contains(this.sink)
+ || this.averageEUTransfered > this.lastAverageEUTransfered
+ || this.voltage != this.lastVoltage)) {
+ IEnergyNetNode[] gridTEList = new IEnergyNetNode[this.telist.size()];
+ if (gridTEList.length > 100)
+ IHLMod.log.error("Grid has " + gridTEList.length
+ + " nodes. If there is no such complex grids in game, report that to mod author.");
+ gridTEList = this.telist.toArray(gridTEList);
+ Map<IEnergyNetNode, IHLCable> map = new HashMap<IEnergyNetNode, IHLCable>();
+ Set<IEnergyNetNode> templist = new HashSet<IEnergyNetNode>();
+ Set<IEnergyNetNode> processlist = new HashSet<IEnergyNetNode>();
+ Set<IEnergyNetNode> templist2 = new HashSet<IEnergyNetNode>();
+ templist.addAll(telist);
+ processlist.add(sink);
+ int threads = 0;
+ a: while (!templist.isEmpty()) {
+ if (threads++ > 1000) {
+ this.isGridValid = false;
+ return;
+ }
+ templist.removeAll(processlist);
+ templist2.clear();
+ Iterator<IEnergyNetNode> it1 = processlist.iterator();
+ while (it1.hasNext()) {
+ if (threads++ > 1000) {
+ this.isGridValid = false;
+ return;
+ }
+ IEnergyNetNode ate1 = it1.next();
+ Iterator<IEnergyNetNode> it2 = templist.iterator();
+ while (it2.hasNext()) {
+ if (threads++ > 1000) {
+ this.isGridValid = false;
+ return;
+ }
+ IEnergyNetNode ate2 = it2.next();
+ if (ate1 != ate2) {
+ IHLCable cable = this.getSame(ate1.getCableList(), ate2.getCableList());
+ if (cable != null) {
+ map.put(ate2, cable);
+ templist2.add(ate2);
+ if (ate2 == source) {
+ break a;
+ }
+ }
+ }
+ }
+ templist.removeAll(templist2);
+ }
+ processlist.clear();
+ processlist.addAll(templist2);
+ }
+ IEnergyNetNode cursor = source;
+ {
+ double voltage1 = this.voltage;
+ double euTransfered = this.averageEUTransfered;
+ double voltageLossPerMeter = 0D;
+ double powerLossPerMeter = 0D;
+ double powerLossPerSquaredEU = 0D;
+ this.energyLossSinkMap.remove(sink);
+ this.voltageSinkMap.remove(sink);
+ while (cursor != sink) {
+ // System.out.println("cycle 4");
+ IHLCable cable = map.get(cursor);
+ if (cable == null) {
+ IHLMod.log.error("One of a cables is null during grid update. Skipping update in this tick.");
+ return;
+ }
+ voltageLossPerMeter = cable.getResistance() / 1000D * euTransfered / voltage1;
+ powerLossPerMeter = voltageLossPerMeter * euTransfered / voltage1;
+ euTransfered -= powerLossPerMeter * cable.length;
+ voltage1 -= voltageLossPerMeter * cable.length;
+ powerLossPerSquaredEU += cable.getResistance() / 1000d * cable.length / voltage1 / voltage1;
+ if (!this.cablesOnFire.contains(cable) && (powerLossPerMeter > IHLGrid.powerLossLimitPerMeter)) {
+ IHLMod.enet.setOnFire(cable);
+ tickCounterFireStart = lastTickCounter;
+ this.cablesOnFire.add(cable);
+ }
+ cursor = this.getHasCable(cable, cursor, gridTEList);
+ }
+ this.energyLossSinkMap.put(sink, powerLossPerSquaredEU);
+ if (voltage1 < 1d)
+ voltage1 = 1d;
+ this.voltageSinkMap.put(sink, voltage1);
+ }
+ this.calculatedSources.add(this.source);
+ this.calculatedSinks.add(this.sink);
+ this.lastAverageEUTransfered = this.averageEUTransfered;
+ this.lastVoltage = this.voltage;
+ }
+ }
+
+ private IHLCable getSame(Set<IHLCable> set, Set<IHLCable> set2) {
+ Iterator<IHLCable> i1 = set.iterator();
+ while (i1.hasNext()) {
+ IHLCable cable = i1.next();
+ if (set2.contains(cable)) {
+ return cable;
+ }
+ }
+ return null;
+ }
+
+ public double getSinkVoltage(IEnergyNetNode node) {
+ if (this.voltageSinkMap.containsKey(node)) {
+ return this.voltageSinkMap.get(node);
+ } else {
+ return this.voltage;
+ }
+ }
+
+ private IEnergyNetNode getHasCable(IHLCable cable, IEnergyNetNode exclude, IEnergyNetNode[] gridTEList) {
+ for (IEnergyNetNode ate1 : gridTEList) {
+ if (ate1 != exclude && ate1.getCableList().contains(cable)) {
+ return ate1;
+ }
+ }
+ return null;
+ }
+
+ public void add(IEnergyNetNode e) {
+ this.telist.add(e);
+ this.isGridValid = true;
+ if (!e.getCableList().isEmpty()) {
+ for (IHLCable cable : e.getCableList()) {
+ IHLMod.enet.cablesToGrids.put(cable.chainUID, this);
+ }
+ }
+ }
+
+ public void remove(IEnergyNetNode e) {
+ this.telist.remove(e);
+ if (!e.getCableList().isEmpty()) {
+ for (IHLCable cable : e.getCableList()) {
+ IHLMod.enet.cablesToGrids.remove(cable.chainUID);
+ }
+ }
+ }
+}
diff --git a/src/main/java/ihl/flexible_cable/InvSlotOutputInProgress.java b/src/main/java/ihl/flexible_cable/InvSlotOutputInProgress.java new file mode 100644 index 0000000..da17e0f --- /dev/null +++ b/src/main/java/ihl/flexible_cable/InvSlotOutputInProgress.java @@ -0,0 +1,93 @@ +package ihl.flexible_cable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class InvSlotOutputInProgress extends IronWorkbenchInvSlot{
+ public short[] slotRecipe;
+ private int size;
+ public InvSlotOutputInProgress(IronWorkbenchTileEntity base1, String name1, int oldStartIndex1, int count) {
+ super(base1, name1, oldStartIndex1, Access.NONE, count);
+ slotRecipe = new short[count];
+ size=count;
+ for(int i=0;i<slotRecipe.length;i++)
+ {
+ slotRecipe[i]=-1;
+ }
+ }
+
+ @Override
+ public boolean accepts(ItemStack itemStack)
+ {
+ return false;
+ }
+
+ @Override
+ public boolean getCanTakeStack()
+ {
+ return false;
+ }
+
+ @Override
+ public void writeToNbt(NBTTagCompound nbtTagCompound){}
+
+ @Override
+ public void readFromNbt(NBTTagCompound nbtTagCompound){}
+
+ public short put(List<ItemStack> outputs)
+ {
+ short slot=this.getFirstEmptySlot();
+ if(slot!=-1 && outputs!=null && !outputs.isEmpty() && slot<=this.size()-outputs.size())
+ {
+ for(int i=0;i<outputs.size();i++)
+ {
+ ItemStack output = outputs.get(i);
+ this.put(slot+i,output.copy());
+ this.slotRecipe[slot+i]=slot;
+ }
+ }
+ return slot;
+ }
+
+
+
+ private short getFirstEmptySlot()
+ {
+ for(short i=0; i<this.size();i++)
+ {
+ if(this.get(i)==null)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public int getCheckSum()
+ {
+ int sum=0;
+ for(short i=0; i<this.size();i++)
+ {
+ sum+=this.slotRecipe[i];
+ }
+ return sum;
+ }
+
+ public List<ItemStack> getRecipeOutputs(int currentSlot)
+ {
+ int slotRecipeIndex=this.slotRecipe[currentSlot];
+ List<ItemStack> list = new ArrayList<ItemStack>();
+ for(int i=0;i<this.size;i++)
+ {
+ if(this.slotRecipe[i]==slotRecipeIndex && get(i)!=null)
+ {
+ list.add(get(i));
+ }
+ }
+ return list;
+ }
+
+}
diff --git a/src/main/java/ihl/flexible_cable/InvSlotProcessableIronWorkbench.java b/src/main/java/ihl/flexible_cable/InvSlotProcessableIronWorkbench.java new file mode 100644 index 0000000..fa2cc73 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/InvSlotProcessableIronWorkbench.java @@ -0,0 +1,131 @@ +package ihl.flexible_cable;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputFluidContainer;
+import ic2.core.IC2;
+import ic2.core.item.ItemUpgradeModule;
+import ihl.interfaces.IWire;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+
+public class InvSlotProcessableIronWorkbench extends IronWorkbenchInvSlot {
+
+ public InvSlotProcessableIronWorkbench(IronWorkbenchTileEntity base1,
+ String name1, int oldStartIndex1, Access access1, int count) {
+ super(base1, name1, oldStartIndex1, access1, count);
+ }
+
+ @Override
+ public boolean accepts(ItemStack itemStack)
+ {
+ if (itemStack != null && itemStack.getItem() instanceof ItemUpgradeModule)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ @Override
+ public void put(int index, ItemStack content)
+ {
+ super.put(index, content);
+ if(IC2.platform.isSimulating() && ((IronWorkbenchTileEntity)this.base).container!=null)
+ {
+ ((IronWorkbenchTileEntity)this.base).resetOutput();
+ ((IronWorkbenchTileEntity)this.base).container.detectAndSendChanges();
+ }
+ }
+
+ public Set<ItemStack> substract(List<IRecipeInput> materials, int multiplier)
+ {
+ Set<ItemStack> output = new HashSet<ItemStack>();
+ Iterator<IRecipeInput> i1 = materials.iterator();
+ while(i1.hasNext())
+ {
+ IRecipeInput is1 = i1.next();
+ for(int i=0;i<this.size();i++)
+ {
+ ItemStack is = this.get(i);
+ if(is!=null && (is1.matches(is)))
+ {
+ if(is.getItem() instanceof IWire)
+ {
+ if(IHLUtils.adjustWireLength(is, -is1.getAmount()*multiplier))
+ {
+ is.stackSize=0;
+ }
+ }
+ else if(is1 instanceof RecipeInputFluidContainer)
+ {
+ if(is.stackSize==1)
+ {
+ output.add(FluidContainerRegistry.drainFluidContainer(is));
+ is.stackSize=0;
+ }
+ else
+ {
+ is.stackSize-=is1.getAmount()*multiplier;
+ ItemStack iscopy = is.copy();
+ iscopy.stackSize=1;
+ ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(iscopy);
+ if(emptyContainer!=null)
+ {
+ output.add(emptyContainer);
+ }
+ }
+ }
+ else
+ {
+ is.stackSize-=is1.getAmount()*multiplier;
+ }
+ if(is.stackSize<=0)
+ {
+ this.put(i, null);
+ }
+ break;
+ }
+ }
+ }
+ return output;
+ }
+
+ public int getAmountOf(ItemStack rubber)
+ {
+ int amount = 0;
+ for(int i=0;i<this.size();i++)
+ {
+ ItemStack is = this.get(i);
+ if(is!=null && ((is.getItem() == rubber.getItem() && is.getItemDamage() == rubber.getItemDamage())||IHLUtils.isItemsHaveSameOreDictionaryEntry(is, rubber)))
+ {
+ amount+=is.stackSize;
+ }
+ }
+ return amount;
+ }
+
+ public int getMultiplier(List<IRecipeInput> materials)
+ {
+ int m = Integer.MAX_VALUE;
+ for(int i=0;i<this.size();i++)
+ {
+ ItemStack is = this.get(i);
+ for(IRecipeInput recipeInput:materials)
+ {
+ if(is!=null && recipeInput.matches(is))
+ {
+ m = Math.min(m, Math.max(IHLUtils.getAmountOf(is)/recipeInput.getAmount(),1));
+ }
+ }
+ }
+ return m;
+ }
+}
diff --git a/src/main/java/ihl/flexible_cable/InvSlotTool.java b/src/main/java/ihl/flexible_cable/InvSlotTool.java new file mode 100644 index 0000000..0d5119e --- /dev/null +++ b/src/main/java/ihl/flexible_cable/InvSlotTool.java @@ -0,0 +1,69 @@ +package ihl.flexible_cable;
+
+import java.util.Iterator;
+import java.util.List;
+
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.IC2;
+import ihl.recipes.IronWorkbenchRecipe;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+
+public class InvSlotTool extends IronWorkbenchInvSlot {
+
+ public InvSlotTool(IronWorkbenchTileEntity base1, String name1, int oldStartIndex1, Access access1, int count) {
+ super(base1, name1, oldStartIndex1, access1, count);
+ // TODO Auto-generated constructor stub
+ }
+
+ public void damage(List<IRecipeInput> tools) {
+ if (tools != null && !tools.isEmpty()) {
+ for (int i = 0; i < this.size(); i++) {
+ ItemStack is = this.get(i);
+ Iterator<IRecipeInput> i1 = tools.iterator();
+ while (i1.hasNext()) {
+ IRecipeInput is1 = i1.next();
+ if (is != null && (is1.matches(is))) {
+ if (!is.attemptDamageItem(1, IC2.random)) {
+ if (is.stackTagCompound != null && is.stackTagCompound.hasKey("GT.ToolStats")) {
+ IHLUtils.damageItemViaNBTTag(is, 1);
+ }
+ }
+ if (is.stackSize <= 0) {
+ this.put(i, null);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void put(int index, ItemStack content) {
+ super.put(index, content);
+ if (IC2.platform.isSimulating() && ((IronWorkbenchTileEntity) this.base).container != null) {
+ ((IronWorkbenchTileEntity) this.base).resetOutput();
+ ((IronWorkbenchTileEntity) this.base).container.detectAndSendChanges();
+ }
+ }
+
+ @Override
+ public boolean accepts(ItemStack itemStack) {
+ for (IronWorkbenchRecipe recipe : IronWorkbenchTileEntity.recipes) {
+ if (recipe.isTool(itemStack)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean contain(ItemStack is1) {
+ for (int i = 0; i < this.size(); i++) {
+ ItemStack is = this.get(i);
+ if (is != null && (is.getItem() == is1.getItem() || IHLUtils.isItemsHaveSameOreDictionaryEntry(is, is1))) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/ihl/flexible_cable/InvSlotWorkspaceElement.java b/src/main/java/ihl/flexible_cable/InvSlotWorkspaceElement.java new file mode 100644 index 0000000..b9e65b2 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/InvSlotWorkspaceElement.java @@ -0,0 +1,184 @@ +package ihl.flexible_cable;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import ihl.interfaces.IWorkspaceElement;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+
+public class InvSlotWorkspaceElement extends IronWorkbenchInvSlot {
+
+ private final IWorkspaceElement[] workspaceElements;
+ public final boolean[] ready;
+
+ public InvSlotWorkspaceElement(IronWorkbenchTileEntity base1, String name1, int oldStartIndex1, Access access1, int count)
+ {
+ super(base1, name1, oldStartIndex1, access1, count);
+ this.put(0, IHLUtils.getThisModItemStack("ironWorkbench"));
+ workspaceElements=new IWorkspaceElement[count];
+ ready=new boolean[count];
+ }
+
+ @Override
+ public boolean accepts(ItemStack itemStack)
+ {
+ return false;
+ }
+
+ @Override
+ public boolean getCanTakeStack()
+ {
+ return false;
+ }
+
+ public boolean containsAndCanUse(List<ItemStack> workspaceElements2)
+ {
+ Iterator<ItemStack> iterator = workspaceElements2.iterator();
+ while(iterator.hasNext())
+ {
+ ItemStack rWorkspaceElementItemStack = iterator.next();
+ boolean presence=false;
+ for(int i=1;i<workspaceElements.length;i++)
+ {
+ IWorkspaceElement cWorkspaceElement=workspaceElements[i];
+ if(cWorkspaceElement!=null && rWorkspaceElementItemStack.getItem() == cWorkspaceElement.getWrenchDrop(null).getItem() && cWorkspaceElement.canBeUsed())
+ {
+ presence=true;
+ break;
+ }
+ }
+ //System.out.println("Checking " + rWorkspaceElementItemStack.getDisplayName());
+ if(!presence)
+ {
+ //System.out.println("Return false");
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public void use(List<ItemStack> workspaceElements2)
+ {
+ Iterator<ItemStack> iterator = workspaceElements2.iterator();
+ while(iterator.hasNext())
+ {
+ ItemStack rWorkspaceElementItemStack = iterator.next();
+ for(int i=1;i<workspaceElements.length;i++)
+ {
+ IWorkspaceElement cWorkspaceElement=workspaceElements[i];
+ if(cWorkspaceElement==null)
+ {
+ continue;
+ }
+ if(rWorkspaceElementItemStack.getItem() == cWorkspaceElement.getWrenchDrop(null).getItem() && cWorkspaceElement.canBeUsed())
+ {
+ cWorkspaceElement.use();
+ break;
+ }
+ }
+ }
+ }
+
+ public void reset()
+ {
+ for(int i=1;i<workspaceElements.length;i++)
+ {
+ workspaceElements[i]=null;
+ ready[i]=true;
+ this.put(i,null);
+ }
+ for(int i=1;i<workspaceElements.length;i++)
+ {
+ boolean clear=true;
+ //int[] xz = new int [] {0,1,1,0,-1,-1,1,-1,0};
+ // -1:1; 0:1; 1:1
+ // -1:0; 0:0; 1:0
+ // -1:-1; 0:-1; 1;-1
+ // 0 1 -1 -1 1 1 0 -1 0
+ for(int iy=-1;iy<=1;iy++)
+ {
+ for(int ix=-2;ix<=2;ix++)
+ {
+ for(int iz=-2;iz<=2;iz++)
+ {
+ TileEntity te = this.base.getWorldObj().getTileEntity(this.base.xCoord+ix, this.base.yCoord+iy, this.base.zCoord+iz);
+ if(te instanceof IWorkspaceElement)
+ {
+ IWorkspaceElement wse = (IWorkspaceElement)te;
+ if(!wse.getIsInvalid() && !this.contains(wse))
+ {
+ workspaceElements[i]=wse;
+ ready[i]=wse.canBeUsed();
+ this.put(i,wse.getWrenchDrop(null));
+ clear=false;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if(clear)
+ {
+ workspaceElements[i]=null;
+ this.put(i,null);
+ }
+ }
+ }
+
+ @Override
+ public void writeToNbt(NBTTagCompound nbtTagCompound){}
+
+ @Override
+ public void readFromNbt(NBTTagCompound nbtTagCompound){}
+
+ private boolean contains(IWorkspaceElement wse)
+ {
+ for(int i=0;i<workspaceElements.length;i++)
+ {
+ if(workspaceElements[i]!=null && workspaceElements[i].getWrenchDrop(null).getItem() == wse.getWrenchDrop(null).getItem())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public short encodeReadyStatus()
+ {
+ short result=0;
+ for(int i=0;i<ready.length;i++)
+ {
+ if(ready[i])
+ {
+ result+= 1 << i;
+ }
+ }
+ //System.out.println("Encoding result = "+ result);
+ return result;
+ }
+
+ public void decodeReadyStatus(short encodedShort)
+ {
+ for(int i=0;i<ready.length;i++)
+ {
+ ready[i]=((encodedShort >> i) & 1)==1;
+ //System.out.println("Decoding result = "+ ready[i]);
+ }
+ }
+
+ @Override
+ public List<ItemStack> getItemStackList()
+ {
+ List<ItemStack> list = new ArrayList<ItemStack>();
+ for(int i=1; i<this.size(); i++)
+ {
+ if(get(i)!=null)list.add(get(i));
+ }
+ return list;
+ }
+
+}
diff --git a/src/main/java/ihl/flexible_cable/IronWorkbenchContainer.java b/src/main/java/ihl/flexible_cable/IronWorkbenchContainer.java new file mode 100644 index 0000000..ede2194 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/IronWorkbenchContainer.java @@ -0,0 +1,131 @@ +package ihl.flexible_cable;
+
+import ic2.core.ContainerBase;
+import ihl.processing.invslots.SlotInvSlotIronWorkbench;
+import ihl.processing.invslots.SlotInvSlotOutputInProgress;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class IronWorkbenchContainer extends ContainerBase<IronWorkbenchTileEntity> {
+
+ protected IronWorkbenchTileEntity tileEntity;
+ private int lastProgress1 = -1;
+ private int conrolSum = -1;
+ private int currentSlot1 = -1;
+ private short workspaceReadyStatus1 = -1;
+ private static final short slotUpdateOffset=4;
+ public final static int height=202;//166
+
+ public IronWorkbenchContainer(EntityPlayer entityPlayer, IronWorkbenchTileEntity tileEntity1){
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ int col, row;
+
+ 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));
+ }
+ for(row=0;row<6;row++)
+ {
+ for(col=0;col<=1;col++)
+ {
+ this.addSlotToContainer(new SlotInvSlotIronWorkbench(tileEntity1.tools, row+col*6, 26+col*18, 8+row*18));
+ }
+ }
+ for(row=0;row<6;row++)
+ {
+ for(col=0;col<=1;col++)
+ {
+ this.addSlotToContainer(new SlotInvSlotIronWorkbench(tileEntity1.inputMaterial, row+col*6, 65+col*18, 8+row*18));
+ }
+ }
+ for (row = 0; row<6; ++row)
+ {
+ this.addSlotToContainer(new SlotInvSlotOutputInProgress(tileEntity1.workspaceElements, row, 8, 8+row*18));
+ }
+ for(row=0;row<6;row++)
+ {
+ for (col = 0; col<3; ++col)
+ {
+ this.addSlotToContainer(new SlotInvSlotOutputInProgress(tileEntity1.output, col+row*3, 116+col*18, 8+row*18));
+ }
+ }
+
+ }
+
+ @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.progress != this.lastProgress1)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+
+ }
+ if (this.tileEntity.currentSlot != this.currentSlot1)
+ {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.currentSlot);
+
+ }
+ if(this.tileEntity.workspaceElements.encodeReadyStatus()!=this.workspaceReadyStatus1)
+ {
+ icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.workspaceElements.encodeReadyStatus());
+ }
+ if(this.tileEntity.output.getCheckSum()!=this.conrolSum)
+ {
+ for(int i1 = 0; i1<this.tileEntity.output.size();i1++)
+ {
+ icrafting.sendProgressBarUpdate(this, i1+slotUpdateOffset, this.tileEntity.output.slotRecipe[i1]);
+ }
+ }
+
+ }
+ this.currentSlot1=this.tileEntity.currentSlot;
+ this.conrolSum=this.tileEntity.output.getCheckSum();
+ this.lastProgress1 = this.tileEntity.progress;
+ this.workspaceReadyStatus1=this.tileEntity.workspaceElements.encodeReadyStatus();
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value)
+ {
+ super.updateProgressBar(index, value);
+ if(index>=slotUpdateOffset)
+ {
+ this.tileEntity.output.slotRecipe[index-slotUpdateOffset]=(short) value;
+ }
+ switch (index)
+ {
+ case 0:
+ this.tileEntity.progress=value;
+ break;
+ case 1:
+ this.tileEntity.currentSlot=value;
+ break;
+ case 2:
+ this.tileEntity.workspaceElements.decodeReadyStatus((short) value);
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+
+ /**
+ * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
+ */
+}
diff --git a/src/main/java/ihl/flexible_cable/IronWorkbenchGui.java b/src/main/java/ihl/flexible_cable/IronWorkbenchGui.java new file mode 100644 index 0000000..c395484 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/IronWorkbenchGui.java @@ -0,0 +1,185 @@ +package ihl.flexible_cable;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.IC2;
+import ihl.interfaces.IItemHasMiniGUI;
+import ihl.interfaces.ItemMiniGUI;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class IronWorkbenchGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIIronWorkbench.png");
+ private IronWorkbenchContainer container;
+ private ItemMiniGUI miniGui;
+ private static final short outputslotoffset=66;
+
+ public IronWorkbenchGui (IronWorkbenchContainer container1) {
+ super(container1);
+ this.container=container1;
+ this.ySize=IronWorkbenchContainer.height;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2)
+ {
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ for(int row = 1;row<6;row++)
+ {
+ if(!this.container.tileEntity.workspaceElements.ready[row] && this.container.tileEntity.workspaceElements.get(row)!=null)
+ {
+ IHLRenderUtils.instance.drawWorkspaceElementTooltip(par1, par2, 8+x, 8+y+row*18, this.container.tileEntity.workspaceElements.get(row));
+ }
+ }
+ if(miniGui!=null)
+ {
+ miniGui.displayGUI();
+ }
+ }
+
+ @Override
+ protected void keyTyped(char characterTyped, int keyIndex)
+ {
+ super.keyTyped(characterTyped, keyIndex);
+ if(miniGui!=null && miniGui.handleKeyTyped(characterTyped, keyIndex))
+ {
+ miniGui.onGUIClosed();
+ miniGui=null;
+ }
+ }
+
+ @Override
+ protected void mouseClicked(int mouseX, int mouseY, int mouseButton)
+ {
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ if(miniGui==null || !miniGui.handleMouseClick(mouseX-x, mouseY-y, mouseButton))
+ {
+ if(miniGui!=null)
+ {
+ miniGui.onGUIClosed();
+ miniGui=null;
+ }
+ super.mouseClicked(mouseX, mouseY, mouseButton);
+ }
+ }
+
+ @Override
+ protected void mouseMovedOrUp(int mouseX, int mouseY, int mouseButton)
+ {
+ super.mouseMovedOrUp(mouseX, mouseY, mouseButton);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ if(miniGui!=null)
+ {
+ miniGui.handleMouseClick(mouseX-x, mouseY-y, mouseButton);
+ }
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float par1, int par2,
+ int par3) {
+ 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);
+ if (this.container.tileEntity.progress > 0)
+ {
+ int frameNum=0;
+ short slotRecipeNum=this.container.tileEntity.output.slotRecipe[0];
+ for(int row = 0;row<6;row++)
+ {
+ for (int col = 0; col<3; ++col)
+ {
+ if(slotRecipeNum!=this.container.tileEntity.output.slotRecipe[col+row*3])
+ {
+ frameNum++;
+ slotRecipeNum=this.container.tileEntity.output.slotRecipe[col+row*3];
+ }
+ if(this.container.tileEntity.currentSlot==slotRecipeNum)
+ {
+ int i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18);
+ this.drawTexturedModalRect(115+x+col*18, 7+y+row*18, 176, 72,i1,18);
+ this.drawTexturedModalRect(115+x+col*18, 7+y+row*18, 176+getFrameX(frameNum), getFrameY(frameNum),18,18);
+ }
+ }
+ }
+ }
+ else
+ {
+ int frameNum=0;
+ short slotRecipeNum=this.container.tileEntity.output.slotRecipe[0];
+ for(int row = 0;row<6;row++)
+ {
+ for (int col = 0;col<3; ++col)
+ {
+ if(slotRecipeNum!=this.container.tileEntity.output.slotRecipe[col+row*3])
+ {
+ frameNum++;
+ slotRecipeNum=this.container.tileEntity.output.slotRecipe[col+row*3];
+ }
+ if(this.container.tileEntity.output.get(col+row*3)!=null)
+ {
+ this.drawTexturedModalRect(115+x+col*18, 7+y+row*18, 176+getFrameX(frameNum), getFrameY(frameNum),18,18);
+ }
+ }
+ }
+ }
+ for(int row = 1;row<6;row++)
+ {
+ if(!this.container.tileEntity.workspaceElements.ready[row])
+ {
+ this.drawTexturedModalRect(20+x, 9+y+row*18, 194, 74,3,14);
+ }
+ }
+ }
+
+ @Override
+ public void onGuiClosed()
+ {
+ super.onGuiClosed();
+ this.container.tileEntity.isGuiScreenOpened=false;
+ IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 16);
+ }
+
+ @Override
+ public void handleMouseClick(Slot slot,int slotNumber,int mouseButton/*0=left 1=right*/,int arg3)
+ {
+ if(miniGui==null && slot!=null && slot.slotNumber>=outputslotoffset && slot.slotNumber<outputslotoffset+18)
+ {
+ if(mouseButton==0)
+ {
+ IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, slot.slotNumber-outputslotoffset);
+ }
+ else if(mouseButton==1)
+ {
+ if(slot.getHasStack() && slot.getStack().getItem() instanceof IItemHasMiniGUI)
+ {
+ if(miniGui!=null)
+ {
+ miniGui.onGUIClosed();
+ }
+ miniGui = ((IItemHasMiniGUI)slot.getStack().getItem()).getMiniGUI(this, slot);
+ }
+ }
+ }
+ super.handleMouseClick(slot, slotNumber, mouseButton, arg3);
+ }
+
+ private int getFrameX(int number)
+ {
+ return (number % 4) * 18;
+ }
+ private int getFrameY(int number)
+ {
+ return ((number>>2) & 3)*18;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/flexible_cable/IronWorkbenchInvSlot.java b/src/main/java/ihl/flexible_cable/IronWorkbenchInvSlot.java new file mode 100644 index 0000000..33821da --- /dev/null +++ b/src/main/java/ihl/flexible_cable/IronWorkbenchInvSlot.java @@ -0,0 +1,30 @@ +package ihl.flexible_cable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.core.block.invslot.InvSlot;
+import net.minecraft.item.ItemStack;
+
+public class IronWorkbenchInvSlot extends InvSlot {
+
+ public IronWorkbenchInvSlot(IronWorkbenchTileEntity base1, String name1,
+ int oldStartIndex1, Access access1, int count) {
+ super(base1, name1, oldStartIndex1, access1, count);
+ }
+
+ public List<ItemStack> getItemStackList()
+ {
+ List<ItemStack> list = new ArrayList<ItemStack>();
+ for(int i=0; i<this.size(); i++)
+ {
+ if(get(i)!=null)list.add(get(i));
+ }
+ return list;
+ }
+
+ public boolean getCanTakeStack()
+ {
+ return true;
+ }
+}
diff --git a/src/main/java/ihl/flexible_cable/IronWorkbenchModel.java b/src/main/java/ihl/flexible_cable/IronWorkbenchModel.java new file mode 100644 index 0000000..1039692 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/IronWorkbenchModel.java @@ -0,0 +1,48 @@ +package ihl.flexible_cable;
+
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.model.ModelRenderer;
+
+public class IronWorkbenchModel extends ModelBase {
+ //fields
+ ModelRenderer Base;
+
+ public IronWorkbenchModel()
+ {
+ textureWidth = 64;
+ textureHeight = 32;
+ setTextureOffset("Base.Shape1", 20, 0);
+ setTextureOffset("Base.Shape2", 20, 0);
+ setTextureOffset("Base.Shape3", 23, 0);
+ setTextureOffset("Base.Shape4", 23, 0);
+ setTextureOffset("Base.Shape5", 0, 0);
+ setTextureOffset("Base.Shape6", 16, 0);
+ setTextureOffset("Base.Shape7", 1, 21);
+ setTextureOffset("Base.Shape8", 0, 17);
+ setTextureOffset("Base.Shape9", 0, 0);
+ setTextureOffset("Base.Shape10", 0, 0);
+ setTextureOffset("Base.Shape11", 0, 0);
+ setTextureOffset("Base.Shape12", 0, 0);
+ setTextureOffset("Base.Shape13", 0, 0);
+ setTextureOffset("Base.Shape14", 0, 0);
+
+ Base = new ModelRenderer(this, "Base");
+ Base.setRotationPoint(0F, 8F, 0F);
+ Base.mirror = true;
+ Base.addBox("Shape1", 5F, 1F, -7F, 2, 15, 2);
+ Base.addBox("Shape2", 5F, 1F, 5F, 2, 15, 2);
+ Base.addBox("Shape3", -7F, 1F, -7F, 2, 15, 2);
+ Base.addBox("Shape4", -7F, 1F, 5F, 2, 15, 2);
+ Base.addBox("Shape5", -8F, 0F, -8F, 16, 1, 16);
+ Base.addBox("Shape6", -6F, 10F, -6F, 12, 1, 12);
+ Base.addBox("Shape7", 5F, 2F, -8F, 2, 2, 1);
+ Base.addBox("Shape8", -1F, -7F, 4F, 8, 1, 3);
+ Base.addBox("Shape9", 5F, -1F, 4F, 3, 1, 3);
+ Base.addBox("Shape10", 7F, -7F, 5F, 1, 6, 1);
+ Base.addBox("Shape11", -5F, 1F, -6F, 10, 2, 1);
+ Base.addBox("Shape12", -5F, 1F, 5F, 10, 2, 1);
+ Base.addBox("Shape13", 5F, 1F, -5F, 1, 2, 10);
+ Base.addBox("Shape14", -6F, 1F, -5F, 1, 2, 10);
+ }
+
+}
diff --git a/src/main/java/ihl/flexible_cable/IronWorkbenchRender.java b/src/main/java/ihl/flexible_cable/IronWorkbenchRender.java new file mode 100644 index 0000000..27b3835 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/IronWorkbenchRender.java @@ -0,0 +1,36 @@ +package ihl.flexible_cable;
+import org.lwjgl.opengl.GL11;
+
+import ihl.utils.IHLItemRenderer;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+
+public class IronWorkbenchRender extends TileEntitySpecialRenderer{
+private IHLItemRenderer itemRenderer=new IHLItemRenderer(true);
+
+public IronWorkbenchRender(){}
+
+public void renderAModelAt(IronWorkbenchTileEntity tile, double x, double y, double z, float f) {
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float)x + 0.5F, (float)y+0.5F, (float)z + 0.5F);
+ GL11.glRotatef(90f, 1F, 0F, 0F);
+ int index = 0;
+ for (int i = 0; i < tile.tools.size() && index < 8; i++) {
+ if (tile.tools.get(i)!=null) {
+ float iy = index >= 4 ? -0.5f : 0f;
+ float ix = (index % 2) * 0.4f-0.2f;
+ float iz = (index / 2) * 0.4f-0.2f + iy * 1.5f;
+ this.itemRenderer.doRender(RenderManager.instance,tile.tools.get(i),ix,iz,iy-0.002f*index);
+ index++;
+ }
+ }
+ GL11.glPopMatrix();
+}
+
+ @Override
+ public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
+ {
+ this.renderAModelAt((IronWorkbenchTileEntity)par1TileEntity, par2, par4, par6, par8);
+ }
+}
diff --git a/src/main/java/ihl/flexible_cable/IronWorkbenchTileEntity.java b/src/main/java/ihl/flexible_cable/IronWorkbenchTileEntity.java new file mode 100644 index 0000000..30f6fda --- /dev/null +++ b/src/main/java/ihl/flexible_cable/IronWorkbenchTileEntity.java @@ -0,0 +1,351 @@ +package ihl.flexible_cable;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.network.INetworkClientTileEntityEventListener;
+import ic2.api.network.INetworkTileEntityEventListener;
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.ContainerBase;
+import ic2.core.IHasGui;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot.Access;
+import ihl.IHLMod;
+import ihl.interfaces.IWire;
+import ihl.recipes.IronWorkbenchRecipe;
+import ihl.recipes.RecipeInputDetonator;
+import ihl.recipes.RecipeInputDie;
+import ihl.recipes.RecipeInputObjectInstance;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+
+public class IronWorkbenchTileEntity extends TileEntityInventory
+ implements IHasGui, INetworkClientTileEntityEventListener, INetworkTileEntityEventListener {
+
+ public static List<IronWorkbenchRecipe> recipes = new ArrayList<IronWorkbenchRecipe>();
+ public int progress;
+ public int currentSlot = -1;
+ public final int maxProgress;
+ public final InvSlotTool tools;
+ public final InvSlotWorkspaceElement workspaceElements;
+ public final InvSlotProcessableIronWorkbench inputMaterial;
+ public final InvSlotOutputInProgress output;
+ public boolean isGuiScreenOpened = false;
+ private boolean startProcess = false;
+ private boolean outputDefined = false;
+ private EntityPlayer crafter;
+ public ContainerBase<?> container;
+ private Map<Integer, IronWorkbenchRecipe> slotRecipeMap = new HashMap<Integer, IronWorkbenchRecipe>();
+ private boolean firstTick = true;
+
+ public IronWorkbenchTileEntity() {
+ this.maxProgress = 80;
+ this.workspaceElements = new InvSlotWorkspaceElement(this, "workspaceElements", 3, Access.NONE, 6);
+ this.tools = new InvSlotTool(this, "tools", 0, Access.IO, 12);
+ this.inputMaterial = new InvSlotProcessableIronWorkbench(this, "input", 1, Access.IO, 12);
+ this.output = new InvSlotOutputInProgress(this, "output", 2, 18);
+ }
+
+ public static void addRecipe(IronWorkbenchRecipe recipe) {
+ IronWorkbenchTileEntity.recipes.add(recipe);
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "ironWorkbench";
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player) {
+ return IHLUtils.getThisModItemStack("ironWorkbench");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void updateEntityClient() {
+ if (firstTick) {
+ IHLMod.proxy.requestTileEntityInitdataFromClientToServer(xCoord, yCoord, zCoord);
+ this.firstTick = false;
+ }
+ }
+
+ @Override
+ public void updateEntityServer() {
+ if (this.isGuiScreenOpened) {
+ if (this.output.isEmpty() && !outputDefined) {
+ this.workspaceElements.reset();
+ Iterator<IronWorkbenchRecipe> iwri = IronWorkbenchTileEntity.recipes.iterator();
+ while (iwri.hasNext()) {
+ IronWorkbenchRecipe recipe = iwri.next();
+ if (recipe.isCanBeCrafted(this.tools.getItemStackList(), this.inputMaterial.getItemStackList(),
+ this.workspaceElements.getItemStackList())) {
+ if (recipe.workspaceElements == null || recipe.workspaceElements.isEmpty()
+ || this.workspaceElements.containsAndCanUse(recipe.workspaceElements)) {
+ List<ItemStack> newOutputs = recipe.outputs;
+ for (IRecipeInput rinput : recipe.tools) {
+ if (rinput instanceof RecipeInputDie) {
+ newOutputs = ((RecipeInputDie) rinput)
+ .transformOutput(this.getMatchedItemStack(rinput), recipe.outputs);
+ }
+ }
+ for (IRecipeInput rinput : recipe.materials) {
+ if (rinput instanceof RecipeInputDetonator) {
+ newOutputs = ((RecipeInputDetonator) rinput)
+ .transformOutput(this.getMatchedItemStack(rinput), recipe.outputs);
+ }
+ }
+ int slot = this.output.put(newOutputs);
+ if (slot < 0)
+ break;
+ slotRecipeMap.put(slot, recipe);
+ this.startProcess = false;
+ }
+ }
+ }
+ for (int i = 0; i < this.inputMaterial.size(); i++) {
+ ItemStack stack = this.inputMaterial.get(i);
+ if (stack != null && stack.getItem() instanceof IWire) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
+ }
+ int fullLength = this.getFullLengthOfSameWires(stack);
+ List<RecipeInputObjectInstance> list = this.getListOfSameWires(stack);
+ ItemStack result = stack.copy();
+ result.stackTagCompound.setInteger("length", fullLength);
+ result.stackTagCompound.setInteger("fullLength", fullLength);
+ IronWorkbenchRecipe recipe = new IronWorkbenchRecipe(null, list,
+ Arrays.asList(new ItemStack[] { result }));
+ int slot = this.output.put(recipe.outputs);
+ if (slot < 0)
+ break;
+ slotRecipeMap.put(slot, recipe);
+ this.startProcess = false;
+ break;
+ }
+ }
+ outputDefined = true;
+ } else if (!this.output.isEmpty()) {
+ Set<Integer> crafterEmptyInventorySlotsList = getCrafterEmptyInventorySlotsList();
+ if (startProcess && crafterEmptyInventorySlotsList.size() >= this.slotRecipeMap.get(currentSlot).outputs
+ .size()) {
+ if (++this.progress >= this.maxProgress) {
+ IronWorkbenchRecipe crecipe = this.slotRecipeMap.get(currentSlot);
+ List<ItemStack> opts = this.output.getRecipeOutputs(currentSlot);
+ int multiplier = this.inputMaterial.getMultiplier(crecipe.materials);
+ Iterator<ItemStack> optsi = opts.iterator();
+ Iterator<Integer> emptySlotsIterator = crafterEmptyInventorySlotsList.iterator();
+ while (optsi.hasNext()) {
+ int slot = emptySlotsIterator.next();
+ ItemStack stack = optsi.next();
+ if (stack.getItem() instanceof IWire) {
+ this.crafter.inventory.mainInventory[slot] = IHLUtils
+ .getWireItemStackCopyWithLengthMultiplied(stack, multiplier);
+ } else {
+ this.crafter.inventory.mainInventory[slot] = stack.copy();
+ this.crafter.inventory.mainInventory[slot].stackSize *= multiplier;
+ }
+ }
+ Iterator<ItemStack> emptyContainers = this.inputMaterial
+ .substract(crecipe.materials, multiplier).iterator();
+ while (emptyContainers.hasNext()) {
+ if (emptySlotsIterator.hasNext()) {
+ int slot = emptySlotsIterator.next();
+ ItemStack stack = emptyContainers.next();
+ this.crafter.inventory.mainInventory[slot] = stack.copy();
+ this.crafter.inventory.mainInventory[slot].stackSize *= multiplier;
+ } else {
+ EntityItem eistack = new EntityItem(this.worldObj, this.xCoord, this.yCoord + 1,
+ this.zCoord, emptyContainers.next());
+ this.worldObj.spawnEntityInWorld(eistack);
+ }
+ }
+ this.crafter.inventoryContainer.detectAndSendChanges();
+ this.tools.damage(crecipe.tools);
+ if (!crecipe.workspaceElements.isEmpty()) {
+ this.workspaceElements.use(crecipe.workspaceElements);
+ }
+ this.resetOutput();
+ }
+ }
+ }
+ }
+ }
+
+ private ItemStack getMatchedItemStack(IRecipeInput rinput) {
+ for (ItemStack tool : this.tools.getItemStackList()) {
+ if (rinput.matches(tool)) {
+ return tool;
+ }
+ }
+ for (ItemStack material : this.inputMaterial.getItemStackList()) {
+ if (rinput.matches(material)) {
+ return material;
+ }
+ }
+
+ return null;
+ }
+
+ private Set<Integer> getCrafterEmptyInventorySlotsList() {
+ Set<Integer> list = new HashSet<Integer>(4);
+ if (this.crafter != null) {
+ for (int var1 = 0; var1 < this.crafter.inventory.mainInventory.length; ++var1) {
+ if (this.crafter.inventory.mainInventory[var1] == null) {
+ list.add(var1);
+ }
+ }
+ }
+ return list;
+ }
+
+ private List<RecipeInputObjectInstance> getListOfSameWires(ItemStack stack1) {
+ List<RecipeInputObjectInstance> list = new ArrayList<RecipeInputObjectInstance>();
+ for (int i = 0; i < this.inputMaterial.size(); i++) {
+ ItemStack stack = this.inputMaterial.get(i);
+ if (stack != null && ((IWire) stack1.getItem()).isSameWire(stack1, stack)) {
+ list.add(new RecipeInputObjectInstance(stack));
+ }
+ }
+ return list;
+ }
+
+ private int getFullLengthOfSameWires(ItemStack stack1) {
+ int fullLength = 0;
+ for (int i = 0; i < this.inputMaterial.size(); i++) {
+ ItemStack stack = this.inputMaterial.get(i);
+ if (stack != null && ((IWire) stack1.getItem()).isSameWire(stack1, stack)) {
+ fullLength += IHLUtils.getWireLength(stack);
+ }
+ }
+ return fullLength;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new IronWorkbenchGui(new IronWorkbenchContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ resetOutput();
+ this.isGuiScreenOpened = true;
+ this.crafter = player;
+ container = new IronWorkbenchContainer(player, this);
+ return container;
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {
+ this.isGuiScreenOpened = false;
+ }
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event) {
+ if (event == 16) {
+ this.isGuiScreenOpened = false;
+ this.crafter = null;
+ this.container = null;
+ return;
+ }
+ for (int i = event; i >= 0; i--) {
+ if (this.slotRecipeMap.containsKey(i)) {
+ if (!this.slotRecipeMap.get(i).isCanBeCrafted(this.tools.getItemStackList(),
+ this.inputMaterial.getItemStackList(), this.workspaceElements.getItemStackList())) {
+ resetOutput();
+ } else {
+ this.currentSlot = i;
+ this.startProcess = true;
+ return;
+ }
+ }
+ }
+ }
+
+ public void resetOutput() {
+ this.output.clear();
+ this.slotRecipeMap.clear();
+ this.progress = 0;
+ this.startProcess = false;
+ this.currentSlot = -1;
+ this.outputDefined = false;
+ }
+
+ public void dropContents() {
+ for (int i = 0; i < this.tools.size(); i++) {
+ if (this.tools.get(i) != null)
+ this.worldObj.spawnEntityInWorld(
+ new EntityItem(this.worldObj, this.xCoord, this.yCoord + 1, this.zCoord, this.tools.get(i)));
+ }
+ for (int i = 0; i < this.inputMaterial.size(); i++) {
+ if (this.inputMaterial.get(i) != null)
+ this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord + 1,
+ this.zCoord, this.inputMaterial.get(i)));
+ }
+ }
+
+ @Override
+ public void onNetworkEvent(int event) {
+
+ }
+
+ public int gaugeProgressScaled(int i) {
+ return this.progress * i / this.maxProgress;
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass) {
+ return pass == 0;
+ }
+
+ public static void removeRecipeByOutput(List<ItemStack> recipeOutputsItems) {
+ Iterator<IronWorkbenchRecipe> ri = recipes.iterator();
+ while (ri.hasNext()) {
+ IronWorkbenchRecipe recipe = ri.next();
+ boolean removeEntry = false;
+ Iterator<ItemStack> roi = recipe.outputs.iterator();
+ while (roi.hasNext()) {
+ if (IHLUtils.isItemStacksIsEqual(recipeOutputsItems.get(0), roi.next(), true)) {
+ removeEntry = true;
+ }
+ }
+ if (removeEntry) {
+ ri.remove();
+ }
+ }
+
+ }
+
+ public static void removeRecipeByInput(List<IRecipeInput> recipeInputsTools1, List<IRecipeInput> recipeInputsItems1,
+ List<ItemStack> recipeInputsMachines) {
+ List<ItemStack> recipeInputsTools = IHLUtils.convertRecipeInputToItemStackList(recipeInputsTools1);
+ List<ItemStack> recipeInputsItems = IHLUtils.convertRecipeInputToItemStackList(recipeInputsItems1);
+ Iterator<IronWorkbenchRecipe> ri = recipes.iterator();
+ while (ri.hasNext()) {
+ IronWorkbenchRecipe recipe = ri.next();
+ if (recipe.isCanBeCrafted(recipeInputsTools, recipeInputsItems, recipeInputsMachines)) {
+ ri.remove();
+ }
+ }
+ }
+
+ @Override
+ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
+ this.readFromNBT(pkt.func_148857_g());
+ }
+
+}
diff --git a/src/main/java/ihl/flexible_cable/NodeEntity.java b/src/main/java/ihl/flexible_cable/NodeEntity.java new file mode 100644 index 0000000..b734cd1 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/NodeEntity.java @@ -0,0 +1,604 @@ +package ihl.flexible_cable;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import cpw.mods.fml.common.network.internal.FMLProxyPacket;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import ihl.interfaces.ICableHolder;
+import ihl.interfaces.IMultiPowerCableHolder;
+import ihl.interfaces.INetworkListener;
+import ihl.items_blocks.FlexibleCableItem;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufInputStream;
+import io.netty.buffer.ByteBufOutputStream;
+import io.netty.buffer.Unpooled;
+import net.minecraft.block.Block;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.World;
+import net.minecraft.world.WorldServer;
+
+public class NodeEntity extends Entity implements INetworkListener{
+
+ public NodeEntity prevAnchorEntity;
+ public Entity nextAnchorEntity;
+ private int anchorX;
+ private int anchorY;
+ private int anchorZ;
+ private short anchorFacing;
+ private int anchorDimensionId;
+ public boolean shouldFollowPlayer=false;
+ protected int chainUniqueID=-2;
+ public int chainArrangeNumber=-2;
+ protected int checkTimer=201;
+ public int colorIndex=16777215;
+ public int renderEvery=1;
+ public int type=1;//0 - uninsulated wire; 1 - insulated cable; 2 - data cable
+ public float dx0=0;
+ public float dy0=0;
+ public float dz0=0;
+ public final int n=48;
+ public final float[] rotationPitchArray = new float[n+1];
+ public final float[] rotationYawArray = new float[n+1];
+ public final float[] translationX = new float[n+1];
+ public final float[] translationY = new float[n+1];
+ public final float[] translationZ = new float[n+1];
+ public double virtualNodePosX;
+ public double virtualNodePosY;
+ public double virtualNodePosZ;
+ public double renderPosX;
+ public double renderPosY;
+ public double renderPosZ;
+ public double lastTickRenderPosX;
+ public double lastTickRenderPosY;
+ public double lastTickRenderPosZ;
+ private boolean alreadyRegistered=false;
+ private boolean shouldUpdateRender=true;
+
+ public NodeEntity(World world)
+ {
+ super(world);
+ if(world.isRemote)
+ {
+ IHLMod.proxy.addEntityToList(this);
+ this.setSize(2f, 0.2f);
+ }
+ else
+ {
+ IHLMod.proxy.addEntityToServerList(this);
+ this.setSize(0.5F, 0.1F);
+ }
+ this.renderDistanceWeight = 5.0D;
+ this.yOffset+=0.15F;
+ this.virtualNodePosX=this.posX;
+ this.virtualNodePosY=this.posY;
+ this.virtualNodePosZ=this.posZ;
+ this.motionX=0D;
+ this.motionY=0D;
+ this.motionZ=0D;
+ }
+
+ @Override
+ public void setInPortal(){}
+
+ @Override
+ public void travelToDimension(int dimensionId){}
+
+ @Override
+ public void setSize(float width, float heigth)
+ {
+ super.setSize(width, heigth);
+ }
+
+ public void setVirtualNodePos(double d,double e, double f)
+ {
+ virtualNodePosX=d;
+ virtualNodePosY=e;
+ virtualNodePosZ=f;
+ this.registerAndSendData(null);
+ }
+
+ @Override
+ public void registerAndSendData(EntityPlayerMP player)
+ {
+ if(!worldObj.isRemote)
+ {
+ if(!alreadyRegistered)
+ {
+ Set<NodeEntity> nes;
+ if(IHLMod.proxy.nodeEntityRegistry.containsKey(this.getChainUniqueID()))
+ {
+ nes=IHLMod.proxy.nodeEntityRegistry.get(this.getChainUniqueID());
+ }
+ else
+ {
+ nes=new HashSet<NodeEntity>();
+ IHLMod.proxy.nodeEntityRegistry.put(this.getChainUniqueID(),nes);
+ }
+ nes.add(this);
+ alreadyRegistered=true;
+ }
+ ByteBuf bb = Unpooled.buffer(30);
+ ByteBufOutputStream byteBufOutputStream = new ByteBufOutputStream(bb);
+ try
+ {
+ byteBufOutputStream.write(1);
+ byteBufOutputStream.writeInt(this.getEntityId());
+ byteBufOutputStream.writeInt(this.getChainUniqueID());
+ byteBufOutputStream.writeInt(this.chainArrangeNumber);
+ byteBufOutputStream.writeByte(this.type);
+ byteBufOutputStream.writeInt(this.colorIndex);
+ byteBufOutputStream.writeDouble(this.virtualNodePosX);
+ byteBufOutputStream.writeDouble(this.virtualNodePosY);
+ byteBufOutputStream.writeDouble(this.virtualNodePosZ);
+ byteBufOutputStream.writeBoolean(this.shouldFollowPlayer);
+ if(player==null)
+ {
+ IHLMod.proxy.sendFromServerToAll(new FMLProxyPacket(byteBufOutputStream.buffer(), IHLModInfo.MODID));
+ }
+ else
+ {
+ IHLMod.proxy.sendFromServerToPlayer(new FMLProxyPacket(byteBufOutputStream.buffer(), IHLModInfo.MODID),player);
+ }
+ byteBufOutputStream.close();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void onUpdate()
+ {
+ super.onUpdate();
+ if(this.checkTimer==201)
+ {
+ if(worldObj.isRemote)
+ {
+ IHLMod.proxy.recieveDelayedDataPacket(this);
+ }
+ else
+ {
+ this.registerAndSendData(null);
+ }
+ }
+ if(prevAnchorEntity==null||(nextAnchorEntity==null || nextAnchorEntity instanceof EntityPlayer || nextAnchorEntity instanceof EntityItem))
+ {
+ double range = 16D;
+ AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.posX-range,this.posY-range,this.posZ-range,this.posX+range,this.posY+range,this.posZ+range);
+ List<NodeEntity> eItemsList = this.worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea);
+ if(!eItemsList.isEmpty())
+ {
+ Iterator<NodeEntity> ei = eItemsList.iterator();
+ while(ei.hasNext())
+ {
+ NodeEntity node=(NodeEntity) ei.next();
+ if(node.getChainUniqueID()==this.getChainUniqueID())
+ {
+ if(node.chainArrangeNumber==this.chainArrangeNumber-1)
+ {
+ this.prevAnchorEntity=node;
+ node.nextAnchorEntity=this;
+ node.shouldFollowPlayer=false;
+ }
+ else if(node.chainArrangeNumber==this.chainArrangeNumber+1)
+ {
+ this.nextAnchorEntity=node;
+ this.shouldFollowPlayer=false;
+ node.prevAnchorEntity=this;
+ }
+ }
+ if(prevAnchorEntity!=null && nextAnchorEntity!=null)
+ {
+ break;
+ }
+ }
+ }
+ }
+ if(this.shouldFollowPlayer && (this.nextAnchorEntity == null || this.nextAnchorEntity.isDead))
+ {
+ double range = 16D;
+ AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.posX-range,this.posY-range,this.posZ-range,this.posX+range,this.posY+range,this.posZ+range);
+ List<EntityPlayer> eItemsList = this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, searchArea);
+ if(!eItemsList.isEmpty())
+ {
+ Iterator<EntityPlayer> ei = eItemsList.iterator();
+ while(ei.hasNext())
+ {
+ EntityPlayer player=(EntityPlayer) ei.next();
+ if(this.playerHasItemStack(player))
+ {
+ this.nextAnchorEntity=player;
+ }
+
+ }
+ }
+ }
+ if(this.shouldFollowPlayer && this.nextAnchorEntity instanceof EntityPlayer)
+ {
+ EntityPlayer player = (EntityPlayer) this.nextAnchorEntity;
+ if(!this.playerHasItemStack(player))
+ {
+ double range = 16D;
+ AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(this.posX-range,this.posY-range,this.posZ-range,this.posX+range,this.posY+range,this.posZ+range);
+ List<EntityItem> eItemsList = this.worldObj.getEntitiesWithinAABB(EntityItem.class, searchArea);
+ if(!eItemsList.isEmpty())
+ {
+ Iterator<EntityItem> ei = eItemsList.iterator();
+ while(ei.hasNext())
+ {
+ EntityItem eitem = ei.next();
+ if(this.isItemHasSameChainId(eitem.getEntityItem()))
+ {
+ this.nextAnchorEntity=eitem;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if(nextAnchorEntity!=null && this.getDistanceSqToEntity(nextAnchorEntity)>2D)
+ {
+ this.nextAnchorEntity.addVelocity((this.posX-this.nextAnchorEntity.posX)*0.02D, (this.posY-this.nextAnchorEntity.posY)*0.02D, (this.posZ-this.nextAnchorEntity.posZ)*0.02D);
+ }
+ if(!worldObj.isRemote)
+ {
+ double x0,x2,y0,y2,z0,z2;
+ x2=x0=this.virtualNodePosX;
+ y2=y0=this.virtualNodePosY;
+ z2=z0=this.virtualNodePosZ;
+ if(nextAnchorEntity!=null)
+ {
+ x2=nextAnchorEntity.posX;
+ y2=nextAnchorEntity.posY;
+ z2=nextAnchorEntity.posZ;
+ }
+ if(prevAnchorEntity!=null)
+ {
+ x0=prevAnchorEntity.posX;
+ y0=prevAnchorEntity.posY;
+ z0=prevAnchorEntity.posZ;
+ }
+ double d1 = (x0-x2)*(x0-x2)+(y0-y2)*(y0-y2)+(z0-z2)*(z0-z2);
+ if(d1>4D)
+ {
+ this.motionX+=(x0+x2)*0.05D-this.posX*0.1D;
+ this.motionY+=(y0+y2)*0.05D-this.posY*0.1D;
+ this.motionZ+=(z0+z2)*0.05D-this.posZ*0.1D;
+ }
+ else
+ {
+ double d2 = this.getDistanceSq(x2,y2,z2);
+ if(d2>1D)
+ {
+ this.motionX+=(x2-this.posX)*0.01D;
+ this.motionY+=(y2-this.posY)*0.01D;
+ this.motionZ+=(z2-this.posZ)*0.01D;
+ }
+ double d3 = this.getDistanceSq(x0,y0,z0);
+ if(d3>1D)
+ {
+ this.motionX+=(x0-this.posX)*0.01D;
+ this.motionY+=(y0-this.posY)*0.01D;
+ this.motionZ+=(z0-this.posZ)*0.01D;
+ }
+ }
+ this.motionY-=0.005D;
+ this.motionX*=0.8D;
+ this.motionY*=0.8D;
+ this.motionZ*=0.8D;
+ this.moveEntity(this.motionX, this.motionY, this.motionZ);
+ }
+ if(this.onGround)
+ {
+ this.motionY *= -0.5D;
+ }
+ if(worldObj.isRemote)
+ {
+ this.lastTickRenderPosX=this.renderPosX;
+ this.lastTickRenderPosY=this.renderPosY;
+ this.lastTickRenderPosZ=this.renderPosZ;
+ this.renderPosX=(float) this.prevPosX;
+ this.renderPosY=(float) this.prevPosY;
+ this.renderPosZ=(float) this.prevPosZ;
+ shouldUpdateRender=
+ Math.abs(this.lastTickRenderPosX-this.renderPosX)+
+ Math.abs(this.lastTickRenderPosY-this.renderPosY)+
+ Math.abs(this.lastTickRenderPosZ-this.renderPosZ)>0.01f;
+
+ float xi,yi,zi;
+ float x0=xi=(float)this.prevPosX;
+ float y0=yi=(float)this.prevPosY;
+ float z0=zi=(float)this.prevPosZ;
+ float dx0=this.dx0;
+ float dy0=this.dy0;
+ float dz0=this.dz0;
+ float dx1=(float) (this.virtualNodePosX-xi);
+ float dy1=(float) (this.virtualNodePosY-yi);
+ float dz1=(float) (this.virtualNodePosZ-zi);
+ if(this.nextAnchorEntity!=null)
+ {
+ dx1=(float) (this.nextAnchorEntity.prevPosX-xi);
+ dy1=(float) (this.nextAnchorEntity.prevPosY-yi);
+ dz1=(float) (this.nextAnchorEntity.prevPosZ-zi);
+ }
+ if(this.prevAnchorEntity==null)
+ {
+ this.renderPosX=this.virtualNodePosX;
+ this.renderPosY=this.virtualNodePosY;
+ this.renderPosZ=this.virtualNodePosZ;
+ x0=xi=(float) this.virtualNodePosX;
+ y0=yi=(float) this.virtualNodePosY;
+ z0=zi=(float) this.virtualNodePosZ;
+ }
+ if(this.nextAnchorEntity instanceof NodeEntity)
+ {
+ shouldUpdateRender=this.shouldUpdateRender || ((NodeEntity)this.nextAnchorEntity).shouldUpdateRender;
+ if(((NodeEntity)this.nextAnchorEntity).nextAnchorEntity!=null)
+ {
+ Entity nne = ((NodeEntity)this.nextAnchorEntity).nextAnchorEntity;
+ dx1=(float) (nne.prevPosX-xi);
+ dy1=(float) (nne.prevPosY-yi);
+ dz1=(float) (nne.prevPosZ-zi);
+ }
+ else
+ {
+ dx1=(float) (((NodeEntity) this.nextAnchorEntity).virtualNodePosX-xi);
+ dy1=(float) (((NodeEntity) this.nextAnchorEntity).virtualNodePosY-yi);
+ dz1=(float) (((NodeEntity) this.nextAnchorEntity).virtualNodePosZ-zi);
+ }
+ }
+ if(shouldUpdateRender)
+ {
+ float x1=(float) this.virtualNodePosX;
+ float y1=(float) this.virtualNodePosY;
+ float z1=(float) this.virtualNodePosZ;
+ if(this.nextAnchorEntity!=null)
+ {
+ if(nextAnchorEntity instanceof NodeEntity)
+ {
+ x1=(float) ((NodeEntity) nextAnchorEntity).renderPosX;
+ y1=(float) ((NodeEntity) nextAnchorEntity).renderPosY;
+ z1=(float) ((NodeEntity) nextAnchorEntity).renderPosZ;
+ }
+ else
+ {
+ x1=(float) nextAnchorEntity.posX;
+ y1=(float) nextAnchorEntity.posY;
+ z1=(float) nextAnchorEntity.posZ;
+ }
+ }
+ float d = (x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)+(z0-z1)*(z0-z1);
+ if(d>2f)
+ {
+ renderEvery=1;
+ }/*
+ else if(d>0.5f)
+ {
+ renderEvery=2;
+ }
+ else
+ {
+ renderEvery=4;
+ }*/
+ int i1=0;
+ for(float i=1f/n;i<=1f+1f/n;i+=((float)renderEvery)/n,i1+=renderEvery)
+ {
+ float dxi = xi;
+ float dyi = yi;
+ float dzi = zi;
+ xi=(dx1-2*x1+2*dx0+2*x0-dx0)*i*i*i+(3*x1-dx1-3*dx0-3*x0+dx0)*i*i+dx0*i+x0;
+ yi=(dy1-2*y1+2*dy0+2*y0-dy0)*i*i*i+(3*y1-dy1-3*dy0-3*y0+dy0)*i*i+dy0*i+y0;
+ zi=(dz1-2*z1+2*dz0+2*z0-dz0)*i*i*i+(3*z1-dz1-3*dz0-3*z0+dz0)*i*i+dz0*i+z0;
+ dxi-=xi;
+ dyi-=yi;
+ dzi-=zi;
+ double var7 = MathHelper.sqrt_double(dxi * dxi + dzi * dzi);
+ float rotationPitch = (float) Math.atan2(dxi, dzi);
+ float rotationYaw = (float) (-Math.atan2(dyi, var7));
+ rotationPitchArray[i1]=rotationPitch;
+ rotationYawArray[i1]=rotationYaw;
+ translationX[i1]=dxi;
+ translationY[i1]=dyi;
+ translationZ[i1]=dzi;
+ }
+ if(this.nextAnchorEntity instanceof NodeEntity)
+ {
+ NodeEntity next = (NodeEntity) this.nextAnchorEntity;
+ next.dx0=dx1;
+ next.dy0=dy1;
+ next.dz0=dz1;
+ }
+ }
+ }
+ if(--this.checkTimer<=0)
+ {
+ if(!worldObj.isRemote)
+ {
+ WorldServer world = MinecraftServer.getServer().worldServerForDimension(this.anchorDimensionId);
+ TileEntity te = world.getTileEntity(this.anchorX, this.anchorY, this.anchorZ);
+ if(te==null || !(te instanceof ICableHolder || te instanceof IMultiPowerCableHolder))
+ {
+ this.setDead();
+ }
+ else
+ {
+ if(te instanceof ICableHolder)
+ {
+ if(((ICableHolder)te).isCableRemoved(this.chainUniqueID))
+ {
+ this.setDead();
+ }
+ }
+ if(te instanceof IMultiPowerCableHolder)
+ {
+ if(((IMultiPowerCableHolder)te).isCableRemoved(this.chainUniqueID))
+ {
+ this.setDead();
+ }
+ }
+ }
+ }
+ this.checkTimer=200;
+ }
+ }
+
+ @Override
+ protected void readEntityFromNBT(NBTTagCompound nbt)
+ {
+ this.setChainUniqueID(nbt.getInteger("chainUniqueID"));
+ this.chainArrangeNumber=nbt.getInteger("chainArrangeNumber");
+ this.anchorX=nbt.getInteger("anchorX");
+ this.anchorY=nbt.getInteger("anchorY");
+ this.anchorZ=nbt.getInteger("anchorZ");
+ this.anchorFacing=nbt.getShort("anchorFacing");
+ this.anchorDimensionId=nbt.getInteger("anchorDimensionId");
+ this.type=nbt.getInteger("type");
+ this.colorIndex=nbt.getInteger("colorIndex");
+ this.shouldFollowPlayer=nbt.getBoolean("shouldFollowPlayer");
+ if(nbt.hasKey("width"))
+ {
+ this.setSize(nbt.getFloat("width"), nbt.getFloat("height"));
+ }
+ this.virtualNodePosX=nbt.getDouble("virtualNodePosX");
+ this.virtualNodePosY=nbt.getDouble("virtualNodePosY");
+ this.virtualNodePosZ=nbt.getDouble("virtualNodePosZ");
+ }
+
+ @Override
+ protected void writeEntityToNBT(NBTTagCompound nbt)
+ {
+ nbt.setFloat("width", this.width);
+ nbt.setFloat("height", this.height);
+ nbt.setInteger("chainUniqueID", this.getChainUniqueID());
+ nbt.setInteger("chainArrangeNumber", this.chainArrangeNumber);
+ nbt.setInteger("anchorX", this.anchorX);
+ nbt.setInteger("anchorY", this.anchorY);
+ nbt.setInteger("anchorZ", this.anchorZ);
+ nbt.setShort("anchorFacing",this.anchorFacing);
+ nbt.setInteger("anchorDimensionId",this.anchorDimensionId);
+ nbt.setInteger("type", this.type);
+ nbt.setInteger("colorIndex", this.colorIndex);
+ nbt.setBoolean("shouldFollowPlayer",this.shouldFollowPlayer);
+ nbt.setDouble("virtualNodePosX",this.virtualNodePosX);
+ nbt.setDouble("virtualNodePosY",this.virtualNodePosY);
+ nbt.setDouble("virtualNodePosZ",this.virtualNodePosZ);
+ }
+
+ public void setAnchor(int x, int y, int z, short facing, int dimensionId)
+ {
+ this.anchorX=x;
+ this.anchorY=y;
+ this.anchorZ=z;
+ this.anchorFacing=facing;
+ this.anchorDimensionId=dimensionId;
+ }
+
+ public boolean playerHasItemStack(EntityPlayer player)
+ {
+ int var2;
+ for (var2 = 0; var2 < player.inventory.mainInventory.length; ++var2)
+ {
+ if(this.isItemHasSameChainId(player.inventory.mainInventory[var2]))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean isItemHasSameChainId(ItemStack itemStack)
+ {
+ if(itemStack!=null)
+ {
+ if(itemStack.getItem() instanceof FlexibleCableItem)
+ {
+ return itemStack.stackTagCompound.getInteger("chainUID") == this.chainUniqueID;
+ }
+ }
+ return false;
+ }
+
+ public int getChainUniqueID() {
+ return chainUniqueID;
+ }
+
+ public void setChainUniqueID(int chainUniqueID) {
+ this.chainUniqueID = chainUniqueID;
+ }
+
+ @Override
+ public int getId()
+ {
+ return this.getEntityId();
+ }
+
+ @Override
+ public void recieveData(ByteBufInputStream byteBufInputStream)
+ {
+ try
+ {
+ this.setChainUniqueID(byteBufInputStream.readInt());
+ this.chainArrangeNumber=byteBufInputStream.readInt();
+ this.type=byteBufInputStream.readByte();
+ this.colorIndex=byteBufInputStream.readInt();
+ this.virtualNodePosX=byteBufInputStream.readDouble();
+ this.virtualNodePosY=byteBufInputStream.readDouble();
+ this.virtualNodePosZ=byteBufInputStream.readDouble();
+ this.shouldFollowPlayer=byteBufInputStream.readBoolean();
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected void entityInit() {}
+
+ @Override
+ public boolean isInvalid()
+ {
+ return this.isDead;
+ }
+
+ public void setVirtualNodePosToNearestPortal()
+ {
+ int x0 = (int)this.posX;
+ int y0 = (int)this.posY;
+ int z0 = (int)this.posZ;
+ for(int xi=x0-2;xi<=x0+2;xi++)
+ {
+ for(int yi=y0-2;yi<=y0+2;yi++)
+ {
+ for(int zi=z0-2;zi<=z0+2;zi++)
+ {
+ Block block = worldObj.getBlock(xi, yi, zi);
+ if(block==Blocks.portal||block==Blocks.end_portal)
+ {
+ this.setVirtualNodePos(xi+0.5d, yi+0.5d, zi+0.5d);
+ return;
+ }
+ }
+ }
+ }
+
+ }
+}
diff --git a/src/main/java/ihl/flexible_cable/NodeRender.java b/src/main/java/ihl/flexible_cable/NodeRender.java new file mode 100644 index 0000000..c27f11a --- /dev/null +++ b/src/main/java/ihl/flexible_cable/NodeRender.java @@ -0,0 +1,76 @@ +package ihl.flexible_cable;
+
+import org.lwjgl.opengl.GL11;
+
+import ihl.IHLModInfo;
+import ihl.model.ModelTube;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.entity.Entity;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class NodeRender extends Render
+{
+
+ private ModelTube model;
+ private ModelTube modelThin;
+ private ResourceLocation tex;
+ private float scale;
+
+ public NodeRender()
+ {
+ super();
+ scale = 1F/16F;
+ model=new ModelTube(null, 0, 0, -4F, -4F, -3F, 8, 8, 6,0f, 0.5f,0.99f, ForgeDirection.NORTH);
+ modelThin=new ModelTube(null, 0, 0, -1F, -1F, -3F, 2, 2, 6,0f, 0f,0.99f, ForgeDirection.NORTH);
+ tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/junctionBox.png");
+ }
+
+ @Override
+ public void doRender(Entity entity, double x1, double y1, double z1, float rotationYaw, float iFrame)
+ {
+ bindTexture(tex);
+ GL11.glPushMatrix();
+ NodeEntity ne = (NodeEntity) entity;
+ float x = (float) (ne.lastTickRenderPosX + (ne.renderPosX-ne.lastTickRenderPosX)*iFrame-RenderManager.renderPosX);
+ float y = (float) (ne.lastTickRenderPosY + (ne.renderPosY-ne.lastTickRenderPosY)*iFrame-RenderManager.renderPosY);
+ float z = (float) (ne.lastTickRenderPosZ + (ne.renderPosZ-ne.lastTickRenderPosZ)*iFrame-RenderManager.renderPosZ);
+ GL11.glTranslatef(x, y, z);
+ GL11.glScalef(0.25F, -0.25F, -0.25F);
+ int red = ne.colorIndex>>16;
+ int green = (ne.colorIndex>>8) & 255;
+ int blue = ne.colorIndex & 255;
+ for(int i=0;i<ne.n;i+=ne.renderEvery)
+ {
+ GL11.glRotatef(-ne.rotationPitchArray[i] * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
+ GL11.glRotatef(ne.rotationYawArray[i] * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
+ float cc=ne.rotationYawArray[i]*0.25f;
+ float red1 = Math.min(Math.max(red/255f+cc,red/511f),1f);
+ float green1 = Math.min(Math.max(green/255f+cc,green/511f),1f);
+ float blue1 = Math.min(Math.max(blue/255f+cc,blue/511f),1f);
+ GL11.glColor3f(red1, green1, blue1);
+ if(ne.type==0)
+ {
+ modelThin.renderCached(Tessellator.instance, scale);
+ }
+ else
+ {
+ model.renderCached(Tessellator.instance, scale);
+ }
+ GL11.glRotatef(-ne.rotationYawArray[i] * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
+ GL11.glRotatef(ne.rotationPitchArray[i] * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
+ GL11.glTranslatef(-ne.translationX[i]*4f, ne.translationY[i]*4f, ne.translationZ[i]*4f);
+ }
+
+ GL11.glPopMatrix(); //end
+ }
+
+ @Override
+ protected ResourceLocation getEntityTexture(Entity arg0)
+ {
+ return this.tex;
+ }
+}
+
\ No newline at end of file diff --git a/src/main/java/ihl/flexible_cable/PowerCableNodeEntity.java b/src/main/java/ihl/flexible_cable/PowerCableNodeEntity.java new file mode 100644 index 0000000..346b86c --- /dev/null +++ b/src/main/java/ihl/flexible_cable/PowerCableNodeEntity.java @@ -0,0 +1,243 @@ +package ihl.flexible_cable;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import ic2.core.IC2DamageSource;
+import ic2.core.item.armor.ItemArmorHazmat;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.play.server.S29PacketSoundEffect;
+import net.minecraft.network.play.server.S2APacketParticles;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.world.World;
+
+public class PowerCableNodeEntity extends NodeEntity implements IEnergyNetNode{
+
+ private Set<IHLCable> cableList;
+ private IHLCable cable;
+ private double soundRange=10d;
+ private final static float groundConductivity=0.005f;
+ private int lastCheckTimer=0;
+
+ public PowerCableNodeEntity(World world)
+ {
+ super(world);
+ }
+
+ @Override
+ public boolean canBeCollidedWith()
+ {
+ return !worldObj.isRemote && !this.noClip;
+ }
+
+ @Override
+ public boolean canBePushed()
+ {
+ return !worldObj.isRemote && !this.noClip;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void onUpdate()
+ {
+ super.onUpdate();
+ if(!worldObj.isRemote)
+ {
+ IHLGrid grid = IHLMod.enet.cablesToGrids.get(this.chainUniqueID);
+ if(grid!=null && grid.energy>0d)
+ {
+ double voltage = grid.getSinkVoltage(this);
+ if(this.onGround && voltage>=10d && this.getMaxAllowableVoltage()<voltage)
+ {
+ grid.drawEnergy(voltage*voltage*groundConductivity, this);
+ if(Math.abs(lastCheckTimer-checkTimer) > 10)
+ {
+ for(Object player:worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, AxisAlignedBB.getBoundingBox(this.posX-soundRange,this.posY-soundRange,this.posZ-soundRange, this.posX+soundRange,this.posY+soundRange,this.posZ+soundRange)))
+ {
+ if(player instanceof EntityPlayerMP)
+ {
+ EntityPlayerMP playerMP = (EntityPlayerMP)player;
+ playerMP.playerNetServerHandler.sendPacket(new S2APacketParticles("largesmoke",(float)this.posX,(float)this.posY,(float)this.posZ,worldObj.rand.nextFloat()*0.1f-0.05f,0.1f,worldObj.rand.nextFloat()*0.1f-0.05f,0.1f,4));
+ }
+ }
+ lastCheckTimer=checkTimer;
+ }
+ }
+ if(this.nextAnchorEntity!=null)
+ {
+ List<EntityLivingBase> entityList = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.boundingBox.expand(4d, 4d,4d));
+ for(EntityLivingBase elb:entityList)
+ {
+ if(elb.boundingBox!=null)
+ {
+ if(IHLUtils.isSegmentInsideAABB(elb.boundingBox,this.posX,this.posY,this.posZ,this.nextAnchorEntity.posX,this.nextAnchorEntity.posY,this.nextAnchorEntity.posZ))
+ {
+ this.applyEntityCollision(elb);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public AxisAlignedBB getCollisionBox(Entity entity)
+ {
+ return boundingBox;
+ }
+
+
+ @Override
+ public void applyEntityCollision(Entity entity)
+ {
+ super.applyEntityCollision(entity);
+ IHLGrid grid = IHLMod.enet.cablesToGrids.get(this.chainUniqueID);
+ if(entity instanceof EntityLivingBase && grid!=null && grid.energy>=1d)
+ {
+ double voltage = grid.getSinkVoltage(this);
+ if(this.getMaxAllowableVoltage()<voltage)
+ {
+ EntityLivingBase victim=(EntityLivingBase) entity;
+ if (!ItemArmorHazmat.hasCompleteHazmat(victim))
+ {
+ float damage=(float)Math.min(voltage*groundConductivity,grid.energy*1000d/voltage);
+ victim.attackEntityFrom(IC2DamageSource.electricity, damage);
+ grid.drawEnergy(damage*voltage/1000d, this);
+ if(voltage>1000)
+ {
+ sendSound();
+ IHLMod.proxy.spawnParticleFromServer(3,worldObj, (float)this.posX,(float)this.posY,(float)this.posZ,0f,0f,0f,10f);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void readEntityFromNBT(NBTTagCompound nbt)
+ {
+ super.readEntityFromNBT(nbt);
+ if(nbt.hasKey("cable"))
+ {
+ this.addCable(nbt.getCompoundTag("cable"));
+ }
+ }
+
+ @Override
+ protected void writeEntityToNBT(NBTTagCompound nbt)
+ {
+ super.writeEntityToNBT(nbt);
+ if(this.cable!=null)
+ {
+ nbt.setTag("cable",this.cable.toNBT());
+ }
+ }
+
+ @Override
+ public IHLGrid getGrid()
+ {
+ return IHLMod.enet.cablesToGrids.get(this.chainUniqueID);
+ }
+
+ @Override
+ public int getGridID()
+ {
+ return 0;
+ }
+
+ @Override
+ public void setGrid(int newGridID) {}
+
+ @Override
+ public double getMaxAllowableVoltage()
+ {
+ if(this.cable!=null)
+ {
+ return this.cable.maxVoltage;
+ }
+ else
+ {
+ return Integer.MAX_VALUE;
+ }
+ }
+
+ @Override
+ public boolean addCable(NBTTagCompound cable1)
+ {
+ this.cable=IHLCable.fromNBT(cable1);
+ return true;
+ }
+
+ @Override
+ public Set<IHLCable> getCableList() {
+ if(cableList==null)
+ {
+ cableList=new HashSet<IHLCable>(1);
+ if(this.cable!=null)
+ {
+ cableList.add(this.cable);
+ }
+ }
+ return cableList;
+ }
+
+ @Override
+ public void removeAttachedChains() {}
+
+ public void sendSound()
+ {
+ for(Object player:worldObj.getEntitiesWithinAABB(EntityPlayerMP.class, AxisAlignedBB.getBoundingBox(this.posX-soundRange,this.posY-soundRange,this.posZ-soundRange, this.posX+soundRange,this.posY+soundRange,this.posZ+soundRange)))
+ {
+ if(player instanceof EntityPlayerMP)
+ {
+ EntityPlayerMP playerMP = (EntityPlayerMP)player;
+ playerMP.playerNetServerHandler.sendPacket(new S29PacketSoundEffect(IHLModInfo.MODID+":electrocution",this.posX,this.posY,this.posZ,1f,1f));
+ }
+ }
+ }
+
+ @Override
+ public double[] getPortPos(EntityLivingBase player)
+ {
+ return new double[3];
+ }
+
+ @Override
+ public void remove(IHLCable cable)
+ {
+ this.cableList.remove(cable);
+ }
+
+ @Override
+ public boolean isCableRemoved(int chainUniqueID)
+ {
+ return false;
+ }
+
+ @Override
+ public void setCableCheck(boolean b) {}
+
+ @Override
+ public double getEnergyAmountThisNodeWant()
+ {
+ return 0;
+ }
+
+ @Override
+ public void injectEnergyInThisNode(double amount, double voltage) {}
+
+ @Override
+ public boolean isTileEntityBaseInvalid() {
+ return this.isDead;
+ }
+
+}
diff --git a/src/main/java/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java b/src/main/java/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java new file mode 100644 index 0000000..60a5a76 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/RectifierTransformerUnitTileEntity.java @@ -0,0 +1,336 @@ +package ihl.flexible_cable;
+
+import java.util.List;
+
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySink;
+import ic2.api.network.INetworkClientTileEntityEventListener;
+import ic2.core.IC2;
+import ic2.core.block.TileEntityInventory;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.interfaces.IMultiPowerCableHolder;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class RectifierTransformerUnitTileEntity extends TileEntityInventory implements INetworkClientTileEntityEventListener, IEnergySink, IMultiPowerCableHolder {
+
+ public boolean addedToEnergyNet=false;
+ public SubRTUEnergyNetNode[] energyNetNodes = new SubRTUEnergyNetNode[2];
+ public float mode = 1f;
+ public static float modeMultiplier = 2f;
+ public static float modeMax = 128f;
+ public static float modeMin = 1/modeMax;
+ public AxisAlignedBB aabb1;// Input zone "0"
+ public AxisAlignedBB aabb2;// Output zone "1"
+ public AxisAlignedBB aabb1_1;
+ public AxisAlignedBB aabb2_1;
+ public boolean checkCables=true;
+
+ public RectifierTransformerUnitTileEntity()
+ {
+ super();
+ for(short i=0;i<2;i++)
+ {
+ energyNetNodes[i] = new SubRTUEnergyNetNode(this, i);
+ }
+ aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, this.yCoord+1d, this.zCoord, this.xCoord+0.5d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord+0.5d, this.yCoord+1d, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.2d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.3d, this.yCoord+1.5d, this.zCoord+0.55d);
+ aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.7d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.8d, this.yCoord+1.5d, this.zCoord+0.55d);
+ }
+
+ @Override
+ public void onLoaded()
+ {
+ super.onLoaded();
+ for(short i=0;i<2;i++)
+ {
+ energyNetNodes[i].onLoaded();
+ }
+ if (IC2.platform.isSimulating()&&!this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ this.setupInteractingSpots(this.getFacing());
+ }
+
+ @Override
+ public void onUnloaded()
+ {
+ for(short i=0;i<2;i++)
+ {
+ energyNetNodes[i].onUnloaded();
+ }
+ if (IC2.platform.isSimulating() && this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ super.onUnloaded();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ fields.add("mode");
+ return fields;
+ }
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ this.removeAttachedChains();
+ short facing2 = (short) Math.max(facing1, 2);
+ super.setFacing(facing2);
+ this.setupInteractingSpots(facing2);
+ }
+
+ public void setupInteractingSpots(short facing2)
+ {
+ double yStart=this.yCoord+0.98d;
+ switch (facing2)
+ {
+ case 2:
+ aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+0.5d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord+0.5d, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.2d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.3d, this.yCoord+1.5d, this.zCoord+0.55d);
+ aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.7d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.8d, this.yCoord+1.5d, this.zCoord+0.55d);
+ break;
+ case 5:
+ aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+0.5d);
+ aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord+0.5d, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.45d, this.yCoord+1.4d, this.zCoord+0.2d, this.xCoord+0.55d, this.yCoord+1.5d, this.zCoord+0.3d);
+ aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.45d, this.yCoord+1.4d, this.zCoord+0.7d, this.xCoord+0.55d, this.yCoord+1.5d, this.zCoord+0.8d);
+ break;
+ case 3:
+ aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+0.5d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.5d, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.2d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.3d, this.yCoord+1.5d, this.zCoord+0.55d);
+ aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.7d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.8d, this.yCoord+1.5d, this.zCoord+0.55d);
+ break;
+ case 4:
+ aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+0.5d);
+ aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord+0.5d, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.45d, this.yCoord+1.4d, this.zCoord+0.2d, this.xCoord+0.55d, this.yCoord+1.5d, this.zCoord+0.3d);
+ aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.45d, this.yCoord+1.4d, this.zCoord+0.7d, this.xCoord+0.55d, this.yCoord+1.5d, this.zCoord+0.8d);
+ break;
+ default:
+ aabb1 = AxisAlignedBB.getBoundingBox(this.xCoord, yStart, this.zCoord, this.xCoord+0.5d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb2 = AxisAlignedBB.getBoundingBox(this.xCoord+0.5d, yStart, this.zCoord, this.xCoord+1d, this.yCoord+1.1d, this.zCoord+1d);
+ aabb1_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.2d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.3d, this.yCoord+1.5d, this.zCoord+0.55d);
+ aabb2_1 = AxisAlignedBB.getBoundingBox(this.xCoord+0.7d, this.yCoord+1.4d, this.zCoord+0.45d, this.xCoord+0.8d, this.yCoord+1.5d, this.zCoord+0.55d);
+ break;
+ }
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player)
+ {
+ return IHLUtils.getThisModItemStack("rectifierTransformerUnit");
+ }
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
+ {
+ return this.getFacing()!=(short)side;
+ }
+
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ NBTTagList energyNetNodeNBTList = new NBTTagList();
+ for(SubRTUEnergyNetNode node:this.energyNetNodes)
+ {
+ energyNetNodeNBTList.appendTag(node.writeToNBT());
+ }
+ nbt.setTag("energyNetNodes", energyNetNodeNBTList);
+ nbt.setFloat("mode",this.mode);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ NBTTagList energyNetNodeNBTList=nbt.getTagList("energyNetNodes", 10);
+ for(int i=0;i<2;i++)
+ {
+ this.energyNetNodes[i].readFromNBT(energyNetNodeNBTList.getCompoundTagAt(i));
+ }
+ this.mode=nbt.getFloat("mode");
+ this.mode=this.mode==0f?1f:this.mode;
+ }
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event)
+ {
+ switch(event)
+ {
+ case 0:
+ break;
+ }
+ }
+
+ public void switchModeUp()
+ {
+ if(this.mode<modeMax)
+ {
+ this.mode*=modeMultiplier;
+ if(this.energyNetNodes[1].getGridID()!=-1)
+ {
+ if(this.energyNetNodes[0].getGridID()!=-1)
+ {
+ this.energyNetNodes[1].getGrid().injectEnergy(0, this.energyNetNodes[0].getGrid().getSinkVoltage(this.energyNetNodes[0])*this.mode, this.energyNetNodes[1]);
+ }
+ else if(this.energyNetNodes[1].getGrid().energy>=1d)
+ {
+ this.energyNetNodes[1].getGrid().injectEnergy(0, 400d*this.mode, this.energyNetNodes[1]);
+ }
+ }
+ IC2.network.get().updateTileEntityField(this, "mode");
+ }
+ }
+
+ public void switchModeDown()
+ {
+ if(this.mode>modeMin)
+ {
+ this.mode/=modeMultiplier;;
+ if(this.energyNetNodes[1].getGridID()!=-1)
+ {
+ if(this.energyNetNodes[0].getGridID()!=-1)
+ {
+ this.energyNetNodes[1].getGrid().injectEnergy(0, this.energyNetNodes[0].getGrid().getSinkVoltage(this.energyNetNodes[0])*this.mode, this.energyNetNodes[1]);
+ }
+ else if(this.energyNetNodes[1].getGrid().energy>=1d)
+ {
+ this.energyNetNodes[1].getGrid().injectEnergy(0, 400d*this.mode, this.energyNetNodes[1]);
+ }
+ }
+ IC2.network.get().updateTileEntityField(this, "mode");
+ }
+ }
+
+ @Override
+ public void onNetworkUpdate(String field)
+ {
+ if (field.equals("facing") && this.prevFacing != this.getFacing())
+ {
+ this.setupInteractingSpots(this.getFacing());
+ }
+ super.onNetworkUpdate(field);
+ }
+
+
+ @Override
+ public void updateEntityServer()
+ {
+
+ }
+
+ @Override
+ public String getInventoryName()
+ {
+ return "RTU";
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity emitter,ForgeDirection direction)
+ {
+ return !direction.equals(ForgeDirection.UP);
+ }
+
+ @Override
+ public double getDemandedEnergy()
+ {
+ if(this.energyNetNodes[1].getGridID()!=-1 && this.energyNetNodes[1].getGrid().energy<1D)
+ {
+ return Integer.MAX_VALUE;
+ }
+ else
+ {
+ return 0d;
+ }
+ }
+
+ @Override
+ public int getSinkTier()
+ {
+ return 4;
+ }
+
+ @Override
+ public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
+ {
+ if(getDemandedEnergy()>0d)
+ {
+ this.energyNetNodes[1].getGrid().injectEnergy(amount, 400d*this.mode, this.energyNetNodes[1]);
+ return 0d;
+ }
+ return amount;
+ }
+
+ @Override
+ public boolean isCableRemoved(int chainUniqueID)
+ {
+ if(!checkCables)
+ {
+ return false;
+ }
+ for(SubRTUEnergyNetNode sen:energyNetNodes)
+ {
+ if(!sen.isCableRemoved(chainUniqueID))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public IEnergyNetNode getEnergyNetNode(short facing)
+ {
+ return this.energyNetNodes[facing];
+ }
+
+ @Override
+ public short getSide(EntityPlayer player)
+ {
+ if(IHLUtils.isPlayerLookingAt(player, aabb1))
+ {
+ return 0;
+ }
+ else if(IHLUtils.isPlayerLookingAt(player, aabb2))
+ {
+ return 1;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ @Override
+ public void removeAttachedChains()
+ {
+ for(short i=0;i<2;i++)
+ {
+ energyNetNodes[i].removeAttachedChains();
+ }
+
+ }
+
+ public boolean isTileEntityInvalid() {
+ return this.tileEntityInvalid;
+ }
+
+
+}
diff --git a/src/main/java/ihl/flexible_cable/SetOfDiesMiniGUI.java b/src/main/java/ihl/flexible_cable/SetOfDiesMiniGUI.java new file mode 100644 index 0000000..c708da7 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/SetOfDiesMiniGUI.java @@ -0,0 +1,81 @@ +package ihl.flexible_cable; + +import java.awt.event.KeyEvent; + +import org.lwjgl.opengl.GL11; + +import ihl.IHLMod; +import ihl.interfaces.ItemMiniGUI; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiTextField; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; + +public class SetOfDiesMiniGUI extends ItemMiniGUI { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIIronWorkbench.png"); + private int transverseSectionValue; + private GuiTextField transverseSectionTextField; + private int xPos; + private int yPos; + + public SetOfDiesMiniGUI(GuiContainer gui, Slot slot) { + super(gui, slot); + transverseSectionValue = slot.getStack().stackTagCompound.getInteger("transverseSection"); + xPos = this.slotBase.xDisplayPosition - 18; + yPos = this.slotBase.yDisplayPosition + 18; + transverseSectionTextField = new GuiTextField(this.guiBase.mc.fontRenderer, xPos + TEXT_BOX_POSX, yPos + TEXT_BOX_POSY, TEXT_BOX_WIDTH, + 11); + transverseSectionTextField.setText(Float.toString(transverseSectionValue / 10f)); + transverseSectionTextField.setFocused(true); + } + + @Override + public void displayGUI() { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + this.guiBase.mc.renderEngine.bindTexture(background); + this.guiBase.drawTexturedModalRect(xPos, yPos, 0, 202, 126, HEIGHT); + int runnerXPos = xPos + 5 + 114 * transverseSectionValue / 1350; + this.guiBase.drawTexturedModalRect(runnerXPos, yPos + RUNNER_POSY, 126, 202, 3, 5); + this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.transversesection"), + xPos + 3, yPos + 4, 0xFFCC00); + this.transverseSectionTextField.drawTextBox(); + this.guiBase.mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("mm\u00B2"), xPos + UNITS_LABEL_POSX, + yPos + 18, 0xFFCC00); + } + + @Override + public boolean handleMouseClick(int mouseX, int mouseY, int mouseButton) { + if (mouseX >= xPos + 5 && mouseX <= xPos + 119 && mouseY >= yPos + RUNNER_POSY - 1 && mouseY <= yPos + HEIGHT) { + this.transverseSectionValue = Math.max(1, Math.min(1350, (mouseX - xPos - 5) * 1350 / 114)); + this.transverseSectionTextField.setText(Float.toString(transverseSectionValue / 10f)); + } + if (mouseX >= xPos + TEXT_BOX_POSX && mouseX <= xPos + TEXT_BOX_POSX + TEXT_BOX_WIDTH && mouseY >= yPos + TEXT_BOX_POSY && mouseY <= yPos + TEXT_BOX_POSY + 11) { + this.transverseSectionTextField.setFocused(true); + } + return mouseX >= xPos && mouseX <= xPos + 202 && mouseY >= yPos && mouseY <= yPos + HEIGHT; + } + + @Override + public boolean handleKeyTyped(char characterTyped, int keyIndex) { + this.transverseSectionTextField.textboxKeyTyped(characterTyped, keyIndex); + // 28 - enter; 156 - numpad enter + if (keyIndex == KeyEvent.VK_ACCEPT || keyIndex == KeyEvent.VK_ENTER || keyIndex == 28 || keyIndex == 156) { + this.transverseSectionValue = Math.max(1, Math.min(1350, (int) (IHLUtils + .parseFloatSafe(this.transverseSectionTextField.getText(), this.transverseSectionValue) * 10f))); + this.transverseSectionTextField.setText(Float.toString(transverseSectionValue / 10f)); + this.transverseSectionTextField.setFocused(false); + return true; + } + return false; + } + + @Override + public void onGUIClosed() { + IHLMod.proxy.sendItemStackNBTTagFromClientToServerPlayer(this.guiBase.mc.thePlayer, this.slotBase.slotNumber, + "transverseSection", this.transverseSectionValue); + } + +} diff --git a/src/main/java/ihl/flexible_cable/SubAnchorEnergyNetNode.java b/src/main/java/ihl/flexible_cable/SubAnchorEnergyNetNode.java new file mode 100644 index 0000000..daada72 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/SubAnchorEnergyNetNode.java @@ -0,0 +1,346 @@ +package ihl.flexible_cable; + +import java.util.HashSet; +import java.util.Set; + +import ic2.api.energy.EnergyNet; +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.energy.tile.IEnergySource; +import ic2.core.IC2; +import ihl.IHLMod; +import ihl.interfaces.IEnergyNetNode; +import ihl.utils.IHLUtils; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; + +public class SubAnchorEnergyNetNode implements IEnergyNetNode{ + + private AnchorTileEntity base; + private short facing; + private int gridID=-1; + private Set<IHLCable> cableList = new HashSet<IHLCable>(); + + public SubAnchorEnergyNetNode(AnchorTileEntity base1, short facing1) + { + base=base1; + facing=facing1; + } + + @Override + public double[] getPortPos(EntityLivingBase player) + { + double d=0.5D; + double f=-0.05D; + switch(facing) + { + case 0: + return new double[]{ + (base.xCoord+d), + (base.yCoord+1D-f), + (base.zCoord+0.5D)}; + case 1: + return new double[]{ + (base.xCoord+d), + (base.yCoord+f), + (base.zCoord+0.5D)}; + case 2: + return new double[]{ + (base.xCoord+0.5D), + (base.yCoord+d), + (base.zCoord+1D-f)}; + case 3: + return new double[]{ + (base.xCoord+0.5D), + (base.yCoord+d), + (base.zCoord+f)}; + case 4: + return new double[]{ + (base.xCoord+1D-f), + (base.yCoord+d), + (base.zCoord+0.5D)}; + case 5: + return new double[]{ + (base.xCoord+f), + (base.yCoord+d), + (base.zCoord+0.5D)}; + default: + return new double[]{ + (base.xCoord+f), + (base.yCoord+d), + (base.zCoord+0.5D)}; + } + } + + @Override + public IHLGrid getGrid() + { + if(gridID!=-1) + { + return IHLMod.enet.getGrid(gridID); + } + else + { + return null; + } + } + + @Override + public int getGridID() + { + return gridID; + } + + @Override + public void setGrid(int newgridID) + { + if(IC2.platform.isSimulating()&& base.addedToEnergyNet && base.getWorldObj()!=null) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(base)); + base.addedToEnergyNet = false; + } + if(newgridID!=-1) + { + this.gridID=newgridID; + IHLMod.enet.getGrid(newgridID).add(this); + } + else + { + this.gridID=-1; + } + if (IC2.platform.isSimulating()&& !base.addedToEnergyNet && base.getWorldObj()!=null) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(base)); + base.addedToEnergyNet = true; + } + } + + @Override + public double getMaxAllowableVoltage() + { + return 64000d; + } + + @Override + public boolean addCable(NBTTagCompound cable) + { + base.hasCableOnSide[this.facing]=true; + return this.cableList.add(IHLCable.fromNBT(cable)); + } + + @Override + public Set<IHLCable> getCableList() { + return cableList; + } + + @Override + public void removeAttachedChains() + { + IHLUtils.removeChains(this,this.base.getWorldObj()); + } + + public void onLoaded() + { + if(gridID!=-1) + { + IHLGrid grid = IHLMod.enet.getGrid(gridID); + grid.add(this); + } + } + + public void onUnloaded() + { + if(gridID!=-1) + { + IHLGrid grid = IHLMod.enet.getGrid(gridID); + grid.remove(this); + } + } + + public NBTTagCompound writeToNBT() + { + NBTTagCompound nbt = new NBTTagCompound(); + NBTTagList cableNBTList = new NBTTagList(); + for(IHLCable cable:this.cableList) + { + cableNBTList.appendTag(cable.toNBT()); + } + nbt.setTag("cableList", cableNBTList); + nbt.setInteger("gridID", this.gridID); + return nbt; + } + + public void readFromNBT(NBTTagCompound nbt) { + NBTTagList cableNBTList=nbt.getTagList("cableList", 10); + for(int i=0;i<cableNBTList.tagCount();i++) + { + this.cableList.add(IHLCable.fromNBT(cableNBTList.getCompoundTagAt(i))); + } + this.gridID=nbt.getInteger("gridID"); + if(this.gridID!=-1) + { + base.hasCableOnSide[this.facing]=true; + } + } + + public double getDemandedEnergy() + { + if(this.gridID==-1) + { + return 0D; + } + else + { + if(this.getGrid().energy<=1d) + { + return 65536d; + } + else + { + return 0D; + } + } + } + + public double drawEnergyFromGrid(double amount) + { + if(this.gridID!=-1 && this.getGrid().energy>0d) + { + double drainedEnergy = Math.min(amount, this.getGrid().energy); + this.getGrid().drawEnergy(drainedEnergy, this); + return drainedEnergy; + } + return 0D; + } + + public double getVoltage() + { + if(this.gridID==-1) + { + return 0D; + } + else + { + return this.getGrid().getSinkVoltage(this); + } + } + + @Override + public void remove(IHLCable cable) + { + if(this.cableList.remove(cable)) + { + IHLUtils.removeChain(cable, this); + } + if(this.cableList.isEmpty()) + { + base.hasCableOnSide[this.facing]=false; + base.checkIfNoCablesLeft(); + } + } + + public double injectEnergyToGrid(double amount) + { + if(this.gridID==-1) + { + return amount; + } + else + { + this.getGrid().injectEnergy(amount, 400d, this); + return 0d; + } + } + + @Override + public boolean isCableRemoved(int chainUniqueID) { + for(IHLCable cable:this.cableList) + { + if(cable.chainUID==chainUniqueID) + { + return false; + } + } + return true; + } + + @Override + public void setCableCheck(boolean b) + { + base.checkCables=b; + } + + @Override + public double getEnergyAmountThisNodeWant() + { + Set<TileEntity> teset = new HashSet<TileEntity>(); + ForgeDirection direction = ForgeDirection.getOrientation(this.facing).getOpposite(); + TileEntity te = EnergyNet.instance.getNeighbor(this.base, direction); + teset.add(te); + TileEntity te1 = this.base.getSink(te, teset); + if(te1==this.base) + { + return 0d; + } + if(te instanceof IEnergySink) + { + return ((IEnergySink)te).acceptsEnergyFrom(this.base, ForgeDirection.getOrientation(this.facing))?((IEnergySink)te).getDemandedEnergy():0d; + } + return 0d; + } + + public double getEnergyOfferedByGrid() + { + if(this.gridID==-1) + { + return 0D; + } + else + { + return Math.max(this.getGrid().energy,0d); + } + } + + @Override + public void injectEnergyInThisNode(double amount, double voltage) + { + Set<TileEntity> teset = new HashSet<TileEntity>(); + ForgeDirection direction = ForgeDirection.getOrientation(this.facing).getOpposite(); + TileEntity te = EnergyNet.instance.getNeighbor(this.base, direction); + teset.add(te); + TileEntity te1 = this.base.getSink(te, teset); + if(te1==this.base) + { + return; + } + if(te1!=null && voltage>500D) + { + if(te1 instanceof IEnergyNetNode) + { + if(((IEnergyNetNode)te1).getMaxAllowableVoltage()<voltage) + { + base.sacrifices.add(te1); + } + } + else if(te1 instanceof IEnergySink) + { + base.sacrifices.add(te1); + } + } + if(te1 instanceof IEnergySink) + { + amount=((IEnergySink)te1).injectEnergy(direction, amount, voltage); + } + } + + @Override + public boolean isTileEntityBaseInvalid() { + return base.isTileEntityInvalid(); + } + +} diff --git a/src/main/java/ihl/flexible_cable/SubRTUEnergyNetNode.java b/src/main/java/ihl/flexible_cable/SubRTUEnergyNetNode.java new file mode 100644 index 0000000..06fc964 --- /dev/null +++ b/src/main/java/ihl/flexible_cable/SubRTUEnergyNetNode.java @@ -0,0 +1,320 @@ +package ihl.flexible_cable; + +import java.util.HashSet; +import java.util.Set; + +import ic2.api.energy.event.EnergyTileLoadEvent; +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.core.IC2; +import ihl.IHLMod; +import ihl.interfaces.IEnergyNetNode; +import ihl.utils.IHLUtils; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.MinecraftForge; + +public class SubRTUEnergyNetNode implements IEnergyNetNode{ + + private RectifierTransformerUnitTileEntity base; + private short side; + private int gridID=-1; + private Set<IHLCable> cableList = new HashSet<IHLCable>(); + + public SubRTUEnergyNetNode(RectifierTransformerUnitTileEntity base1, short facing1) + { + base=base1; + side=facing1; + } + + @Override + public double[] getPortPos(EntityLivingBase player) + { + double d=0.5D; + double f=0.25D; + double h=1.45d; + switch(base.getFacing()) + { + case 0: + case 1: + case 2: + switch(side) + { + case 0: + return new double[]{ + (base.xCoord+f), + (base.yCoord+h), + (base.zCoord+d)}; + case 1: + return new double[]{ + (base.xCoord+1d-f), + (base.yCoord+h), + (base.zCoord+d)}; + } + case 3: + switch(side) + { + case 1: + return new double[]{ + (base.xCoord+f), + (base.yCoord+h), + (base.zCoord+d)}; + case 0: + return new double[]{ + (base.xCoord+1d-f), + (base.yCoord+h), + (base.zCoord+d)}; + } + case 4: + switch(side) + { + case 1: + return new double[]{ + (base.xCoord+d), + (base.yCoord+h), + (base.zCoord+f)}; + case 0: + return new double[]{ + (base.xCoord+d), + (base.yCoord+h), + (base.zCoord+1d-f)}; + } + case 5: + switch(side) + { + case 0: + return new double[]{ + (base.xCoord+d), + (base.yCoord+h), + (base.zCoord+f)}; + case 1: + return new double[]{ + (base.xCoord+d), + (base.yCoord+h), + (base.zCoord+1d-f)}; + } + default: + return new double[]{ + (base.xCoord+1d-f), + (base.yCoord+h), + (base.zCoord+d)}; + } + } + + @Override + public IHLGrid getGrid() + { + if(gridID!=-1) + { + return IHLMod.enet.getGrid(gridID); + } + else + { + return null; + } + } + + @Override + public int getGridID() + { + return gridID; + } + + @Override + public void setGrid(int newgridID) + { + if(IC2.platform.isSimulating()&& base.addedToEnergyNet && base.getWorldObj()!=null) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(base)); + base.addedToEnergyNet = false; + } + if(newgridID!=-1) + { + this.gridID=newgridID; + IHLMod.enet.getGrid(newgridID).add(this); + } + else + { + this.gridID=-1; + } + if (IC2.platform.isSimulating()&& !base.addedToEnergyNet && base.getWorldObj()!=null) + { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(base)); + base.addedToEnergyNet = true; + } + } + + @Override + public double getMaxAllowableVoltage() + { + return 64000d; + } + + @Override + public boolean addCable(NBTTagCompound cable) + { + return this.cableList.add(IHLCable.fromNBT(cable)); + } + + @Override + public Set<IHLCable> getCableList() { + return cableList; + } + + @Override + public void removeAttachedChains() + { + IHLUtils.removeChains(this,this.base.getWorldObj()); + } + + public void onLoaded() + { + if(gridID!=-1) + { + IHLGrid grid = IHLMod.enet.getGrid(gridID); + grid.add(this); + } + } + + public void onUnloaded() + { + if(gridID!=-1) + { + IHLGrid grid = IHLMod.enet.getGrid(gridID); + grid.remove(this); + } + } + + public NBTTagCompound writeToNBT() + { + NBTTagCompound nbt = new NBTTagCompound(); + NBTTagList cableNBTList = new NBTTagList(); + for(IHLCable cable:this.cableList) + { + cableNBTList.appendTag(cable.toNBT()); + } + nbt.setTag("cableList", cableNBTList); + nbt.setInteger("gridID", this.gridID); + return nbt; + } + + public void readFromNBT(NBTTagCompound nbt) { + NBTTagList cableNBTList=nbt.getTagList("cableList", 10); + for(int i=0;i<cableNBTList.tagCount();i++) + { + this.cableList.add(IHLCable.fromNBT(cableNBTList.getCompoundTagAt(i))); + } + this.gridID=nbt.getInteger("gridID"); + } + + public double getOfferedEnergy() + { + if(this.gridID==-1) + { + return 0D; + } + else + { + return Math.max(this.getGrid().energy, 0D); + } + } + + public double drawEnergy(double amount) + { + if(this.gridID==-1) + { + return 0D; + } + else + { + double dEnergy = Math.min(this.getGrid().energy, amount); + this.getGrid().energy-=dEnergy; + return dEnergy; + } + } + + public double getVoltage() + { + if(this.gridID==-1) + { + return 0D; + } + else + { + return this.getGrid().getSinkVoltage(this); + } + } + + @Override + public void remove(IHLCable cable) + { + if(this.cableList.remove(cable)) + { + IHLUtils.removeChain(cable, this); + } + } + + public double injectEnergyToGrid(double amount) + { + if(this.gridID==-1) + { + return amount; + } + else + { + this.getGrid().injectEnergy(amount, 400d, this); + return 0d; + } + } + + @Override + public boolean isCableRemoved(int chainUniqueID) { + for(IHLCable cable:this.cableList) + { + if(cable.chainUID==chainUniqueID) + { + return false; + } + } + return true; + } + + @Override + public void setCableCheck(boolean b) + { + base.checkCables=b; + } + + @Override + public double getEnergyAmountThisNodeWant() + { + if(this.side==0) + { + IEnergyNetNode eNode1 = this.base.getEnergyNetNode((short)1); + if(eNode1.getGridID()!=-1 && eNode1.getGrid().energy<1d) + { + return Integer.MAX_VALUE; + } + } + return 0; + } + + @Override + public void injectEnergyInThisNode(double amount, double voltage) + { + if(this.side==0) + { + IEnergyNetNode eNode1 = this.base.getEnergyNetNode((short)1); + if(eNode1.getGridID()!=-1) + { + eNode1.getGrid().injectEnergy(amount, voltage*this.base.mode, eNode1); + } + } + } + + @Override + public boolean isTileEntityBaseInvalid() { + return this.base.isTileEntityInvalid(); + } + +} diff --git a/src/main/java/ihl/handpump/AdvancedHandPump.java b/src/main/java/ihl/handpump/AdvancedHandPump.java new file mode 100644 index 0000000..c842a2b --- /dev/null +++ b/src/main/java/ihl/handpump/AdvancedHandPump.java @@ -0,0 +1,351 @@ +package ihl.handpump;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.ElectricItem;
+import ic2.api.item.IC2Items;
+import ic2.core.Ic2Items;
+import ic2.core.util.LiquidUtil;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import ihl.utils.IHLUtils;
+import ihl.worldgen.ores.IHLFluid;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.BlockFluidBase;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+
+public class AdvancedHandPump extends IHLHandPump {
+
+ public AdvancedHandPump()
+ {
+ super();
+ this.maxCharge=IHLMod.config.advancedHandpumpMaxCharge;
+ this.operationEUCost=IHLMod.config.advancedHandpumpOperationEUCost;
+ this.tier=IHLMod.config.advancedHandpumpTier;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
+ {
+ MovingObjectPosition movingobjectposition = IHLUtils.returnMOPFromPlayer(entityPlayer, world);
+ if(movingobjectposition!=null)
+ {
+ int x=movingobjectposition.blockX;
+ int y=movingobjectposition.blockY;
+ int z=movingobjectposition.blockZ;
+ Block block = world.getBlock(x, y, z);
+ if(!block.getMaterial().isLiquid())
+ {
+ y++;
+ block = world.getBlock(x, y, z);
+ if(!block.getMaterial().isLiquid())
+ {
+ return itemStack;
+ }
+ }
+ if(world.isRemote && ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer))
+ {
+ entityPlayer.playSound(IHLModInfo.MODID+":handpumpOne", (float) (Math.random()*0.2D+0.6D), (float) (Math.random()*0.1D+0.9D));
+ return itemStack;
+ }
+ else
+ {
+ BlockWithCoordinates blockXYZ = this.searchSource(world, x, y, z);
+ if(blockXYZ==null)
+ {
+ return itemStack;
+ }
+ block = blockXYZ.block;
+ FluidStack fluid1 = null;
+ if(block instanceof BlockFluidBase)
+ {
+ fluid1 = ((BlockFluidBase)block).drain(world, blockXYZ.x, blockXYZ.y, blockXYZ.z, false);
+ }
+ else if(block==Blocks.water||block==Blocks.flowing_water)
+ {
+ fluid1 = new FluidStack(FluidRegistry.WATER, 1000);
+ }
+ else if(block==Blocks.lava||block==Blocks.flowing_lava)
+ {
+ fluid1 = new FluidStack(FluidRegistry.LAVA, 1000);
+ }
+ int amount2=0;
+ ItemStack stack = this.getItemStackContains(fluid1, entityPlayer);
+ if(stack!=null && fluid1 != null)
+ {
+ amount2 = LiquidUtil.fillContainerStack(stack, entityPlayer, fluid1, true);
+ }
+ if(amount2 >0)
+ {
+ if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer))
+ {
+ fluid1.amount=Integer.MAX_VALUE;
+ int countFreeAmount = this.countAmountOfEmptyFluidCells(Ic2Items.FluidCell, fluid1, entityPlayer);
+ Set<BlockWithCoordinates> blockXYZSet = this.searchSourcesAndDestroyThem(world, blockXYZ, countFreeAmount/1000);
+ int countDestroedSources = blockXYZSet.size();
+ this.destroyAllSources(world, blockXYZSet);
+ ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false);
+ this.fillUniversalFluidCells(fluid1, entityPlayer,countDestroedSources);
+ entityPlayer.inventoryContainer.detectAndSendChanges();
+ }
+ return itemStack;
+ }
+ else if(entityPlayer.inventory.hasItemStack(IC2Items.getItem("cell")))
+ {
+ if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer))
+ {
+ int countCells = this.countEmptyCells(IC2Items.getItem("cell"), entityPlayer);
+ Set<BlockWithCoordinates> blockXYZSet = this.searchSourcesAndDestroyThem(world, blockXYZ, countCells);
+ int countDestroedSources = blockXYZSet.size();
+ this.destroyAllSources(world, blockXYZSet);
+ ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false);
+ this.fillFluidCells(fluid1, entityPlayer, countDestroedSources);
+ entityPlayer.inventoryContainer.detectAndSendChanges();
+ return itemStack;
+ }
+ }
+ }
+ }
+ return itemStack;
+ }
+
+ private void destroyAllSources(World world,Set<BlockWithCoordinates> blockXYZSet)
+ {
+ Iterator<BlockWithCoordinates> iterator = blockXYZSet.iterator();
+ while(iterator.hasNext())
+ {
+ BlockWithCoordinates blockXYZ = iterator.next();
+ blockXYZ.setMetadataOrDestroyBlock(world, 1, 7);
+ }
+ }
+
+ private void fillUniversalFluidCells(FluidStack fluid1, EntityPlayer entityPlayer,
+ int countDestroedSources) {
+ fluid1.amount=countDestroedSources*1000;
+ //System.out.println("countDestroedSources="+countDestroedSources);
+ //System.out.println("fluidStackAmount="+fluid1.amount);
+ a:for (int i=0;i<entityPlayer.inventory.getSizeInventory();i++)
+ {
+ if(entityPlayer.inventory.getStackInSlot(i)!=null)
+ {
+ if(entityPlayer.inventory.getStackInSlot(i).getItem() instanceof IFluidContainerItem)
+ {
+ int amount2 = LiquidUtil.fillContainerStack(entityPlayer.inventory.getStackInSlot(i), entityPlayer, fluid1, false);
+ fluid1.amount-=amount2;
+ while(fluid1.amount>=1000 && entityPlayer.inventory.getStackInSlot(i).stackSize>=1 && amount2>0)
+ {
+ amount2 = LiquidUtil.fillContainerStack(entityPlayer.inventory.getStackInSlot(i), entityPlayer, fluid1, false);
+ fluid1.amount-=amount2;
+ }
+ if(fluid1.amount<1000)
+ {
+ break a;
+ }
+ }
+ }
+ }
+ }
+
+ private void fillFluidCells(FluidStack fluid1, EntityPlayer player, int countDestroedSources) {
+ ItemStack cell = IHLFluid.getCell(fluid1.getFluid().getName());
+ if(cell==null)
+ {
+ return;
+ }
+ ItemStack emptyCells = IC2Items.getItem("cell").copy();
+ emptyCells.stackSize=player.inventory.clearInventory(IC2Items.getItem("cell").getItem(),0)-countDestroedSources;
+ cell.stackSize=countDestroedSources;
+ IHLUtils.addItemStackToInventory(player, cell);
+ if(emptyCells.stackSize>0)
+ {
+ IHLUtils.addItemStackToInventory(player, emptyCells);
+ }
+ }
+
+ private Set<BlockWithCoordinates> searchSourcesAndDestroyThem(World world, BlockWithCoordinates blockXYZ, int countCells)
+ {
+ int startx = blockXYZ.x;
+ int starty = blockXYZ.y;
+ int startz = blockXYZ.z;
+ int currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ HashSet<BlockWithCoordinates> outputSet = new HashSet<BlockWithCoordinates>();
+ for (int i=0; i<256;i++)
+ {
+ if(getFlowDecay(world, blockXYZ, startx, starty+1, startz)>=0)
+ {
+ starty++;
+ currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ }
+
+ else if(getFlowDecay(world, blockXYZ, startx+1, starty+1, startz)>=0)
+ {
+ starty++;
+ startx++;
+ currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ }
+
+ else if(getFlowDecay(world, blockXYZ, startx-1, starty+1, startz)>=0)
+ {
+ starty++;
+ startx--;
+ currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ }
+
+ else if(getFlowDecay(world, blockXYZ, startx, starty+1, startz+1)>=0)
+ {
+ starty++;
+ startz++;
+ currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ }
+
+ else if(getFlowDecay(world, blockXYZ, startx, starty+1, startz-1)>=0)
+ {
+ starty++;
+ startz--;
+ currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ }
+ //Start checking neighbor blocks to lower flow decay.
+ else if(getFlowDecay(world, blockXYZ, startx-1, starty, startz)<currentFlowDecay&&getFlowDecay(world, startx-1, starty, startz)!=-1)
+ {
+ startx--;
+ currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ }
+ else if(getFlowDecay(world, blockXYZ, startx, starty, startz+1)<currentFlowDecay&&getFlowDecay(world, startx, starty, startz+1)!=-1)
+ {
+ startz++;
+ currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ }
+ else if(getFlowDecay(world, blockXYZ, startx, starty, startz-1)<currentFlowDecay&&getFlowDecay(world, startx, starty, startz-1)!=-1)
+ {
+ startz--;
+ currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ }
+ else if(getFlowDecay(world, blockXYZ, startx+1, starty, startz)<currentFlowDecay&&getFlowDecay(world, startx+1, starty, startz)!=-1)
+ {
+ startx++;
+ currentFlowDecay=getFlowDecay(world, blockXYZ, startx, starty, startz);
+ }
+ else {break;}
+ }
+ List<XYZ> xyzlist = new ArrayList<XYZ>();
+ if(currentFlowDecay==0)
+ {
+ xyzlist.add(new XYZ(startx, starty, startz));
+ outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
+ int listPos=0;
+ for(int i=0;i<=countCells;i++)
+ {
+ if(getFlowDecay(world, blockXYZ, startx-1, starty, startz)==0 && !xyzlist.contains(new XYZ(startx-1, starty, startz)))
+ {
+ startx--;
+ xyzlist.add(new XYZ(startx, starty, startz));
+ listPos=xyzlist.size()-1;
+ outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
+ }
+ else if(getFlowDecay(world, blockXYZ, startx, starty, startz+1)==0 && !xyzlist.contains(new XYZ(startx, starty, startz+1)))
+ {
+ startz++;
+ xyzlist.add(new XYZ(startx, starty, startz));
+ listPos=xyzlist.size()-1;
+ outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
+ }
+ else if(getFlowDecay(world, blockXYZ, startx, starty, startz-1)==0 && !xyzlist.contains(new XYZ(startx, starty, startz-1)))
+ {
+ startz--;
+ xyzlist.add(new XYZ(startx, starty, startz));
+ listPos=xyzlist.size()-1;
+ outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
+ }
+ else if(getFlowDecay(world, blockXYZ, startx+1, starty, startz)==0 && !xyzlist.contains(new XYZ(startx+1, starty, startz)))
+ {
+ startx++;
+ xyzlist.add(new XYZ(startx, starty, startz));
+ listPos=xyzlist.size()-1;
+ outputSet.add(new BlockWithCoordinates(world.getBlock(startx, starty, startz), startx, starty, startz,0));
+ }
+ else
+ {
+ if(listPos>0)
+ {
+ listPos--;
+ XYZ xyz = xyzlist.get(listPos);
+ startx=xyz.x;
+ starty=xyz.y;
+ startz=xyz.z;
+ }
+ }
+ }
+ }
+ return outputSet;
+ }
+
+ private int countEmptyCells(ItemStack fluidCell, EntityPlayer player) {
+ int num=0;
+ ItemStack[] inv = player.inventory.mainInventory;
+ for (int i=0;i<=35;i++)
+ {
+ if(inv[i]!=null)
+ {
+ if(inv[i].getItem() == fluidCell.getItem())
+ {
+ if(FluidContainerRegistry.isEmptyContainer(inv[i]))
+ {
+ num+=inv[i].stackSize;
+ }
+ }
+ }
+ }
+ return num;
+ }
+
+ private int countAmountOfEmptyFluidCells(ItemStack fluidCell, FluidStack fluid, EntityPlayer entityPlayer) {
+ int num=0;
+ for (int i=0;i<entityPlayer.inventory.getSizeInventory();i++)
+ {
+ if(entityPlayer.inventory.getStackInSlot(i)!=null)
+ {
+ if(entityPlayer.inventory.getStackInSlot(i).getItem() instanceof IFluidContainerItem)
+ {
+ int amount = LiquidUtil.fillContainerStack(entityPlayer.inventory.getStackInSlot(i), entityPlayer, fluid, true)*entityPlayer.inventory.getStackInSlot(i).stackSize;
+ num+=amount;
+ }
+ }
+ }
+ return num;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister par1IconRegister)
+ {
+ this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":itemAdvancedElectricHandpump");
+ }
+
+ protected int getFlowDecay(World world, BlockWithCoordinates blockXYZ, int x, int y, int z)
+ {
+ if(blockXYZ.isSameTypeBlock(world,x,y,z))
+ {
+ return world.getBlockMetadata(x, y, z);
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/handpump/BlockWithCoordinates.java b/src/main/java/ihl/handpump/BlockWithCoordinates.java new file mode 100644 index 0000000..d934b35 --- /dev/null +++ b/src/main/java/ihl/handpump/BlockWithCoordinates.java @@ -0,0 +1,96 @@ +package ihl.handpump;
+
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+import net.minecraft.world.World;
+
+public class BlockWithCoordinates {
+public Block block;
+public int x;
+public int y;
+public int z;
+public int meta;
+
+public BlockWithCoordinates(Block block1, int x1, int y1, int z1, int meta1)
+{
+ block=block1;
+ x=x1;
+ y=y1;
+ z=z1;
+ meta=meta1;
+}
+
+public boolean setMetadataOrDestroyBlock(World world, int meta, int maxMeta)
+{
+ if(meta>maxMeta)
+ {
+ return world.setBlockToAir(x, y, z);
+ }
+ else if(isWaterBlock())
+ {
+ if(world.setBlock(x,y,z,Blocks.flowing_water,meta,3))
+ {
+ world.scheduleBlockUpdate(x,y,z,Blocks.flowing_water,2);
+ return true;
+ }
+ return false;
+ }
+ else if(isLavaBlock())
+ {
+ if(world.setBlock(x,y,z,Blocks.flowing_lava,meta,3))
+ {
+ world.scheduleBlockUpdate(x,y,z,Blocks.flowing_lava,2);
+ return true;
+ }
+ return false;
+ }
+ return world.setBlockMetadataWithNotify(x, y, z, meta, 3);
+}
+
+public boolean isSameTypeBlock(World world, int x2, int y2, int z2)
+{
+ Block block2 = world.getBlock(x2, y2, z2);
+ if(isWaterBlock())
+ {
+ return block2==Blocks.water||block2==Blocks.flowing_water;
+ }
+ else if(isLavaBlock())
+ {
+ return block2==Blocks.lava||block2==Blocks.flowing_lava;
+ }
+ else
+ {
+ return block2==block;
+ }
+}
+
+public boolean isWaterBlock()
+{
+ if(block==Blocks.water||block==Blocks.flowing_water)
+ {
+ return true;
+ }
+ return false;
+}
+
+public boolean isLavaBlock()
+{
+ if(block==Blocks.lava||block==Blocks.flowing_lava)
+ {
+ return true;
+ }
+ return false;
+}
+
+@Override
+public boolean equals(Object other)
+{
+ if(other instanceof BlockWithCoordinates)
+ {
+ BlockWithCoordinates bwc = (BlockWithCoordinates)other;
+ return bwc.block==this.block && bwc.x==this.x && bwc.y==this.y && bwc.z==this.z;
+ }
+ return false;
+}
+
+}
diff --git a/src/main/java/ihl/handpump/IHLHandPump.java b/src/main/java/ihl/handpump/IHLHandPump.java new file mode 100644 index 0000000..a21919d --- /dev/null +++ b/src/main/java/ihl/handpump/IHLHandPump.java @@ -0,0 +1,351 @@ +package ihl.handpump;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.ElectricItem;
+import ic2.api.item.IBoxable;
+import ic2.api.item.IC2Items;
+import ic2.api.item.IElectricItem;
+import ic2.api.item.IItemHudInfo;
+import ic2.core.item.resources.ItemCell;
+import ic2.core.util.LiquidUtil;
+import ihl.IHLCreativeTab;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import ihl.utils.IHLUtils;
+import ihl.worldgen.ores.IHLFluid;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.BlockFluidBase;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+
+public class IHLHandPump extends Item implements IElectricItem, IBoxable, IItemHudInfo {
+
+ protected int tier=1;
+ protected int maxCharge=30000;
+ protected int operationEUCost=600;
+ protected int transferLimit = 2000;
+
+ public IHLHandPump()
+ {
+ super();
+ this.setMaxDamage(27);
+ this.maxCharge=IHLMod.config.handpumpMaxCharge;
+ this.operationEUCost=IHLMod.config.handpumpOperationEUCost;
+ this.tier=IHLMod.config.handpumpTier;
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.maxStackSize=1;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
+ {
+ MovingObjectPosition movingobjectposition = IHLUtils.returnMOPFromPlayer(entityPlayer, world);
+ if(movingobjectposition!=null)
+ {
+ int x=movingobjectposition.blockX;
+ int y=movingobjectposition.blockY;
+ int z=movingobjectposition.blockZ;
+ Block block = world.getBlock(x, y, z);
+ if(!block.getMaterial().isLiquid())
+ {
+ y++;
+ block = world.getBlock(x, y, z);
+ if(!block.getMaterial().isLiquid())
+ {
+ return itemStack;
+ }
+ }
+ if(world.isRemote && ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer))
+ {
+ entityPlayer.playSound(IHLModInfo.MODID+":handpumpOne", (float) (Math.random()*0.2D+0.6D), (float) (Math.random()*0.1D+0.9D));
+ return itemStack;
+ }
+ else
+ {
+ BlockWithCoordinates blockXYZ = this.searchSource(world, x, y, z);
+ if(blockXYZ==null)
+ {
+ return itemStack;
+ }
+ block = blockXYZ.block;
+ FluidStack fluid1 = null;
+ if(block instanceof BlockFluidBase)
+ {
+ fluid1 = ((BlockFluidBase)block).drain(world, blockXYZ.x, blockXYZ.y, blockXYZ.z, false);
+ }
+ else if(blockXYZ.isWaterBlock())
+ {
+ fluid1 = new FluidStack(FluidRegistry.WATER, 1000);
+ }
+ else if(blockXYZ.isLavaBlock())
+ {
+ fluid1 = new FluidStack(FluidRegistry.LAVA, 1000);
+ }
+ int amount2=0;
+ ItemStack stack = this.getItemStackContains(fluid1, entityPlayer);
+ if(stack!=null && fluid1 != null)
+ {
+ amount2 = LiquidUtil.fillContainerStack(stack, entityPlayer, fluid1, true);
+ }
+ if(amount2 > 0)
+ {
+ if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer) && blockXYZ.setMetadataOrDestroyBlock(world, blockXYZ.meta+1,7))
+ {
+ ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false);
+ LiquidUtil.fillContainerStack(stack, entityPlayer, fluid1, false);
+ entityPlayer.inventoryContainer.detectAndSendChanges();
+ }
+ return itemStack;
+ }
+ else if(entityPlayer.inventory.hasItemStack(IC2Items.getItem("cell")))
+ {
+ if(ElectricItem.manager.use(itemStack, this.operationEUCost, entityPlayer) && blockXYZ.setMetadataOrDestroyBlock(world, blockXYZ.meta+1,7))
+ {
+ ElectricItem.manager.discharge(itemStack,this.operationEUCost,1,false,false, false);
+ this.fillFluidCell(fluid1, entityPlayer);
+ entityPlayer.inventoryContainer.detectAndSendChanges();
+ return itemStack;
+ }
+ }
+ }
+ }
+ return itemStack;
+ }
+
+
+ protected ItemStack getItemStackContains(FluidStack fluidStack, EntityPlayer player) {
+ for (int i=0;i<player.inventory.getSizeInventory();i++)
+ {
+ if(player.inventory.getStackInSlot(i)!=null)
+ {
+ if(player.inventory.getStackInSlot(i).getItem() instanceof IFluidContainerItem)
+ {
+ if(LiquidUtil.fillContainerStack(player.inventory.getStackInSlot(i), player, fluidStack, true) > 0)
+ {
+ return player.inventory.getStackInSlot(i);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister par1IconRegister)
+ {
+ this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":itemElectricHandpump");
+ }
+
+ @Override
+ public boolean canProvideEnergy(ItemStack itemStack) {
+ return false;
+ }
+
+ @Override
+ public Item getChargedItem(ItemStack itemStack) {
+ return this;
+ }
+
+ @Override
+ public Item getEmptyItem(ItemStack itemStack) {
+ return this;
+ }
+
+ @Override
+ public double getMaxCharge(ItemStack itemStack) {
+ return this.maxCharge;
+ }
+
+ @Override
+ public double getTransferLimit(ItemStack itemStack) {
+ return this.transferLimit;
+ }
+
+ @Override
+ public int getTier(ItemStack itemStack) {
+ return this.tier;
+ }
+
+ @Override
+ public List<String> getHudInfo(ItemStack itemStack) {
+ LinkedList<String> info = new LinkedList<String>();
+ info.add(ElectricItem.manager.getToolTip(itemStack));
+ info.add("Power Tier: " + this.tier);
+ return info;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b)
+ {
+ info.add("PowerTier: " + this.tier);
+ }
+
+ @Override
+ public boolean canBeStoredInToolbox(ItemStack itemstack) {
+ return true;
+ }
+
+ @Override
+ public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2)
+ {
+ return false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList)
+ {
+ itemList.add(this.getItemStack(this.maxCharge));
+ itemList.add(this.getItemStack(0));
+ }
+
+ public ItemStack getItemStack(int charge)
+ {
+ ItemStack ret = new ItemStack(this);
+ ElectricItem.manager.charge(ret, charge, this.maxCharge, true, false);
+ return ret;
+ }
+
+
+ @Override
+ public double getDurabilityForDisplay(ItemStack stack)
+ {
+ return (this.maxCharge-ElectricItem.manager.getCharge(stack))/this.maxCharge;
+ }
+
+ protected void fillFluidCell(FluidStack fluid1, EntityPlayer player)
+ {
+ ItemStack cell = IHLFluid.getCell(fluid1.getFluid().getName());
+ if(cell==null)
+ {
+ return;
+ }
+ ItemStack[] inv = player.inventory.mainInventory;
+ for (int i=0;i<=35;i++)
+ {
+ if(inv[i]!=null)
+ {
+ if(inv[i].getItem() instanceof ItemCell)
+ {
+ if(inv[i].getItemDamage()==0)
+ {
+ if (IHLUtils.addItemStackToInventory(player, cell))
+ {
+ if(inv[i].stackSize<=1)
+ {
+ ItemStack sourceItemStack = inv[i].copy();
+ sourceItemStack.stackSize=player.inventory.clearInventory(sourceItemStack.getItem(),0)-1;
+ if(sourceItemStack.stackSize>0)
+ {
+ player.inventory.addItemStackToInventory(sourceItemStack);
+ }
+ }
+ else
+ {
+ inv[i].stackSize--;
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected BlockWithCoordinates searchSource(World world, int startx, int starty, int startz)
+ {
+ int currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ for (int i=0; i<256;i++)
+ {
+ if(getFlowDecay(world, startx, starty+1, startz)>=0)
+ {
+ starty++;
+ currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ }
+
+ else if(getFlowDecay(world, startx+1, starty+1, startz)>=0)
+ {
+ starty++;
+ startx++;
+ currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ }
+
+ else if(getFlowDecay(world, startx-1, starty+1, startz)>=0)
+ {
+ starty++;
+ startx--;
+ currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ }
+
+ else if(getFlowDecay(world, startx, starty+1, startz+1)>=0)
+ {
+ starty++;
+ startz++;
+ currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ }
+
+ else if(getFlowDecay(world, startx, starty+1, startz-1)>=0)
+ {
+ starty++;
+ startz--;
+ currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ }
+ //Start checking neighbor blocks to lower flow decay.
+ else if(getFlowDecay(world, startx-1, starty, startz)<currentFlowDecay&&getFlowDecay(world, startx-1, starty, startz)!=-1)
+ {
+ startx--;
+ currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ }
+ else if(getFlowDecay(world, startx, starty, startz+1)<currentFlowDecay&&getFlowDecay(world, startx, starty, startz+1)!=-1)
+ {
+ startz++;
+ currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ }
+ else if(getFlowDecay(world, startx, starty, startz-1)<currentFlowDecay&&getFlowDecay(world, startx, starty, startz-1)!=-1)
+ {
+ startz--;
+ currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ }
+ else if(getFlowDecay(world, startx+1, starty, startz)<currentFlowDecay&&getFlowDecay(world, startx+1, starty, startz)!=-1)
+ {
+ startx++;
+ currentFlowDecay=getFlowDecay(world, startx, starty, startz);
+ }
+ else {break;}
+ }
+ if(currentFlowDecay==0)
+ {
+ Block block = world.getBlock(startx, starty, startz);
+ return new BlockWithCoordinates(block, startx, starty, startz,0);
+ }
+ else
+ {
+ if(currentFlowDecay < 7)
+ {
+ world.setBlockMetadataWithNotify(startx, starty, startz,currentFlowDecay+1,3);
+ return null;
+ }
+ }
+ return null;
+ }
+
+ protected int getFlowDecay(World par1World, int par2, int par3, int par4)
+ {
+ return par1World.getBlock(par2, par3, par4).getMaterial().isLiquid() ? par1World.getBlockMetadata(par2, par3, par4) : -1;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/handpump/XYZ.java b/src/main/java/ihl/handpump/XYZ.java new file mode 100644 index 0000000..9a2627e --- /dev/null +++ b/src/main/java/ihl/handpump/XYZ.java @@ -0,0 +1,26 @@ +package ihl.handpump;
+
+public class XYZ {
+ public int x;
+ public int y;
+ public int z;
+
+ public XYZ(int x1,int y1,int z1)
+ {
+ this.x=x1;
+ this.y=y1;
+ this.z=z1;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if(obj instanceof XYZ)
+ {
+ XYZ xyz2 = (XYZ) obj;
+ return (this.x==xyz2.x && this.y==xyz2.y && this.z==xyz2.z);
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/java/ihl/interfaces/ICableHolder.java b/src/main/java/ihl/interfaces/ICableHolder.java new file mode 100644 index 0000000..ba9922e --- /dev/null +++ b/src/main/java/ihl/interfaces/ICableHolder.java @@ -0,0 +1,10 @@ +package ihl.interfaces; + +import net.minecraft.entity.EntityLivingBase; + +public interface ICableHolder +{ + double[] getPortPos(EntityLivingBase player); + boolean isCableRemoved(int chainUniqueID); + void setCableCheck(boolean b); +} diff --git a/src/main/java/ihl/interfaces/IEnergyNetNode.java b/src/main/java/ihl/interfaces/IEnergyNetNode.java new file mode 100644 index 0000000..c347d97 --- /dev/null +++ b/src/main/java/ihl/interfaces/IEnergyNetNode.java @@ -0,0 +1,21 @@ +package ihl.interfaces;
+
+import java.util.Set;
+
+import ihl.flexible_cable.IHLCable;
+import ihl.flexible_cable.IHLGrid;
+import net.minecraft.nbt.NBTTagCompound;
+
+public interface IEnergyNetNode extends ICableHolder{
+ IHLGrid getGrid();
+ int getGridID();
+ void setGrid(int newGridID);
+ double getMaxAllowableVoltage();
+ boolean addCable(NBTTagCompound cable);
+ Set<IHLCable> getCableList();
+ void removeAttachedChains();
+ void remove(IHLCable cable);
+ double getEnergyAmountThisNodeWant();
+ void injectEnergyInThisNode(double amount, double voltage);
+ public boolean isTileEntityBaseInvalid();
+}
diff --git a/src/main/java/ihl/interfaces/IFluidTankVisual.java b/src/main/java/ihl/interfaces/IFluidTankVisual.java new file mode 100644 index 0000000..cb34424 --- /dev/null +++ b/src/main/java/ihl/interfaces/IFluidTankVisual.java @@ -0,0 +1,8 @@ +package ihl.interfaces; + +public interface IFluidTankVisual { +int getVisibleFluidId(); +int getVisibleFluidAmount(); +float getRenderLiquidLevel(); + +} diff --git a/src/main/java/ihl/interfaces/IItemHasMiniGUI.java b/src/main/java/ihl/interfaces/IItemHasMiniGUI.java new file mode 100644 index 0000000..6b3d88a --- /dev/null +++ b/src/main/java/ihl/interfaces/IItemHasMiniGUI.java @@ -0,0 +1,12 @@ +package ihl.interfaces; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; + +public interface IItemHasMiniGUI +{ + @SideOnly(Side.CLIENT) + ItemMiniGUI getMiniGUI(GuiContainer gui, Slot slot); +} diff --git a/src/main/java/ihl/interfaces/IMultiPowerCableHolder.java b/src/main/java/ihl/interfaces/IMultiPowerCableHolder.java new file mode 100644 index 0000000..a6b1eba --- /dev/null +++ b/src/main/java/ihl/interfaces/IMultiPowerCableHolder.java @@ -0,0 +1,11 @@ +package ihl.interfaces; + +import net.minecraft.entity.player.EntityPlayer; + +public interface IMultiPowerCableHolder +{ + IEnergyNetNode getEnergyNetNode(short facing); + short getSide(EntityPlayer player); + void removeAttachedChains(); + boolean isCableRemoved(int chainUniqueID); +} diff --git a/src/main/java/ihl/interfaces/INetworkListener.java b/src/main/java/ihl/interfaces/INetworkListener.java new file mode 100644 index 0000000..7902df5 --- /dev/null +++ b/src/main/java/ihl/interfaces/INetworkListener.java @@ -0,0 +1,12 @@ +package ihl.interfaces; + +import io.netty.buffer.ByteBufInputStream; +import net.minecraft.entity.player.EntityPlayerMP; + +public interface INetworkListener +{ + void recieveData(ByteBufInputStream byteBufInputStream); + int getId(); + boolean isInvalid(); + void registerAndSendData(EntityPlayerMP player); +} diff --git a/src/main/java/ihl/interfaces/ISelectionBoxSpecialRenderer.java b/src/main/java/ihl/interfaces/ISelectionBoxSpecialRenderer.java new file mode 100644 index 0000000..2c27f32 --- /dev/null +++ b/src/main/java/ihl/interfaces/ISelectionBoxSpecialRenderer.java @@ -0,0 +1,10 @@ +package ihl.interfaces; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; + +public interface ISelectionBoxSpecialRenderer +{ + public void drawSelectionBox(EntityPlayer player, ItemStack currentItem, MovingObjectPosition movingObjectPosition, float partialTick); +} diff --git a/src/main/java/ihl/interfaces/IWire.java b/src/main/java/ihl/interfaces/IWire.java new file mode 100644 index 0000000..c2a9c0b --- /dev/null +++ b/src/main/java/ihl/interfaces/IWire.java @@ -0,0 +1,9 @@ +package ihl.interfaces;
+
+import net.minecraft.item.ItemStack;
+
+public interface IWire {
+ public String getTag();
+ public String getTagSecondary();
+ public boolean isSameWire(ItemStack stack1, ItemStack stack2);
+}
diff --git a/src/main/java/ihl/interfaces/IWorkspaceElement.java b/src/main/java/ihl/interfaces/IWorkspaceElement.java new file mode 100644 index 0000000..7f57ca7 --- /dev/null +++ b/src/main/java/ihl/interfaces/IWorkspaceElement.java @@ -0,0 +1,10 @@ +package ihl.interfaces;
+
+import ic2.api.tile.IWrenchable;
+
+public interface IWorkspaceElement extends IWrenchable
+{
+ boolean canBeUsed();
+ void use();
+ boolean getIsInvalid();
+}
diff --git a/src/main/java/ihl/interfaces/ItemMiniGUI.java b/src/main/java/ihl/interfaces/ItemMiniGUI.java new file mode 100644 index 0000000..249fb7d --- /dev/null +++ b/src/main/java/ihl/interfaces/ItemMiniGUI.java @@ -0,0 +1,29 @@ +package ihl.interfaces; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; + +public abstract class ItemMiniGUI { + protected final GuiContainer guiBase; + protected final Slot slotBase; + + protected final int TEXT_BOX_POSX = 50; + protected final int TEXT_BOX_POSY = 16; + protected final int TEXT_BOX_WIDTH = 42; + protected final int UNITS_LABEL_POSX = 105; + protected final int HEIGHT = 39; + protected final int RUNNER_POSY = 30; + + public ItemMiniGUI(GuiContainer gui, Slot slot) { + guiBase = gui; + slotBase = slot; + } + + public abstract void displayGUI(); + + public abstract boolean handleMouseClick(int mouseButton, int mouseX, int mouseY); + + public abstract boolean handleKeyTyped(char characterTyped, int keyIndex); + + public abstract void onGUIClosed(); +} diff --git a/src/main/java/ihl/items_blocks/FiberItem.java b/src/main/java/ihl/items_blocks/FiberItem.java new file mode 100644 index 0000000..79e50f9 --- /dev/null +++ b/src/main/java/ihl/items_blocks/FiberItem.java @@ -0,0 +1,109 @@ +package ihl.items_blocks;
+
+import java.util.List;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.interfaces.IWire;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class FiberItem extends Item implements IWire {
+
+ protected String info;
+ protected FiberMaterial material;
+ private String registryName;
+
+ public FiberItem(FiberMaterial material1, int leadsNum1, String registryName1)
+ {
+ super();
+ this.registryName=registryName1;
+ this.material=material1;
+ this.info=material.description;
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setMaxStackSize(1);
+ this.setUnlocalizedName(registryName);
+ }
+
+ public FiberItem()
+ {
+ super();
+ }
+
+ public static void init()
+ {
+ FiberMaterial[] var1 = FiberMaterial.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ String registryName = "fiber"+var1[i].description;
+ GameRegistry.registerItem(new FiberItem(var1[i],1,registryName),registryName);
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList)
+ {
+ ItemStack stack = new ItemStack(item);
+ stack.stackTagCompound=new NBTTagCompound();
+ stack.stackTagCompound.setInteger("fullLength", 1024);
+ stack.stackTagCompound.setInteger("length", 1024);
+ itemList.add(stack);
+ }
+
+ @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(this.info);
+ }
+
+ @Override
+ public String getTag()
+ {
+ return "length";
+ }
+
+ @Override
+ public String getTagSecondary()
+ {
+ return "fullLength";
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister par1IconRegister)
+ {
+ this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":"+this.registryName);
+ }
+
+ public static enum FiberMaterial
+ {
+ Glass("Glass");
+ FiberMaterial(String description1)
+ {
+ description=description1;
+ }
+ public String description;
+ }
+
+
+ @Override
+ public boolean isSameWire(ItemStack stack1,ItemStack stack2)
+ {
+ return stack1.getItem()==stack2.getItem();
+ }
+
+}
diff --git a/src/main/java/ihl/items_blocks/FlexibleCableItem.java b/src/main/java/ihl/items_blocks/FlexibleCableItem.java new file mode 100644 index 0000000..d5d8eda --- /dev/null +++ b/src/main/java/ihl/items_blocks/FlexibleCableItem.java @@ -0,0 +1,434 @@ +package ihl.items_blocks;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent;
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.energy.tile.IEnergyTile;
+import ihl.IHLCreativeTab;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import ihl.flexible_cable.AnchorTileEntity;
+import ihl.flexible_cable.NodeEntity;
+import ihl.flexible_cable.PowerCableNodeEntity;
+import ihl.interfaces.ICableHolder;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.interfaces.IMultiPowerCableHolder;
+import ihl.interfaces.IWire;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class FlexibleCableItem extends Item implements IWire {
+
+ public static FlexibleCableItem instance;
+ public final Set<String> yellowColoredWires = new HashSet<String>(3);
+
+ public FlexibleCableItem() {
+ super();
+ yellowColoredWires.add("Gold");
+ yellowColoredWires.add("Copper");
+ yellowColoredWires.add("Bronze");
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setMaxStackSize(1);
+ this.setFull3D();
+ instance = this;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList) {
+ itemList.add(IHLUtils.getUninsulatedWire("Copper", 160, 15));
+ itemList.add(IHLUtils.getUninsulatedWire("Copper", 160, 240));
+ itemList.add(IHLUtils.getUninsulatedWire("Steel", 160, 15));
+ itemList.add(IHLUtils.getUninsulatedWire("Steel", 160, 240));
+ itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 15, "RawRubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 240, "RawRubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 15, "RawRubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 240, "RawRubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 15, "Rubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Copper", 160, 240, "Rubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 15, "Rubber", 100));
+ itemList.add(IHLUtils.getInsulatedWire("Steel", 160, 240, "Rubber", 100));
+ }
+
+ public static void init() {
+ GameRegistry.registerItem(new FlexibleCableItem(), "copperWire");
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int par7,
+ float par8, float par9, float par10) {
+ TileEntity t = world.getTileEntity(x, y, z);
+ short facing = IHLUtils.getFacingFromPlayerView(player, true);
+ if (!world.isRemote && t instanceof IEnergyTile && !(t instanceof IMultiPowerCableHolder)
+ && !(t instanceof ICableHolder)) {
+ ForgeDirection direction = ForgeDirection.getOrientation(facing);
+ x += direction.offsetX;
+ y += direction.offsetY;
+ z += direction.offsetZ;
+ t = world.getTileEntity(x, y, z);
+ if (IHLUtils.isBlockCanBeReplaced(world, x, y, z)) {
+ world.setBlock(x, y, z, IHLMod.cableAnchorBlock);
+ } else if (!(t instanceof AnchorTileEntity)) {
+ return false;
+ }
+ t = world.getTileEntity(x, y, z);
+ }
+ if (world.isRemote)
+ world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "step.stone", 1.0F, 0.8F);
+ if (!world.isRemote && t != null
+ && ((t instanceof IEnergyNetNode)
+ || (t instanceof IMultiPowerCableHolder))
+ && stack.stackTagCompound.getInteger("fullLength") >= 1) {
+ double ppx, ppy, ppz;
+ ICableHolder te;
+ if (t instanceof IMultiPowerCableHolder) {
+ facing = ((IMultiPowerCableHolder) t).getSide(player);
+ if (facing == -1) {
+ return false;
+ } else {
+ te = ((IMultiPowerCableHolder) t).getEnergyNetNode(facing);
+ }
+ } else {
+ te = (ICableHolder) t;
+ }
+ ppx = te.getPortPos(player)[0];
+ ppy = te.getPortPos(player)[1];
+ ppz = te.getPortPos(player)[2];
+ if (stack.stackTagCompound.getBoolean("firstConnection")) {
+ int x1 = stack.stackTagCompound.getInteger("connectorX");
+ int y1 = stack.stackTagCompound.getInteger("connectorY");
+ int z1 = stack.stackTagCompound.getInteger("connectorZ");
+ int l1 = stack.stackTagCompound.getInteger("fullLength");
+ int l2 = stack.stackTagCompound.getInteger("length");
+ if (x == x1 && y == y1 && z == z1) {
+ this.cleanUp(stack.stackTagCompound.getInteger("chainUID"));
+ stack.stackTagCompound.setBoolean("firstConnection", false);
+ stack.stackTagCompound.setInteger("length", l1);
+ return true;
+ }
+ int t2DimensionId = stack.stackTagCompound.getInteger("connectorDimensionId");
+ short facing2 = stack.stackTagCompound.getShort("connectorFacing");
+ TileEntity t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x1, y1,
+ z1);
+ if (t2 == null) {
+ stack.stackTagCompound.setBoolean("firstConnection", false);
+ return false;
+ } else {
+ if (t instanceof IMultiPowerCableHolder) {
+ facing = ((IMultiPowerCableHolder) t).getSide(player);
+ if (facing == -1) {
+ return false;
+ } else {
+ te = ((IMultiPowerCableHolder) t).getEnergyNetNode(facing);
+ }
+ } else {
+ te = (ICableHolder) t;
+ }
+ te.setCableCheck(true);
+ }
+ this.connect(t, facing, t2, facing2, stack);
+ stack.stackTagCompound.setInteger("fullLength", l2);
+ if (l2 <= 0) {
+ stack.stackSize--;
+ }
+ stack.stackTagCompound.setBoolean("firstConnection", false);
+ stack.stackTagCompound.setInteger("chainArrangeNumber",
+ stack.stackTagCompound.getInteger("chainArrangeNumber") + 1);
+ x = x1;
+ y = y1;
+ z = z1;
+ } else {
+ te.setCableCheck(false);
+ stack.stackTagCompound.setBoolean("firstConnection", true);
+ stack.stackTagCompound.setInteger("connectorX", x);
+ stack.stackTagCompound.setInteger("connectorY", y);
+ stack.stackTagCompound.setInteger("connectorZ", z);
+ stack.stackTagCompound.setShort("connectorFacing", facing);
+ stack.stackTagCompound.setInteger("connectorDimensionId", world.provider.dimensionId);
+ stack.stackTagCompound.setInteger("prevDimensionId", world.provider.dimensionId);
+ stack.stackTagCompound.setInteger("chainArrangeNumber", 0);
+ stack.stackTagCompound.setInteger("chainUID", world.rand.nextInt());
+ stack.stackTagCompound.setDouble("prevNodePosX", ppx);
+ stack.stackTagCompound.setDouble("prevNodePosY", ppy);
+ stack.stackTagCompound.setDouble("prevNodePosZ", ppz);
+ stack.stackTagCompound.setInteger("length", stack.stackTagCompound.getInteger("length")-1);
+ }
+ NodeEntity node = newNode(world, player.posX, player.posY, player.posZ, stack,
+ stack.stackTagCompound.getInteger("chainArrangeNumber"), x, y, z);
+ node.virtualNodePosX = ppx;
+ node.virtualNodePosY = ppy;
+ node.virtualNodePosZ = ppz;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ protected void connect(TileEntity t1, short facing, TileEntity t2, short facing2, ItemStack stack) {
+ IEnergyNetNode te;
+ IEnergyNetNode te1;
+ if (t1 instanceof IEnergyNetNode) {
+ te = (IEnergyNetNode) t1;
+ } else {
+ te = ((IMultiPowerCableHolder) t1).getEnergyNetNode(facing);
+ }
+ if (t2 instanceof IEnergyNetNode) {
+ te1 = (IEnergyNetNode) t2;
+ } else {
+ te1 = ((IMultiPowerCableHolder) t2).getEnergyNetNode(facing2);
+ }
+ int newGridID = IHLMod.enet.mergeGrids(te.getGridID(), te1.getGridID());
+ int l1 = stack.stackTagCompound.getInteger("fullLength");
+ int l2 = stack.stackTagCompound.getInteger("length");
+ NBTTagCompound cable = (NBTTagCompound) stack.stackTagCompound.copy();
+ cable.setInteger("length", l1 - l2);
+ cable.setBoolean("firstConnection", false);
+ cable.setInteger("connectorX1", t1.xCoord);
+ cable.setInteger("connectorY1", t1.yCoord);
+ cable.setInteger("connectorZ1", t1.zCoord);
+ cable.setShort("connectorFacing1", facing);
+ cable.setInteger("connectorDimensionId1", t1.getWorldObj().provider.dimensionId);
+ te.addCable(cable);
+ te1.addCable(cable);
+ te.setGrid(newGridID);
+ te1.setGrid(newGridID);
+ }
+
+ private int getTransverseSection(ItemStack stack) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
+ }
+ return stack.stackTagCompound.getInteger("transverseSection");
+ }
+
+ public String getMaterial(ItemStack stack) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
+ }
+ return stack.stackTagCompound.getString("material");
+ }
+
+ public int getVoltageLimit(ItemStack stack) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
+ }
+ if (stack.stackTagCompound.hasKey("maxVoltage")) {
+ return stack.stackTagCompound.getInteger("maxVoltage");
+ }
+ return 0;
+ }
+
+ private long getResistance(ItemStack stack) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
+ }
+ return IHLUtils.getResistance(stack.stackTagCompound);
+ }
+
+ private void cleanUp(int uid) {
+ Set<NodeEntity> cs = IHLMod.proxy.nodeEntityRegistry.get(uid);
+ if (cs != null) {
+ for (NodeEntity ne : cs) {
+ if (ne != null) {
+ ne.setDead();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem) {
+ if (!world.isRemote && stack.stackTagCompound != null) {
+ if (stack.stackTagCompound.getBoolean("firstConnection")) {
+ int leight = stack.stackTagCompound.getInteger("length");
+ if (leight > 0) {
+ double pnpx = stack.stackTagCompound.getDouble("prevNodePosX");
+ double pnpy = stack.stackTagCompound.getDouble("prevNodePosY");
+ double pnpz = stack.stackTagCompound.getDouble("prevNodePosZ");
+ double ppx = entity.posX;
+ double ppy = entity.posY;
+ double ppz = entity.posZ;
+
+ if (pnpx != 0D && pnpy != 0D && pnpz != 0D) {
+ double sqd = (ppx - pnpx) * (ppx - pnpx) + (ppy - pnpy) * (ppy - pnpy)
+ + (ppz - pnpz) * (ppz - pnpz);
+ if (sqd > 2D) {
+ int can = stack.stackTagCompound.getInteger("chainArrangeNumber") + 1;
+ int cx = stack.stackTagCompound.getInteger("connectorX");
+ int cy = stack.stackTagCompound.getInteger("connectorY");
+ int cz = stack.stackTagCompound.getInteger("connectorZ");
+ NodeEntity node = newNode(world, ppx, ppy, ppz, stack, can, cx, cy, cz);
+ node.shouldFollowPlayer = true;
+ node.virtualNodePosX = ppx + (ppx - pnpx) * 2;
+ node.virtualNodePosY = ppy + (ppy - pnpy) * 2;
+ node.virtualNodePosZ = ppz + (ppz - pnpz) * 2;
+ stack.stackTagCompound.setInteger("chainArrangeNumber", can);
+ stack.stackTagCompound.setDouble("prevNodePosX", ppx);
+ stack.stackTagCompound.setDouble("prevNodePosY", ppy);
+ stack.stackTagCompound.setDouble("prevNodePosZ", ppz);
+ stack.stackTagCompound.setInteger("length", --leight);
+ stack.stackTagCompound.setInteger("prevDimensionId", world.provider.dimensionId);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void onPlayerTeleport(PlayerChangedDimensionEvent event) {
+ EntityPlayer player = event.player;
+ for (ItemStack stack : player.inventory.mainInventory) {
+ if (stack != null && stack.getItem() instanceof FlexibleCableItem) {
+ if (stack.stackTagCompound.getBoolean("firstConnection")) {
+ int can = -1;
+ Set<NodeEntity> ns = IHLMod.proxy.nodeEntityRegistry
+ .get(stack.stackTagCompound.getInteger("chainUID"));
+ if (ns != null) {
+ NodeEntity lastNode = null;
+ for (NodeEntity node : ns) {
+ node.shouldFollowPlayer = false;
+ if (node.chainArrangeNumber > can) {
+ lastNode = node;
+ can = node.chainArrangeNumber;
+ }
+ }
+ if (lastNode != null) {
+ lastNode.setVirtualNodePosToNearestPortal();
+ }
+ }
+ double[] cc = IHLUtils.tracePlayerView(player);
+ can = stack.stackTagCompound.getInteger("chainArrangeNumber") + 1;
+ int cx = stack.stackTagCompound.getInteger("connectorX");
+ int cy = stack.stackTagCompound.getInteger("connectorY");
+ int cz = stack.stackTagCompound.getInteger("connectorZ");
+ int leight = stack.stackTagCompound.getInteger("length");
+ NodeEntity node = newNode(MinecraftServer.getServer().worldServerForDimension(event.toDim), cc[0],
+ player.posY, cc[2], stack, can, cx, cy, cz);
+ node.setVirtualNodePosToNearestPortal();
+ stack.stackTagCompound.setInteger("chainArrangeNumber", can);
+ stack.stackTagCompound.setDouble("prevNodePosX", cc[0]);
+ stack.stackTagCompound.setDouble("prevNodePosY", cc[1]);
+ stack.stackTagCompound.setDouble("prevNodePosZ", cc[2]);
+ stack.stackTagCompound.setInteger("length", --leight);
+ stack.stackTagCompound.setInteger("prevDimensionId", event.toDim);
+ }
+ }
+ }
+ }
+
+ protected NodeEntity newNode(World world, double ppx, double ppy, double ppz, ItemStack stack, int can, int x,
+ int y, int z) {
+ PowerCableNodeEntity node = new PowerCableNodeEntity(world);
+ node.setPosition(ppx, ppy, ppz);
+ node.setChainUniqueID(stack.stackTagCompound.getInteger("chainUID"));
+ short facing = stack.stackTagCompound.getShort("connectorFacing");
+ int dimensionId = stack.stackTagCompound.getInteger("connectorDimensionId");
+ node.setAnchor(x, y, z, facing, dimensionId);
+ node.chainArrangeNumber = can;
+ node.colorIndex = this.getColor(stack);
+ node.addCable((NBTTagCompound) stack.stackTagCompound.copy());
+ if (stack.stackTagCompound.hasKey("insulationMaterial")) {
+ node.type = 1;
+ } else {
+ node.type = 0;
+ }
+ world.spawnEntityInWorld(node);
+ return node;
+ }
+
+ private int getColor(ItemStack stack) {
+ if (!stack.stackTagCompound.hasKey("insulationMaterial")) {
+ if (yellowColoredWires.contains(this.getMaterial(stack))) {
+ return 0xFF9900;
+ } else {
+ return 0xAAAABB;
+ }
+ }
+ return 0xFFFFFF;
+ }
+
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) {
+ if (itemStack.stackTagCompound != null) {
+ info.add(StatCollector.translateToLocal("ihl.lenght")+": " + itemStack.stackTagCompound.getInteger("length") + " m");
+ info.add(StatCollector.translateToLocal("ihl.wire_material")+": " + this.getMaterial(itemStack));
+ info.add(StatCollector.translateToLocal("ihl.resistivity")+": " + this.getResistance(itemStack) / 1000F + " V^2/(EU*m)");
+ info.add(StatCollector.translateToLocal("ihl.transverse_section")+": " + this.getTransverseSection(itemStack) / 10F + " sq. mm.");
+ if (itemStack.stackTagCompound.hasKey("insulationMaterial")) {
+ info.add(StatCollector.translateToLocal("ihl.insulation_material")+": " + this.getInsulationMaterial(itemStack));
+ info.add(StatCollector.translateToLocal("ihl.insulation_thickness")+": " + this.getInsulationThickness(itemStack) / 10f + " mm");
+ info.add(StatCollector.translateToLocal("ihl.insulation_beakdown_voltage")+": " + this.getVoltageLimit(itemStack) / 1000 + " kV");
+ }
+ info.add(StatCollector.translateToLocal("ihl.powerCableTooltip"));
+ }
+ }
+
+ @Override
+ public String getTag() {
+ return "length";
+ }
+
+ @Override
+ public String getTagSecondary() {
+ return "fullLength";
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister par1IconRegister) {
+ this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":copperWire");
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack) {
+ if (stack.stackTagCompound != null && !this.getInsulationMaterial(stack).equals("null")) {
+ return "cable";
+ }
+ return "wire";
+ }
+
+ @Override
+ public boolean isSameWire(ItemStack stack1, ItemStack stack2) {
+ if (stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage()) {
+ if (stack1.stackTagCompound != null && stack2.stackTagCompound != null) {
+ return this.getMaterial(stack1).equals(this.getMaterial(stack2))
+ && this.getTransverseSection(stack1) == this.getTransverseSection(stack2)
+ && this.getInsulationMaterial(stack1).equals(this.getInsulationMaterial(stack2))
+ && this.getInsulationThickness(stack1) == this.getInsulationThickness(stack2);
+ }
+ }
+ return false;
+ }
+
+ public String getInsulationMaterial(ItemStack stack) {
+ if (stack.stackTagCompound.hasKey("insulationMaterial")) {
+ return stack.stackTagCompound.getString("insulationMaterial");
+ }
+ return "null";
+ }
+
+ public int getInsulationThickness(ItemStack stack) {
+ if (stack.stackTagCompound.hasKey("insulationThickness")) {
+ return stack.stackTagCompound.getInteger("insulationThickness");
+ }
+ return 0;
+ }
+}
diff --git a/src/main/java/ihl/items_blocks/FlexiblePipeItem.java b/src/main/java/ihl/items_blocks/FlexiblePipeItem.java new file mode 100644 index 0000000..f5bb3fd --- /dev/null +++ b/src/main/java/ihl/items_blocks/FlexiblePipeItem.java @@ -0,0 +1,107 @@ +package ihl.items_blocks;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+
+public class FlexiblePipeItem extends Item {
+
+ private static Map<Integer, IIcon> iconMap = new HashMap<Integer, IIcon>();
+ private static Map<Integer, String> nameMap = new HashMap<Integer, String>();
+
+ public FlexiblePipeItem()
+ {
+ super();
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setMaxStackSize(1);
+ this.setUnlocalizedName("flexiblePipe");
+ }
+
+ public static void init()
+ {
+ FlexiblePipeItem item = new FlexiblePipeItem();
+ Type[] var1 = Type.values();
+ GameRegistry.registerItem(item,item.getUnlocalizedName());
+ for(int i=0;i<var1.length;i++)
+ {
+ nameMap.put(var1[i].damage,var1[i].unLocalizedName);
+ IHLUtils.registerLocally(var1[i].unLocalizedName, new ItemStack(item,1,var1[i].damage));
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ ItemStack stack = IHLUtils.getThisModItemStack(var1[i].unLocalizedName);
+ stack.stackTagCompound=new NBTTagCompound();
+ stack.stackTagCompound.setInteger("fullLength", 16);
+ stack.stackTagCompound.setInteger("length", 16);
+ itemList.add(stack);
+ }
+ }
+
+ @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");
+ }
+ }
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ iconMap.put(var1[i].damage, register.registerIcon(IHLModInfo.MODID + ":"+var1[i].unLocalizedName));
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int i)
+ {
+ return iconMap.get(i);
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack)
+ {
+ return nameMap.get(stack.getItemDamage());
+ }
+
+ public static enum Type
+ {
+ VulcanizedRubber(1, "pipeVulcanizedRubber"),
+ RubberWithSulfurPipe(0, "pipeRubberWithSulfur");
+ Type(int damage1, String unLocalizedName1)
+ {
+ damage=damage1;
+ unLocalizedName=unLocalizedName1;
+ }
+ public int damage;
+ public String unLocalizedName;
+ }
+}
diff --git a/src/main/java/ihl/items_blocks/IHLBucketHandler.java b/src/main/java/ihl/items_blocks/IHLBucketHandler.java new file mode 100644 index 0000000..9f3a7b8 --- /dev/null +++ b/src/main/java/ihl/items_blocks/IHLBucketHandler.java @@ -0,0 +1,20 @@ +package ihl.items_blocks;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import net.minecraft.block.Block;
+import net.minecraftforge.event.entity.player.FillBucketEvent;
+
+public class IHLBucketHandler
+{
+ public IHLBucketHandler() {}
+ @SubscribeEvent
+ public void onBucketFill(FillBucketEvent event)
+ {
+ Block block = event.world.getBlock(event.target.blockX, event.target.blockY, event.target.blockZ);
+ if (block instanceof IHLFluidBlock && event.isCancelable())
+ {
+ event.setCanceled(true);
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/items_blocks/IHLFluidBlock.java b/src/main/java/ihl/items_blocks/IHLFluidBlock.java new file mode 100644 index 0000000..7ad7730 --- /dev/null +++ b/src/main/java/ihl/items_blocks/IHLFluidBlock.java @@ -0,0 +1,120 @@ +package ihl.items_blocks;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.BlockFluidClassic;
+import net.minecraftforge.fluids.Fluid;
+
+public class IHLFluidBlock extends BlockFluidClassic {
+
+ private String textureName = "fluidRubberTreeSap";
+ @SideOnly(Side.CLIENT)
+ protected IIcon stillIcon;
+ @SideOnly(Side.CLIENT)
+ protected IIcon flowingIcon;
+ private boolean flammable;
+
+ public IHLFluidBlock(Fluid fluid, Material material, String textureName1, String registryName1) {
+ super(fluid, material);
+ textureName = textureName1;
+ GameRegistry.registerBlock(this, registryName1);
+ }
+
+ @Override
+ public int getLightValue(IBlockAccess world, int x, int y, int z)
+ {
+ return this.blockMaterial==Material.lava?15:0;
+ }
+
+ public IHLFluidBlock setFlammable(boolean flammable)
+ {
+ this.flammable = flammable;
+ return this;
+ }
+
+ @Override
+ public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
+ return flammable ? 300 : 0;
+ }
+
+ @Override
+ public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
+ return flammable ? 5 : 0;
+ }
+
+ @Override
+ public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
+ return flammable;
+ }
+
+
+ @Override
+ public IIcon getIcon(int side, int meta) {
+ return (side == 0 || side == 1)? stillIcon : flowingIcon;
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public void registerBlockIcons(IIconRegister register) {
+ stillIcon = register.registerIcon(IHLModInfo.MODID + ":" + textureName + "Still");
+ flowingIcon = register.registerIcon(IHLModInfo.MODID + ":" + textureName + "Flowing");
+ }
+
+ @Override
+ public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
+ if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
+ return super.canDisplace(world, x, y, z);
+ }
+
+ @Override
+ public boolean displaceIfPossible(World world, int x, int y, int z) {
+ if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false;
+ return super.displaceIfPossible(world, x, y, z);
+ }
+
+ @Override
+ public int onBlockPlaced(World world, int x, int y, int z, int meta, float xF, float yF, float zF, int meta2)
+ {
+ int var = super.onBlockPlaced(world, x, y, z, meta, xF, yF, zF, meta2);
+ if(!world.isRemote && this.isAirCompound())
+ {
+ world.setBlockToAir(x, y, z);
+ }
+ return var;
+ }
+
+ @Override
+ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack)
+ {
+ super.onBlockPlacedBy(world, x, y, z, player, itemStack);
+ if(!world.isRemote && this.isAirCompound())
+ {
+ world.setBlockToAir(x, y, z);
+ }
+ }
+
+ @Override
+ public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
+ super.onNeighborBlockChange(world, x, y, z, block);
+ if(!world.isRemote && this.isAirCompound())
+ {
+ world.setBlockToAir(x, y, z);
+ }
+ }
+
+ private boolean isAirCompound()
+ {
+ return this.fluidName.equals("air") || this.fluidName.equals("nitrogen") || this.fluidName.equals("oxygen");
+ }
+}
diff --git a/src/main/java/ihl/items_blocks/IHLItemBlock.java b/src/main/java/ihl/items_blocks/IHLItemBlock.java new file mode 100644 index 0000000..ff61070 --- /dev/null +++ b/src/main/java/ihl/items_blocks/IHLItemBlock.java @@ -0,0 +1,219 @@ +package ihl.items_blocks;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+
+public class IHLItemBlock extends ItemBlock {
+ public Map<Integer, String> nameMap = new HashMap<Integer, String>();
+
+ public IHLItemBlock(Block block1) {
+ super(block1);
+ this.setFull3D();
+ this.setHasSubtypes(true);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World world, int x, int y, int z, int par7,
+ float par8, float par9, float par10) {
+ Block block = world.getBlock(x, y, z);
+
+ if (block == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 7) < 1) {
+ par7 = 1;
+ } else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush) {
+ if (par7 == 0) {
+ --y;
+ }
+
+ if (par7 == 1) {
+ ++y;
+ }
+
+ if (par7 == 2) {
+ --z;
+ }
+
+ if (par7 == 3) {
+ ++z;
+ }
+
+ if (par7 == 4) {
+ --x;
+ }
+
+ if (par7 == 5) {
+ ++x;
+ }
+ }
+
+ if (par1ItemStack.stackSize == 0) {
+ return false;
+ } else if (!player.canPlayerEdit(x, y, z, par7, par1ItemStack)) {
+ return false;
+ } else if (y == 255) {
+ return false;
+ } else if (world.canPlaceEntityOnSide(this.field_150939_a, x, y, z, false, par7, player, par1ItemStack)) {
+ int metadata = par1ItemStack.getItemDamage();
+ int var13 = this.field_150939_a.onBlockPlaced(world, x, y, z, par7, par8, par9, par10, metadata);
+
+ if (world.setBlock(x, y, z, this.field_150939_a, var13, 3)) {
+ if (world.getBlock(x, y, z) == this.field_150939_a) {
+ this.field_150939_a.onBlockPlacedBy(world, x, y, z, player, par1ItemStack);
+ this.field_150939_a.onPostBlockPlaced(world, x, y, z, var13);
+ TileEntity tile = world.getTileEntity(x, y, z);
+ if (tile instanceof IWrenchable && IC2.platform.isSimulating()) {
+ IWrenchable te = (IWrenchable) tile;
+ int var6 = MathHelper.floor_double(player.rotationPitch * 4.0F / 360.0F + 0.5D) & 3;
+ int l = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+ te.setFacing((short) 0);
+ boolean allDPlacing = te.getFacing()==0;
+ if (player.isSneaking()) {
+ if (var6 == 1 && allDPlacing) {
+ te.setFacing((short) 0);
+ } else if (var6 == 3 && allDPlacing) {
+ te.setFacing((short) 1);
+ } else {
+
+ switch (l) {
+ case 0:
+ te.setFacing((short) 3);
+ break;
+
+ case 1:
+ te.setFacing((short) 4);
+ break;
+
+ case 2:
+ te.setFacing((short) 2);
+ break;
+
+ case 3:
+ te.setFacing((short) 5);
+ }
+ }
+ } else {
+ if (var6 == 1 && allDPlacing) {
+ te.setFacing((short) 1);
+ } else if (var6 == 3 && allDPlacing) {
+ te.setFacing((short) 0);
+ } else {
+
+ switch (l) {
+ case 0:
+ te.setFacing((short) 2);
+ break;
+
+ case 1:
+ te.setFacing((short) 5);
+ break;
+
+ case 2:
+ te.setFacing((short) 3);
+ break;
+
+ case 3:
+ te.setFacing((short) 4);
+ }
+ }
+ }
+ }
+ }
+
+ world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "step.stone", 1.0F, 0.8F);
+ --par1ItemStack.stackSize;
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister par1IconRegister) {
+ this.itemIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":sackItem");
+ }
+
+ public Block getBlockContained() {
+ return this.field_150939_a;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public CreativeTabs getCreativeTab() {
+ return this.field_150939_a.getCreativeTabToDisplayOn();
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack) {
+ if (!nameMap.isEmpty() && nameMap.containsKey(stack.getItemDamage())) {
+ return nameMap.get(stack.getItemDamage());
+ } else {
+ return this.field_150939_a.getUnlocalizedName();
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) {
+ if (itemStack.stackTagCompound != null) {
+ if (itemStack.stackTagCompound.hasKey("resultSuffix")) {
+ String result_suffix = itemStack.stackTagCompound.getString("resultSuffix");
+ if (StatCollector.canTranslate("ihl." + result_suffix)) {
+ result_suffix = StatCollector.translateToLocal("ihl." + result_suffix);
+ }
+ info.add(StatCollector.translateToLocal("result_of_molding") + result_suffix);
+ if (itemStack.stackTagCompound.hasKey("isContainStearin")
+ && itemStack.stackTagCompound.getBoolean("isContainStearin")) {
+ info.add(StatCollector.translateToLocal("ihl.tooltip.step") + " 1: "
+ + StatCollector.translateToLocal("remove_wax_using_muffle_furnace"));
+ info.add(StatCollector.translateToLocal("ihl.tooltip.step") + " 2: "
+ + StatCollector.translateToLocal("fill_from_top_with_molten_metal"));
+ info.add(StatCollector.translateToLocal("ihl.tooltip.step") + " 3: "
+ + StatCollector.translateToLocal("wait_for_10_seconds"));
+ info.add(StatCollector.translateToLocal("ihl.tooltip.step") + " 4: "
+ + StatCollector.translateToLocal("destroy_mold_to_get_results"));
+
+ } else {
+ info.add(StatCollector.translateToLocal("ihl.tooltip.step") + " 1: "
+ + StatCollector.translateToLocal("fill_from_top_with_molten_metal"));
+ info.add(StatCollector.translateToLocal("ihl.tooltip.step") + " 2: "
+ + StatCollector.translateToLocal("wait_for_10_seconds"));
+ info.add(StatCollector.translateToLocal("ihl.tooltip.step") + " 3: "
+ + StatCollector.translateToLocal("destroy_mold_to_get_results"));
+ }
+
+ }
+ if (itemStack.stackTagCompound.hasKey("detonator_delay")) {
+ info.add(StatCollector.translateToLocal("ihl.detonator_delay") + " "
+ + itemStack.stackTagCompound.getInteger("detonator_delay") + " "
+ + StatCollector.translateToLocal("ihl.seconds"));
+ }
+ if (itemStack.stackTagCompound.hasKey("explosionPower")) {
+ info.add(StatCollector.translateToLocal("ihl.explosionPower") + " "
+ + itemStack.stackTagCompound.getInteger("explosionPower") + " "
+ + StatCollector.translateToLocal("ihl.mTNT"));
+ }
+ }
+ }
+}
diff --git a/src/main/java/ihl/items_blocks/IHLTool.java b/src/main/java/ihl/items_blocks/IHLTool.java new file mode 100644 index 0000000..eb23ff5 --- /dev/null +++ b/src/main/java/ihl/items_blocks/IHLTool.java @@ -0,0 +1,444 @@ +package ihl.items_blocks;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.energy.tile.IEnergySink;
+import ic2.api.reactor.IReactor;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.flexible_cable.SetOfDiesMiniGUI;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.interfaces.IItemHasMiniGUI;
+import ihl.interfaces.IMultiPowerCableHolder;
+import ihl.interfaces.ItemMiniGUI;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.SharedMonsterAttributes;
+import net.minecraft.entity.passive.EntitySheep;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.potion.Potion;
+import net.minecraft.stats.AchievementList;
+import net.minecraft.stats.StatList;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.oredict.OreDictionary;
+public class IHLTool extends Item implements IItemHasMiniGUI{
+
+ private static Map<Integer, IIcon> iconMap = new HashMap<Integer, IIcon>();
+ private static Map<Integer, String> nameMap = new HashMap<Integer, String>();
+ private static Map<Integer, String> hintMap = new HashMap<Integer, String>();
+ private static Map<Integer, Boolean> isWeaponMap = new HashMap<Integer, Boolean>();
+ private static Map<Integer, Float> damageVersusEntityMap = new HashMap<Integer, Float>();
+ public static Item instance;
+
+ private IIcon dice240;
+
+ public IHLTool()
+ {
+ super();
+ this.setMaxDamage(0);
+ this.setNoRepair();
+ this.setHasSubtypes(true);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setUnlocalizedName("ihlTool");
+ this.setMaxStackSize(1);
+ instance=this;
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
+ {
+ if(itemStack.getItemDamage()!=19 || world.isRemote)
+ {
+ return itemStack;
+ }
+ MovingObjectPosition movingobjectposition = IHLUtils.returnMOPFromPlayer(entityPlayer, world);
+ if(movingobjectposition!=null)
+ {
+ int x=movingobjectposition.blockX;
+ int y=movingobjectposition.blockY;
+ int z=movingobjectposition.blockZ;
+ TileEntity te = world.getTileEntity(x, y, z);
+ if(te instanceof IReactor)
+ {
+ this.setThermometerTemperature(itemStack, entityPlayer, ((IReactor)te).getHeat()+273);
+ }
+ if(te instanceof IEnergySink)
+ {
+ System.out.println("demanded="+((IEnergySink)te).getDemandedEnergy());
+ }
+ IEnergyNetNode node = null;
+ if(te instanceof IMultiPowerCableHolder)
+ {
+ node = ((IMultiPowerCableHolder)te).getEnergyNetNode((short) 0);
+ for(short i=0;i<6;i++){
+ if(((IMultiPowerCableHolder)te).getEnergyNetNode(i).getGridID()!=-1)
+ node = ((IMultiPowerCableHolder)te).getEnergyNetNode(i);
+ }
+ }
+ if(te instanceof IEnergyNetNode)
+ {
+ node = ((IEnergyNetNode)te);
+ }
+ if(node!=null){
+ System.out.println("gridId="+node.getGridID());
+ if(node.getGridID()!=-1){
+ System.out.println("grid energy="+node.getGrid().energy);
+ System.out.println("getEnergyAmountThisNodeWant()="+node.getEnergyAmountThisNodeWant());
+ }
+ }
+ }
+ return itemStack;
+ }
+
+ @Override
+ public final ItemStack getContainerItem(ItemStack stack)
+ {
+ ItemStack outStack = stack.copy();
+ IHLUtils.damageItemViaNBTTag(outStack, 100);
+ if(outStack.stackSize<=0)
+ {
+ return null;
+ }
+ else
+ {
+ return outStack;
+ }
+ }
+
+ @Override
+ public final boolean doesContainerItemLeaveCraftingGrid(ItemStack aStack)
+ {
+ return false;
+ }
+
+ @Override
+ public final boolean hasContainerItem(ItemStack aStack)
+ {
+ return true;
+ }
+
+ public static void init()
+ {
+ IHLTool item = new IHLTool();
+ GameRegistry.registerItem(item,item.getUnlocalizedName());
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ nameMap.put(var1[i].itemDamage,var1[i].unLocalizedName);
+ ItemStack stack = new ItemStack(item,1,var1[i].itemDamage);
+ stack.stackTagCompound = new NBTTagCompound();
+ NBTTagCompound stats = new NBTTagCompound();
+ stats.setInteger("MaxDamage", var1[i].maxToolDamage);
+ stack.stackTagCompound.setTag("GT.ToolStats", stats);
+ if(var1[i].equals(Type.SetOfDies1_5sqmm))
+ {
+ stack.stackTagCompound.setInteger("transverseSection",15);
+ }
+ IHLUtils.registerLocally(var1[i].unLocalizedName, stack);
+ if(var1[i].hint!=null)
+ {
+ hintMap.put(var1[i].itemDamage, var1[i].hint);
+ }
+ isWeaponMap.put(var1[i].itemDamage, var1[i].isWeapon);
+ damageVersusEntityMap.put(var1[i].itemDamage, var1[i].damageVersusEntity);
+ if(var1[i].oreDictName!=null && var1[i].oreDictName.length>0)
+ {
+ for(int i1=0;i1<var1[i].oreDictName.length;i1++)
+ {
+ OreDictionary.registerOre(var1[i].oreDictName[i1], stack);
+ }
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ ItemStack stack = IHLUtils.getThisModItemStack(var1[i].unLocalizedName);
+ itemList.add(stack);
+ if(var1[i].equals(Type.SetOfDies1_5sqmm))
+ {
+ stack = IHLUtils.getItemStackWithTag(var1[i].unLocalizedName, "transverseSection",240);
+ itemList.add(stack);
+ }
+ }
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack)
+ {
+ return nameMap.get(stack.getItemDamage());
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ iconMap.put(var1[i].itemDamage, register.registerIcon(IHLModInfo.MODID + ":"+var1[i].unLocalizedName));
+ }
+ dice240 = register.registerIcon(IHLModInfo.MODID + ":setOfDies24sqmm");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(ItemStack stack, int i)
+ {
+ if(stack.stackTagCompound!=null && stack.stackTagCompound.hasKey("transverseSection"))
+ {
+ if(stack.stackTagCompound.getInteger("transverseSection")>=240)
+ {
+ return dice240;
+ }
+ }
+ return this.getIconFromDamage(stack.getItemDamage());
+ }
+
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int i)
+ {
+ return iconMap.get(i);
+ }
+
+ public enum Type
+ {
+ Thermometer("mercuryThermometer",19,1,0.1f,false,null,(String[])null),
+ FiberGlassDie("fiberGlassDieSteel",18,20000,0.5f,false,null,(String[])null),
+ SharpenedCarvingKnifeBronze("sharpenedCarvingKnifeBronze",17,2000,3.5f, true, "ihl.mutton_drop_hint", "craftingToolBlade", "craftingToolKnife"),
+ GlassBlowingTube("glassBlowingTubeSteel",16,2000,0.5f,false,null,(String[])null),
+ PolishingPucks("polishingPucksSteel",15,2000,0.5f,false,null,(String[])null),
+ GravelSteel("graverSteelHardened",14,10,0.5f,false,null,(String[])null),
+ DiceM10Steel("diceM10x1SteelHardened",13,2000,0.5f,false,null,(String[])null),
+ TapM10("tapM10x1SteelHardened",12,2000,0.5f,false,null,(String[])null),
+ Vise("viseSteel",11,200000,0.5f,false,null,(String[])null),
+ SetOfFiles("setOfFilesSteel",10,20000,1.5f,false,null,"craftingToolFile"),
+ HandDrillBronze("handDrillBronze",9,20000,0.5f,false,null,(String[])null),
+ HackSawSteel("hackSawSteel",8,200,0.5f,false,null,"craftingToolSaw"),
+ DrillSteel("drillSteelHardened",7,200,0.5f,false,null,(String[])null),
+ NeedleFile("needleFile",6,2000,0.1f,false,null,(String[])null),
+ Chisel("chisel",5,2000,1.5f,false,null,"craftingToolChisel"),
+ 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,"ihl.setOfDiesHint",(String[])null);
+ Type(String unlocalizedName1,int itemDamage1, int maxToolDamage1, float damageVersusEntity1, boolean isWeapon1, String hint1, String... oreDictName1)
+ {
+ unLocalizedName=unlocalizedName1;
+ itemDamage=itemDamage1;
+ maxToolDamage=maxToolDamage1;
+ damageVersusEntity=damageVersusEntity1;
+ isWeapon=isWeapon1;
+ hint=hint1;
+ oreDictName=oreDictName1;
+ }
+ public final String unLocalizedName;
+ public final String[] oreDictName;
+ public final int itemDamage;
+ public final int maxToolDamage;
+ public final float damageVersusEntity;
+ public final boolean isWeapon;
+ public final String hint;
+ }
+
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag)
+ {
+ info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.durability") +EnumChatFormatting.GREEN + (IHLUtils.getMaxDamageValueViaNBTTag(itemStack) - IHLUtils.getDamageValueViaNBTTag(itemStack))+" / "+IHLUtils.getMaxDamageValueViaNBTTag(itemStack));
+ info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.attack_damage") +EnumChatFormatting.DARK_BLUE + damageVersusEntityMap.get(itemStack.getItemDamage()));
+ if(hintMap.containsKey(itemStack.getItemDamage()))
+ {
+ info.add(EnumChatFormatting.RED+StatCollector.translateToLocal(hintMap.get(itemStack.getItemDamage())));
+ }
+ if(itemStack.stackTagCompound.hasKey("transverseSection"))
+ {
+ info.add(EnumChatFormatting.WHITE+StatCollector.translateToLocal("ihl.transversesection") +EnumChatFormatting.GREEN + (itemStack.stackTagCompound.getInteger("transverseSection")/10f)+" sq. mm.");
+ }
+ }
+
+ @Override
+ public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
+ {
+ IHLUtils.damageItemViaNBTTag(stack, 1);
+ if(target!=null && target instanceof EntitySheep && !target.isChild() && target.getHealth()<=0F)
+ {
+ target.entityDropItem(IHLUtils.getThisModItemStackWithSize("muttonLard", target.worldObj.rand.nextInt(2)+2), 1F);
+ }
+ return true;
+ }
+
+ @Override//That was taken from Gregtech. I think Greg wouldn't mind.
+ public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
+ {
+ if (entity.canAttackWithItem() && !entity.hitByEntity(player))
+ {
+ float tMagicDamage = entity instanceof EntityLivingBase ? EnchantmentHelper.getEnchantmentModifierLiving(player, (EntityLivingBase)entity) : 0.0F;
+ float tDamage = (float)player.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue() + damageVersusEntityMap.get(stack.getItemDamage());
+
+ if (tDamage + tMagicDamage > 0.0F)
+ {
+ boolean tCriticalHit = player.fallDistance > 0.0F && !player.onGround && !player.isOnLadder() && !player.isInWater() && !player.isPotionActive(Potion.blindness) && player.ridingEntity == null && entity instanceof EntityLivingBase;
+
+ if (tCriticalHit && tDamage > 0.0F)
+ {
+ tDamage *= 1.5F;
+ }
+
+ tDamage += tMagicDamage;
+
+ if (entity.attackEntityFrom(DamageSource.generic, tDamage))
+ {
+ if (entity instanceof EntityLivingBase)
+ {
+ entity.setFire(EnchantmentHelper.getFireAspectModifier(player) * 4);
+ }
+
+ int tKnockcack = (player.isSprinting() ? 1 : 0) + (entity instanceof EntityLivingBase ? EnchantmentHelper.getKnockbackModifier(player, (EntityLivingBase)entity) : 0);
+
+ if (tKnockcack > 0)
+ {
+ entity.addVelocity(-MathHelper.sin(player.rotationYaw * (float)Math.PI / 180.0F) * tKnockcack * 0.5F, 0.1D, MathHelper.cos(player.rotationYaw * (float)Math.PI / 180.0F) * tKnockcack * 0.5F);
+ player.motionX *= 0.6D;
+ player.motionZ *= 0.6D;
+ player.setSprinting(false);
+ }
+
+ if (tCriticalHit)
+ {
+ player.onCriticalHit(entity);
+ }
+
+ if (tMagicDamage > 0.0F)
+ {
+ player.onEnchantmentCritical(entity);
+ }
+
+ if (tDamage >= 18.0F)
+ {
+ player.triggerAchievement(AchievementList.overkill);
+ }
+
+ player.setLastAttacker(entity);
+
+ if (entity instanceof EntityLivingBase)
+ {
+ EnchantmentHelper.func_151384_a((EntityLivingBase)entity, player);
+ }
+
+ EnchantmentHelper.func_151385_b(player, entity);
+
+ if (entity instanceof EntityLivingBase)
+ {
+ player.addStat(StatList.damageDealtStat, Math.round(tDamage * 10.0F));
+ }
+ entity.hurtResistantTime = isWeaponMap.get(stack.getItemDamage())?0:1;
+ if(entity!=null && entity instanceof EntitySheep && !((EntityLivingBase) entity).isChild() && ((EntityLivingBase) entity).getHealth()<=0F && isWeaponMap.get(stack.getItemDamage()))
+ {
+ entity.entityDropItem(IHLUtils.getThisModItemStackWithSize("muttonLard", entity.worldObj.rand.nextInt(2)+1), 1F);
+ }
+ player.addExhaustion(0.3F);
+ IHLUtils.damageItemViaNBTTag(stack, 1);
+ }
+ }
+ }
+ if (stack.stackSize <= 0)
+ {
+ player.destroyCurrentEquippedItem();
+ }
+ return true;
+ }
+
+ @Override
+ public boolean showDurabilityBar(ItemStack stack)
+ {
+ return true;
+ }
+
+ @Override
+ public double getDurabilityForDisplay(ItemStack stack)
+ {
+ return ((double)IHLUtils.getDamageValueViaNBTTag(stack))/(double)IHLUtils.getMaxDamageValueViaNBTTag(stack);
+ }
+
+ @Override
+ public void onUpdate(ItemStack stack, World world, Entity entity, int slotIndex, boolean isCurrentItem)
+ {
+ if(stack.stackTagCompound!=null && !world.isRemote)
+ {
+ if(stack.stackTagCompound.hasKey("showTemperature"))
+ {
+ byte timerDelay = stack.stackTagCompound.getByte("showTemperature");
+ if(timerDelay>0)
+ {
+ timerDelay--;
+ if(Math.abs(stack.stackTagCompound.getDouble("playerPosX")-entity.prevPosX)>0.2d ||
+ Math.abs(stack.stackTagCompound.getDouble("playerPosY")-entity.prevPosY)>0.2d ||
+ Math.abs(stack.stackTagCompound.getDouble("playerPosZ")-entity.prevPosZ)>0.2d)
+ {
+ timerDelay=0;
+ }
+ stack.stackTagCompound.setByte("showTemperature",timerDelay);
+ if(timerDelay==0 && entity instanceof EntityPlayer)
+ {
+ ((EntityPlayer)entity).inventoryContainer.detectAndSendChanges();
+ }
+ }
+ }
+ }
+ }
+ private void setThermometerTemperature(ItemStack itemStack, EntityPlayer entityPlayer, long l)
+ {
+ if(itemStack.stackTagCompound==null)
+ {
+ itemStack.stackTagCompound=new NBTTagCompound();
+ }
+ itemStack.stackTagCompound.setLong("temperature", l);
+ itemStack.stackTagCompound.setByte("showTemperature", (byte) 60);
+ itemStack.stackTagCompound.setDouble("playerPosX", entityPlayer.prevPosX);
+ itemStack.stackTagCompound.setDouble("playerPosY", entityPlayer.prevPosY);
+ itemStack.stackTagCompound.setDouble("playerPosZ", entityPlayer.prevPosZ);
+ entityPlayer.inventoryContainer.detectAndSendChanges();
+
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public ItemMiniGUI getMiniGUI(GuiContainer gui, Slot slot)
+ {
+ if(slot.getHasStack() && slot.getStack().getItemDamage()==0 && slot.getStack().stackTagCompound!=null)
+ {
+ return new SetOfDiesMiniGUI(gui, slot);
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/ihl/items_blocks/ItemSubstance.java b/src/main/java/ihl/items_blocks/ItemSubstance.java new file mode 100644 index 0000000..507e65b --- /dev/null +++ b/src/main/java/ihl/items_blocks/ItemSubstance.java @@ -0,0 +1,413 @@ +package ihl.items_blocks;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.IC2Items;
+import ic2.api.recipe.RecipeInputOreDict;
+import ic2.api.recipe.Recipes;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.explosion.DetonatorMiniGUI;
+import ihl.interfaces.IItemHasMiniGUI;
+import ihl.interfaces.ItemMiniGUI;
+import ihl.utils.IHLUtils;
+import ihl.worldgen.ores.IHLFluid.IHLFluidType;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemFood;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.oredict.OreDictionary;
+
+public class ItemSubstance extends Item implements IItemHasMiniGUI {
+
+ private static Map<Integer, IIcon> iconMap = new HashMap<Integer, IIcon>();
+ private static Map<Integer, String> nameMap = new HashMap<Integer, String>();
+ private static Map<Integer, String> descriptionMap = new HashMap<Integer, String>();
+ public static ItemSubstance instance;
+
+ public ItemSubstance() {
+ super();
+ this.setMaxDamage(0);
+ this.setNoRepair();
+ this.setHasSubtypes(true);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setUnlocalizedName("ihlSimpleItem");
+ instance = this;
+ }
+
+ public static void init() {
+ Item breadWithLard = (new ItemFood(4, 0.1F, false)).setUnlocalizedName("breadWithLard")
+ .setTextureName(IHLModInfo.MODID + ":breadWithLard").setCreativeTab(IHLCreativeTab.tab);
+ GameRegistry.registerItem(breadWithLard, "food");
+ IHLUtils.registerLocally("breadWithLard", new ItemStack(breadWithLard, 1, 0));
+ ItemSubstance item = new ItemSubstance();
+ GameRegistry.registerItem(item, item.getUnlocalizedName());
+ Type[] var1 = Type.values();
+ for (int i = 0; i < var1.length; i++) {
+ nameMap.put(var1[i].damage, var1[i].unLocalizedName);
+ IHLUtils.registerLocally(var1[i].unLocalizedName, new ItemStack(item, 1, var1[i].damage));
+ if (var1[i].registerInOreDictionary) {
+ OreDictionary.registerOre(var1[i].oreRegistryName, new ItemStack(item, 1, var1[i].damage));
+ }
+ if (var1[i].description != null) {
+ descriptionMap.put(var1[i].damage, var1[i].description);
+ }
+ }
+ ItemStack emptyCell = IC2Items.getItem("cell");
+ IHLFluidType[] var2 = IHLFluidType.values();
+ for (int i = 0; i < var2.length; i++) {
+ IHLFluidType type = var2[i];
+ if (type.cell != null) {
+ OreDictionary.registerOre("cell" + type.fluidName.replaceFirst("fluid", ""), type.cell);
+ FluidContainerRegistry.registerFluidContainer(new FluidContainerData(
+ new FluidStack(type.fluid, FluidContainerRegistry.BUCKET_VOLUME), type.cell, emptyCell.copy()));
+ } else {
+ ItemStack filledCell = FluidContainerRegistry.fillFluidContainer(
+ new FluidStack(type.fluid, FluidContainerRegistry.BUCKET_VOLUME), emptyCell.copy());
+ if (filledCell == null && type.hasCell) {
+ ItemStack stack = new ItemStack(item, 1, type.damage);
+ nameMap.put(type.damage, type.cellName);
+ IHLUtils.registerLocally(type.cellName, stack);
+ type.cell = stack;
+ OreDictionary.registerOre("cell" + type.fluidName.replaceFirst("fluid", ""), type.cell);
+ FluidContainerRegistry.registerFluidContainer(new FluidContainerData(
+ new FluidStack(type.fluid, FluidContainerRegistry.BUCKET_VOLUME), stack, emptyCell.copy()));
+ } else {
+ type.cell = filledCell;
+ }
+ }
+ }
+ OreDictionary.registerOre("itemSalt", IHLUtils.getThisModItemStack("dustSalt"));
+ }
+
+ public static void postInit() {
+ Type[] var1 = Type.values();
+ for (int i = 0; i < var1.length; i++) {
+ if (var1[i].registerInOreDictionary) {
+ if (var1[i].oreRegistryName.contains("dustTiny")) {
+ RecipeInputOreDict stack = new RecipeInputOreDict(var1[i].oreRegistryName);
+ ;
+ Recipes.advRecipes.addShapelessRecipe(
+ IHLUtils.getOreDictItemStackWithSize(var1[i].oreRegistryName, 9),
+ new RecipeInputOreDict(var1[i].oreRegistryName.replace("dustTiny", "dust")));
+ Recipes.advRecipes.addShapelessRecipe(
+ IHLUtils.getOreDictItemStack(var1[i].oreRegistryName.replace("dustTiny", "dust")), stack,
+ stack, stack, stack, stack, stack, stack, stack, stack);
+ }
+ if (var1[i].oreRegistryName.contains("ingot")
+ && IHLUtils.hasOreDictionaryEntry(var1[i].oreRegistryName.replace("ingot", "dust"))) {
+ IHLUtils.addIC2MaceratorRecipe(var1[i].oreRegistryName,
+ IHLUtils.getOreDictItemStack(var1[i].oreRegistryName.replace("ingot", "dust")));
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tabs, List itemList) {
+ Type[] var1 = Type.values();
+ for (int i = 0; i < var1.length; i++) {
+ ItemStack stack = IHLUtils.getThisModItemStack(var1[i].unLocalizedName);
+ if (var1[i] == Type.Detonator) {
+ stack.stackTagCompound = new NBTTagCompound();
+ stack.stackTagCompound.setInteger("detonator_delay", 5);
+ }
+ itemList.add(stack);
+ }
+ IHLFluidType[] var2 = IHLFluidType.values();
+ for (int i = 0; i < var2.length; i++) {
+ if (var2[i].hasCell && var2[i].cell != null) {
+ itemList.add(var2[i].cell);
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register) {
+ Type[] var1 = Type.values();
+ for (int i = 0; i < var1.length; i++) {
+ iconMap.put(var1[i].damage, register.registerIcon(IHLModInfo.MODID + ":" + var1[i].textureName));
+ }
+ IHLFluidType[] var2 = IHLFluidType.values();
+ for (int i = 0; i < var2.length; i++) {
+ IHLFluidType type = var2[i];
+ if (var2[i].hasCell) {
+ iconMap.put(type.damage, register.registerIcon(IHLModInfo.MODID + ":" + type.cellName));
+ }
+ }
+
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int i) {
+ return iconMap.get(i);
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack) {
+ return nameMap.get(stack.getItemDamage());
+ }
+
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag) {
+ if (ItemSubstance.descriptionMap.containsKey(itemStack.getItemDamage())) {
+ info.add(ItemSubstance.descriptionMap.get(itemStack.getItemDamage()));
+ }
+ if (itemStack.stackTagCompound != null && itemStack.stackTagCompound.hasKey("detonator_delay")) {
+ info.add(StatCollector.translateToLocal("ihl.detonator_delay") + " "
+ + itemStack.stackTagCompound.getInteger("detonator_delay")
+ + StatCollector.translateToLocal("ihl.seconds"));
+ info.add(StatCollector.translateToLocal("ihl.detonatorHint"));
+ }
+ }
+
+ public enum Type {
+ dustMercuryFulminate(195, "dustMercuryFulminate", true, "Hg(CNO)\u2082"),
+ Detonator(194, "detonator"),
+ dustPentaerythritolTetranitrate(193, "dustPentaerythritolTetranitrate", true, "C(CH\u2082ONO\u2082)\u2084"),
+ DustPentaerythritol(192, "dustPentaerythritol", true, "C(CH\u2082OH)\u2084"),
+ DustPotassiumOxide(191, "dustPotassiumOxide", true, "K\u2082O"),
+ IngotPotassium(190, "ingotPotassium", true, "K"),
+ catalystIron(189, "catalystIron", false, "Fe (foam) + Al\u2082O\u2083 + K\u2082O"),
+ catalystIronOxide(188, "catalystIronOxide", false, "Fe\u2082O\u2083 + Al\u2082O\u2083 + K\u2082O"),
+ catalystRawIronOxide(187, "catalystRawIronOxide", false, "Fe\u2082O\u2083 + Al\u2082O\u2083 + K\u2082O"),
+ IronOxideCatalystMix(186, "dustIronOxideCatalystMix", false, "Fe\u2082O\u2083 + Al\u2082O\u2083 + K\u2082O"),
+ SodiumFormate(185, "dustSodiumFormate", true, "HCO\u2082Na"),
+ MercuryChloride(184, "dustMercuryChloride", true, "HgCl\u2082"),
+ CalciumAcetate(183, "dustCalciumAcetate", true, "Ca(CH\u2083COO)\u2082"),
+ TinySiliconDioxide(182, "dustTinySiliconDioxide", true, "SiO\u2082"),
+ TinyIronOxide(181, "dustTinyIronOxide", true, "Fe\u2082O\u2083"),
+ TinyManganeseOxide(180, "dustTinyManganeseOxide", true, "Mn\u2083O\u2084"),
+ TinyGypsum(179, "dustTinyGypsum", true, "CaSO\u2084\u00B72H\u2082O"),
+ SodiumZeoliteCoked(178, "dustSodiumZeoliteCoked", true, "Na[AlSi\u2083O\u2088]+C"),
+ SodiumZeolite(177, "dustSodiumZeolite", true, "Na[AlSi\u2083O\u2088]"),
+ SodiumAluminate(176, "dustSodiumAluminate", true, "NaAlO\u2082"),
+ SodiumHydroxide(175, "dustSodiumHydroxide", true, "NaOH"),
+ DustTinyTungsten(174, "dustTinyTungsten", true, "W"),
+ BauxiteDust(173, "dustBauxite", true, "Al\u2082O\u2083\u00B7H\u2082O"),
+ LithiumIngot(172, "ingotLithium", true, "Li"),
+ DustLithiumChloride(171, "dustLithiumChloride", true, "LiCl"),
+ CoalPlate(170, "plateCoal", true, "C (amorphic)"),
+ GraphitePlate(156, "plateGraphite", true, "C (graphite)"),
+ CoalRawPlate(155, "plateRawCoal"),
+ // RedstoneSensor(169,"redstoneSensor"),
+ // RedstoneEmitter(168,"redstoneEmitter"),
+ IncisorSteelDiamondCoated(167, "incisorSteelDiamondCoated"),
+ IncisorSteel(166, "incisorSteel"),
+ LampHolderPorcelain(165, "lampHolderPorcelain"),
+ LampHolderRawPorcelain(164, "lampHolderRawPorcelain"),
+ DustIridium(163, "dustIridium", true, "Ir"),
+ SiliconTiny(162, "dustTinySilicon", true, "Si"),
+ DustMagnesiumOxide(161, "dustMagnesiumOxide", true, "MgO"),
+ Silicon(160, "dustSilicon", true, "Si"),
+ Bischofite(159, "dustBischofite", true, "MgCl\u2082\u00B76H\u2082O"),
+ DustMagnesium(158, "dustMagnesium", true, "Mg"),
+ IngotMagnesium(157, "ingotMagnesium", true, "Mg"),
+ Ignitron(154, "ignitron"),
+ BoronCarbideElectrode(153, "stickBoronCarbide", true, "B\u2084C"),
+ LeadFoil(152, "foilLead", true, "Pb"),
+ DustLeadPlumbate(151, "dustLeadPlumbate", true, "Pb\u2082PbO\u2084"),
+ VacuumSwitch(150, "vacuumSwitch"),
+ HallSensor(149, "hallSensor"),
+ BatteryCells(148, "batteryCellsEbonite"),
+ // BatteryCellsRaw(147,"batteryCellsRawEbonite"),
+ MuscoviteGetinax(146, "plateMica", true, "KAl\u2082(AlSi\u2083O\u2081\u2080)(OH)\u2082"),
+ BoronCarbide(145, "dustBoronCarbide", true, "B\u2084C"),
+ DustBoricAcid(144, "dustBoricAcid", true, "H\u2083BO\u2083"),
+ DustDatolite(143, "dustDatolite", true, "H\u2082Ca\u2082B\u2082Si\u2082O\u2081\u2080"),
+ DustFerrite(142, "dustFerrite", true, "Li\u2082Fe\u2082O\u2084"),
+ RingFerrite(141, "ringFerrite", true, "Li\u2082Fe\u2082O\u2084"),
+ RingRawFerrite(140, "ringRawFerrite"),
+ LithiumOxide(139, "dustLithiumOxide", true, "Li\u2082O"),
+ SolderingAlloyDust(138, "dustSolderingAlloy", true, "Sn\u2089Sb"),
+ AntimonyTinyDust(137, "dustTinyAntimony", true, "Sb"),
+ InsulatorPorcelain(136, "insulatorPorcelain"),
+ InsulatorRawPorcelain(135, "insulatorRawPorcelain"),
+ AntimonyDust(134, "dustAntimony", true, "Sb"),
+ AntimonyOxide(133, "dustAntimonyOxide", true, "Sb\u2082O\u2083"),
+ StibniteDust(132, "dustStibnite", true, "Sb\u2082S\u2083"),
+ CrushedPurifiedStibnite(131, "crushedPurifiedStibnite", true, "Sb\u2082S\u2083"),
+ CrushedStibnite(130, "crushedStibnite", true, "Sb\u2082S\u2083"),
+ RingPorcelain(129, "ringPorcelain"),
+ RingRawPorcelain(128, "ringRawPorcelain"),
+ CopperFoil(127, "foilCopper", true, "Cu"),
+ CrushedPurifiedBauxite(126, "crushedPurifiedBauxite", true, "Al\u2082O\u2083\u00B7H\u2082O"),
+ CrushedBauxite(125, "crushedBauxite", true, "Al\u2082O\u2083�H\u2082O + SiO\u2082, Fe\u2082O\u2083"),
+ SodiumSulfide(124, "dustSodiumSulfide", true, "NaS"),
+ SodiumSulfate(123, "dustSodiumSulfate", true, "Na\u2082SO\u2084"),
+ dustWood(122, "dustWood", true),
+ Kenotron(121, "valveTube1C21P"),
+ HighVolatgeCapacitor(120, "highVoltageCapacitor"),
+ MuscovitePaper(119, "foilMica", true, "KAl\u2082(AlSi\u2083O\u2081\u2080)(OH)\u2082"),
+ MuscoviteDust(118, "dustMica", true, "KAl\u2082(AlSi\u2083O\u2081\u2080)(OH)\u2082"),
+ GaedesPumpBarrel(117, "gaedesPumpBarrelPorcelain"),
+ RawGaedesPumpBarrel(116, "gaedesPumpBarrelRawPorcelain"),
+ GlassDust(115, "dustGlass", true),
+ Gu81m(114, "gu-81m"),
+ TungstenFoil(113, "foilTungsten", true),
+ TungstenIngot(112, "ingotTungsten", true),
+ TungstenPlate(111, "plateTungsten", true),
+ TungstenHotPlate(110, "plateHotTungsten", true),
+ CrushedPurifiedCinnabar(109, "crushedPurifiedCinnabar", true, "HgS"),
+ CrushedCinnabar(108, "crushedCinnabar", true, "HgS"),
+ OvenRawPorcelain(107, "ovenRawPorcelain"),
+ TungstenDust(104, "dustTungsten", true, "W"),
+ ElectrolysisBathPorcelain(103, "electrolysisBathPorcelain"),
+ ElectrolysisBathRawPorcelain(102, "electrolysisBathRawPorcelain"),
+ Porcelain(99, "dustPorcelain", true),
+ FoilGold(98, "foilGold", true),
+ TungsticAcid(97, "dustTungsticAcid", true, "WO\u2083\u00B7H\u2082O"),
+ TurboCompressorSetOfMoldedParts(96, "turboCompressorSetOfMoldedPartsBronze"),
+ TungstenOxide(94, "dustTungstenOxide", true, "WO\u2083"),
+ CalciumTungstate(93, "dustCalciumTungstate", true, "CaWO\u2084"),
+ SodiumHydrogenSulfate(92, "dustSodiumHydrogenSulfate", true, "NaHSO\u2084"),
+ Salt(91, "dustSalt", true, "NaCl"),
+ CalciumChloride(90, "dustCalciumChloride", true, "CaCl\u2082"),
+ PotassiumSulphate(89, "dustPotassiumSulphate", true, "K\u2082SO\u2084"),
+ RockSalt(88, "dustRockSalt", true, "KCl"),
+ CrushedPurifiedGyuibnera(87, "crushedPurifiedGyubnera", true, "(Mn,Fe)WO\u2084 (5:1)"),
+ CrushedGyuibnera(86, "crushedGyubnera", true, "(Mn,Fe)WO\u2084 (5:1)"),
+ ManganeseOxide(85, "dustManganeseOxide", true, "Mn\u2083O\u2084"),
+ IronOxide(84, "dustIronOxide", true, "Fe\u2082O\u2083"),
+ SmallRound(83, "smallRoundSteel"),
+ SmallRoundPolished(82, "smallRoundPolishedSteel"),
+ RollingMachineSetOfMoldedParts(81, "rollingMachineSetOfMoldedPartsSteel"),
+ PistonCylinder(80, "pistonCylinderSteel"),
+ PipelineAccessoriesSteel(77, "pipelineAccessoriesSteel"),
+ DustTrona(76, "dustTrona", true, "Na\u2082CO\u2083�NaHCO\u2083\u00B72H\u2082O"),
+ HighPressureVessel(75, "highPressureVesselSteel"),
+ GasJet(74, "gasJetSteel"),
+ GasReducerSteel(73, "gasReducerSteel"),
+ HotSteelIngot(70, "ingotHotSteel", true),
+ BarD10Gold(69, "barD10Gold"),
+ CalciumCarbide(68, "dustCalciumCarbide", true, "CaC\u2082"),
+ foilRubber(67, "foilRubber", true, "(C\u2085H\u2088)n"),
+ Fabric(66, "fabric"),
+ ThinRubberWithSulfur(65, "foilRubberWithSulfur"),
+ Bucket_tarPitch(64, "bucket_tarPitch"),
+ DetonationSprayingMachineSetOfMoldedParts(63, "detonationSprayingMachineSetOfMoldedPartsBronze"),
+ SetOfPartsForLVElemotorSteel(62, "setOfPartsForLVElemotorSteel"),
+ // PlateNonVulcanizedRubber(60, "plateNonVulcanizedRubber"),
+ TapM10SteelHot(59, "tapM10x1SteelHot"),
+ DiceM10SteelHot(58, "diceM10x1SteelHot"),
+ NailSteel(57, "nailSteel"),
+ NutM10x1Steel(56, "nutM10x1Steel"),
+ GraverSteel(55, "graverSteel"),
+ GraverSteelHot(54, "graverSteelHot"),
+ DrillSteel(53, "drillSteel"),
+ DrillSteelHot(52, "drillSteelHot"),
+ BarD10Steel(51, "barD10Steel"),
+ BarD10SteelHot(50, "barD10SteelHot"),
+ SawBladeSteel(49, "sawBladeSteel"),
+ SawBladeSteelHot(48, "sawBladeSteelHot"),
+ SawBladeSteelHardened(47, "sawBladeSteelHardened"),
+ LinerIronGraphite(46, "linerIronGraphite"),
+ LinerIronGraphiteHot(45, "linerIronGraphiteHot"),
+ LinerIronGraphiteGreased(44, "linerIronGraphiteGreased"),
+ BoltM10x1Steel(43, "boltM10x1Steel"),
+ ExtruderSetOfMoldedParts(42, "extruderSetOfMoldedPartsSteel"),
+ MeshGlass(41, "meshGlass"),
+ TapM10Steel(39, "tapM10x1Steel"),
+ DiceM10Steel(38, "diceM10x1Steel"),
+ BlankSetOfFilesSteel(37, "blankSetOfFilesSteel"),
+ HandDrillSetOfMoldedPartsBronze(36, "handDrillSetOfMoldedPartsBronze"),
+ ViseSetOfMoldedPartsSteel(34, "viseSetOfMoldedPartsSteel"),
+ DustIrongraphite(33, "dustIrongraphite", true),
+ PlateSteelHot(32, "plateHotSteel"),
+ Chisel(31, "blankChiselSteel"),
+ CrucibleMixture(30, "crucibleMixture"),
+ GraphiteDust(29, "dustGraphite", true, "C (graphite)"),
+ BrickDust(28, "dustBrick", true),
+ CalciumSoap(27, "ingotCalciumSoap"),
+ Stearin(26, "ingotStearin"),
+ MuttonLard(25, "muttonLard"),
+ CarvingKnifeBronze(24, "carvingKnifeBronze"),
+ DehydratedGypsum(23, "dustDehydratedGypsum"),
+ BlankNeedleFileSteel(22, "blankNeedleFileSteel"),
+ HammerHead(21, "toolHeadHammerSmallSteel"),
+ SpringSteel(19, "springSteel"),
+ CoalElectrodePremix(18, "dustCoalElectrodePremix"),
+ rawCoalElectrode(17, "stickCoalElectrodePremix"),
+ FoilSteel(16, "foilSteel", true),
+ StickSteel(15, "stickSteel", true),
+ Quicklime(14, "dustQuicklime", true, "CaO"),
+ Calcite(13, "dustCalcite", true, "CaCO\u2082"),
+ Gypsum(12, "dustGypsum", true, "CaSO\u2084\u00B72H\u2082O"),
+ PotassiumFeldspar(11, "dustPotassiumFeldspar", true, "K[AlSi\u2083O\u2088]"),
+ Apatite(10, "gemApatite", true, "Ca\u2085[PO\u2084]\u2083(F,Cl,OH)"),
+ Saltpeter(9, "dustSaltpeter", true, "KNO\u2083"),
+ TarPitch(8, "ingotTarPitch", true),
+ nuggetTarPitch(7, "nuggetTarPitch", true),
+ Graphite_Electrode(6, "stickGraphite", true, "C (graphite)"),
+ Coal_Electrode(5, "stickCoal", true, "C (amorphic)"),
+ Carborundum(4, "dustCarborundum", true, "SiC"),
+ IridiumAndSodiumOxide(3, "dustIridiumAndSodiumOxide", true, "IrO\u2082 + Na\u2082O"),
+ PlatinumGroupSludge(2, "dustPlatinumGroupSludge", true),
+ TinyPlatinumGroupSludge(1, "dustTinyPlatinumGroupSludge", true),
+ SodiumPeroxide(0, "dustSodiumPeroxide", true, "Na\u2082O\u2082");
+ Type(int damage1, String unlocalizedName1) {
+ damage = damage1;
+ textureName = unLocalizedName = unlocalizedName1;
+ }
+
+ Type(int damage1, String unlocalizedName1, boolean registerInOreDictionary1) {
+ damage = damage1;
+ textureName = oreRegistryName = unLocalizedName = unlocalizedName1;
+ registerInOreDictionary = registerInOreDictionary1;
+ }
+
+ Type(int damage1, String unlocalizedName1, boolean registerInOreDictionary1, String description1) {
+ damage = damage1;
+ textureName = oreRegistryName = unLocalizedName = unlocalizedName1;
+ registerInOreDictionary = registerInOreDictionary1;
+ description = description1;
+ }
+
+ Type(int damage1, String unlocalizedName1, boolean registerInOreDictionary1, String description1,
+ String textureName1) {
+ damage = damage1;
+ oreRegistryName = unLocalizedName = unlocalizedName1;
+ registerInOreDictionary = registerInOreDictionary1;
+ description = description1;
+ textureName = textureName1;
+ }
+
+ public int damage;
+ public String unLocalizedName;
+ public String oreRegistryName;
+ public String description;
+ public String textureName;
+ public boolean registerInOreDictionary = false;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public ItemMiniGUI getMiniGUI(GuiContainer gui, Slot slot) {
+ if (slot.getHasStack() && slot.getStack().getItemDamage() == Type.Detonator.damage
+ && slot.getStack().stackTagCompound != null) {
+ return new DetonatorMiniGUI(gui, slot);
+ }
+ return null;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/items_blocks/MachineBaseBlock.java b/src/main/java/ihl/items_blocks/MachineBaseBlock.java new file mode 100644 index 0000000..aef567c --- /dev/null +++ b/src/main/java/ihl/items_blocks/MachineBaseBlock.java @@ -0,0 +1,662 @@ +package ihl.items_blocks;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.item.tool.ItemToolCutter;
+import ihl.IHLCreativeTab;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import ihl.flexible_cable.BatterySwitchUnitTileEntity;
+import ihl.flexible_cable.IronWorkbenchTileEntity;
+import ihl.flexible_cable.RectifierTransformerUnitTileEntity;
+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;
+import ihl.processing.chemistry.FractionatorCoverTileEntity;
+import ihl.processing.chemistry.FractionatorSectionTileEntity;
+import ihl.processing.chemistry.GaedesMercuryRotaryPumpTileEntity;
+import ihl.processing.chemistry.LabElectrolyzerTileEntity;
+import ihl.processing.chemistry.LeadOvenTileEntity;
+import ihl.processing.chemistry.LoomTileEntity;
+import ihl.processing.chemistry.PaperMachineTileEntity;
+import ihl.processing.chemistry.RefluxCondenserTileEntity;
+import ihl.processing.chemistry.SolarEvaporatorTileEntity;
+import ihl.processing.metallurgy.AchesonFurnanceTileEntity;
+import ihl.processing.metallurgy.CoilerTileEntity;
+import ihl.processing.metallurgy.DetonationSprayingMachineTileEntity;
+import ihl.processing.metallurgy.ExtruderTileEntity;
+import ihl.processing.metallurgy.GasWeldingStationTileEntity;
+import ihl.processing.metallurgy.ImpregnatingMachineTileEntity;
+import ihl.processing.metallurgy.LathePart1TileEntity;
+import ihl.processing.metallurgy.LathePart2TileEntity;
+import ihl.processing.metallurgy.MuffleFurnanceTileEntity;
+import ihl.processing.metallurgy.RollingMachinePart1TileEntity;
+import ihl.processing.metallurgy.RollingMachinePart2TileEntity;
+import ihl.processing.metallurgy.VulcanizationExtrudingMoldTileEntity;
+import ihl.processing.metallurgy.WireMillTileEntity;
+import ihl.processing.metallurgy.WoodenRollingMachinePart1TileEntity;
+import ihl.processing.metallurgy.WoodenRollingMachinePart2TileEntity;
+import ihl.utils.IHLUtils;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class MachineBaseBlock extends Block implements ITileEntityProvider {
+
+ public MachineType type;
+ private static List<MachineBaseBlock> instances = new ArrayList<MachineBaseBlock>();
+
+ @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, dosingPumpBack, dosingPumpLeftSide, dosingPumpRightSide,
+ dosingPumpTop, dosingPumpFront, solarEvaporatorSide;
+
+ 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);
+ }
+
+ @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);
+ 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) {
+ TileEntity te = world.getTileEntity(x, y, z);
+ if (te != null) {
+ if (te instanceof IEnergyNetNode) {
+ IEnergyNetNode ate = (IEnergyNetNode) te;
+ ate.removeAttachedChains();
+ }
+ if (te instanceof IMultiPowerCableHolder) {
+ IMultiPowerCableHolder ate = (IMultiPowerCableHolder) te;
+ ate.removeAttachedChains();
+ }
+ 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)));
+ }
+ }
+ }
+ }
+ super.onBlockPreDestroy(world, x, y, z, meta);
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB aabb, List list,
+ Entity entity) {
+ float height = 1f;
+ switch (this.type) {
+ case SolarEvaporator:
+ height = 0.5f;
+ 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);
+ this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1F, height, 1.0F);
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, height, 0.1F);
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ this.setBlockBounds(0.9F, 0.0F, 0.0F, 1.0F, height, 1.0F);
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ this.setBlockBounds(0.0F, 0.0F, 0.9F, 1.0F, height, 1.0F);
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ this.setBlockBoundsForItemRender();
+ break;
+ default:
+ super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity);
+ break;
+ }
+ }
+
+ @Override
+ public void setBlockBoundsForItemRender() {
+ if(this.type.equals(MachineType.SolarEvaporator)){
+ this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5f, 1.0F);
+ }
+ else {
+ 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 < var1.length; i++) {
+ if (!var1[i].unlocalizedName.equalsIgnoreCase(IHLMod.config.preventMachineBlockRegistrationName)) {
+ GameRegistry.registerBlock(new MachineBaseBlock(var1[i]), IHLItemBlock.class, var1[i].unlocalizedName);
+ GameRegistry.registerTileEntity(var1[i].teclass, var1[i].unlocalizedName);
+ }
+ }
+ IHLUtils.getThisModBlock("tubBronze").setBlockTextureName("tubBronzeIcon");
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag) {
+ if (this.type.itemDroppedOnBlockDestroy != null) {
+ this.dropBlockAsItem(world, x, y, z, this.type.itemDroppedOnBlockDestroy.copy());
+ } else {
+ super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag);
+ }
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ TileEntity newTE = null;
+ try {
+ newTE = (TileEntity) type.teclass.newInstance();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ return newTE;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister) {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenSide");
+ this.textureBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenBack");
+ this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenSide");
+ this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":brickOvenTop");
+ this.textureFrontMuffleFurnance = par1IconRegister.registerIcon(IHLModInfo.MODID + ":muffleOvenFront");
+ this.textureTopAchesonFurnance = par1IconRegister.registerIcon(IHLModInfo.MODID + ":achesonOvenTop");
+ this.textureTopGoldFurnace = par1IconRegister.registerIcon(IHLModInfo.MODID + ":porcelainFurnaceTop");
+ this.textureFrontGoldFurnace = par1IconRegister.registerIcon(IHLModInfo.MODID + ":porcelainFurnaceFront");
+ this.textureSideGoldFurnace = par1IconRegister.registerIcon(IHLModInfo.MODID + ":porcelainFurnaceSide");
+ this.textureLeftMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsLeft");
+ this.textureTopMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsTop");
+ this.textureRightMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsRight");
+ this.textureFrontMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsFront");
+ this.textureBackMachineCasing = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fiberglassSpinneretsBack");
+ this.textureFrontCryogenicDistiller = par1IconRegister
+ .registerIcon(IHLModInfo.MODID + ":cryogenicDistillerOxygenSide");
+ this.textureTopCryogenicDistiller = par1IconRegister
+ .registerIcon(IHLModInfo.MODID + ":cryogenicDistillerNitrogenSide");
+ this.textureBackCryogenicDistiller = par1IconRegister
+ .registerIcon(IHLModInfo.MODID + ":cryogenicDistillerInputSide");
+ this.textureFrontChemicalReactor = par1IconRegister
+ .registerIcon(IHLModInfo.MODID + ":chemicalReactorOutputSide");
+ this.textureFrontPaperMachine = par1IconRegister.registerIcon(IHLModInfo.MODID + ":paperMachineFront");
+ this.bronzeTubTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tubBronzeTop");
+ this.bronzeTubSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tubBronzeSide");
+ this.steel = par1IconRegister.registerIcon(IHLModInfo.MODID + ":steel");
+ this.redPaint = par1IconRegister.registerIcon(IHLModInfo.MODID + ":redPaint");
+ this.greenPaint = par1IconRegister.registerIcon(IHLModInfo.MODID + ":greenPaint");
+ this.rubberInsulatedCase = par1IconRegister.registerIcon(IHLModInfo.MODID + ":rubberInsulatedCase");
+ this.powerPort = par1IconRegister.registerIcon(IHLModInfo.MODID + ":powerPort");
+ this.dosingPumpBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":dosingPumpBack");
+ this.dosingPumpLeftSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":dosingPumpLeft");
+ this.dosingPumpRightSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":dosingPumpRight");
+ this.dosingPumpTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":dosingPumpTop");
+ this.dosingPumpFront = par1IconRegister.registerIcon(IHLModInfo.MODID + ":dosingPumpFront");
+ this.solarEvaporatorSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solarEvaporatorSide");
+ }
+
+ @Override
+ public boolean hasTileEntity(int metadata) {
+ return true;
+ }
+
+ @Override
+ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float pos_x,
+ float pos_y, float pos_z) {
+ TileEntity te = world.getTileEntity(x, y, z);
+ if (IC2.platform.isSimulating()) {
+ if (te instanceof DetonationSprayingMachineTileEntity && player.getCurrentEquippedItem() != null
+ && player.getCurrentEquippedItem().getItem() == Items.flint_and_steel) {
+ ((DetonationSprayingMachineTileEntity) te).operate();
+ return true;
+ }
+ if (te instanceof LathePart2TileEntity) {
+ LathePart2TileEntity lte = ((LathePart2TileEntity) te);
+ te = world.getTileEntity(x - ForgeDirection.getOrientation(lte.getFacing()).offsetX,
+ y - ForgeDirection.getOrientation(lte.getFacing()).offsetY,
+ z - ForgeDirection.getOrientation(lte.getFacing()).offsetZ);
+ }
+ if (te instanceof RollingMachinePart2TileEntity) {
+ RollingMachinePart2TileEntity lte = ((RollingMachinePart2TileEntity) te);
+ te = world.getTileEntity(x - ForgeDirection.getOrientation(lte.getFacing()).offsetX,
+ y - ForgeDirection.getOrientation(lte.getFacing()).offsetY,
+ z - ForgeDirection.getOrientation(lte.getFacing()).offsetZ);
+ }
+ if (te instanceof WoodenRollingMachinePart2TileEntity) {
+ WoodenRollingMachinePart2TileEntity lte = ((WoodenRollingMachinePart2TileEntity) te);
+ te = world.getTileEntity(x - ForgeDirection.getOrientation(lte.getFacing()).offsetX,
+ y - ForgeDirection.getOrientation(lte.getFacing()).offsetY,
+ z - ForgeDirection.getOrientation(lte.getFacing()).offsetZ);
+ }
+ if (te instanceof RectifierTransformerUnitTileEntity) {
+ RectifierTransformerUnitTileEntity rtu = (RectifierTransformerUnitTileEntity) te;
+ if (player.getCurrentEquippedItem() == null) {
+ if (IC2.keyboard.isModeSwitchKeyDown(player)) {
+ rtu.switchModeDown();
+ } else {
+ rtu.switchModeUp();
+ }
+ IC2.platform.messagePlayer(player, "ic2.tooltip.mode",
+ new Object[] { " Voltage output was set to x" + rtu.mode });
+ }
+ }
+ if (te instanceof IEnergyNetNode) {
+ IEnergyNetNode node = (IEnergyNetNode) te;
+ if (player.getCurrentEquippedItem() != null
+ && player.getCurrentEquippedItem().getItem() instanceof ItemToolCutter) {
+ node.removeAttachedChains();
+ }
+ }
+ }
+ return te instanceof IHasGui
+ ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, (IHasGui) te) : true) : false;
+ }
+
+ /**
+ * Called when the block is placed in the world.
+ */
+ @Override
+ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack) {
+ TileEntity t = world.getTileEntity(x, y, z);
+ if (t != null && t instanceof IWrenchable) {
+ ((IWrenchable) t).setFacing(IHLUtils.getFacingFromPlayerView(player, false));
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
+ int facing = 3;
+ TileEntity te = world.getTileEntity(x, y, z);
+ if (te instanceof IWrenchable) {
+ IWrenchable tebh = (IWrenchable) te;
+ facing = tebh.getFacing();
+ }
+ return this.getIconFromFacing(facing, side);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta) {
+ if (this.type == MachineType.IronWorkbench) {
+ return this.steel;
+ }
+ if (this.type == MachineType.RectifierTransformerUnit) {
+ switch (side) {
+ case 0:
+ return this.bronzeTubSide;
+ case 1:
+ return this.textureSideGoldFurnace;
+ case 2:
+ return this.redPaint;
+ case 3:
+ return this.greenPaint;
+ case 4:
+ return this.rubberInsulatedCase;
+ case 5:
+ return this.powerPort;
+ }
+ }
+ return this.getIconFromFacing(3, side);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromFacing(int facing, int side) {
+ int mask[] = { 0, 1, 2, 3, 4, 5, 1, 0, 3, 2, 4, 5, 2, 3, 0, 1, 4, 5, 2, 3, 1, 0, 4, 5, 2, 3, 5, 4, 0, 1, 2, 3,
+ 4, 5, 1, 0 };
+ switch (this.type) {
+ case RefluxCondenser:
+ return this.steel;
+ case RectifierTransformerUnit:
+ return this.bronzeTubSide;
+ case IronWorkbench:
+ return this.steel;
+ default:
+ }
+ switch (mask[facing * 6 + side]) {
+ case 0:
+ switch (this.type) {
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case SolarEvaporator:
+ return this.solarEvaporatorSide;
+ case AchesonFurnace:
+ return this.blockIcon;
+ case MuffleFurnace:
+ return this.textureFrontMuffleFurnance;
+ case LeadOven:
+ return this.textureFrontGoldFurnace;
+ case WireMill:
+ return this.textureFrontMachineCasing;
+ case LabElectrolyzer:
+ return this.textureTopMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureTopMachineCasing;
+ case ChemicalReactor:
+ return this.textureFrontChemicalReactor;
+ case CryogenicDistiller:
+ return this.textureFrontCryogenicDistiller;
+ case PaperMachine:
+ return this.textureFrontPaperMachine;
+ case DosingPump:
+ return this.dosingPumpFront;
+ default:
+ break;
+ }
+ case 1:
+ switch (this.type) {
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case SolarEvaporator:
+ return this.solarEvaporatorSide;
+ case LeadOven:
+ return this.textureSideGoldFurnace;
+ case WireMill:
+ return this.textureBackMachineCasing;
+ case CryogenicDistiller:
+ return this.textureBackCryogenicDistiller;
+ case PaperMachine:
+ return this.textureBackCryogenicDistiller;
+ case LabElectrolyzer:
+ return this.textureBackCryogenicDistiller;
+ case FluidizedBedReactor:
+ return this.textureBackCryogenicDistiller;
+ case ChemicalReactor:
+ return this.textureBackCryogenicDistiller;
+ case DosingPump:
+ return this.dosingPumpBack;
+ default:
+ return this.textureBack;
+ }
+
+ case 2:
+ switch (this.type) {
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case SolarEvaporator:
+ return this.solarEvaporatorSide;
+ case LeadOven:
+ return this.textureSideGoldFurnace;
+ case WireMill:
+ return this.textureBackMachineCasing;
+ case CryogenicDistiller:
+ return this.textureBackMachineCasing;
+ case PaperMachine:
+ return this.textureBackMachineCasing;
+ case LabElectrolyzer:
+ return this.textureBackMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureBackMachineCasing;
+ case ChemicalReactor:
+ return this.textureBackMachineCasing;
+ case DosingPump:
+ return this.dosingPumpBack;
+ default:
+ return this.textureTop;
+ }
+ case 3:
+ switch (this.type) {
+ case BronzeTub:
+ case SolarEvaporator:
+ return this.bronzeTubTop;
+ case AchesonFurnace:
+ return this.textureTopAchesonFurnance;
+ case MuffleFurnace:
+ return this.textureTop;
+ case LeadOven:
+ return this.textureTopGoldFurnace;
+ case WireMill:
+ return this.textureTopMachineCasing;
+ case CryogenicDistiller:
+ return this.textureTopCryogenicDistiller;
+ case PaperMachine:
+ return this.textureTopMachineCasing;
+ case LabElectrolyzer:
+ return this.textureTopMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureTopMachineCasing;
+ case ChemicalReactor:
+ return this.textureTopMachineCasing;
+ case DosingPump:
+ return this.dosingPumpTop;
+ default:
+ return this.textureTop;
+ }
+ case 4:
+ switch (this.type) {
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case SolarEvaporator:
+ return this.solarEvaporatorSide;
+ case LeadOven:
+ return this.textureSideGoldFurnace;
+ case WireMill:
+ return this.textureRightMachineCasing;
+ case CryogenicDistiller:
+ return this.textureRightMachineCasing;
+ case PaperMachine:
+ return this.textureRightMachineCasing;
+ case LabElectrolyzer:
+ return this.textureRightMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureRightMachineCasing;
+ case ChemicalReactor:
+ return this.textureRightMachineCasing;
+ case DosingPump:
+ return this.dosingPumpRightSide;
+ default:
+ return this.textureSide;
+ }
+ case 5:
+ switch (this.type) {
+ case BronzeTub:
+ return this.bronzeTubSide;
+ case SolarEvaporator:
+ return this.solarEvaporatorSide;
+ case LeadOven:
+ return this.textureSideGoldFurnace;
+ case CryogenicDistiller:
+ return this.textureLeftMachineCasing;
+ case PaperMachine:
+ return this.textureLeftMachineCasing;
+ case WireMill:
+ return this.textureLeftMachineCasing;
+ case ChemicalReactor:
+ return this.textureLeftMachineCasing;
+ case LabElectrolyzer:
+ return this.textureLeftMachineCasing;
+ case FluidizedBedReactor:
+ return this.textureLeftMachineCasing;
+ case DosingPump:
+ return this.dosingPumpLeftSide;
+ default:
+ return this.textureSide;
+ }
+ default:
+ return this.textureSide;
+ }
+ }
+
+ @Override
+ public boolean onBlockEventReceived(World world, int x, int y, int z, int metadata, int flag) {
+ return true;
+ }
+
+ @Override
+ public boolean canProvidePower() {
+ return true;
+ }
+
+ @Override
+ public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int metadata) {
+ return this.isProvidingWeakPower(world, x, y, z, metadata);
+ }
+
+ public enum MachineType {
+ SolarEvaporator("solarEvaporator", SolarEvaporatorTileEntity.class, false, true, null),
+ 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<? extends TileEntity> teclass1, boolean isNormalBlock1,
+ ItemStack itemDroppedOnBlockDestroy1) {
+ unlocalizedName = unlocalizedName1;
+ teclass = teclass1;
+ isNormalBlock = isNormalBlock1;
+ if (isNormalBlock) {
+ specialBlockRendererId = 0;
+ } else {
+ specialBlockRendererId = -2;
+ }
+ itemDroppedOnBlockDestroy = itemDroppedOnBlockDestroy1;
+ }
+
+ MachineType(String unlocalizedName1, Class<? extends TileEntity> teclass1, boolean isNormalBlock1,
+ boolean hasSpecialBlockRenderer1, ItemStack itemDroppedOnBlockDestroy1) {
+ unlocalizedName = unlocalizedName1;
+ teclass = teclass1;
+ isNormalBlock = isNormalBlock1;
+ hasSpecialBlockRenderer = hasSpecialBlockRenderer1;
+ itemDroppedOnBlockDestroy = itemDroppedOnBlockDestroy1;
+
+ }
+
+ public String unlocalizedName;
+ Class<? extends TileEntity> teclass;
+ boolean isNormalBlock = true;
+ boolean hasSpecialBlockRenderer = false;
+ int specialBlockRendererId = -2;
+ ItemStack itemDroppedOnBlockDestroy;
+ }
+
+ @Override
+ 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;
+ }
+
+ @Override
+ public boolean renderAsNormalBlock() {
+ return this.type.isNormalBlock;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public IIcon getAdditionalIconsForBlockRenderer(int flag) {
+ switch (this.type) {
+ case SolarEvaporator:
+ return this.solarEvaporatorSide;
+ case BronzeTub:
+ return this.bronzeTubSide;
+ default:
+ return this.blockIcon;
+ }
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/items_blocks/RecipeInputs.java b/src/main/java/ihl/items_blocks/RecipeInputs.java new file mode 100644 index 0000000..6b49ce2 --- /dev/null +++ b/src/main/java/ihl/items_blocks/RecipeInputs.java @@ -0,0 +1,25 @@ +package ihl.items_blocks;
+
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeInputOreDict;
+import ihl.utils.IHLUtils;
+
+public class RecipeInputs
+{
+ public static IRecipeInput cutter = new RecipeInputOreDict("craftingToolWireCutter");
+ public static IRecipeInput saw = new RecipeInputOreDict("craftingToolSaw");
+ public static IRecipeInput file = new RecipeInputOreDict("craftingToolFile");
+ public static IRecipeInput vise = new RecipeInputItemStack(IHLUtils.getThisModItemStack("viseSteel"));
+ public static IRecipeInput plateSteel = new RecipeInputOreDict("plateSteel");
+ public static IRecipeInput hammer = new RecipeInputOreDict("craftingToolHardHammer");
+
+ public static IRecipeInput get(String name, int amount)
+ {
+ return new RecipeInputItemStack(IHLUtils.getThisModItemStackWithSize(name,amount),amount);
+ }
+ public static IRecipeInput get(String name)
+ {
+ return new RecipeInputItemStack(IHLUtils.getThisModItemStack(name));
+ }
+}
diff --git a/src/main/java/ihl/metallurgy/constants/Details.java b/src/main/java/ihl/metallurgy/constants/Details.java new file mode 100644 index 0000000..80c715c --- /dev/null +++ b/src/main/java/ihl/metallurgy/constants/Details.java @@ -0,0 +1,55 @@ +package ihl.metallurgy.constants;
+
+import ihl.IHLMod;
+
+public enum Details {
+ block(1296),
+ highPressureVessel(432),
+ turboCompressorSetOfMoldedParts(576),
+ rollingMachineSetOfMoldedParts(576),
+ gasJet(36),
+ setOfPartsForLVElemotor(288),
+ pipelineAccessories(288),
+ detonationSprayingMachineSetOfMoldedParts(432),
+ blankChisel(36),
+ carvingKnife(36),
+ machineCasingSetOfMoldedParts(288),
+ polishingPucks(288),
+ extruderSetOfMoldedParts(288),
+ handDrillSetOfMoldedParts(72),
+ barD10(1),
+ latheSetOfMoldedParts(144),
+ viseSetOfMoldedParts(144),
+ ingot(144),
+ tub(144),
+ nugget(16),
+ screw(16),
+ round(16),
+ gear(576),
+ bolt(18),
+ stick(72),
+ frameGt(288),
+ toolHeadHammer(864),
+ toolHeadHammerSmall(72),
+ toolTinSnipsParts(72),
+ ring(36),
+ toolHeadPickaxe(432),
+ gearSmall(144),
+ nozzle(864),
+ wire(48);
+ Details(int moltenAmount1)
+ {
+ IHLMod.moltenAmounts.put(this.name(), moltenAmount1);
+ }
+ public static int getMeltingFluidAmount(String name)
+ {
+ if(IHLMod.moltenAmounts.containsKey(name))
+ {
+ return IHLMod.moltenAmounts.get(name);
+ }
+ else
+ {
+ return 0;
+ }
+ }
+}
diff --git a/src/main/java/ihl/metallurgy/constants/ElectricConductor.java b/src/main/java/ihl/metallurgy/constants/ElectricConductor.java new file mode 100644 index 0000000..e3412ab --- /dev/null +++ b/src/main/java/ihl/metallurgy/constants/ElectricConductor.java @@ -0,0 +1,49 @@ +package ihl.metallurgy.constants;
+
+public enum ElectricConductor {
+ Silver(158,1000),
+ Copper(175,100),
+ Gold(220,100),
+ Aluminum(270,100),
+ Magnesium(440,100),
+ Iridium(474,1000),
+ Molybdenum(540,1000),
+ Tungsten(550,5000),
+ Zinc(600,100),
+ Nickel(730,5000),
+ Bronze(990,100),
+ Iron(1000,5000),
+ Platinum(1080,5000),
+ Tin(1130,100),
+ Steel(1300,5000),
+ Lead(2080,100),
+ Antimony(3400,5000),
+ Manganese(4300,5000),
+ Constantan(5000,5000),
+ Titan(6000,5000),
+ Mercury(9540,-10),
+ Castiron(10000,5000),
+ Nichrome(11200,6000),
+ Bismuth(11800,5000),
+ Graphite(80000,10000),
+ Coal(400000,10000),
+ Uran(29000000,5000);
+ ElectricConductor(int resistivity1, int meltingPoint1)//Ohm*m *10^10
+ {
+ resistivity=resistivity1;
+ meltingPoint=meltingPoint1;
+ }
+ public final long resistivity;
+ public final int meltingPoint;
+ public static long getResistivity(String name)
+ {
+ if(ElectricConductor.valueOf(name)==null)
+ {
+ return 0;
+ }
+ else
+ {
+ return ElectricConductor.valueOf(name).resistivity;
+ }
+ }
+}
diff --git a/src/main/java/ihl/metallurgy/constants/Insulation.java b/src/main/java/ihl/metallurgy/constants/Insulation.java new file mode 100644 index 0000000..cd8f8c9 --- /dev/null +++ b/src/main/java/ihl/metallurgy/constants/Insulation.java @@ -0,0 +1,40 @@ +package ihl.metallurgy.constants;
+
+public enum Insulation {
+ TarPitch(10000,6000),
+ RawRubber(10000,6000),
+ PVC(18000,20000),
+ Rubber(20000,10000),
+ Plastic(40000,35000),//Polyethylene
+ XPVC(30000,100000);
+ Insulation(int maxVoltagePermm1, int maxVoltageCap1)
+ {
+ maxVoltagePermm=maxVoltagePermm1;//V/mm
+ maxVoltageCap=maxVoltageCap1;
+ }
+ public final int maxVoltagePermm;
+ public final int maxVoltageCap;
+ public static int getMaxVoltagePermm(String name)
+ {
+ if(Insulation.valueOf(name)==null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Insulation.valueOf(name).maxVoltagePermm;
+ }
+ }
+ public static int getMaxVoltageCap(String name)
+ {
+ if(Insulation.valueOf(name)==null)
+ {
+ return 0;
+ }
+ else
+ {
+ return Insulation.valueOf(name).maxVoltageCap;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/model/CableHolderSelectionBoxSpecialRenderer.java b/src/main/java/ihl/model/CableHolderSelectionBoxSpecialRenderer.java new file mode 100644 index 0000000..e878a78 --- /dev/null +++ b/src/main/java/ihl/model/CableHolderSelectionBoxSpecialRenderer.java @@ -0,0 +1,42 @@ +package ihl.model; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.flexible_cable.AnchorTileEntity; +import ihl.interfaces.ISelectionBoxSpecialRenderer; +import ihl.utils.IHLUtils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MovingObjectPosition; + +@SideOnly(value=Side.CLIENT) +public class CableHolderSelectionBoxSpecialRenderer implements ISelectionBoxSpecialRenderer +{ + @Override + public void drawSelectionBox(EntityPlayer player, ItemStack currentItem, MovingObjectPosition movingObjectPosition, float partialTick) + { + AnchorTileEntity ate = (AnchorTileEntity) Minecraft.getMinecraft().theWorld.getTileEntity(movingObjectPosition.blockX, movingObjectPosition.blockY, movingObjectPosition.blockZ); + short facing = IHLUtils.getFacingFromPlayerView(player, true); + double[] portPos = ate.energyNetNodes[facing].getPortPos(player); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.8F); + GL11.glLineWidth(2.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(false); + double offsetX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTick; + double offsetY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTick; + double offsetZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTick; + double size=0.1d; + RenderGlobal.drawOutlinedBoundingBox(AxisAlignedBB.getBoundingBox(portPos[0]-size, portPos[1]-size, portPos[2]-size, portPos[0]+size, portPos[1]+size, portPos[2]+size).getOffsetBoundingBox(-offsetX, -offsetY, -offsetZ), -1); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + } +} diff --git a/src/main/java/ihl/model/FlexibleCableItemRender.java b/src/main/java/ihl/model/FlexibleCableItemRender.java new file mode 100644 index 0000000..e11a253 --- /dev/null +++ b/src/main/java/ihl/model/FlexibleCableItemRender.java @@ -0,0 +1,178 @@ +package ihl.model;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.items_blocks.FlexibleCableItem;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityClientPlayerMP;
+import net.minecraft.client.renderer.GLAllocation;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.entity.RenderPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.client.IItemRenderer;
+import net.minecraftforge.common.util.ForgeDirection;
+
+@SideOnly(value=Side.CLIENT)
+public class FlexibleCableItemRender implements IItemRenderer {
+ private ModelTube model;
+ private ModelTube modelThin;
+ private ModelTube modelLong;
+ private ModelTube modelThinLong;
+ private final int segmentsAmount = 19;
+ private final float spiralStepAngle = 1f;
+ private final float scale = 1 / 32f;
+ private final int[] displayListCache = new int[4];
+
+ public FlexibleCableItemRender() {
+ float vOffset = 16f;
+ int longFragmensSize = 24;
+ model = new ModelTube(null, 0, 0, -2F, -3F, -2F + vOffset, 4, 6, 4, 0f, 0.5f, 0.99f, ForgeDirection.UP);
+ modelLong = new ModelTube(null, 0, 0, -2F, -3F, -2F + vOffset, 4, longFragmensSize, 4, 0f, 0f, 0.99f,
+ ForgeDirection.UP);
+ modelThin = new ModelTube(null, 0, 0, -1F, -3F, -1F + vOffset, 2, 6, 2, 0f, 0.5f, 0.99f, ForgeDirection.UP);
+ modelThinLong = new ModelTube(null, 0, 0, -1F, -3F, -1F + vOffset, 2, longFragmensSize, 2, 0f, 0.5f, 0.99f,
+ ForgeDirection.UP);
+ }
+
+ @Override
+ public boolean handleRenderType(ItemStack item, ItemRenderType type) {
+ switch (type) {
+ case ENTITY:
+ return true;
+ case EQUIPPED:
+ return true;
+ case EQUIPPED_FIRST_PERSON:
+ return true;
+ case INVENTORY:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
+ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
+ return true;
+ }
+
+ @Override
+ public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
+ GL11.glPushMatrix();
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glScalef(1F, -1F, -1F);
+ switch (type) {
+ case ENTITY:
+ GL11.glTranslatef(0, -1.0F, 0);
+ this.rendercoil(stack);
+ break;
+ case EQUIPPED:
+ GL11.glTranslatef(0.25F, -2F, -0.75F);
+ this.rendercoil(stack);
+ break;
+ case EQUIPPED_FIRST_PERSON:
+ RenderPlayer var25;
+ EntityClientPlayerMP var3 = Minecraft.getMinecraft().thePlayer;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(var3.getLocationSkin());
+ var25 = (RenderPlayer) RenderManager.instance.getEntityRenderObject(Minecraft.getMinecraft().thePlayer);
+ GL11.glRotatef(135F, 1.0F, 0.0F, 0.0F);
+ GL11.glRotatef(35F, 0.0F, 1.0F, 0.0F);
+ var25.renderFirstPersonArm(Minecraft.getMinecraft().thePlayer);
+ GL11.glRotatef(-35F, 0.0F, 1.0F, 0.0F);
+ GL11.glRotatef(-135F, 1.0F, 0.0F, 0.0F);
+ GL11.glTranslatef(0.0F, 0.2F, 0F);
+ GL11.glTranslatef(-0.25F, -1.0F, 0F);
+ this.rendercoil(stack);
+ break;
+ case INVENTORY:
+ GL11.glTranslatef(0.0F, -0.2F, 0F);
+ this.rendercoil(stack);
+ break;
+ default:
+ }
+ GL11.glPopMatrix();
+ }
+
+ private void rendercoil(ItemStack stack) {
+ int type = this.getCableType(stack);
+ if (this.displayListCache[type] != 0) {
+ GL11.glCallList(displayListCache[type]);
+ } else {
+
+ this.displayListCache[type] = GLAllocation.generateDisplayLists(1);
+ GL11.glNewList(displayListCache[type], 4864 /* GL_COMPILE */);
+
+ GL11.glDisable(GL11.GL_TEXTURE_2D);
+ int saMax = this.segmentsAmount * 2 + this.segmentsAmount / 2;
+ for (int i = 0; i <= saMax; i++) {
+ GL11.glRotatef(-spiralStepAngle, 0f, 0f, 1f);
+ GL11.glRotatef(360f / this.segmentsAmount, 1f, 0f, 0f);
+ GL11.glTranslatef(0.004f, 0f, 0f);
+ GL11.glRotatef(spiralStepAngle, 0f, 0f, 1f);
+ GL11.glColor3f(1f, 1f, 1f);
+ if (i == 0) {
+ if (isNoInsulation(stack)) {
+ if (FlexibleCableItem.instance.yellowColoredWires
+ .contains(FlexibleCableItem.instance.getMaterial(stack))) {
+ GL11.glColor3f(1f, 0.75f, 0.1f);
+ } else {
+ GL11.glColor3f(0.65f, 0.65f, 0.67f);
+ }
+ this.modelThinLong.render(Tessellator.instance, scale);
+
+ } else {
+ this.modelLong.render(Tessellator.instance, scale);
+ }
+ } else if (i == saMax) {
+ GL11.glTranslatef(0.0F, -0.55F, 0F);
+ if (isNoInsulation(stack)) {
+ if (FlexibleCableItem.instance.yellowColoredWires
+ .contains(FlexibleCableItem.instance.getMaterial(stack))) {
+ GL11.glColor3f(1f, 0.75f, 0.1f);
+ } else {
+ GL11.glColor3f(0.65f, 0.65f, 0.67f);
+ }
+ this.modelThinLong.render(Tessellator.instance, scale);
+
+ } else {
+ this.modelLong.render(Tessellator.instance, scale);
+ }
+ GL11.glTranslatef(0.0F, 0.55F, 0F);
+ } else {
+ if (isNoInsulation(stack)) {
+ if (FlexibleCableItem.instance.yellowColoredWires
+ .contains(FlexibleCableItem.instance.getMaterial(stack))) {
+ GL11.glColor3f(1f, 0.75f, 0.1f);
+ } else {
+ GL11.glColor3f(0.65f, 0.65f, 0.67f);
+ }
+ this.modelThin.render(Tessellator.instance, scale);
+
+ } else {
+ this.model.render(Tessellator.instance, scale);
+ }
+ }
+ }
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+ GL11.glEndList();
+ }
+ }
+
+ private int getCableType(ItemStack stack) {
+ if (isNoInsulation(stack)) {
+ if (FlexibleCableItem.instance.yellowColoredWires.contains(FlexibleCableItem.instance.getMaterial(stack))) {
+ return 1;
+ } else {
+ return 2;
+ }
+ }
+ return 0;
+ }
+
+ private boolean isNoInsulation(ItemStack stack) {
+ return stack.stackTagCompound != null && FlexibleCableItem.instance.getInsulationMaterial(stack).equals("null");
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/model/FluidRenderer.java b/src/main/java/ihl/model/FluidRenderer.java new file mode 100644 index 0000000..674e4ea --- /dev/null +++ b/src/main/java/ihl/model/FluidRenderer.java @@ -0,0 +1,158 @@ +package ihl.model;
+/* This code with minimal changes was
+ * taken by me (Foghrye4) from
+ * RailCraft GitHub.
+ */
+
+/*
+ * Copyright (c) CovertJaguar, 2014 http://railcraft.info
+ *
+ * This code is the property of CovertJaguar
+ * and may only be used with explicit written
+ * permission unless otherwise specified on the
+ * license page at http://railcraft.info/wiki/info:license.
+ */
+import java.util.HashMap;
+import java.util.Map;
+
+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.GLAllocation;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+/**
+ *
+ * @author CovertJaguar <http://www.railcraft.info>
+ */
+@SideOnly(value=Side.CLIENT)
+public class FluidRenderer {
+
+ private static RenderBlocks renderBlocks = new RenderBlocks();
+ private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture;
+ private static final Map<Fluid, int[]> flowingRenderCache = new HashMap<Fluid, int[]>();
+ private static final Map<Fluid, int[]> stillRenderCache = new HashMap<Fluid, int[]>();
+ public static final int DISPLAY_STAGES = 100;
+ private static final RenderInfo liquidBlock = new RenderInfo();
+
+ static {
+ liquidBlock.texture = new IIcon[1];
+ }
+
+ public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) {
+ if (fluidStack == null)
+ return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
+ Fluid fluid = fluidStack.getFluid();
+ if (fluid == null)
+ return ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
+ IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
+ if(icon==null)
+ {
+ icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
+ }
+ return icon;
+ }
+
+ public static ResourceLocation getFluidSheet(FluidStack liquid) {
+ return BLOCK_TEXTURE;
+ }
+
+ public static ResourceLocation setupFlowingLiquidTexture(FluidStack liquid, IIcon[] texArray) {
+ if (liquid == null || liquid.amount <= 0)
+ return null;
+
+ Fluid fluid = liquid.getFluid();
+ if (fluid == null)
+ return null;
+ IIcon top = fluid.getStillIcon();
+ IIcon side = fluid.getFlowingIcon();
+ texArray[0] = top;
+ texArray[1] = top;
+ texArray[2] = side;
+ texArray[3] = side;
+ texArray[4] = side;
+ texArray[5] = side;
+ return getFluidSheet(liquid);
+ }
+
+ public static int[] getLiquidDisplayLists(FluidStack fluidStack) {
+ return getLiquidDisplayLists(fluidStack, false);
+ }
+
+ public static int[] getLiquidDisplayLists(FluidStack fluidStack, boolean flowing) {
+ if (fluidStack == null)
+ return null;
+ Fluid fluid = fluidStack.getFluid();
+ if (fluid == null)
+ return null;
+ Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
+ int[] diplayLists = cache.get(fluid);
+ if (diplayLists != null)
+ return diplayLists;
+
+ diplayLists = new int[DISPLAY_STAGES];
+
+ liquidBlock.texture[0] = null;
+
+ if (fluid.getBlock() != null) {
+ liquidBlock.template = fluid.getBlock();
+ liquidBlock.texture[0] = getFluidTexture(fluidStack, flowing);
+ } else {
+ liquidBlock.template = Blocks.water;
+ liquidBlock.texture[0] = getFluidTexture(fluidStack, flowing);
+ }
+
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glDisable(GL11.GL_CULL_FACE);
+ for (int s = 0; s < DISPLAY_STAGES; ++s) {
+ diplayLists[s] = GLAllocation.generateDisplayLists(1);
+ GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/);
+
+ liquidBlock.minX = 0.01f;
+ liquidBlock.minY = 0;
+ liquidBlock.minZ = 0.01f;
+
+ liquidBlock.maxX = 0.99f;
+ liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES;
+ liquidBlock.maxZ = 0.99f;
+ Tessellator tessellator = Tessellator.instance;
+ tessellator.startDrawingQuads();
+ RenderInfo info = liquidBlock;
+ renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ);
+
+ if (info.renderSide[0])
+ renderBlocks.renderFaceYNeg(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(0));
+ if (info.renderSide[1])
+ renderBlocks.renderFaceYPos(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(1));
+ if (info.renderSide[2])
+ renderBlocks.renderFaceZNeg(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(2));
+ if (info.renderSide[3])
+ renderBlocks.renderFaceZPos(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(3));
+ if (info.renderSide[4])
+ renderBlocks.renderFaceXNeg(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(4));
+ if (info.renderSide[5])
+ renderBlocks.renderFaceXPos(info.template, 0D, 0D, 0D, info.getBlockTextureFromSide(5));
+ tessellator.draw();
+ GL11.glEndList();
+ }
+
+ GL11.glColor4f(1, 1, 1, 1);
+ GL11.glEnable(GL11.GL_CULL_FACE);
+ GL11.glEnable(GL11.GL_BLEND);
+
+ cache.put(fluid, diplayLists);
+
+ return diplayLists;
+ }
+
+}
diff --git a/src/main/java/ihl/model/IHLBlockRenderer.java b/src/main/java/ihl/model/IHLBlockRenderer.java new file mode 100644 index 0000000..81efbd9 --- /dev/null +++ b/src/main/java/ihl/model/IHLBlockRenderer.java @@ -0,0 +1,78 @@ +package ihl.model;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.handpump.BlockWithCoordinates;
+import net.minecraft.client.renderer.GLAllocation;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.world.ChunkCache;
+import net.minecraft.world.World;
+
+@SideOnly(value=Side.CLIENT)
+public class IHLBlockRenderer {
+
+ private RenderBlocks renderBlocks;
+ private final Map<BlockWithCoordinates, Integer> renderCache = new HashMap<BlockWithCoordinates, Integer>();
+ public static IHLBlockRenderer instance;
+
+ public IHLBlockRenderer()
+ {
+ renderBlocks=RenderBlocks.getInstance();
+ instance=this;
+ }
+
+ public void refreshDisplayLists(int diplayLists, List<BlockWithCoordinates> bwc, ChunkCache iBlockAccess)
+ {
+ if (bwc==null || bwc.isEmpty())
+ {
+ return;
+ }
+ renderBlocks.blockAccess=iBlockAccess;
+ GL11.glNewList(diplayLists, 4864 /*GL_COMPILE*/);
+ Iterator<BlockWithCoordinates> bwci = bwc.iterator();
+ while(bwci.hasNext())
+ {
+ BlockWithCoordinates bwce = bwci.next();
+ renderBlock(bwce);
+ }
+ GL11.glEndList();
+ }
+
+
+ public int getBlockDisplayLists(BlockWithCoordinates bwc, World world) {
+ if (bwc.block == null)
+ {
+ return -1;
+ }
+ if(renderCache.containsKey(bwc))
+ {
+ return renderCache.get(bwc);
+ }
+ int diplayLists = GLAllocation.generateDisplayLists(1);
+ if(renderBlocks.blockAccess==null || !renderBlocks.blockAccess.equals(world))
+ {
+ renderBlocks.blockAccess=world;
+ }
+ GL11.glNewList(diplayLists, 4864 /*GL_COMPILE*/);
+ renderBlock(bwc);
+ GL11.glEndList();
+ renderCache.put(bwc, diplayLists);
+ return diplayLists;
+ }
+
+ private void renderBlock(BlockWithCoordinates bwc)
+ {
+ Tessellator tessellator = Tessellator.instance;
+ tessellator.startDrawingQuads();
+ renderBlocks.renderBlockByRenderType(bwc.block, bwc.x, bwc.y, bwc.z);
+ tessellator.draw();
+ }
+}
diff --git a/src/main/java/ihl/model/IHLModelRenderer.java b/src/main/java/ihl/model/IHLModelRenderer.java new file mode 100644 index 0000000..0bf95d2 --- /dev/null +++ b/src/main/java/ihl/model/IHLModelRenderer.java @@ -0,0 +1,369 @@ +package ihl.model;
+
+import java.util.ArrayList;
+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;
+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;
+
+ /** The size of the texture file's height in pixels. */
+ public float textureHeight;
+
+ /** The X offset into the texture used for displaying this model */
+ private int textureOffsetX;
+
+ /** The Y offset into the texture used for displaying this model */
+ private int textureOffsetY;
+ public float rotationPointX;
+ public float rotationPointY;
+ public float rotationPointZ;
+ public float rotateAngleX;
+ public float rotateAngleY;
+ public float rotateAngleZ;
+ private boolean compiled;
+
+ /** The GL display list rendered by the Tessellator for this model */
+ private int displayList;
+ public boolean mirror;
+ public boolean showModel;
+
+ /** Hides the model. */
+ public boolean isHidden;
+ public List<Object> cubeList;
+ public List<ModelRenderer> childModels;
+ public final String boxName;
+ private ModelBase baseModel;
+ public float offsetX;
+ public float offsetY;
+ public float offsetZ;
+
+ public boolean drawFromInside=false;
+
+ @SuppressWarnings("unchecked")
+ public IHLModelRenderer(ModelBase par1ModelBase, String par2Str)
+ {
+ this.textureWidth = 64.0F;
+ this.textureHeight = 32.0F;
+ this.showModel = true;
+ this.cubeList = new ArrayList<Object>();
+ this.baseModel = par1ModelBase;
+ par1ModelBase.boxList.add(this);
+ this.boxName = par2Str;
+ this.setTextureSize(par1ModelBase.textureWidth, par1ModelBase.textureHeight);
+ }
+
+ public IHLModelRenderer(ModelBase par1ModelBase)
+ {
+ this(par1ModelBase, (String)null);
+ }
+
+ public IHLModelRenderer(ModelBase par1ModelBase, int par2, int par3)
+ {
+ this(par1ModelBase);
+ this.setTextureOffset(par2, par3);
+ }
+
+ /**
+ * Sets the current box's rotation points and rotation angles to another box.
+ */
+ public void addChild(ModelRenderer par1ModelRenderer)
+ {
+ if (this.childModels == null)
+ {
+ this.childModels = new ArrayList<ModelRenderer>();
+ }
+
+ this.childModels.add(par1ModelRenderer);
+ }
+
+ public IHLModelRenderer setTextureOffset(int par1, int par2)
+ {
+ this.textureOffsetX = par1;
+ this.textureOffsetY = par2;
+ return this;
+ }
+
+ public IHLModelRenderer addBox(String par1Str, float par2, float par3, float par4, int par5, int par6, int par7, boolean inverted, boolean[] renderFace)
+ {
+ par1Str = this.boxName + "." + par1Str;
+ TextureOffset var8 = this.baseModel.getTextureOffset(par1Str);
+ this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY);
+ this.cubeList.add((new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5, par6, par7, 0.0F, inverted, renderFace)).func_78244_a(par1Str));
+ return this;
+ }
+
+ public IHLModelRenderer addBox(String par1Str, float par2, float par3, float par4, int par5, int par6, int par7, boolean inverted)
+ {
+ boolean[] renderFace={true,true,true,true,true,true};
+ par1Str = this.boxName + "." + par1Str;
+ TextureOffset var8 = this.baseModel.getTextureOffset(par1Str);
+ this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY);
+ this.cubeList.add((new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par2, par3, par4, par5, par6, par7, 0.0F, inverted, renderFace)).func_78244_a(par1Str));
+ return this;
+ }
+
+ public IHLModelRenderer addBox(float par1, float par2, float par3, int par4, int par5, int par6, boolean inverted, boolean[] renderFace)
+ {
+ this.cubeList.add(new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F, inverted, renderFace));
+ return this;
+ }
+
+ public IHLModelRenderer addTube(String par1Str, float par1, float par2, float par3, int par4, int par5, int par6, float radius1, float radius2, ForgeDirection direction)
+ {
+ par1Str = this.boxName + "." + par1Str;
+ TextureOffset var8 = this.baseModel.getTextureOffset(par1Str);
+ this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY);
+ this.cubeList.add(new ModelTube(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F, radius1,radius2, direction));
+ return this;
+ }
+
+ public IHLModelRenderer addKnee(String par1Str, float par1, float par2, float par3, int par4, int par5, int par6, float radius1, float radius2, ForgeDirection direction, ForgeDirection direction2)
+ {
+ par1Str = this.boxName + "." + par1Str;
+ TextureOffset var8 = this.baseModel.getTextureOffset(par1Str);
+ this.setTextureOffset(var8.textureOffsetX, var8.textureOffsetY);
+ this.cubeList.add(new ModelKnee(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F, radius1,radius2, direction, direction2));
+ return this;
+ }
+
+ public IHLModelRenderer addBox(float par1, float par2, float par3, int par4, int par5, int par6)
+ {
+ boolean[] renderFace={true,true,true,true,true,true};
+ this.cubeList.add(new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, 0.0F, false, renderFace));
+ return this;
+ }
+
+ /**
+ * Creates a textured box. Args: originX, originY, originZ, width, height, depth, scaleFactor.
+ */
+ public void addBox(float par1, float par2, float par3, int par4, int par5, int par6, float par7, boolean inverted, boolean[] renderFace)
+ {
+ this.cubeList.add(new ModelToplessBox(this, this.textureOffsetX, this.textureOffsetY, par1, par2, par3, par4, par5, par6, par7, inverted, renderFace));
+ }
+
+ public void setRotationPoint(float par1, float par2, float par3)
+ {
+ this.rotationPointX = par1;
+ this.rotationPointY = par2;
+ this.rotationPointZ = par3;
+ }
+
+ public void render(float par1)
+ {
+ if (!this.isHidden)
+ {
+ if (this.showModel)
+ {
+ if (!this.compiled)
+ {
+ this.compileDisplayList(par1);
+ }
+
+ GL11.glTranslatef(this.offsetX, this.offsetY, this.offsetZ);
+ int var2;
+
+ if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F)
+ {
+ if (this.rotationPointX == 0.0F && this.rotationPointY == 0.0F && this.rotationPointZ == 0.0F)
+ {
+ GL11.glCallList(this.displayList);
+
+ if (this.childModels != null)
+ {
+ for (var2 = 0; var2 < this.childModels.size(); ++var2)
+ {
+ ((ModelRenderer)this.childModels.get(var2)).render(par1);
+ }
+ }
+ }
+ else
+ {
+ GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
+ GL11.glCallList(this.displayList);
+
+ if (this.childModels != null)
+ {
+ for (var2 = 0; var2 < this.childModels.size(); ++var2)
+ {
+ ((ModelRenderer)this.childModels.get(var2)).render(par1);
+ }
+ }
+
+ GL11.glTranslatef(-this.rotationPointX * par1, -this.rotationPointY * par1, -this.rotationPointZ * par1);
+ }
+ }
+ else
+ {
+ GL11.glPushMatrix();
+ GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
+
+ if (this.rotateAngleZ != 0.0F)
+ {
+ GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
+ }
+
+ if (this.rotateAngleY != 0.0F)
+ {
+ GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
+ }
+
+ if (this.rotateAngleX != 0.0F)
+ {
+ GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+
+ GL11.glCallList(this.displayList);
+
+ if (this.childModels != null)
+ {
+ for (var2 = 0; var2 < this.childModels.size(); ++var2)
+ {
+ ((ModelRenderer)this.childModels.get(var2)).render(par1);
+ }
+ }
+
+ GL11.glPopMatrix();
+ }
+
+ GL11.glTranslatef(-this.offsetX, -this.offsetY, -this.offsetZ);
+ }
+ }
+ }
+
+ public void renderWithRotation(float par1)
+ {
+ if (!this.isHidden)
+ {
+ if (this.showModel)
+ {
+ if (!this.compiled)
+ {
+ this.compileDisplayList(par1);
+ }
+
+ GL11.glPushMatrix();
+ GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
+
+ if (this.rotateAngleY != 0.0F)
+ {
+ GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
+ }
+
+ if (this.rotateAngleX != 0.0F)
+ {
+ GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+
+ if (this.rotateAngleZ != 0.0F)
+ {
+ GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
+ }
+
+ GL11.glCallList(this.displayList);
+ GL11.glPopMatrix();
+ }
+ }
+ }
+
+ /**
+ * Allows the changing of Angles after a box has been rendered
+ */
+ public void postRender(float par1)
+ {
+ if (!this.isHidden)
+ {
+ if (this.showModel)
+ {
+ if (!this.compiled)
+ {
+ this.compileDisplayList(par1);
+ }
+
+ if (this.rotateAngleX == 0.0F && this.rotateAngleY == 0.0F && this.rotateAngleZ == 0.0F)
+ {
+ if (this.rotationPointX != 0.0F || this.rotationPointY != 0.0F || this.rotationPointZ != 0.0F)
+ {
+ GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
+ }
+ }
+ else
+ {
+ GL11.glTranslatef(this.rotationPointX * par1, this.rotationPointY * par1, this.rotationPointZ * par1);
+
+ if (this.rotateAngleZ != 0.0F)
+ {
+ GL11.glRotatef(this.rotateAngleZ * (180F / (float)Math.PI), 0.0F, 0.0F, 1.0F);
+ }
+
+ if (this.rotateAngleY != 0.0F)
+ {
+ GL11.glRotatef(this.rotateAngleY * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
+ }
+
+ if (this.rotateAngleX != 0.0F)
+ {
+ GL11.glRotatef(this.rotateAngleX * (180F / (float)Math.PI), 1.0F, 0.0F, 0.0F);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Compiles a GL display list for this model
+ */
+ private void compileDisplayList(float par1)
+ {
+ this.displayList = GLAllocation.generateDisplayLists(1);
+ GL11.glNewList(this.displayList, GL11.GL_COMPILE);
+ Tessellator var2 = Tessellator.instance;
+
+ for (int var3 = 0; var3 < this.cubeList.size(); ++var3)
+ {
+ if(this.cubeList.get(var3) instanceof ModelToplessBox)
+ {
+ ((ModelToplessBox)this.cubeList.get(var3)).render(var2, par1);
+ }
+ else if(this.cubeList.get(var3) instanceof ModelTube)
+ {
+ ((ModelTube)this.cubeList.get(var3)).render(var2, par1);
+ }
+ else if(this.cubeList.get(var3) instanceof ModelKnee)
+ {
+ ((ModelKnee)this.cubeList.get(var3)).render(var2, par1);
+ }
+ }
+
+ GL11.glEndList();
+ this.compiled = true;
+ }
+
+ /**
+ * Returns the model renderer with the new texture parameters.
+ */
+ public IHLModelRenderer setTextureSize(int par1, int par2)
+ {
+ this.textureWidth = par1;
+ this.textureHeight = par2;
+ return this;
+ }
+
+ public void addBox(String string, float f, float g, float h, int i, int j, int k) {
+ this.addBox(string, f, g, h, i, j, k, false);
+ }
+
+
+}
diff --git a/src/main/java/ihl/model/IHLToolRenderer.java b/src/main/java/ihl/model/IHLToolRenderer.java new file mode 100644 index 0000000..31758b2 --- /dev/null +++ b/src/main/java/ihl/model/IHLToolRenderer.java @@ -0,0 +1,69 @@ +package ihl.model;
+
+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;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraftforge.client.IItemRenderer;
+
+@SideOnly(value=Side.CLIENT)
+public class IHLToolRenderer implements IItemRenderer
+{
+
+ @Override
+ public boolean handleRenderType(ItemStack item, ItemRenderType type) {
+ switch (type) {
+ case ENTITY:
+ return true;
+ case EQUIPPED:
+ return true;
+ case EQUIPPED_FIRST_PERSON:
+ return true;
+ case INVENTORY:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
+ public void renderItem(ItemRenderType irt, ItemStack stack, Object... arg2)
+ {
+ IIcon icon = stack.getItem().getIcon(stack, 0);
+ Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
+ if(irt.equals(ItemRenderType.INVENTORY))
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ Tessellator tessellator = Tessellator.instance;
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0f, 0f, -1f);
+ double xStart=0d,yStart=0d;
+ double xEnd=16d,yEnd=16d;
+ double z = 0.001d;
+ tessellator.addVertexWithUV(xStart, yEnd, z, icon.getMinU(), icon.getMaxV());
+ tessellator.addVertexWithUV(xEnd, yEnd, z, icon.getMaxU(), icon.getMaxV());
+ tessellator.addVertexWithUV(xEnd, yStart, z, icon.getMaxU(), icon.getMinV());
+ tessellator.addVertexWithUV(xStart, yStart, z, icon.getMinU(), icon.getMinV());
+ tessellator.draw();
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+ else
+ {
+ ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
+ }
+ }
+
+ @Override
+ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack arg1, ItemRendererHelper arg2)
+ {
+ return type.equals(ItemRenderType.ENTITY);
+ }
+
+}
diff --git a/src/main/java/ihl/model/ImpregnatingMachineBlockRender.java b/src/main/java/ihl/model/ImpregnatingMachineBlockRender.java new file mode 100644 index 0000000..2602fd0 --- /dev/null +++ b/src/main/java/ihl/model/ImpregnatingMachineBlockRender.java @@ -0,0 +1,126 @@ +package ihl.model;
+
+import org.lwjgl.opengl.GL11;
+
+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;
+import ihl.items_blocks.MachineBaseBlock;
+import ihl.items_blocks.MachineBaseBlock.MachineType;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+
+@SideOnly(value=Side.CLIENT)
+public class ImpregnatingMachineBlockRender implements ISimpleBlockRenderingHandler
+{
+ public static int renderId;
+
+ public ImpregnatingMachineBlockRender()
+ {
+ renderId = RenderingRegistry.getNextAvailableRenderId();
+ }
+
+ @Override
+ public int getRenderId()
+ {
+ return renderId;
+ }
+
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderblocks)
+ {
+ MachineBaseBlock blockmb = (MachineBaseBlock) block;
+ Tessellator tessellator = Tessellator.instance;
+ block.setBlockBoundsForItemRender();
+ renderblocks.setRenderBoundsFromBlock(block);
+ GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, -1.0F, 0.0F);
+ renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 0, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 1.0F, 0.0F);
+ renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 1, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 0.0F, -1.0F);
+ renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 2, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 0.0F, 1.0F);
+ renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 3, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(-1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 4, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 5, metadata));
+ tessellator.draw();
+ float var11 = 0.0625F;
+ IIcon innerSideIcon = blockmb.getAdditionalIconsForBlockRenderer(0);
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 0.0F, -1.0F);
+ renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 1.0F - var11, innerSideIcon);
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 0.0F, 1.0F);
+ renderblocks.renderFaceZPos(block, 0.0D, 0.0D, var11-1.0F, innerSideIcon);
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(-1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXNeg(block, 1.0F - var11, 0.0D, 0.0D, innerSideIcon);
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXPos(block, var11-1.0F, 0.0D, 0.0D, innerSideIcon);
+ tessellator.draw();
+ IIcon innerBottomIcon = blockmb.getAdditionalIconsForBlockRenderer(1);
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 1.0F, 0.0F);
+ if(blockmb.type.equals(MachineType.SolarEvaporator))
+ var11 = 0.5625f;
+ renderblocks.renderFaceYPos(block, 0.0D, var11-1.0F, 0.0D, innerBottomIcon);
+ tessellator.draw();
+ GL11.glTranslatef(0.5F, 0.5F, 0.5F);
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta, RenderBlocks blockRenderer)
+ {
+ MachineBaseBlock blockmb = (MachineBaseBlock) block;
+ blockRenderer.renderStandardBlock(block, x, y, z);
+ Tessellator var5 = Tessellator.instance;
+ var5.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z));
+ int var6 = block.colorMultiplier(blockAccess, x, y, z);
+ float var7 = (var6 >> 16 & 255) / 255.0F;
+ float var8 = (var6 >> 8 & 255) / 255.0F;
+ float var9 = (var6 & 255) / 255.0F;
+ float var11;
+ var5.setColorOpaque_F(var7, var8, var9);
+ IIcon innerSideIcon = blockmb.getAdditionalIconsForBlockRenderer(0);
+ var11 = 0.0625F;
+
+ blockRenderer.renderFaceXPos(block, x - 1.0F + var11, y, z, innerSideIcon);
+ blockRenderer.renderFaceXNeg(block, x + 1.0F - var11, y, z, innerSideIcon);
+ blockRenderer.renderFaceZPos(block, x, y, z - 1.0F + var11, innerSideIcon);
+ blockRenderer.renderFaceZNeg(block, x, y, z + 1.0F - var11, innerSideIcon);
+ IIcon innerBottomIcon = blockmb.getAdditionalIconsForBlockRenderer(1);
+ if(blockmb.type.equals(MachineType.SolarEvaporator))
+ var11 = 0.5625f;
+ blockRenderer.renderFaceYPos(block, x, y - 1.0F + var11, z, innerBottomIcon);
+ return true;
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory(int arg0)
+ {
+ return true;
+ }
+}
diff --git a/src/main/java/ihl/model/IronWorkbenchBlockRender.java b/src/main/java/ihl/model/IronWorkbenchBlockRender.java new file mode 100644 index 0000000..1af81cf --- /dev/null +++ b/src/main/java/ihl/model/IronWorkbenchBlockRender.java @@ -0,0 +1,107 @@ +package ihl.model;
+
+import org.lwjgl.opengl.GL11;
+
+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;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.world.IBlockAccess;
+
+@SideOnly(value=Side.CLIENT)
+public class IronWorkbenchBlockRender implements ISimpleBlockRenderingHandler
+{
+ public static int renderId;
+
+ public IronWorkbenchBlockRender()
+ {
+ renderId = RenderingRegistry.getNextAvailableRenderId();
+ }
+
+ @Override
+ public int getRenderId()
+ {
+ return renderId;
+ }
+
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderblocks)
+ {
+ Tessellator tessellator = Tessellator.instance;
+ GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+ tessellator.startDrawingQuads();
+ for(int i=0;i<=5;i++)
+ {
+ this.setBounds(i, renderblocks, block);
+ tessellator.setNormal(0.0F, -1.0F, 0.0F);
+ renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(0.0F, 1.0F, 0.0F);
+ renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(0.0F, 0.0F, -1.0F);
+ renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(0.0F, 0.0F, 1.0F);
+ renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(-1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ }
+ tessellator.draw();
+ GL11.glTranslatef(0.5F, 0.5F, 0.5F);
+ renderblocks.clearOverrideBlockTexture();
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta, RenderBlocks renderblocks)
+ {
+ Tessellator var5 = Tessellator.instance;
+ var5.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z));
+ int var6 = block.colorMultiplier(blockAccess, x, y, z);
+ float var7 = (var6 >> 16 & 255) / 255.0F;
+ float var8 = (var6 >> 8 & 255) / 255.0F;
+ float var9 = (var6 & 255) / 255.0F;
+ var5.setColorOpaque_F(var7, var8, var9);
+ for(int i=0;i<=5;i++)
+ {
+ this.setBounds(i, renderblocks, block);
+ renderblocks.renderStandardBlock(block, x, y, z);
+ }
+ return true;
+ }
+
+ private void setBounds(int index, RenderBlocks renderblocks, Block block)
+ {
+ double rt = 1/11d;
+ switch(index)
+ {
+ case 0:
+ renderblocks.setRenderBounds(0d, 10*rt, 0d, 1d, 1d, 1d);
+ break;
+ case 1:
+ renderblocks.setRenderBounds(rt*2, 4*rt, rt*2, 9*rt, 5*rt, 9*rt);
+ break;
+ case 2:
+ renderblocks.setRenderBounds(rt, 0d, rt, rt*3, rt*10, rt*3);
+ break;
+ case 3:
+ renderblocks.setRenderBounds(rt*8, 0d, rt, rt*10, rt*10, rt*3);
+ break;
+ case 4:
+ renderblocks.setRenderBounds(rt, 0d, rt*8, rt*3, rt*10, rt*10);
+ break;
+ case 5:
+ renderblocks.setRenderBounds(rt*8, 0d, rt*8, rt*10, rt*10, rt*10);
+ break;
+ }
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory(int arg0)
+ {
+ return true;
+ }
+}
diff --git a/src/main/java/ihl/model/ModelKnee.java b/src/main/java/ihl/model/ModelKnee.java new file mode 100644 index 0000000..3f720ac --- /dev/null +++ b/src/main/java/ihl/model/ModelKnee.java @@ -0,0 +1,228 @@ +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
+ */
+ private PositionTextureVertex[] vertexPositions;
+
+ /** An array of 6 TexturedQuads, one for each face of a cube */
+ private TexturedQuad[] quadList;
+
+ /** X vertex coordinate of lower box corner */
+ public final float posX1;
+
+ /** Y vertex coordinate of lower box corner */
+ public final float posY1;
+
+ /** Z vertex coordinate of lower box corner */
+ public final float posZ1;
+
+ /** X vertex coordinate of upper box corner */
+ public final float posX2;
+
+ /** Y vertex coordinate of upper box corner */
+ public final float posY2;
+
+ /** Z vertex coordinate of upper box corner */
+ public final float posZ2;
+ public String field_78247_g;
+ private ForgeDirection direction1;
+ private ForgeDirection direction2;
+
+ public ModelKnee(IHLModelRenderer par1ModelRenderer, int par2, int par3, float x1, float y1, float z1, int par7, int par8, int par9, float par10, float radius1, float radius2, ForgeDirection direction1_1)
+ {
+ this(par1ModelRenderer, par2, par3, x1, y1, z1, par7, par8, par9, par10, radius1, radius2, direction1_1, direction1_1);
+ }
+
+
+ public ModelKnee(IHLModelRenderer par1ModelRenderer, int par2, int par3, float x1, float y1, float z1, int par7, int par8, int par9, float par10, float radius1, float radius2, ForgeDirection direction1_1, ForgeDirection direction2_1)
+ {
+ this.direction1=direction1_1;
+ this.direction2=direction2_1;
+ this.posX1 = x1;
+ this.posY1 = y1;
+ this.posZ1 = z1;
+ this.posX2 = x1 + par7;
+ this.posY2 = y1 + par8;
+ this.posZ2 = z1 + par9;
+ this.vertexPositions = new PositionTextureVertex[32];
+ this.quadList = new TexturedQuad[32];
+ float x2 = x1 + par7;
+ float y2 = y1 + par8;
+ float z2 = z1 + par9;
+ x1 -= par10;
+ y1 -= par10;
+ z1 -= par10;
+ x2 += par10;
+ y2 += par10;
+ z2 += par10;
+
+ if (par1ModelRenderer.mirror)
+ {
+ float var14 = x2;
+ x2 = x1;
+ x1 = var14;
+ }
+ float dx = x2-x1 ;
+ float dy = y2-y1;
+ float dz = z2-z1;
+ PositionTextureVertex[] outervertexes1 = new PositionTextureVertex[8];
+ PositionTextureVertex[] innervertexes1 = new PositionTextureVertex[8];
+ PositionTextureVertex[] outervertexes2 = new PositionTextureVertex[8];
+ PositionTextureVertex[] innervertexes2 = new PositionTextureVertex[8];
+ int i=0;
+ for(i=0;i<8;i++)
+ {
+ switch(direction1)
+ {
+ case UP:
+ outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.25F*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case DOWN:
+ outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F-dz*0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F-dz*0.25F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case SOUTH:
+ outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case NORTH:
+ outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case EAST:
+ outervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.25F*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case WEST:
+ outervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.52F*radius2*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ default:
+ outervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.52F*radius2*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ }
+
+ switch(direction2)
+ {
+ case UP:
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case DOWN:
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case WEST:
+ outervertexes2[i] = new PositionTextureVertex(x2, y1+dy*0.5F+dy*0.25F*(float)Math.cos(2D*Math.PI/8D*i), z1+dz*0.5F-dz*0.25F*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x2, y1+dy*0.5F+dy*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), z1+dz*0.5F-dz*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case EAST:
+ outervertexes2[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.25F*(float)Math.cos(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.25F*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case NORTH:
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+z2-dz*0.5F-dz*0.25F*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+z2-dz*0.5F-dz*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z2, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ case SOUTH:
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*(float)Math.sin(2D*Math.PI/8D*i), z1, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ default:
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ break;
+ }
+ }
+ for(i=0;i<32;i++)
+ {
+ if(i<8)
+ {
+ this.vertexPositions[i]=outervertexes1[i];
+ }
+ else if(i<16)
+ {
+ this.vertexPositions[i]=innervertexes1[i-8];
+ }
+ else if(i<24)
+ {
+ this.vertexPositions[i]=outervertexes2[i-16];
+ }
+ else
+ {
+ this.vertexPositions[i]=innervertexes2[i-24];
+ }
+ }
+ for(i=0;i<32;i++)
+ {
+ if(i<7)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i],outervertexes1[i+1],innervertexes1[i+1],innervertexes1[i]},par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ else if(i==7)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i],outervertexes1[0],innervertexes1[0],innervertexes1[i]},par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ else if(i<15)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes2[i-8],innervertexes2[i+1-8],outervertexes2[i+1-8],outervertexes2[i-8]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ else if(i==15)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes2[i-8],innervertexes2[0],outervertexes2[0],outervertexes2[i-8]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ else if(i<23)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[i-16+1],outervertexes1[i-16+1]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ else if(i==23)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[0],outervertexes1[0]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ else if(i<31)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[i-24+1],innervertexes2[i-24+1], innervertexes2[i-24], innervertexes1[i-24]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ else if(i==31)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[0],innervertexes2[0],innervertexes2[i-24],innervertexes1[i-24]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ }
+ if (par1ModelRenderer.mirror)
+ {
+ for (int var22 = 0; var22 < this.quadList.length; ++var22)
+ {
+ this.quadList[var22].flipFace();
+ }
+ }
+ }
+
+ /**
+ * Draw the six sided box defined by this ModelBox
+ */
+ public void render(Tessellator par1Tessellator, float par2)
+ {
+ for(int i=0;i<this.quadList.length;i++)
+ {
+ this.quadList[i].draw(par1Tessellator, par2);
+ }
+ }
+
+ public ModelKnee func_78244_a(String par1Str)
+ {
+ this.field_78247_g = par1Str;
+ return this;
+ }
+}
diff --git a/src/main/java/ihl/model/ModelToplessBox.java b/src/main/java/ihl/model/ModelToplessBox.java new file mode 100644 index 0000000..09885c9 --- /dev/null +++ b/src/main/java/ihl/model/ModelToplessBox.java @@ -0,0 +1,207 @@ +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
+ */
+ private PositionTextureVertex[] vertexPositions;
+
+ /** An array of 6 TexturedQuads, one for each face of a cube */
+ private TexturedQuad[] quadList;
+
+ /** X vertex coordinate of lower box corner */
+ public final float posX1;
+
+ /** Y vertex coordinate of lower box corner */
+ public final float posY1;
+
+ /** Z vertex coordinate of lower box corner */
+ public final float posZ1;
+
+ /** X vertex coordinate of upper box corner */
+ public final float posX2;
+
+ /** Y vertex coordinate of upper box corner */
+ public final float posY2;
+
+ /** Z vertex coordinate of upper box corner */
+ public final float posZ2;
+ public String field_78247_g;
+ private boolean[] renderFace;
+ private boolean inverted = false;
+
+ public ModelToplessBox(IHLModelRenderer par1ModelRenderer, int par2, int par3, float par4, float par5, float par6, int par7, int par8, int par9, float par10, boolean inverted1, boolean renderFace1[])
+ {
+ this.inverted=inverted1;
+ renderFace=renderFace1;
+ this.posX1 = par4;
+ this.posY1 = par5;
+ this.posZ1 = par6;
+ this.posX2 = par4 + par7;
+ this.posY2 = par5 + par8;
+ this.posZ2 = par6 + par9;
+ this.vertexPositions = new PositionTextureVertex[8];
+ this.quadList = new TexturedQuad[6];
+ float var11 = par4 + par7;
+ float var12 = par5 + par8;
+ float var13 = par6 + par9;
+ par4 -= par10;
+ par5 -= par10;
+ par6 -= par10;
+ var11 += par10;
+ var12 += par10;
+ var13 += par10;
+
+ if (par1ModelRenderer.mirror)
+ {
+ float var14 = var11;
+ var11 = par4;
+ par4 = var14;
+ }
+
+ PositionTextureVertex var23 = new PositionTextureVertex(par4, par5, par6, 0.0F, 0.0F);
+ PositionTextureVertex var15 = new PositionTextureVertex(var11, par5, par6, 0.0F, 8.0F);
+ PositionTextureVertex var16 = new PositionTextureVertex(var11, var12, par6, 8.0F, 8.0F);
+ PositionTextureVertex var17 = new PositionTextureVertex(par4, var12, par6, 8.0F, 0.0F);
+ PositionTextureVertex var18 = new PositionTextureVertex(par4, par5, var13, 0.0F, 0.0F);
+ PositionTextureVertex var19 = new PositionTextureVertex(var11, par5, var13, 0.0F, 8.0F);
+ PositionTextureVertex var20 = new PositionTextureVertex(var11, var12, var13, 8.0F, 8.0F);
+ PositionTextureVertex var21 = new PositionTextureVertex(par4, var12, var13, 8.0F, 0.0F);
+ this.vertexPositions[0] = var23;
+ this.vertexPositions[1] = var15;
+ this.vertexPositions[2] = var16;
+ this.vertexPositions[3] = var17;
+ this.vertexPositions[4] = var18;
+ this.vertexPositions[5] = var19;
+ this.vertexPositions[6] = var20;
+ this.vertexPositions[7] = var21;
+ if(inverted)
+ {
+ this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] {var20, var16, var15, var19}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] {var17, var21, var18, var23}, par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] {var15, var23, var18, var19}, par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] {var20, var21, var17, var16}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] {var16, var17, var23, var15}, par2 + par9, par3 + par9, par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] {var21, var20, var19, var18}, par2 + par9 + par7 + par9, par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ else
+ {
+ this.quadList[0] = new TexturedQuad(new PositionTextureVertex[] {var19, var15, var16, var20}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[1] = new TexturedQuad(new PositionTextureVertex[] {var23, var18, var21, var17}, par2, par3 + par9, par2 + par9, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[2] = new TexturedQuad(new PositionTextureVertex[] {var19, var18, var23, var15}, par2 + par9, par3, par2 + par9 + par7, par3 + par9, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[3] = new TexturedQuad(new PositionTextureVertex[] {var16, var17, var21, var20}, par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par7, par3, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[4] = new TexturedQuad(new PositionTextureVertex[] {var15, var23, var17, var16}, par2 + par9, par3 + par9, par2 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ this.quadList[5] = new TexturedQuad(new PositionTextureVertex[] {var18, var19, var20, var21}, par2 + par9 + par7 + par9, par3 + par9, par2 + par9 + par7 + par9 + par7, par3 + par9 + par8, par1ModelRenderer.textureWidth, par1ModelRenderer.textureHeight);
+ }
+ if (par1ModelRenderer.mirror)
+ {
+ for (int var22 = 0; var22 < this.quadList.length; ++var22)
+ {
+ this.quadList[var22].flipFace();
+ }
+ }
+ }
+
+ /**
+ * Draw the six sided box defined by this ModelBox
+ */
+ public void render(Tessellator par1Tessellator, float par2)
+ {
+ for(int i=0;i<this.quadList.length;i++)
+ {
+ if(this.renderFace[i])
+ {
+ this.quadList[i].draw(par1Tessellator, par2);
+ }
+ }
+ }
+
+ public ModelToplessBox func_78244_a(String par1Str)
+ {
+ this.field_78247_g = par1Str;
+ return this;
+ }
+
+ public void redefineVertices(double xs[],double ys[],double zs[])
+ {
+ this.quadList[1].vertexPositions[0].vector3D.xCoord=xs[0];
+ this.quadList[1].vertexPositions[0].vector3D.yCoord=ys[0];
+ this.quadList[1].vertexPositions[0].vector3D.zCoord=zs[0];
+ this.quadList[2].vertexPositions[2].vector3D.xCoord=xs[0];
+ this.quadList[2].vertexPositions[2].vector3D.yCoord=ys[0];
+ this.quadList[2].vertexPositions[2].vector3D.zCoord=zs[0];
+ this.quadList[4].vertexPositions[1].vector3D.xCoord=xs[0];
+ this.quadList[4].vertexPositions[1].vector3D.yCoord=ys[0];
+ this.quadList[4].vertexPositions[1].vector3D.zCoord=zs[0];
+ this.quadList[0].vertexPositions[1].vector3D.xCoord=xs[1];
+ this.quadList[0].vertexPositions[1].vector3D.yCoord=ys[1];
+ this.quadList[0].vertexPositions[1].vector3D.zCoord=zs[1];
+ this.quadList[2].vertexPositions[3].vector3D.xCoord=xs[1];
+ this.quadList[2].vertexPositions[3].vector3D.yCoord=ys[1];
+ this.quadList[2].vertexPositions[3].vector3D.zCoord=zs[1];
+ this.quadList[4].vertexPositions[0].vector3D.xCoord=xs[1];
+ this.quadList[4].vertexPositions[0].vector3D.yCoord=ys[1];
+ this.quadList[4].vertexPositions[0].vector3D.zCoord=zs[1];
+ this.quadList[0].vertexPositions[2].vector3D.xCoord=xs[2];
+ this.quadList[0].vertexPositions[2].vector3D.yCoord=ys[2];
+ this.quadList[0].vertexPositions[2].vector3D.zCoord=zs[2];
+ this.quadList[3].vertexPositions[0].vector3D.xCoord=xs[2];
+ this.quadList[3].vertexPositions[0].vector3D.yCoord=ys[2];
+ this.quadList[3].vertexPositions[0].vector3D.zCoord=zs[2];
+ this.quadList[4].vertexPositions[3].vector3D.xCoord=xs[2];
+ this.quadList[4].vertexPositions[3].vector3D.yCoord=ys[2];
+ this.quadList[4].vertexPositions[3].vector3D.zCoord=zs[2];
+ this.quadList[1].vertexPositions[3].vector3D.xCoord=xs[3];
+ this.quadList[1].vertexPositions[3].vector3D.yCoord=ys[3];
+ this.quadList[1].vertexPositions[3].vector3D.zCoord=zs[3];
+ this.quadList[3].vertexPositions[1].vector3D.xCoord=xs[3];
+ this.quadList[3].vertexPositions[1].vector3D.yCoord=ys[3];
+ this.quadList[3].vertexPositions[1].vector3D.zCoord=zs[3];
+ this.quadList[4].vertexPositions[2].vector3D.xCoord=xs[3];
+ this.quadList[4].vertexPositions[2].vector3D.yCoord=ys[3];
+ this.quadList[4].vertexPositions[2].vector3D.zCoord=zs[3];
+ this.quadList[1].vertexPositions[1].vector3D.xCoord=xs[4];
+ this.quadList[1].vertexPositions[1].vector3D.yCoord=ys[4];
+ this.quadList[1].vertexPositions[1].vector3D.zCoord=zs[4];
+ this.quadList[2].vertexPositions[1].vector3D.xCoord=xs[4];
+ this.quadList[2].vertexPositions[1].vector3D.yCoord=ys[4];
+ this.quadList[2].vertexPositions[1].vector3D.zCoord=zs[4];
+ this.quadList[5].vertexPositions[0].vector3D.xCoord=xs[4];
+ this.quadList[5].vertexPositions[0].vector3D.yCoord=ys[4];
+ this.quadList[5].vertexPositions[0].vector3D.zCoord=zs[4];
+ this.quadList[0].vertexPositions[0].vector3D.xCoord=xs[5];
+ this.quadList[0].vertexPositions[0].vector3D.yCoord=ys[5];
+ this.quadList[0].vertexPositions[0].vector3D.zCoord=zs[5];
+ this.quadList[2].vertexPositions[0].vector3D.xCoord=xs[5];
+ this.quadList[2].vertexPositions[0].vector3D.yCoord=ys[5];
+ this.quadList[2].vertexPositions[0].vector3D.zCoord=zs[5];
+ this.quadList[5].vertexPositions[1].vector3D.xCoord=xs[5];
+ this.quadList[5].vertexPositions[1].vector3D.yCoord=ys[5];
+ this.quadList[5].vertexPositions[1].vector3D.zCoord=zs[5];
+ this.quadList[0].vertexPositions[3].vector3D.xCoord=xs[6];
+ this.quadList[0].vertexPositions[3].vector3D.yCoord=ys[6];
+ this.quadList[0].vertexPositions[3].vector3D.zCoord=zs[6];
+ this.quadList[3].vertexPositions[3].vector3D.xCoord=xs[6];
+ this.quadList[3].vertexPositions[3].vector3D.yCoord=ys[6];
+ this.quadList[3].vertexPositions[3].vector3D.zCoord=zs[6];
+ this.quadList[5].vertexPositions[2].vector3D.xCoord=xs[6];
+ this.quadList[5].vertexPositions[2].vector3D.yCoord=ys[6];
+ this.quadList[5].vertexPositions[2].vector3D.zCoord=zs[6];
+ this.quadList[1].vertexPositions[2].vector3D.xCoord=xs[7];
+ this.quadList[1].vertexPositions[2].vector3D.yCoord=ys[7];
+ this.quadList[1].vertexPositions[2].vector3D.zCoord=zs[7];
+ this.quadList[3].vertexPositions[2].vector3D.xCoord=xs[7];
+ this.quadList[3].vertexPositions[2].vector3D.yCoord=ys[7];
+ this.quadList[3].vertexPositions[2].vector3D.zCoord=zs[7];
+ this.quadList[5].vertexPositions[3].vector3D.xCoord=xs[7];
+ this.quadList[5].vertexPositions[3].vector3D.yCoord=ys[7];
+ this.quadList[5].vertexPositions[3].vector3D.zCoord=zs[7];
+ }
+}
diff --git a/src/main/java/ihl/model/ModelTube.java b/src/main/java/ihl/model/ModelTube.java new file mode 100644 index 0000000..6fd6c36 --- /dev/null +++ b/src/main/java/ihl/model/ModelTube.java @@ -0,0 +1,274 @@ +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
+ */
+ private PositionTextureVertex[] vertexPositions;
+
+ /** An array of 6 TexturedQuads, one for each face of a cube */
+ private TexturedQuad[] quadList;
+
+ /** X vertex coordinate of lower box corner */
+ public final float posX1;
+
+ /** Y vertex coordinate of lower box corner */
+ public final float posY1;
+
+ /** Z vertex coordinate of lower box corner */
+ public final float posZ1;
+
+ /** X vertex coordinate of upper box corner */
+ public final float posX2;
+
+ /** Y vertex coordinate of upper box corner */
+ public final float posY2;
+
+ /** Z vertex coordinate of upper box corner */
+ public final float posZ2;
+ public String field_78247_g;
+ private ForgeDirection direction1;
+
+ private int displayListCache=-1;
+
+ public ModelTube(IHLModelRenderer par1ModelRenderer, int par2, int par3, float x1, float y1, float z1, int par7, int par8, int par9, float par10, float radius1, float radius2, ForgeDirection direction1_1)
+ {
+ this.direction1=direction1_1;
+ this.posX1 = x1;
+ this.posY1 = y1;
+ this.posZ1 = z1;
+ this.posX2 = x1 + par7;
+ this.posY2 = y1 + par8;
+ this.posZ2 = z1 + par9;
+ this.vertexPositions = new PositionTextureVertex[32];
+ this.quadList = new TexturedQuad[32];
+ float x2 = x1 + par7;
+ float y2 = y1 + par8;
+ float z2 = z1 + par9;
+ x1 -= par10;
+ y1 -= par10;
+ z1 -= par10;
+ x2 += par10;
+ y2 += par10;
+ z2 += par10;
+ float textureWidth = 16f;
+ float textureHeight = 16f;
+ if (par1ModelRenderer!=null)
+ {
+ textureWidth = par1ModelRenderer.textureWidth;
+ textureHeight = par1ModelRenderer.textureHeight;
+ if(par1ModelRenderer.mirror)
+ {
+ float var14 = x2;
+ x2 = x1;
+ x1 = var14;
+ }
+ }
+ float dx = x2-x1 ;
+ float dy = y2-y1;
+ float dz = z2-z1;
+ PositionTextureVertex[] outervertexes1 = new PositionTextureVertex[8];
+ PositionTextureVertex[] innervertexes1 = new PositionTextureVertex[8];
+ PositionTextureVertex[] outervertexes2 = new PositionTextureVertex[8];
+ PositionTextureVertex[] innervertexes2 = new PositionTextureVertex[8];
+ int i=0;
+ for(i=0;i<8;i++)
+ {
+ switch(direction1)
+ {
+ case UP:
+ outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.5F*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ break;
+ case DOWN:
+ outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ break;
+ case SOUTH:
+ outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.5F*(float)Math.sin(2D*Math.PI/8D*i), z2, textureWidth, textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z2, textureWidth, textureHeight);
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z1, textureWidth, textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), z1, textureWidth, textureHeight);
+ break;
+ case NORTH:
+ outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z2, textureWidth, textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), z2, textureWidth, textureHeight);
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.5F*(float)Math.sin(2D*Math.PI/8D*i), z1, textureWidth, textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1+dy*0.5F+dy*0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1, textureWidth, textureHeight);
+ break;
+ case EAST:
+ outervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.5F*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.5F*(float)Math.cos(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ outervertexes2[i] = new PositionTextureVertex(x2, y1+dy*0.5F+dy*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x2, y1+dy*0.5F+dy*0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ break;
+ case WEST:
+ outervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1, y1+dy*0.5F+dy*0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ outervertexes2[i] = new PositionTextureVertex(x2, y1+dy*0.5F+dy*0.5F*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*0.5F*(float)Math.cos(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x2, y1+dy*0.5F+dy*0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), z1+dz*0.5F+dz*radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ break;
+ default:
+ outervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.5F*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes1[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y1, z1+dz*0.5F+dz*0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ outervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ innervertexes2[i] = new PositionTextureVertex(x1+dx*0.5F+dx*radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), y2, z1+dz*0.5F+dz*0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), textureWidth, textureHeight);
+ break;
+ }
+ }
+ for(i=0;i<32;i++)
+ {
+ if(i<8)
+ {
+ this.vertexPositions[i]=outervertexes1[i];
+ }
+ else if(i<16)
+ {
+ this.vertexPositions[i]=innervertexes1[i-8];
+ }
+ else if(i<24)
+ {
+ this.vertexPositions[i]=outervertexes2[i-16];
+ }
+ else
+ {
+ this.vertexPositions[i]=innervertexes2[i-24];
+ }
+ }
+
+ if(par1ModelRenderer!=null && par1ModelRenderer.drawFromInside)
+ {
+ for(i=0;i<32;i++)
+ {
+ if(i<7)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i],innervertexes1[i],innervertexes1[i+1],outervertexes1[i+1]},par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ }
+ else if(i==7)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i],innervertexes1[i],innervertexes1[0],outervertexes1[0]},par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ }
+ else if(i<15)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes2[i-8],outervertexes2[i-8],outervertexes2[i+1-8],innervertexes2[i+1-8]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ }
+ else if(i==15)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes2[i-8],outervertexes2[i-8],outervertexes2[0],innervertexes2[0]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ }
+ else if(i<23)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i-16],outervertexes1[i-16+1],outervertexes2[i-16+1],outervertexes2[i-16]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ }
+ else if(i==23)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i-16],outervertexes1[0],outervertexes2[0],outervertexes2[i-16]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ }
+ else if(i<31)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[i-24+1],innervertexes1[i-24],innervertexes2[i-24],innervertexes2[i-24+1]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ }
+ else if(i==31)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[0],innervertexes1[i-24],innervertexes2[i-24],innervertexes2[0]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ }
+ }
+ }
+ else
+ {
+ for(i=0;i<32;i++)
+ {
+ if(i<7)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i],outervertexes1[i+1],innervertexes1[i+1],innervertexes1[i]},par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ }
+ else if(i==7)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i],outervertexes1[0],innervertexes1[0],innervertexes1[i]},par2 + par9 + par7, par3 + par9, par2 + par9 + par7 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ }
+ else if(i<15)
+ {
+ //this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes2[i-8],outervertexes2[i+1-8],innervertexes2[i+1-8],innervertexes2[i-8]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes2[i-8],innervertexes2[i+1-8],outervertexes2[i+1-8],outervertexes2[i-8]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ }
+ else if(i==15)
+ {
+ //this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes2[i-8],outervertexes2[0],innervertexes2[0],innervertexes2[i-8]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes2[i-8],innervertexes2[0],outervertexes2[0],outervertexes2[i-8]},par2, par3 + par9, par2 + par9, par3 + par9 + par8, textureWidth, textureHeight);
+ }
+ else if(i<23)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[i-16+1],outervertexes1[i-16+1]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ }
+ else if(i==23)
+ {
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[0],outervertexes1[0]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ }
+ else if(i<31)
+ {
+ //this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[i-24],innervertexes2[i-24],innervertexes2[i-24+1],innervertexes1[i-24+1]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[i-24+1],innervertexes2[i-24+1], innervertexes2[i-24], innervertexes1[i-24]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ }
+ else if(i==31)
+ {
+ //this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[i-24],innervertexes2[i-24],innervertexes2[0],innervertexes1[0]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ this.quadList[i]=new TexturedQuad(new PositionTextureVertex[] {innervertexes1[0],innervertexes2[0],innervertexes2[i-24],innervertexes1[i-24]},par2 + par9, par3, par2 + par9 + par7, par3 + par9, textureWidth, textureHeight);
+ }
+ }
+ }
+ if (par1ModelRenderer!=null && par1ModelRenderer.mirror)
+ {
+ for (int var22 = 0; var22 < this.quadList.length; ++var22)
+ {
+ this.quadList[var22].flipFace();
+ }
+ }
+ }
+
+ public void render(Tessellator par1Tessellator, float par2)
+ {
+ for(int i=0;i<this.quadList.length;i++)
+ {
+ this.quadList[i].draw(par1Tessellator, par2);
+ }
+ }
+
+ public void renderCached(Tessellator par1Tessellator, float par2)
+ {
+ if (this.displayListCache != -1)
+ {
+ GL11.glCallList(displayListCache);
+ }
+ else
+ {
+ this.displayListCache=GLAllocation.generateDisplayLists(1);
+ GL11.glNewList(displayListCache, 4864 /*GL_COMPILE*/);
+ for(int i=/*16*/0;i<=23;i++)
+ {
+ this.quadList[i].draw(par1Tessellator, par2);
+ }
+ GL11.glEndList();
+ }
+ }
+
+ public ModelTube func_78244_a(String par1Str)
+ {
+ this.field_78247_g = par1Str;
+ return this;
+ }
+}
diff --git a/src/main/java/ihl/model/RectifierTransformerUnitBlockRender.java b/src/main/java/ihl/model/RectifierTransformerUnitBlockRender.java new file mode 100644 index 0000000..9f45ee4 --- /dev/null +++ b/src/main/java/ihl/model/RectifierTransformerUnitBlockRender.java @@ -0,0 +1,415 @@ +package ihl.model;
+
+import org.lwjgl.opengl.GL11;
+
+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;
+import ic2.api.tile.IWrenchable;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraftforge.common.util.ForgeDirection;
+
+@SideOnly(value=Side.CLIENT)
+public class RectifierTransformerUnitBlockRender implements ISimpleBlockRenderingHandler
+{
+ public static int renderId;
+
+ public RectifierTransformerUnitBlockRender()
+ {
+ renderId = RenderingRegistry.getNextAvailableRenderId();
+ }
+
+ @Override
+ public int getRenderId()
+ {
+ return renderId;
+ }
+
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderblocks)
+ {
+ Tessellator tessellator = Tessellator.instance;
+ GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+ tessellator.startDrawingQuads();
+ for(int i=0;i<=43;i++)
+ {
+ this.setBounds(i, renderblocks, block);
+ tessellator.setNormal(0.0F, -1.0F, 0.0F);
+ renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(0.0F, 1.0F, 0.0F);
+ renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(0.0F, 0.0F, -1.0F);
+ renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(0.0F, 0.0F, 1.0F);
+ renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(-1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ tessellator.setNormal(1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, 0));
+ }
+
+
+ this.setBounds(44, renderblocks, block);
+ renderblocks.renderFaceXNeg(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceXPos(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceZNeg(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceZPos(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceYNeg(block,0, 0, 0, block.getIcon(5, 0));
+
+ this.setBounds(45, renderblocks, block);
+ renderblocks.renderFaceXNeg(block,0, 0, 0, block.getIcon(5, 0));
+ renderblocks.renderFaceXPos(block,0, 0, 0, block.getIcon(5, 0));
+ renderblocks.renderFaceZNeg(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceZPos(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceYNeg(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceYPos(block,0, 0, 0, block.getIcon(0, 0));
+
+ this.setBounds(46, renderblocks, block);
+ renderblocks.renderFaceXNeg(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceXPos(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceZNeg(block,0, 0, 0, block.getIcon(5, 0));
+ renderblocks.renderFaceZPos(block,0, 0, 0, block.getIcon(5, 0));
+ renderblocks.renderFaceYNeg(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceYPos(block,0, 0, 0, block.getIcon(0, 0));
+
+ this.setBounds(47, renderblocks, block);
+ renderblocks.renderFaceXNeg(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceXPos(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceZNeg(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceZPos(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceYNeg(block,0, 0, 0, block.getIcon(0, 0));
+ renderblocks.renderFaceYPos(block,0, 0, 0, block.getIcon(4, 0));
+
+
+ IHLRenderUtils.instance.setPosition(0, 0, 0);
+ IHLRenderUtils.instance.setRotationPoint(0F, 16F, 0F);
+ IHLRenderUtils.instance.setRotation(0F, 0f, 0F);
+
+ IIcon icon = block.getIcon(1, 0);
+ IHLRenderUtils.instance.drawPipe(-6F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-6F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-6F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ IHLRenderUtils.instance.drawPipe(2F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(2F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(2F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ icon = block.getIcon(2, 0);
+ IHLRenderUtils.instance.drawPipe(-4.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ icon = block.getIcon(3, 0);
+ IHLRenderUtils.instance.drawPipe(3.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+
+ tessellator.draw();
+ GL11.glTranslatef(0.5F, 0.5F, 0.5F);
+ renderblocks.clearOverrideBlockTexture();
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta, RenderBlocks renderblocks)
+ {
+ Tessellator var5 = Tessellator.instance;
+ var5.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z));
+ int var6 = block.colorMultiplier(blockAccess, x, y, z);
+ float var7 = (var6 >> 16 & 255) / 255.0F;
+ float var8 = (var6 >> 8 & 255) / 255.0F;
+ float var9 = (var6 & 255) / 255.0F;
+ var5.setColorOpaque_F(var7, var8, var9);
+ for(int i=0;i<=43;i++)
+ {
+ this.setBounds(i, renderblocks, block);
+ renderblocks.renderStandardBlock(block, x, y, z);
+ }
+
+ this.setBounds(44, renderblocks, block);
+ renderblocks.renderFaceXNeg(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceXPos(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceZNeg(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceZPos(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceYNeg(block, x, y, z, block.getIcon(5, 0));
+
+ this.setBounds(45, renderblocks, block);
+ renderblocks.renderFaceXNeg(block, x, y, z, block.getIcon(5, 0));
+ renderblocks.renderFaceXPos(block, x, y, z, block.getIcon(5, 0));
+ renderblocks.renderFaceZNeg(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceZPos(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceYPos(block, x, y, z, block.getIcon(0, 0));
+
+ this.setBounds(46, renderblocks, block);
+ renderblocks.renderFaceXNeg(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceXPos(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceZNeg(block, x, y, z, block.getIcon(5, 0));
+ renderblocks.renderFaceZPos(block, x, y, z, block.getIcon(5, 0));
+ renderblocks.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceYPos(block, x, y, z, block.getIcon(0, 0));
+
+ this.setBounds(47, renderblocks, block);
+ renderblocks.renderFaceXNeg(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceXPos(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceZNeg(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceZPos(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0));
+ renderblocks.renderFaceYPos(block, x, y, z, block.getIcon(4, 0));
+
+ IHLRenderUtils.instance.setPosition(x, y, z);
+ IHLRenderUtils.instance.setRotationPoint(0F, 16F, 0F);
+ IHLRenderUtils.instance.setRotation(0F, 0f, 0F);
+
+ IIcon icon = block.getIcon(1, 0);
+
+ TileEntity tile = blockAccess.getTileEntity(x, y, z);
+ if(tile!=null && tile.getWorldObj() != null)
+ {
+ switch (((IWrenchable)tile).getFacing())
+ {
+ case 2:
+ IHLRenderUtils.instance.drawPipe(-6F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-6F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-6F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ IHLRenderUtils.instance.drawPipe(2F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(2F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(2F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ icon = block.getIcon(2, 0);
+ IHLRenderUtils.instance.drawPipe(-4.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ icon = block.getIcon(3, 0);
+ IHLRenderUtils.instance.drawPipe(3.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ break;
+ case 5:
+ IHLRenderUtils.instance.drawPipe(-2F, -14F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -12F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -10F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ IHLRenderUtils.instance.drawPipe(-2F, -14F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -12F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -10F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ icon = block.getIcon(2, 0);
+ IHLRenderUtils.instance.drawPipe(-0.5F, -16F, -4.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ icon = block.getIcon(3, 0);
+ IHLRenderUtils.instance.drawPipe(-0.5F, -16F, 3.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ break;
+ case 3:
+ IHLRenderUtils.instance.drawPipe(-6F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-6F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-6F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ IHLRenderUtils.instance.drawPipe(2F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(2F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(2F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ icon = block.getIcon(3, 0);
+ IHLRenderUtils.instance.drawPipe(-4.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ icon = block.getIcon(2, 0);
+ IHLRenderUtils.instance.drawPipe(3.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ break;
+ case 4:
+ IHLRenderUtils.instance.drawPipe(-2F, -14F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -12F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -10F, -6F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ IHLRenderUtils.instance.drawPipe(-2F, -14F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -12F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -10F, 2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ icon = block.getIcon(3, 0);
+ IHLRenderUtils.instance.drawPipe(-0.5F, -16F, -4.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ icon = block.getIcon(2, 0);
+ IHLRenderUtils.instance.drawPipe(-0.5F, -16F, 3.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ break;
+ default:
+ IHLRenderUtils.instance.drawPipe(-6F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-6F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-6F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ IHLRenderUtils.instance.drawPipe(2F, -14F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(2F, -12F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(2F, -10F, -2F, 4, 2, 4, 0f, 0.5f,ForgeDirection.UP,icon);
+
+ icon = block.getIcon(2, 0);
+ IHLRenderUtils.instance.drawPipe(-4.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ icon = block.getIcon(3, 0);
+ IHLRenderUtils.instance.drawPipe(3.5F, -16F, -0.5F, 1, 2, 1, 0f, 1f, ForgeDirection.UP,icon);
+ break;
+ }
+ }
+ return true;
+ }
+
+ private void setBounds(int index, RenderBlocks renderblocks, Block block)
+ {
+ double rt = 1/11d;
+ switch(index)
+ {
+ case 0:
+ renderblocks.setRenderBounds(rt, 0d, 0d, rt*2, 1d, rt);
+ break;
+ case 1:
+ renderblocks.setRenderBounds(rt*3, rt*8, 0d, rt*4, 1d, rt);
+ break;
+ case 2:
+ renderblocks.setRenderBounds(rt*5, rt*8, 0d, rt*6, 1d, rt);
+ break;
+ case 3:
+ renderblocks.setRenderBounds(rt*7, rt*8, 0d, rt*8, 1d, rt);
+ break;
+ case 4:
+ renderblocks.setRenderBounds(rt*3, 0d, 0d, rt*4, rt*3, rt);
+ break;
+ case 5:
+ renderblocks.setRenderBounds(rt*5, 0d, 0d, rt*6, rt*3, rt);
+ break;
+ case 6:
+ renderblocks.setRenderBounds(rt*7, 0d, 0d, rt*8, rt*3, rt);
+ break;
+ case 7:
+ renderblocks.setRenderBounds(rt*9, 0d, 0d, rt*10, 1d, rt);
+ break;
+
+ case 8:
+ renderblocks.setRenderBounds(rt, 0d, rt*10, rt*2, 1d, 1d);
+ break;
+ case 9:
+ renderblocks.setRenderBounds(rt*3, rt*8, rt*10, rt*4, 1d, 1d);
+ break;
+ case 10:
+ renderblocks.setRenderBounds(rt*5, rt*8, rt*10, rt*6, 1d, 1d);
+ break;
+ case 11:
+ renderblocks.setRenderBounds(rt*7, rt*8, rt*10, rt*8, 1d, 1d);
+ break;
+ case 12:
+ renderblocks.setRenderBounds(rt*3, 0d, rt*10, rt*4, rt*3, 1d);
+ break;
+ case 13:
+ renderblocks.setRenderBounds(rt*5, 0d, rt*10, rt*6, rt*3, 1d);
+ break;
+ case 14:
+ renderblocks.setRenderBounds(rt*7, 0d, rt*10, rt*8, rt*3, 1d);
+ break;
+ case 15:
+ renderblocks.setRenderBounds(rt*9, 0d, rt*10, rt*10, 1d, 1d);
+ break;
+
+ case 16:
+ renderblocks.setRenderBounds(0d, 0d, rt, rt, 1d, rt*2);
+ break;
+ case 17:
+ renderblocks.setRenderBounds(0d,rt*8, rt*3,rt,1d, rt*4);
+ break;
+ case 18:
+ renderblocks.setRenderBounds(0d,rt*8, rt*5,rt, 1d, rt*6);
+ break;
+ case 19:
+ renderblocks.setRenderBounds(0d,rt*8, rt*7,rt,1d, rt*8);
+ break;
+ case 20:
+ renderblocks.setRenderBounds(0d,0d, rt*3, rt, rt*3,rt*4);
+ break;
+ case 21:
+ renderblocks.setRenderBounds(0d,0d, rt*5,rt, rt*3, rt*6);
+ break;
+ case 22:
+ renderblocks.setRenderBounds(0d,0d, rt*7, rt,rt*3, rt*8);
+ break;
+ case 23:
+ renderblocks.setRenderBounds(0d,0d, rt*9,rt,1d, rt*10);
+ break;
+
+ case 24:
+ renderblocks.setRenderBounds(rt*10, 0d, rt, 1d, 1d, rt*2);
+ break;
+ case 25:
+ renderblocks.setRenderBounds(rt*10, rt*8, rt*3, 1d, 1d, rt*4);
+ break;
+ case 26:
+ renderblocks.setRenderBounds(rt*10, rt*8, rt*5,1d, 1d, rt*6);
+ break;
+ case 27:
+ renderblocks.setRenderBounds(rt*10, rt*8, rt*7, 1d, 1d, rt*8);
+ break;
+ case 28:
+ renderblocks.setRenderBounds(rt*10, 0d, rt*3, 1d, rt*3, rt*4);
+ break;
+ case 29:
+ renderblocks.setRenderBounds(rt*10, 0d, rt*5,1d, rt*3, rt*6);
+ break;
+ case 30:
+ renderblocks.setRenderBounds(rt*10, 0d, rt*7,1d, rt*3, rt*8);
+ break;
+ case 31:
+ renderblocks.setRenderBounds(rt*10, 0d, rt*9, 1d, 1d, rt*10);
+ break;
+
+ case 32:
+ renderblocks.setRenderBounds(rt, 0d, rt*3, rt*3, rt, rt*4);
+ break;
+ case 33:
+ renderblocks.setRenderBounds(rt, 0d, rt*5, rt*3, rt, rt*6);
+ break;
+ case 34:
+ renderblocks.setRenderBounds(rt, 0d, rt*7, rt*3, rt, rt*8);
+ break;
+ case 35:
+ renderblocks.setRenderBounds(rt*8, 0d, rt*3, rt*10, rt, rt*4);
+ break;
+ case 36:
+ renderblocks.setRenderBounds(rt*8, 0d, rt*5, rt*10, rt, rt*6);
+ break;
+ case 37:
+ renderblocks.setRenderBounds(rt*8, 0d, rt*7, rt*10, rt, rt*8);
+ break;
+
+ case 38:
+ renderblocks.setRenderBounds(rt*3, 0d, rt, rt*4, rt, rt*3);
+ break;
+ case 39:
+ renderblocks.setRenderBounds(rt*5, 0d, rt, rt*6, rt, rt*3);
+ break;
+ case 40:
+ renderblocks.setRenderBounds(rt*7, 0d, rt, rt*8, rt, rt*3);
+ break;
+ case 41:
+ renderblocks.setRenderBounds(rt*3, 0d, rt*8, rt*4, rt, rt*10);
+ break;
+ case 42:
+ renderblocks.setRenderBounds(rt*5, 0d, rt*8, rt*6, rt, rt*10);
+ break;
+ case 43:
+ renderblocks.setRenderBounds(rt*7, 0d, rt*8, rt*8, rt, rt*10);
+ break;
+
+ case 44:
+ renderblocks.setRenderBounds(rt*3, 0d, rt*3, rt*8, rt, rt*8);
+ break;
+
+ case 45:
+ renderblocks.setRenderBounds(0d, rt*3, rt*3, 1d, rt*8, rt*8);
+ break;
+
+ case 46:
+ renderblocks.setRenderBounds(rt*3, rt*3, 0d, rt*8, rt*8, 1d);
+ break;
+
+ case 47:
+ renderblocks.setRenderBounds(rt, rt, rt, rt*10, 1d, rt*10);
+ break;
+
+ }
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory(int arg0)
+ {
+ return true;
+ }
+}
diff --git a/src/main/java/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java b/src/main/java/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java new file mode 100644 index 0000000..4ce866b --- /dev/null +++ b/src/main/java/ihl/model/RectifierTransformerUnitSelectionBoxSpecialRenderer.java @@ -0,0 +1,51 @@ +package ihl.model; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ihl.flexible_cable.RectifierTransformerUnitTileEntity; +import ihl.interfaces.ISelectionBoxSpecialRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MovingObjectPosition; + +@SideOnly(value=Side.CLIENT) +public class RectifierTransformerUnitSelectionBoxSpecialRenderer implements ISelectionBoxSpecialRenderer +{ + @Override + public void drawSelectionBox(EntityPlayer player, ItemStack currentItem, MovingObjectPosition movingObjectPosition, float partialTick) + { + double offsetX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTick; + double offsetY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTick; + double offsetZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTick; + RectifierTransformerUnitTileEntity tile = (RectifierTransformerUnitTileEntity) Minecraft.getMinecraft().theWorld.getTileEntity(movingObjectPosition.blockX, movingObjectPosition.blockY, movingObjectPosition.blockZ); + if(tile!=null && tile.getWorldObj() != null) + { + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glLineWidth(2.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(false); + short side = tile.getSide(player); + if(side==0) + { + GL11.glColor4f(0.0F, 1.0F, 0.0F, 0.8F); + RenderGlobal.drawOutlinedBoundingBox(tile.aabb1.getOffsetBoundingBox(-offsetX, -offsetY, -offsetZ), -1); + RenderGlobal.drawOutlinedBoundingBox(tile.aabb1_1.getOffsetBoundingBox(-offsetX, -offsetY, -offsetZ), -1); + } + else if(side==1) + { + GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.8F); + RenderGlobal.drawOutlinedBoundingBox(tile.aabb2.getOffsetBoundingBox(-offsetX, -offsetY, -offsetZ), -1); + RenderGlobal.drawOutlinedBoundingBox(tile.aabb2_1.getOffsetBoundingBox(-offsetX, -offsetY, -offsetZ), -1); + } + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + } + } +} diff --git a/src/main/java/ihl/model/RefluxCondenserBlockRender.java b/src/main/java/ihl/model/RefluxCondenserBlockRender.java new file mode 100644 index 0000000..c9021b9 --- /dev/null +++ b/src/main/java/ihl/model/RefluxCondenserBlockRender.java @@ -0,0 +1,125 @@ +package ihl.model;
+
+import org.lwjgl.opengl.GL11;
+
+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;
+import ic2.api.tile.IWrenchable;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraftforge.common.util.ForgeDirection;
+
+@SideOnly(value=Side.CLIENT)
+public class RefluxCondenserBlockRender implements ISimpleBlockRenderingHandler
+{
+ public static int renderId;
+
+ public RefluxCondenserBlockRender()
+ {
+ renderId = RenderingRegistry.getNextAvailableRenderId();
+ }
+
+ @Override
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderblocks)
+ {
+ Tessellator tessellator = Tessellator.instance;
+ IHLRenderUtils.instance.reset();
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+ tessellator.startDrawingQuads();
+ IIcon icon = block.getIcon(0, 0);
+ IHLRenderUtils.instance.setPosition(0, 0, 0);
+ IHLRenderUtils.instance.setRotationPoint(0F, 16F, 0F);
+ IHLRenderUtils.instance.setRotation(0F, 0f, 0F);
+ IHLRenderUtils.instance.drawPipe(-2F, 7F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawKnee(-8F, 2F, -3F, 5, 6, 6, .8F, 1F, ForgeDirection.UP, ForgeDirection.EAST,icon);
+ IHLRenderUtils.instance.drawPipe(3.5F, -7F, -1.5F, 4, 3, 3, 0.8f, 1f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(7F, -7.5F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(7F, 3F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(-3F, 3.5F, -1.5F, 10, 3, 3, .8F, 1F, ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -8F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-1.5F, -7F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-1.5F, 5F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -2F, -8F, 4, 4, 1, 0.6f, 1f,ForgeDirection.NORTH,icon);
+ IHLRenderUtils.instance.drawPipe(-1.5F, -1.5F, -7F, 3, 3, 7, 0.8f, 1f,ForgeDirection.NORTH,icon);
+ IHLRenderUtils.instance.setRotationPoint(3F, 16F, 0F);
+ IHLRenderUtils.instance.setRotation(0F, 0f, -0.5F);
+ IHLRenderUtils.instance.drawPipe(1F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(-9F, -4F, -4F, 10, 8, 8, 0.8f, 1f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(-11F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.EAST,icon);
+ tessellator.draw();
+ GL11.glTranslatef(0.5F, 0.5F, 0.5F);
+ }
+
+ @Override
+ public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta, RenderBlocks blockRenderer)
+ {
+ IHLRenderUtils.instance.reset();
+ TileEntity tile = blockAccess.getTileEntity(x, y, z);
+ if(tile.getWorldObj() != null)
+ {
+ switch (((IWrenchable)tile).getFacing())
+ {
+ case 5:
+ IHLRenderUtils.instance.renderFromInside=true;
+ IHLRenderUtils.instance.swapXandZ=true;
+ IHLRenderUtils.instance.swapRenderBoundsZ=true;
+ break;
+ case 3:
+ IHLRenderUtils.instance.swapRenderBoundsX=true;
+ IHLRenderUtils.instance.swapRenderBoundsZ=true;
+ break;
+ case 4:
+ IHLRenderUtils.instance.renderFromInside=true;
+ IHLRenderUtils.instance.swapXandZ=true;
+ IHLRenderUtils.instance.swapRenderBoundsX=true;
+ break;
+ default:
+ }
+ }
+ Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(blockAccess, x, y, z));
+ int colorMultiplier = block.colorMultiplier(blockAccess, x, y, z);
+ float red = (colorMultiplier >> 16 & 255) / 255.0F;
+ float green = (colorMultiplier >> 8 & 255) / 255.0F;
+ float blue = (colorMultiplier & 255) / 255.0F;
+ Tessellator.instance.setColorOpaque_F(red, green, blue);
+ IIcon icon = block.getBlockTextureFromSide(0);
+ IHLRenderUtils.instance.setPosition(x, y, z);
+ IHLRenderUtils.instance.setRotationPoint(0F, 16F, 0F);
+ IHLRenderUtils.instance.setRotation(0F, 0f, 0F);
+ IHLRenderUtils.instance.drawPipe(-2F, 7F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawKnee(-8F, 2F, -3F, 5, 6, 6, .8F, 1F, ForgeDirection.UP, ForgeDirection.EAST,icon);
+ IHLRenderUtils.instance.drawPipe(3.5F, -7F, -1.5F, 4, 3, 3, 0.8f, 1f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(7F, -7.5F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(7F, 3F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(-3F, 3.5F, -1.5F, 10, 3, 3, .8F, 1F, ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -8F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-1.5F, -7F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-1.5F, 5F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP,icon);
+ IHLRenderUtils.instance.drawPipe(-2F, -2F, -8F, 4, 4, 1, 0.6f, 1f,ForgeDirection.NORTH,icon);
+ IHLRenderUtils.instance.drawPipe(-1.5F, -1.5F, -7F, 3, 3, 7, 0.8f, 1f,ForgeDirection.NORTH,icon);
+ IHLRenderUtils.instance.setRotationPoint(3F, 16F, 0F);
+ IHLRenderUtils.instance.setRotation(0F, 0f, -0.5F);
+ IHLRenderUtils.instance.drawPipe(1F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(-9F, -4F, -4F, 10, 8, 8, 0.8f, 1f,ForgeDirection.WEST,icon);
+ IHLRenderUtils.instance.drawPipe(-11F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.EAST,icon);
+ return true;
+ }
+
+ @Override
+ public boolean shouldRender3DInInventory(int arg0)
+ {
+ return true;
+ }
+
+ @Override
+ public int getRenderId() {
+ return renderId;
+ }
+}
diff --git a/src/main/java/ihl/model/RenderInfo.java b/src/main/java/ihl/model/RenderInfo.java new file mode 100644 index 0000000..4e85f6f --- /dev/null +++ b/src/main/java/ihl/model/RenderInfo.java @@ -0,0 +1,71 @@ +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;
+ public IIcon[] texture = null;
+ public IIcon override = null;
+ public float minX = 0;
+ public float minY = 0;
+ public float minZ = 0;
+ public float maxX = 1;
+ public float maxY = 1;
+ public float maxZ = 1;
+ public boolean[] renderSide = new boolean[6];
+ public float light = -1f;
+ public int brightness = -1;
+
+ public RenderInfo() {
+ setRenderAllSides();
+ }
+
+ public RenderInfo(Block template, IIcon[] texture) {
+ this();
+ this.template = template;
+ this.texture = texture;
+ }
+
+ public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
+ this();
+ setBlockBounds(minX, minY, minZ, maxX, maxY, maxZ);
+ }
+
+ public final void setBlockBounds(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
+ this.minX = minX;
+ this.minY = minY;
+ this.minZ = minZ;
+ this.maxX = maxX;
+ this.maxY = maxY;
+ this.maxZ = maxZ;
+ }
+
+ public final void setRenderSingleSide(int side) {
+ Arrays.fill(renderSide, false);
+ renderSide[side] = true;
+ }
+
+ public final void setRenderAllSides() {
+ Arrays.fill(renderSide, true);
+ }
+
+ public IIcon getBlockTextureFromSide(int i) {
+ if (override != null)
+ return override;
+ if (texture == null || texture.length == 0)
+ return template.getBlockTextureFromSide(i);
+ else {
+ if (i >= texture.length)
+ i = 0;
+ return texture[i];
+ }
+ }
+}
diff --git a/src/main/java/ihl/model/UniversalTileRender.java b/src/main/java/ihl/model/UniversalTileRender.java new file mode 100644 index 0000000..d3cb4c6 --- /dev/null +++ b/src/main/java/ihl/model/UniversalTileRender.java @@ -0,0 +1,76 @@ +package ihl.model;
+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;
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.model.ModelRenderer;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+
+public class UniversalTileRender extends TileEntitySpecialRenderer{
+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;
+ this.tex=texture;
+}
+
+ @Override
+ public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8)
+ {
+ int rotation = 0;
+ if(tile.getWorldObj() != null)
+ {
+ switch (((IWrenchable)tile).getFacing())
+ {
+ case 2:
+ rotation = 0;
+ break;
+ case 5:
+ rotation = 1;
+ break;
+ case 3:
+ rotation = 2;
+ break;
+ case 4:
+ rotation = 3;
+ break;
+ default:
+ rotation = 0;
+ }
+ }
+ GL11.glPushMatrix();
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
+ GL11.glScalef(1.0F, -1F, -1F);
+ GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F);
+
+ bindTexture(tex);
+ for(int i = 0;i<model.boxList.size();i++)
+ {
+ if(model.boxList.get(i) instanceof ModelRenderer)
+ {
+ ModelRenderer piece = (ModelRenderer) model.boxList.get(i);
+ piece.render(scale);
+ }
+ else if(model.boxList.get(i) instanceof IHLModelRenderer)
+ {
+ IHLModelRenderer piece = (IHLModelRenderer) model.boxList.get(i);
+ piece.render(scale);
+ }
+ }
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glPopMatrix(); //end
+
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/nei_integration/AchesonFurnaceRecipeHandler.java b/src/main/java/ihl/nei_integration/AchesonFurnaceRecipeHandler.java new file mode 100644 index 0000000..2ffa450 --- /dev/null +++ b/src/main/java/ihl/nei_integration/AchesonFurnaceRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.metallurgy.AchesonFurnaceGui;
+import ihl.processing.metallurgy.AchesonFurnanceTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class AchesonFurnaceRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return AchesonFurnaceGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{40-5,40-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{40-11,22-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{98-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{32-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.achesonFurnace";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIAchesonFurnace.png";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(57-5, 29-11, 40, 30), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "achesonFurnace";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return AchesonFurnanceTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/ChemicalReactorRecipeHandler.java b/src/main/java/ihl/nei_integration/ChemicalReactorRecipeHandler.java new file mode 100644 index 0000000..53eeb8d --- /dev/null +++ b/src/main/java/ihl/nei_integration/ChemicalReactorRecipeHandler.java @@ -0,0 +1,125 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import org.lwjgl.opengl.GL11;
+
+import codechicken.lib.gui.GuiDraw;
+import ihl.processing.chemistry.ChemicalReactorGui;
+import ihl.processing.chemistry.ChemicalReactorTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.StatCollector;
+
+
+public class ChemicalReactorRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return ChemicalReactorGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{104-5,122-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{15-11};
+ }
+
+ @Override
+ protected int[] getFluidInputPosX()
+ {
+ return new int[]{60-5,42-5,24-5};
+ }
+
+ @Override
+ protected int[] getFluidInputPosY()
+ {
+ return new int[]{15-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{104-5,122-5};
+ }
+
+ @Override
+ protected int[] getFluidOutputPosX()
+ {
+ return new int[]{42-5,60-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{51-11};
+ }
+
+ @Override
+ protected int[] getFluidOutputPosY()
+ {
+ return new int[]{51-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.chemicalReactor";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIChemicalReactor.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "chemicalReactor";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(103-5,32-10, 36, 18), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public void drawExtras(int recipeNumber)
+ {
+ super.drawExtras(recipeNumber);
+ MachineRecipeHandler.CachedIORecipe recipe = (CachedIORecipe) this.arecipes.get(recipeNumber);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiDraw.drawTexturedModalRect(103-18-5, 52-11, 246, 226+6*(this.ticks%4),10,6);
+ if(recipe.specialConditions)
+ {
+ GuiDraw.drawTexturedModalRect(0, 32-11, 0, 166,134,18);
+ GuiDraw.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.use_with_cryogenic_distiller"), 0, 27, 16777215);
+ }
+ }
+
+ @Override
+ public void drawBackground(int i)
+ {
+ super.drawBackground(i);
+ GuiDraw.drawTexturedModalRect(23-5, 14-11, 59, 14, 18, 18);
+ GuiDraw.drawTexturedModalRect(41-5, 14-11, 59, 14, 18, 18);
+ GuiDraw.drawTexturedModalRect(41-5, 50-11, 59, 50, 18, 18);
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return ChemicalReactorTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/CrucibleRecipeHandler.java b/src/main/java/ihl/nei_integration/CrucibleRecipeHandler.java new file mode 100644 index 0000000..87bd6a2 --- /dev/null +++ b/src/main/java/ihl/nei_integration/CrucibleRecipeHandler.java @@ -0,0 +1,79 @@ +package ihl.nei_integration;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import codechicken.nei.PositionedStack;
+import ihl.processing.metallurgy.Crucible;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class CrucibleRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return null;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{11-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{15-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{106-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{51-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.crucible";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUICrucibleNEI.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "crucible";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return Crucible.getRecipes();
+ }
+
+ @Override
+ public List<PositionedStack> getAdditionalIngredients()
+ {
+ List<PositionedStack> ps = new ArrayList<PositionedStack>();
+ ps.add(new PositionedStack(IHLUtils.getThisModItemStackWithDamage("crucible", 0),61-5,15-11));
+ ps.add(new PositionedStack(IHLUtils.getThisModItemStackWithDamage("crucible", 1),106-5,15-11));
+ return ps;
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/CryogenicDistillerRecipeHandler.java b/src/main/java/ihl/nei_integration/CryogenicDistillerRecipeHandler.java new file mode 100644 index 0000000..374d66e --- /dev/null +++ b/src/main/java/ihl/nei_integration/CryogenicDistillerRecipeHandler.java @@ -0,0 +1,106 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.lwjgl.opengl.GL11;
+
+import codechicken.lib.gui.GuiDraw;
+import ic2.core.item.ItemFluidCell;
+import ihl.processing.chemistry.CryogenicDistillerGui;
+import ihl.processing.chemistry.CryogenicDistillerTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.FluidStack;
+
+
+public class CryogenicDistillerRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return CryogenicDistillerGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{103-5};
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(57-5, 32-10, 63, 18), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{51-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{123-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{33-11,51-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.cryogenicDistiller";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUICryogenicDistiller.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "cryogenicDistiller";
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void drawExtras(int recipeNumber)
+ {
+ super.drawExtras(recipeNumber);
+ MachineRecipeHandler.CachedIORecipe recipe = (MachineRecipeHandler.CachedIORecipe) this.arecipes.get(recipeNumber);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ if(recipe.specialConditions)
+ {
+ GuiDraw.drawTexturedModalRect(0, 0, 0, 166, 97, 69);
+ String note = StatCollector.translateToLocal("ihl.as_byproduct_of_processing_of");
+ FluidStack fstack = ((ItemFluidCell)recipe.getIngredients().get(0).item.getItem()).getFluid(recipe.getIngredients().get(0).item);
+ note+=" "+ fstack.getLocalizedName();
+ note+=" "+ StatCollector.translateToLocal("ihl.in_chemical_reactor");
+ Iterator<String> noteListIterator = GuiDraw.fontRenderer.listFormattedStringToWidth(note, 90).iterator();
+ int yTextPos=0;
+ while(noteListIterator.hasNext())
+ {
+ GuiDraw.fontRenderer.drawStringWithShadow(noteListIterator.next(), 0, yTextPos, 16777215);
+ yTextPos+=10;
+ }
+ GuiDraw.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal("ihl.check_usage"), 0, 44, 16777215);
+ }
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return CryogenicDistillerTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/DetonationSprayingMachineRecipeHandler.java b/src/main/java/ihl/nei_integration/DetonationSprayingMachineRecipeHandler.java new file mode 100644 index 0000000..e821bef --- /dev/null +++ b/src/main/java/ihl/nei_integration/DetonationSprayingMachineRecipeHandler.java @@ -0,0 +1,82 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import codechicken.lib.gui.GuiDraw;
+import ihl.processing.metallurgy.DetonationSprayingMachineGui;
+import ihl.processing.metallurgy.DetonationSprayingMachineTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class DetonationSprayingMachineRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return DetonationSprayingMachineGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{10-5,98-5,117-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{17-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{10-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{53-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.detonationSprayingMachine";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIDetonationSprayingMachine.png";
+ }
+
+ @Override
+ public void drawBackground(int i)
+ {
+ super.drawBackground(i);
+ GuiDraw.drawTexturedModalRect(9-5, 34-11, 176, 0, 18, 36);
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(30-5,0, 60, 30), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "detonationSprayingMachine";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return DetonationSprayingMachineTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/ElectricEvaporatorRecipeHandler.java b/src/main/java/ihl/nei_integration/ElectricEvaporatorRecipeHandler.java new file mode 100644 index 0000000..349601a --- /dev/null +++ b/src/main/java/ihl/nei_integration/ElectricEvaporatorRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.chemistry.ElectricEvaporatorGui;
+import ihl.processing.chemistry.EvaporatorTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class ElectricEvaporatorRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return ElectricEvaporatorGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{39};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{3};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{112};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{21};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.electricEvaporator";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIElectricEvaporator.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "electricEvaporator";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(99-5,34-10, 17, 13), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return EvaporatorTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/ElectrolysisBathRecipeHandler.java b/src/main/java/ihl/nei_integration/ElectrolysisBathRecipeHandler.java new file mode 100644 index 0000000..bf91f03 --- /dev/null +++ b/src/main/java/ihl/nei_integration/ElectrolysisBathRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.chemistry.ElectrolysisBathGui;
+import ihl.processing.chemistry.ElectrolysisBathTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class ElectrolysisBathRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return ElectrolysisBathGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{6-5,98-5,78-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{16-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{6-5,87-5,106-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{52-11,51-11,15-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.electrolysisBath";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIElectrolysisBath.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "electrolysisBath";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(115-5,10-10, 172-115, 72), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return ElectrolysisBathTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/EvaporatorRecipeHandler.java b/src/main/java/ihl/nei_integration/EvaporatorRecipeHandler.java new file mode 100644 index 0000000..54eb4e9 --- /dev/null +++ b/src/main/java/ihl/nei_integration/EvaporatorRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.chemistry.EvaporatorGui;
+import ihl.processing.chemistry.EvaporatorTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class EvaporatorRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return EvaporatorGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{39};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{3};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{112};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{21};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.evaporator";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUISolidFuelEvaporator.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "evaporator";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(99-5,34-10, 17, 13), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return EvaporatorTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/ExtruderRecipeHandler.java b/src/main/java/ihl/nei_integration/ExtruderRecipeHandler.java new file mode 100644 index 0000000..64dd072 --- /dev/null +++ b/src/main/java/ihl/nei_integration/ExtruderRecipeHandler.java @@ -0,0 +1,63 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.metallurgy.ExtruderGui;
+import ihl.processing.metallurgy.ExtruderTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+public class ExtruderRecipeHandler extends MachineRecipeHandler {
+ @Override
+ public Class<? extends GuiContainer> getGuiClass() {
+ return ExtruderGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX() {
+ return new int[] { 39 - 5, 57 - 5 };
+ }
+
+ @Override
+ protected int[] getInputPosY() {
+ return new int[] { 32 - 11 };
+ }
+
+ @Override
+ protected int[] getOutputPosX() {
+ return new int[] { 92 - 5 };
+ }
+
+ @Override
+ protected int[] getOutputPosY() {
+ return new int[] { 32 - 11 };
+ }
+
+ @Override
+ public String getRecipeId() {
+ return "ihl.extruder";
+ }
+
+ @Override
+ public String getGuiTexture() {
+ return "ihl:textures/gui/GUIExtruder.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier() {
+ return "extruder";
+ }
+
+ @Override
+ public void loadTransferRects() {
+ this.transferRects
+ .add(new RecipeTransferRect(new Rectangle(74 - 5, 31 - 10, 18, 18), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList() {
+ return ExtruderTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/FluidizedBedReactorRecipeHandler.java b/src/main/java/ihl/nei_integration/FluidizedBedReactorRecipeHandler.java new file mode 100644 index 0000000..2f9c581 --- /dev/null +++ b/src/main/java/ihl/nei_integration/FluidizedBedReactorRecipeHandler.java @@ -0,0 +1,106 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import codechicken.lib.gui.GuiDraw;
+import ihl.processing.chemistry.FluidizedBedReactorGui;
+import ihl.processing.chemistry.FluidizedBedReactorTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class FluidizedBedReactorRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return FluidizedBedReactorGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{41-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{23-11,41-11};
+ }
+
+ @Override
+ protected int[] getFluidInputPosX()
+ {
+ return new int[]{102-5,84-5};
+ }
+
+ @Override
+ protected int[] getFluidInputPosY()
+ {
+ return new int[]{15-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{76-5};
+ }
+
+ @Override
+ protected int[] getFluidOutputPosX()
+ {
+ return new int[]{102-5,84-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{33-11};
+ }
+
+ @Override
+ protected int[] getFluidOutputPosY()
+ {
+ return new int[]{51-11,51-11};
+ }
+ @Override
+ public void drawBackground(int i)
+ {
+ super.drawBackground(i);
+ GuiDraw.drawTexturedModalRect(83-5, 14-11, 101, 14, 18, 18);
+ GuiDraw.drawTexturedModalRect(83-5, 50-11, 101, 14, 18, 18);
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.fluidizedBedReactor";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIFluidizedBedReactor.png";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(58-5,34-10, 17, 13), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "fluidizedBedReactor";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return FluidizedBedReactorTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/FractionationColumnRecipeHandler.java b/src/main/java/ihl/nei_integration/FractionationColumnRecipeHandler.java new file mode 100644 index 0000000..693dce2 --- /dev/null +++ b/src/main/java/ihl/nei_integration/FractionationColumnRecipeHandler.java @@ -0,0 +1,66 @@ +package ihl.nei_integration;
+
+import java.util.Map;
+
+import ihl.processing.chemistry.FractionatorBottomTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class FractionationColumnRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return null;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{6-5,61-5,106-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{33-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{76-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{51-11,31-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.fractionator";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIFractionationColumn.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "fractionator";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return FractionatorBottomTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/GasWeldingStationGasRecipeHandler.java b/src/main/java/ihl/nei_integration/GasWeldingStationGasRecipeHandler.java new file mode 100644 index 0000000..eef6b75 --- /dev/null +++ b/src/main/java/ihl/nei_integration/GasWeldingStationGasRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.metallurgy.GasWeldingStationGui;
+import ihl.processing.metallurgy.GasWeldingStationTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class GasWeldingStationGasRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return GasWeldingStationGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{44-5,62-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{15-11,51-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{62-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{15-11,33-11};
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(80-5, 15-11, 50, 50), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.gasWeldingStationGas";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIGasWeldingStation.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "gasWeldingStationGas";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return GasWeldingStationTileEntity.getGasRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/IHLBlockHighlightHandler.java b/src/main/java/ihl/nei_integration/IHLBlockHighlightHandler.java new file mode 100644 index 0000000..1fc3666 --- /dev/null +++ b/src/main/java/ihl/nei_integration/IHLBlockHighlightHandler.java @@ -0,0 +1,46 @@ +package ihl.nei_integration; + +import java.util.List; + +import codechicken.nei.api.IHighlightHandler; +import codechicken.nei.api.ItemInfo; +import ihl.flexible_cable.RectifierTransformerUnitTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MovingObjectPosition; +import net.minecraft.world.World; + +public class IHLBlockHighlightHandler implements IHighlightHandler +{ + @Override + public List<String> handleTextData(ItemStack stack, World world, EntityPlayer player, MovingObjectPosition movingObjectPosition, List<String> currenttip, ItemInfo.Layout layout) + { + TileEntity tile = world.getTileEntity(movingObjectPosition.blockX, movingObjectPosition.blockY, movingObjectPosition.blockZ); + if(tile instanceof RectifierTransformerUnitTileEntity) + { + RectifierTransformerUnitTileEntity rtu = (RectifierTransformerUnitTileEntity)tile; + currenttip.add("Current mode: "+EnumChatFormatting.RED+getMode(rtu.mode)+"x V"); + currenttip.add("R.Click: "+EnumChatFormatting.RED+getMode(Math.min(rtu.mode*RectifierTransformerUnitTileEntity.modeMultiplier,RectifierTransformerUnitTileEntity.modeMax))+"x V"); + currenttip.add("IC2 Mode+R.Click: "+EnumChatFormatting.RED+getMode(Math.max(rtu.mode/RectifierTransformerUnitTileEntity.modeMultiplier,RectifierTransformerUnitTileEntity.modeMin))+"x V"); + } + return currenttip; + } + + private String getMode(float value) + { + if(value>=1f) + { + return Integer.toString(Math.round(value)); + } + else + { + return "1/"+Integer.toString(Math.round(1f/value)); + } + } + @Override + public ItemStack identifyHighlight(World world, EntityPlayer player, MovingObjectPosition mop) { + return null; + } +} diff --git a/src/main/java/ihl/nei_integration/IHLPositionedStack.java b/src/main/java/ihl/nei_integration/IHLPositionedStack.java new file mode 100644 index 0000000..d00083d --- /dev/null +++ b/src/main/java/ihl/nei_integration/IHLPositionedStack.java @@ -0,0 +1,45 @@ +package ihl.nei_integration;
+
+import java.util.Arrays;
+import java.util.List;
+
+import codechicken.nei.PositionedStack;
+import ic2.core.Ic2Items;
+import ic2.core.item.ItemFluidCell;
+import ihl.recipes.RecipeOutputItemStack;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+public class IHLPositionedStack extends PositionedStack {
+
+ public final float sQuantity;
+ public IHLPositionedStack(RecipeOutputItemStack object, int x, int y)
+ {
+ super(object.itemStack.copy(), x, y);
+ sQuantity=object.quantity;
+ }
+
+ public IHLPositionedStack(FluidStack fluidStack, int x, int y)
+ {
+ super(Ic2Items.FluidCell.copy(), x, y);
+ ItemStack fluidCellStack = this.items[0];
+ ((ItemFluidCell)fluidCellStack.getItem()).fill(fluidCellStack, fluidStack, true);
+ sQuantity=fluidStack.amount/1000f;
+ this.item=this.items[0]=fluidCellStack;
+ }
+
+
+ public IHLPositionedStack(List<FluidStack> list, int x, int y) {
+ super(Ic2Items.FluidCell.copy(),x,y);
+ sQuantity = list.get(0).amount/1000f;
+ this.items = new ItemStack[list.size()];
+ for(int i=0;i<list.size();i++){
+ ItemStack fluidCellStack = Ic2Items.FluidCell.copy();
+ ((ItemFluidCell)fluidCellStack.getItem()).fill(fluidCellStack, list.get(i), true);
+ this.items[i] = fluidCellStack;
+ }
+ this.item=this.items[0];
+ }
+
+
+}
diff --git a/src/main/java/ihl/nei_integration/IHLRecipeHandler.java b/src/main/java/ihl/nei_integration/IHLRecipeHandler.java new file mode 100644 index 0000000..a263ae8 --- /dev/null +++ b/src/main/java/ihl/nei_integration/IHLRecipeHandler.java @@ -0,0 +1,242 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.lwjgl.opengl.GL11;
+
+import codechicken.lib.gui.GuiDraw;
+import codechicken.nei.NEIServerUtils;
+import codechicken.nei.PositionedStack;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeOutput;
+import ic2.core.util.StackUtil;
+import net.minecraft.item.ItemStack;
+
+public abstract class IHLRecipeHandler extends TemplateRecipeHandler
+{
+ protected int ticks;
+
+ @Override
+ public abstract String getRecipeName();
+
+ public abstract String getRecipeId();
+
+ @Override
+ public abstract String getGuiTexture();
+
+ @Override
+ public abstract String getOverlayIdentifier();
+
+ public abstract Map<IRecipeInput, RecipeOutput> getRecipeList();
+
+ @Override
+ public void drawBackground(int i)
+ {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiDraw.changeTexture(this.getGuiTexture());
+ GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 140, 65);
+ }
+
+ @Override
+ public void drawExtras(int i)
+ {
+ float f = this.ticks >= 20 ? (this.ticks - 20) % 20 / 20.0F : 0.0F;
+ this.drawProgressBar(74, 23, 176, 14, 25, 16, f, 0);
+ f = this.ticks <= 20 ? this.ticks / 20.0F : 1.0F;
+ this.drawProgressBar(51, 25, 176, 0, 14, 14, f, 3);
+ }
+
+ @Override
+ public void onUpdate()
+ {
+ super.onUpdate();
+ ++this.ticks;
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(74, 23, 25, 16), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public void loadCraftingRecipes(String outputId, Object ... results)
+ {
+ if (outputId.equals(this.getRecipeId()))
+ {
+ Iterator<Entry<IRecipeInput, RecipeOutput>> i$ = this.getRecipeList().entrySet().iterator();
+
+ while (i$.hasNext())
+ {
+ Entry<IRecipeInput, RecipeOutput> entry = i$.next();
+ this.arecipes.add(new IHLRecipeHandler.CachedIORecipe((IRecipeInput)entry.getKey(), (RecipeOutput)entry.getValue()));
+ }
+ }
+ else
+ {
+ super.loadCraftingRecipes(outputId, results);
+ }
+ }
+
+ @Override
+ public void loadCraftingRecipes(ItemStack result)
+ {
+ Iterator<Entry<IRecipeInput, RecipeOutput>> i$ = this.getRecipeList().entrySet().iterator();
+
+ while (i$.hasNext())
+ {
+ Entry<IRecipeInput, RecipeOutput> entry = i$.next();
+ Iterator<ItemStack> i$1 = ((RecipeOutput)entry.getValue()).items.iterator();
+
+ while (i$1.hasNext())
+ {
+ ItemStack output = i$1.next();
+
+ if (NEIServerUtils.areStacksSameTypeCrafting(output, result))
+ {
+ this.arecipes.add(new IHLRecipeHandler.CachedIORecipe((IRecipeInput)entry.getKey(), (RecipeOutput)entry.getValue()));
+ break;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void loadUsageRecipes(ItemStack ingredient)
+ {
+ Iterator<Entry<IRecipeInput, RecipeOutput>> i$ = this.getRecipeList().entrySet().iterator();
+
+ while (i$.hasNext())
+ {
+ Entry<IRecipeInput, RecipeOutput> entry = i$.next();
+
+ if (((IRecipeInput)entry.getKey()).matches(ingredient))
+ {
+ this.arecipes.add(new IHLRecipeHandler.CachedIORecipe((IRecipeInput)entry.getKey(), (RecipeOutput)entry.getValue()));
+ }
+ }
+ }
+
+ protected int getInputPosX()
+ {
+ return 51;
+ }
+
+ protected int getInputPosY()
+ {
+ return 6;
+ }
+
+ protected int getOutputPosX()
+ {
+ return 111;
+ }
+
+ protected int getOutputPosY()
+ {
+ return 24;
+ }
+
+ protected boolean isOutputsVertical()
+ {
+ return true;
+ }
+
+ public class CachedIORecipe extends CachedRecipe
+ {
+ private final List<PositionedStack> ingredients = new ArrayList<PositionedStack>();
+ private final PositionedStack output;
+ private final List<PositionedStack> otherStacks = new ArrayList<PositionedStack>();
+
+ @Override
+ public List<PositionedStack> getIngredients()
+ {
+ return this.getCycledIngredients(IHLRecipeHandler.this.cycleticks / 20, this.ingredients);
+ }
+
+ @Override
+ public PositionedStack getResult()
+ {
+ return this.output;
+ }
+
+ @Override
+ public List<PositionedStack> getOtherStacks()
+ {
+ return this.otherStacks;
+ }
+
+ public CachedIORecipe(ItemStack input, ItemStack output1)
+ {
+ super();
+
+ if (input == null)
+ {
+ throw new NullPointerException("Input must not be null (recipe " + input + " -> " + output1 + ").");
+ }
+ else if (output1 == null)
+ {
+ throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ").");
+ }
+ else
+ {
+ this.ingredients.add(new PositionedStack(input, IHLRecipeHandler.this.getInputPosX(), IHLRecipeHandler.this.getInputPosY()));
+ this.output = new PositionedStack(output1, IHLRecipeHandler.this.getOutputPosX(), IHLRecipeHandler.this.getOutputPosY());
+ }
+ }
+
+ public CachedIORecipe(IRecipeInput input, RecipeOutput output1)
+ {
+ super();
+
+ if (input == null)
+ {
+ throw new NullPointerException("Input must not be null (recipe " + input + " -> " + output1 + ").");
+ }
+ else if (output1 == null)
+ {
+ throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ").");
+ }
+ else if (output1.items.isEmpty())
+ {
+ throw new IllegalArgumentException("Output must not be empty (recipe " + input + " -> " + output1 + ").");
+ }
+ else if (output1.items.contains((Object)null))
+ {
+ throw new IllegalArgumentException("Output must not contain null (recipe " + input + " -> " + output1 + ").");
+ }
+ else
+ {
+ ArrayList<ItemStack> items = new ArrayList<ItemStack>();
+ Iterator<ItemStack> i = input.getInputs().iterator();
+
+ while (i.hasNext())
+ {
+ ItemStack item = i.next();
+ items.add(StackUtil.copyWithSize(item, input.getAmount()));
+ }
+
+ this.ingredients.add(new PositionedStack(items, IHLRecipeHandler.this.getInputPosX(), IHLRecipeHandler.this.getInputPosY()));
+ this.output = new PositionedStack(output1.items.get(0), IHLRecipeHandler.this.getOutputPosX(), IHLRecipeHandler.this.getOutputPosY());
+
+ for (int var7 = 1; var7 < output1.items.size(); ++var7)
+ {
+ if (IHLRecipeHandler.this.isOutputsVertical())
+ {
+ this.otherStacks.add(new PositionedStack(output1.items.get(var7), IHLRecipeHandler.this.getOutputPosX(), IHLRecipeHandler.this.getOutputPosY() + var7 * 18));
+ }
+ else
+ {
+ this.otherStacks.add(new PositionedStack(output1.items.get(var7), IHLRecipeHandler.this.getOutputPosX() + var7 * 18, IHLRecipeHandler.this.getOutputPosY()));
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/ImpregnatingMachineRecipeHandler.java b/src/main/java/ihl/nei_integration/ImpregnatingMachineRecipeHandler.java new file mode 100644 index 0000000..9abad4b --- /dev/null +++ b/src/main/java/ihl/nei_integration/ImpregnatingMachineRecipeHandler.java @@ -0,0 +1,106 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import codechicken.lib.gui.GuiDraw;
+import ihl.processing.metallurgy.ImpregnatingMachineGui;
+import ihl.processing.metallurgy.ImpregnatingMachineTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class ImpregnatingMachineRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return ImpregnatingMachineGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{116-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{16-11};
+ }
+
+ @Override
+ protected int[] getFluidInputPosX()
+ {
+ return new int[]{24-5,6-5};
+ }
+
+ @Override
+ protected int[] getFluidInputPosY()
+ {
+ return new int[]{16-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{116-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{41-11,59-11};
+ }
+
+ @Override
+ protected int[] getFluidOutputPosX()
+ {
+ return new int[]{24-5};
+ }
+
+ @Override
+ protected int[] getFluidOutputPosY()
+ {
+ return new int[]{52-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.impregnatingMachine";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUITubBronze.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "impregnatingMachine";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(134-5, 0, 35, 65), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public void drawBackground(int i)
+ {
+ super.drawBackground(i);
+ GuiDraw.drawTexturedModalRect(5-5, 15-11, 23, 15, 18, 18);
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return ImpregnatingMachineTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/InjectionMoldRecipeHandler.java b/src/main/java/ihl/nei_integration/InjectionMoldRecipeHandler.java new file mode 100644 index 0000000..e125b54 --- /dev/null +++ b/src/main/java/ihl/nei_integration/InjectionMoldRecipeHandler.java @@ -0,0 +1,64 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.metallurgy.InjectionMoldTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+public class InjectionMoldRecipeHandler extends MachineRecipeHandler {
+ @Override
+ public Class<? extends GuiContainer> getGuiClass() {
+ return null;
+ }
+
+ @Override
+ protected int[] getInputPosX() {
+ return new int[] { 65 - 5 };
+ }
+
+ @Override
+ protected int[] getInputPosY() {
+ return new int[] { 15 - 11, 51 - 11 };
+ }
+
+ @Override
+ protected int[] getOutputPosX() {
+ return new int[] { 101 - 5 };
+ }
+
+ @Override
+ protected int[] getOutputPosY() {
+ return new int[] { 51 - 11 };
+ }
+
+ @Override
+ public String getRecipeId() {
+ return "ihl.casting";
+ }
+
+ @Override
+ public String getGuiTexture() {
+ return "ihl:textures/gui/GUICastingNEI.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier() {
+ return "casting";
+ }
+
+ @Override
+ public void loadTransferRects() {
+ this.transferRects
+ .add(new RecipeTransferRect(new Rectangle(64 - 5, 32 - 10, 18, 18), this.getRecipeId(), new Object[0]));
+ this.transferRects
+ .add(new RecipeTransferRect(new Rectangle(82 - 5, 50 - 10, 18, 18), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList() {
+ return InjectionMoldTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/IronWorkbenchRecipeHandler.java b/src/main/java/ihl/nei_integration/IronWorkbenchRecipeHandler.java new file mode 100644 index 0000000..c060bb7 --- /dev/null +++ b/src/main/java/ihl/nei_integration/IronWorkbenchRecipeHandler.java @@ -0,0 +1,283 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.lwjgl.opengl.GL11;
+
+import codechicken.lib.gui.GuiDraw;
+import codechicken.nei.NEIServerUtils;
+import codechicken.nei.PositionedStack;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import ic2.api.recipe.IRecipeInput;
+import ihl.flexible_cable.IronWorkbenchGui;
+import ihl.flexible_cable.IronWorkbenchTileEntity;
+import ihl.interfaces.IWire;
+import ihl.recipes.IronWorkbenchRecipe;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+
+public class IronWorkbenchRecipeHandler extends TemplateRecipeHandler
+{
+ private static final int workspaceItemsPosX=8-7;
+ private static final int workspaceItemsPosY=8-7;
+ private static final int toolsPosX=26-7;
+ private static final int toolsPosY=8-7;
+ private static final int materialsPosX=65-7;
+ private static final int materialsPosY=8-7;
+ private static final int outputPosX=116-7;
+ private static final int outputPosY=8-7;
+
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return IronWorkbenchGui.class;
+ }
+
+ @Override
+ public String getRecipeName()
+ {
+ return StatCollector.translateToLocal(getRecipeId());
+ }
+
+ @Override
+ public int recipiesPerPage()
+ {
+ return 1;
+ }
+
+ public String getRecipeId()
+ {
+ return "ihl.ironWorkbench";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIIronWorkbench.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "ironWorkbench";
+ }
+
+ public List<IronWorkbenchRecipe> getRecipeList()
+ {
+ return IronWorkbenchTileEntity.recipes;
+ }
+
+
+ @Override
+ public void drawBackground(int recipeNumber)
+ {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiDraw.changeTexture(this.getGuiTexture());
+ GuiDraw.drawTexturedModalRect(0, 0, 7, 7, 162, 108);
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(104-10, 9-10, 15, 108), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public void loadCraftingRecipes(String outputId, Object ... results)
+ {
+ if (outputId.equals(this.getRecipeId()))
+ {
+ Iterator<IronWorkbenchRecipe> i$ = this.getRecipeList().iterator();
+
+ while (i$.hasNext())
+ {
+ IronWorkbenchRecipe entry = i$.next();
+ this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry));
+ }
+ }
+ else
+ {
+ super.loadCraftingRecipes(outputId, results);
+ }
+ }
+
+ @Override
+ public void loadCraftingRecipes(ItemStack result)
+ {
+ Iterator<IronWorkbenchRecipe> i$ = this.getRecipeList().iterator();
+
+ while (i$.hasNext())
+ {
+ IronWorkbenchRecipe entry = i$.next();
+ Iterator<ItemStack> i$1 = entry.outputs.iterator();
+ while (i$1.hasNext())
+ {
+ ItemStack output = i$1.next();
+ if (NEIServerUtils.areStacksSameTypeCrafting(output, result))
+ {
+ this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry));
+ break;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void loadUsageRecipes(ItemStack ingredient)
+ {
+ Iterator<IronWorkbenchRecipe> i$ = this.getRecipeList().iterator();
+ while (i$.hasNext())
+ {
+ IronWorkbenchRecipe entry = i$.next();
+ if(entry.workspaceElements!=null && !entry.workspaceElements.isEmpty())
+ {
+ Iterator<ItemStack> i$1 = entry.workspaceElements.iterator();
+ while (i$1.hasNext())
+ {
+ ItemStack output = (ItemStack)i$1.next();
+ if (NEIServerUtils.areStacksSameTypeCrafting(output, ingredient) || IHLUtils.isItemsHaveSameOreDictionaryEntry(output, ingredient) || output.getItem()==ingredient.getItem())
+ {
+ this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry));
+ break;
+ }
+ }
+ }
+
+ if(entry.tools!=null && !entry.tools.isEmpty())
+ {
+ Iterator<IRecipeInput> i$1 = entry.tools.iterator();
+ while (i$1.hasNext())
+ {
+ IRecipeInput output = i$1.next();
+ if (output.matches(ingredient))
+ {
+ this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry));
+ break;
+ }
+ }
+ }
+ if(entry.materials!=null && !entry.materials.isEmpty())
+ {
+ Iterator<IRecipeInput> i$2 = entry.materials.iterator();
+ while (i$2.hasNext())
+ {
+ IRecipeInput output = i$2.next();
+ if (output.matches(ingredient))
+ {
+ this.arecipes.add(new IronWorkbenchRecipeHandler.CachedIORecipe(entry));
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public class CachedIORecipe extends CachedRecipe
+ {
+ private final List<PositionedStack> ingredients = new ArrayList<PositionedStack>();
+ private final PositionedStack output;
+ private final List<PositionedStack> otherStacks = new ArrayList<PositionedStack>();
+
+ @Override
+ public List<PositionedStack> getIngredients()
+ {
+ return this.getCycledIngredients(IronWorkbenchRecipeHandler.this.cycleticks / 20, this.ingredients);
+ }
+
+ @Override
+ public PositionedStack getResult()
+ {
+ return this.output;
+ }
+
+ @Override
+ public List<PositionedStack> getOtherStacks()
+ {
+ return this.otherStacks;
+ }
+
+ public CachedIORecipe(IronWorkbenchRecipe recipe)
+ {
+ super();
+ if (recipe == null)
+ {
+ throw new NullPointerException("Recipe must not be null.");
+ }
+ else
+ {
+ this.ingredients.add(new PositionedStack(IHLUtils.getThisModItemStack("ironWorkbench"), workspaceItemsPosX, workspaceItemsPosY));
+ if(recipe.workspaceElements!=null && !recipe.workspaceElements.isEmpty())
+ {
+ Iterator<ItemStack> i = recipe.workspaceElements.iterator();
+ int index = 1;
+ while (i.hasNext())
+ {
+ int x = workspaceItemsPosX;
+ int y = workspaceItemsPosY + index * 18;
+ ItemStack stack = i.next();
+ this.ingredients.add(new PositionedStack(stack, x, y));
+ index++;
+ }
+ }
+ if(recipe.tools!=null && !recipe.tools.isEmpty())
+ {
+ Iterator<IRecipeInput> i = recipe.tools.iterator();
+ int index = 0;
+ while (i.hasNext())
+ {
+ int x = toolsPosX + (index % 2) * 18;
+ int y = toolsPosY + index / 2 * 18;
+ IRecipeInput rInput = i.next();
+ this.ingredients.add(new PositionedStack(rInput.getInputs(), x, y));
+ index++;
+ }
+ }
+
+ if(recipe.materials!=null && !recipe.materials.isEmpty())
+ {
+ Iterator<IRecipeInput> i = recipe.materials.iterator();
+ int index = 0;
+ while (i.hasNext())
+ {
+ int x = materialsPosX + (index % 2) * 18;
+ int y = materialsPosY + index / 2 * 18;
+ IRecipeInput rInput = (IRecipeInput)i.next();
+ Iterator<ItemStack> rInputsi = rInput.getInputs().iterator();
+ List<ItemStack> itemInputs = new ArrayList<ItemStack>();
+ while(rInputsi.hasNext())
+ {
+ ItemStack stack = rInputsi.next().copy();
+ if(!(stack.getItem() instanceof IWire))
+ {
+ stack.stackSize=rInput.getAmount();
+ }
+ itemInputs.add(stack);
+ }
+ this.ingredients.add(new PositionedStack(itemInputs, x, y));
+ index++;
+ }
+ }
+ this.output=new PositionedStack(recipe.outputs.get(0), outputPosX, outputPosY);
+ Iterator<ItemStack> i = recipe.outputs.iterator();
+ int index = 0;
+ while (i.hasNext())
+ {
+ int x = outputPosX + (index % 3) * 18;
+ int y = outputPosY + index / 3 * 18;
+ ItemStack stack = i.next();
+ if(index>0)
+ {
+ this.otherStacks.add(new PositionedStack(stack, x, y));
+ }
+ index++;
+ }
+ }
+ }
+
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/LabElectrolyzerRecipeHandler.java b/src/main/java/ihl/nei_integration/LabElectrolyzerRecipeHandler.java new file mode 100644 index 0000000..a9df742 --- /dev/null +++ b/src/main/java/ihl/nei_integration/LabElectrolyzerRecipeHandler.java @@ -0,0 +1,77 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import org.lwjgl.opengl.GL11;
+
+import codechicken.lib.gui.GuiDraw;
+import ihl.processing.chemistry.LabElectrolyzerGui;
+import ihl.processing.chemistry.LabElectrolyzerTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+public class LabElectrolyzerRecipeHandler extends MachineRecipeHandler {
+ @Override
+ public Class<? extends GuiContainer> getGuiClass() {
+ return LabElectrolyzerGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX() {
+ return new int[] { 63 - 5, 46 - 5, 29 - 5 };
+ }
+
+ @Override
+ protected int[] getInputPosY() {
+ return new int[] { 11 - 10 };
+ }
+
+ @Override
+ protected int[] getOutputPosX() {
+ return new int[] { 29 - 5, 63 - 5, 109 - 5 };
+ }
+
+ @Override
+ protected int[] getOutputPosY() {
+ return new int[] { 47 - 10 };
+ }
+
+ @Override
+ public String getRecipeId() {
+ return "ihl.labElectrolyzer";
+ }
+
+ @Override
+ public String getGuiTexture() {
+ return "ihl:textures/gui/GUILabElectrolyzer.png";
+ }
+
+ @Override
+ public void loadTransferRects() {
+ this.transferRects
+ .add(new RecipeTransferRect(new Rectangle(28 - 5, 28 - 10, 18, 18), this.getRecipeId(), new Object[0]));
+ this.transferRects
+ .add(new RecipeTransferRect(new Rectangle(108 - 5, 32 - 10, 18, 18), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public String getOverlayIdentifier() {
+ return "labElectrolyzer";
+ }
+
+ @Override
+ public void drawBackground(int recipeNumber)
+ {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiDraw.changeTexture(this.getGuiTexture());
+ GuiDraw.drawTexturedModalRect(0, 0, 5, 10, 140, 54);
+ GuiDraw.drawTexturedModalRect(46-5, 10-10, 62, 10, 18, 18);
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList() {
+ return LabElectrolyzerTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/LeadOvenRecipeHandler.java b/src/main/java/ihl/nei_integration/LeadOvenRecipeHandler.java new file mode 100644 index 0000000..8a7f686 --- /dev/null +++ b/src/main/java/ihl/nei_integration/LeadOvenRecipeHandler.java @@ -0,0 +1,83 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.chemistry.LeadOvenGui;
+import ihl.processing.chemistry.LeadOvenTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+public class LeadOvenRecipeHandler extends MachineRecipeHandler {
+ @Override
+ public Class<? extends GuiContainer> getGuiClass() {
+ return LeadOvenGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX() {
+ return new int[] { 47 - 5, 65 - 5 };
+ }
+
+ @Override
+ protected int[] getInputPosY() {
+ return new int[] { 17 - 11 };
+ }
+
+ @Override
+ protected int[] getOutputPosX() {
+ return new int[] { 112 - 5 };
+ }
+
+ @Override
+ protected int[] getOutputPosY() {
+ return new int[] { 35 - 11 };
+ }
+
+ @Override
+ protected int[] getFluidOutputPosX() {
+ return new int[] { 9 - 5 };
+ }
+
+ @Override
+ protected int[] getFluidOutputPosY() {
+ return new int[] { 53 - 11 };
+ }
+
+ @Override
+ protected int[] getFluidInputPosX() {
+ return new int[] { 9 - 5 };
+ }
+
+ @Override
+ protected int[] getFluidInputPosY() {
+ return new int[] { 17 - 11 };
+ }
+
+ @Override
+ public String getRecipeId() {
+ return "ihl.leadOven";
+ }
+
+ @Override
+ public String getGuiTexture() {
+ return "ihl:textures/gui/GUILeadOven.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier() {
+ return "leadOven";
+ }
+
+ @Override
+ public void loadTransferRects() {
+ this.transferRects.add(
+ new RecipeTransferRect(new Rectangle(80 - 10, 35 - 10, 22, 15), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList() {
+ return LeadOvenTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/LoomRecipeHandler.java b/src/main/java/ihl/nei_integration/LoomRecipeHandler.java new file mode 100644 index 0000000..d34f505 --- /dev/null +++ b/src/main/java/ihl/nei_integration/LoomRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.chemistry.LoomGui;
+import ihl.processing.chemistry.LoomTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class LoomRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return LoomGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{8-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{44-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{127-5};
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(35-10, 0, 90, 60), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{44-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.loom";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUILoom.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "loom";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return LoomTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/MachineRecipeHandler.java b/src/main/java/ihl/nei_integration/MachineRecipeHandler.java new file mode 100644 index 0000000..eba0855 --- /dev/null +++ b/src/main/java/ihl/nei_integration/MachineRecipeHandler.java @@ -0,0 +1,413 @@ +package ihl.nei_integration;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.lwjgl.opengl.GL11;
+
+import codechicken.lib.gui.GuiDraw;
+import codechicken.nei.NEIServerUtils;
+import codechicken.nei.PositionedStack;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import ic2.api.recipe.IRecipeInput;
+import ihl.interfaces.IWire;
+import ihl.recipes.IRecipeInputFluid;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.BlockFluidBase;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+
+public abstract class MachineRecipeHandler extends TemplateRecipeHandler {
+ protected int ticks;
+
+ @Override
+ public String getRecipeName() {
+ return StatCollector.translateToLocal(getRecipeId());
+ }
+
+ public abstract String getRecipeId();
+
+ @Override
+ public abstract String getGuiTexture();
+
+ @Override
+ public abstract String getOverlayIdentifier();
+
+ public abstract Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList();
+
+ @Override
+ public void drawBackground(int i) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiDraw.changeTexture(this.getGuiTexture());
+ GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 140, 65);
+ }
+
+ @Override
+ public void drawExtras(int recipeNumber) {
+ MachineRecipeHandler.CachedIORecipe recipe = (CachedIORecipe) this.arecipes.get(recipeNumber);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ for (PositionedStack stack : recipe.ingredients) {
+ if (stack.item.stackSize == 0) {
+ GuiDraw.fontRenderer.drawStringWithShadow("0.001", stack.relx + 3, stack.rely + 9, 16777215);
+ }
+ if (stack instanceof IHLPositionedStack)
+ drawFormattedString((IHLPositionedStack) stack);
+
+ }
+ for (PositionedStack stack : recipe.otherStacks) {
+ if (stack instanceof IHLPositionedStack)
+ drawFormattedString((IHLPositionedStack) stack);
+ }
+ if (recipe.output instanceof IHLPositionedStack) {
+ IHLPositionedStack rOutput = (IHLPositionedStack) recipe.output;
+ drawFormattedString(rOutput);
+ }
+ GuiDraw.changeTexture(this.getGuiTexture());
+ }
+
+ public void drawFormattedString(IHLPositionedStack rOutput) {
+ if (Math.abs(rOutput.sQuantity - Math.round(rOutput.sQuantity)) < 0.01f) {
+ if (Math.round(rOutput.sQuantity) != 1) {
+ GuiDraw.fontRenderer.drawStringWithShadow(String.format("%d", Math.round(rOutput.sQuantity)),
+ rOutput.relx + 11, rOutput.rely + 9, 16777215);
+ }
+ } else {
+ GuiDraw.fontRenderer.drawStringWithShadow(String.format("%.1f", rOutput.sQuantity), rOutput.relx + 3,
+ rOutput.rely + 9, 16777215);
+ }
+ }
+
+ @Override
+ public void onUpdate() {
+ super.onUpdate();
+ ++this.ticks;
+ }
+
+ @Override
+ public void loadTransferRects() {
+ // this.transferRects.add(new RecipeTransferRect(new Rectangle(74, 23,
+ // 25, 16), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public void loadCraftingRecipes(String outputId, Object... results) {
+ if (outputId.equals(this.getRecipeId())) {
+ Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.getRecipeList().entrySet()
+ .iterator();
+
+ while (i$.hasNext()) {
+ Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
+ this.arecipes.add(new MachineRecipeHandler.CachedIORecipe(entry.getKey(), entry.getValue(),
+ getAdditionalIngredients()));
+ }
+ } else {
+ super.loadCraftingRecipes(outputId, results);
+ }
+ }
+
+ @Override
+ public void loadCraftingRecipes(ItemStack result) {
+ Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.getRecipeList().entrySet().iterator();
+ FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(result);
+ if (fluidStack == null && result.getItem() instanceof IFluidContainerItem) {
+ IFluidContainerItem ifc = (IFluidContainerItem) result.getItem();
+ fluidStack = ifc.getFluid(result);
+ } else if (result.getItem() instanceof ItemBlock) {
+ Block blockfluid = ((ItemBlock) result.getItem()).field_150939_a;
+ if (blockfluid instanceof BlockFluidBase) {
+ Fluid fluid = ((BlockFluidBase) blockfluid).getFluid();
+ if (fluid != null) {
+ fluidStack = new FluidStack(fluid, 1000);
+ }
+ }
+ }
+ if (fluidStack != null) {
+ while (i$.hasNext()) {
+ Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
+ Iterator<FluidStack> i$1 = ((UniversalRecipeOutput) entry.getValue()).getFluidOutputs().iterator();
+ while (i$1.hasNext()) {
+ FluidStack output = i$1.next();
+ if (output != null && output.getFluid() == fluidStack.getFluid()) {
+ this.arecipes.add(new MachineRecipeHandler.CachedIORecipe((UniversalRecipeInput) entry.getKey(),
+ (UniversalRecipeOutput) entry.getValue(), getAdditionalIngredients()));
+ break;
+ }
+ }
+ }
+ } else {
+ while (i$.hasNext()) {
+ Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
+ Iterator<RecipeOutputItemStack> i$1 = (entry.getValue()).getItemOutputs().iterator();
+
+ while (i$1.hasNext()) {
+ RecipeOutputItemStack output = i$1.next();
+
+ if (NEIServerUtils.areStacksSameTypeCrafting(output.itemStack, result)
+ || IHLUtils.isItemsHaveSameOreDictionaryEntry(output.itemStack, result)) {
+ this.arecipes.add(new MachineRecipeHandler.CachedIORecipe(entry.getKey(), entry.getValue(),
+ getAdditionalIngredients()));
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ public List<PositionedStack> getAdditionalIngredients() {
+ return null;
+ }
+
+ @Override
+ public void loadUsageRecipes(ItemStack ingredient) {
+ Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.getRecipeList().entrySet().iterator();
+ FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(ingredient);
+ if (fluidStack == null && ingredient.getItem() instanceof IFluidContainerItem) {
+ IFluidContainerItem ifc = (IFluidContainerItem) ingredient.getItem();
+ fluidStack = ifc.getFluid(ingredient);
+ } else if (ingredient.getItem() instanceof ItemBlock) {
+ Block blockfluid = ((ItemBlock) ingredient.getItem()).field_150939_a;
+ if (blockfluid instanceof BlockFluidBase) {
+ Fluid fluid = ((BlockFluidBase) blockfluid).getFluid();
+ if (fluid != null) {
+ fluidStack = new FluidStack(fluid, 1000);
+ }
+ }
+ }
+
+ if (fluidStack != null && fluidStack.getFluid() != null) {
+ while (i$.hasNext()) {
+ Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
+ if (((UniversalRecipeInput) entry.getKey()).containFluidStack(fluidStack)) {
+ this.arecipes.add(new MachineRecipeHandler.CachedIORecipe(entry.getKey(), entry.getValue(),
+ getAdditionalIngredients()));
+ }
+ }
+ } else {
+ while (i$.hasNext()) {
+ Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
+ if (((UniversalRecipeInput) entry.getKey()).containItemStack(ingredient)) {
+ this.arecipes.add(new MachineRecipeHandler.CachedIORecipe(entry.getKey(), entry.getValue(),
+ getAdditionalIngredients()));
+ }
+ }
+ }
+ }
+
+ protected int[] getFluidInputPosX() {
+ return null;
+ }
+
+ protected int[] getFluidInputPosY() {
+ return null;
+ }
+
+ protected int[] getFluidOutputPosX() {
+ return null;
+ }
+
+ protected int[] getFluidOutputPosY() {
+ return null;
+ }
+
+ protected abstract int[] getInputPosX();
+
+ protected abstract int[] getInputPosY();
+
+ protected abstract int[] getOutputPosX();
+
+ protected abstract int[] getOutputPosY();
+
+ public class CachedIORecipe extends CachedRecipe {
+ private final List<PositionedStack> ingredients = new ArrayList<PositionedStack>();
+ public PositionedStack output;
+ public final List<PositionedStack> otherStacks = new ArrayList<PositionedStack>();
+ public boolean specialConditions = false;
+ public UniversalRecipeInput urInput;
+ public UniversalRecipeOutput urOutput;
+
+ @Override
+ public List<PositionedStack> getIngredients() {
+ return this.getCycledIngredients(MachineRecipeHandler.this.cycleticks / 20, this.ingredients);
+ }
+
+ @Override
+ public PositionedStack getResult() {
+ return this.output;
+ }
+
+ @Override
+ public List<PositionedStack> getOtherStacks() {
+ return this.otherStacks;
+ }
+
+ public CachedIORecipe(UniversalRecipeInput input, UniversalRecipeOutput output1,
+ List<PositionedStack> additionalIngredients) {
+ super();
+ if (input == null) {
+ throw new NullPointerException("Input must not be null (recipe " + input + " -> " + output1 + ").");
+ } else if (output1 == null) {
+ throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ").");
+ } else if ((output1.getFluidOutputs() == null || output1.getFluidOutputs().isEmpty())
+ && (output1.getItemOutputs() == null || output1.getItemOutputs().isEmpty())) {
+ throw new NullPointerException("Output must not be null (recipe " + input + " -> " + output1 + ").");
+ } else {
+ this.urInput = input;
+ this.urOutput = output1;
+ specialConditions = output1.specialConditions;
+ ArrayList<List<ItemStack>> items = new ArrayList<List<ItemStack>>();
+ ArrayList<List<FluidStack>> fluidItems = new ArrayList<List<FluidStack>>();
+ if (input.getFluidInputs() != null && !input.getFluidInputs().isEmpty()) {
+ Iterator<?> i = input.getFluidInputs().iterator();
+ while (i.hasNext()) {
+ IRecipeInputFluid fstackRI = (IRecipeInputFluid) i.next();
+ List<FluidStack> fstackList = fstackRI.getInputs();
+ fluidItems.add(fstackList);
+ }
+ }
+
+ if (input.getItemInputs() != null && !input.getItemInputs().isEmpty()) {
+ Iterator<?> i = input.getItemInputs().iterator();
+ while (i.hasNext()) {
+ IRecipeInput rInput = (IRecipeInput) i.next();
+ Iterator<ItemStack> rInputsi = rInput.getInputs().iterator();
+ List<ItemStack> itemInputs = new ArrayList<ItemStack>();
+ while (rInputsi.hasNext()) {
+ ItemStack stack = rInputsi.next().copy();
+ if (!(stack.getItem() instanceof IWire)) {
+ stack.stackSize = rInput.getAmount();
+ }
+ itemInputs.add(stack);
+ }
+ items.add(itemInputs);
+ }
+ }
+
+ int var7 = 0;
+ int var8 = 0;
+ boolean skipOneFluidOutput = false;
+ if (output1.getItemOutputs() != null && !output1.getItemOutputs().isEmpty()) {
+ int x = MachineRecipeHandler.this.getOutputPosX()[0],
+ y = MachineRecipeHandler.this.getOutputPosY()[0];
+ if (output1.getItemOutputs().get(0) != null)
+ this.output = new IHLPositionedStack(output1.getItemOutputs().get(0), x, y);
+ Iterator<RecipeOutputItemStack> i = output1.getItemOutputs().iterator();
+ i.next();
+ while (i.hasNext()) {
+ RecipeOutputItemStack rOut = i.next();
+ var7++;
+ if (var7 < MachineRecipeHandler.this.getOutputPosX().length) {
+ x = MachineRecipeHandler.this.getOutputPosX()[var7];
+ }
+ if (var7 < MachineRecipeHandler.this.getOutputPosY().length) {
+ y = MachineRecipeHandler.this.getOutputPosY()[var7];
+ }
+ if (rOut != null) {
+ this.otherStacks.add(new IHLPositionedStack(rOut, x, y));
+ }
+ }
+ } else {
+ if (MachineRecipeHandler.this.getFluidOutputPosX() != null) {
+ this.output = new IHLPositionedStack(output1.getFluidOutputs().get(0),
+ MachineRecipeHandler.this.getFluidOutputPosX()[0],
+ MachineRecipeHandler.this.getFluidOutputPosY()[0]);
+ } else {
+ this.output = new IHLPositionedStack(output1.getFluidOutputs().get(0), MachineRecipeHandler.this.getOutputPosX()[0],
+ MachineRecipeHandler.this.getOutputPosY()[0]);
+ }
+ skipOneFluidOutput = true;
+ var8++;
+ }
+
+ if (output1.getFluidOutputs() != null && !output1.getFluidOutputs().isEmpty()) {
+ int x = MachineRecipeHandler.this.getOutputPosX()[0],
+ y = MachineRecipeHandler.this.getOutputPosY()[0];
+ if (MachineRecipeHandler.this.getFluidOutputPosX() != null) {
+ x = MachineRecipeHandler.this.getFluidOutputPosX()[0];
+ y = MachineRecipeHandler.this.getFluidOutputPosY()[0];
+ }
+ Iterator<?> i = output1.getFluidOutputs().iterator();
+ if (skipOneFluidOutput) {
+ i.next();
+ }
+ while (i.hasNext()) {
+ FluidStack fstack = (FluidStack) i.next();
+ var7++;
+ if (MachineRecipeHandler.this.getFluidOutputPosX() != null) {
+ if (var8 < MachineRecipeHandler.this.getFluidOutputPosX().length) {
+ x = MachineRecipeHandler.this.getFluidOutputPosX()[var8];
+ }
+ if (var8 < MachineRecipeHandler.this.getFluidOutputPosY().length) {
+ y = MachineRecipeHandler.this.getFluidOutputPosY()[var8];
+ }
+ var8++;
+ } else {
+ if (var7 < MachineRecipeHandler.this.getOutputPosX().length) {
+ x = MachineRecipeHandler.this.getOutputPosX()[var7];
+ }
+ if (var7 < MachineRecipeHandler.this.getOutputPosY().length) {
+ y = MachineRecipeHandler.this.getOutputPosY()[var7];
+ }
+ }
+ this.otherStacks.add(new IHLPositionedStack(fstack, x, y));
+ }
+ }
+
+ if (MachineRecipeHandler.this.getFluidInputPosX() != null) {
+ int x = MachineRecipeHandler.this.getFluidInputPosX()[0],
+ y = MachineRecipeHandler.this.getFluidInputPosY()[0];
+ for (int i = 0; i < fluidItems.size(); i++) {
+ if (i < MachineRecipeHandler.this.getFluidInputPosX().length) {
+ x = MachineRecipeHandler.this.getFluidInputPosX()[i];
+ }
+ if (i < MachineRecipeHandler.this.getFluidInputPosY().length) {
+ y = MachineRecipeHandler.this.getFluidInputPosY()[i];
+ }
+ this.ingredients.add(new IHLPositionedStack(fluidItems.get(i), x, y));
+ }
+ x = MachineRecipeHandler.this.getInputPosX()[0];
+ y = MachineRecipeHandler.this.getInputPosY()[0];
+ for (int i = 0; i < items.size(); i++) {
+ if (i < MachineRecipeHandler.this.getInputPosX().length) {
+ x = MachineRecipeHandler.this.getInputPosX()[i];
+ }
+ if (i < MachineRecipeHandler.this.getInputPosY().length) {
+ y = MachineRecipeHandler.this.getInputPosY()[i];
+ }
+ this.ingredients.add(new PositionedStack(items.get(i), x, y));
+ }
+ } else {
+ int x = MachineRecipeHandler.this.getInputPosX()[0],
+ y = MachineRecipeHandler.this.getInputPosY()[0];
+ for (int i = 0; i < fluidItems.size() + items.size(); i++) {
+ if (i < MachineRecipeHandler.this.getInputPosX().length) {
+ x = MachineRecipeHandler.this.getInputPosX()[i];
+ }
+ if (i < MachineRecipeHandler.this.getInputPosY().length) {
+ y = MachineRecipeHandler.this.getInputPosY()[i];
+ }
+ if (i < fluidItems.size()) {
+ this.ingredients.add(new IHLPositionedStack(fluidItems.get(i), x, y));
+ } else {
+ this.ingredients.add(new PositionedStack(items.get(i - fluidItems.size()), x, y));
+ }
+ }
+ }
+ if (additionalIngredients != null) {
+ this.ingredients.addAll(additionalIngredients);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/MuffleFurnaceRecipeHandler.java b/src/main/java/ihl/nei_integration/MuffleFurnaceRecipeHandler.java new file mode 100644 index 0000000..c5ff0c9 --- /dev/null +++ b/src/main/java/ihl/nei_integration/MuffleFurnaceRecipeHandler.java @@ -0,0 +1,83 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import codechicken.lib.gui.GuiDraw;
+import ihl.processing.metallurgy.MuffleFurnaceGui;
+import ihl.processing.metallurgy.MuffleFurnanceTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class MuffleFurnaceRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return MuffleFurnaceGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{40-5,40-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{40-11,22-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{98-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{32-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.muffleFurnace";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIAchesonFurnace.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "muffleFurnace";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(57-5, 29-11, 40, 30), this.getRecipeId(), new Object[0]));
+ }
+
+
+ @Override
+ public void drawBackground(int i)
+ {
+ super.drawBackground(i);
+ GuiDraw.drawTexturedModalRect(86-5, 33-11, 176, 14, 54, 18);
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return MuffleFurnanceTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/NEIIHLConfig.java b/src/main/java/ihl/nei_integration/NEIIHLConfig.java new file mode 100644 index 0000000..c1867a7 --- /dev/null +++ b/src/main/java/ihl/nei_integration/NEIIHLConfig.java @@ -0,0 +1,116 @@ +package ihl.nei_integration;
+
+import codechicken.nei.api.API;
+import codechicken.nei.api.IConfigureNEI;
+import codechicken.nei.api.ItemInfo;
+import ihl.IHLModInfo;
+import ihl.processing.chemistry.ChemicalReactorGui;
+import ihl.processing.chemistry.CryogenicDistillerGui;
+import ihl.processing.chemistry.ElectricEvaporatorGui;
+import ihl.processing.chemistry.EvaporatorGui;
+import ihl.processing.chemistry.FluidizedBedReactorGui;
+import ihl.processing.chemistry.LabElectrolyzerGui;
+import ihl.processing.chemistry.LeadOvenGui;
+import ihl.processing.chemistry.LoomGui;
+import ihl.processing.chemistry.PaperMachineGui;
+import ihl.processing.metallurgy.AchesonFurnaceGui;
+import ihl.processing.metallurgy.DetonationSprayingMachineGui;
+import ihl.processing.metallurgy.ExtruderGui;
+import ihl.processing.metallurgy.GasWeldingStationGui;
+import ihl.processing.metallurgy.ImpregnatingMachineGui;
+import ihl.processing.metallurgy.MuffleFurnaceGui;
+import ihl.processing.metallurgy.RollingMachineGui;
+import ihl.processing.metallurgy.WireMillGui;
+import ihl.processing.metallurgy.WoodenRollingMachineGui;
+
+public class NEIIHLConfig implements IConfigureNEI
+{
+ @Override
+ public void loadConfig()
+ {
+ API.registerHighlightHandler(new IHLBlockHighlightHandler(), ItemInfo.Layout.HEADER);
+ API.registerRecipeHandler(new EvaporatorRecipeHandler());
+ API.registerUsageHandler(new EvaporatorRecipeHandler());
+ API.registerGuiOverlay(EvaporatorGui.class, "evaporator", 5, 11);
+ API.registerRecipeHandler(new ElectricEvaporatorRecipeHandler());
+ API.registerUsageHandler(new ElectricEvaporatorRecipeHandler());
+ API.registerGuiOverlay(ElectricEvaporatorGui.class, "electricevaporator", 5, 11);
+ API.registerRecipeHandler(new AchesonFurnaceRecipeHandler());
+ API.registerUsageHandler(new AchesonFurnaceRecipeHandler());
+ API.registerGuiOverlay(AchesonFurnaceGui.class, "achesonFurnace", 5, 11);
+ API.registerRecipeHandler(new MuffleFurnaceRecipeHandler());
+ API.registerUsageHandler(new MuffleFurnaceRecipeHandler());
+ API.registerGuiOverlay(MuffleFurnaceGui.class, "muffleFurnace", 5, 11);
+ API.registerRecipeHandler(new DetonationSprayingMachineRecipeHandler());
+ API.registerUsageHandler(new DetonationSprayingMachineRecipeHandler());
+ API.registerGuiOverlay(DetonationSprayingMachineGui.class, "detonationSprayingMachine", 5, 11);
+ API.registerRecipeHandler(new ExtruderRecipeHandler());
+ API.registerUsageHandler(new ExtruderRecipeHandler());
+ API.registerGuiOverlay(ExtruderGui.class, "extruder", 5, 11);
+ API.registerRecipeHandler(new ImpregnatingMachineRecipeHandler());
+ API.registerUsageHandler(new ImpregnatingMachineRecipeHandler());
+ API.registerGuiOverlay(ImpregnatingMachineGui.class, "impregnatingMachine", 5, 11);
+ API.registerRecipeHandler(new LeadOvenRecipeHandler());
+ API.registerUsageHandler(new LeadOvenRecipeHandler());
+ API.registerGuiOverlay(LeadOvenGui.class, "leadOven", 5, 11);
+ API.registerRecipeHandler(new LoomRecipeHandler());
+ API.registerUsageHandler(new LoomRecipeHandler());
+ API.registerGuiOverlay(LoomGui.class, "loom", 5, 11);
+ API.registerGuiOverlay(GasWeldingStationGui.class, "gasWeldingStation", 5, 11);
+ API.registerRecipeHandler(new GasWeldingStationGasRecipeHandler());
+ API.registerUsageHandler(new GasWeldingStationGasRecipeHandler());
+ API.registerGuiOverlay(GasWeldingStationGui.class, "gasWeldingStationGas", 5, 11);
+ API.registerRecipeHandler(new WoodenRollingMachineRecipeHandler());
+ API.registerUsageHandler(new WoodenRollingMachineRecipeHandler());
+ API.registerGuiOverlay(WoodenRollingMachineGui.class, "woodenRollingMachine", 5, 11);
+ API.registerRecipeHandler(new CryogenicDistillerRecipeHandler());
+ API.registerUsageHandler(new CryogenicDistillerRecipeHandler());
+ API.registerGuiOverlay(CryogenicDistillerGui.class, "cryogenicDistiller", 5, 11);
+ API.registerRecipeHandler(new ChemicalReactorRecipeHandler());
+ API.registerUsageHandler(new ChemicalReactorRecipeHandler());
+ API.registerGuiOverlay(ChemicalReactorGui.class, "chemicalReactor", 5, 11);
+ API.registerRecipeHandler(new FluidizedBedReactorRecipeHandler());
+ API.registerUsageHandler(new FluidizedBedReactorRecipeHandler());
+ API.registerGuiOverlay(FluidizedBedReactorGui.class, "fluidizedBedReactor", 5, 11);
+ API.registerRecipeHandler(new LabElectrolyzerRecipeHandler());
+ API.registerUsageHandler(new LabElectrolyzerRecipeHandler());
+ API.registerGuiOverlay(LabElectrolyzerGui.class, "labElectrolyzer", 5, 11);
+ API.registerRecipeHandler(new RollingMachineRecipeHandler());
+ API.registerUsageHandler(new RollingMachineRecipeHandler());
+ API.registerGuiOverlay(RollingMachineGui.class, "rollingMachine", 5, 11);
+ API.registerRecipeHandler(new PaperMachineRecipeHandler());
+ API.registerUsageHandler(new PaperMachineRecipeHandler());
+ API.registerGuiOverlay(PaperMachineGui.class, "paperMachine", 5, 11);
+ API.registerRecipeHandler(new ElectrolysisBathRecipeHandler());
+ API.registerUsageHandler(new ElectrolysisBathRecipeHandler());
+ API.registerGuiOverlay(PaperMachineGui.class, "paperMachine", 5, 11);
+ API.registerRecipeHandler(new WireMillRecipeHandler());
+ API.registerUsageHandler(new WireMillRecipeHandler());
+ API.registerGuiOverlay(WireMillGui.class, "wireMill", 5, 11);
+ API.registerRecipeHandler(new InjectionMoldRecipeHandler());
+ API.registerUsageHandler(new InjectionMoldRecipeHandler());
+ API.registerRecipeHandler(new VulcanizationExtrudingMoldRecipeHandler());
+ API.registerUsageHandler(new VulcanizationExtrudingMoldRecipeHandler());
+ API.registerRecipeHandler(new CrucibleRecipeHandler());
+ API.registerUsageHandler(new CrucibleRecipeHandler());
+ API.registerRecipeHandler(new FractionationColumnRecipeHandler());
+ API.registerUsageHandler(new FractionationColumnRecipeHandler());
+ API.registerRecipeHandler(new IronWorkbenchRecipeHandler());
+ API.registerUsageHandler(new IronWorkbenchRecipeHandler());
+ this.addSubsets();
+ }
+
+ public void addSubsets() {}
+
+ @Override
+ public String getName()
+ {
+ return "IHL";
+ }
+
+ @Override
+ public String getVersion()
+ {
+ return IHLModInfo.MODVERSION;
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/PaperMachineRecipeHandler.java b/src/main/java/ihl/nei_integration/PaperMachineRecipeHandler.java new file mode 100644 index 0000000..0a5fc90 --- /dev/null +++ b/src/main/java/ihl/nei_integration/PaperMachineRecipeHandler.java @@ -0,0 +1,75 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.chemistry.PaperMachineGui;
+import ihl.processing.chemistry.PaperMachineTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class PaperMachineRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return PaperMachineGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{78-5,78-5-18,122-5-18,122-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{15-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{122-5,122-5-18,78-5-18};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{51-11,51-11,51-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.paperMachine";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIPaperMachine.png";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(25-5, 11-11, 52, 74), this.getRecipeId(), new Object[0]));
+ }
+
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "paperMachine";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return PaperMachineTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/RollingMachineRecipeHandler.java b/src/main/java/ihl/nei_integration/RollingMachineRecipeHandler.java new file mode 100644 index 0000000..1a8e4ee --- /dev/null +++ b/src/main/java/ihl/nei_integration/RollingMachineRecipeHandler.java @@ -0,0 +1,67 @@ +package ihl.nei_integration;
+
+import java.util.Map;
+
+import ihl.processing.metallurgy.RollingMachineGui;
+import ihl.processing.metallurgy.RollingMachinePart1TileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class RollingMachineRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return RollingMachineGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{54-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{25-11,34-11,53-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{105-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{25-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.rollingMachine";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIRollingMachine.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "rollingMachine";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return RollingMachinePart1TileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/VulcanizationExtrudingMoldRecipeHandler.java b/src/main/java/ihl/nei_integration/VulcanizationExtrudingMoldRecipeHandler.java new file mode 100644 index 0000000..2ca3b46 --- /dev/null +++ b/src/main/java/ihl/nei_integration/VulcanizationExtrudingMoldRecipeHandler.java @@ -0,0 +1,66 @@ +package ihl.nei_integration;
+
+import java.util.Map;
+
+import ihl.processing.metallurgy.VulcanizationExtrudingMoldTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class VulcanizationExtrudingMoldRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return null;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{41-5,16-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{17-11,46-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{123-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{46-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.vulcanizationExtrudingMold";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIVulcanizationExtrudingMoldNEI.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "vulcanizationExtrudingMold";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return VulcanizationExtrudingMoldTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/WireMillRecipeHandler.java b/src/main/java/ihl/nei_integration/WireMillRecipeHandler.java new file mode 100644 index 0000000..aebf85e --- /dev/null +++ b/src/main/java/ihl/nei_integration/WireMillRecipeHandler.java @@ -0,0 +1,101 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import org.lwjgl.opengl.GL11;
+
+import codechicken.lib.gui.GuiDraw;
+import ihl.processing.metallurgy.WireMillGui;
+import ihl.processing.metallurgy.WireMillTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class WireMillRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return WireMillGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{117-5,44-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{31-11,14-11};
+ }
+
+ @Override
+ protected int[] getFluidInputPosX()
+ {
+ return new int[]{8-5,26-5,44-5};
+ }
+
+ @Override
+ protected int[] getFluidInputPosY()
+ {
+ return new int[]{14-11};
+ }
+
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{152-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{31-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.wireMill";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIWireMill.png";
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "wireMill";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(134-5, 33-11, 18, 13), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public void drawBackground(int i)
+ {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GuiDraw.changeTexture(this.getGuiTexture());
+ GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 151, 65);
+ GuiDraw.drawTexturedModalRect(133-5+18, 30-11, 98+18, 30, 18, 18);
+ GuiDraw.drawTexturedModalRect(7-5+18, 13-11, 25+18, 13, 18, 18);
+ GuiDraw.drawTexturedModalRect(7-5, 13-11, 25+18, 13, 18, 18);
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return WireMillTileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/nei_integration/WoodenRollingMachineRecipeHandler.java b/src/main/java/ihl/nei_integration/WoodenRollingMachineRecipeHandler.java new file mode 100644 index 0000000..f8adb4f --- /dev/null +++ b/src/main/java/ihl/nei_integration/WoodenRollingMachineRecipeHandler.java @@ -0,0 +1,74 @@ +package ihl.nei_integration;
+
+import java.awt.Rectangle;
+import java.util.Map;
+
+import ihl.processing.metallurgy.WoodenRollingMachineGui;
+import ihl.processing.metallurgy.WoodenRollingMachinePart1TileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.inventory.GuiContainer;
+
+
+public class WoodenRollingMachineRecipeHandler extends MachineRecipeHandler
+{
+ @Override
+ public Class <? extends GuiContainer > getGuiClass()
+ {
+ return WoodenRollingMachineGui.class;
+ }
+
+ @Override
+ protected int[] getInputPosX()
+ {
+ return new int[]{123-5};
+ }
+
+ @Override
+ protected int[] getInputPosY()
+ {
+ return new int[]{15-11,34-11,53-11};
+ }
+
+ @Override
+ protected int[] getOutputPosX()
+ {
+ return new int[]{54-5};
+ }
+
+ @Override
+ protected int[] getOutputPosY()
+ {
+ return new int[]{25-11};
+ }
+
+ @Override
+ public String getRecipeId()
+ {
+ return "ihl.woodenRollingMachine";
+ }
+
+ @Override
+ public String getGuiTexture()
+ {
+ return "ihl:textures/gui/GUIWoodenRollingMachine.png";
+ }
+
+ @Override
+ public void loadTransferRects()
+ {
+ this.transferRects.add(new RecipeTransferRect(new Rectangle(74-5,16-11, 46, 48), this.getRecipeId(), new Object[0]));
+ }
+
+ @Override
+ public String getOverlayIdentifier()
+ {
+ return "woodenRollingMachine";
+ }
+
+ @Override
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipeList()
+ {
+ return WoodenRollingMachinePart1TileEntity.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/ApparatusProcessableInvSlot.java b/src/main/java/ihl/processing/chemistry/ApparatusProcessableInvSlot.java new file mode 100644 index 0000000..bfed5c9 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ApparatusProcessableInvSlot.java @@ -0,0 +1,59 @@ +package ihl.processing.chemistry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+
+public class ApparatusProcessableInvSlot extends InvSlot {
+
+ public ApparatusProcessableInvSlot(TileEntityInventory base1, String name1, int oldStartIndex1, Access access1,
+ int count, int stackSizeLimit1) {
+ super(base1, name1, oldStartIndex1, Access.I, count);
+ this.setStackSizeLimit(stackSizeLimit1);
+ }
+
+ public List<ItemStack> getItemStackList() {
+ List<ItemStack> list = new ArrayList<ItemStack>();
+ for (int i = 0; i < this.size(); i++) {
+ if (get(i) != null) {
+ list.add(get(i));
+ }
+ }
+ return list;
+ }
+
+ public ItemStack getItemStack(Item item) {
+ for (int i = 0; i < this.size(); i++) {
+ if (get(i) != null && get(i).getItem() == item) {
+ return get(i);
+ }
+ }
+ return null;
+ }
+
+ public void replaceItemStack(ItemStack stack1) {
+ for (int i = 0; i < this.size(); i++) {
+ if (this.get(i) != null && this.get(i).getItem() == stack1.getItem()) {
+ this.put(i, stack1);
+ }
+ }
+ }
+
+ public void consume(IRecipeInput iRecipeInput) {
+ for (int i = 0; i < this.size(); i++) {
+ if (this.get(i) != null && iRecipeInput.matches(this.get(i))) {
+ this.get(i).stackSize -= iRecipeInput.getAmount();
+ if (this.get(i).stackSize <= 0) {
+ this.put(i, null);
+ return;
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/BasicElectricMotorContainer.java b/src/main/java/ihl/processing/chemistry/BasicElectricMotorContainer.java new file mode 100644 index 0000000..a32e006 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/BasicElectricMotorContainer.java @@ -0,0 +1,74 @@ +package ihl.processing.chemistry;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import ihl.processing.metallurgy.BasicElectricMotorTileEntity;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class BasicElectricMotorContainer<T extends BasicElectricMotorTileEntity> extends ContainerBase<T> {
+
+ protected BasicElectricMotorTileEntity tileEntity;
+ public short lastProgress = -1;
+ public short lastEnergy = -1;
+ private final static int height = 166;
+
+ public BasicElectricMotorContainer(EntityPlayer entityPlayer, T tileEntity1) {
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ 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.dischargeSlot, 0, 8, 33));
+ for (col = 0; col < 4; ++col) {
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.upgradeSlot, col, 152, 8 + col * 18));
+ }
+ }
+
+ @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.progress != this.lastProgress) {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+
+ if ((short) this.tileEntity.energy != this.lastEnergy) {
+ icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy);
+ }
+ }
+
+ this.lastProgress = this.tileEntity.progress;
+ 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:
+ break;
+ case 2:
+ this.tileEntity.energy = value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/BatteryItem.java b/src/main/java/ihl/processing/chemistry/BatteryItem.java new file mode 100644 index 0000000..b9c5435 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/BatteryItem.java @@ -0,0 +1,194 @@ +package ihl.processing.chemistry;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.ElectricItem;
+import ic2.api.item.IElectricItem;
+import ic2.api.item.IItemHudInfo;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+
+public class BatteryItem extends Item implements IElectricItem, IItemHudInfo
+{
+ public int maxCharge=65536;
+ public int transferLimit = 4096;
+ public int tier = 4;
+ private static Map<Integer, IIcon> iconMap = new HashMap<Integer, IIcon>();
+ private static Map<Integer, String> nameMap = new HashMap<Integer, String>();
+ private static Map<Integer, String> descriptionMap = new HashMap<Integer, String>();
+
+ public BatteryItem()
+ {
+ super();
+ this.setMaxDamage(27);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.maxStackSize=1;
+ this.canRepair=false;
+ this.setUnlocalizedName("battery");
+ }
+
+ public static void init()
+ {
+ BatteryItem item = new BatteryItem();
+ GameRegistry.registerItem(item,item.getUnlocalizedName());
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ nameMap.put(var1[i].damage,var1[i].unLocalizedName);
+ IHLUtils.registerLocally(var1[i].unLocalizedName, new ItemStack(item,1,var1[i].damage));
+ if(var1[i].description!=null)
+ {
+ descriptionMap.put(var1[i].damage,var1[i].description);
+ }
+ }
+ }
+
+ @Override
+ public boolean canProvideEnergy(ItemStack itemStack)
+ {
+ return true;
+ }
+
+ @Override
+ public Item getChargedItem(ItemStack itemStack)
+ {
+ return this;
+ }
+
+ @Override
+ public Item getEmptyItem(ItemStack itemStack)
+ {
+ return this;
+ }
+
+ @Override
+ public double getMaxCharge(ItemStack itemStack)
+ {
+ return this.maxCharge;
+ }
+
+ @Override
+ public int getTier(ItemStack itemStack)
+ {
+ return this.tier;
+ }
+
+ @Override
+ public double getTransferLimit(ItemStack itemStack)
+ {
+ return this.transferLimit;
+ }
+
+ @Override
+ public List<String> getHudInfo(ItemStack itemStack)
+ {
+ LinkedList<String> info = new LinkedList<String>();
+ info.add(ElectricItem.manager.getToolTip(itemStack));
+ return info;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register)
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ iconMap.put(var1[i].damage, register.registerIcon(IHLModInfo.MODID + ":"+var1[i].textureName));
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int i)
+ {
+ return iconMap.get(0);
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack stack)
+ {
+ return nameMap.get(0);//stack.getItemDamage());
+ }
+
+ @SideOnly(Side.CLIENT)
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void func_150895_a(Item item, CreativeTabs par2CreativeTabs, List itemList)
+ {
+ ItemStack itemStack = new ItemStack(this, 1);
+ ItemStack charged;
+
+ if (this.getChargedItem(itemStack) == this)
+ {
+ charged = new ItemStack(this, 1);
+ ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false);
+ itemList.add(charged);
+ }
+
+ if (this.getEmptyItem(itemStack) == this)
+ {
+ charged = new ItemStack(this, 1);
+ ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false);
+ itemList.add(charged);
+ }
+ }
+
+ public static ItemStack getFullyChargedItemStack(String name)
+ {
+ ItemStack stack = IHLUtils.getThisModItemStack(name);
+ ElectricItem.manager.charge(stack, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false);
+ return stack;
+ }
+
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean flag)
+ {
+ if(BatteryItem.descriptionMap.containsKey(0))//itemStack.getItemDamage()))
+ {
+ info.add(BatteryItem.descriptionMap.get(0));//itemStack.getItemDamage()));
+ }
+ }
+
+ @Override
+ public double getDurabilityForDisplay(ItemStack stack)
+ {
+ return (this.maxCharge-ElectricItem.manager.getCharge(stack))/this.maxCharge;
+ }
+
+ public enum Type
+ {
+ LeadAcidBattery(0,"leadAcidBattery","Pb/Pb2PbO4 + H2SO4");
+ Type(int damage1,String unlocalizedName1,String description1)
+ {
+ damage=damage1;
+ textureName=oreRegistryName=unLocalizedName=unlocalizedName1;
+ description=description1;
+ }
+ public int damage;
+ public String unLocalizedName;
+ public String oreRegistryName;
+ public String description;
+ public String textureName;
+ }
+
+ public static ItemStack getFullyChargedItemStackWithSize(String name, int stackSize1)
+ {
+ ItemStack stack = getFullyChargedItemStack(name);
+ stack.stackSize=stackSize1;
+ return stack;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ChemicalReactorContainer.java b/src/main/java/ihl/processing/chemistry/ChemicalReactorContainer.java new file mode 100644 index 0000000..16b6baa --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ChemicalReactorContainer.java @@ -0,0 +1,37 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class ChemicalReactorContainer extends BasicElectricMotorContainer<ChemicalReactorTileEntity> {
+
+ protected ChemicalReactorTileEntity tileEntity;
+ public List<FluidStack> fluidTankFluidList;
+ public int fluidListHash = -1;
+
+ public ChemicalReactorContainer(EntityPlayer entityPlayer, ChemicalReactorTileEntity tileEntity1) {
+ super(entityPlayer, tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList = tileEntity.getFluidTank().getFluidList();
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 60, 51));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 60, 15));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 60, 33));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 122 - 18, 15));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 122, 15));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 122 - 18, 51));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 122, 51));
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ if (this.fluidListHash != fluidTankFluidList.hashCode()) {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ this.fluidListHash = fluidTankFluidList.hashCode();
+ }
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/ChemicalReactorGui.java b/src/main/java/ihl/processing/chemistry/ChemicalReactorGui.java new file mode 100644 index 0000000..de22f76 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ChemicalReactorGui.java @@ -0,0 +1,79 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class ChemicalReactorGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIChemicalReactor.png");
+ private ChemicalReactorContainer container;
+ private int mixerFrame=0;
+
+ public ChemicalReactorGui (ChemicalReactorContainer container1) {
+ //the container is instanciated and passed to the superclass for handling
+ super(container1);
+ this.container=container1;
+ }
+
+ @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, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27);
+ this.drawTexturedModalRect(30, 29, getFrameX(i1), getFrameY(i1),24,24);
+ if(mixerFrame++>4)
+ {
+ mixerFrame=0;
+ }
+ }
+ else
+ {
+ mixerFrame=0;
+ }
+ this.drawTexturedModalRect(103-18, 52, 246, 226+6*mixerFrame,10,6);
+ if (this.container.tileEntity.getTankAmount() > 0)
+ {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 102-18, 28, 114-18, 59, zLevel, par1, par2, xOffset, yOffset);
+ }
+ }
+
+ @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);
+ }
+
+ private int getFrameY(int number)
+ {
+ return (number % 10) * 24 + 14;
+ }
+
+ private int getFrameX(int number)
+ {
+ return (number / 10) * 24 + 176;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ChemicalReactorTileEntity.java b/src/main/java/ihl/processing/chemistry/ChemicalReactorTileEntity.java new file mode 100644 index 0000000..7de2ccf --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ChemicalReactorTileEntity.java @@ -0,0 +1,294 @@ +package ihl.processing.chemistry;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.processing.metallurgy.BasicElectricMotorTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+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;
+
+public class ChemicalReactorTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler
+{
+ private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("chemicalreactor");
+ public final ApparatusProcessableInvSlot input;
+ public final IHLInvSlotOutput outputSlot;
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ private final IHLFluidTank fluidTank = new IHLFluidTank(8000);
+ public short temperature=20;
+
+ public ChemicalReactorTileEntity() {
+ super();
+ this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2);
+ 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);
+ this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.I, 2, 64);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=side;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("chemicalReactor");
+ }
+
+ @Override
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ 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 true;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "chemicalReactor";
+ }
+
+ 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 ChemicalReactorGui(new ChemicalReactorContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player)
+ {
+ this.fluidTank.sortFluidsByDensity();
+ return new ChemicalReactorContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {}
+
+ @Override
+ public boolean canOperate()
+ {
+ UniversalRecipeOutput output = getOutput();
+ if(output!=null && this.outputSlot.canAdd(getOutput().getItemOutputs()))
+ {
+ if(output.specialConditions)
+ {
+ return this.checkSpecialConditions();
+ }
+ else
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean checkSpecialConditions()
+ {
+ ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing());
+ TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ);
+ if(te instanceof CryogenicDistillerTileEntity)
+ {
+ CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te;
+ return cgte.getFacing()==this.getFacing() && cgte.canProcess();
+ }
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ public UniversalRecipeOutput getOutput()
+ {
+ return ChemicalReactorTileEntity.recipeManager.getOutputFor(this.getInput()[0],this.getInput()[1]);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public List[] getInput()
+ {
+ return new List[] {fluidTank.getFluidList(), this.input.getItemStackList()};
+ }
+
+ @Override
+ @SuppressWarnings({ "unchecked"})
+ public void operate()
+ {
+ UniversalRecipeInput recipeInput = ChemicalReactorTileEntity.recipeManager.getRecipeInput(this.getInput()[0],this.getInput()[1]);
+ UniversalRecipeOutput output1 = getOutput();
+ for(int i=0; i<recipeInput.getItemInputs().size();i++)
+ {
+ this.input.consume(recipeInput.getItemInputs().get(i));
+ }
+ if(output1.specialConditions)
+ {
+ ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing());
+ TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ);
+ if(te instanceof CryogenicDistillerTileEntity)
+ {
+ CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te;
+ cgte.fill(ForgeDirection.getOrientation(this.getFacing()).getOpposite(), recipeInput.getFluidInputs().get(0).getInputs().get(0), true);
+ }
+ }
+ this.fluidTank.drain(recipeInput.getFluidInputs(), true);
+ this.fluidTank.fill(output1.getFluidOutputs(), true);
+ this.outputSlot.add(output1.getItemOutputs());
+ }
+
+ @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 static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output)
+ {
+ recipeManager.addRecipe(input, output);
+ }
+
+ public int getNumberOfFluidsInTank()
+ {
+ return this.fluidTank.getNumberOfFluids();
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1, fluidStackInput2}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new ItemStack[] {itemStackOutput1, itemStackOutput2}),200));
+ }
+
+ public static void addSpecialConditionsRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1, fluidStackInput2}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new ItemStack[] {itemStackOutput1, itemStackOutput2}),200, true));
+ }
+
+ public IHLFluidTank getFluidTank()
+ {
+ return this.fluidTank;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/CryogenicDistillerContainer.java b/src/main/java/ihl/processing/chemistry/CryogenicDistillerContainer.java new file mode 100644 index 0000000..988b844 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/CryogenicDistillerContainer.java @@ -0,0 +1,39 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class CryogenicDistillerContainer extends BasicElectricMotorContainer<CryogenicDistillerTileEntity> {
+
+ public CryogenicDistillerTileEntity tileEntity;
+ private int lastNumberOfFluids = -1;
+ private int lastFluidAmount = -1;
+ public List<FluidStack> fluidTankFluidList;
+
+ public CryogenicDistillerContainer(EntityPlayer entityPlayer,
+ CryogenicDistillerTileEntity lathePart1TileEntity) {
+ super(entityPlayer, lathePart1TileEntity);
+ tileEntity=lathePart1TileEntity;
+ fluidTankFluidList=tileEntity.fluidTankProducts.getFluidList();
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fillInputSlotInput,0, 58, 51));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fillInputSlotProducts,0, 103, 51));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fluidItemsSlot,0, 58, 15));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.fluidItemsSlot,1, 103, 15));
+ }
+
+ @Override
+ public void detectAndSendChanges()
+ {
+ super.detectAndSendChanges();
+ if (this.tileEntity.fluidTankProducts.getFluidAmount() != this.lastFluidAmount || this.tileEntity.fluidTankProducts.getNumberOfFluids() != this.lastNumberOfFluids)
+ {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ }
+ this.lastNumberOfFluids = this.tileEntity.fluidTankProducts.getNumberOfFluids();
+ this.lastFluidAmount = this.tileEntity.fluidTankProducts.getFluidAmount();
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/CryogenicDistillerGui.java b/src/main/java/ihl/processing/chemistry/CryogenicDistillerGui.java new file mode 100644 index 0000000..a8f9f0f --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/CryogenicDistillerGui.java @@ -0,0 +1,71 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import ic2.core.IC2;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+public class CryogenicDistillerGui extends GuiContainer {
+
+ private CryogenicDistillerContainer container;
+ protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUICryogenicDistiller.png");
+
+ public CryogenicDistillerGui(CryogenicDistillerContainer latheContainer) {
+ super(latheContainer);
+ container = latheContainer;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void initGui() {
+ super.initGui();
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.buttonList.add(new GuiButton(0, x + 7, y + 50, 49, 20, "Empty"));
+ }
+
+ @Override
+ public void actionPerformed(GuiButton button) {
+ super.actionPerformed(button);
+ IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, button.id);
+ }
+
+ @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(tex);
+ 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);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F);
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12), 12);
+ this.drawTexturedModalRect(9, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0) {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18), 18);
+ this.drawTexturedModalRect(81, 35, 198, 0, i1 + 1, 13);
+ }
+ if (this.container.tileEntity.fluidTankProducts.getFluid() != null
+ && this.container.tileEntity.fluidTankProducts.getFluidAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankProducts, 125, 28, 137, 67,
+ zLevel, par1, par2, xOffset, yOffset);
+ }
+ }
+
+ @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(tex);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/CryogenicDistillerTileEntity.java b/src/main/java/ihl/processing/chemistry/CryogenicDistillerTileEntity.java new file mode 100644 index 0000000..6a156db --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/CryogenicDistillerTileEntity.java @@ -0,0 +1,229 @@ +package ihl.processing.chemistry;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.ContainerBase;
+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.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+import net.minecraft.block.Block;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+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;
+
+public class CryogenicDistillerTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler {
+
+ public final InvSlotConsumableLiquidIHL fillInputSlotInput;
+ public final InvSlotOutput fluidItemsSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlotProducts;
+
+ private IHLFluidTank fluidTankInput = new IHLFluidTank(8000);
+ public IHLFluidTank fluidTankProducts = new IHLFluidTank(8000);
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("cryogenicdistiller");
+ protected static UniversalRecipeOutput airOutput = new UniversalRecipeOutput(new FluidStack[] {
+ IHLUtils.getFluidStackWithSize("nitrogen", 781), IHLUtils.getFluidStackWithSize("oxygen", 209) }, null, 20,
+ false);
+
+ static {
+ recipeManager.addRecipe(
+ new UniversalRecipeInput(new FluidStack[] { IHLUtils.getFluidStackWithSize("air", 1000) }, null),
+ airOutput);
+ }
+
+ public CryogenicDistillerTileEntity() {
+ super();
+ this.fillInputSlotInput = new InvSlotConsumableLiquidIHL(this, "fillInputSlotInput", -1, InvSlot.Access.I, 1,
+ InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ this.fillInputSlotProducts = new InvSlotConsumableLiquidIHL(this, "fillInputSlotProducts", -1, InvSlot.Access.I,
+ 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ this.fluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 2);
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "CryogenicDistiller";
+ }
+
+ @Override
+ public void updateEntityServer() {
+ super.updateEntityServer();
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlotProducts, null, fluidItemsSlot, fluidTankProducts);
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player) {
+ return IHLUtils.getThisModItemStack("cryogenicDistiller");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new CryogenicDistillerGui(new CryogenicDistillerContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new CryogenicDistillerContainer(player, this);
+ }
+
+ @Override
+ public void operate() {
+ UniversalRecipeInput ri = CryogenicDistillerTileEntity.recipeManager.getRecipeInput(getInput());
+ this.fluidTankProducts.fill(getOutput().getFluidOutputs(), true);
+ this.fluidTankInput.drain(ri.getFluidInputs().get(0), true);
+ TileEntity teOnTop = worldObj.getTileEntity(xCoord, yCoord + 1, zCoord);
+ if (teOnTop instanceof IFluidHandler && this.fluidTankProducts.getLigthestFluid() != null) {
+ IFluidHandler topFH = (IFluidHandler) teOnTop;
+ if (topFH.canFill(ForgeDirection.DOWN, this.fluidTankProducts.getLigthestFluid().getFluid())) {
+ FluidStack fsToDrain = this.fluidTankProducts.getLigthestFluid().copy();
+ fsToDrain.amount = topFH.fill(ForgeDirection.DOWN, fsToDrain, true);
+ this.fluidTankProducts.drain(fsToDrain, true);
+ }
+ }
+ ForgeDirection orientation = ForgeDirection.getOrientation(this.getFacing());
+ TileEntity teOnFront = worldObj.getTileEntity(xCoord + orientation.offsetX, yCoord,
+ zCoord + orientation.offsetZ);
+ if (teOnFront instanceof IFluidHandler && this.fluidTankProducts.getFluid() != null) {
+ IFluidHandler frontFH = (IFluidHandler) teOnFront;
+ if (frontFH.canFill(orientation, this.fluidTankProducts.getFluid().getFluid())) {
+ FluidStack fsToDrain = this.fluidTankProducts.getFluid().copy();
+ fsToDrain.amount = frontFH.fill(orientation, fsToDrain, true);
+ this.fluidTankProducts.drain(fsToDrain, true);
+ }
+ }
+ }
+
+ public UniversalRecipeOutput getOutput() {
+ return CryogenicDistillerTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @Override
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public List[] getInput() {
+ return new List[] { Arrays.asList(new FluidStack[] { this.fluidTankInput.getLigthestFluid() }), null };
+ }
+
+ @Override
+ public boolean canOperate() {
+ UniversalRecipeOutput output = this.getOutput();
+ if (output == airOutput) {
+ ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing()).getOpposite();
+ Block block = worldObj.getBlock(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
+ if (!block.isAir(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ)
+ && block != Blocks.air)
+ return false;
+ }
+ return output != null && (this.fluidTankProducts.getCapacity() - this.fluidTankProducts.getFluidAmount()) > 0;
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTankInput.readFromNBT(nbttagcompound.getCompoundTag("fluidTankInput"));
+ this.fluidTankProducts.readFromNBT(nbttagcompound.getCompoundTag("fluidTankProducts"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankInputTag = new NBTTagCompound();
+ this.fluidTankInput.writeToNBT(fluidTankInputTag);
+ nbttagcompound.setTag("fluidTankInput", fluidTankInputTag);
+ NBTTagCompound fluidTankProductsTag = new NBTTagCompound();
+ this.fluidTankProducts.writeToNBT(fluidTankProductsTag);
+ nbttagcompound.setTag("fluidTankProducts", fluidTankProductsTag);
+ }
+
+ public static void addRecipe(FluidStack input, FluidStack output, FluidStack output2, boolean specialCondition) {
+ if (output2 != null) {
+ recipeManager.addRecipe(new UniversalRecipeInput(new FluidStack[] { input }, null),
+ new UniversalRecipeOutput(new FluidStack[] { output, output2 }, null, 20, specialCondition));
+ } else {
+ recipeManager.addRecipe(new UniversalRecipeInput(new FluidStack[] { input }, null),
+ new UniversalRecipeOutput(new FluidStack[] { output }, null, 20, specialCondition));
+ }
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public boolean canProcess() {
+ return this.energy >= this.energyConsume;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection dir, Fluid arg1) {
+ return dir.equals(ForgeDirection.getOrientation(this.getFacing())) || dir.equals(ForgeDirection.UP);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection dir, Fluid fluid) {
+ return dir.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite());
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection dir, FluidStack fstack, boolean doDrain) {
+ if (this.canDrain(dir, null)) {
+ return this.fluidTankProducts.drain(fstack, doDrain);
+ }
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection dir, int amount, boolean doDrain) {
+ if (this.canDrain(dir, null)) {
+ if (dir.equals(ForgeDirection.UP)) {
+ return this.fluidTankProducts.drainLightest(amount, doDrain);
+ }
+ return this.fluidTankProducts.drain(amount, doDrain);
+ }
+ return null;
+ }
+
+ @Override
+ public int fill(ForgeDirection dir, FluidStack fstack, boolean doFill) {
+ if (fstack != null && fstack.getFluid() != null && this.canFill(dir, fstack.getFluid())) {
+ return this.fluidTankInput.fill(fstack, doFill);
+ }
+ return 0;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection dir) {
+ return new FluidTankInfo[] { this.fluidTankInput.getInfo(), this.fluidTankProducts.getInfo() };
+ }
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event) {
+ switch (event) {
+ case 0:
+ this.fluidTankProducts.setEmpty();
+ break;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/DosingPumpContainer.java b/src/main/java/ihl/processing/chemistry/DosingPumpContainer.java new file mode 100644 index 0000000..5a4cb21 --- /dev/null +++ b/src/main/java/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<DosingPumpTileEntity> {
+
+ 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<FluidStack> 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/src/main/java/ihl/processing/chemistry/DosingPumpGui.java b/src/main/java/ihl/processing/chemistry/DosingPumpGui.java new file mode 100644 index 0000000..dde4f13 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/DosingPumpGui.java @@ -0,0 +1,103 @@ +package ihl.processing.chemistry;
+
+import java.awt.event.KeyEvent;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.ClientProxy;
+import ihl.IHLMod;
+import ihl.utils.IHLRenderUtils;
+import ihl.utils.IHLUtils;
+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;
+
+@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 int lastFluidAmountSetpoint = -1;
+ 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) {
+ if(lastFluidAmountSetpoint!= this.container.tileEntity.fluidAmountSetpoint){
+ setpointTextField.setText(Integer.toString(this.container.tileEntity.fluidAmountSetpoint));
+ lastFluidAmountSetpoint= this.container.tileEntity.fluidAmountSetpoint;
+ }
+ 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/src/main/java/ihl/processing/chemistry/DosingPumpTileEntity.java b/src/main/java/ihl/processing/chemistry/DosingPumpTileEntity.java new file mode 100644 index 0000000..e1e4996 --- /dev/null +++ b/src/main/java/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 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;
+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;
+
+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/src/main/java/ihl/processing/chemistry/ElectricEvaporatorBlock.java b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorBlock.java new file mode 100644 index 0000000..f65b76d --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorBlock.java @@ -0,0 +1,220 @@ +package ihl.processing.chemistry;
+
+import java.util.Random;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+public class ElectricEvaporatorBlock extends Block implements ITileEntityProvider{
+
+ IIcon textureFrontActive, textureSide, textureBottom, textureTop;
+
+ public ElectricEvaporatorBlock(Material material)
+ {
+ super(material);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ }
+
+ @Override
+ public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
+ {
+ return new ItemStack(Blocks.furnace,1).getItem();
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
+ {
+ ItemStack result = new ItemStack(Blocks.furnace,1);
+ this.dropBlockAsItem(world, x, y, z, result);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ return new ElectricEvaporatorTileEntity();
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorFront");
+ this.textureFrontActive = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorFrontActive");
+ this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorSide");
+ this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorTop");
+ this.textureBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":electricEvaporatorBottom");
+ }
+
+ @Override
+ public boolean hasTileEntity(int metadata)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){
+ TileEntity te = world.getTileEntity(x,y,z);
+ if(te instanceof ElectricEvaporatorTileEntity)
+ {
+ ElectricEvaporatorTileEntity bte = (ElectricEvaporatorTileEntity)te;
+ if (bte == null || entityPlayer.isSneaking()) {
+ return false;
+ }
+ else
+ {
+ return bte.getGui(entityPlayer);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Called when the block is placed in the world.
+ */
+ @Override
+ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack)
+ {
+ int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+ TileEntity t = world.getTileEntity(x, y, z);
+ if(t!=null && t instanceof ElectricEvaporatorTileEntity)
+ {
+ ElectricEvaporatorTileEntity te = (ElectricEvaporatorTileEntity)t;
+ if(player.isSneaking())
+ {
+ switch(var7)
+ {
+ case 0:
+ te.setFacing((short) 3);
+ break;
+ case 1:
+ te.setFacing((short) 4);
+ break;
+ case 2:
+ te.setFacing((short) 2);
+ break;
+ case 3:
+ te.setFacing((short) 5);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch(var7)
+ {
+ case 0:
+ te.setFacing((short) 2);
+ break;
+ case 1:
+ te.setFacing((short) 5);
+ break;
+ case 2:
+ te.setFacing((short) 3);
+ break;
+ case 3:
+ te.setFacing((short) 4);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
+ {
+ IIcon faceIcon=this.blockIcon;
+ int facing=3;
+ int mask[] = {
+ 0,1,2,3,4,5,
+ 1,0,3,2,4,5,
+ 2,3,0,1,4,5,
+ 2,3,1,0,4,5,
+ 2,3,5,4,0,1,
+ 2,3,4,5,1,0
+ };
+ TileEntity te = world.getTileEntity(x, y, z);
+ if(te!=null)
+ {
+ ElectricEvaporatorTileEntity tebh = (ElectricEvaporatorTileEntity) te;
+ facing=tebh.getFacing();
+ if(tebh.getActive())
+ {
+ faceIcon=this.textureFrontActive;
+ }
+ }
+
+ switch (mask[facing*6+side])
+ {
+ case 0:
+ return faceIcon;
+ case 1:
+ return this.textureSide;
+ case 2:
+ return this.textureBottom;
+ case 3:
+ return this.textureTop;
+ case 4:
+ return this.textureSide;
+ case 5:
+ return this.textureSide;
+ default:
+ return this.textureSide;
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta)
+ {
+ switch (side)
+ {
+ case 0:
+ return this.textureBottom;
+ case 1:
+ return this.textureTop;
+ case 2:
+ return this.textureSide;
+ case 3:
+ return this.blockIcon;
+ case 4:
+ return this.textureSide;
+ case 5:
+ return this.textureSide;
+ default:
+ return this.textureSide;
+ }
+ }
+
+ @Override
+ public void randomDisplayTick(World world, int x, int y, int z, Random random)
+ {
+ TileEntity te = world.getTileEntity(x, y, z);
+ if(te instanceof ElectricEvaporatorTileEntity)
+ {
+ ElectricEvaporatorTileEntity ete = (ElectricEvaporatorTileEntity) te;
+ if(ete.getActive())
+ {
+ world.spawnParticle("snowshovel", x+0.2D, y+1.2D, z+0.2D, 0D, 0.05D, 0D);
+ }
+ }
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/ElectricEvaporatorContainer.java b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorContainer.java new file mode 100644 index 0000000..d981d94 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorContainer.java @@ -0,0 +1,113 @@ +package ihl.processing.chemistry;
+
+import ic2.core.ContainerBase;
+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.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+public class ElectricEvaporatorContainer extends ContainerBase<ElectricEvaporatorTileEntity> {
+
+ protected ElectricEvaporatorTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public double lastEnergy = -1;
+ public short lastProgress = -1;
+ private final static int height=166;
+
+ public ElectricEvaporatorContainer(EntityPlayer entityPlayer, ElectricEvaporatorTileEntity electricEvaporatorTileEntity){
+ super(electricEvaporatorTileEntity);
+ this.tileEntity = electricEvaporatorTileEntity;
+ 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(electricEvaporatorTileEntity.fuelSlot, 0, 8, 32));
+ this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.fluidItemsSlot, 0, 44, 14));
+ this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.emptyFluidItemsSlot, 0, 44, 32));
+ this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.fillItemsSlot, 0, 44, 50));
+ this.addSlotToContainer(new SlotInvSlot(electricEvaporatorTileEntity.outputSlot, 0, 117, 32));
+ for(int row=0;row<=3;row++)
+ {
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.upgradeSlot, row, 152, 8+row*18));
+ }
+
+ }
+
+ @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.getFluidTank().getFluid()!=null && this.tileEntity.getFluidTank().getFluidAmount() != this.lastFluidAmount)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.getFluidTank().getFluid().getFluid().getID());
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getFluidTank().getFluidAmount());
+ }
+
+ if (this.tileEntity.getEnergy() != this.lastEnergy)
+ {
+ icrafting.sendProgressBarUpdate(this, 2, ((int)this.tileEntity.getEnergy()>>15) & Short.MAX_VALUE);
+ icrafting.sendProgressBarUpdate(this, 3, (short)((int)this.tileEntity.getEnergy() & Short.MAX_VALUE));
+ }
+
+ if (this.tileEntity.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 4, this.tileEntity.progress);
+ icrafting.sendProgressBarUpdate(this, 5, this.tileEntity.maxProgress);
+ }
+ }
+
+ this.lastFluidAmount = this.tileEntity.getFluidTank().getFluidAmount();
+ this.lastEnergy = this.tileEntity.getEnergy();
+ this.lastProgress = this.tileEntity.progress;
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value)
+ {
+ super.updateProgressBar(index, value);
+
+ switch (index)
+ {
+ case 0:
+ this.tileEntity.getFluidTank().setFluid(new FluidStack(FluidRegistry.getFluid(value), 1000));
+ break;
+ case 1:
+ this.tileEntity.getFluidTank().setFluid(new FluidStack(this.tileEntity.getFluidTank().getFluid().getFluid(), value));
+ break;
+ case 2:
+ this.tileEntity.setEnergy(value<<15);
+ break;
+ case 3:
+ this.tileEntity.setEnergy(this.tileEntity.getEnergy()+value);
+ break;
+ case 4:
+ this.tileEntity.progress=(short) value;
+ break;
+ case 5:
+ this.tileEntity.maxProgress=(short) value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/ElectricEvaporatorGui.java b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorGui.java new file mode 100644 index 0000000..4a36631 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorGui.java @@ -0,0 +1,85 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.util.DrawUtil;
+import ic2.core.util.GuiTooltipHelper;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+@SideOnly(Side.CLIENT)
+public class ElectricEvaporatorGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIElectricEvaporator.png");
+ private ElectricEvaporatorContainer container;
+ private String title = StatCollector.translateToLocal("ihl.gui.electricEvaporator");
+
+ public ElectricEvaporatorGui (ElectricEvaporatorContainer electricEvaporatorContainer) {
+ //the container is instanciated and passed to the superclass for handling
+ super(electricEvaporatorContainer);
+ this.container=electricEvaporatorContainer;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ int xOffset = (this.width - xSize) / 2;
+ int yOffset = (this.height - ySize) / 2;
+ fontRendererObj.drawString(title, 8, 70, 6171880);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(background);
+ int i1;
+ if (this.container.tileEntity.getEnergy() > 0D)
+ {
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12);
+ this.drawTexturedModalRect(9, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18);
+ this.drawTexturedModalRect(99, 34, 198, 0, i1 + 1, 13);
+ }
+
+ if (this.container.tileEntity.getFluidTank().getFluid()!=null && this.container.tileEntity.getFluidTank().getFluidAmount() > 0)
+ {
+ FluidStack fluidStack = this.container.tileEntity.getFluidTank().getFluid();
+ if(fluidStack!=null)
+ {
+ Fluid fluid = fluidStack.getFluid();
+ if(fluid!=null)
+ {
+
+ IIcon fluidIcon = fluid.getIcon();
+
+ if (fluidIcon != null)
+ {
+ this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
+ int liquidHeight = this.container.tileEntity.gaugeLiquidScaled(47);
+
+ DrawUtil.drawRepeated(fluidIcon, (82), 16 + 47 - liquidHeight, 12.0D, liquidHeight, this.zLevel);
+ this.mc.renderEngine.bindTexture(background);
+ }
+ }
+ String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getUnlocalizedName()) + ": " + fluidStack.amount + "mB";
+ //GuiTooltiphelper.drawAreaTooltip(par1-90, par2-32, tooltip, xOffset+64, yOffset+23, xOffset+74, yOffset+71);
+ GuiTooltipHelper.drawAreaTooltip(par1-90, par2-32, tooltip, xOffset-8, yOffset-15, xOffset+2, yOffset+30);
+ }
+ }
+ }
+
+ @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);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java new file mode 100644 index 0000000..cdf3524 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectricEvaporatorTileEntity.java @@ -0,0 +1,430 @@ +package ihl.processing.chemistry;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySink;
+import ic2.api.item.IC2Items;
+import ic2.api.network.INetworkTileEntityEventListener;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.audio.AudioSource;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotUpgrade;
+import ic2.core.upgrade.IUpgradableBlock;
+import ic2.core.upgrade.IUpgradeItem;
+import ic2.core.upgrade.UpgradableProperty;
+import ihl.IHLMod;
+import ihl.utils.IHLInvSlotDischarge;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.item.EntityItem;
+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.MinecraftForge;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class ElectricEvaporatorTileEntity extends EvaporatorTileEntity implements IEnergySink, IUpgradableBlock, INetworkTileEntityEventListener
+{
+ public final InvSlotUpgrade upgradeSlot;
+ private int tier;
+ public int maxStorage;
+ private int defaultMaxStorage;
+ private double energy;
+ public final int defaultEnergyConsume;
+ public final int defaultOperationLength;
+ public final int defaultTier;
+ public int energyConsume;
+ public AudioSource audioSource;
+ private int updateChecksum=0;
+ private boolean addedToEnergyNet=false;
+
+ public ElectricEvaporatorTileEntity()
+ {
+ super();
+ this.defaultEnergyConsume = this.energyConsume = 8;
+ this.defaultOperationLength = this.maxProgress = 400;
+ this.energy=0D;
+ this.tier = this.defaultTier = 1;
+ this.maxStorage = this.defaultMaxStorage = defaultEnergyConsume * defaultOperationLength;
+ this.fuelSlot = new IHLInvSlotDischarge(this, 1, Access.IO, this.tier, InvSlot.InvSide.BOTTOM);
+ this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 4, 4);
+ }
+
+ @Override
+ public void onLoaded()
+ {
+ super.onLoaded();
+ if (IC2.platform.isSimulating()&&!this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ fields.add("tier");
+ fields.add("maxStorage");
+ return fields;
+ }
+
+ public void setOverclockRates()
+ {
+ int speedUp=0;
+ int tierUp=0;
+ int capacityUp=0;
+ int checksum=0;
+ for(int i=0;i<this.upgradeSlot.size();i++)
+ {
+ if(this.upgradeSlot.get(i)!=null)
+ {
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("overclockerUpgrade").getItemDamage())
+ {
+ speedUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("transformerUpgrade").getItemDamage())
+ {
+ tierUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("energyStorageUpgrade").getItemDamage())
+ {
+ capacityUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ }
+ }
+ checksum=speedUp*4096+tierUp*64+capacityUp;
+ if(this.updateChecksum!=checksum)
+ {
+ this.maxProgress=(short)Math.max(this.defaultOperationLength*Math.pow(0.7D, speedUp),2D);
+ this.maxStorage=this.defaultMaxStorage + capacityUp*10000;
+ IC2.network.get().updateTileEntityField(this, "maxStorage");
+ this.energyConsume=(int) Math.min(this.defaultEnergyConsume*Math.pow(1.6D, speedUp),this.maxStorage);
+ this.tier=this.defaultTier+tierUp;
+ IC2.network.get().updateTileEntityField(this, "tier");
+ this.updateChecksum=checksum;
+ };
+ }
+
+ @Override
+ public void onUnloaded()
+ {
+ super.onUnloaded();
+
+ if (IC2.platform.isRendering() && this.audioSource != null)
+ {
+ IC2.audioManager.removeSources(this);
+ this.audioSource = null;
+ }
+
+ if (IC2.platform.isSimulating()&&this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.energy=nbttagcompound.getDouble("energy");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setDouble("energy", this.energy);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=(short)side && side!=0 && side!=1;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ if(this.outputSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.outputSlot.get()));
+ if(this.fuelSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.fuelSlot.get()));
+ if(this.emptyFluidItemsSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.emptyFluidItemsSlot.get()));
+ if(this.upgradeSlot.get(0)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(0)));
+ if(this.upgradeSlot.get(1)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(1)));
+ if(this.upgradeSlot.get(2)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(2)));
+ if(this.upgradeSlot.get(3)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(3)));
+ return new ItemStack(IHLMod.electricEvaporatorBlock,1);
+ }
+
+ public int getGUIEnergy(int i)
+ {
+ if(this.energy<Float.MAX_VALUE)
+ {
+ return Math.round((float)this.energy/this.maxStorage*i);
+ }
+ else
+ {
+ return Math.round((float)(this.energy/this.maxStorage)*i);
+ }
+ }
+
+ @Override
+ public boolean enableUpdateEntity()
+ {
+ return true;
+ }
+ @Override
+ public void updateEntityClient()
+ {
+ if(((IHLInvSlotDischarge)this.fuelSlot).tier!=this.tier)
+ {
+ ((IHLInvSlotDischarge)this.fuelSlot).tier=this.tier;
+ }
+ }
+ @Override
+ public void updateEntityServer()
+ {
+ if(((IHLInvSlotDischarge)this.fuelSlot).tier!=this.tier)
+ {
+ ((IHLInvSlotDischarge)this.fuelSlot).tier=this.tier;
+ }
+ if(IC2.platform.isSimulating())
+ {
+ this.setOverclockRates();
+
+ if(this.getDemandedEnergy() > 1.0D)
+ {
+ double amount = ((IHLInvSlotDischarge)this.fuelSlot).discharge(this.getDemandedEnergy(), false);
+ this.energy += amount;
+ }
+ if (this.needsFluid())
+ {
+ IHLUtils.handleFluidSlotsBehaviour(null, fluidItemsSlot, emptyFluidItemsSlot, fluidTank);
+ }
+
+ if (this.canOperate() && this.energy >= this.energyConsume)
+ {
+ this.setActive(true);
+
+ if (this.progress == 0)
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 0, true);
+ }
+ ++this.progress;
+ this.energy -= this.energyConsume;
+ if (this.progress >= this.maxProgress)
+ {
+ this.operate();
+ this.progress = 0;
+ IC2.network.get().initiateTileEntityEvent(this, 2, true);
+ }
+ }
+ else
+ {
+ if (this.progress != 0 && this.getActive())
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 1, true);
+ }
+ if (!this.canOperate())
+ {
+ this.progress = 0;
+ }
+ this.setActive(false);
+ }
+ for (int i = 0; i < this.upgradeSlot.size(); ++i)
+ {
+ ItemStack stack = this.upgradeSlot.get(i);
+
+ if (stack != null && stack.getItem() instanceof IUpgradeItem)
+ {
+ ((IUpgradeItem)stack.getItem()).onTick(stack, this);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onNetworkEvent(int event)
+ {
+ if (this.audioSource == null && this.getStartSoundFile() != null)
+ {
+ this.audioSource = IC2.audioManager.createSource(this, this.getStartSoundFile());
+ }
+
+ switch (event)
+ {
+ case 0:
+ if (this.audioSource != null)
+ {
+ this.audioSource.play();
+ }
+
+ break;
+
+ case 1:
+ if (this.audioSource != null)
+ {
+ this.audioSource.stop();
+ }
+
+ break;
+
+ case 2:
+ if (this.audioSource != null)
+ {
+ this.audioSource.stop();
+ }
+
+ }
+ }
+
+ public String getStartSoundFile()
+ {
+ return "Machines/Electro Furnace/ElectroFurnaceLoop.ogg";
+ }
+
+ /**
+ * Returns the name of the inventory
+ */
+ @Override
+ public String getInventoryName()
+ {
+ return "Electric evaporator";
+ }
+
+ @Override
+ public ContainerBase<ElectricEvaporatorTileEntity> getGuiContainer(EntityPlayer entityPlayer)
+ {
+ return new ElectricEvaporatorContainer(entityPlayer, this);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin)
+ {
+ return new ElectricEvaporatorGui(new ElectricEvaporatorContainer(entityPlayer, this));
+ }
+
+ @Override
+ public boolean getGui(EntityPlayer player)
+ {
+ return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false;
+ }
+
+ @Override
+ public int mX()
+ {
+ switch(this.getFacing())
+ {
+ case 4:
+ return -1;
+ case 5:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ @Override
+ public int mZ()
+ {
+ switch(this.getFacing())
+ {
+ case 2:
+ return -1;
+ case 3:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ @Override
+ public double getEnergy()
+ {
+ return this.energy;
+ }
+
+ @Override
+ public boolean useEnergy(double amount) {
+ if (this.energy >= amount)
+ {
+ this.energy -= amount;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public void setEnergy(double i) {
+ this.energy=i;
+ }
+
+ @Override
+ public double getDemandedEnergy()
+ {
+ return this.maxStorage - this.energy;
+ }
+
+ @Override
+ public int getSinkTier()
+ {
+ return this.tier;
+ }
+
+ @Override
+ public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
+ {
+ if (this.energy >= this.maxStorage)
+ {
+ return amount;
+ }
+ else
+ {
+ this.energy += amount;
+ return 0.0D;
+ }
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity emitter,
+ ForgeDirection direction) {
+ return true;
+ }
+
+ public ItemStack getOutput(int arg0)
+ {
+ return this.outputSlot.get(arg0);
+ }
+
+ public int getOutputSize() {
+ return this.outputSlot.size();
+ }
+
+ public void setOutput(int arg0, ItemStack arg1)
+ {
+ this.outputSlot.put(arg0, arg1);
+ }
+
+ @Override
+ public Set<UpgradableProperty> getUpgradableProperties()
+ {
+ Set<UpgradableProperty> properties = new HashSet<UpgradableProperty>();
+ properties.add(UpgradableProperty.ItemProducing);
+ properties.add(UpgradableProperty.EnergyStorage);
+ properties.add(UpgradableProperty.Transformer);
+ return properties;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ElectrolysisBathContainer.java b/src/main/java/ihl/processing/chemistry/ElectrolysisBathContainer.java new file mode 100644 index 0000000..13a5ddb --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectrolysisBathContainer.java @@ -0,0 +1,79 @@ +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 ElectrolysisBathContainer extends ContainerBase<ElectrolysisBathTileEntity> {
+
+ protected ElectrolysisBathTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public short lastProgress = -1;
+ public short lastTemperature = -1;
+ private final static int height = 166;
+ public List<FluidStack> fluidTankFluidList;
+ public int fluidListHash = -1;
+
+ public ElectrolysisBathContainer(EntityPlayer entityPlayer, ElectrolysisBathTileEntity tileEntity1) {
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList = this.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, 6, 52));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 6, 16));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 6, 33));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 98, 16));
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ for (int i = 0; i < this.crafters.size(); ++i) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+ if (this.fluidListHash != fluidTankFluidList.hashCode()) {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ this.fluidListHash = fluidTankFluidList.hashCode();
+ }
+
+ if (this.tileEntity.progress != this.lastProgress) {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+
+ }
+
+ this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank();
+ this.lastFluidAmount = this.tileEntity.getTankAmount();
+ this.lastProgress = this.tileEntity.progress;
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value) {
+ super.updateProgressBar(index, value);
+ switch (index) {
+ case 0:
+ this.tileEntity.progress = (short) value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/ElectrolysisBathGui.java b/src/main/java/ihl/processing/chemistry/ElectrolysisBathGui.java new file mode 100644 index 0000000..404ef94 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectrolysisBathGui.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.IC2;
+import ihl.utils.GuiMultiTextureButton;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.GuiButton;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class ElectrolysisBathGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIElectrolysisBath.png");
+ private ElectrolysisBathContainer container;
+ private GuiMultiTextureButton button1;
+ private int timer=10;
+
+ public ElectrolysisBathGui (ElectrolysisBathContainer container1) {
+ //the container is instanciated and passed to the superclass for handling
+ super(container1);
+ this.container=container1;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void initGui()
+ {
+ super.initGui();
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ button1=new GuiMultiTextureButton(0, x+97, y+58, 18, 18, background,97,58,238,238);
+ this.buttonList.add(button1);
+ }
+
+ @Override
+ public void actionPerformed(GuiButton button)
+ {
+ super.actionPerformed(button);
+ IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, button.id);
+ if (button.id == 0)
+ {
+ button1.isActive=true;
+ timer=10;
+ }
+ }
+
+ @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.progress > 0)
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27);
+ this.drawTexturedModalRect(121, 33, getFrameX(i1), getFrameY(i1),24,24);
+ }
+ if (this.container.tileEntity.getTankAmount() > 0)
+ {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 32, 11, 89, 72, zLevel, par1, par2, xOffset, yOffset);
+ }
+ this.mc.renderEngine.bindTexture(background);
+ this.drawTexturedModalRect(60, 3, 252, 0,4,48);
+ }
+
+ @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);
+ if(timer>0)
+ {
+ timer--;
+ }
+ if(timer==1)
+ {
+ button1.isActive=false;
+ }
+ }
+
+ private int getFrameY(int number)
+ {
+ return (number % 10) * 24 + 14;
+ }
+
+ private int getFrameX(int number)
+ {
+ return (number / 10) * 24 + 176;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ElectrolysisBathModel.java b/src/main/java/ihl/processing/chemistry/ElectrolysisBathModel.java new file mode 100644 index 0000000..310ec62 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectrolysisBathModel.java @@ -0,0 +1,86 @@ +package ihl.processing.chemistry; + +// Date: 12.04.2015 13:06:31 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; + +public class ElectrolysisBathModel extends ModelBase +{ + //fields + ModelRenderer Piece1; + ModelRenderer FrontPylone; + ModelRenderer BackPylone; + ModelRenderer LeftPylone; + ModelRenderer RightPylone; + + public ElectrolysisBathModel() + { + textureWidth = 64; + textureHeight = 128; + setTextureOffset("Piece1.Stick01", 48, 4); + setTextureOffset("Piece1.Shape1", 16, 18); + setTextureOffset("Piece1.Body04", 0, 48); + setTextureOffset("Piece1.Shape2", 0, 18); + setTextureOffset("Piece1.Shape3", 16, 0); + setTextureOffset("Piece1.Shape4", 0, 0); + setTextureOffset("Piece1.Box01", 41, 18); + setTextureOffset("Piece1.Shape5", 23, 84); + setTextureOffset("Piece1.Shape6", 23, 84); + setTextureOffset("Piece1.Shape7", 23, 84); + setTextureOffset("Piece1.Shape8", 23, 83); + setTextureOffset("FrontPylone.Shape9", 23, 84); + setTextureOffset("BackPylone.Shape10", 23, 84); + setTextureOffset("LeftPylone.Shape12", 23, 84); + setTextureOffset("RightPylone.Shape11", 23, 82); + + Piece1 = new ModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = false; + Piece1.addBox("Stick01", -1F, -16F, -1F, 2, 9, 2); + Piece1.addBox("Shape1", -8F, -8F, -8F, 2, 16, 14); + Piece1.addBox("Body04", -6F, -7F, -6F, 12, 15, 12); + Piece1.addBox("Shape2", 6F, -8F, -6F, 2, 16, 14); + Piece1.addBox("Shape3", -6F, -8F, -8F, 14, 16, 2); + Piece1.addBox("Shape4", -8F, -8F, 6F, 14, 16, 2); + Piece1.addBox("Box01", -2F, -13F, -2F, 4, 2, 4); + Piece1.addBox("Shape5", 5F, -9F, -1.5F, 2, 2, 3); + Piece1.addBox("Shape6", -7F, -9F, -1.5F, 2, 2, 3); + Piece1.addBox("Shape7", -1.5F, -9F, 5F, 3, 2, 2); + Piece1.addBox("Shape8", -1.5F, -9F, -7F, 3, 2, 2); + FrontPylone = new ModelRenderer(this, "FrontPylone"); + FrontPylone.setRotationPoint(0F, 7F, -5F); + setRotation(FrontPylone, -0.9F, 0F, 0); + FrontPylone.mirror = true; + FrontPylone.addBox("Shape9", -1F, -5F, -1F, 2, 6, 1); + BackPylone = new ModelRenderer(this, "BackPylone"); + BackPylone.setRotationPoint(0F, 7F, 5F); + setRotation(BackPylone, 0.9F, 0F, 0F); + BackPylone.mirror = true; + BackPylone.addBox("Shape10", -1F, -5F, 0F, 2, 6, 1); + LeftPylone = new ModelRenderer(this, "LeftPylone"); + LeftPylone.setRotationPoint(5F, 7F, 0F); + setRotation(LeftPylone, 0F, 0F, -0.9F); + LeftPylone.mirror = true; + LeftPylone.addBox("Shape12", 0F, -5F, -1F, 1, 6, 2); + RightPylone = new ModelRenderer(this, "RightPylone"); + RightPylone.setRotationPoint(-5F, 7F, 0F); + setRotation(RightPylone, 0, 0F, 0.9F); + RightPylone.mirror = true; + RightPylone.addBox("Shape11", -1F, -5F, -1F, 1, 6, 2); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/chemistry/ElectrolysisBathTileEntity.java b/src/main/java/ihl/processing/chemistry/ElectrolysisBathTileEntity.java new file mode 100644 index 0000000..ea98a34 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ElectrolysisBathTileEntity.java @@ -0,0 +1,297 @@ +package ihl.processing.chemistry;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.network.INetworkClientTileEntityEventListener;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.flexible_cable.FlexibleCableHolderBaseTileEntity;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+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;
+
+public class ElectrolysisBathTileEntity extends FlexibleCableHolderBaseTileEntity implements IHasGui, INetworkClientTileEntityEventListener, IFluidHandler
+{
+ private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("electrolysisbath");
+ public final ApparatusProcessableInvSlot input;
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ public short progress;
+ protected short operationLength=20000;//Short.MAX_VALUE=32767
+ private final IHLFluidTank fluidTank = new IHLFluidTank(2000);
+ private final static double resistance=5D;
+
+ public ElectrolysisBathTileEntity() {
+ 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);
+ this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 1, 64);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return false;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("electrolysisBath");
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank);
+ if (this.canOperate())
+ {
+ this.setActive(true);
+ if (this.progress == 0)
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 0, true);
+ }
+ if(gridID!=-1 && this.getGrid().energy>0D)
+ {
+ double drawEnergy = getEnergyAmountThisNodeWant();
+ this.progress+=drawEnergy;
+ this.getGrid().drawEnergy(drawEnergy, this);
+ }
+
+ if (this.progress >= this.operationLength)
+ {
+ this.operate();
+ this.progress = 0;
+ IC2.network.get().initiateTileEntityEvent(this, 2, true);
+ }
+ }
+ else
+ {
+ if (this.progress != 0 && this.getActive())
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 1, true);
+ }
+ if (!this.canOperate())
+ {
+ this.progress = 0;
+ }
+ this.setActive(false);
+ }
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int amount, boolean doDrain)
+ {
+ FluidStack fstack = this.fluidTank.drain(amount, doDrain);
+ return fstack;
+ }
+
+
+ //1.7.10 API
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return true;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection direction, Fluid arg1) {
+ return true;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "Electrolysis bath";
+ }
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event)
+ {
+ TileEntity te = worldObj.getTileEntity(xCoord, yCoord-1, zCoord);
+ if(te instanceof IFluidHandler && this.fluidTank.getFluid()!=null)
+ {
+ IFluidHandler ifhte = (IFluidHandler)te;
+ if(ifhte.canFill(ForgeDirection.UP, this.fluidTank.getFluid().getFluid()))
+ {
+ int filled = ifhte.fill(ForgeDirection.UP, this.fluidTank.drain(this.getTankAmount(), false), true);
+ this.fluidTank.drain(filled, true);
+ }
+ }
+ }
+
+ public int gaugeProgressScaled(int i)
+ {
+ return this.progress * i / operationLength;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new ElectrolysisBathGui(new ElectrolysisBathContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player)
+ {
+ this.fluidTank.sortFluidsByDensity();
+ return new ElectrolysisBathContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {}
+
+ public boolean canOperate()
+ {
+ return getOutput()!=null;
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ return ElectrolysisBathTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @SuppressWarnings("rawtypes")
+ public List[] getInput()
+ {
+ for(int i=0;i<fluidTank.getNumberOfFluids();i++)
+ {
+ List[] rInput = new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid(i)}), this.input.getItemStackList()};
+ if(ElectrolysisBathTileEntity.recipeManager.getOutputFor(rInput)!=null)
+ {
+ return rInput;
+ }
+ }
+ return new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid()}), this.input.getItemStackList()};
+ }
+
+ public void operate() {
+ if (this.fluidTank.getCapacity() > this.fluidTank.getFluidAmount()) {
+ UniversalRecipeInput recipeInput = ElectrolysisBathTileEntity.recipeManager.getRecipeInput(getInput());
+ UniversalRecipeOutput output1 = getOutput();
+ for (int i = 0; i < recipeInput.getItemInputs().size(); i++) {
+ this.input.consume(recipeInput.getItemInputs().get(i));
+ }
+ this.fluidTank.fill(output1.getFluidOutputs(), true);
+ }
+ }
+
+ @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 static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output)
+ {
+ recipeManager.addRecipe(input, output);
+ }
+
+ public int getNumberOfFluidsInTank()
+ {
+ return this.fluidTank.getNumberOfFluids();
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public IHLFluidTank getFluidTank()
+ {
+ return this.fluidTank;
+ }
+
+ @Override
+ public double getMaxAllowableVoltage()
+ {
+ return 64000D;
+ }
+
+ @Override
+ public double getEnergyAmountThisNodeWant()
+ {
+ double voltage = this.getGrid().getSinkVoltage(this);
+ double energy = voltage*voltage/resistance;
+ return this.getOutput()!=null?energy>1d?energy:1d:0d;
+ }
+
+ @Override
+ public void injectEnergyInThisNode(double amount, double voltage)
+ {
+ this.progress+=amount;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/EvaporatorBlock.java b/src/main/java/ihl/processing/chemistry/EvaporatorBlock.java new file mode 100644 index 0000000..6994176 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/EvaporatorBlock.java @@ -0,0 +1,221 @@ +package ihl.processing.chemistry;
+
+import java.util.Random;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+public class EvaporatorBlock extends Block implements ITileEntityProvider{
+
+ IIcon textureFrontActive, textureSide, textureBottom, textureTop;
+
+ public EvaporatorBlock(Material material)
+ {
+ super(material);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ }
+
+ @Override
+ public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
+ {
+ return new ItemStack(Blocks.furnace,1).getItem();
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
+ {
+ ItemStack result = new ItemStack(Blocks.furnace,1);
+ this.dropBlockAsItem(world, x, y, z, result);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ return new EvaporatorTileEntity();
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorFront");
+ this.textureFrontActive = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorFrontActive");
+ this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorSide");
+ this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorTop");
+ this.textureBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":solidFuelEvaporatorBottom");
+ }
+
+ @Override
+ public boolean hasTileEntity(int metadata)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){
+ TileEntity te = world.getTileEntity(x,y,z);
+ if(te instanceof EvaporatorTileEntity)
+ {
+ EvaporatorTileEntity bte = (EvaporatorTileEntity)te;
+ if (bte == null || entityPlayer.isSneaking()) {
+ return false;
+ }
+ else
+ {
+ return bte.getGui(entityPlayer);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Called when the block is placed in the world.
+ */
+ @Override
+ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack)
+ {
+ int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+ TileEntity t = world.getTileEntity(x, y, z);
+ if(t!=null && t instanceof EvaporatorTileEntity)
+ {
+ EvaporatorTileEntity te = (EvaporatorTileEntity)t;
+ if(player.isSneaking())
+ {
+ switch(var7)
+ {
+ case 0:
+ te.setFacing((short) 3);
+ break;
+ case 1:
+ te.setFacing((short) 4);
+ break;
+ case 2:
+ te.setFacing((short) 2);
+ break;
+ case 3:
+ te.setFacing((short) 5);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch(var7)
+ {
+ case 0:
+ te.setFacing((short) 2);
+ break;
+ case 1:
+ te.setFacing((short) 5);
+ break;
+ case 2:
+ te.setFacing((short) 3);
+ break;
+ case 3:
+ te.setFacing((short) 4);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
+ {
+ IIcon faceIcon=this.blockIcon;
+ int facing=3;
+ int mask[] = {
+ 0,1,2,3,4,5,
+ 1,0,3,2,4,5,
+ 2,3,0,1,4,5,
+ 2,3,1,0,4,5,
+ 2,3,5,4,0,1,
+ 2,3,4,5,1,0
+ };
+ TileEntity te = world.getTileEntity(x, y, z);
+ if(te!=null)
+ {
+ EvaporatorTileEntity tebh = (EvaporatorTileEntity) te;
+ facing=tebh.getFacing();
+ if(tebh.getActive())
+ {
+ faceIcon=this.textureFrontActive;
+ }
+ }
+
+ switch (mask[facing*6+side])
+ {
+ case 0:
+ return faceIcon;
+ case 1:
+ return this.textureSide;
+ case 2:
+ return this.textureBottom;
+ case 3:
+ return this.textureTop;
+ case 4:
+ return this.textureSide;
+ case 5:
+ return this.textureSide;
+ default:
+ return this.textureSide;
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta)
+ {
+ switch (side)
+ {
+ case 0:
+ return this.textureTop;
+ case 1:
+ return this.textureBottom;
+ case 2:
+ return this.textureSide;
+ case 3:
+ return this.blockIcon;
+ case 4:
+ return this.textureSide;
+ case 5:
+ return this.textureSide;
+ default:
+ return this.textureSide;
+ }
+ }
+
+ @Override
+ public void randomDisplayTick(World world, int x, int y, int z, Random random)
+ {
+ TileEntity te = world.getTileEntity(x, y, z);
+ if(te instanceof EvaporatorTileEntity)
+ {
+ EvaporatorTileEntity ete = (EvaporatorTileEntity) te;
+ if(ete.getActive())
+ {
+ world.spawnParticle("snowshovel", x+0.2D, y+1.2D, z+0.2D, 0D, 0.05D, 0D);
+ world.spawnParticle("flame", x+0.5D+ete.mX()*0.5D+(random.nextDouble()*0.4D-0.2D)*ete.mZ(), y+random.nextDouble()*0.25D, z+0.5D+ete.mZ()*0.5D+(random.nextDouble()*0.4D-0.2D)*ete.mX(), 0D, 0.01D, 0D);
+ }
+ }
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/EvaporatorContainer.java b/src/main/java/ihl/processing/chemistry/EvaporatorContainer.java new file mode 100644 index 0000000..cb83269 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/EvaporatorContainer.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry;
+
+import ic2.core.ContainerBase;
+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.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+public class EvaporatorContainer extends ContainerBase<EvaporatorTileEntity> {
+
+ protected EvaporatorTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastFuel = -1;
+ public short lastProgress = -1;
+ private final static int height=166;
+
+ public EvaporatorContainer(EntityPlayer entityPlayer, EvaporatorTileEntity tileEntity1){
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ 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.fuelSlot, 0, 8, 32));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fluidItemsSlot, 0, 44, 14));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 44, 32));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillItemsSlot, 0, 44, 50));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 117, 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.getFluidTank().getFluid()!=null && this.tileEntity.getFluidTank().getFluidAmount() != this.lastFluidAmount)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.getFluidTank().getFluid().getFluid().getID());
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getFluidTank().getFluidAmount());
+ }
+
+ if (this.tileEntity.fuel != this.lastFuel)
+ {
+ icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.fuel);
+ }
+
+ if (this.tileEntity.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 3, this.tileEntity.progress);
+ }
+ }
+
+ this.lastFluidAmount = this.tileEntity.getFluidTank().getFluidAmount();
+ this.lastFuel = this.tileEntity.fuel;
+ this.lastProgress = this.tileEntity.progress;
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value)
+ {
+ super.updateProgressBar(index, value);
+
+ switch (index)
+ {
+ case 0:
+ this.tileEntity.getFluidTank().setFluid(new FluidStack(FluidRegistry.getFluid(value), 1000));
+ break;
+ case 1:
+ this.tileEntity.getFluidTank().setFluid(new FluidStack(this.tileEntity.getFluidTank().getFluid().getFluid(), value));
+ break;
+ case 2:
+ this.tileEntity.fuel=value;
+ break;
+ case 3:
+ this.tileEntity.progress=(short) value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/EvaporatorGui.java b/src/main/java/ihl/processing/chemistry/EvaporatorGui.java new file mode 100644 index 0000000..05f7c31 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/EvaporatorGui.java @@ -0,0 +1,84 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.util.DrawUtil;
+import ic2.core.util.GuiTooltipHelper;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+@SideOnly(Side.CLIENT)
+public class EvaporatorGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUISolidFuelEvaporator.png");
+ private EvaporatorContainer container;
+ private String title = StatCollector.translateToLocal("ihl.gui.evaporator");
+
+
+ public EvaporatorGui (EvaporatorContainer container1) {
+ //the container is instanciated and passed to the superclass for handling
+ super(container1);
+ this.container=container1;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ int xOffset = (this.width - xSize) / 2;
+ int yOffset = (this.height - ySize) / 2;
+ fontRendererObj.drawString(title, 8, 70, 6171880);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(background);
+ int i1;
+ if (this.container.tileEntity.fuel > 0)
+ {
+ i1 = Math.min(this.container.tileEntity.gaugeFuelScaled(12),12);
+ this.drawTexturedModalRect(9, 16 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18);
+ this.drawTexturedModalRect(99, 34, 198, 0, i1 + 1, 13);
+ }
+
+ if (this.container.tileEntity.getTankAmount() > 0)
+ {
+ FluidStack fluidStack = this.container.tileEntity.getFluidTank().getFluid();
+ if(fluidStack!=null)
+ {
+ Fluid fluid = fluidStack.getFluid();
+ if(fluid!=null)
+ {
+
+ IIcon fluidIcon = fluid.getIcon();
+
+ if (fluidIcon != null)
+ {
+ this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
+ int liquidHeight = this.container.tileEntity.gaugeLiquidScaled(47);
+ DrawUtil.drawRepeated(fluidIcon, (82), 16 + 47 - liquidHeight, 12.0D, liquidHeight, this.zLevel);
+ this.mc.renderEngine.bindTexture(background);
+ }
+ }
+ String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getUnlocalizedName()) + ": " + fluidStack.amount + "mB";
+ GuiTooltipHelper.drawAreaTooltip(par1-90, par2-32, tooltip, xOffset-8, yOffset-15, xOffset+2, yOffset+30);
+ }
+ }
+ }
+
+ @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);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/EvaporatorTileEntity.java b/src/main/java/ihl/processing/chemistry/EvaporatorTileEntity.java new file mode 100644 index 0000000..279fa17 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/EvaporatorTileEntity.java @@ -0,0 +1,290 @@ +package ihl.processing.chemistry;
+
+import java.util.Arrays;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.IC2Items;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.block.TileEntityLiquidTankInventory;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlotConsumableFuel;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.IHLMod;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+public class EvaporatorTileEntity extends TileEntityLiquidTankInventory implements IHasGui
+{
+ public final IHLInvSlotOutput outputSlot;
+ public InvSlot fuelSlot;
+ public final InvSlotConsumableLiquidIHL fluidItemsSlot;
+ public final InvSlotConsumableLiquidIHL fillItemsSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+
+ public short progress = 0;
+ public short maxProgress = 450;
+ public int fuel = 0;
+ public int maxFuel = 0;
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("evaporator");
+
+ public EvaporatorTileEntity()
+ {
+ super(8);
+ this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1);
+ this.fuelSlot = new InvSlotConsumableFuel(this, "fuel", 1, 1, true);
+ this.fluidItemsSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", 2, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain);
+ this.fillItemsSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", 4, InvSlot.Access.I, 1, InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Fill);
+ this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 3, 1);
+ }
+
+ public static void init()
+ {
+ addRecipe(new FluidStack(FluidRegistry.getFluid("fluidrubbertreesap"),200), IC2Items.getItem("resin"));
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+
+ try
+ {
+ this.fuel = nbttagcompound.getInteger("fuel");
+ }
+ catch (Throwable var4)
+ {
+ this.fuel = nbttagcompound.getShort("fuel");
+ }
+
+ try
+ {
+ this.maxFuel = nbttagcompound.getInteger("maxFuel");
+ }
+ catch (Throwable var3)
+ {
+ this.maxFuel = nbttagcompound.getShort("maxFuel");
+ }
+
+ this.progress = nbttagcompound.getShort("progress");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setInteger("fuel", this.fuel);
+ nbttagcompound.setInteger("maxFuel", this.maxFuel);
+ nbttagcompound.setShort("progress", this.progress);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=(short)side && side!=0 && side!=1;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ if(this.outputSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.outputSlot.get()));
+ if(this.fuelSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.fuelSlot.get()));
+ if(this.emptyFluidItemsSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.emptyFluidItemsSlot.get()));
+ return new ItemStack(IHLMod.evaporatorBlock,1);
+ }
+
+ public int gaugeProgressScaled(int i)
+ {
+ return this.progress * i / maxProgress;
+ }
+
+ public int gaugeFuelScaled(int i)
+ {
+ if (this.maxFuel == 0)
+ {
+ this.maxFuel = this.fuel;
+
+ if (this.maxFuel == 0)
+ {
+ this.maxFuel = 160;
+ }
+ }
+
+ return this.fuel * i / this.maxFuel;
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ if (this.needsFluid())
+ {
+ IHLUtils.handleFluidSlotsBehaviour(fillItemsSlot, fluidItemsSlot, emptyFluidItemsSlot, fluidTank);
+ }
+ if (this.fuel <= 0 && this.canOperate() && this.fuelSlot instanceof InvSlotConsumableFuel)
+ {
+ this.fuel = this.maxFuel = ((InvSlotConsumableFuel) this.fuelSlot).consumeFuel();
+ }
+
+ if (this.isBurning() && this.canOperate())
+ {
+ ++this.progress;
+
+ if (this.progress >= maxProgress)
+ {
+ this.progress = 0;
+ this.operate();
+ }
+ }
+ else
+ {
+ this.progress = 0;
+ }
+
+ if (this.fuel > 0)
+ {
+ --this.fuel;
+ }
+
+ if (this.getActive() != this.isBurning())
+ {
+ this.setActive(this.isBurning());
+ }
+ }
+
+ public void operate()
+ {
+ UniversalRecipeOutput output = this.getOutput();
+ if(output!=null && !output.getItemOutputs().isEmpty())
+ {
+ this.outputSlot.add(this.getOutput().getItemOutputs().get(0).copy());
+ }
+ this.fluidTank.drain(recipeManager.getRecipeInput(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null).getFluidInputs().get(0).getAmount(), true);
+ }
+
+ public boolean isBurning()
+ {
+ return this.fuel > 0;
+ }
+
+ public boolean canOperate()
+ {
+ if (this.fluidTank.getFluid()==null)
+ {
+ return false;
+ }
+ else
+ {
+ UniversalRecipeOutput output = recipeManager.getOutputFor(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null);
+ return output == null ? false : (this.outputSlot.canAdd(output.getItemOutputs()) ? true : false);
+ }
+ }
+
+ /**
+ * Returns the name of the inventory
+ */
+ @Override
+ public String getInventoryName()
+ {
+ return "Solid fuel evaporator";
+ }
+
+ @Override
+ public ContainerBase<? extends EvaporatorTileEntity> getGuiContainer(EntityPlayer entityPlayer)
+ {
+ return new EvaporatorContainer(entityPlayer, this);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin)
+ {
+ return new EvaporatorGui(new EvaporatorContainer(entityPlayer, this));
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer entityPlayer) {}
+
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return false;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection arg0, Fluid fluid1) {
+ return true;
+ }
+
+ public boolean getGui(EntityPlayer player)
+ {
+ return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false;
+ }
+
+ public int mX()
+ {
+ switch(this.getFacing())
+ {
+ case 4:
+ return -1;
+ case 5:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ public int mZ()
+ {
+ switch(this.getFacing())
+ {
+ case 2:
+ return -1;
+ case 3:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ public static void addRecipe(FluidStack input, ItemStack output)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput((new FluidStack [] {input}),null), new UniversalRecipeOutput(null, (new ItemStack[] {output}),20));
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ if (this.fluidTank.getFluid()==null)
+ {
+ return null;
+ }
+ else
+ {
+ UniversalRecipeOutput output = recipeManager.getOutputFor(Arrays.asList(new FluidStack [] {this.fluidTank.getFluid()}),null);
+ return output == null ? null : (this.outputSlot.canAdd(output.getItemOutputs()) ? output : null);
+ }
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/ExtruderModel.java b/src/main/java/ihl/processing/chemistry/ExtruderModel.java new file mode 100644 index 0000000..4d4688a --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/ExtruderModel.java @@ -0,0 +1,100 @@ +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class ExtruderModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + IHLModelRenderer Extruder; + + public ExtruderModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.PipeN4", 0, 7); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 0, 0); + setTextureOffset("Belt2.Shape13", 0, 0); + setTextureOffset("Extruder.PipeN16", 0, 0); + setTextureOffset("Extruder.PipeN15", 24, 20); + setTextureOffset("Extruder.Shape8", 0, 0); + setTextureOffset("Extruder.PipeU17", 0, 0); + setTextureOffset("Extruder.PipeUC18", 0, 0); + setTextureOffset("Extruder.Shape14", 0, 0); + setTextureOffset("Extruder.PipeN14", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape16", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN4", -1F, -1F, 1F, 2, 2, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0.5F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + Extruder = new IHLModelRenderer(this, "Extruder"); + Extruder.setRotationPoint(0F, 16F, 0F); + setRotation(Extruder, 0F, 0F, 0F); + Extruder.mirror = true; + Extruder.addTube("PipeN16", -4.5F, 0.5F, -5F, 3, 3, 12, 0F,1F,ForgeDirection.NORTH); + Extruder.addTube("PipeN15", -5.5F, -0.5F, 0F, 5, 5, 7, 0.5F,1F,ForgeDirection.NORTH); + Extruder.addBox("Shape8", -5F, 4F, 6.9F, 4, 3, 1); + Extruder.addTube("PipeU17", -5.5F, -8F, -5F, 5, 8, 5, 0.8F,1F,ForgeDirection.UP); + Extruder.addTube("PipeUC18", -5.5F, 0F, -5F, 5, 2, 5, 0.8F,0.6F,ForgeDirection.UP); + Extruder.addBox("Shape14", -5F, 3F, -4.9F, 4, 4, 1); + Extruder.addTube("PipeN14", -5.5F, -0.5F, 7F, 5, 5, 1, 0.5F,1F,ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/chemistry/FluidizedBedReactorContainer.java b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorContainer.java new file mode 100644 index 0000000..ada1463 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorContainer.java @@ -0,0 +1,44 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class FluidizedBedReactorContainer extends BasicElectricMotorContainer<FluidizedBedReactorTileEntity> {
+
+ protected FluidizedBedReactorTileEntity tileEntity;
+ public int lastFluidsHash = -1;
+ private final static int height=166;
+ public List<FluidStack> fluidTankFluidList;
+
+ public FluidizedBedReactorContainer(EntityPlayer entityPlayer, FluidizedBedReactorTileEntity tileEntity1){
+ super(entityPlayer, tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList();
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 102, 51));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 102, 15));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 102, 33));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 41, 23));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 41, 41));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 76, 33));
+ }
+
+ @Override
+ public void detectAndSendChanges()
+ {
+ super.detectAndSendChanges();
+ if (fluidTankFluidList.hashCode() != this.lastFluidsHash)
+ {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ this.lastFluidsHash = fluidTankFluidList.hashCode();
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/FluidizedBedReactorGui.java b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorGui.java new file mode 100644 index 0000000..95ba8f0 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorGui.java @@ -0,0 +1,59 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class FluidizedBedReactorGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl",
+ "textures/gui/GUIFluidizedBedReactor.png");
+ private FluidizedBedReactorContainer container;
+ private int mixerFrame = 0;
+
+ public FluidizedBedReactorGui(FluidizedBedReactorContainer container1) {
+ // the container is instanciated and passed to the superclass for
+ // handling
+ super(container1);
+ this.container = container1;
+ }
+
+ @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) {
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12), 12);
+ this.drawTexturedModalRect(12, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0) {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(17), 17);
+ this.drawTexturedModalRect(58, 34, 198, 0, i1, 13);
+ if (mixerFrame++ > 3) {
+ mixerFrame = 0;
+ }
+ this.drawTexturedModalRect(126, 31, 244, 126 + 26 * mixerFrame, 12, 26);
+ }
+ if (this.container.tileEntity.getTankAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 126, 28, 138, 59,
+ zLevel, par1, par2, xOffset, yOffset);
+ }
+ }
+
+ @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);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java new file mode 100644 index 0000000..69dd4e1 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FluidizedBedReactorTileEntity.java @@ -0,0 +1,318 @@ +package ihl.processing.chemistry;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.ContainerBase;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.IHLMod;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.processing.metallurgy.BasicElectricMotorTileEntity;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+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;
+
+public class FluidizedBedReactorTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler
+{
+ private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("fluidizedbedreactor");
+ public final ApparatusProcessableInvSlot input;
+ public final IHLInvSlotOutput outputSlot;
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ private final IHLFluidTank fluidTank = new IHLFluidTank(8000);
+ public short temperature=20;
+
+ public FluidizedBedReactorTileEntity() {
+ super();
+ this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1);
+ 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);
+ this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 2, 64);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=side;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("fluidizedBedReactor");
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ 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 true;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "fluidizedBedReactor";
+ }
+
+ @Override
+ public int gaugeProgressScaled(int i)
+ {
+ return this.progress * i / operationLength;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new FluidizedBedReactorGui(new FluidizedBedReactorContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player)
+ {
+ this.fluidTank.sortFluidsByDensity();
+ return new FluidizedBedReactorContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {}
+
+ @Override
+ public boolean canOperate()
+ {
+ UniversalRecipeOutput output = getOutput();
+ if(output!=null && this.outputSlot.canAdd(getOutput().getItemOutputs()))
+ {
+ if(output.specialConditions)
+ {
+ return this.checkSpecialConditions();
+ }
+ else
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean checkSpecialConditions()
+ {
+ ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing());
+ TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ);
+ if(te instanceof CryogenicDistillerTileEntity)
+ {
+ CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te;
+ return cgte.getFacing()==this.getFacing() && cgte.canProcess();
+ }
+ return false;
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ return FluidizedBedReactorTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public List[] getInput()
+ {
+ for(int i=0;i<fluidTank.getNumberOfFluids();i++)
+ {
+ for(int i1=0;i1<fluidTank.getNumberOfFluids();i1++)
+ {
+ if(i!=i1)
+ {
+ List[] rInput = new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid(i),fluidTank.getFluid(i1)}), this.input.getItemStackList()};
+ if(FluidizedBedReactorTileEntity.recipeManager.getOutputFor(rInput)!=null)
+ {
+ return rInput;
+ }
+ }
+ }
+ }
+ return new List[] {Arrays.asList(new FluidStack[]{fluidTank.getLigthestFluid()}), this.input.getItemStackList()};
+ }
+
+ @Override
+ public void operate()
+ {
+ UniversalRecipeInput recipeInput = FluidizedBedReactorTileEntity.recipeManager.getRecipeInput(getInput());
+ UniversalRecipeOutput output1 = getOutput();
+ this.fluidTank.drain(recipeInput.getFluidInputs(), true);
+ for (int i = 0; i < recipeInput.getItemInputs().size(); i++) {
+ this.input.consume(recipeInput.getItemInputs().get(i));
+ if (recipeInput.getItemInputs().get(i).getAmount() == 0) {
+ for (int i1 = 0; i1 < this.input.size(); i1++) {
+ ItemStack stack = this.input.get(i1);
+ if (stack != null && recipeInput.getItemInputs().get(i).matches(stack)) {
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
+ }
+ stack.stackTagCompound.setInteger("catalyst_uses",
+ stack.stackTagCompound.getInteger("catalyst_uses") + 1);
+ if (stack.stackTagCompound.getInteger("catalyst_uses") > IHLMod.config.maxCatalystUses){
+ stack.stackTagCompound.setInteger("catalyst_uses", 0);
+ if(--stack.stackSize<=0)
+ this.input.put(i1, null);
+ }
+ }
+ }
+ }
+ }
+ if(output1.getFluidOutputs().size()>0)this.fluidTank.fill(output1.getFluidOutputs().get(0).copy(), true);
+ if(output1.getFluidOutputs().size()>1)this.fluidTank.fill(output1.getFluidOutputs().get(1).copy(), true);
+ if(!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0)!=null)this.outputSlot.add(output1.getItemOutputs());
+
+ }
+
+ @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 static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output)
+ {
+ recipeManager.addRecipe(input, output);
+ }
+
+ public int getNumberOfFluidsInTank()
+ {
+ return this.fluidTank.getNumberOfFluids();
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes()
+ {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1)
+ {
+ if(fluidStackOutput!=null)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new ItemStack[] {itemStackOutput1}),200));
+ }
+ else
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(null, (new ItemStack[] {itemStackOutput1}),200));
+ }
+ }
+
+ public IHLFluidTank getFluidTank()
+ {
+ return this.fluidTank;
+ }
+
+ public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackInput, FluidStack fluidStackOutput, RecipeOutputItemStack itemStackOutput1) {
+ if(fluidStackOutput!=null)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new RecipeOutputItemStack[] {itemStackOutput1}),200));
+ }
+ else
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1}), (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput(null, (new RecipeOutputItemStack[] {itemStackOutput1}),200));
+ }
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/FractionatorBottomModel.java b/src/main/java/ihl/processing/chemistry/FractionatorBottomModel.java new file mode 100644 index 0000000..c395af7 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FractionatorBottomModel.java @@ -0,0 +1,48 @@ +// Date: 05.04.2015 16:55:22 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class FractionatorBottomModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public FractionatorBottomModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Box03", 0, 0); + setTextureOffset("Base.Box04", 0, 0); + setTextureOffset("Base.Pipeup02", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.PipeUp05", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Box03", 2F, -7.1F, -8F, 6, 15, 16); + Base.addBox("Box04", -8F, 7F, -8F, 16, 1, 16); + Base.addTube("Pipeup02", -8F, -8F, -8F, 16, 1, 16, 0.8F, 1.0F, ForgeDirection.UP); + Base.addTube("WestPipe03", -7.5F, -1.5F, -1.5F, 3, 3, 3, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("WestPipe04", -8F, -2F, -2F, 1, 4, 4, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("PipeUp05", -7F, -7F, -7F, 14, 15, 14, 0.8F, 1.0F, ForgeDirection.UP); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/chemistry/FractionatorBottomTileEntity.java b/src/main/java/ihl/processing/chemistry/FractionatorBottomTileEntity.java new file mode 100644 index 0000000..3d9e95e --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FractionatorBottomTileEntity.java @@ -0,0 +1,352 @@ +package ihl.processing.chemistry;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import ic2.api.energy.tile.IHeatSource;
+import ic2.core.IC2;
+import ic2.core.block.TileEntityInventory;
+import ihl.recipes.IRecipeInputFluid;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+import ihl.worldgen.ores.IHLFluid;
+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;
+
+public class FractionatorBottomTileEntity extends TileEntityInventory implements IFluidHandler
+{
+ private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("fractionator");
+ private static float kF = 24000F;
+ private static float fluidC = 4F;
+ private static float H = 2256F;
+ private final IHLFluidTank waterTank = new IHLFluidTank(100);
+ private final IHLFluidTank fluidTank = new IHLFluidTank(8000);
+ private int amountOfGasCondensed=0;
+ private int amountOfFluidEvaporated=0;
+ private int systemHeat=0;
+ private static final int maxSystemHeat=10000;
+ private final List<FractionatorSectionTileEntity> listOfColumnSections = new ArrayList<FractionatorSectionTileEntity>();
+ private FractionatorCoverTileEntity columnCover;
+ private RefluxCondenserTileEntity refluxCondenser;
+ private IHeatSource heatSource;
+ private int fluxRecirculationProportion=10;
+
+ public FractionatorBottomTileEntity()
+ {
+ super();
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ this.waterTank.readFromNBT(nbttagcompound.getCompoundTag("waterTank"));
+ this.amountOfGasCondensed=nbttagcompound.getInteger("amountOfGasCondensed");
+ this.systemHeat=nbttagcompound.getInteger("systemHeat");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+
+ NBTTagCompound waterTankTag = new NBTTagCompound();
+ this.waterTank.writeToNBT(waterTankTag);
+ nbttagcompound.setTag("waterTank", waterTankTag);
+
+ nbttagcompound.setInteger("amountOfGasCondensed",this.amountOfGasCondensed);
+ nbttagcompound.setInteger("systemHeat",this.systemHeat);
+
+ }
+
+ public static void addRecipe(FluidStack fluidIn, FluidStack fluidOut1, FluidStack fluidOut2)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidIn}), null), new UniversalRecipeOutput((new FluidStack[] {fluidOut1,fluidOut2}),null,2));
+ }
+
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=(short)side && side!=0 && side!=1;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("fractionatorBottom");
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ if(!this.checkIntegrity())
+ {
+ return;
+ }
+ this.fluxRecirculationProportion=100-10000/(100+this.listOfColumnSections.size()*3);
+ ForgeDirection orientation = ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP);
+ if(systemHeat < maxSystemHeat && this.checkHeatSource(orientation))
+ {
+ systemHeat+=this.heatSource.requestHeat(orientation.getOpposite(), Integer.MAX_VALUE);
+ }
+ FluidStack fsCurrentInput = this.fluidTank.getFluid();
+ if(fsCurrentInput!=null && fsCurrentInput.amount>100 && systemHeat>0)
+ {
+ UniversalRecipeOutput rOutput = FractionatorBottomTileEntity.recipeManager.getOutputFor(this.fluidTank.getFluidList(),null);
+ UniversalRecipeInput rInput = FractionatorBottomTileEntity.recipeManager.getRecipeInput(this.fluidTank.getFluidList(),null);
+ if(rOutput!=null)
+ {
+ IRecipeInputFluid input = rInput.getFluidInputs().get(0);
+ int rInputAmount = input.getAmount();
+ FluidStack result1=rOutput.getFluidOutputs().get(0).copy();
+ FluidStack result2=rOutput.getFluidOutputs().get(1).copy();
+ //max heat per tick of electric heater is 100
+ int amountOfFluidToEvaporate = Math.min(fsCurrentInput.amount*result2.amount/rInputAmount,systemHeat/100);
+ systemHeat-=amountOfFluidToEvaporate*100;
+ amountOfFluidEvaporated+=amountOfFluidToEvaporate;
+ int amountOfVapours=amountOfFluidEvaporated*50;
+ FluidStack coolant = this.waterTank.getFluid();
+ if(coolant!=null && coolant.amount>0)
+ {
+ int amountOfGasToCondense = Math.min(coolant.amount*50, amountOfVapours);
+ amountOfGasCondensed += amountOfGasToCondense;
+ amountOfFluidEvaporated -= amountOfGasToCondense/50;
+ }
+ if(amountOfGasCondensed>10000)
+ {
+ int amountToProcess=amountOfGasCondensed*this.fluxRecirculationProportion/5000;//only 10% of condensate will be extracted.
+ int amount = rInputAmount * amountToProcess / result2.amount;
+ result1.amount = result1.amount* amountToProcess / result2.amount;
+ result2.amount = amountToProcess;
+ this.fluidTank.drain(input,amount, true);
+ this.fillVatResidueOutputApparatus(orientation.getOpposite(), result1, true);
+ this.fillCondensateOutputApparatus(ForgeDirection.UP, result2, true);
+ amountOfGasCondensed=0;
+ }
+ }
+ }
+ if(this.waterTank.getFluid()!=null)
+ {
+ FluidStack coolant = this.waterTank.drain(5, true);
+ this.fillHeatTransferAgentOutputApparatus(ForgeDirection.UP, coolant, true);
+ }
+ }
+
+
+ private boolean checkHeatSource(ForgeDirection orientation)
+ {
+ if(this.heatSource!=null)
+ {
+ return true;
+ }
+ else
+ {
+ TileEntity te = worldObj.getTileEntity(xCoord+orientation.offsetX, yCoord, zCoord+orientation.offsetZ);
+ if(te instanceof IHeatSource)
+ {
+ if(((IHeatSource)te).maxrequestHeatTick(orientation.getOpposite())>0)
+ {
+ this.heatSource=(IHeatSource)te;
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean checkIntegrity()
+ {
+ boolean allright=true;
+ if(!this.listOfColumnSections.isEmpty() &&
+ this.columnCover!=null &&
+ !this.columnCover.isInvalid() &&
+ this.refluxCondenser!=null &&
+ !this.refluxCondenser.isInvalid())
+ {
+ Iterator<FractionatorSectionTileEntity> sectionsIterator = this.listOfColumnSections.iterator();
+ while(sectionsIterator.hasNext())
+ {
+ FractionatorSectionTileEntity section = sectionsIterator.next();
+ if(section==null || section.isInvalid())
+ {
+ allright=false;
+ }
+ }
+ }
+ else
+ {
+ allright=false;
+ }
+ if(allright)
+ {
+ return true;
+ }
+ else
+ {
+ this.listOfColumnSections.clear();
+ this.columnCover=null;
+ this.refluxCondenser=null;
+ boolean checking = true;
+ int height=0;
+ while(checking)
+ {
+ height++;
+ TileEntity te = worldObj.getTileEntity(xCoord, yCoord+height, zCoord);
+ if(te instanceof FractionatorSectionTileEntity)
+ {
+ FractionatorSectionTileEntity section = (FractionatorSectionTileEntity)te;
+ section.columnBottom=this;
+ this.listOfColumnSections.add(section);
+ }
+ else if(te instanceof FractionatorCoverTileEntity)
+ {
+ if(this.listOfColumnSections.isEmpty())
+ {
+ return false;
+ }
+ FractionatorCoverTileEntity fcte = (FractionatorCoverTileEntity)te;
+ this.columnCover=fcte;
+ ForgeDirection orientation = ForgeDirection.getOrientation(fcte.getFacing()).getRotation(ForgeDirection.DOWN);
+ te = worldObj.getTileEntity(xCoord+orientation.offsetX, yCoord+height, zCoord+orientation.offsetZ);
+ if(te instanceof RefluxCondenserTileEntity)
+ {
+ if(((RefluxCondenserTileEntity)te).getFacing()==fcte.getFacing())
+ {
+ this.refluxCondenser=(RefluxCondenserTileEntity)te;
+ this.refluxCondenser.columnBottom=this;
+ return true;
+ }
+ }
+ }
+ else
+ {
+ checking=false;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String getInventoryName()
+ {
+ return "fractionator";
+ }
+
+ public void onGuiClosed(EntityPlayer entityPlayer) {}
+
+ public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill)
+ {
+ if(direction.equals(ForgeDirection.UP))
+ {
+ return waterTank.fill(fluidStack, doFill);
+ }
+ else
+ {
+ return fluidTank.fill(fluidStack, doFill);
+ }
+ }
+
+ private int fillCondensateOutputApparatus(ForgeDirection direction,FluidStack fluidStack, boolean doFill)
+ {
+ TileEntity te = worldObj.getTileEntity(this.refluxCondenser.xCoord,this.refluxCondenser.yCoord-1,this.refluxCondenser.zCoord);
+ if(te instanceof IFluidHandler)
+ {
+ return ((IFluidHandler)te).fill(direction, fluidStack, doFill);
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+
+ private int fillVatResidueOutputApparatus(ForgeDirection orientation, FluidStack fluidStack, boolean doFill) {
+ TileEntity te = worldObj.getTileEntity(xCoord+orientation.offsetX,yCoord, zCoord+orientation.offsetZ);
+ if(te instanceof IFluidHandler)
+ {
+ return ((IFluidHandler)te).fill(orientation, fluidStack, doFill);
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ private int fillHeatTransferAgentOutputApparatus(ForgeDirection direction,FluidStack fluidStack, boolean doFill)
+ {
+ ForgeDirection orientation = ForgeDirection.getOrientation(this.refluxCondenser.getFacing()).getOpposite();
+ TileEntity te = worldObj.getTileEntity(this.refluxCondenser.xCoord+orientation.offsetX,this.refluxCondenser.yCoord,this.refluxCondenser.zCoord+orientation.offsetZ);
+ if(te instanceof IFluidHandler)
+ {
+ return ((IFluidHandler)te).fill(orientation, fluidStack, doFill);
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ super.setFacing((short) Math.max(facing1, 2));
+ }
+
+ public FluidTankInfo[] getTankInfo(ForgeDirection arg0) {
+ return new FluidTankInfo[]{this.fluidTank.getInfo(), this.waterTank.getInfo()};
+ }
+
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
+ return this.fluidTank.drain(resource, doDrain);
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
+ return this.fluidTank.drain(maxDrain, doDrain);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection from, Fluid fluid) {
+ return true;
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection from, Fluid fluid) {
+ return true;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/FractionatorCoverModel.java b/src/main/java/ihl/processing/chemistry/FractionatorCoverModel.java new file mode 100644 index 0000000..451d73c --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FractionatorCoverModel.java @@ -0,0 +1,52 @@ +// Date: 05.04.2015 1:01:48 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class FractionatorCoverModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public FractionatorCoverModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeUp03", 0, 0); + setTextureOffset("Base.ConeUp14to10", 0, 0); + setTextureOffset("Base.PipeUp", 0, 0); + setTextureOffset("Base.KneeUPWEST", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.ConeUp10To3", 0, 0); + setTextureOffset("Base.WestPipe02", 0, 0); + setTextureOffset("Base.WestPipe01", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeUp03", -8F, 7F, -8F, 16, 1, 16, .8F, 1F, ForgeDirection.UP); + Base.addTube("ConeUp14to10", -7F, 2F, -7F, 14, 5, 14, .8F, 0.71F, ForgeDirection.DOWN); + Base.addTube("PipeUp", -1.5F, -2.5F, -1.5F, 3, 3, 3, .8F, 1F, ForgeDirection.UP); + Base.addKnee("KneeUPWEST", -3F, -8.5F, -3F, 6, 6, 6, .8F, 1F, ForgeDirection.DOWN, ForgeDirection.WEST); + Base.addTube("WestPipe03", -7F, -7F, -1.5F, 4, 3, 3, .8F, 1F, ForgeDirection.WEST); + Base.addTube("WestPipe04", -8F, -7.5F, -2F, 1, 4, 4, .6F, 1F, ForgeDirection.WEST); + Base.addTube("ConeUp10To3", -5F, 0F, -5F, 10, 2, 10, .8F, 0.3F, ForgeDirection.DOWN); + Base.addTube("WestPipe02", -8F, 3F, -2F, 1, 4, 4, .6F, 1F, ForgeDirection.WEST); + Base.addTube("WestPipe01", -7F, 3.5F, -1.5F, 3, 3, 3, .8F, 1F, ForgeDirection.WEST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/src/main/java/ihl/processing/chemistry/FractionatorCoverTileEntity.java b/src/main/java/ihl/processing/chemistry/FractionatorCoverTileEntity.java new file mode 100644 index 0000000..048f953 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FractionatorCoverTileEntity.java @@ -0,0 +1,104 @@ +package ihl.processing.chemistry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.api.network.INetworkDataProvider;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+
+public class FractionatorCoverTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{
+
+ private short facing=2;
+ private short lastFacing=2;
+ public FractionatorBottomTileEntity columnBottom;
+
+ public FractionatorCoverTileEntity()
+ {
+ super();
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = new ArrayList<String>();
+ fields.add("facing");
+ return fields;
+ }
+
+ @Override
+ public void updateEntity()
+ {
+ super.updateEntity();
+ if(lastFacing!=facing)
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ lastFacing=facing;
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=side;
+ }
+
+
+ @Override
+ public short getFacing() {
+ return this.facing;
+ }
+
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ facing=(short) Math.max(2,facing1);
+ if(IC2.platform.isSimulating())
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
+ return true;
+ }
+
+
+ @Override
+ public float getWrenchDropRate() {
+ return 1F;
+ }
+
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("fractionatorCover");
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ facing=nbttagcompound.getShort("facing");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setShort("facing", facing);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/FractionatorSectionModel.java b/src/main/java/ihl/processing/chemistry/FractionatorSectionModel.java new file mode 100644 index 0000000..2a20e7b --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FractionatorSectionModel.java @@ -0,0 +1,47 @@ +// Date: 05.04.2015 16:59:49 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + + +public class FractionatorSectionModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public FractionatorSectionModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeUp03", 0, 0); + setTextureOffset("Base.Pipeup02", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.PipeUp05", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeUp03", -8F, 7F, -8F, 16, 1, 16, 0.8F, 1.0F, ForgeDirection.UP); + Base.addTube("Pipeup02", -8F, -8F, -8F, 16, 1, 16, 0.8F, 1.0F, ForgeDirection.UP); + Base.addTube("WestPipe03", 4.5F, -1.5F, -1.5F, 3, 3, 3, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("WestPipe04", 7F, -2F, -2F, 1, 4, 4, 0.8F, 1.0F, ForgeDirection.WEST); + Base.addTube("PipeUp05", -7F, -7F, -7F, 14, 14, 14, 0.8F, 1.0F, ForgeDirection.UP); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + +} diff --git a/src/main/java/ihl/processing/chemistry/FractionatorSectionTileEntity.java b/src/main/java/ihl/processing/chemistry/FractionatorSectionTileEntity.java new file mode 100644 index 0000000..e71c453 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/FractionatorSectionTileEntity.java @@ -0,0 +1,148 @@ +package ihl.processing.chemistry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.api.network.INetworkDataProvider;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ihl.utils.IHLUtils;
+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;
+
+public class FractionatorSectionTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IFluidHandler{
+
+ private short facing=2;
+ private short lastFacing=2;
+ public FractionatorBottomTileEntity columnBottom;
+
+ public FractionatorSectionTileEntity()
+ {
+ super();
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = new ArrayList<String>();
+ fields.add("facing");
+ return fields;
+ }
+
+ @Override
+ public void updateEntity()
+ {
+ super.updateEntity();
+ if(lastFacing!=facing)
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ lastFacing=facing;
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=side;
+ }
+
+
+ @Override
+ public short getFacing() {
+ return this.facing;
+ }
+
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ facing=(short) Math.max(2,facing1);
+ if(IC2.platform.isSimulating())
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
+ return true;
+ }
+
+
+ @Override
+ public float getWrenchDropRate() {
+ return 1F;
+ }
+
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("fractionatorSection");
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ facing=nbttagcompound.getShort("facing");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setShort("facing", facing);
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return false;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection direction, Fluid arg1) {
+ return ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP).equals(direction);
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, int arg1, boolean arg2) {
+ return null;
+ }
+
+ @Override
+ public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) {
+ if(fluidStack!=null && fluidStack.getFluid()!=null && this.canFill(direction, fluidStack.getFluid()) && columnBottom!=null)
+ {
+ return columnBottom.fill(direction, fluidStack, doFill);
+ }
+ return 0;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection arg0)
+ {
+ if(columnBottom!=null)
+ return columnBottom.getTankInfo(arg0);
+ else
+ return new FluidTankInfo[] {new FluidTankInfo(null, 8000)};
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java new file mode 100644 index 0000000..b283a48 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpContainer.java @@ -0,0 +1,76 @@ +package ihl.processing.chemistry;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class GaedesMercuryRotaryPumpContainer extends ContainerBase<GaedesMercuryRotaryPumpTileEntity> {
+
+ protected GaedesMercuryRotaryPumpTileEntity tileEntity;
+ private final static int height=166;
+ public short lastEnergy = -1;
+ public short lastProgress = -1;
+
+ public GaedesMercuryRotaryPumpContainer(EntityPlayer entityPlayer, GaedesMercuryRotaryPumpTileEntity tileEntity1){
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ 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.dischargeSlot, 0, 61, 36));
+ }
+
+ @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.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+ if ((short) this.tileEntity.energy != this.lastEnergy)
+ {
+ icrafting.sendProgressBarUpdate(this, 2, (short) this.tileEntity.energy);
+ }
+ }
+
+ this.lastProgress = this.tileEntity.progress;
+ 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 2:
+ this.tileEntity.energy=value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java new file mode 100644 index 0000000..28c9edc --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpGui.java @@ -0,0 +1,60 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+public class GaedesMercuryRotaryPumpGui extends GuiContainer {
+
+ private GaedesMercuryRotaryPumpContainer container;
+ protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIGaedesMercuryRotaryPump.png");
+
+ public GaedesMercuryRotaryPumpGui(GaedesMercuryRotaryPumpContainer latheContainer) {
+ super(latheContainer);
+ container = latheContainer;
+ }
+
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(tex);
+ 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(51, 37 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27);
+ this.drawTexturedModalRect(17, 30, getFrameX(i1), getFrameY(i1),24,24);
+ }
+ }
+
+ @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(tex);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+
+ private int getFrameY(int number)
+ {
+ return (number % 10) * 24 + 14;
+ }
+
+ private int getFrameX(int number)
+ {
+ return (number / 10) * 24 + 176;
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java new file mode 100644 index 0000000..607d26a --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpModel.java @@ -0,0 +1,64 @@ +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +// Date: 17.03.2015 21:30:34 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +public class GaedesMercuryRotaryPumpModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public GaedesMercuryRotaryPumpModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeN1", 0, 0); + setTextureOffset("Base.PipeU3", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.PipeN2", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape7", 0, 0); + setTextureOffset("Base.PipeU4", 0, 0); + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.PipeW5", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape4", 0, 0); + setTextureOffset("Base.Shape8", 0, 0); + setTextureOffset("Base.PipeW8", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeN1", -5F, -5F, -6F, 10, 10, 10,0F,1F,ForgeDirection.NORTH); + Base.addTube("PipeU3", -0.5F, -2.5F, -8F, 1, 2, 1,0.1F,1F,ForgeDirection.UP); + Base.addBox("Shape3", -0.5F, -0.5F, -8F, 1, 1, 2); + Base.addTube("PipeN2", -3F, -2F, 4F, 6, 6, 4,0F,1F,ForgeDirection.NORTH); + Base.addBox("Shape5", -7F, 7F, -6F, 14, 1, 14); + Base.addBox("Shape6", 2F, 1F, -5F, 1, 6, 12); + Base.addBox("Shape7", -3F, 1F, -5F, 1, 6, 12); + Base.addTube("PipeU4", 0F, -8F, -5F, 1, 3, 1,0.1F,1F,ForgeDirection.UP); + Base.addBox("Shape1", 0F, -7F, -5F, 1, 1, 1); + Base.addTube("PipeW5", -1F, -7F, -5F, 8, 1, 1,0.1F,1F,ForgeDirection.WEST); + Base.addBox("Shape2", 4F, -8F, -5F, 1, 2, 1); + Base.addBox("Shape4", 4F, -8F, -1F, 1, 8, 1); + Base.addBox("Shape8", -5F, -8F, -1F, 1, 8, 1); + Base.addTube("PipeW8", -4F, -8F, -1F, 8, 1, 1,0.1F,1F,ForgeDirection.WEST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java new file mode 100644 index 0000000..186b606 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/GaedesMercuryRotaryPumpTileEntity.java @@ -0,0 +1,83 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.ContainerBase;
+import ihl.interfaces.IWorkspaceElement;
+import ihl.processing.metallurgy.BasicElectricMotorTileEntity;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+
+public class GaedesMercuryRotaryPumpTileEntity extends BasicElectricMotorTileEntity implements IWorkspaceElement{
+
+ public boolean ready=false;
+
+ public GaedesMercuryRotaryPumpTileEntity()
+ {
+ }
+
+ @Override
+ public void operate()
+ {
+ ready=true;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
+ {
+ return IHLUtils.getThisModItemStack("gaedesMercuryRotaryPump");
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public List[] getInput()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean canOperate()
+ {
+ return !ready;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new GaedesMercuryRotaryPumpGui(new GaedesMercuryRotaryPumpContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new GaedesMercuryRotaryPumpContainer(player, this);
+ }
+
+ @Override
+ public boolean canBeUsed()
+ {
+ return ready;
+ }
+
+ @Override
+ public void use()
+ {
+ ready=false;
+ }
+
+ @Override
+ public boolean getIsInvalid()
+ {
+ return this.isInvalid();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/LabElectrolyzerContainer.java b/src/main/java/ihl/processing/chemistry/LabElectrolyzerContainer.java new file mode 100644 index 0000000..1be5e01 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LabElectrolyzerContainer.java @@ -0,0 +1,73 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class LabElectrolyzerContainer extends BasicElectricMotorContainer<LabElectrolyzerTileEntity> {
+
+ protected LabElectrolyzerTileEntity tileEntity;
+ public short lastProgress = -1;
+ public short lastTemperature = -1;
+ public short lastEnergy = -1;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public int lastFluidAmount2 = -1;
+ public int lastNumberOfFluids2 = -1;
+ public int lastFluidAmount3 = -1;
+ public int lastNumberOfFluids3 = -1;
+ public List<FluidStack> fluidTankFluidList;
+ public List<FluidStack> fluidTankFluidList2;
+ public List<FluidStack> fluidTankFluidList3;
+
+ public LabElectrolyzerContainer(EntityPlayer entityPlayer, LabElectrolyzerTileEntity tileEntity1) {
+ super(entityPlayer, tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList = this.tileEntity.getFluidTank().getFluidList();
+ fluidTankFluidList2 = this.tileEntity.fluidTankAnodeOutput.getFluidList();
+ fluidTankFluidList3 = this.tileEntity.fluidTankCathodeOutput.getFluidList();
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 63, 47));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlotAnodeOutput, 0, 109, 47));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlotCathodeOutput, 0, 29, 47));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 63, 11));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 29, 11));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 1, 63, 29));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 2, 109, 11));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 63, 65));
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ if (this.tileEntity.getTankAmount() != this.lastFluidAmount
+ || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids) {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ }
+
+ if (this.tileEntity.fluidTankAnodeOutput.getFluidAmount() != this.lastFluidAmount2
+ || this.tileEntity.fluidTankAnodeOutput.getNumberOfFluids() != this.lastNumberOfFluids2) {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList2");
+ }
+
+ if (this.tileEntity.fluidTankCathodeOutput.getFluidAmount() != this.lastFluidAmount3
+ || this.tileEntity.fluidTankCathodeOutput.getNumberOfFluids() != this.lastNumberOfFluids3) {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList3");
+ }
+
+ this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank();
+ this.lastFluidAmount = this.tileEntity.getTankAmount();
+ this.lastNumberOfFluids2 = this.tileEntity.fluidTankAnodeOutput.getNumberOfFluids();
+ this.lastFluidAmount2 = this.tileEntity.fluidTankAnodeOutput.getFluidAmount();
+ this.lastNumberOfFluids3 = this.tileEntity.fluidTankCathodeOutput.getNumberOfFluids();
+ this.lastFluidAmount3 = this.tileEntity.fluidTankCathodeOutput.getFluidAmount();
+
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/LabElectrolyzerGui.java b/src/main/java/ihl/processing/chemistry/LabElectrolyzerGui.java new file mode 100644 index 0000000..3eb14a3 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LabElectrolyzerGui.java @@ -0,0 +1,74 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class LabElectrolyzerGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl",
+ "textures/gui/GUILabElectrolyzer.png");
+ private LabElectrolyzerContainer container;
+
+ public LabElectrolyzerGui(LabElectrolyzerContainer container1) {
+ // the container is instanciated and passed to the superclass for
+ // handling
+ super(container1);
+ this.container = container1;
+ }
+
+ @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, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0) {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27), 27);
+ this.drawTexturedModalRect(81, 31, getFrameX(i1), getFrameY(i1), 24, 24);
+ }
+ if (this.container.tileEntity.getTankAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 83, 15, 104, 81, zLevel,
+ par1, par2, xOffset, yOffset);
+ }
+ if (this.container.tileEntity.fluidTankCathodeOutput.getFluidAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankCathodeOutput, 48, 24, 59, 81,
+ zLevel, par1, par2, xOffset, yOffset);
+ }
+ if (this.container.tileEntity.fluidTankAnodeOutput.getFluidAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.fluidTankAnodeOutput, 128, 24, 139, 81,
+ zLevel, par1, par2, xOffset, yOffset);
+ }
+ }
+
+ @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);
+ }
+
+ private int getFrameY(int number) {
+ return (number % 10) * 24 + 14;
+ }
+
+ private int getFrameX(int number) {
+ return (number / 10) * 24 + 176;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/LabElectrolyzerTileEntity.java b/src/main/java/ihl/processing/chemistry/LabElectrolyzerTileEntity.java new file mode 100644 index 0000000..19348b6 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LabElectrolyzerTileEntity.java @@ -0,0 +1,272 @@ +package ihl.processing.chemistry;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+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.IHLInvSlotOutput;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.processing.metallurgy.BasicElectricMotorTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+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;
+
+public class LabElectrolyzerTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler {
+ private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("labelectrolyzer");
+ public final IHLInvSlotOutput outputSlot;
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlotAnodeOutput;
+ public final InvSlotConsumableLiquidIHL fillInputSlotCathodeOutput;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ private final IHLFluidTank fluidTank = new IHLFluidTank(2000);
+ public final IHLFluidTank fluidTankAnodeOutput = new IHLFluidTank(8000);
+ public final IHLFluidTank fluidTankCathodeOutput = new IHLFluidTank(8000);
+ public short temperature = 20;
+
+ public LabElectrolyzerTileEntity() {
+ super();
+ this.energyConsume *= 10;
+ this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2);
+ 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.fillInputSlotAnodeOutput = new InvSlotConsumableLiquidIHL(this, "fillInputAnodeOutput", -1,
+ InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ this.fillInputSlotCathodeOutput = new InvSlotConsumableLiquidIHL(this, "fillInputCathodeOutput", -1,
+ InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 3);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ this.fluidTankAnodeOutput.readFromNBT(nbttagcompound.getCompoundTag("fluidTankAnodeOutput"));
+ this.fluidTankCathodeOutput.readFromNBT(nbttagcompound.getCompoundTag("fluidTankCathodeOutput"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+
+ NBTTagCompound fluidTankAnodeTag = new NBTTagCompound();
+ this.fluidTankAnodeOutput.writeToNBT(fluidTankAnodeTag);
+ nbttagcompound.setTag("fluidTankAnodeOutput", fluidTankAnodeTag);
+
+ NBTTagCompound fluidTankCathodeTag = new NBTTagCompound();
+ this.fluidTankCathodeOutput.writeToNBT(fluidTankCathodeTag);
+ nbttagcompound.setTag("fluidTankCathodeOutput", fluidTankCathodeTag);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing() != side;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("labElectrolyzer");
+ }
+
+ @Override
+ public boolean enableUpdateEntity() {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntityServer() {
+ super.updateEntityServer();
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank);
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlotAnodeOutput, null, emptyFluidItemsSlot, fluidTankAnodeOutput);
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlotCathodeOutput, null, emptyFluidItemsSlot,
+ fluidTankCathodeOutput);
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection direction, int amount, boolean doDrain) {
+ if (this.canDrain(direction, null)) {
+ if (direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP))) {
+ return this.fluidTankAnodeOutput.drain(amount, doDrain);
+ }
+ if (direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.DOWN))) {
+ return this.fluidTankCathodeOutput.drain(amount, doDrain);
+ }
+ return this.fluidTank.drain(amount, doDrain);
+ }
+ return null;
+ }
+
+ // 1.7.10 API
+ @Override
+ public boolean canDrain(ForgeDirection direction, Fluid arg1) {
+ return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP))
+ || direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.DOWN))
+ || direction.equals(ForgeDirection.DOWN);
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection direction, Fluid arg1) {
+ return direction.equals(ForgeDirection.getOrientation(this.getFacing()).getOpposite());
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "labElectrolizer";
+ }
+
+ @Override
+ public int gaugeProgressScaled(int i) {
+ return this.progress * i / operationLength;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new LabElectrolyzerGui(new LabElectrolyzerContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ this.fluidTank.sortFluidsByDensity();
+ return new LabElectrolyzerContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {
+ }
+
+ @Override
+ public boolean canOperate() {
+ UniversalRecipeOutput output = getOutput();
+ if (output != null) {
+ if (getOutput().getItemOutputs() != null && !getOutput().getItemOutputs().isEmpty()
+ && getOutput().getItemOutputs().get(0) != null) {
+ return this.outputSlot.canAdd(getOutput().getItemOutputs());
+ } else {
+ return this.fluidTankAnodeOutput.getFluidAmount() < this.fluidTankAnodeOutput.getCapacity()
+ && this.fluidTankAnodeOutput.getFluidAmount() < this.fluidTankCathodeOutput.getCapacity();
+ }
+ }
+ return false;
+ }
+
+ public UniversalRecipeOutput getOutput() {
+ return LabElectrolyzerTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public List[] getInput() {
+ return new List[] { Arrays.asList(new FluidStack[] { fluidTank.getFluid() }), null };
+ }
+
+ @Override
+ public void operate() {
+ UniversalRecipeInput recipeInput = LabElectrolyzerTileEntity.recipeManager.getRecipeInput(getInput());
+ UniversalRecipeOutput output1 = getOutput();
+ this.fluidTank.drain(recipeInput.getFluidInputs().get(0), true);
+ if (output1.getFluidOutputs().size() > 0)
+ this.fluidTankAnodeOutput.fill(output1.getFluidOutputs().get(0).copy(), true);
+ if (output1.getFluidOutputs().size() > 1)
+ this.fluidTankCathodeOutput.fill(output1.getFluidOutputs().get(1).copy(), true);
+ if (!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0) != null)
+ this.outputSlot.add(output1.getItemOutputs());
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection direction, FluidStack fluidStack, boolean doDrain) {
+ if (this.fluidTankAnodeOutput.getFluid().containsFluid(fluidStack)) {
+ return this.fluidTankAnodeOutput.drain(fluidStack.amount, doDrain);
+ } else if (this.fluidTankCathodeOutput.getFluid().containsFluid(fluidStack)) {
+ return this.fluidTankCathodeOutput.drain(fluidStack.amount, doDrain);
+ }
+ return null;
+ }
+
+ @Override
+ public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
+ return this.fluidTank.fill(arg1, arg2);
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection direction) {
+ if (direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.UP))) {
+ return new FluidTankInfo[] { this.fluidTankAnodeOutput.getInfo() };
+ }
+ if (direction.equals(ForgeDirection.getOrientation(this.getFacing()).getRotation(ForgeDirection.DOWN))) {
+ return new FluidTankInfo[] { this.fluidTankCathodeOutput.getInfo() };
+ }
+ 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 static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) {
+ recipeManager.addRecipe(input, output);
+ }
+
+ public int getNumberOfFluidsInTank() {
+ return this.fluidTank.getNumberOfFluids();
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(FluidStack fluidStackInput1, FluidStack fluidStackOutputAnode,
+ FluidStack fluidStackOutputCathode, ItemStack itemStackOutput1) {
+ if (itemStackOutput1 != null) {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] { fluidStackInput1 }), null),
+ new UniversalRecipeOutput((new FluidStack[] { fluidStackOutputAnode, fluidStackOutputCathode }),
+ (new ItemStack[] { itemStackOutput1 }), 200));
+ } else {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] { fluidStackInput1 }), null),
+ new UniversalRecipeOutput((new FluidStack[] { fluidStackOutputAnode, fluidStackOutputCathode }),
+ null, 200));
+ }
+ }
+
+ public IHLFluidTank getFluidTank() {
+ return this.fluidTank;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/LeadOvenContainer.java b/src/main/java/ihl/processing/chemistry/LeadOvenContainer.java new file mode 100644 index 0000000..2f0ff8a --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LeadOvenContainer.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 LeadOvenContainer extends ContainerBase<LeadOvenTileEntity> {
+
+ protected LeadOvenTileEntity tileEntity;
+ public int lastInputFluidAmount = -1;
+ public int lastOutputFluidAmount = -1;
+ public int lastFuel = -1;
+ public short lastProgress = -1;
+ private final static int height = 166;
+ public List<FluidStack> inputTankFluidList;
+ public List<FluidStack> outputTankFluidList;
+
+ public LeadOvenContainer(EntityPlayer entityPlayer, LeadOvenTileEntity tileEntity1) {
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ inputTankFluidList = this.tileEntity.inputTank.getFluidList();
+ outputTankFluidList = this.tileEntity.outputTank.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.fuelSlot, 0, 56, 53));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputSlot, 0, 47, 17));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputSlot, 1, 65, 17));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 112, 35));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 9, 53));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 9, 17));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 9, 35));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot2, 0, 150, 53));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot2, 0, 150, 17));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 1, 150, 35));
+ }
+
+ @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.inputTank.getFluidAmount() != this.lastInputFluidAmount) {
+ IC2.network.get().sendContainerField(this, "inputTankFluidList");
+ }
+ if (this.tileEntity.outputTank.getFluidAmount() != this.lastOutputFluidAmount) {
+ IC2.network.get().sendContainerField(this, "outputTankFluidList");
+ }
+
+ if (this.tileEntity.fuel != this.lastFuel) {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.fuel);
+ }
+
+ if (this.tileEntity.progress != this.lastProgress) {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.progress);
+ }
+ }
+ this.lastFuel = this.tileEntity.fuel;
+ this.lastProgress = this.tileEntity.progress;
+ this.lastInputFluidAmount = this.tileEntity.inputTank.getFluidAmount();
+ this.lastOutputFluidAmount = this.tileEntity.outputTank.getFluidAmount();
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value) {
+ super.updateProgressBar(index, value);
+
+ switch (index) {
+ case 0:
+ this.tileEntity.fuel = value;
+ break;
+ case 1:
+ this.tileEntity.progress = (short) value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/LeadOvenGui.java b/src/main/java/ihl/processing/chemistry/LeadOvenGui.java new file mode 100644 index 0000000..72fb107 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LeadOvenGui.java @@ -0,0 +1,55 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class LeadOvenGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUILeadOven.png");
+ private LeadOvenContainer container;
+
+ public LeadOvenGui(LeadOvenContainer container1) {
+ // the container is instanciated and passed to the superclass for
+ // handling
+ super(container1);
+ this.container = container1;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ 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;
+ if (this.container.tileEntity.inputTank.getFluidAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.inputTank, 30, 19, 42, 66, zLevel,
+ par1, par2, x, y);
+ }
+ if (this.container.tileEntity.outputTank.getFluidAmount() > 0) {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.outputTank, 133, 19, 145, 66, zLevel,
+ par1, par2, x, y);
+ }
+ }
+
+ @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);
+ int i1;
+ if (this.container.tileEntity.fuel > 0) {
+ i1 = this.container.tileEntity.gaugeFuelScaled(12);
+ this.drawTexturedModalRect(x + 56, y + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
+ }
+ i1 = this.container.tileEntity.gaugeProgressScaled(24);
+ this.drawTexturedModalRect(x + 79, y + 34, 176, 14, i1 + 1, 16);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/LeadOvenTileEntity.java b/src/main/java/ihl/processing/chemistry/LeadOvenTileEntity.java new file mode 100644 index 0000000..95636ad --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LeadOvenTileEntity.java @@ -0,0 +1,286 @@ +package ihl.processing.chemistry;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotConsumableFuel;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+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;
+
+public class LeadOvenTileEntity extends TileEntityInventory implements IHasGui, IFluidHandler {
+ public final InvSlotConsumableFuel fuelSlot;
+ public final ApparatusProcessableInvSlot inputSlot;
+ public final IHLInvSlotOutput outputSlot;
+ public final IHLFluidTank inputTank = new IHLFluidTank(1000);
+ public final IHLFluidTank outputTank = new IHLFluidTank(1000);
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ public final InvSlotConsumableLiquidIHL drainInputSlot2;
+ public final InvSlotConsumableLiquidIHL fillInputSlot2;
+ public short progress = 0;
+ public final short maxProgress = 160;
+ public int fuel = 0;
+ public int maxFuel = 0;
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("chemicaloven");
+
+ public LeadOvenTileEntity() {
+ super();
+ this.fuelSlot = new InvSlotConsumableFuel(this, "fuel", 1, 1, true);
+ this.inputSlot = new ApparatusProcessableInvSlot(this, "input", 2, Access.IO, 2, 64);
+ this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1);
+ 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.drainInputSlot2 = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1,
+ InvSlot.InvSide.TOP, InvSlotConsumableLiquid.OpType.Drain);
+ this.fillInputSlot2 = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1,
+ InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 2);
+ }
+
+ public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) {
+ recipeManager.addRecipe(input, output);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ super.readFromNBT(nbttagcompound);
+ this.fuel = nbttagcompound.getInteger("fuel");
+ this.maxFuel = nbttagcompound.getInteger("maxFuel");
+ this.progress = nbttagcompound.getShort("progress");
+ this.inputTank.readFromNBT(nbttagcompound.getCompoundTag("inputTank"));
+ this.outputTank.readFromNBT(nbttagcompound.getCompoundTag("outputTank"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setInteger("fuel", this.fuel);
+ nbttagcompound.setInteger("maxFuel", this.maxFuel);
+ nbttagcompound.setShort("progress", this.progress);
+ NBTTagCompound inputTankTag = new NBTTagCompound();
+ this.inputTank.writeToNBT(inputTankTag);
+ nbttagcompound.setTag("inputTank", inputTankTag);
+ NBTTagCompound outputTankTag = new NBTTagCompound();
+ this.outputTank.writeToNBT(outputTankTag);
+ nbttagcompound.setTag("outputTank", outputTankTag);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing() != (short) side && side != 0 && side != 1;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("leadOven");
+ }
+
+ public int gaugeProgressScaled(int i) {
+ return this.progress * i / maxProgress;
+ }
+
+ public int gaugeFuelScaled(int i) {
+ if (this.maxFuel == 0) {
+ this.maxFuel = this.fuel;
+
+ if (this.maxFuel == 0) {
+ this.maxFuel = 160;
+ }
+ }
+
+ return this.fuel * i / this.maxFuel;
+ }
+
+ public boolean enableUpdateEntity() {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntityServer() {
+ super.updateEntityServer();
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, inputTank);
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot2, drainInputSlot2, emptyFluidItemsSlot, outputTank);
+ if (this.fuel <= 0 && this.canOperate()) {
+ this.fuel = this.maxFuel = this.fuelSlot.consumeFuel();
+ }
+
+ if (this.isBurning() && this.canOperate()) {
+ ++this.progress;
+
+ if (this.progress >= maxProgress) {
+ this.progress = 0;
+ this.operate();
+ }
+ } else {
+ this.progress = 0;
+ }
+
+ if (this.fuel > 0) {
+ --this.fuel;
+ }
+
+ if (this.getActive() != this.isBurning()) {
+ this.setActive(this.isBurning());
+ }
+ }
+
+ public boolean isBurning() {
+ return this.fuel > 0;
+ }
+
+ public boolean canOperate() {
+ return this.getOutput() != null;
+ }
+
+ /**
+ * Returns the name of the inventory
+ */
+ @Override
+ public String getInventoryName() {
+ return "goldOven";
+ }
+
+ @Override
+ public ContainerBase<LeadOvenTileEntity> getGuiContainer(EntityPlayer entityPlayer) {
+ return new LeadOvenContainer(entityPlayer, this);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) {
+ return new LeadOvenGui(new LeadOvenContainer(entityPlayer, this));
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer entityPlayer) {
+ }
+
+ public UniversalRecipeOutput getOutput() {
+ return LeadOvenTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @SuppressWarnings("rawtypes")
+ public List[] getInput() {
+ if (this.inputSlot.get(1) != null) {
+ return new List[] { this.inputTank.getFluidList(),
+ Arrays.asList(new ItemStack[] { this.inputSlot.get(0), this.inputSlot.get(1) }) };
+ }
+ return new List[] { this.inputTank.getFluidList(), Arrays.asList(new ItemStack[] { this.inputSlot.get() }) };
+ }
+
+ public void operate() {
+ UniversalRecipeInput rinput = LeadOvenTileEntity.recipeManager.getRecipeInput(getInput());
+ List<IRecipeInput> rinputItems = rinput.getItemInputs();
+ UniversalRecipeOutput routput = LeadOvenTileEntity.recipeManager.getOutputFor(getInput());
+ List<FluidStack> output2 = routput.getFluidOutputs();
+ if (!output2.isEmpty()) {
+ this.outputTank.fill(output2.get(0), true);
+ }
+ this.inputTank.drain(rinput.getFluidInputs(), true);
+ List<RecipeOutputItemStack> itemOutputs = routput.getItemOutputs();
+ if (itemOutputs != null && !itemOutputs.isEmpty()) {
+ this.outputSlot.add(itemOutputs);
+ }
+ for (int i = 0; i < rinputItems.size(); i++) {
+ this.inputSlot.consume(rinputItems.get(i));
+ }
+
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int amount, boolean doDrain) {
+ switch (from) {
+ case UP:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case NORTH:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case SOUTH:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case WEST:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case EAST:
+ return this.outputTank.drainLightest(amount, doDrain);
+ case DOWN:
+ return this.outputTank.drain(amount, doDrain);
+ default:
+ return this.outputTank.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()).getOpposite());
+ }
+
+ public static void addRecipe(UniversalRecipeInput input, FluidStack fluidStackWithSize) {
+ recipeManager.addRecipe(input, new UniversalRecipeOutput((new FluidStack[] { fluidStackWithSize }), null, 20));
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(IRecipeInput recipeInputOreDict, FluidStack fluidStackOutput, ItemStack output) {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] { recipeInputOreDict })),
+ new UniversalRecipeOutput((new FluidStack[] { fluidStackOutput }), (new ItemStack[] { output }), 20));
+ }
+
+ public static void addRecipe(IRecipeInput input, ItemStack output) {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] { input })),
+ new UniversalRecipeOutput(null, (new ItemStack[] { output }), 20));
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) {
+ if (outputTank.getFluid() != null && outputTank.getFluid().containsFluid(fluidStack)) {
+ return this.outputTank.drain(fluidStack, doDrain);
+ }
+ return null;
+ }
+
+ @Override
+ public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
+ return this.inputTank.fill(arg1, arg2);
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection arg0) {
+ return new FluidTankInfo[] { this.inputTank.getInfo() };
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/LoomContainer.java b/src/main/java/ihl/processing/chemistry/LoomContainer.java new file mode 100644 index 0000000..2d480ef --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LoomContainer.java @@ -0,0 +1,66 @@ +package ihl.processing.chemistry;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class LoomContainer extends ContainerBase<LoomTileEntity> {
+
+ public LoomTileEntity tileEntity;
+ public int lastProgress = -1;
+ private final static int height=166;
+
+ public LoomContainer(EntityPlayer entityPlayer,
+ LoomTileEntity lathePart1TileEntity) {
+ super(lathePart1TileEntity);
+ tileEntity=lathePart1TileEntity;
+ 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(lathePart1TileEntity.input, 0, 8, 44));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.output, 0, 127, 44));
+ }
+
+ @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.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+ }
+ this.lastProgress = this.tileEntity.progress;
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value)
+ {
+ super.updateProgressBar(index, value);
+
+ switch (index)
+ {
+ case 0:
+ this.tileEntity.progress=(short) value;
+ break;
+
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/LoomGui.java b/src/main/java/ihl/processing/chemistry/LoomGui.java new file mode 100644 index 0000000..4964687 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LoomGui.java @@ -0,0 +1,60 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import ic2.core.IC2;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+public class LoomGui extends GuiContainer {
+
+ private LoomContainer container;
+ protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUILoom.png");
+
+ public LoomGui(LoomContainer latheContainer) {
+ super(latheContainer);
+ container = latheContainer;
+ }
+
+
+ @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(tex);
+ int i1;
+ if (this.container.tileEntity.progress > 0)
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.99F);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(38),38);
+ this.drawTexturedModalRect(68, 30, 176, 0, i1 + 1, 10);
+ }
+ IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.coiler.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(tex);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+
+ @Override
+ public void onGuiClosed()
+ {
+ super.onGuiClosed();
+ this.container.tileEntity.isGuiScreenOpened=false;
+ IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 0);
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/LoomModel.java b/src/main/java/ihl/processing/chemistry/LoomModel.java new file mode 100644 index 0000000..31c2724 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LoomModel.java @@ -0,0 +1,66 @@ +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class LoomModel extends ModelBase +{ + //fields + IHLModelRenderer RotatePart; + IHLModelRenderer Piece1; + + public LoomModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("RotatePart.Shape1", 0, 14); + setTextureOffset("RotatePart.Pipe2", 0, 17); + setTextureOffset("RotatePart.Shape4", 3, 14); + setTextureOffset("RotatePart.Shape3", 0, 26); + setTextureOffset("RotatePart.Pipe5", 16, 20); + setTextureOffset("RotatePart.Pipe6", 0, 18); + setTextureOffset("RotatePart.Pipe11", 13, 22); + setTextureOffset("RotatePart.Pipe12", 13, 22); + setTextureOffset("RotatePart.Pipe13", 13, 22); + setTextureOffset("RotatePart.Pipe14", 13, 22); + setTextureOffset("RotatePart.Pipe15", 13, 22); + setTextureOffset("Piece1.Shape7", 0, 17); + setTextureOffset("Piece1.Shape8", 0, 17); + setTextureOffset("Piece1.PipeW9", 0, 18); + setTextureOffset("Piece1.PipeW10", 0, 20); + setTextureOffset("Piece1.Shape2", 0, 0); + + RotatePart = new IHLModelRenderer(this, "RotatePart"); + RotatePart.setRotationPoint(0F, 23F, -6F); + setRotation(RotatePart, 0.4F, 0F, 0F); + RotatePart.mirror = true; + RotatePart.addBox("Shape1", 7F, -1F, -1F, 1, 2, 16,false); + RotatePart.addTube("Pipe2", -7.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addBox("Shape4", -8F, -1F, -1F, 1, 2, 16,false); + RotatePart.addBox("Shape3", -7F, -1F, -1F, 14, 2, 2,false); + RotatePart.addTube("Pipe5", -5.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe6", -3.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe11", -1.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe12", 0.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe13", 2.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe14", 4.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + RotatePart.addTube("Pipe15", 6.5F, -3F, 0F, 1, 2, 1, 0F,1F,ForgeDirection.UP); + Piece1 = new IHLModelRenderer(this, "Piece1"); + Piece1.setRotationPoint(0F, 16F, 0F); + setRotation(Piece1, 0F, 0F, 0F); + Piece1.mirror = true; + Piece1.addBox("Shape7", 6F, -4F, 6F, 1, 12, 2,false); + Piece1.addBox("Shape8", -7F, -4F, 6F, 1, 12, 2,false); + Piece1.addTube("PipeW9", -6F, 7F, 7F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addTube("PipeW10", -6F, -4F, 6F, 12, 1, 1, 0F,1F,ForgeDirection.EAST); + Piece1.addBox("Shape2", 0F, 7F, 0F, 4, 1, 1,false); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } +} diff --git a/src/main/java/ihl/processing/chemistry/LoomTileEntity.java b/src/main/java/ihl/processing/chemistry/LoomTileEntity.java new file mode 100644 index 0000000..8432a2d --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/LoomTileEntity.java @@ -0,0 +1,172 @@ +package ihl.processing.chemistry;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.network.INetworkClientTileEntityEventListener;
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot.Access;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.recipes.RecipeInputWire;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+
+public class LoomTileEntity extends TileEntityInventory implements IHasGui, INetworkClientTileEntityEventListener
+{
+ protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("loom");
+ public short progress;
+ protected short operationLength=200;
+ public final ApparatusProcessableInvSlot input;
+ public final IHLInvSlotOutput output;
+ boolean isGuiScreenOpened=false;
+
+ public LoomTileEntity()
+ {
+ super();
+ input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, 1, 64);
+ output = new IHLInvSlotOutput(this, "output", 1, 1);
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ if (this.canOperate() && this.isGuiScreenOpened)
+ {
+ this.setActive(true);
+
+ if (this.progress == 0)
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 0, true);
+ }
+ ++this.progress;
+ if (this.progress >= this.operationLength)
+ {
+ this.operate();
+ this.progress = 0;
+ IC2.network.get().initiateTileEntityEvent(this, 2, true);
+ }
+ }
+ else
+ {
+ if (this.progress != 0 && this.getActive())
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 1, true);
+ }
+ if (!this.canOperate())
+ {
+ this.progress = 0;
+ }
+ this.setActive(false);
+ }
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "Loom";
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player)
+ {
+ return IHLUtils.getThisModItemStack("loom");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new LoomGui(new LoomContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ this.isGuiScreenOpened=true;
+ return new LoomContainer(player, this);
+ }
+
+ public void operate()
+ {
+ List<IRecipeInput> input1 = LoomTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs();
+ List<?> output1 = LoomTileEntity.recipeManager.getOutputFor(getInput()).getItemOutputs();
+ this.output.add(output1);
+ if(input1.get(0) instanceof RecipeInputWire)
+ {
+ int fiberLength = input1.get(0).getAmount();
+ boolean isFiberConsumed = IHLUtils.adjustWireLength(this.input.get(), -fiberLength);
+ if(isFiberConsumed)
+ {
+ this.input.put(null);
+ }
+ }
+ else
+ {
+ this.input.consume(input1.get(0));
+ }
+ }
+
+ @SuppressWarnings("rawtypes")
+ public List[] getInput()
+ {
+ return new List[] {null,Arrays.asList(new ItemStack[] {input.get()})};
+ }
+
+ public boolean canOperate()
+ {
+ if(LoomTileEntity.recipeManager.getOutputFor(getInput())==null) return false;
+ List<?> output1 = LoomTileEntity.recipeManager.getOutputFor(getInput()).getItemOutputs();
+ return this.output.canAdd(output1);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {}
+
+ public static void addRecipe(ItemStack input, ItemStack output)
+ {
+ if(input==null || output==null) throw new NullPointerException();
+ recipeManager.addRecipe(new UniversalRecipeInput(null,new ItemStack[] {input}), new UniversalRecipeOutput(null, new ItemStack[] {output},20));
+ }
+
+ public int gaugeProgressScaled(int i)
+ {
+ return this.progress * i / this.operationLength;
+ }
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event)
+ {
+ switch(event)
+ {
+ case 0:
+ this.isGuiScreenOpened=false;
+ break;
+ }
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/PaperMachineContainer.java b/src/main/java/ihl/processing/chemistry/PaperMachineContainer.java new file mode 100644 index 0000000..01db6fd --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/PaperMachineContainer.java @@ -0,0 +1,41 @@ +package ihl.processing.chemistry;
+
+import java.util.List;
+
+import ic2.core.IC2;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.fluids.FluidStack;
+
+public class PaperMachineContainer extends BasicElectricMotorContainer<PaperMachineTileEntity> {
+
+ protected PaperMachineTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public short lastProgress = -1;
+ public short lastTemperature = -1;
+ public short lastEnergy = -1;
+ public List<FluidStack> fluidTankFluidList;
+
+ public PaperMachineContainer(EntityPlayer entityPlayer, PaperMachineTileEntity tileEntity1){
+ super(entityPlayer, tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList=this.tileEntity.getFluidTank().getFluidList();
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 78, 51));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.drainInputSlot, 0, 78, 15));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 78, 33));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 122, 51));
+ }
+
+ @Override
+ public void detectAndSendChanges()
+ {
+ super.detectAndSendChanges();
+ if (this.tileEntity.getTankAmount() != this.lastFluidAmount || this.tileEntity.getNumberOfFluidsInTank() != this.lastNumberOfFluids)
+ {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ }
+ this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank();
+ this.lastFluidAmount = this.tileEntity.getTankAmount();
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/PaperMachineGui.java b/src/main/java/ihl/processing/chemistry/PaperMachineGui.java new file mode 100644 index 0000000..8fea247 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/PaperMachineGui.java @@ -0,0 +1,79 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class PaperMachineGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIPaperMachine.png");
+ private PaperMachineContainer container;
+ private int mixerFrame=0;
+
+ public PaperMachineGui (PaperMachineContainer container1) {
+ //the container is instanciated and passed to the superclass for handling
+ super(container1);
+ this.container=container1;
+ }
+
+ @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, 16 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27);
+ this.drawTexturedModalRect(38, 29, getFrameX(i1), getFrameY(i1),24,24);
+ if(mixerFrame++>4)
+ {
+ mixerFrame=0;
+ }
+ }
+ else
+ {
+ mixerFrame=0;
+ }
+ this.drawTexturedModalRect(103, 52, 246, 226+6*mixerFrame,10,6);
+ if (this.container.tileEntity.getTankAmount() > 0)
+ {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 102, 28, 114, 59, zLevel, par1, par2, xOffset, yOffset);
+ }
+ }
+
+ @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);
+ }
+
+ private int getFrameY(int number)
+ {
+ return (number % 10) * 24 + 14;
+ }
+
+ private int getFrameX(int number)
+ {
+ return (number / 10) * 24 + 176;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/PaperMachineTileEntity.java b/src/main/java/ihl/processing/chemistry/PaperMachineTileEntity.java new file mode 100644 index 0000000..dddd306 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/PaperMachineTileEntity.java @@ -0,0 +1,261 @@ +package ihl.processing.chemistry;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+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.IHLInvSlotOutput;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.processing.metallurgy.BasicElectricMotorTileEntity;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+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;
+
+public class PaperMachineTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler
+{
+ private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("papermachine");
+ public final IHLInvSlotOutput outputSlot;
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ private final IHLFluidTank fluidTank = new IHLFluidTank(8000);
+ public short temperature=20;
+
+ public PaperMachineTileEntity() {
+ super();
+ this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2);
+ 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"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=side;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("paperMachine");
+ }
+
+ @Override
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank);
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int amount, boolean doDrain)
+ {
+ FluidStack fstack = this.fluidTank.drain(amount, doDrain);
+ return fstack;
+ }
+
+
+ //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.UP);
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "chemicalReactor";
+ }
+
+ 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 PaperMachineGui(new PaperMachineContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player)
+ {
+ this.fluidTank.sortFluidsByDensity();
+ return new PaperMachineContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {}
+
+ @Override
+ public boolean canOperate()
+ {
+ UniversalRecipeOutput output = getOutput();
+ if(output!=null && this.outputSlot.canAdd(getOutput().getItemOutputs()))
+ {
+ if(output.specialConditions)
+ {
+ return this.checkSpecialConditions();
+ }
+ else
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean checkSpecialConditions()
+ {
+ ForgeDirection dir = ForgeDirection.getOrientation(this.getFacing());
+ TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX, yCoord, zCoord+dir.offsetZ);
+ if(te instanceof CryogenicDistillerTileEntity)
+ {
+ CryogenicDistillerTileEntity cgte = (CryogenicDistillerTileEntity)te;
+ return cgte.getFacing()==this.getFacing() && cgte.canProcess();
+ }
+ return false;
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ return PaperMachineTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @Override
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public List[] getInput()
+ {
+ return new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid()}), null};
+ }
+
+ @Override
+ public void operate()
+ {
+ UniversalRecipeInput recipeInput = PaperMachineTileEntity.recipeManager.getRecipeInput(getInput());
+ UniversalRecipeOutput output1 = getOutput();
+ this.fluidTank.drain(recipeInput.getFluidInputs(), true);
+ this.fluidTank.fill(output1.getFluidOutputs(), true);
+ if(!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0)!=null)this.outputSlot.add(output1.getItemOutputs());
+ }
+
+ @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 static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output)
+ {
+ recipeManager.addRecipe(input, output);
+ }
+
+ public int getNumberOfFluidsInTank()
+ {
+ return this.fluidTank.getNumberOfFluids();
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(FluidStack fluidStackInput1, ItemStack itemStackOutput1)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {fluidStackInput1}), null), new UniversalRecipeOutput(null, (new ItemStack[] {itemStackOutput1}),200));
+ }
+
+ public static void addSpecialConditionsRecipe(FluidStack fluidStackInput1, FluidStack fluidStackInput2, ItemStack itemStackInput, FluidStack fluidStackOutput, ItemStack itemStackOutput1, ItemStack itemStackOutput2)
+ {
+ addRecipe(new UniversalRecipeInput(new FluidStack[] {fluidStackInput1, fluidStackInput2}, (new ItemStack[] {itemStackInput})), new UniversalRecipeOutput((new FluidStack[] {fluidStackOutput}), (new ItemStack[] {itemStackOutput1, itemStackOutput2}),200, true));
+ }
+
+ public IHLFluidTank getFluidTank()
+ {
+ return this.fluidTank;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/RefluxCondenserModel.java b/src/main/java/ihl/processing/chemistry/RefluxCondenserModel.java new file mode 100644 index 0000000..9cb2f2f --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/RefluxCondenserModel.java @@ -0,0 +1,70 @@ +// Date: 05.04.2015 16:30:47 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX +package ihl.processing.chemistry; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + + +public class RefluxCondenserModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPartZ; + + public RefluxCondenserModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.PipeUp03", 0, 0); + setTextureOffset("Base.KneeUpEast", 0, 0); + setTextureOffset("Base.WestPipe03", 0, 0); + setTextureOffset("Base.WestPipe04", 0, 0); + setTextureOffset("Base.WestPipe02", 0, 0); + setTextureOffset("Base.WestPipe01", 0, 0); + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.PipeUp06", 0, 0); + setTextureOffset("Base.PipeUp07", 0, 0); + setTextureOffset("Base.PipeNorth07", 0, 0); + setTextureOffset("Base.PipeNorth08", 0, 0); + setTextureOffset("RotatingPartZ.ConeWest05", 0, 0); + setTextureOffset("RotatingPartZ.PipeWest07", 0, 0); + setTextureOffset("RotatingPartZ.ConeEast06", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addTube("PipeUp03", -2F, 7F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP); + Base.addKnee("KneeUpEast", -8F, 2F, -3F, 5, 6, 6, .8F, 1F, ForgeDirection.UP, ForgeDirection.EAST); + Base.addTube("WestPipe03", 3.5F, -7F, -1.5F, 4, 3, 3, 0.8f, 1f,ForgeDirection.WEST); + Base.addTube("WestPipe04", 7F, -7.5F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST); + Base.addTube("WestPipe02", 7F, 3F, -2F, 1, 4, 4, 0.6f, 1f,ForgeDirection.WEST); + Base.addTube("WestPipe01", -3F, 3.5F, -1.5F, 10, 3, 3, .8F, 1F, ForgeDirection.WEST); + Base.addTube("Shape1", -2F, -8F, -2F, 4, 1, 4, 0.6f, 1f,ForgeDirection.UP); + Base.addTube("PipeUp06", -1.5F, -7F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP); + Base.addTube("PipeUp07", -1.5F, 5F, -1.5F, 3, 2, 3, 0.8f, 1f,ForgeDirection.UP); + Base.addTube("PipeNorth07", -2F, -2F, -8F, 4, 4, 1, 0.6f, 1f,ForgeDirection.NORTH); + Base.addTube("PipeNorth08", -1.5F, -1.5F, -7F, 3, 3, 7, 0.8f, 1f,ForgeDirection.NORTH); + RotatingPartZ = new IHLModelRenderer(this, "RotatingPartZ"); + RotatingPartZ.setRotationPoint(3F, 13F, 0F); + setRotation(RotatingPartZ, 0F, 0F, -0.5F); + RotatingPartZ.mirror = true; + RotatingPartZ.addTube("ConeWest05", 1F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.WEST); + RotatingPartZ.addTube("PipeWest07", -9F, -4F, -4F, 10, 8, 8, 0.8f, 1f,ForgeDirection.WEST); + RotatingPartZ.addTube("ConeEast06", -11F, -4F, -4F, 2, 8, 8, 0f, 0.8f,ForgeDirection.EAST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + +} diff --git a/src/main/java/ihl/processing/chemistry/RefluxCondenserTileEntity.java b/src/main/java/ihl/processing/chemistry/RefluxCondenserTileEntity.java new file mode 100644 index 0000000..83eb108 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/RefluxCondenserTileEntity.java @@ -0,0 +1,148 @@ +package ihl.processing.chemistry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.api.network.INetworkDataProvider;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ihl.utils.IHLUtils;
+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;
+
+public class RefluxCondenserTileEntity extends TileEntity implements IWrenchable, INetworkDataProvider, IFluidHandler{
+
+ private short facing=2;
+ private short lastFacing=2;
+ public FractionatorBottomTileEntity columnBottom;
+
+ public RefluxCondenserTileEntity()
+ {
+ super();
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = new ArrayList<String>();
+ fields.add("facing");
+ return fields;
+ }
+
+ @Override
+ public void updateEntity()
+ {
+ super.updateEntity();
+ if(lastFacing!=facing)
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ lastFacing=facing;
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=side;
+ }
+
+
+ @Override
+ public short getFacing() {
+ return this.facing;
+ }
+
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ facing=(short) Math.max(2,facing1);
+ if(IC2.platform.isSimulating())
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
+ return true;
+ }
+
+
+ @Override
+ public float getWrenchDropRate() {
+ return 1F;
+ }
+
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("refluxCondenser");
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ facing=nbttagcompound.getShort("facing");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setShort("facing", facing);
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return false;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection direction, Fluid arg1) {
+ return direction.equals(ForgeDirection.UP);
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, int arg1, boolean arg2) {
+ return null;
+ }
+
+ @Override
+ public int fill(ForgeDirection direction, FluidStack fluidStack, boolean doFill) {
+ if(fluidStack!=null && fluidStack.getFluid()!=null && this.canFill(direction, fluidStack.getFluid()) && columnBottom!=null)
+ {
+ return columnBottom.fill(direction, fluidStack, doFill);
+ }
+ return 0;
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection arg0)
+ {
+ if(columnBottom!=null)
+ return columnBottom.getTankInfo(arg0);
+ else
+ return new FluidTankInfo[] {new FluidTankInfo(null, 8000)};
+ }
+
+}
diff --git a/src/main/java/ihl/processing/chemistry/SolarEvaporatorContainer.java b/src/main/java/ihl/processing/chemistry/SolarEvaporatorContainer.java new file mode 100644 index 0000000..4ecf44d --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/SolarEvaporatorContainer.java @@ -0,0 +1,112 @@ +package ihl.processing.chemistry;
+
+import ic2.core.ContainerBase;
+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.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+public class SolarEvaporatorContainer extends ContainerBase<SolarEvaporatorTileEntity> {
+
+ protected SolarEvaporatorTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastFuel = -1;
+ public short lastProgress = -1;
+ private final static int height = 166;
+ public int lastNumberOfFluids = -1;
+ public int lastVisibleFluidID = -1;
+ public int lastVisibleFluidAmount = -1;
+
+ public SolarEvaporatorContainer(EntityPlayer entityPlayer, SolarEvaporatorTileEntity tileEntity1) {
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ 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.fluidItemsSlot, 0, 44, 14));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 44, 32));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillItemsSlot, 0, 44, 50));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 117, 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.getFluidTank().getFluid() != null
+ && this.tileEntity.getFluidTank().getFluidAmount() != this.lastFluidAmount) {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.getFluidTank().getFluid().getFluid().getID());
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getFluidTank().getFluidAmount());
+ }
+
+ if (this.tileEntity.fuel != this.lastFuel) {
+ icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.fuel);
+ }
+
+ if (this.tileEntity.progress != this.lastProgress) {
+ icrafting.sendProgressBarUpdate(this, 3, this.tileEntity.progress);
+ }
+ if (this.tileEntity.visibleFluidId != this.lastVisibleFluidID)
+ {
+ icrafting.sendProgressBarUpdate(this, 4, this.tileEntity.visibleFluidId);
+ }
+ if (this.tileEntity.visibleFluidAmount != this.lastVisibleFluidAmount)
+ {
+ icrafting.sendProgressBarUpdate(this, 5, this.tileEntity.visibleFluidAmount);
+ }
+ }
+
+ this.lastFluidAmount = this.tileEntity.getFluidTank().getFluidAmount();
+ this.lastFuel = this.tileEntity.fuel;
+ this.lastProgress = this.tileEntity.progress;
+ this.lastVisibleFluidID=this.tileEntity.visibleFluidId;
+ this.lastVisibleFluidAmount=this.tileEntity.visibleFluidAmount;
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value) {
+ super.updateProgressBar(index, value);
+
+ switch (index) {
+ case 0:
+ this.tileEntity.getFluidTank().setFluid(new FluidStack(FluidRegistry.getFluid(value), 1000));
+ break;
+ case 1:
+ this.tileEntity.getFluidTank()
+ .setFluid(new FluidStack(this.tileEntity.getFluidTank().getFluid().getFluid(), value));
+ break;
+ case 2:
+ this.tileEntity.fuel = value;
+ break;
+ case 3:
+ this.tileEntity.progress = (short) value;
+ break;
+ case 4:
+ this.tileEntity.visibleFluidId=value;
+ break;
+ case 5:
+ this.tileEntity.visibleFluidAmount=value;
+ break;
+
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/chemistry/SolarEvaporatorGui.java b/src/main/java/ihl/processing/chemistry/SolarEvaporatorGui.java new file mode 100644 index 0000000..e97f9e0 --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/SolarEvaporatorGui.java @@ -0,0 +1,78 @@ +package ihl.processing.chemistry;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.util.DrawUtil;
+import ic2.core.util.GuiTooltipHelper;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+@SideOnly(Side.CLIENT)
+public class SolarEvaporatorGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl",
+ "textures/gui/GUISolarEvaporator.png");
+ private SolarEvaporatorContainer container;
+
+ public SolarEvaporatorGui(SolarEvaporatorContainer container1) {
+ // the container is instanciated and passed to the superclass for
+ // handling
+ super(container1);
+ this.container = container1;
+ }
+
+ @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.getActive()) {
+ this.drawTexturedModalRect(9, 16, 176, 0, 14, 14);
+ }
+ if (this.container.tileEntity.progress > 0) {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18), 18);
+ this.drawTexturedModalRect(99, 34, 198, 0, i1 + 1, 13);
+ }
+
+ if (this.container.tileEntity.getTankAmount() > 0) {
+ FluidStack fluidStack = this.container.tileEntity.getFluidTank().getFluid();
+ if (fluidStack != null) {
+ Fluid fluid = fluidStack.getFluid();
+ if (fluid != null) {
+
+ IIcon fluidIcon = fluid.getIcon();
+
+ if (fluidIcon != null) {
+ this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
+ int liquidHeight = this.container.tileEntity.gaugeLiquidScaled(47);
+ DrawUtil.drawRepeated(fluidIcon, (82), 16 + 47 - liquidHeight, 12.0D, liquidHeight,
+ this.zLevel);
+ this.mc.renderEngine.bindTexture(background);
+ }
+ }
+ String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getUnlocalizedName()) + ": "
+ + fluidStack.amount + "mB";
+ GuiTooltipHelper.drawAreaTooltip(par1 - 90, par2 - 32, tooltip, xOffset - 8, yOffset - 15, xOffset + 2,
+ yOffset + 30);
+ }
+ }
+ }
+
+ @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);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/chemistry/SolarEvaporatorTileEntity.java b/src/main/java/ihl/processing/chemistry/SolarEvaporatorTileEntity.java new file mode 100644 index 0000000..947a88a --- /dev/null +++ b/src/main/java/ihl/processing/chemistry/SolarEvaporatorTileEntity.java @@ -0,0 +1,108 @@ +package ihl.processing.chemistry; + +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.ContainerBase; +import ic2.core.IC2; +import ihl.interfaces.IFluidTankVisual; +import ihl.utils.IHLUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.EnumSkyBlock; + +public class SolarEvaporatorTileEntity extends EvaporatorTileEntity implements IFluidTankVisual { + public int visibleFluidId = -1; + public int visibleFluidAmount = 1; + + public SolarEvaporatorTileEntity(){ + super(); + this.fuelSlot = null; + this.maxProgress = 4500; + } + + @Override + public List<String> getNetworkedFields() + { + List<String> ret = super.getNetworkedFields(); + ret.add("visibleFluidId"); + ret.add("visibleFluidAmount"); + return ret; + } + + @Override + public void updateEntityServer() + { + super.updateEntityServer(); + if(this.fluidTank.getFluid()!=null && (visibleFluidId!=this.fluidTank.getFluid().getFluid().getID() || visibleFluidAmount!=this.fluidTank.getFluidAmount())) + { + visibleFluidId = this.fluidTank.getFluid().getFluid().getID(); + visibleFluidAmount = this.fluidTank.getFluidAmount(); + IC2.network.get().updateTileEntityField(this, "visibleFluidId"); + IC2.network.get().updateTileEntityField(this, "visibleFluidAmount"); + } + else if(this.fluidTank.getFluid()==null && visibleFluidId!=-1) + { + visibleFluidId=-1; + IC2.network.get().updateTileEntityField(this, "visibleFluidId"); + } + } + @Override + public boolean isBurning() + { + return this.worldObj.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, xCoord, yCoord, zCoord)>=15; + } + + @Override + public ContainerBase<? extends EvaporatorTileEntity> getGuiContainer(EntityPlayer entityPlayer) + { + return new SolarEvaporatorContainer(entityPlayer, this); + } + + @Override + @SideOnly(Side.CLIENT) + public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) + { + return new SolarEvaporatorGui(new SolarEvaporatorContainer(entityPlayer, this)); + } + + @Override + public short getFacing() + { + return 3; + } + + @Override + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return false; + } + + @Override + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return IHLUtils.getThisModItemStack("solarEvaporator"); + } + + @Override + public int getVisibleFluidId() { + return this.visibleFluidId; + } + + @Override + public int getVisibleFluidAmount() { + return this.visibleFluidAmount; + } + + @Override + public float getRenderLiquidLevel() + { + return (float)this.visibleFluidAmount/(float)this.fluidTank.getCapacity()/2; + } + + @Override + public boolean shouldRenderInPass(int pass) + { + return pass==0; + } +} diff --git a/src/main/java/ihl/processing/invslots/IHLInvSlotOutput.java b/src/main/java/ihl/processing/invslots/IHLInvSlotOutput.java new file mode 100644 index 0000000..d5186e2 --- /dev/null +++ b/src/main/java/ihl/processing/invslots/IHLInvSlotOutput.java @@ -0,0 +1,166 @@ +package ihl.processing.invslots;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class IHLInvSlotOutput extends InvSlotOutput {
+
+ private final Map<Long, Float> substanceAmount = new HashMap<Long, Float>();
+
+ public IHLInvSlotOutput(TileEntityInventory base1, String name1, int oldStartIndex1, int count) {
+ super(base1, name1, oldStartIndex1, count);
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public boolean canAdd(List itemOutputs) {
+ if (itemOutputs == null || itemOutputs.isEmpty()) {
+ return true;
+ }
+ Iterator ioi = itemOutputs.iterator();
+ if (this.size() >= itemOutputs.size()) {
+ Object rois;
+ if (ioi.hasNext()) {
+ rois = ioi.next();
+ } else {
+ return true;
+ }
+ for (int i = 0; i < this.size(); i++) {
+ if (this.get(i) == null || (this.objectMatchesSlot(rois, i)
+ && this.get(i).stackSize + this.getAmoutOfObject(rois) < this.getStackSizeLimit()
+ && this.get(i).stackSize + this.getAmoutOfObject(rois) <= this.get(i).getMaxStackSize())) {
+ if (ioi.hasNext()) {
+ rois = ioi.next();
+ } else {
+ return true;
+ }
+ } else {
+ if (i == this.size() - 1) {
+ return false;
+ }
+ }
+ }
+
+ }
+ return false;
+ }
+
+ private float getAmoutOfObject(Object obj) {
+ if (obj instanceof ItemStack) {
+ return ((ItemStack) obj).stackSize;
+ } else if (obj instanceof RecipeOutputItemStack) {
+ return ((RecipeOutputItemStack) obj).quantity;
+ }
+ return Short.MAX_VALUE;
+ }
+
+ public boolean objectMatchesSlot(Object obj, int slot) {
+ if (this.get(slot) == null) {
+ return true;
+ } else {
+ if (obj instanceof ItemStack) {
+ return IHLUtils.isItemStacksIsEqual(this.get(slot), (ItemStack) obj, true);
+ } else if (obj instanceof RecipeOutputItemStack) {
+ return ((RecipeOutputItemStack) obj).matches(this.get(slot));
+ }
+ }
+ return false;
+ }
+
+ public void add(RecipeOutputItemStack rois) {
+ for (int i = 0; i < this.size(); i++) {
+ if (this.get(i) == null || (this.objectMatchesSlot(rois, i)
+ && this.get(i).stackSize + this.getAmoutOfObject(rois) < this.getStackSizeLimit())) {
+ this.add(i, rois);
+ break;
+ }
+ }
+ }
+
+ private void add(int i, RecipeOutputItemStack rois) {
+ long key = (Item.getIdFromItem(rois.itemStack.getItem()) << 32) + rois.itemStack.getItemDamage();
+ float amount = 0f;
+ if (this.substanceAmount.containsKey(key)) {
+ amount = this.substanceAmount.get(key);
+ }
+ amount += rois.quantity;
+ while (amount >= 1) {
+ amount--;
+ this.add(rois.itemStack.copy());
+ }
+ this.substanceAmount.put(key, amount);
+ }
+
+ @Override
+ @SuppressWarnings("rawtypes")
+ public int add(List itemOutputs) {
+ if (itemOutputs == null || itemOutputs.isEmpty()) {
+ return 0;
+ }
+ Iterator ioi = itemOutputs.iterator();
+ if (this.size() >= itemOutputs.size() && ioi.hasNext()) {
+ Object rois = ioi.next();
+ for (int i = 0; i < this.size(); i++) {
+ if (this.get(i) == null || (this.objectMatchesSlot(rois, i)
+ && this.get(i).stackSize + this.getAmoutOfObject(rois) < this.getStackSizeLimit())) {
+ if (rois instanceof ItemStack) {
+ this.add(((ItemStack) rois).copy());
+ } else if (rois instanceof RecipeOutputItemStack) {
+ this.add(i, (RecipeOutputItemStack) rois);
+ }
+ if (ioi.hasNext()) {
+ rois = ioi.next();
+ } else {
+ return itemOutputs.size();
+ }
+ } else {
+ if (i == this.size() - 1) {
+ return 0;
+ }
+ }
+ }
+
+ }
+ return 0;
+ }
+
+ @Override
+ public void readFromNbt(NBTTagCompound nbtTagCompound) {
+ super.readFromNbt(nbtTagCompound);
+ NBTTagList amountTagList = nbtTagCompound.getTagList("substanceAmountMap", 10);
+ for (int i = 0; i < amountTagList.tagCount(); i++) {
+ if (amountTagList.getCompoundTagAt(i).hasKey("substanceKey")) {
+ long substanceKey = amountTagList.getCompoundTagAt(i).getLong("substanceKey");
+ float substanceAmount = amountTagList.getCompoundTagAt(i).getFloat("substanceAmount");
+ this.substanceAmount.put(substanceKey, substanceAmount);
+ }
+ }
+ }
+
+ @Override
+ public void writeToNbt(NBTTagCompound nbtTagCompound) {
+ super.writeToNbt(nbtTagCompound);
+ NBTTagList sAmountsList = new NBTTagList();
+ Iterator<Entry<Long, Float>> entrySetIterator = this.substanceAmount.entrySet().iterator();
+ while (entrySetIterator.hasNext()) {
+ Entry<Long, Float> entry = entrySetIterator.next();
+ NBTTagCompound tag = new NBTTagCompound();
+ tag.setLong("substanceKey", entry.getKey());
+ tag.setFloat("substanceAmount", entry.getValue());
+ sAmountsList.appendTag(tag);
+ }
+ nbtTagCompound.setTag("substanceAmountMap", sAmountsList);
+ }
+}
diff --git a/src/main/java/ihl/processing/invslots/InvSlotConsumableLiquidIHL.java b/src/main/java/ihl/processing/invslots/InvSlotConsumableLiquidIHL.java new file mode 100644 index 0000000..7bb6ecc --- /dev/null +++ b/src/main/java/ihl/processing/invslots/InvSlotConsumableLiquidIHL.java @@ -0,0 +1,271 @@ +package ihl.processing.invslots;
+
+import java.util.Iterator;
+
+import org.apache.commons.lang3.mutable.MutableObject;
+
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.util.StackUtil;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+
+public class InvSlotConsumableLiquidIHL extends InvSlotConsumableLiquid{
+
+ private OpType opType;
+ private String additionalInputs;
+
+ public InvSlotConsumableLiquidIHL(TileEntityInventory base1, String name1,int oldStartIndex1, Access access1, int count,InvSide preferredSide1, OpType opType1)
+ {
+ super(base1, name1, oldStartIndex1, access1, count, preferredSide1, opType1);
+ opType=opType1;
+ }
+
+ public InvSlotConsumableLiquidIHL(TileEntityInventory base1, String name1,int oldStartIndex1, Access access1, int count,InvSide preferredSide1, OpType opType1, String additionalInputs1)
+ {
+ super(base1, name1, oldStartIndex1, access1, count, preferredSide1, opType1);
+ opType=opType1;
+ additionalInputs=additionalInputs1;
+ }
+
+ @Override
+ public FluidStack drain(Fluid fluid, int maxAmount, MutableObject<ItemStack> output, boolean simulate)
+ {
+ if(output!=null)
+ {
+ output.setValue((ItemStack)null);
+ }
+
+ if (this.opType != InvSlotConsumableLiquid.OpType.Drain && this.opType != InvSlotConsumableLiquid.OpType.Both)
+ {
+ return null;
+ }
+ else
+ {
+ ItemStack stack = this.get();
+
+ if (stack == null)
+ {
+ return null;
+ }
+ else if (!FluidContainerRegistry.isFilledContainer(stack))
+ {
+ if (stack.getItem() instanceof IFluidContainerItem)
+ {
+ IFluidContainerItem var9 = (IFluidContainerItem)stack.getItem();
+
+ if (var9.getFluid(stack) == null)
+ {
+ return null;
+ }
+ else if (fluid != null && var9.getFluid(stack).getFluid() != fluid)
+ {
+ return null;
+ }
+ else if (!this.acceptsLiquid(var9.getFluid(stack).getFluid()))
+ {
+ return null;
+ }
+ else
+ {
+ ItemStack singleStack = StackUtil.copyWithSize(stack, 1);
+ FluidStack fluidStack = var9.drain(singleStack, maxAmount, true);
+
+ if (fluidStack != null && fluidStack.amount > 0)
+ {
+ if (singleStack.stackSize <= 0)
+ {
+ if (!simulate)
+ {
+ --stack.stackSize;
+ }
+ }
+ else if (var9.getFluid(singleStack) == null)
+ {
+ if(output!=null)
+ {
+ output.setValue(singleStack);
+ }
+ if (!simulate)
+ {
+ --stack.stackSize;
+ }
+ }
+ else
+ {
+ if (stack.stackSize > 1)
+ {
+ return null;
+ }
+
+ if (!simulate)
+ {
+ this.put(singleStack);
+ }
+ }
+
+ if (stack.stackSize <= 0)
+ {
+ this.put((ItemStack)null);
+ }
+
+ return fluidStack;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ FluidStack container = FluidContainerRegistry.getFluidForFilledItem(stack);
+
+ if (container != null && (fluid == null || fluid == container.getFluid()))
+ {
+ if (!this.acceptsLiquid(container.getFluid()))
+ {
+ return null;
+ }
+ else if (container.amount > 0 && container.amount <= maxAmount)
+ {
+ if (stack.getItem().hasContainerItem(stack) && output!=null)
+ {
+ output.setValue(stack.getItem().getContainerItem(stack));
+ }
+ else
+ {
+ ItemStack emptystack = FluidContainerRegistry.drainFluidContainer(stack);
+ if(emptystack!=null && output!=null)
+ {
+ output.setValue(emptystack);
+ }
+ }
+
+ if (!simulate)
+ {
+ --stack.stackSize;
+
+ if (stack.stackSize <= 0)
+ {
+ this.put((ItemStack)null);
+ }
+ }
+
+ return container;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean accepts(ItemStack stack)
+ {
+ if (stack == null)
+ {
+ return true;
+ }
+ Item item = stack.getItem();
+ if (item == null)
+ {
+ return false;
+ }
+ else
+ {
+ if(this.additionalInputs!=null)
+ {
+ String fon = IHLUtils.getFirstOreDictName(stack);
+ if(fon!=null && fon.contains(additionalInputs))
+ {
+ return true;
+ }
+ }
+ if (this.opType == InvSlotConsumableLiquid.OpType.Drain || this.opType == InvSlotConsumableLiquid.OpType.Both)
+ {
+ FluidStack containerItem = null;
+ if (FluidContainerRegistry.isFilledContainer(stack))
+ {
+ containerItem = FluidContainerRegistry.getFluidForFilledItem(stack);
+ }
+ else if (item instanceof IFluidContainerItem)
+ {
+ containerItem = ((IFluidContainerItem)item).getFluid(stack);
+ }
+
+ if (containerItem != null && containerItem.amount > 0)
+ {
+ return true;
+ }
+ }
+ if (this.opType == InvSlotConsumableLiquid.OpType.Fill || this.opType == InvSlotConsumableLiquid.OpType.Both)
+ {
+ if (FluidContainerRegistry.isEmptyContainer(stack))
+ {
+ if (this.getPossibleFluids() == null)
+ {
+ return true;
+ }
+
+ Iterator<Fluid> containerItem1 = this.getPossibleFluids().iterator();
+
+ while (containerItem1.hasNext())
+ {
+ Fluid prevFluid = containerItem1.next();
+
+ if (FluidContainerRegistry.fillFluidContainer(new FluidStack(prevFluid, Integer.MAX_VALUE), stack) != null)
+ {
+ return true;
+ }
+ }
+ }
+ else if (item instanceof IFluidContainerItem)
+ {
+ IFluidContainerItem containerItem2 = (IFluidContainerItem)item;
+ FluidStack prevFluid1 = containerItem2.getFluid(stack);
+
+ if (prevFluid1 == null || containerItem2.getCapacity(stack) > prevFluid1.amount)
+ {
+ if (this.getPossibleFluids() == null)
+ {
+ return true;
+ }
+
+ ItemStack singleStack = StackUtil.copyWithSize(stack, 1);
+ Iterator<Fluid> i$ = this.getPossibleFluids().iterator();
+
+ while (i$.hasNext())
+ {
+ Fluid fluid = i$.next();
+
+ if (containerItem2.fill(singleStack, new FluidStack(fluid, Integer.MAX_VALUE), false) > 0)
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/invslots/InvSlotUpgradeIHL.java b/src/main/java/ihl/processing/invslots/InvSlotUpgradeIHL.java new file mode 100644 index 0000000..5c1fff9 --- /dev/null +++ b/src/main/java/ihl/processing/invslots/InvSlotUpgradeIHL.java @@ -0,0 +1,61 @@ +package ihl.processing.invslots;
+
+import ic2.core.Ic2Items;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+
+public class InvSlotUpgradeIHL extends InvSlot {
+
+ public InvSlotUpgradeIHL(int count) {
+ super(count);
+ }
+
+ public InvSlotUpgradeIHL(TileEntityInventory base, int oldStartIndex, Access access, int count, InvSide side) {
+ super(base, "invSlotUpgrade", oldStartIndex, access, count, side);
+ }
+
+ public double getPowerConsumtionMultiplier() {
+ double base = 1d;
+ for (int i = 0; i < this.size(); i++) {
+ if (IHLUtils.isItemStacksIsEqual(this.get(i), Ic2Items.overclockerUpgrade, false)) {
+ int i1 = this.get(i).stackSize;
+ while (i1-- > 0 && base < 600) {
+ base *= 1.6f;
+ }
+ }
+ }
+ return base;
+ }
+
+ public float getProgressMultiplier() {
+ float base = 1f;
+ for (int i = 0; i < this.size(); i++) {
+ if (IHLUtils.isItemStacksIsEqual(this.get(i), Ic2Items.overclockerUpgrade, false)) {
+ int i1 = this.get(i).stackSize;
+ while (i1-- > 0 && base < 600) {
+ base *= 1.428571429f;
+ }
+ }
+ }
+ return base;
+ }
+
+ public int getAdditionalEnergyStorage() {
+ int base = 0;
+ for (int i = 0; i < this.size(); i++) {
+ if (IHLUtils.isItemStacksIsEqual(this.get(i), Ic2Items.energyStorageUpgrade, false)) {
+ base += this.get(i).stackSize * 10000;
+ }
+ }
+ return base;
+ }
+
+ @Override
+ public boolean accepts(ItemStack stack) {
+ return IHLUtils.isItemStacksIsEqual(stack, Ic2Items.overclockerUpgrade, false) ||
+ IHLUtils.isItemStacksIsEqual(stack, Ic2Items.energyStorageUpgrade, false);
+ }
+
+}
diff --git a/src/main/java/ihl/processing/invslots/SlotInvSlotIronWorkbench.java b/src/main/java/ihl/processing/invslots/SlotInvSlotIronWorkbench.java new file mode 100644 index 0000000..7f00e06 --- /dev/null +++ b/src/main/java/ihl/processing/invslots/SlotInvSlotIronWorkbench.java @@ -0,0 +1,32 @@ +package ihl.processing.invslots;
+
+import ic2.core.slot.SlotInvSlot;
+import ihl.flexible_cable.IronWorkbenchInvSlot;
+import ihl.flexible_cable.IronWorkbenchTileEntity;
+import net.minecraft.entity.player.EntityPlayer;
+
+public class SlotInvSlotIronWorkbench extends SlotInvSlot {
+
+ public IronWorkbenchInvSlot invSlot;
+
+ public SlotInvSlotIronWorkbench(IronWorkbenchInvSlot invSlot1, int index1,
+ int xDisplayPosition1, int yDisplayPosition1) {
+ super(invSlot1, index1, xDisplayPosition1, yDisplayPosition1);
+ this.invSlot=invSlot1;
+
+ }
+
+ @Override
+ public boolean canTakeStack(EntityPlayer player)
+ {
+ return this.invSlot.getCanTakeStack();
+ }
+
+
+ @Override
+ public void onSlotChanged()
+ {
+ super.onSlotChanged();
+ ((IronWorkbenchTileEntity)this.invSlot.base).resetOutput();
+ }
+}
diff --git a/src/main/java/ihl/processing/invslots/SlotInvSlotOutputInProgress.java b/src/main/java/ihl/processing/invslots/SlotInvSlotOutputInProgress.java new file mode 100644 index 0000000..25c0673 --- /dev/null +++ b/src/main/java/ihl/processing/invslots/SlotInvSlotOutputInProgress.java @@ -0,0 +1,23 @@ +package ihl.processing.invslots;
+
+import ic2.core.slot.SlotInvSlot;
+import ihl.flexible_cable.IronWorkbenchInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+
+public class SlotInvSlotOutputInProgress extends SlotInvSlot {
+
+ public IronWorkbenchInvSlot invSlot;
+
+ public SlotInvSlotOutputInProgress(IronWorkbenchInvSlot invSlot1, int index1,
+ int xDisplayPosition1, int yDisplayPosition1) {
+ super(invSlot1, index1, xDisplayPosition1, yDisplayPosition1);
+ this.invSlot=invSlot1;
+
+ }
+
+ @Override
+ public boolean canTakeStack(EntityPlayer player)
+ {
+ return this.invSlot.getCanTakeStack();
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/AchesonFurnaceGui.java b/src/main/java/ihl/processing/metallurgy/AchesonFurnaceGui.java new file mode 100644 index 0000000..6f8238a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/AchesonFurnaceGui.java @@ -0,0 +1,46 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+public class AchesonFurnaceGui extends GuiContainer {
+ protected static final ResourceLocation achesonFurnaceBackground = new ResourceLocation("ihl", "textures/gui/GUIAchesonFurnace.png");
+ private MachineBaseContainer container;
+
+ public AchesonFurnaceGui(MachineBaseContainer machineBaseContainer) {
+ super(machineBaseContainer);
+ this.container=machineBaseContainer;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(achesonFurnaceBackground);
+ int i1;
+ if (this.container.tileEntity.getEnergy() > 0D)
+ {
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12);
+ this.drawTexturedModalRect(8, 6 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(17),17);
+ this.drawTexturedModalRect(70,34, 197, 0, i1 + 1, 13);
+ }
+ fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("ihl.gui.achesonFurnance"), 40, 12, 16768125);
+ }
+
+ @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(achesonFurnaceBackground);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/AchesonFurnanceContainer.java b/src/main/java/ihl/processing/metallurgy/AchesonFurnanceContainer.java new file mode 100644 index 0000000..2580c6c --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/AchesonFurnanceContainer.java @@ -0,0 +1,16 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+
+public class AchesonFurnanceContainer extends MachineBaseContainer {
+
+ public AchesonFurnanceContainer(EntityPlayer entityPlayer,
+ AchesonFurnanceTileEntity tileEntity1) {
+ super(entityPlayer, tileEntity1);
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 40, 22));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 40, 40));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 98, 32));
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java b/src/main/java/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java new file mode 100644 index 0000000..75efd70 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/AchesonFurnanceTileEntity.java @@ -0,0 +1,101 @@ +package ihl.processing.metallurgy;
+
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.ContainerBase;
+import ihl.IHLMod;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+
+public class AchesonFurnanceTileEntity extends MachineBaseTileEntity {
+
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("achesonfurnace");
+ public final IHLInvSlotOutput outputSlot;
+
+ public AchesonFurnanceTileEntity() {
+ super(2);
+ this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1);
+ }
+
+ public static void addRecipe(IRecipeInput input1, IRecipeInput input2, String output1) {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, new IRecipeInput[] { input1, input2 }),
+ new UniversalRecipeOutput(null, new ItemStack[] { IHLUtils.getThisModItemStack(output1) }, 20));
+ }
+
+ @Override
+ public String getStartSoundFile() {
+ return "Machines/Electro Furnace/ElectroFurnaceLoop.ogg";
+ }
+
+ @Override
+ public String getLoopSoundFile() {
+ return null;
+ }
+
+ @Override
+ public String getStopSoundFile() {
+ return null;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "AchesonFurnance";
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new AchesonFurnaceGui(new AchesonFurnanceContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new AchesonFurnanceContainer(player, this);
+ }
+
+ @Override
+ public void operate() {
+ ItemStack crucible = input.getItemStack(IHLMod.crucible);
+ if (crucible != null) {
+ ((Crucible) crucible.getItem()).processContent(crucible, this);
+ return;
+ }
+ List<RecipeOutputItemStack> output = recipeManager
+ .getOutputFor(getInput()).getItemOutputs();
+ List<IRecipeInput> rinput = recipeManager.getRecipeInput(getInput()).getItemInputs();
+ for (int i = 0; i < rinput.size(); i++) {
+ this.input.consume(rinput.get(i));
+ }
+ this.outputSlot.add(output);
+ }
+
+ @Override
+ public boolean canOperate() {
+ return this.getOutput() != null;
+ }
+
+ @Override
+ public List<?>[] getInput() {
+ return new List[] { null, this.input.getItemStackList() };
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ @Override
+ public UniversalRecipeOutput getOutput() {
+ return AchesonFurnanceTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java b/src/main/java/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java new file mode 100644 index 0000000..a546b0a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/BasicElectricMotorTileEntity.java @@ -0,0 +1,272 @@ +package ihl.processing.metallurgy;
+
+import java.util.Iterator;
+import java.util.List;
+
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySink;
+import ic2.api.network.INetworkClientTileEntityEventListener;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ihl.IHLMod;
+import ihl.flexible_cable.FlexibleCableHolderBaseTileEntity;
+import ihl.flexible_cable.NodeEntity;
+import ihl.processing.invslots.InvSlotUpgradeIHL;
+import ihl.utils.IHLInvSlotDischarge;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public abstract class BasicElectricMotorTileEntity extends FlexibleCableHolderBaseTileEntity
+ implements IHasGui, INetworkClientTileEntityEventListener, IEnergySink {
+
+ public final IHLInvSlotDischarge dischargeSlot;
+ public final InvSlotUpgradeIHL upgradeSlot;
+ public short progress;
+ protected short operationLength = 6000;
+ protected double energyConsume = 1d;
+ public double energy = 0d;
+ public int maxStorage = 128;
+ private boolean addedToEnergyNet = false;
+
+ public BasicElectricMotorTileEntity() {
+ super();
+ energyConsume = IHLMod.config.machineryEnergyConsume/100d;
+ dischargeSlot = new IHLInvSlotDischarge(this, 1, Access.I, 4, InvSlot.InvSide.BOTTOM);
+ upgradeSlot = new InvSlotUpgradeIHL(this, 1, Access.I, 4, InvSlot.InvSide.BOTTOM);
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "Lathe";
+ }
+
+ public boolean enableUpdateEntity() {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void onLoaded() {
+ super.onLoaded();
+ if (IC2.platform.isSimulating() && !this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ }
+
+ @Override
+ public void onUnloaded() {
+ if (IC2.platform.isSimulating() && this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+
+ super.onUnloaded();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setFacing(short facing1) {
+ double d = 0.3D;
+ double f = -0.1D;
+ if (IC2.platform.isSimulating() && this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ double range = 2D;
+ AxisAlignedBB searchArea = AxisAlignedBB.getBoundingBox(connectionX - range, connectionY - range,
+ connectionZ - range, connectionX + range, connectionY + range, connectionZ + range);
+ List<NodeEntity> nodeList = worldObj.getEntitiesWithinAABB(NodeEntity.class, searchArea);
+ super.setFacing(facing1);
+ switch (getFacing()) {
+ case 4:
+ setConnectionX(this.xCoord + 0.5D);
+ setConnectionY(this.yCoord + d);
+ setConnectionZ(this.zCoord + 1D - f);
+ break;
+ case 5:
+ setConnectionX(this.xCoord + 0.5D);
+ setConnectionY(this.yCoord + d);
+ setConnectionZ(this.zCoord + f);
+ break;
+ case 2:
+ setConnectionX(this.xCoord + 1D - f);
+ setConnectionY(this.yCoord + d);
+ setConnectionZ(this.zCoord + 0.5D);
+ break;
+ case 3:
+ setConnectionX(this.xCoord + f);
+ setConnectionY(this.yCoord + d);
+ setConnectionZ(this.zCoord + 0.5D);
+ break;
+ default:
+ setConnectionX(this.xCoord + 1D - f);
+ setConnectionY(this.yCoord + d);
+ setConnectionZ(this.zCoord + 0.5D);
+ break;
+
+ }
+ if (!nodeList.isEmpty()) {
+ Iterator<NodeEntity> ei = nodeList.iterator();
+ while (ei.hasNext()) {
+ NodeEntity ne = ei.next();
+ if ((ne.prevAnchorEntity == null || ne.nextAnchorEntity == null)
+ && this.cableListContains(ne.getChainUniqueID())) {
+ ne.setVirtualNodePos(connectionX, connectionY, connectionZ);
+ }
+ }
+ }
+ if (IC2.platform.isSimulating() && !this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ }
+
+ @Override
+ public double getDemandedEnergy() {
+ if(this.getMaxStorage() - this.energy <= 1d)
+ {
+ return 0d;
+ }
+ return this.getMaxStorage() - this.energy;
+ }
+
+ @Override
+ public int getSinkTier() {
+ return 4;
+ }
+
+ @Override
+ public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) {
+ if (this.energy < this.getMaxStorage()) {
+ this.energy += amount;
+ return 0.0D;
+ } else {
+ return amount;
+ }
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing() != (short) side;
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbt) {
+ super.writeToNBT(nbt);
+ nbt.setShort("progress", this.progress);
+ nbt.setDouble("energy", this.energy);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbt) {
+ super.readFromNBT(nbt);
+ this.progress = nbt.getShort("progress");
+ this.energy = nbt.getDouble("energy");
+ }
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event) {
+ switch (event) {
+ case 0:
+ break;
+ }
+ }
+
+ public abstract void operate();
+
+ @Override
+ public void updateEntityServer() {
+ if (this.getDemandedEnergy() > 1.0D) {
+ double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false);
+ this.energy += amount;
+ }
+ if (this.gridID != -1 && this.getGrid().energy > 0D && this.energy < this.getMaxStorage()) {
+ this.energy += energyConsume * 10D;
+ this.getGrid().drawEnergy(energyConsume * 10D, this);
+ }
+ if (this.canOperate() && this.energy >= this.energyConsume) {
+ this.energy -= this.energyConsume * this.upgradeSlot.getPowerConsumtionMultiplier();
+ if (this.progress == 0) {
+ IC2.network.get().initiateTileEntityEvent(this, 0, true);
+ }
+ this.progress+=(short)(10*this.upgradeSlot.getProgressMultiplier());
+ if (this.progress >= this.operationLength) {
+ this.operate();
+ this.progress = 0;
+ IC2.network.get().initiateTileEntityEvent(this, 2, true);
+ }
+ } else {
+ if (this.progress != 0 && this.getActive()) {
+ IC2.network.get().initiateTileEntityEvent(this, 1, true);
+ }
+ if (!this.canOperate()) {
+ this.progress = 0;
+ }
+ }
+
+ }
+
+ private double getMaxStorage() {
+ return maxStorage+this.upgradeSlot.getAdditionalEnergyStorage();
+ }
+
+ public abstract List<?>[] getInput();
+
+ public abstract boolean canOperate();
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {
+ }
+
+ public int getEnergy() {
+ return (int) this.energy;
+ }
+
+ public int getGUIEnergy(int i) {
+ if (this.energy < Float.MAX_VALUE) {
+ return Math.round((float) (this.energy / this.getMaxStorage() * i));
+ } else {
+ return Math.round((float) (this.energy / this.getMaxStorage()) * i);
+ }
+ }
+
+ public int gaugeProgressScaled(int i) {
+ return this.progress * i / this.operationLength;
+ }
+
+ public void setEnergy(int value) {
+ this.energy = value;
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
+ return true;
+ }
+
+ @Override
+ public double getMaxAllowableVoltage() {
+ return 64000D;
+ }
+
+ @Override
+ public double getEnergyAmountThisNodeWant() {
+ return this.getMaxStorage()-this.energy;
+ }
+
+ public double drawEnergyToGrid(double amount) {
+ return 0d;
+ }
+
+ @Override
+ public void injectEnergyInThisNode(double amount, double voltage) {
+ this.energy += amount;
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/CoilerContainer.java b/src/main/java/ihl/processing/metallurgy/CoilerContainer.java new file mode 100644 index 0000000..710a708 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerContainer.java @@ -0,0 +1,65 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class CoilerContainer extends ContainerBase<CoilerTileEntity> {
+
+ public CoilerTileEntity tileEntity;
+ private short lastEnergy = -1;
+ private final static int height=166;
+
+ public CoilerContainer(EntityPlayer entityPlayer,
+ CoilerTileEntity lathePart1TileEntity) {
+ super(lathePart1TileEntity);
+ tileEntity=lathePart1TileEntity;
+ 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(lathePart1TileEntity.output, 0, 69, 22));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.dischargeSlot,0, 22, 55));
+ }
+
+ @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.getEnergy() != this.lastEnergy)
+ {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy());
+ }
+ }
+ this.lastEnergy = (short) this.tileEntity.getEnergy();
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value)
+ {
+ super.updateProgressBar(index, value);
+
+ switch (index)
+ {
+ case 1:
+ this.tileEntity.setEnergy(value);
+ break;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/CoilerGui.java b/src/main/java/ihl/processing/metallurgy/CoilerGui.java new file mode 100644 index 0000000..b635506 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerGui.java @@ -0,0 +1,48 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+public class CoilerGui extends GuiContainer {
+
+ private CoilerContainer container;
+ protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUICoiler.png");
+
+ public CoilerGui(CoilerContainer latheContainer) {
+ super(latheContainer);
+ container = latheContainer;
+ }
+
+
+ @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);
+ fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("ihl.gui.coiler"), 40, 12, 16768125);
+ this.mc.renderEngine.bindTexture(tex);
+ int i1;
+ if (this.container.tileEntity.getEnergy() > 0D)
+ {
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12);
+ this.drawTexturedModalRect(39, 55 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.coiler.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(tex);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/CoilerModel.java b/src/main/java/ihl/processing/metallurgy/CoilerModel.java new file mode 100644 index 0000000..9c1721e --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerModel.java @@ -0,0 +1,103 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class CoilerModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + IHLModelRenderer CoilRotating; + IHLModelRenderer Coil; + + public CoilerModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("RotatingPart2.PipeN1", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.PipeN4", 0, 17); + setTextureOffset("RotatingPart2.PipeN14", 0, 19); + setTextureOffset("RotatingPart2.PipeN17", 0, 17); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 0, 0); + setTextureOffset("Belt2.Shape13", 0, 0); + setTextureOffset("CoilRotating.PipeN15", 22, 19); + setTextureOffset("Coil.Shape1", 22, 30); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape2", -5.5F, -1F, 7F, 5, 8, 1); + Base.addBox("Shape16", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN1", -0.5F, -0.5F, 0F, 1, 1, 14, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN4", -4F, -4F, 2F, 8, 8, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN14", -4F, -4F, 12F, 8, 8, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN17", -1F, -1F, 3F, 2, 2, 9, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0.5F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + CoilRotating = new IHLModelRenderer(this, "CoilRotating"); + CoilRotating.setRotationPoint(-3F, 18F, -7F); + setRotation(CoilRotating, 0F, 0F, 0F); + CoilRotating.mirror = true; + CoilRotating.addTube("PipeN15", -2F, -2F, 3F, 4, 4, 9, 0F,1F,ForgeDirection.NORTH); + Coil = new IHLModelRenderer(this, "Coil"); + Coil.setRotationPoint(-0.25F, 16F, 0F); + setRotation(Coil, 0F, 0F, -0.2F); + Coil.mirror = true; + Coil.addTube("Shape1", -8F, -0.25F, -0.5F, 5, 1, 1, 0F,1F,ForgeDirection.WEST); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/CoilerRender.java b/src/main/java/ihl/processing/metallurgy/CoilerRender.java new file mode 100644 index 0000000..26ee32f --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerRender.java @@ -0,0 +1,80 @@ +package ihl.processing.metallurgy;
+import org.lwjgl.opengl.GL11;
+
+import ic2.api.tile.IWrenchable;
+import ihl.IHLModInfo;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+
+public class CoilerRender extends TileEntitySpecialRenderer{
+private CoilerModel model = new CoilerModel();
+private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png");
+private final float scale=1F/16F;
+
+ public CoilerRender() {}
+
+
+ @Override
+ public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8)
+ {
+ int rotation = 0;
+ if(tile.getWorldObj() != null)
+ {
+ switch (((IWrenchable)tile).getFacing())
+ {
+ case 2:
+ rotation = 0;
+ break;
+ case 5:
+ rotation = 1;
+ break;
+ case 3:
+ rotation = 2;
+ break;
+ case 4:
+ rotation = 3;
+ break;
+ default:
+ rotation = 0;
+ }
+ }
+ else
+ {
+ return;
+ }
+ CoilerTileEntity cte = (CoilerTileEntity)tile;
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
+ GL11.glScalef(1.0F, -1F, -1F);
+ GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F);
+
+ bindTexture(tex);
+ model.Base.render(scale);
+ model.Belt.render(scale);
+ model.Belt2.render(scale);
+ if(cte.getActive())
+ {
+ model.Coil.render(scale);
+ model.CoilRotating.rotateAngleZ+=0.02F;
+ model.CoilRotating.render(scale);
+ model.RotatingPart2.rotateAngleZ+=0.02F;
+ model.MotorPart1.rotateAngleZ+=0.03F;
+ model.MotorPart1.render(scale);
+ model.MotorPart2.render(scale);
+ }
+ else
+ {
+
+ if(cte.hasCoil)
+ {
+ model.CoilRotating.render(scale);
+ }
+ model.MotorPart1.render(scale);
+ model.MotorPart2.render(scale);
+ }
+ model.RotatingPart2.render(scale);
+ GL11.glPopMatrix(); //end
+
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/CoilerTileEntity.java b/src/main/java/ihl/processing/metallurgy/CoilerTileEntity.java new file mode 100644 index 0000000..3853a0e --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CoilerTileEntity.java @@ -0,0 +1,155 @@ +package ihl.processing.metallurgy;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.interfaces.IWire;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+
+public class CoilerTileEntity extends BasicElectricMotorTileEntity implements IProductionLine{
+
+ public final InvSlotOutput output;
+ private int activeTimer=0;
+ public boolean hasCoil=false;
+
+ public CoilerTileEntity()
+ {
+ super();
+ this.output = new InvSlotOutput(this, "output", 1, 1);
+ }
+
+
+ @Override
+ public String getInventoryName() {
+ return "Coiler";
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ fields.add("hasCoil");
+ return fields;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player)
+ {
+ return IHLUtils.getThisModItemStack("coiler");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new CoilerGui(new CoilerContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player)
+ {
+ return new CoilerContainer(player, this);
+ }
+
+ @Override
+ public boolean canOperate()
+ {
+ return false;
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ if(activeTimer>0)
+ {
+ activeTimer--;
+ }
+ else
+ {
+ setActive(false);
+ }
+ if(this.output.isEmpty() && hasCoil==true)
+ {
+ this.hasCoil=false;
+ IC2.network.get().updateTileEntityField(this, "hasCoil");
+ }
+ else if(!this.output.isEmpty() && hasCoil==false)
+ {
+ this.hasCoil=true;
+ IC2.network.get().updateTileEntityField(this, "hasCoil");
+ }
+ }
+
+ @Override
+ public void operate()
+ {}
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public List[] getInput()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean canProcess(ItemStack cable) {
+ if(this.energy>1D && cable.getItem() instanceof IWire)
+ {
+ if(this.output.isEmpty())
+ {
+ return true;
+ }
+ else if(this.output.get().getItem() instanceof IWire)
+ {
+ return ((IWire)this.output.get().getItem()).isSameWire(this.output.get(), cable);
+ }
+ else
+ {
+ return this.output.get().isItemEqual(cable);
+ }
+ }
+ return false;
+ }
+
+
+ @Override
+ public void process(ItemStack cable) {
+ if(cable.getItem() instanceof IWire)
+ {
+ this.energy-=1D;
+ if(this.output.isEmpty())
+ {
+ setActive(true);
+ activeTimer=800;
+ this.output.put(cable);
+ this.hasCoil=true;
+ IC2.network.get().updateTileEntityField(this, "hasCoil");
+ }
+ else
+ {
+ setActive(true);
+ activeTimer=800;
+ int length = this.output.get().stackTagCompound.getInteger(((IWire)this.output.get().getItem()).getTag());
+ int fullLength = this.output.get().stackTagCompound.getInteger(((IWire)this.output.get().getItem()).getTagSecondary());
+ int lengthToAdd = cable.stackTagCompound.getInteger(((IWire)cable.getItem()).getTag());
+ int fullLengthToAdd = cable.stackTagCompound.getInteger(((IWire)cable.getItem()).getTagSecondary());
+ this.output.get().stackTagCompound.setInteger(((IWire)this.output.get().getItem()).getTag(), length+lengthToAdd);
+ this.output.get().stackTagCompound.setInteger(((IWire)this.output.get().getItem()).getTagSecondary(),fullLength+fullLengthToAdd);
+ }
+ }
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/Crucible.java b/src/main/java/ihl/processing/metallurgy/Crucible.java new file mode 100644 index 0000000..220b505 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/Crucible.java @@ -0,0 +1,366 @@ +package ihl.processing.metallurgy;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.IItemHudInfo;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputOreDict;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.item.IHandHeldInventory;
+import ic2.core.util.LiquidUtil;
+import ic2.core.util.StackUtil;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+import net.minecraftforge.fluids.IFluidHandler;
+
+public class Crucible extends Item implements IHandHeldInventory, IFluidContainerItem, IItemHudInfo{
+
+ public int capacity=864;
+ private String itemName;
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("crucible");
+
+ @SideOnly(Side.CLIENT)
+ private IIcon iconHot;
+
+ public Crucible() {
+ super();
+ this.itemName="crucible";
+ this.setUnlocalizedName(itemName);
+ GameRegistry.registerItem(this, this.itemName);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.maxStackSize=1;
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setMaxDamage(0);
+ }
+
+ public static void addRecipe(String string, FluidStack output)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, new IRecipeInput[] {new RecipeInputOreDict(string)}), new UniversalRecipeOutput(new FluidStack[] {output},null,20));
+ }
+
+ @Override
+ public IHasGui getInventory(EntityPlayer entityPlayer, ItemStack itemStack)
+ {
+ return new CrucibleInventory(entityPlayer, itemStack);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)
+ {
+ if (IC2.platform.isSimulating())
+ {
+ IC2.platform.launchGui(entityPlayer, this.getInventory(entityPlayer, itemStack));
+ }
+ return itemStack;
+ }
+
+ /**
+ * allows items to add custom lines of information to the mouseover description
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b)
+ {
+ super.addInformation(itemStack, player, info, b);
+ FluidStack fs = this.getFluid(itemStack);
+
+ if (fs != null)
+ {
+ info.add("< " + FluidRegistry.getFluidName(fs) + ", " + fs.amount + " mB >");
+ }
+ else
+ {
+ info.add(StatCollector.translateToLocal("ic2.item.FluidContainer.Empty"));
+ }
+ }
+
+ @Override
+ public List<String> getHudInfo(ItemStack itemStack)
+ {
+ LinkedList<String> info = new LinkedList<String>();
+ FluidStack fs = this.getFluid(itemStack);
+
+ if (fs != null)
+ {
+ info.add("< " + FluidRegistry.getFluidName(fs) + ", " + fs.amount + " mB >");
+ }
+ else
+ {
+ info.add(StatCollector.translateToLocal("ic2.item.FluidContainer.Empty"));
+ }
+
+ return info;
+ }
+
+ @Override
+ public FluidStack getFluid(ItemStack stack)
+ {
+ NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(stack);
+ NBTTagCompound fluidTag = nbtTagCompound.getCompoundTag("Fluid");
+ return FluidStack.loadFluidStackFromNBT(fluidTag);
+ }
+
+ public boolean isEmpty(ItemStack stack)
+ {
+ return this.getFluid(stack) == null;
+ }
+
+ @Override
+ public int getCapacity(ItemStack container)
+ {
+ return this.capacity;
+ }
+
+ public boolean canfill(Fluid var1)
+ {
+ return true;
+ }
+
+ public ItemStack processContent(ItemStack itemStack, IInventory inventoryContainer)
+ {
+ CrucibleInventory inventory = new CrucibleInventory(inventoryContainer, itemStack);
+ ItemStack content = inventory.getStackInSlot(0);
+ if(content!=null)
+ {
+ UniversalRecipeOutput routput = recipeManager.getOutputFor(null, Arrays.asList(new ItemStack [] {content}));
+ if(routput!=null && !routput.getFluidOutputs().isEmpty())
+ {
+ FluidStack fluidStack = routput.getFluidOutputs().get(0).copy();
+ fluidStack.amount *= content.stackSize;
+ itemStack.stackTagCompound = new NBTTagCompound();
+ this.fill(itemStack, fluidStack, true);
+ return itemStack;
+ }
+ }
+ return itemStack;
+ }
+
+ @Override
+ public int fill(ItemStack stack, FluidStack resource, boolean doFill)
+ {
+ if (stack.stackSize != 1)
+ {
+ return 0;
+ }
+ else if (resource == null)
+ {
+ return 0;
+ }
+ else if (!this.canfill(resource.getFluid()))
+ {
+ return 0;
+ }
+ else
+ {
+ NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(stack);
+ NBTTagCompound fluidTag = nbtTagCompound.getCompoundTag("Fluid");
+ FluidStack fs = FluidStack.loadFluidStackFromNBT(fluidTag);
+
+ if (fs == null)
+ {
+ fs = new FluidStack(resource, 0);
+ }
+
+ if (!fs.isFluidEqual(resource))
+ {
+ return 0;
+ }
+ else
+ {
+ int amount = Math.min(this.capacity - fs.amount, resource.amount);
+
+ if (doFill && amount > 0)
+ {
+ fs.amount += amount;
+ fs.writeToNBT(fluidTag);
+ nbtTagCompound.setTag("Fluid", fluidTag);
+ if(fs.getFluid().getTemperature()>900)stack.setItemDamage(1);
+ }
+
+ return amount;
+ }
+ }
+ }
+
+ @Override
+ public FluidStack drain(ItemStack stack, int maxDrain, boolean doDrain)
+ {
+ if (stack.stackSize != 1)
+ {
+ return null;
+ }
+ else
+ {
+ NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(stack);
+ NBTTagCompound fluidTag = nbtTagCompound.getCompoundTag("Fluid");
+ FluidStack fs = FluidStack.loadFluidStackFromNBT(fluidTag);
+
+ if (fs == null)
+ {
+ return null;
+ }
+ else
+ {
+ maxDrain = Math.min(fs.amount, maxDrain);
+
+ if (doDrain)
+ {
+ fs.amount -= maxDrain;
+
+ if (fs.amount <= 0)
+ {
+ nbtTagCompound.removeTag("Fluid");
+ stack.setItemDamage(0);
+ }
+ else
+ {
+ fs.writeToNBT(fluidTag);
+ nbtTagCompound.setTag("Fluid", fluidTag);
+ }
+ }
+
+ return new FluidStack(fs, maxDrain);
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register)
+ {
+ itemIcon=register.registerIcon(IHLModInfo.MODID + ":crucible");
+ iconHot=register.registerIcon(IHLModInfo.MODID + ":crucibleHot");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int meta)
+ {
+ switch(meta)
+ {
+ case 0:
+ return this.itemIcon;
+ case 1:
+ return this.iconHot;
+ default:
+ return this.itemIcon;
+ }
+ }
+
+ @Override
+ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset)
+ {
+ if (!IC2.platform.isSimulating())
+ {
+ return false;
+ }
+ else if (this.interactWithTank(stack, player, world, x, y, z, side))
+ {
+ return true;
+ }
+ return false;
+ }
+
+
+ private boolean interactWithTank(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side)
+ {
+ if (!IC2.platform.isSimulating())
+ {
+ return false;
+ }
+ else
+ {
+ TileEntity te = world.getTileEntity(x, y, z);
+
+ if (!(te instanceof IFluidHandler))
+ {
+ return false;
+ }
+ else
+ {
+ IFluidHandler handler = (IFluidHandler)te;
+ ForgeDirection dir = ForgeDirection.getOrientation(side);
+ FluidStack fs = this.getFluid(stack);
+ int amount;
+
+ if (fs != null && (!player.isSneaking() || fs.amount >= this.capacity))
+ {
+ amount = handler.fill(dir, fs, false);
+
+ if (amount <= 0)
+ {
+ return false;
+ }
+ else
+ {
+ fs = LiquidUtil.drainContainerStack(stack, player, amount, false);
+
+ if (fs != null && fs.amount > 0)
+ {
+ handler.fill(dir, fs, true);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ else
+ {
+ amount = fs == null ? this.capacity : this.capacity - fs.amount;
+ FluidStack input = handler.drain(dir, amount, false);
+
+ if (input != null && input.amount > 0)
+ {
+ amount = LiquidUtil.fillContainerStack(stack, player, input, false);
+
+ if (amount <= 0)
+ {
+ return false;
+ }
+ else
+ {
+ handler.drain(dir, amount, true);
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/CrucibleContainer.java b/src/main/java/ihl/processing/metallurgy/CrucibleContainer.java new file mode 100644 index 0000000..20ec65e --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CrucibleContainer.java @@ -0,0 +1,66 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.util.StackUtil;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class CrucibleContainer extends ContainerBase<CrucibleInventory>
+{
+ public CrucibleInventory box;
+ public CrucibleContainer(EntityPlayer entityPlayer, CrucibleInventory box)
+ {
+ super(box);
+ this.box = box;
+ int col;
+ if(((Crucible)this.box.thisItemStack.getItem()).isEmpty(this.box.thisItemStack))
+ {
+ this.addSlotToContainer(new CrucibleSlot(this.box, 0, 81, 42));
+ }
+ 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, 84 + col * 18));
+ }
+ }
+
+ for (col = 0; col < 9; ++col)
+ {
+ this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 8 + col * 18, 142));
+ }
+ }
+
+ @Override
+ public ItemStack slotClick(int slot, int button, int par3, EntityPlayer player)
+ {
+ if (player instanceof EntityPlayerMP && IC2.platform.isSimulating() && slot == -999 && (button == 0 || button == 1))
+ {
+ ItemStack stack = player.inventory.getItemStack();
+
+ if (stack != null)
+ {
+ StackUtil.getOrCreateNbtData(stack);
+
+ if (this.box.isThisContainer(stack))
+ {
+ ((EntityPlayerMP)player).closeScreen();
+ }
+ }
+ }
+ return super.slotClick(slot, button, par3, player);
+ }
+
+ /**
+ * Called when the container is closed.
+ */
+ @Override
+ public void onContainerClosed(EntityPlayer entityPlayer)
+ {
+ this.box.onGuiClosed(entityPlayer);
+ super.onContainerClosed(entityPlayer);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/CrucibleGui.java b/src/main/java/ihl/processing/metallurgy/CrucibleGui.java new file mode 100644 index 0000000..f05e7bb --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CrucibleGui.java @@ -0,0 +1,84 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import ic2.core.util.DrawUtil;
+import ic2.core.util.GuiTooltipHelper;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+public class CrucibleGui extends GuiContainer
+{
+ public CrucibleContainer container;
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUICrucible.png");
+ private static final String title = StatCollector.translateToLocal("item.crucible.name");
+
+ public CrucibleGui(CrucibleContainer container1)
+ {
+ super(container1);
+ this.container = container1;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ fontRendererObj.drawString(title, 68, 0, 6171880);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ }
+
+ @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);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.mc.renderEngine.bindTexture(background);
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ if(this.getItemStack().getItemDamage()==1)
+ {
+ this.drawTexturedModalRect(x+67, y+26, 198, 52, 58, 39);
+ }
+ FluidStack fluidStack = this.getItemInstance().getFluid(this.getItemStack());
+ if (fluidStack!=null && fluidStack.amount > 0)
+ {
+ Fluid fluid = fluidStack.getFluid();
+ if(fluid!=null)
+ {
+ IIcon fluidIcon = fluid.getIcon();
+ if (fluidIcon != null)
+ {
+ this.mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
+ int liquidHeight = fluidStack.amount*20/getItemInstance().capacity;
+ DrawUtil.drawRepeated(fluidIcon, x+71, y+ 41 + 20 - liquidHeight, 35.0D, liquidHeight, this.zLevel);
+ }
+ }
+ String tooltip = StatCollector.translateToLocal(fluidStack.getFluid().getName()) + ": " + fluidStack.amount + "mB";
+ GuiTooltipHelper.drawAreaTooltip(par2, par3, tooltip, x-16, y+10, x+16, y+29);
+ }
+ this.mc.renderEngine.bindTexture(background);
+ if(this.getItemStack().getItemDamage()==1)
+ {
+ this.drawTexturedModalRect(x+68, y+40, 198, 26, 58, 26);
+ }
+ else
+ {
+ this.drawTexturedModalRect(x+68, y+40, 198, 0, 58, 26);
+ }
+ }
+
+ private Crucible getItemInstance()
+ {
+ return ((Crucible)this.container.box.thisItemStack.getItem());
+ }
+
+ private ItemStack getItemStack()
+ {
+ return this.container.box.thisItemStack;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/CrucibleInventory.java b/src/main/java/ihl/processing/metallurgy/CrucibleInventory.java new file mode 100644 index 0000000..253483f --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CrucibleInventory.java @@ -0,0 +1,126 @@ +package ihl.processing.metallurgy;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.item.tool.HandHeldInventory;
+import ic2.core.util.StackUtil;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class CrucibleInventory extends HandHeldInventory {
+
+ ItemStack thisItemStack;
+ IInventory inventoryContainer;
+
+ public CrucibleInventory(EntityPlayer player, ItemStack stack) {
+ super(player, stack, 1);
+ thisItemStack = stack;
+ inventoryContainer = player.inventory;
+ }
+
+ public CrucibleInventory(IInventory inventoryContainer1, ItemStack stack) {
+ super(null, stack, 1);
+ thisItemStack = stack;
+ inventoryContainer = inventoryContainer1;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new CrucibleGui(new CrucibleContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new CrucibleContainer(player, this);
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "crucible";
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return false;
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int arg0, ItemStack stack) {
+ return true;
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 6;
+ }
+
+ @Override
+ public void save() {
+ if (IC2.platform.isSimulating()) {
+ NBTTagCompound nbtTagCompound = StackUtil.getOrCreateNbtData(this.thisItemStack);
+
+ for (int nbtTagList = 0; nbtTagList < this.getSizeInventory(); ++nbtTagList) {
+ if (this.inventory[nbtTagList] != null) {
+ NBTTagCompound i = StackUtil.getOrCreateNbtData(this.inventory[nbtTagList]);
+
+ if (nbtTagCompound.getInteger("uid") == i.getInteger("uid")) {
+ this.thisItemStack.stackSize = 1;
+ this.inventory[nbtTagList] = null;
+ break;
+ }
+ }
+ }
+
+ NBTTagList var7 = new NBTTagList();
+ int var8;
+
+ for (var8 = 0; var8 < this.inventory.length; ++var8) {
+ if (this.inventory[var8] != null) {
+ NBTTagCompound itemStackSlot = new NBTTagCompound();
+ itemStackSlot.setByte("Slot", (byte) var8);
+ this.inventory[var8].writeToNBT(itemStackSlot);
+ var7.appendTag(itemStackSlot);
+ }
+ }
+
+ nbtTagCompound.setTag("Items", var7);
+
+ for (var8 = -1; var8 < inventoryContainer.getSizeInventory(); ++var8) {
+ ItemStack var9 = null;
+
+ if (var8 == -1 && inventoryContainer instanceof InventoryPlayer) {
+ var9 = ((InventoryPlayer) inventoryContainer).getItemStack();
+ } else if (var8 >= 0) {
+ var9 = inventoryContainer.getStackInSlot(var8);
+ }
+
+ if (var9 != null) {
+ NBTTagCompound nbtTagCompoundSlot = var9.getTagCompound();
+
+ if (nbtTagCompoundSlot != null
+ && nbtTagCompound.getInteger("uid") == nbtTagCompoundSlot.getInteger("uid")) {
+ this.thisItemStack.stackSize = 1;
+
+ if (var8 == -1 && inventoryContainer instanceof InventoryPlayer) {
+ ((InventoryPlayer) inventoryContainer).setItemStack(this.thisItemStack);
+ } else {
+ inventoryContainer.setInventorySlotContents(var8, this.thisItemStack);
+ }
+
+ break;
+ }
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/CrucibleSlot.java b/src/main/java/ihl/processing/metallurgy/CrucibleSlot.java new file mode 100644 index 0000000..5fc6a33 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/CrucibleSlot.java @@ -0,0 +1,18 @@ +package ihl.processing.metallurgy;
+
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class CrucibleSlot extends Slot {
+ CrucibleInventory inventory;
+
+ public CrucibleSlot(CrucibleInventory arg0, int arg1, int arg2, int arg3) {
+ super(arg0, arg1, arg2, arg3);
+ inventory = arg0;
+ }
+
+ @Override
+ public boolean isItemValid(ItemStack itemstack) {
+ return itemstack != null;
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java new file mode 100644 index 0000000..94d479c --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineContainer.java @@ -0,0 +1,39 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Slot;
+
+public class DetonationSprayingMachineContainer extends ContainerBase<DetonationSprayingMachineTileEntity> {
+
+ protected DetonationSprayingMachineTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public short lastProgress = -1;
+ private final static int height=166;
+
+ public DetonationSprayingMachineContainer(EntityPlayer entityPlayer, DetonationSprayingMachineTileEntity detonationSprayingMachineTileEntity){
+ super(detonationSprayingMachineTileEntity);
+ this.tileEntity = detonationSprayingMachineTileEntity;
+ 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(detonationSprayingMachineTileEntity.input, 0, 10, 17));
+ this.addSlotToContainer(new SlotInvSlot(detonationSprayingMachineTileEntity.input, 1, 98, 17));
+ this.addSlotToContainer(new SlotInvSlot(detonationSprayingMachineTileEntity.input, 2, 117, 17));
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineGui.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineGui.java new file mode 100644 index 0000000..8cd29d0 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineGui.java @@ -0,0 +1,48 @@ +package ihl.processing.metallurgy;
+
+import java.util.Iterator;
+
+import org.lwjgl.opengl.GL11;
+
+import codechicken.lib.gui.GuiDraw;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+@SideOnly(Side.CLIENT)
+public class DetonationSprayingMachineGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDetonationSprayingMachine.png");
+ private static final String hint = StatCollector.translateToLocal("ihl.dsmhint");
+
+ public DetonationSprayingMachineGui (DetonationSprayingMachineContainer detonationSprayingMachineContainer) {
+ //the container is instanciated and passed to the superclass for handling
+ super(detonationSprayingMachineContainer);
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(background);
+ }
+
+ @SuppressWarnings("unchecked")
+ @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);
+ Iterator<String> noteListIterator = this.mc.fontRenderer.listFormattedStringToWidth(hint, 140).iterator();
+ int yTextPos=40;
+ while(noteListIterator.hasNext())
+ {
+ GuiDraw.fontRenderer.drawStringWithShadow(noteListIterator.next(), x+15, y+yTextPos, 16777215);
+ yTextPos+=10;
+ }
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineModel.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineModel.java new file mode 100644 index 0000000..7335125 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineModel.java @@ -0,0 +1,57 @@ +package ihl.processing.metallurgy;
+
+import ihl.model.IHLModelRenderer;
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.entity.Entity;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class DetonationSprayingMachineModel extends ModelBase {
+ //fields
+ IHLModelRenderer Base;
+
+ public DetonationSprayingMachineModel()
+ {
+ textureWidth = 64;
+ textureHeight = 32;
+ setTextureOffset("Base.Shape1", 20, 0);
+ setTextureOffset("Base.Shape2", 34, 0);
+ setTextureOffset("Base.Shape3", 23, 0);
+ setTextureOffset("Base.Shape4", 23, 0);
+ setTextureOffset("Base.Shape5", 0, 0);
+ setTextureOffset("Base.Tube1", 0, 0);
+ setTextureOffset("Base.Tube2", 0, 0);
+ setTextureOffset("Base.Shape12", 0, 20);
+ setTextureOffset("Base.Shape13", 0, 20);
+ setTextureOffset("Base.Shape14", 0, 20);
+ setTextureOffset("Base.Shape7", 26, 22);
+ setTextureOffset("Base.Shape8", 18, 19);
+ setTextureOffset("Base.Shape9", 18, 22);
+ setTextureOffset("Base.Tube11", 8, 5);
+
+ Base = new IHLModelRenderer(this, "Base");
+ Base.setRotationPoint(0F, 8F, 0F);
+ Base.mirror = true;
+ Base.addBox("Shape1", 4F, 6F, 7F, 2, 9, 1, false);
+ Base.addBox("Shape2", -7F, 4F, 6F, 14, 11, 1, false);
+ Base.addBox("Shape3", -1F, 6F, 7F, 2, 9, 1, false);
+ Base.addBox("Shape4", -6F, 6F, 7F, 2, 9, 1, false);
+ Base.addBox("Shape5", -8F, 15F, -8F, 16, 1, 16, false);
+ Base.addTube("Tube1", -1F, 10F, -7F, 2, 2, 6, 0.5F,1F,ForgeDirection.NORTH);
+ Base.addTube("Tube2", -2.5F, 10.5F, -6F, 5, 1, 1, 0F,1F,ForgeDirection.EAST);
+ Base.addBox("Shape12", -2.5F, 11.7F, -2.2F, 5, 4, 1, false);
+ Base.addBox("Shape13", 1F, 9F, -8F, 1, 6, 6, false);
+ Base.addBox("Shape14", -2F, 9F, -8F, 1, 6, 6, false);
+ Base.addBox("Shape7", -1F, 14F, -8F, 2, 1, 5, false);
+ Base.addBox("Shape8", 2F, 14F, -8F, 2, 1, 9, false);
+ Base.addBox("Shape9", -4F, 14F, -8F, 2, 1, 9, false);
+ Base.addTube("Tube11", -1F, 10F, -8F, 2, 2, 1, 0F,1F,ForgeDirection.NORTH);
+ }
+
+ @Override
+ public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)
+ {
+ super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
+ }
+}
+
+
diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineRender.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineRender.java new file mode 100644 index 0000000..b68f8b3 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineRender.java @@ -0,0 +1,61 @@ +package ihl.processing.metallurgy;
+import org.lwjgl.opengl.GL11;
+
+import ic2.api.tile.IWrenchable;
+import ihl.IHLModInfo;
+import ihl.utils.IHLItemRenderer;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+
+public class DetonationSprayingMachineRender extends TileEntitySpecialRenderer{
+private DetonationSprayingMachineModel model = new DetonationSprayingMachineModel();
+private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/detonationSprayingMachine.png");
+private final float scale=1F/16F;
+private IHLItemRenderer itemRenderer=new IHLItemRenderer(true);
+
+public DetonationSprayingMachineRender(){}
+
+public void renderAModelAt(DetonationSprayingMachineTileEntity tile, double x, double y, double z, float f) {
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float)x + 0.5F, (float)y+0.5F, (float)z + 0.5F);
+ int rotation = 0;
+ if(tile.getWorldObj() != null)
+ {
+ switch (((IWrenchable)tile).getFacing())
+ {
+ case 2:
+ rotation = 0;
+ break;
+ case 5:
+ rotation = 1;
+ break;
+ case 3:
+ rotation = 2;
+ break;
+ case 4:
+ rotation = 3;
+ break;
+ default:
+ rotation = 0;
+ }
+ }
+ GL11.glRotatef(-rotation*90f, 0F, 1F, 0F);
+ if(tile.input.get()!=null)
+ {
+ this.itemRenderer.doRender(RenderManager.instance,tile.input.get(),0F,-0.2F,-0.35F);
+ }
+ bindTexture(tex); //texture
+ GL11.glScalef(1F, -1F, -1F);
+ GL11.glTranslatef(0F, -1.0F, 0F);
+ model.Base.render(scale);
+ GL11.glPopMatrix();
+}
+
+ @Override
+ public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
+ {
+ this.renderAModelAt((DetonationSprayingMachineTileEntity)par1TileEntity, par2, par4, par6, par8);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java new file mode 100644 index 0000000..411b8db --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/DetonationSprayingMachineTileEntity.java @@ -0,0 +1,198 @@ +package ihl.processing.metallurgy;
+
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.network.INetworkTileEntityEventListener;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeInputOreDict;
+import ic2.core.ContainerBase;
+import ic2.core.ExplosionIC2;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.audio.AudioSource;
+import ic2.core.audio.PositionSpec;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot.Access;
+import ihl.processing.chemistry.ApparatusProcessableInvSlot;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class DetonationSprayingMachineTileEntity extends TileEntityInventory implements IHasGui, INetworkTileEntityEventListener
+{
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("detonationsprayingmachine");
+ public final ApparatusProcessableInvSlot input;
+ private AudioSource explosion;
+
+ public DetonationSprayingMachineTileEntity() {
+ super();
+ this.input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, 3, 64);
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ return fields;
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return false;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("cannonBronze");
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "detonationSprayingMachine";
+ }
+
+ @Override
+ public void onNetworkEvent(int event)
+ {
+ worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.explode", 4.0F, 1.0F);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new DetonationSprayingMachineGui(new DetonationSprayingMachineContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new DetonationSprayingMachineContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {}
+
+ public boolean canOperate()
+ {
+ return getOutput()!=null;
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ return DetonationSprayingMachineTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ public List<?>[] getInput()
+ {
+ return new List[] {null,this.input.getItemStackList()};
+ }
+
+ @Override
+ public void onLoaded()
+ {
+ super.onLoaded();
+ if (IC2.platform.isRendering() && this.explosion==null)
+ {
+ this.explosion = IC2.audioManager.createSource(this, PositionSpec.Center, "Machines/MinerOp.ogg",false,false, 0.5F);
+ }
+ }
+
+
+ public void operate()
+ {//diamond file max durability - 128000
+ //file tags - "GT.ToolStats"->"MaxDamage" & "Damage"
+ if(this.canOperate())
+ {
+ List<IRecipeInput> input1 = DetonationSprayingMachineTileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs();
+ List<RecipeOutputItemStack> output1 = DetonationSprayingMachineTileEntity.recipeManager.getOutputFor(getInput()).getItemOutputs();
+ ItemStack resultStack = output1.get(0).itemStack.copy();
+ resultStack.stackSize=this.input.get(0).stackSize;
+ if(resultStack.stackTagCompound==null)
+ {
+ resultStack.stackTagCompound=this.input.get(0).stackTagCompound;
+ }
+ if(resultStack.stackTagCompound!=null && resultStack.stackTagCompound.hasKey("GT.ToolStats"))
+ {
+ NBTTagCompound gtTagCompound = resultStack.stackTagCompound.getCompoundTag("GT.ToolStats");
+ if(gtTagCompound!=null && gtTagCompound.hasKey("MaxDamage"))
+ {
+ int maxDamage = gtTagCompound.getInteger("MaxDamage");
+ int damage = 0;
+ if(gtTagCompound.hasKey("Damage"))
+ {
+ damage = gtTagCompound.getInteger("Damage");
+ }
+ if(damage<maxDamage-400)
+ {
+ damage+=400;
+ if(maxDamage<128000)
+ {
+ int dd = (128000-maxDamage)*3/4;
+ maxDamage+=dd;
+ }
+ gtTagCompound.setInteger("Damage",damage);
+ gtTagCompound.setInteger("MaxDamage",maxDamage);
+ resultStack.stackTagCompound.setTag("GT.ToolStats", gtTagCompound);
+ }
+ else
+ {
+ resultStack=null;
+ }
+ }
+ }
+ for(IRecipeInput stack:input1){
+ this.input.consume(stack);
+ }
+ this.input.put(0,resultStack);
+ ExplosionIC2 explosion = new ExplosionIC2(worldObj, null, this.xCoord+0.5D, this.yCoord+0.5D, this.zCoord+0.5D, 0.5F, 0.3F, ExplosionIC2.Type.Normal, null, 0);
+ explosion.doExplosion();
+ IC2.network.get().initiateTileEntityEvent(this, 0, true);
+ }
+ }
+
+ public static void addRecipe(ItemStack input, ItemStack output)
+ {
+ IRecipeInput[] dsmInputs1 = new IRecipeInput[3];
+ dsmInputs1[0]=new RecipeInputItemStack(input);
+ dsmInputs1[1]=new RecipeInputOreDict("dustDiamond");
+ dsmInputs1[2]=new RecipeInputOreDict("dustGunpowder");
+ recipeManager.addRecipe(new UniversalRecipeInput(null, dsmInputs1), new UniversalRecipeOutput(null,new ItemStack[] {output},1));
+ }
+
+ public static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output)
+ {
+ recipeManager.addRecipe(input, output);
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/ElectricEngineItem.java b/src/main/java/ihl/processing/metallurgy/ElectricEngineItem.java new file mode 100644 index 0000000..c1e0003 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ElectricEngineItem.java @@ -0,0 +1,84 @@ +package ihl.processing.metallurgy;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.item.Item;
+import net.minecraft.util.IIcon;
+
+public class ElectricEngineItem extends Item{
+
+ public Type type;
+ public static List<ElectricEngineItem> instances = new ArrayList<ElectricEngineItem> ();
+ private static Map<Type, IIcon> iconMap = new HashMap<Type, IIcon>();
+
+
+ public ElectricEngineItem(Type type1)
+ {
+ super();
+ this.type=type1;
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setUnlocalizedName(type.unLocalizedName);
+ this.setMaxStackSize(1);
+ instances.add(this);
+ }
+
+ public static void init()
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ new ElectricEngineItem(var1[i]);
+ }
+ Iterator<ElectricEngineItem> ii = instances.iterator();
+ while(ii.hasNext())
+ {
+ ElectricEngineItem instance = ii.next();
+ GameRegistry.registerItem(instance,instance.type.unLocalizedName);
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister register)
+ {
+ iconMap.put(this.type, register.registerIcon(IHLModInfo.MODID + ":"+this.type.unLocalizedName));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int i)
+ {
+ return iconMap.get(type);
+ }
+
+
+ public enum Type
+ {
+ LVLEElectricEngine("electricMotorLVLEDC", 600,400,0.2F,1500);
+ Type(String unlocalizedName1, int maxVoltage1, int generatedVoltage1, float efficiency1,int rpm1)
+ {
+ unLocalizedName=unlocalizedName1;
+ maxVoltage=maxVoltage1;
+ generatedVoltage=generatedVoltage1;
+ efficiency=efficiency1;
+ rpm=rpm1;
+ }
+
+ public String unLocalizedName;
+ public int maxVoltage=600;
+ public int generatedVoltage=400;
+ public float efficiency = 0.2F;
+ public int rpm=1500;//at max voltage
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/ExtruderContainer.java b/src/main/java/ihl/processing/metallurgy/ExtruderContainer.java new file mode 100644 index 0000000..77b92e6 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ExtruderContainer.java @@ -0,0 +1,75 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class ExtruderContainer extends ContainerBase<ExtruderTileEntity> {
+
+ public ExtruderTileEntity tileEntity;
+ public int lastProgress = -1;
+ private short lastEnergy = -1;
+ private final static int height=166;
+
+ public ExtruderContainer(EntityPlayer entityPlayer,
+ ExtruderTileEntity lathePart1TileEntity) {
+ super(lathePart1TileEntity);
+ tileEntity=lathePart1TileEntity;
+ 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(lathePart1TileEntity.input, 0, 39, 32));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input2, 0, 57, 32));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.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.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+ if (this.tileEntity.getEnergy() != this.lastEnergy)
+ {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy());
+ }
+ }
+ this.lastProgress = this.tileEntity.progress;
+ this.lastEnergy = (short) this.tileEntity.getEnergy();
+ }
+
+ @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.setEnergy(value);
+ break;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/ExtruderGui.java b/src/main/java/ihl/processing/metallurgy/ExtruderGui.java new file mode 100644 index 0000000..acf1a76 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ExtruderGui.java @@ -0,0 +1,49 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+public class ExtruderGui extends GuiContainer {
+
+ private ExtruderContainer container;
+ protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIExtruder.png");
+
+ public ExtruderGui(ExtruderContainer latheContainer) {
+ super(latheContainer);
+ container = latheContainer;
+ }
+
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(tex);
+ 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);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F);
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12);
+ this.drawTexturedModalRect(9, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18);
+ this.drawTexturedModalRect(74, 34, 198, 0, i1 + 1, 13);
+ }
+ }
+
+ @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(tex);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/ExtruderModel.java b/src/main/java/ihl/processing/metallurgy/ExtruderModel.java new file mode 100644 index 0000000..fcff405 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ExtruderModel.java @@ -0,0 +1,100 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class ExtruderModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + IHLModelRenderer Extruder; + + public ExtruderModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.PipeN4", 0, 7); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 0, 0); + setTextureOffset("Belt2.Shape13", 0, 0); + setTextureOffset("Extruder.PipeN16", 0, 0); + setTextureOffset("Extruder.PipeN15", 24, 20); + setTextureOffset("Extruder.Shape8", 0, 0); + setTextureOffset("Extruder.PipeU17", 0, 0); + setTextureOffset("Extruder.PipeUC18", 0, 0); + setTextureOffset("Extruder.Shape14", 0, 0); + setTextureOffset("Extruder.PipeN14", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape16", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN4", -1F, -1F, 1F, 2, 2, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0.5F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + Extruder = new IHLModelRenderer(this, "Extruder"); + Extruder.setRotationPoint(0F, 16F, 0F); + setRotation(Extruder, 0F, 0F, 0F); + Extruder.mirror = true; + Extruder.addTube("PipeN16", -4.5F, 0.5F, -5F, 3, 3, 12, 0F,1F,ForgeDirection.NORTH); + Extruder.addTube("PipeN15", -5.5F, -0.5F, 0F, 5, 5, 7, 0.5F,1F,ForgeDirection.NORTH); + Extruder.addBox("Shape8", -5F, 4F, 6.9F, 4, 3, 1); + Extruder.addTube("PipeU17", -5.5F, -8F, -5F, 5, 8, 5, 0.8F,1F,ForgeDirection.UP); + Extruder.addTube("PipeUC18", -5.5F, 0F, -5F, 5, 2, 5, 0.8F,0.6F,ForgeDirection.UP); + Extruder.addBox("Shape14", -5F, 3F, -4.9F, 4, 4, 1); + Extruder.addTube("PipeN14", -5.5F, -0.5F, 7F, 5, 5, 1, 0.5F,1F,ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/ExtruderTileEntity.java b/src/main/java/ihl/processing/metallurgy/ExtruderTileEntity.java new file mode 100644 index 0000000..a46ae62 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ExtruderTileEntity.java @@ -0,0 +1,155 @@ +package ihl.processing.metallurgy;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.ContainerBase;
+import ic2.core.block.invslot.InvSlot.Access;
+import ihl.processing.chemistry.ApparatusProcessableInvSlot;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+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.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTank;
+import net.minecraftforge.fluids.IFluidHandler;
+
+public class ExtruderTileEntity extends BasicElectricMotorTileEntity{
+
+ public final ApparatusProcessableInvSlot input;
+ public final ApparatusProcessableInvSlot input2;
+ private int processTimer=0;
+ private FluidTank fluidTank = new FluidTank(1000);
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("extruder");
+
+ public ExtruderTileEntity()
+ {
+ super();
+ input = new ApparatusProcessableInvSlot(this, "input", 1, Access.IO, 1, 64);
+ input2 = new ApparatusProcessableInvSlot(this, "input2", 2, Access.IO, 1, 64);
+ }
+
+
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ return super.getNetworkedFields();
+ }
+
+
+ @Override
+ public String getInventoryName() {
+ return "Extruder";
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ ForgeDirection dir = ForgeDirection.getOrientation(getFacing());
+ TileEntity te = worldObj.getTileEntity(xCoord+dir.offsetX,yCoord+dir.offsetY,zCoord+dir.offsetZ);
+ if(checkCorrectAccembly() && this.fluidTank.getFluidAmount()>0 && this.processTimer++>20)
+ {
+ this.processTimer=0;
+ ((IFluidHandler)te).fill(ForgeDirection.getOrientation(getFacing()), this.fluidTank.drain(this.fluidTank.getCapacity(), true), true);
+ }
+
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player)
+ {
+ return IHLUtils.getThisModItemStack("extruder");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new ExtruderGui(new ExtruderContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new ExtruderContainer(player, this);
+ }
+
+ @Override
+ public void operate()
+ {
+ UniversalRecipeInput ri = ExtruderTileEntity.recipeManager.getRecipeInput(getInput());
+ this.fluidTank.fill(getOutput().getFluidOutputs().get(0), true);
+ this.input.consume(ri.getItemInputs().get(0));
+ this.input2.consume(ri.getItemInputs().get(1));
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ return ExtruderTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public List[] getInput()
+ {
+ return new List[]{null,Arrays.asList(new ItemStack[] {input.get(),input2.get()})};
+ }
+
+ @Override
+ public boolean canOperate()
+ {
+ return this.fluidTank.getFluidAmount()<this.fluidTank.getCapacity() && this.getOutput()!=null && checkCorrectAccembly();
+ }
+
+ private boolean checkCorrectAccembly()
+ {
+ TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ);
+ return te instanceof IFluidHandler && ((IFluidHandler)te).canFill(ForgeDirection.getOrientation(getFacing()), FluidRegistry.getFluid("molten.rubberwithsulfur"));
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {}
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ }
+
+ public static void addRecipe(ItemStack input, ItemStack input2, FluidStack output)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, new ItemStack[] {input,input2}), new UniversalRecipeOutput(new FluidStack [] {output},null,20));
+ }
+
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/GasWeldingStationContainer.java b/src/main/java/ihl/processing/metallurgy/GasWeldingStationContainer.java new file mode 100644 index 0000000..e960edb --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/GasWeldingStationContainer.java @@ -0,0 +1,99 @@ +package ihl.processing.metallurgy;
+
+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 GasWeldingStationContainer extends ContainerBase<GasWeldingStationTileEntity> {
+
+ protected GasWeldingStationTileEntity tileEntity;
+ public short lastProgress2 = -1;
+ private final static int height=166;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public int lastFluidAmount2 = -1;
+ public int lastNumberOfFluids2 = -1;
+ public List<FluidStack> fluidTankFluidList;
+ public List<FluidStack> fluidTankFluidList2;
+
+ public GasWeldingStationContainer(EntityPlayer entityPlayer, GasWeldingStationTileEntity weldingStation){
+ super(weldingStation);
+ this.tileEntity = weldingStation;
+ fluidTankFluidList = this.tileEntity.flammableGasTank.getFluidList();
+ fluidTankFluidList2 = this.tileEntity.oxygenTank.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(tileEntity.drainInputSlotOxygen, 0, 8, 15));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.drainInputSlotFlammableGas, 0, 44, 15));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.fillInputSlotOxygen, 0, 8, 51));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.fillInputSlotFlammableGas, 0, 44, 51));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.emptyFluidItemsSlot, 0, 8, 33));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.emptyFluidItemsSlot, 1, 44, 33));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.input, 0, 62, 51));
+ }
+
+ @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.progress2 != this.lastProgress2)
+ {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.progress2);
+ }
+ if (this.tileEntity.flammableGasTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.flammableGasTank.getNumberOfFluids() != this.lastNumberOfFluids)
+ {
+
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ }
+
+ if (this.tileEntity.oxygenTank.getFluidAmount() != this.lastFluidAmount2 || this.tileEntity.oxygenTank.getNumberOfFluids() != this.lastNumberOfFluids2)
+ {
+
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList2");
+ }
+ }
+
+
+ this.lastProgress2 = this.tileEntity.progress2;
+ this.lastNumberOfFluids = this.tileEntity.flammableGasTank.getNumberOfFluids();
+ this.lastFluidAmount = this.tileEntity.flammableGasTank.getFluidAmount();
+ this.lastNumberOfFluids2 = this.tileEntity.oxygenTank.getNumberOfFluids();
+ this.lastFluidAmount2 = this.tileEntity.oxygenTank.getFluidAmount();
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value)
+ {
+ super.updateProgressBar(index, value);
+ switch (index)
+ {
+ case 1:
+ this.tileEntity.progress2=(short) value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/GasWeldingStationGui.java b/src/main/java/ihl/processing/metallurgy/GasWeldingStationGui.java new file mode 100644 index 0000000..79becd5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/GasWeldingStationGui.java @@ -0,0 +1,78 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.IC2;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class GasWeldingStationGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIGasWeldingStation.png");
+ private GasWeldingStationContainer container;
+ private int outputslotoffset=45;
+
+ public GasWeldingStationGui (GasWeldingStationContainer detonationSprayingMachineContainer) {
+ //the container is instanciated and passed to the superclass for handling
+ super(detonationSprayingMachineContainer);
+ this.container=detonationSprayingMachineContainer;
+ }
+
+ @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.progress2 > 0)
+ {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27);
+ this.drawTexturedModalRect(90, 30, getFrameX(i1), getFrameY(i1),24,24);
+ }
+ if (this.container.tileEntity.flammableGasTank.getFluid()!=null && this.container.tileEntity.flammableGasTank.getFluidAmount() > 0)
+ {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.flammableGasTank, 64, 28, 76, 67, zLevel, par1, par2, xOffset, yOffset);
+ }
+ if (this.container.tileEntity.oxygenTank.getFluid()!=null && this.container.tileEntity.oxygenTank.getFluidAmount() > 0)
+ {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.oxygenTank, 28, 28, 40, 67, zLevel, par1, par2, xOffset, yOffset);
+ }
+
+ }
+
+ @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
+ public void handleMouseClick(Slot slot,int arg1,int arg2,int arg3)
+ {
+ if(slot!=null && slot.slotNumber>=outputslotoffset && slot.slotNumber<outputslotoffset+8)
+ {
+ IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, slot.slotNumber-outputslotoffset+1);
+ }
+ super.handleMouseClick(slot, arg1, arg2, arg3);
+ }
+
+ private int getFrameY(int number)
+ {
+ return (number % 10) * 24 + 14;
+ }
+
+ private int getFrameX(int number)
+ {
+ return (number / 10) * 24 + 176;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/GasWeldingStationModel.java b/src/main/java/ihl/processing/metallurgy/GasWeldingStationModel.java new file mode 100644 index 0000000..d8675a6 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/GasWeldingStationModel.java @@ -0,0 +1,108 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +// Date: 23.02.2015 12:31:33 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +public class GasWeldingStationModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public GasWeldingStationModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 13); + setTextureOffset("Base.Shape3", 0, 13); + setTextureOffset("Base.Shape16", 0, 13); + setTextureOffset("Base.Shape161", 0, 13); + setTextureOffset("Base.Shape162", 0, 13); + setTextureOffset("Base.Shape163", 0, 22); + setTextureOffset("Base.Shape164", 0, 13); + setTextureOffset("Base.Shape14", 0, 13); + setTextureOffset("Base.Shape165", 0, 13); + setTextureOffset("Base.Shape2", 0, 13); + setTextureOffset("Base.Shape4", 15, 17); + setTextureOffset("Base.Shape5", 12, 17); + setTextureOffset("Base.Cone176DOWN", 0, 0); + setTextureOffset("Base.Shape7", 0, 0); + setTextureOffset("Base.Cone173DOWN", 24, 0); + setTextureOffset("Base.Shape9", 24, 0); + setTextureOffset("Base.Cone172UP", 24, 0); + setTextureOffset("Base.Tube166UP", 48, 0); + setTextureOffset("Base.Tube168Up", 48, 0); + setTextureOffset("Base.Cone175UP", 0, 0); + setTextureOffset("Base.Tube169UP", 48, 4); + setTextureOffset("Base.Tube167UP", 50, 5); + setTextureOffset("Base.Tube170UP", 57, 2); + setTextureOffset("Base.Tube165UP", 48, 0); + setTextureOffset("Base.Shape20", 48, 0); + setTextureOffset("Base.Shape21", 48, 0); + setTextureOffset("Base.Shape22", 28, 0); + setTextureOffset("Base.Shape23", 28, 0); + setTextureOffset("Base.Shape24", 26, 0); + setTextureOffset("Base.Shape25", 26, 0); + setTextureOffset("Base.Shape26", 26, 0); + setTextureOffset("Base.Shape27", 0, 0); + setTextureOffset("Base.Shape28", 0, 0); + setTextureOffset("Base.Shape29", 0, 0); + setTextureOffset("Base.Shape30", 0, 0); + setTextureOffset("Base.Cone171WEST", 48, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, 0F, 1, 1, 8); + Base.addBox("Shape3", -7F, 7F, 0F, 14, 1, 1); + Base.addBox("Shape16", 7F, 7F, 0F, 1, 1, 8); + Base.addBox("Shape161", -8F, -1F, 0F, 1, 8, 1); + Base.addBox("Shape162", -8F, -2F, 1F, 1, 1, 6); + Base.addBox("Shape163", -8F, -2F, -0F, 16, 1, 1); + Base.addBox("Shape164", 7F, -1F, 0F, 1, 8, 1); + Base.addBox("Shape14", 7F, -2F, 1F, 1, 1, 6); + Base.addBox("Shape165", -8F, -2F, 7F, 16, 1, 1); + Base.addBox("Shape2", -7F, 7F, 7F, 14, 1, 1); + Base.addBox("Shape4", -8F, -1F, 7F, 1, 8, 1); + Base.addBox("Shape5", 7F, -1F, 7F, 1, 8, 1); + Base.addTube("Cone176DOWN", -7F, 5F, 1F, 6, 3, 6, 0.5F, 0.5F, ForgeDirection.UP); + Base.addTube("Shape7", -7F, -2F, 1F, 6, 7, 6, 0F, 1F, ForgeDirection.UP); + Base.addTube("Cone173DOWN", 1F, 5F, 1F, 6, 3, 6, 0.5F, 0.5F, ForgeDirection.UP); + Base.addTube("Shape9", 1F, -2F, 1F, 6, 7, 6, 0F, 1F, ForgeDirection.UP); + Base.addTube("Cone172UP", 1F, -5F, 1F, 6, 3, 6, 0.5F, 0.5F, ForgeDirection.DOWN); + Base.addTube("Tube166UP", 2.5F, -8F, 2.5F, 3, 1, 3, 0F, 1F, ForgeDirection.UP); + Base.addTube("Tube168Up", 2.5F, -6F, 2.5F, 3, 1, 3, 0F, 1F, ForgeDirection.UP); + Base.addTube("Cone175UP", -7F, -5F, 1F, 6, 3, 6, 0.5F, 0.5F, ForgeDirection.DOWN); + Base.addTube("Tube169UP", 3.5F, -7F, 3.5F, 1, 1, 1, 0F, 1F, ForgeDirection.UP); + Base.addTube("Tube167UP", -5.5F, -6F, 2.5F, 3, 1, 3, 0F, 1F, ForgeDirection.UP); + Base.addTube("Tube170UP", -4.5F, -7F, 3.5F, 1, 1, 1, 0F, 1F, ForgeDirection.UP); + Base.addTube("Tube165UP", -5.5F, -8F, 2.5F, 3, 1, 3, 0F, 1F, ForgeDirection.UP); + Base.addBox("Shape20", 1F, 7F, -7F, 7, 1, 1); + Base.addBox("Shape21", 0F, 7F, -7.5F, 1, 1, 2); + Base.addBox("Shape22", 3.5F, -6F, -1.5F, 1, 1, 4); + Base.addBox("Shape23", -3F, 7F, -6.5F, 3, 1, 1); + Base.addBox("Shape25",-2.8F, 7F, -1.5F, 7, 1, 1); + Base.addBox("Shape26",-3F, 6.9F, -6F, 1, 1, 5); + Base.addBox("Shape29",-4.7F, -5F, -1.5F, 1, 12, 1); + Base.addBox("Shape24", 3.4F, -5F, -1.5F, 1, 12, 1); + Base.addBox("Shape27", -5F, 7F, -8F, 5, 1, 1); + Base.addBox("Shape28", -4.5F, -6F, -1.5F, 1, 1, 4); + Base.addBox("Shape30", -4.9F, 6.9F, -7.5F, 1, 1, 7); + Base.addTube("Cone171WEST", 7F, 7F, -6F, 1, 1, 2, 0.5F, 0.5F, ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/GasWeldingStationTileEntity.java b/src/main/java/ihl/processing/metallurgy/GasWeldingStationTileEntity.java new file mode 100644 index 0000000..b7172c2 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/GasWeldingStationTileEntity.java @@ -0,0 +1,286 @@ +package ihl.processing.metallurgy;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.network.INetworkClientTileEntityEventListener;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.interfaces.IWorkspaceElement;
+import ihl.processing.chemistry.ApparatusProcessableInvSlot;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+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;
+
+public class GasWeldingStationTileEntity extends TileEntityInventory implements IHasGui, INetworkClientTileEntityEventListener, IFluidHandler, IWorkspaceElement
+{
+ protected static final UniversalRecipeManager acetyleneRecipeManager = new UniversalRecipeManager("gasweldingstation");
+ public final ApparatusProcessableInvSlot input;
+ public final InvSlotConsumableLiquidIHL fillInputSlotFlammableGas;
+ public final InvSlotConsumableLiquidIHL fillInputSlotOxygen;
+ public final InvSlotConsumableLiquidIHL drainInputSlotFlammableGas;
+ public final InvSlotConsumableLiquidIHL drainInputSlotOxygen;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ public final IHLFluidTank flammableGasTank = new IHLFluidTank(8000);
+ public final IHLFluidTank oxygenTank = new IHLFluidTank(8000);
+ public short progress2;
+ protected short operationLength=200;
+
+ public GasWeldingStationTileEntity() {
+ super();
+ this.input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, 1, 16);
+ this.fillInputSlotFlammableGas = new InvSlotConsumableLiquidIHL(this, "fillInputFlammableGas", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ this.fillInputSlotOxygen = new InvSlotConsumableLiquidIHL(this, "fillInputOxygen", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ this.drainInputSlotFlammableGas = new InvSlotConsumableLiquidIHL(this, "drainInputFlammableGas", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Drain);
+ this.drainInputSlotOxygen = new InvSlotConsumableLiquidIHL(this, "drainInputOxygen", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Drain);
+ this.emptyFluidItemsSlot = new InvSlotOutput(this, "fluidCellsOutput", 2, 2);
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ return fields;
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ if (this.canProduceGas())
+ {
+ ++this.progress2;
+ if (this.progress2 >= this.operationLength)
+ {
+ this.produceGas();
+ this.progress2 = 0;
+ }
+ }
+ else
+ {
+ if (!this.canProduceGas())
+ {
+ this.progress2 = 0;
+ }
+ }
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlotFlammableGas, drainInputSlotFlammableGas, emptyFluidItemsSlot, flammableGasTank);
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlotOxygen, drainInputSlotOxygen, emptyFluidItemsSlot, oxygenTank);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.flammableGasTank.readFromNBT(nbttagcompound.getCompoundTag("flammableGasTank"));
+ this.oxygenTank.readFromNBT(nbttagcompound.getCompoundTag("oxygenTank"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound flammableGasTankNBT = new NBTTagCompound();
+ this.flammableGasTank.writeToNBT(flammableGasTankNBT);
+ nbttagcompound.setTag("flammableGasTank", flammableGasTankNBT);
+ NBTTagCompound oxygenTankNBT = new NBTTagCompound();
+ this.oxygenTank.writeToNBT(oxygenTankNBT);
+ nbttagcompound.setTag("oxygenTank", oxygenTankNBT);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return false;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("gasWeldingStation");
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "detonationSprayingMachine";
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new GasWeldingStationGui(new GasWeldingStationContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new GasWeldingStationContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {}
+
+ @Override
+ public void onNetworkEvent(EntityPlayer player, int event)
+ {
+ }
+
+ public boolean canProduceGas()
+ {
+ UniversalRecipeOutput rOutput = GasWeldingStationTileEntity.acetyleneRecipeManager.getOutputFor(Arrays.asList(new FluidStack[]{this.flammableGasTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get()}));
+ return rOutput!=null;
+ }
+
+ public void produceGas()
+ {
+ if(canProduceGas())
+ {
+ UniversalRecipeInput rInput = GasWeldingStationTileEntity.acetyleneRecipeManager.getRecipeInput(Arrays.asList(new FluidStack[]{this.flammableGasTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get()}));
+ UniversalRecipeOutput rOutput = GasWeldingStationTileEntity.acetyleneRecipeManager.getOutputFor(Arrays.asList(new FluidStack[]{this.flammableGasTank.getFluid()}), Arrays.asList(new ItemStack[]{this.input.get()}));
+ FluidStack output1 = rOutput.getFluidOutputs().get(0).copy();
+ FluidStack output2 = rOutput.getFluidOutputs().get(1).copy();
+ this.flammableGasTank.drain(rInput.getFluidInputs().get(0), true);
+ this.input.get().stackSize-=rInput.getItemInputs().get(0).getAmount();
+ if(this.input.get().stackSize<=0)
+ {
+ this.input.clear();
+ }
+ this.flammableGasTank.fill(output1, true);
+ this.flammableGasTank.fill(output2, true);
+ }
+ }
+
+
+ public UniversalRecipeInput getInput()
+ {
+ return new UniversalRecipeInput(new FluidStack[] {this.flammableGasTank.getLigthestFluid(), this.oxygenTank.getFluid()}, new ItemStack[]{this.input.get(0),this.input.get(1),this.input.get(2)});
+ }
+
+ public static void addGasRecipe(ItemStack input, FluidStack inputFluid, FluidStack output, FluidStack output2)
+ {
+ acetyleneRecipeManager.addRecipe(new UniversalRecipeInput(new FluidStack[] {inputFluid},new ItemStack[] {input}), new UniversalRecipeOutput(new FluidStack [] {output, output2},new ItemStack [] {}, 20));
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getGasRecipes() {
+ return acetyleneRecipeManager.getRecipes();
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int amount, boolean doDrain)
+ {
+ FluidStack fstack = this.flammableGasTank.drain(amount, doDrain);
+ return fstack;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, FluidStack fluidStack, boolean doDrain) {
+ if(this.flammableGasTank.getFluid().containsFluid(fluidStack))
+ {
+ return this.flammableGasTank.drain(fluidStack.amount, doDrain);
+ }
+ return null;
+ }
+
+ @Override
+ public int fill(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
+ return this.oxygenTank.fill(arg1, arg2);
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection arg0) {
+ return new FluidTankInfo[] {this.flammableGasTank.getInfo(),this.oxygenTank.getInfo()};
+ }
+
+
+ //1.7.10 API
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return true;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection direction, Fluid arg1) {
+ return true;
+ }
+
+ public int gaugeProgressScaled(int i)
+ {
+ return this.progress2 * i / this.operationLength;
+ }
+
+ public int gaugeFlammableGasScaled(int i)
+ {
+ if(this.flammableGasTank.getFluid()!=null)
+ {
+ return this.flammableGasTank.getFluidAmount() * i /this.flammableGasTank.getCapacity();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ public int gaugeOxygenScaled(int i)
+ {
+ if(this.oxygenTank.getFluid()!=null)
+ {
+ return this.oxygenTank.getFluidAmount() * i /this.oxygenTank.getCapacity();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ @Override
+ public boolean canBeUsed()
+ {
+ return
+ this.flammableGasTank.getFluid()!=null &&
+ this.flammableGasTank.getLigthestFluid().getFluid().getName().equals("acetylene") &&
+ this.flammableGasTank.getLigthestFluid().amount>=20 &&
+ this.oxygenTank.getFluid()!=null &&
+ this.oxygenTank.getLigthestFluid().getFluid().getName().equals("oxygen") &&
+ this.oxygenTank.getLigthestFluid().amount>=20;
+ }
+
+ @Override
+ public void use()
+ {
+ this.flammableGasTank.drain(IHLUtils.getFluidStackWithSize("acetylene", 20), true);
+ this.oxygenTank.drain(IHLUtils.getFluidStackWithSize("oxygen", 20), true);
+ }
+
+ @Override
+ public boolean getIsInvalid()
+ {
+ return this.isInvalid();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/IProductionLine.java b/src/main/java/ihl/processing/metallurgy/IProductionLine.java new file mode 100644 index 0000000..5cf7605 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/IProductionLine.java @@ -0,0 +1,12 @@ +package ihl.processing.metallurgy;
+
+import net.minecraft.item.ItemStack;
+
+public interface IProductionLine
+{
+
+ short getFacing();
+ boolean canProcess(ItemStack stack);
+ void process(ItemStack stack);
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineContainer.java b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineContainer.java new file mode 100644 index 0000000..d166889 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineContainer.java @@ -0,0 +1,105 @@ +package ihl.processing.metallurgy;
+
+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 ImpregnatingMachineContainer extends ContainerBase<ImpregnatingMachineTileEntity> {
+
+ protected ImpregnatingMachineTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public int lastVisibleFluidID = -1;
+ public int lastVisibleFluidAmount = -1;
+ public short lastProgress = -1;
+ public short lastTemperature = -1;
+ private final static int height = 166;
+ public List<FluidStack> fluidTankFluidList;
+ public int fluidListHash = -1;
+
+ public ImpregnatingMachineContainer(EntityPlayer entityPlayer, ImpregnatingMachineTileEntity tileEntity1) {
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ fluidTankFluidList = this.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.drainInputSlot, 0, 24, 16));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.emptyFluidItemsSlot, 0, 24, 34));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.fillInputSlot, 0, 24, 52));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 116, 16));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 116, 41));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 1, 116, 59));
+ }
+
+ @Override
+ public void detectAndSendChanges() {
+ super.detectAndSendChanges();
+ for (int i = 0; i < this.crafters.size(); ++i) {
+ ICrafting icrafting = (ICrafting) this.crafters.get(i);
+
+ if (this.fluidListHash != fluidTankFluidList.hashCode()) {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ this.fluidListHash = fluidTankFluidList.hashCode();
+ }
+
+ if (this.tileEntity.progress != this.lastProgress) {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+
+ if (this.tileEntity.temperature != this.lastTemperature) {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.temperature);
+ }
+ if (this.tileEntity.visibleFluidId != this.lastVisibleFluidID) {
+ icrafting.sendProgressBarUpdate(this, 2, this.tileEntity.visibleFluidId);
+ }
+ if (this.tileEntity.visibleFluidAmount != this.lastVisibleFluidAmount) {
+ icrafting.sendProgressBarUpdate(this, 3, this.tileEntity.visibleFluidAmount);
+ }
+ }
+
+ this.lastNumberOfFluids = this.tileEntity.getNumberOfFluidsInTank();
+ this.lastFluidAmount = this.tileEntity.getTankAmount();
+ this.lastProgress = this.tileEntity.progress;
+ this.lastTemperature = this.tileEntity.temperature;
+ this.lastVisibleFluidID = this.tileEntity.visibleFluidId;
+ this.lastVisibleFluidAmount = this.tileEntity.visibleFluidAmount;
+ }
+
+ @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.temperature = (short) value;
+ break;
+ case 2:
+ this.tileEntity.visibleFluidId = value;
+ break;
+ case 3:
+ this.tileEntity.visibleFluidAmount = value;
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineGui.java b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineGui.java new file mode 100644 index 0000000..29ba298 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineGui.java @@ -0,0 +1,63 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class ImpregnatingMachineGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUITubBronze.png");
+ private ImpregnatingMachineContainer container;
+
+
+ public ImpregnatingMachineGui (ImpregnatingMachineContainer container1) {
+ //the container is instanciated and passed to the superclass for handling
+ super(container1);
+ this.container=container1;
+ }
+
+ @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, 0.5F);
+ this.mc.renderEngine.bindTexture(background);
+ int i1;
+ if (this.container.tileEntity.progress > 0)
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27);
+ this.drawTexturedModalRect(138, 28, getFrameX(i1), getFrameY(i1),24,24);
+ }
+ if (this.container.tileEntity.getTankAmount() > 0)
+ {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.getFluidTank(), 50, 11, 107, 72, zLevel, par1, par2, xOffset, yOffset);
+ }
+ }
+
+ @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);
+ }
+
+ private int getFrameY(int number)
+ {
+ return (number % 10) * 24 + 14;
+ }
+
+ private int getFrameX(int number)
+ {
+ return (number / 10) * 24 + 176;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineRender.java b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineRender.java new file mode 100644 index 0000000..9529186 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineRender.java @@ -0,0 +1,55 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import ihl.interfaces.IFluidTankVisual;
+import ihl.model.FluidRenderer;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+public class ImpregnatingMachineRender extends TileEntitySpecialRenderer {
+
+ private float cap;
+
+ public ImpregnatingMachineRender(float capIn) {
+ cap = capIn;
+ }
+
+ public void renderAModelAt(IFluidTankVisual tile, double x, double y, double z, float f) {
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);
+ float rotation = 0F;
+ GL11.glRotatef(-rotation, 0F, 1F, 0F);
+ GL11.glScalef(1F, -1F, -1F);
+ GL11.glTranslatef(0F, -1.0F, 0F);
+ GL11.glPopMatrix();
+ if (tile.getVisibleFluidId() == -1 || tile.getVisibleFluidAmount() <= 0) {
+ return;
+ }
+ FluidStack fluidStack = new FluidStack(FluidRegistry.getFluid(tile.getVisibleFluidId()),
+ tile.getVisibleFluidAmount());
+ GL11.glPushMatrix();
+ GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glTranslatef((float) x, (float) y + 0.1F, (float) z);
+ GL11.glScalef(0.99F, 0.8F * tile.getRenderLiquidLevel(), 0.99F);
+ int[] displayLists = FluidRenderer.getLiquidDisplayLists(fluidStack);
+ if (displayLists != null) {
+ float level = Math.min(fluidStack.amount, cap) / cap;
+ bindTexture(FluidRenderer.getFluidSheet(fluidStack));
+ GL11.glCallList(displayLists[(int) (level * (FluidRenderer.DISPLAY_STAGES - 1))]);
+ }
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glPopAttrib();
+ GL11.glPopMatrix();
+
+ }
+
+ @Override
+ public void renderTileEntityAt(TileEntity tile, double par2, double par4, double par6, float par8) {
+ this.renderAModelAt((IFluidTankVisual) tile, par2, par4, par6, par8);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java new file mode 100644 index 0000000..4f7c529 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/ImpregnatingMachineTileEntity.java @@ -0,0 +1,343 @@ +package ihl.processing.metallurgy;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.network.INetworkTileEntityEventListener;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.interfaces.IFluidTankVisual;
+import ihl.processing.chemistry.ApparatusProcessableInvSlot;
+import ihl.processing.chemistry.ChemicalReactorTileEntity;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+
+public class ImpregnatingMachineTileEntity extends TileEntityInventory implements IHasGui,IFluidTankVisual,INetworkTileEntityEventListener, IFluidHandler
+{
+ private final static UniversalRecipeManager recipeManager = new UniversalRecipeManager("tub");
+ public final ApparatusProcessableInvSlot input;
+ public final IHLInvSlotOutput outputSlot;
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ public short progress;
+ protected short operationLength=Short.MAX_VALUE/2;
+ private final IHLFluidTank fluidTank = new IHLFluidTank(8000);
+ public short temperature=20;
+ public int visibleFluidId = -1;
+ public int visibleFluidAmount = 1;
+
+ public ImpregnatingMachineTileEntity() {
+ super();
+ this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 2);
+ 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);
+ this.input = new ApparatusProcessableInvSlot(this, "input", 3, Access.IO, 1, 64);
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return false;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("tubBronze");
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> ret = super.getNetworkedFields();
+ ret.add("visibleFluidId");
+ ret.add("visibleFluidAmount");
+ return ret;
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ if(this.fluidTank.getFluid()!=null)
+ {
+ if(this.fluidTank.getLigthestFluid().getFluid().isGaseous())
+ {
+ this.fluidTank.drainLightest(10, true);
+ }
+ }
+ if(this.fluidTank.getFluid()!=null && (visibleFluidId!=this.fluidTank.getFluid().getFluid().getID() || visibleFluidAmount!=this.fluidTank.getFluidAmount()))
+ {
+ visibleFluidId = this.fluidTank.getFluid().getFluid().getID();
+ visibleFluidAmount = this.fluidTank.getFluidAmount();
+ IC2.network.get().updateTileEntityField(this, "visibleFluidId");
+ IC2.network.get().updateTileEntityField(this, "visibleFluidAmount");
+ }
+ else if(this.fluidTank.getFluid()==null && visibleFluidId!=-1)
+ {
+ visibleFluidId=-1;
+ IC2.network.get().updateTileEntityField(this, "visibleFluidId");
+ }
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, fluidTank);
+ if (this.canOperate())
+ {
+ this.setActive(true);
+ if (this.progress == 0)
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 0, true);
+ }
+
+ this.progress+=this.operationLength/this.getOutput().getTime();
+ if (this.progress >= this.operationLength)
+ {
+ this.operate();
+ this.progress = 0;
+ IC2.network.get().initiateTileEntityEvent(this, 2, true);
+ }
+ }
+ else
+ {
+ if (this.progress != 0 && this.getActive())
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 1, true);
+ }
+ if (!this.canOperate())
+ {
+ this.progress = 0;
+ }
+ this.setActive(false);
+ }
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int amount, boolean doDrain)
+ {
+ FluidStack fstack = this.fluidTank.drain(amount, doDrain);
+ return fstack;
+ }
+
+
+ //1.7.10 API
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return true;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection direction, Fluid arg1) {
+ return true;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "impregnatingMachine";
+ }
+
+ public float getRenderLiquidLevel()
+ {
+ return (float)this.visibleFluidAmount/(float)this.fluidTank.getCapacity();
+ }
+
+ @Override
+ public void onNetworkEvent(int event)
+ {
+ }
+
+ public int gaugeProgressScaled(int i)
+ {
+ return this.progress * i / operationLength;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new ImpregnatingMachineGui(new ImpregnatingMachineContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player)
+ {
+ this.fluidTank.sortFluidsByDensity();
+ return new ImpregnatingMachineContainer(player, this);
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer player) {}
+
+ public boolean canOperate()
+ {
+ return getOutput()!=null && this.outputSlot.canAdd(getOutput().getItemOutputs());
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ return ImpregnatingMachineTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @SuppressWarnings("rawtypes")
+ public List[] getInput()
+ {
+ for(int i=0;i<fluidTank.getNumberOfFluids();i++)
+ {
+ for(int i1=0;i1<fluidTank.getNumberOfFluids();i1++)
+ {
+ if(i!=i1)
+ {
+ List[] rInput = new List[]{Arrays.asList(new FluidStack[]{fluidTank.getFluid(i),fluidTank.getFluid(i1)}), this.input.getItemStackList()};
+ if(ImpregnatingMachineTileEntity.recipeManager.getOutputFor(rInput)!=null)
+ {
+ return rInput;
+ }
+ }
+ }
+ }
+ return new List[] {Arrays.asList(new FluidStack[]{fluidTank.getFluid()}), this.input.getItemStackList()};
+ }
+
+ public void operate()
+ {
+ UniversalRecipeInput recipeInput = ImpregnatingMachineTileEntity.recipeManager.getRecipeInput(getInput());
+ UniversalRecipeOutput output1 = getOutput();
+ for(int i=0; i<recipeInput.getItemInputs().size();i++)
+ {
+ this.input.consume(recipeInput.getItemInputs().get(i));
+ }
+ this.fluidTank.drain(recipeInput.getFluidInputs(), true);
+ this.fluidTank.fill(output1.getFluidOutputs(), true);
+ if(!output1.getItemOutputs().isEmpty() && output1.getItemOutputs().get(0)!=null)this.outputSlot.add(output1.getItemOutputs());
+ }
+
+ @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()};
+ }
+
+ @Override
+ public short getFacing()
+ {
+ return 3;
+ }
+
+ 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 static void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output)
+ {
+ recipeManager.addRecipe(input, output);
+ }
+
+ public int getNumberOfFluidsInTank()
+ {
+ return this.fluidTank.getNumberOfFluids();
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addQuenchingRecipe(String nameHot, String nameQuenched)
+ {
+ addRecipe(new UniversalRecipeInput((new FluidStack[] {new FluidStack(FluidRegistry.WATER, 50)}), (new ItemStack[] {IHLUtils.getThisModItemStack(nameHot)})), new UniversalRecipeOutput(null, (new ItemStack[] {IHLUtils.getThisModItemStack(nameQuenched)}),2));
+ }
+
+ public IHLFluidTank getFluidTank()
+ {
+ return this.fluidTank;
+ }
+
+ public static void addChemicalRecipe(UniversalRecipeInput universalRecipeInput, UniversalRecipeOutput universalRecipeOutput)
+ {
+ addRecipe(universalRecipeInput,universalRecipeOutput);
+ ChemicalReactorTileEntity.addRecipe(universalRecipeInput,universalRecipeOutput);
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+ @Override
+ public int getVisibleFluidId() {
+ return this.visibleFluidId;
+ }
+
+ @Override
+ public int getVisibleFluidAmount() {
+ return this.visibleFluidAmount;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/InjectionMoldBlock.java b/src/main/java/ihl/processing/metallurgy/InjectionMoldBlock.java new file mode 100644 index 0000000..bbea1cb --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/InjectionMoldBlock.java @@ -0,0 +1,248 @@ +package ihl.processing.metallurgy;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.items_blocks.IHLItemBlock;
+import ihl.metallurgy.constants.Details;
+import ihl.utils.IHLUtils;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.fluids.FluidStack;
+
+public class InjectionMoldBlock extends Block implements ITileEntityProvider{
+
+ IIcon textureSide;
+
+ public static InjectionMoldBlock instance;
+ public static String[] materials = new String[] {"Bronze","Steel","Gold","Magnesium", "Lithium", "TarPitch", "Potassium", "Sodium"};
+
+ public InjectionMoldBlock()
+ {
+ super(Material.rock);
+ this.setResistance(0.5F);
+ this.setHardness(0.5F);
+ this.setBlockName("injectionMold");
+ this.setCreativeTab(IHLCreativeTab.tab);
+ instance=this;
+ }
+
+ public static void init()
+ {
+ GameRegistry.registerBlock(new InjectionMoldBlock(),IHLItemBlock.class,"injectionMold");
+ GameRegistry.registerTileEntity(InjectionMoldTileEntity.class,"injectionMoldTileEntity");
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
+ {
+ super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag);
+ }
+
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList)
+ {
+ ItemStack result = new ItemStack(item);
+ result.stackTagCompound=new NBTTagCompound();
+ result.stackTagCompound.setString("resultSuffix", "ingot");
+ itemList.add(result);
+ }
+
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ return new InjectionMoldTileEntity();
+ }
+
+ @Override
+ 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 && te instanceof InjectionMoldTileEntity)
+ {
+ InjectionMoldTileEntity gte = (InjectionMoldTileEntity) te;
+ gte.dropContents();
+ }
+ }
+ super.onBlockPreDestroy(world, x, y, z, meta);
+ }
+
+ @Override
+ public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
+ {
+ ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
+ TileEntity t = world.getTileEntity(x, y, z);
+ if(t!=null)
+ {
+ InjectionMoldTileEntity te = (InjectionMoldTileEntity)t;
+ if(te.result!=null)drops.add(te.result);
+ if(te.result2!=null)drops.add(te.result2);
+ }
+ return drops;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":injectionMoldTop");
+ this.textureSide = par1IconRegister.registerIcon(IHLModInfo.MODID + ":injectionMoldSide");
+ }
+
+ @Override
+ public boolean hasTileEntity(int metadata)
+ {
+ return true;
+ }
+
+ @Override
+ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack)
+ {
+ TileEntity t = world.getTileEntity(x, y, z);
+ if(t!=null && t instanceof InjectionMoldTileEntity)
+ {
+ InjectionMoldTileEntity te = (InjectionMoldTileEntity)t;
+ te.resultSuffix=itemStack.stackTagCompound.getString("resultSuffix");
+ if(itemStack.stackTagCompound.hasKey("isContainStearin"))
+ {
+ te.isContainStearin=itemStack.stackTagCompound.getBoolean("isContainStearin");
+ }
+ if(itemStack.stackTagCompound.hasKey("maxAmount"))
+ {
+ te.maxAmount=itemStack.stackTagCompound.getByte("maxAmount");
+ }
+
+ }
+ }
+ @Override
+ public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int i,float pos_x,float pos_y,float pos_z)
+ {
+ if(player.getCurrentEquippedItem()!=null && player.getCurrentEquippedItem().getItem() instanceof Crucible)
+ {
+ if(!world.isRemote)
+ {
+ return ((Crucible)player.getCurrentEquippedItem().getItem()).onItemUse(player.getCurrentEquippedItem(), player, world, x, y, z, 0, pos_x, pos_y, pos_z);
+ }
+ return true;
+ }
+ return false;
+ }
+
+
+
+ /**
+ * Called when the block is placed in the world.
+ */
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
+ {
+ switch (side)
+ {
+ case 1:
+ return this.blockIcon;
+ case 0:
+ return this.textureSide;
+ case 2:
+ return this.textureSide;
+ case 3:
+ return this.textureSide;
+ case 4:
+ return this.textureSide;
+ case 5:
+ return this.textureSide;
+ default:
+ return this.textureSide;
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta)
+ {
+ switch (side)
+ {
+ case 1:
+ return this.blockIcon;
+ case 0:
+ return this.textureSide;
+ case 2:
+ return this.textureSide;
+ case 3:
+ return this.textureSide;
+ case 4:
+ return this.textureSide;
+ case 5:
+ return this.textureSide;
+ default:
+ return this.textureSide;
+ }
+ }
+
+ public ItemStack getSandInjectionMoldForResult(String result1)
+ {
+ ItemStack stack = new ItemStack(this);
+ stack.stackTagCompound=new NBTTagCompound();
+ stack.stackTagCompound.setString("resultSuffix", result1);
+ registerRecipes(result1, stack);
+ return stack;
+ }
+
+ public ItemStack getGypsumInjectionMoldForResult(String result1)
+ {
+ ItemStack stack = new ItemStack(this);
+ stack.stackTagCompound=new NBTTagCompound();
+ stack.stackTagCompound.setString("resultSuffix", result1);
+ stack.stackTagCompound.setByte("maxAmount", (byte)1);
+ stack.stackTagCompound.setBoolean("isContainStearin", true);
+ registerRecipes(result1, stack);
+ return stack;
+ }
+
+ public static void registerRecipes(String result1,ItemStack stack1)
+ {
+ for(int i=0;i<materials.length;i++)
+ {
+ String material = InjectionMoldBlock.materials[i];
+ ItemStack stack = IHLUtils.getItemStackIfExist(result1+material);
+ if(stack!=null)
+ {
+ material=material.toLowerCase(Locale.ROOT);
+ FluidStack fluidstack = IHLUtils.getFluidStackIfExist("molten."+material,Details.getMeltingFluidAmount(result1));
+ if(fluidstack!=null)
+ {
+ // Cap hash to positive integer range.
+ stack1.setItemDamage(result1.hashCode() & Integer.MAX_VALUE);
+/* IHLMod.log.info("Setting damage for injection mold to: "
+ +result1.toLowerCase(Locale.ROOT).hashCode()
+ +" using hash code of "+result1
+ +" Result of lower case: "+result1.toLowerCase(Locale.ROOT));*/
+ InjectionMoldTileEntity.addRecipe(fluidstack,stack1,stack);
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/InjectionMoldTileEntity.java b/src/main/java/ihl/processing/metallurgy/InjectionMoldTileEntity.java new file mode 100644 index 0000000..e5fee82 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/InjectionMoldTileEntity.java @@ -0,0 +1,201 @@ +package ihl.processing.metallurgy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import ic2.core.IC2;
+import ihl.metallurgy.constants.Details;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.item.EntityItem;
+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.FluidTank;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+import net.minecraftforge.oredict.OreDictionary;
+
+
+public class InjectionMoldTileEntity extends TileEntity implements IFluidHandler
+{
+ public short timer = 100;
+ public String resultSuffix;
+ public boolean isContainStearin = false;
+ public short maxAmount=Short.MAX_VALUE;
+ public ItemStack result;
+ public ItemStack result2;
+ private final FluidTank fluidTank;
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("injectionmold");
+
+ public InjectionMoldTileEntity()
+ {
+ this.fluidTank = new FluidTank(864);//144 mB per ingot 1300 EU with 100% efficiency
+ }
+
+ public static void addRecipe(FluidStack input, ItemStack input1, ItemStack output)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput((new FluidStack[] {input}),(new ItemStack[] {input1})), new UniversalRecipeOutput(null,(new ItemStack[]{output}),20));
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ resultSuffix=nbttagcompound.getString("resultSuffix");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ nbttagcompound.setString("resultSuffix",resultSuffix);
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void updateEntity()
+ {
+ if(this.getFluidStackfromTank()!=null && this.getFluidStackfromTank().amount>16)
+ {
+ if(this.timer--==0)
+ {
+ String formattedFluidName=this.getFormattedMaterialName(this.getFluidfromTank().getName());
+ if(formattedFluidName!="")
+ {
+ int fluidAmountPerItem = Details.getMeltingFluidAmount(this.resultSuffix);
+ ArrayList<ItemStack> resultList = OreDictionary.getOres(this.resultSuffix+formattedFluidName);
+ if(resultList.isEmpty() || fluidAmountPerItem<=0)
+ {
+ resultList=new ArrayList<ItemStack>();
+ List<FluidStack> fi = Arrays.asList(new FluidStack[] {this.fluidTank.getFluid()});
+ List<ItemStack> ii = Arrays.asList(new ItemStack[] {IHLUtils.getThisModItemStackWithDamage("injectionMold", this.resultSuffix.hashCode() & Integer.MAX_VALUE)});
+ UniversalRecipeOutput ro = recipeManager.getOutputFor(fi, ii);
+ if(ro!=null)
+ {
+ ItemStack stack = ro.getItemOutputs().get(0).itemStack.copy();
+ stack.stackSize=Math.round(ro.getItemOutputs().get(0).quantity);
+ resultList.add(stack);
+ UniversalRecipeInput ri = recipeManager.getRecipeInput(fi, ii);
+ fluidAmountPerItem = ri.getFluidInputs().get(0).getAmount();
+ }
+ }
+ int fluidAmountPerItem2 = Details.getMeltingFluidAmount("nugget");
+ ArrayList<ItemStack> resultList2 = OreDictionary.getOres("nugget"+formattedFluidName);
+ if(!resultList.isEmpty())
+ {
+ if(fluidAmountPerItem>0)
+ {
+ int stackSize1=Math.min(this.maxAmount,this.getFluidStackfromTank().amount/fluidAmountPerItem);
+ if(stackSize1>0)
+ {
+ result=resultList.get(0).copy();
+ result.stackSize=stackSize1;
+ }
+ }
+ }
+ if(!resultList2.isEmpty())
+ {
+ int stackSize1=this.getFluidStackfromTank().amount/fluidAmountPerItem2;
+ if(result!=null)
+ {
+ stackSize1=(this.getFluidStackfromTank().amount % fluidAmountPerItem)/fluidAmountPerItem2;
+ }
+ if(stackSize1>0)
+ {
+ result2=resultList2.get(0).copy();
+ result2.stackSize=stackSize1;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return false;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection direction, Fluid fluid1) {
+ return direction==ForgeDirection.UP && !isContainStearin;
+ }
+
+ public String getInventoryName() {
+ return "injectionMold";
+ }
+
+ private String getFormattedMaterialName(String input)
+ {
+ String input2 = input.replace("molten.", "").replace(".molten", "");
+ String firstletter = String.valueOf(input2.charAt(0)).toUpperCase();
+ input2 = input2.replaceFirst(".", firstletter);
+ return input2;
+ }
+
+ public FluidTank getFluidTank()
+ {
+ return this.fluidTank;
+ }
+
+ public FluidStack getFluidStackfromTank()
+ {
+ return this.getFluidTank().getFluid();
+ }
+
+ public Fluid getFluidfromTank()
+ {
+ return this.getFluidStackfromTank().getFluid();
+ }
+
+ @Override
+ public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
+ {
+ return this.canFill(from, resource.getFluid()) ? this.getFluidTank().fill(resource, doFill) : 0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
+ {
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
+ {
+ return this.getFluidTank().drain(maxDrain, doDrain);
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection from)
+ {
+ return new FluidTankInfo[] {this.getFluidTank().getInfo()};
+ }
+
+ public void dropContents()
+ {
+ if(result!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, result));
+ if(result2!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, result2));
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes()
+ {
+ return recipeManager.getRecipes();
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/LatheContainer.java b/src/main/java/ihl/processing/metallurgy/LatheContainer.java new file mode 100644 index 0000000..5e79a2a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LatheContainer.java @@ -0,0 +1,72 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class LatheContainer extends ContainerBase<LathePart1TileEntity> {
+
+ public LathePart1TileEntity tileEntity;
+ public int lastProgress = -1;
+ private short lastEnergy = -1;
+ private final static int height=166;
+
+ public LatheContainer(EntityPlayer entityPlayer,
+ LathePart1TileEntity lathePart1TileEntity) {
+ super(lathePart1TileEntity);
+ tileEntity=lathePart1TileEntity;
+ 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(lathePart1TileEntity.dischargeSlot,0, 22, 55));
+ }
+
+ @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.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+ if (this.tileEntity.getEnergy() != this.lastEnergy)
+ {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy());
+ }
+ }
+ this.lastProgress = this.tileEntity.progress;
+ this.lastEnergy = (short) this.tileEntity.getEnergy();
+ }
+
+ @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.setEnergy(value);
+ break;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/LatheGui.java b/src/main/java/ihl/processing/metallurgy/LatheGui.java new file mode 100644 index 0000000..16f64c5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LatheGui.java @@ -0,0 +1,51 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+public class LatheGui extends GuiContainer {
+
+ private LatheContainer container;
+ protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUILathe.png");
+
+ public LatheGui(LatheContainer latheContainer) {
+ super(latheContainer);
+ container = latheContainer;
+ }
+
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ fontRendererObj.drawString(StatCollector.translateToLocal("ihl.gui.lathe"), 50, 10, 14722081);
+ this.mc.renderEngine.bindTexture(tex);
+ int i1;
+ if (this.container.tileEntity.getEnergy() > 0D)
+ {
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12);
+ this.drawTexturedModalRect(39, 55 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(50),50);
+ this.drawTexturedModalRect(64, 63, 197, 0, i1 + 1, 13);
+ }
+ }
+
+ @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(tex);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/LathePart1Model.java b/src/main/java/ihl/processing/metallurgy/LathePart1Model.java new file mode 100644 index 0000000..c08b3bf --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LathePart1Model.java @@ -0,0 +1,93 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class LathePart1Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer Belt; + IHLModelRenderer Belt2; + + public LathePart1Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.NewShape4", 0, 0); + setTextureOffset("RotatingPart2.PipeN1", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 49, 23); + setTextureOffset("RotatingPart2.Shape1", 56, 19); + setTextureOffset("RotatingPart2.Shape5", 0, 8); + setTextureOffset("RotatingPart2.Shape8", 0, 11); + setTextureOffset("RotatingPart2.PipeN4", 0, 0); + setTextureOffset("RotatingPart2.Shape9", 0, 0); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("Belt.Shape12", 46, 0); + setTextureOffset("Belt2.Shape13", 46, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5.5F, -1.5F, -7F, 7, 9, 1); + Base.addBox("Shape2", -5.5F, -0.5F, -4F, 5, 8, 1); + Base.addBox("NewShape4", 3F, 3F, -6F, 3, 4, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-3F, 18F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN1", -1.5F, -1.5F, 0F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN7", -2.5F, -2.5F, -1F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addBox("Shape1", 2F, -0.5F, 8.5F, 3, 1, 1); + RotatingPart2.addBox("Shape5", -0.5F, -5F, 8.5F, 1, 3, 1); + RotatingPart2.addBox("Shape8", -5F, -0.5F, 8.5F, 3, 1, 1); + RotatingPart2.addTube("PipeN4", -4F, -4F, 4F, 8, 8, 5, 0.3F,1F,ForgeDirection.NORTH); + RotatingPart2.addBox("Shape9", -0.5F, 2F, 8.5F, 1, 3, 1); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(0F, 21F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", 3F, -2F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", 4F, -1F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", 3F, -2F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + Belt = new IHLModelRenderer(this, "Belt"); + Belt.setRotationPoint(-3F, 15.5F, -7.9F); + setRotation(Belt, 0F, 0F, 0.45F); + Belt.mirror = true; + Belt.addBox("Shape12", 0F, 0F, 0F, 8, 1, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(-3F, 19.5F, -7.9F); + setRotation(Belt2, 0F, 0F, 0.19F); + Belt2.mirror = true; + Belt2.addBox("Shape13", 0F, 0F, 0F, 8, 1, 1); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/LathePart1TileEntity.java b/src/main/java/ihl/processing/metallurgy/LathePart1TileEntity.java new file mode 100644 index 0000000..788bfd4 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LathePart1TileEntity.java @@ -0,0 +1,99 @@ +package ihl.processing.metallurgy;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.ContainerBase;
+import ihl.interfaces.IWorkspaceElement;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class LathePart1TileEntity extends BasicElectricMotorTileEntity implements IWorkspaceElement{
+
+ public boolean ready=false;
+
+ public LathePart1TileEntity()
+ {
+ super();
+ }
+
+
+ @Override
+ public String getInventoryName() {
+ return "Lathe";
+ }
+
+ @Override
+ public void operate()
+ {
+ ready=true;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player)
+ {
+ return IHLUtils.getThisModItemStack("lathePart1");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new LatheGui(new LatheContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new LatheContainer(player, this);
+ }
+
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public List[] getInput()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean canOperate()
+ {
+ TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ);
+ if(te!=null && te instanceof LathePart2TileEntity)
+ {
+ return !ready;
+ }
+ return false;
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {}
+
+ @Override
+ public boolean canBeUsed()
+ {
+ return ready;
+ }
+
+ @Override
+ public void use()
+ {
+ ready=false;
+ }
+
+ @Override
+ public boolean getIsInvalid()
+ {
+ return this.isInvalid();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/LathePart2Model.java b/src/main/java/ihl/processing/metallurgy/LathePart2Model.java new file mode 100644 index 0000000..40b9b2a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LathePart2Model.java @@ -0,0 +1,87 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class LathePart2Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public LathePart2Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape1", 0, 0); + setTextureOffset("Base.Shape2", 38, 5); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape4", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.PipeN7", 0, 0); + setTextureOffset("Base.Shape7", 0, 0); + setTextureOffset("Base.PipeW9", 0, 0); + setTextureOffset("Base.PipeW9", 0, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("Base.Shape10", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape12", 0, 0); + setTextureOffset("Base.PipeW13", 0, 0); + setTextureOffset("Base.PipeN13", 0, 0); + setTextureOffset("Base.Shape13", 0, 0); + setTextureOffset("Base.Shape14", 0, 0); + setTextureOffset("Base.PipeU15", 0, 0); + setTextureOffset("Base.PipeU16", 0, 0); + setTextureOffset("Base.PipeU17", 0, 0); + setTextureOffset("Base.PipeU18", 0, 0); + setTextureOffset("Base.Shape15", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.PipeW20", 0, 0); + setTextureOffset("Base.PipeW19", 0, 0); + setTextureOffset("Base.PipeN21", 0, 0); + setTextureOffset("Base.PipeN22", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 14, 1, 16); + Base.addBox("Shape1", 0F, 1F, 0F, 4, 1, 4); + Base.addBox("Shape2", -2F, 2F, 1F, 5, 1, 1); + Base.addBox("Shape3", 0F, 3F, 0F, 4, 2, 4); + Base.addBox("Shape4", 2F, 6F, -8F, 1, 1, 16); + Base.addBox("Shape5", 5F, 6F, -8F, 1, 1, 13); + Base.addTube("PipeN7", 3.5F, 6F, -7F, 1, 1, 12, 0F,1F,ForgeDirection.NORTH); + Base.addBox("Shape7", 3F, 6F, -8F, 2, 1, 1); + Base.addTube("PipeW9", 6F, 5F, 5F, 1, 3, 3, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeW9", 7F, 6F, 5.2F, 1, 1, 1, 0F,1F,ForgeDirection.WEST); + Base.addBox("Shape9", 3F, 5F, 5F, 3, 2, 3); + Base.addBox("Shape10", -2F, 5F, 0F, 8, 1, 1); + Base.addBox("Shape11", -2F, 5F, 3F, 8, 1, 1); + Base.addBox("Shape12", 1F, 5F, 1F, 2, 1, 2); + Base.addTube("PipeW13", -1F, 5F, 1.5F, 6, 1, 1, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeN13", -4F, 1F, 3F, 2, 2, 3, 0F,1F,ForgeDirection.NORTH); + Base.addBox("Shape13", -3.5F, 2F, 3.8F, 1, 5, 2); + Base.addBox("Shape14", -4.5F, 6F, 2F, 3, 1, 4); + Base.addTube("PipeU15", 0F, 2F, 3F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addTube("PipeU16", 3F, 2F, 3F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addTube("PipeU17", 3F, 2F, 0F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addTube("PipeU18", 0F, 2F, 0F, 1, 1, 1, 0F,1F,ForgeDirection.UP); + Base.addBox("Shape15", 5F, 5F, 1F, 1, 1, 2); + Base.addBox("Shape16", -2F, 5F, 1F, 1, 1, 2); + Base.addTube("PipeW20", 6F, 4F, 0.5F, 1, 3, 3, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeW19", 7F, 5F, 0.8F, 1, 1, 1, 0F,1F,ForgeDirection.WEST); + Base.addTube("PipeN21", -4.5F, 0.5F, 6F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + Base.addTube("PipeN22", -3F, 1F, 7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + +} diff --git a/src/main/java/ihl/processing/metallurgy/LathePart2TileEntity.java b/src/main/java/ihl/processing/metallurgy/LathePart2TileEntity.java new file mode 100644 index 0000000..7d4dac7 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/LathePart2TileEntity.java @@ -0,0 +1,104 @@ +package ihl.processing.metallurgy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.api.network.INetworkDataProvider;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+
+public class LathePart2TileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{
+
+ private short facing=2;
+ private short lastFacing=2;
+
+ public LathePart2TileEntity()
+ {
+ super();
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = new ArrayList();
+ fields.add("facing");
+ return fields;
+ }
+
+ @Override
+ public void updateEntity()
+ {
+ super.updateEntity();
+ if(lastFacing!=facing)
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ lastFacing=facing;
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=side;
+ }
+
+
+ @Override
+ public short getFacing() {
+ return this.facing;
+ }
+
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ facing=(short) Math.max(2,facing1);
+ if(IC2.platform.isSimulating())
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ lastFacing=facing;
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
+ return true;
+ }
+
+
+ @Override
+ public float getWrenchDropRate() {
+ return 1F;
+ }
+
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("lathePart2");
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ facing=nbttagcompound.getShort("facing");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setShort("facing", facing);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/MachineBaseContainer.java b/src/main/java/ihl/processing/metallurgy/MachineBaseContainer.java new file mode 100644 index 0000000..d7e3ac7 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/MachineBaseContainer.java @@ -0,0 +1,74 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.ContainerBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class MachineBaseContainer extends ContainerBase<MachineBaseTileEntity> {
+
+ protected MachineBaseTileEntity tileEntity;
+ public int lastProgress = -1;
+ private short lastEnergy;
+ private final static int height=166;
+
+ public MachineBaseContainer(EntityPlayer entityPlayer, MachineBaseTileEntity tileEntity1){
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ 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));
+ }
+
+ }
+
+ @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.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+ if (this.tileEntity.getEnergy() != this.lastEnergy)
+ {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy());
+ }
+ }
+ this.lastProgress = this.tileEntity.progress;
+ }
+
+ @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.setEnergy(value);
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/MachineBaseTileEntity.java b/src/main/java/ihl/processing/metallurgy/MachineBaseTileEntity.java new file mode 100644 index 0000000..79763b5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/MachineBaseTileEntity.java @@ -0,0 +1,279 @@ +package ihl.processing.metallurgy;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySink;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot.Access;
+import ihl.processing.chemistry.ApparatusProcessableInvSlot;
+import ihl.recipes.UniversalRecipeOutput;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public abstract class MachineBaseTileEntity extends TileEntityInventory implements IHasGui, IEnergySink
+{
+ public short progress;
+ protected short operationLength=200;
+ protected double energy;
+ public int maxStorage;
+ public int energyConsume;
+ public final ApparatusProcessableInvSlot input;
+ private boolean addedToEnergyNet=false;
+
+ public MachineBaseTileEntity(int inputCount)
+ {
+ input = new ApparatusProcessableInvSlot(this, "input", 0, Access.IO, inputCount, 64);
+ maxStorage=128;
+ energyConsume=5;
+ }
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ return fields;
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.progress = nbttagcompound.getShort("progress");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setShort("progress", this.progress);
+ }
+
+ @Override
+ public void onLoaded()
+ {
+ super.onLoaded();
+ if (IC2.platform.isSimulating()&&!this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ }
+
+ @Override
+ public void onUnloaded()
+ {
+ if (IC2.platform.isSimulating()&&this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+
+ super.onUnloaded();
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=(short)side;
+ }
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ if (IC2.platform.isSimulating()&&this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ super.setFacing(facing1);
+ if (IC2.platform.isSimulating()&&!this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ public abstract String getStartSoundFile();
+
+ public abstract String getLoopSoundFile();
+
+ public abstract String getStopSoundFile();
+
+ @Override
+ public void updateEntityServer()
+ {
+ if(this.energy>this.maxStorage)
+ {
+ this.energy=this.maxStorage;
+ }
+
+ if (this.canOperate() && this.energy >= this.energyConsume)
+ {
+ this.setActive(true);
+
+ if (this.progress == 0)
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 0, true);
+ }
+
+ ++this.progress;
+ this.energy -= this.energyConsume;
+
+ if (this.progress >= this.operationLength)
+ {
+ this.operate();
+ this.progress = 0;
+ IC2.network.get().initiateTileEntityEvent(this, 2, true);
+ }
+ }
+ else
+ {
+ if (this.progress != 0 && this.getActive())
+ {
+ IC2.network.get().initiateTileEntityEvent(this, 1, true);
+ }
+ if (!this.canOperate())
+ {
+ this.progress = 0;
+ }
+ this.setActive(false);
+ }
+ }
+
+ protected int mX()
+ {
+ switch(this.getFacing())
+ {
+ case 4:
+ return 1;
+ case 5:
+ return -1;
+ default:
+ return 0;
+ }
+ }
+
+ protected int mY()
+ {
+ switch(this.getFacing())
+ {
+ case 0:
+ return -1;
+ case 1:
+ return 1;
+ default:
+ return 0;
+ }
+ }
+
+ protected int mZ()
+ {
+ switch(this.getFacing())
+ {
+ case 2:
+ return 1;
+ case 3:
+ return -1;
+ default:
+ return 0;
+ }
+ }
+
+ @Override
+ public abstract String getInventoryName();
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public abstract GuiScreen getGui(EntityPlayer arg0, boolean arg1);
+
+ @Override
+ public abstract ContainerBase<?> getGuiContainer(EntityPlayer arg0);
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {}
+
+ public int gaugeProgressScaled(int i)
+ {
+ return this.progress * i / this.operationLength;
+ }
+
+ public boolean canOperate()
+ {
+ return getOutput()!=null;
+ }
+
+ public abstract UniversalRecipeOutput getOutput();
+
+ @SuppressWarnings("rawtypes")
+ public List[] getInput()
+ {
+ return new List[]{null, this.input.getItemStackList()};
+ }
+
+
+ @Override
+ public double getDemandedEnergy()
+ {
+ return this.maxStorage - this.energy;
+ }
+
+ @Override
+ public int getSinkTier()
+ {
+ return 4;
+ }
+
+ @Override
+ public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
+ {
+ if (this.energy >= this.maxStorage)
+ {
+ return amount;
+ }
+ else
+ {
+ this.energy += amount;
+ return 0.0D;
+ }
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
+ {
+ return true;
+ }
+
+
+ public abstract void operate();
+ public short getEnergy() {
+ return (short)this.energy;
+ }
+ public void setEnergy(int value)
+ {
+ this.energy=value;
+ }
+ public int getGUIEnergy(int i) {
+ if(this.energy<Float.MAX_VALUE)
+ {
+ return Math.round((float)this.energy/this.maxStorage*i);
+ }
+ else
+ {
+ return Math.round((float)(this.energy/this.maxStorage)*i);
+ }
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/MuffleFurnaceGui.java b/src/main/java/ihl/processing/metallurgy/MuffleFurnaceGui.java new file mode 100644 index 0000000..9c83401 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/MuffleFurnaceGui.java @@ -0,0 +1,48 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+public class MuffleFurnaceGui extends GuiContainer {
+ protected static final ResourceLocation muffleFurnaceBackground = new ResourceLocation("ihl", "textures/gui/GUIAchesonFurnace.png");
+ private MachineBaseContainer container;
+
+ public MuffleFurnaceGui(MachineBaseContainer machineBaseContainer) {
+ //the container is instanciated and passed to the superclass for handling
+ super(machineBaseContainer);
+ this.container=machineBaseContainer;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(muffleFurnaceBackground);
+ int i1;
+ if (this.container.tileEntity.getEnergy() > 0D)
+ {
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12);
+ this.drawTexturedModalRect(8, 6 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(17),17);
+ this.drawTexturedModalRect(70,34, 197, 0, i1 + 1, 13);
+ }
+ fontRendererObj.drawStringWithShadow(StatCollector.translateToLocal("ihl.gui.muffleFurnace"), 40, 12, 16768125);
+
+ }
+
+ @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(muffleFurnaceBackground);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/MuffleFurnanceContainer.java b/src/main/java/ihl/processing/metallurgy/MuffleFurnanceContainer.java new file mode 100644 index 0000000..1ae7203 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/MuffleFurnanceContainer.java @@ -0,0 +1,16 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+
+public class MuffleFurnanceContainer extends MachineBaseContainer {
+
+ public MuffleFurnanceContainer(EntityPlayer entityPlayer,
+ MuffleFurnanceTileEntity tileEntity1) {
+ super(entityPlayer, tileEntity1);
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 0, 40, 22));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.input, 1, 40, 40));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, 0, 98, 32));
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java b/src/main/java/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java new file mode 100644 index 0000000..6f811cb --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/MuffleFurnanceTileEntity.java @@ -0,0 +1,119 @@ +package ihl.processing.metallurgy;
+
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.ContainerBase;
+import ihl.IHLMod;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+
+public class MuffleFurnanceTileEntity extends MachineBaseTileEntity {
+
+ protected static UniversalRecipeManager recipeManager = new UniversalRecipeManager("mufflefurnace");
+ public final IHLInvSlotOutput outputSlot;
+
+ public MuffleFurnanceTileEntity() {
+ super(2);
+ this.outputSlot = new IHLInvSlotOutput(this, "output", 0, 1);
+ }
+
+ @Override
+ public String getStartSoundFile() {
+ return null;
+ }
+
+ @Override
+ public String getLoopSoundFile() {
+ return null;
+ }
+
+ @Override
+ public String getStopSoundFile() {
+ return null;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "MuffleFurnance";
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new MuffleFurnaceGui(new MuffleFurnanceContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new MuffleFurnanceContainer(player, this);
+ }
+
+ @Override
+ public boolean canOperate() {
+ ItemStack crucible = input.getItemStack(IHLMod.crucible);
+ if (crucible != null) {
+ return true;
+ }
+ ItemStack mold = input.getItemStack(IHLUtils.getThisModItem("injectionMold"));
+ if (mold != null) {
+ return true;
+ }
+ return getOutput() != null;
+ }
+
+ @Override
+ public void operate() {
+ ItemStack crucible = input.getItemStack(IHLMod.crucible);
+ if (crucible != null) {
+ ((Crucible) crucible.getItem()).processContent(crucible, this);
+ return;
+ }
+ ItemStack mold = input.getItemStack(IHLUtils.getThisModItem("injectionMold"));
+ if (mold != null) {
+ mold.stackTagCompound.setBoolean("isContainStearin", false);
+ return;
+ }
+ List<RecipeOutputItemStack> output = recipeManager
+ .getOutputFor(getInput()).getItemOutputs();
+ List<IRecipeInput> rinput = recipeManager.getRecipeInput(getInput()).getItemInputs();
+ for (int i = 0; i < rinput.size(); i++) {
+ this.input.consume(rinput.get(i));
+ }
+ this.outputSlot.add(output);
+ }
+
+ public static void addRecipe(IRecipeInput recipeInputOreDict, ItemStack output) {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] { recipeInputOreDict })),
+ new UniversalRecipeOutput(null, (new ItemStack[] { output }), 20));
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ @Override
+ public UniversalRecipeOutput getOutput() {
+ return MuffleFurnanceTileEntity.recipeManager.getOutputFor(null, this.input.getItemStackList());
+ }
+
+ public static void addRecipe(UniversalRecipeInput universalRecipeInput,
+ UniversalRecipeOutput universalRecipeOutput) {
+ recipeManager.addRecipe(universalRecipeInput, universalRecipeOutput);
+ }
+
+ public static void addRecipe(IRecipeInput recipeInputOreDict, ItemStack output, float f) {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] { recipeInputOreDict })), new UniversalRecipeOutput(
+ null, (new RecipeOutputItemStack[] { new RecipeOutputItemStack(output, f) }), 20));
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachineContainer.java b/src/main/java/ihl/processing/metallurgy/RollingMachineContainer.java new file mode 100644 index 0000000..7a83d9d --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachineContainer.java @@ -0,0 +1,75 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class RollingMachineContainer extends ContainerBase<RollingMachinePart1TileEntity> {
+
+ public RollingMachinePart1TileEntity tileEntity;
+ public int lastProgress = -1;
+ private short lastEnergy = -1;
+ private final static int height=166;
+
+ public RollingMachineContainer(EntityPlayer entityPlayer,
+ RollingMachinePart1TileEntity lathePart1TileEntity) {
+ super(lathePart1TileEntity);
+ tileEntity=lathePart1TileEntity;
+ 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(lathePart1TileEntity.input, 0, 54, 25));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.output, 0, 105, 25));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.dischargeSlot,0, 22, 55));
+ }
+
+ @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.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+ if (this.tileEntity.getEnergy() != this.lastEnergy)
+ {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy());
+ }
+ }
+ this.lastProgress = this.tileEntity.progress;
+ this.lastEnergy = (short) this.tileEntity.getEnergy();
+ }
+
+ @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.setEnergy(value);
+ break;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachineGui.java b/src/main/java/ihl/processing/metallurgy/RollingMachineGui.java new file mode 100644 index 0000000..a792bd3 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachineGui.java @@ -0,0 +1,50 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+public class RollingMachineGui extends GuiContainer {
+
+ private RollingMachineContainer container;
+ protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIRollingMachine.png");
+
+ public RollingMachineGui(RollingMachineContainer latheContainer) {
+ super(latheContainer);
+ container = latheContainer;
+ }
+
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(tex);
+ 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(39, 55 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(50),50);
+ this.drawTexturedModalRect(64, 63, 197, 0, i1 + 1, 13);
+ }
+ }
+
+ @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(tex);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachinePart1Model.java b/src/main/java/ihl/processing/metallurgy/RollingMachinePart1Model.java new file mode 100644 index 0000000..fe062f8 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachinePart1Model.java @@ -0,0 +1,97 @@ +package ihl.processing.metallurgy; + + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + + +public class RollingMachinePart1Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer RotatingPart1; + IHLModelRenderer Plate; + + public RollingMachinePart1Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape8", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape9", 0, 0); + setTextureOffset("RotatingPart2.PipeN7", 0, 0); + setTextureOffset("RotatingPart2.PipeN17", 0, 0); + setTextureOffset("RotatingPart2.Shape3", 0, 0); + setTextureOffset("RotatingPart2.Shape12", 0, 0); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("RotatingPart1.Shape1", 0, 0); + setTextureOffset("RotatingPart1.Shape2", 0, 0); + setTextureOffset("RotatingPart1.Shape13", 0, 0); + setTextureOffset("Plate.Shape14", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape16", -3F, -7F, -6F, 9, 14, 1); + Base.addBox("Shape5", 2F, -1F, -5F, 6, 1, 13); + Base.addBox("Shape8", -8F, -1F, -5F, 6, 1, 13); + Base.addBox("Shape11", 3F, 0F, 7F, 4, 7, 1); + Base.addBox("Shape9", -7F, 0F, 7F, 4, 7, 1); + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(0F, 16F, -7F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN7", -5.5F, -5.5F, -0.9F, 11, 11, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN17", -2F, -2F, 2F, 4, 4, 26, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("Shape3", -2.5F, -2.5F, 0F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("Shape12", -1F, -1F, 28F, 2, 2, 3, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + RotatingPart1 = new IHLModelRenderer(this, "RotatingPart1"); + RotatingPart1.setRotationPoint(0F, 11.9F, -5F); + setRotation(RotatingPart1, 0F, 0F, 0F); + RotatingPart1.mirror = true; + RotatingPart1.addTube("Shape1", -2F, -2F, 0F, 4, 4, 26, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("Shape2", -2.5F, -2.5F, -1.9F, 5, 5, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("Shape13", -1F, -1F, 26F, 2, 2, 3, 0F,1F,ForgeDirection.NORTH); + Plate = new IHLModelRenderer(this, "Plate"); + Plate.setRotationPoint(0F, 13.5F, 0F); + setRotation(Plate, 0F, 0F, 0F); + Plate.mirror = true; + Plate.addBox("Shape14", -18F, 0F, 0F, 16, 1, 16); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java b/src/main/java/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java new file mode 100644 index 0000000..da60877 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachinePart1TileEntity.java @@ -0,0 +1,149 @@ +package ihl.processing.metallurgy;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.recipe.IRecipeInput;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.block.invslot.InvSlot.Access;
+import ihl.processing.chemistry.ApparatusProcessableInvSlot;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class RollingMachinePart1TileEntity extends BasicElectricMotorTileEntity{
+
+ public final ApparatusProcessableInvSlot input;
+ public final IHLInvSlotOutput output;
+ public boolean assembled;
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("rollingmachine");
+
+ public RollingMachinePart1TileEntity()
+ {
+ super();
+ input = new ApparatusProcessableInvSlot(this, "input", 1, Access.IO, 1, 64);
+ output = new IHLInvSlotOutput(this, "output", 2, 1);
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ return RollingMachinePart1TileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ fields.add("assembled");
+ return fields;
+ }
+
+
+ @Override
+ public String getInventoryName() {
+ return "RollingMachine";
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ if(assembled && !this.checkCorrectAccembly())
+ {
+ assembled=false;
+ IC2.network.get().updateTileEntityField(this, "assembled");
+ }
+ else if(!assembled && this.checkCorrectAccembly())
+ {
+ assembled=true;
+ IC2.network.get().updateTileEntityField(this, "assembled");
+ }
+ if (this.getActive() && this.progress == 0 && !this.canOperate())
+ {
+ this.setActive(false);
+ }
+
+ if (!this.getActive() && this.progress>0 && this.canOperate())
+ {
+ this.setActive(true);
+ }
+
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player)
+ {
+ return IHLUtils.getThisModItemStack("rollingMachinePart1");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new RollingMachineGui(new RollingMachineContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new RollingMachineContainer(player, this);
+ }
+
+ @Override
+ public void operate()
+ {
+ List<IRecipeInput> rinput = recipeManager.getRecipeInput(getInput()).getItemInputs();
+ List<RecipeOutputItemStack> output = RollingMachinePart1TileEntity.recipeManager.getOutputFor(getInput()).getItemOutputs();
+ this.output.add(output);
+ this.input.consume(rinput.get(0));
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public List[] getInput()
+ {
+ return new List[]{null, Arrays.asList(new ItemStack[] {input.get()})};
+ }
+
+ @Override
+ public boolean canOperate()
+ {
+ return this.getOutput()!=null && this.output.canAdd(this.getOutput().getItemOutputs()) && checkCorrectAccembly();
+ }
+
+ private boolean checkCorrectAccembly()
+ {
+ TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ);
+ return te!=null && te instanceof RollingMachinePart2TileEntity && ((RollingMachinePart2TileEntity)te).getFacing()==this.getFacing();
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {}
+
+ public static void addRecipe(ItemStack input, ItemStack output)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new ItemStack [] {input})), new UniversalRecipeOutput(null, (new ItemStack[] {output}), 20));
+ }
+
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachinePart2Model.java b/src/main/java/ihl/processing/metallurgy/RollingMachinePart2Model.java new file mode 100644 index 0000000..39fd1f5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachinePart2Model.java @@ -0,0 +1,42 @@ +package ihl.processing.metallurgy; + + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; + +public class RollingMachinePart2Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public RollingMachinePart2Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.Shape5", 0, 0); + setTextureOffset("Base.Shape8", 0, 0); + setTextureOffset("Base.Shape11", 0, 0); + setTextureOffset("Base.Shape9", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape16", -3F, -7F, 5F, 6, 14, 1); + Base.addBox("Shape5", 2F, -1F, -8F, 6, 1, 13); + Base.addBox("Shape8", -8F, -1F, -8F, 6, 1, 13); + Base.addBox("Shape11", 3F, 0F, -8F, 4, 7, 1); + Base.addBox("Shape9", -7F, 0F, -8F, 4, 7, 1); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java b/src/main/java/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java new file mode 100644 index 0000000..13f4f6c --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachinePart2TileEntity.java @@ -0,0 +1,104 @@ +package ihl.processing.metallurgy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.api.network.INetworkDataProvider;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+
+public class RollingMachinePart2TileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{
+
+ private short facing=2;
+ private short lastFacing=2;
+
+ public RollingMachinePart2TileEntity()
+ {
+ super();
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = new ArrayList();
+ fields.add("facing");
+ return fields;
+ }
+
+ @Override
+ public void updateEntity()
+ {
+ super.updateEntity();
+ if(lastFacing!=facing)
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ lastFacing=facing;
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=side;
+ }
+
+
+ @Override
+ public short getFacing() {
+ return this.facing;
+ }
+
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ facing=(short) Math.max(2,facing1);
+ if(IC2.platform.isSimulating())
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
+ return true;
+ }
+
+
+ @Override
+ public float getWrenchDropRate() {
+ return 1F;
+ }
+
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("rollingMachinePart2");
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ facing=nbttagcompound.getShort("facing");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setShort("facing", facing);
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/RollingMachineRender.java b/src/main/java/ihl/processing/metallurgy/RollingMachineRender.java new file mode 100644 index 0000000..f347a73 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/RollingMachineRender.java @@ -0,0 +1,81 @@ +package ihl.processing.metallurgy;
+import org.lwjgl.opengl.GL11;
+
+import ic2.api.tile.IWrenchable;
+import ihl.IHLModInfo;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+
+public class RollingMachineRender extends TileEntitySpecialRenderer{
+private RollingMachinePart1Model model = new RollingMachinePart1Model();
+private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/coiler.png");
+private final float scale=1F/16F;
+
+ public RollingMachineRender() {}
+
+
+ @Override
+ public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8)
+ {
+ int rotation = 0;
+ if(tile.getWorldObj() != null)
+ {
+ switch (((IWrenchable)tile).getFacing())
+ {
+ case 2:
+ rotation = 0;
+ break;
+ case 5:
+ rotation = 1;
+ break;
+ case 3:
+ rotation = 2;
+ break;
+ case 4:
+ rotation = 3;
+ break;
+ default:
+ rotation = 0;
+ }
+ }
+ else
+ {
+ return;
+ }
+ RollingMachinePart1TileEntity cte = (RollingMachinePart1TileEntity)tile;
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
+ GL11.glScalef(1.0F, -1F, -1F);
+ GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F);
+
+ bindTexture(tex);
+ model.Base.render(scale);
+ if(cte.getActive())
+ {
+ model.RotatingPart1.rotateAngleZ-=0.01F;
+ model.RotatingPart2.rotateAngleZ+=0.01F;
+ model.RotatingPart1.render(scale);
+ model.RotatingPart2.render(scale);
+ model.MotorPart1.rotateAngleZ-=0.03F;
+ model.MotorPart1.render(scale);
+ model.MotorPart2.render(scale);
+ model.Plate.offsetX+=0.001F;
+ if(model.Plate.offsetX>1F){model.Plate.offsetX=0;}
+ model.Plate.render(scale);
+ }
+ else
+ {
+ model.Plate.offsetX=0F;
+ if(cte.assembled)
+ {
+ model.RotatingPart1.render(scale);
+ model.RotatingPart2.render(scale);
+ }
+ model.MotorPart1.render(scale);
+ model.MotorPart2.render(scale);
+ }
+ GL11.glPopMatrix(); //end
+
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java b/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java new file mode 100644 index 0000000..9ce0f01 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldModel.java @@ -0,0 +1,54 @@ +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class VulcanizationExtrudingMoldModel extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public VulcanizationExtrudingMoldModel() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 0); + setTextureOffset("Base.Shape3", 0, 0); + setTextureOffset("Base.Shape16", 0, 0); + setTextureOffset("Base.PipeW161", 0, 0); + setTextureOffset("Base.PipeN16", 0, 0); + setTextureOffset("Base.PipeW15", 22, 22); + setTextureOffset("Base.PipeW17", 0, 0); + setTextureOffset("Base.Shape14", 0, 0); + setTextureOffset("Base.PipeN14", 0, 0); + setTextureOffset("Base.Shape2", 0, 0); + setTextureOffset("Base.Shape4", 42, 17); + setTextureOffset("Base.Shape5", 37, 17); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape3", -5F, 0F, -7F, 4, 7, 1); + Base.addBox("Shape16", 6.9F, 3F, -1.5F, 1, 4, 3); + Base.addTube("PipeW161", -7F, 0.5F, -1.5F, 15, 3, 3, 0.5F,1F,ForgeDirection.WEST); + Base.addTube("PipeN16", -4.5F, 0.5F, -6F, 3, 3, 6, 0.8F,1F,ForgeDirection.NORTH); + Base.addTube("PipeW15", -5.5F, -0.5F, -2.5F, 12, 5, 5, 0.5F,1F,ForgeDirection.WEST); + Base.addTube("PipeW17", -8F, -0.5F, -2.5F, 1, 5, 5, 0.1F,1F,ForgeDirection.WEST); + Base.addBox("Shape14", -5F, 3F, -4.9F, 4, 4, 1); + Base.addTube("PipeN14", -5.5F, -0.5F, -8F, 5, 5, 1, 0.5F,1F,ForgeDirection.NORTH); + Base.addBox("Shape2", -7F, 3F, -1.5F, 1, 4, 3); + Base.addBox("Shape4", 5F, 3F, 1F, 1, 4, 1); + Base.addBox("Shape5", 5F, 6F, 2F, 3, 1, 1); + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java b/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java new file mode 100644 index 0000000..bb51ced --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/VulcanizationExtrudingMoldTileEntity.java @@ -0,0 +1,256 @@ +package ihl.processing.metallurgy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+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.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ihl.items_blocks.FlexibleCableItem;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+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.MinecraftForge;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTank;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidHandler;
+
+public class VulcanizationExtrudingMoldTileEntity extends TileEntity
+ implements IWrenchable, INetworkDataProvider, IEnergySink, IProductionLine, IFluidHandler {
+
+ private short facing = 2;
+ private short lastFacing = 2;
+ public double energy;
+ public int maxStorage = 64;
+ private double energyConsume = 16D;
+ private boolean addedToEnergyNet = false;
+ private FluidTank fluidTank = new FluidTank(5000);
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager(
+ "vulcanizationextrudingmold");
+
+ public VulcanizationExtrudingMoldTileEntity() {
+ super();
+ }
+
+ public static void addRecipe(FluidStack inputFluid, ItemStack input, ItemStack output1) {
+ recipeManager.addRecipe(
+ new UniversalRecipeInput((new FluidStack[] { inputFluid }),
+ (new IRecipeInput[] { new RecipeInputItemStack(input) })),
+ new UniversalRecipeOutput(null, (new ItemStack[] { output1 }), 200));
+ }
+
+ public boolean enableUpdateEntity() {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public void invalidate() {
+ if (IC2.platform.isSimulating() && this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ super.invalidate();
+ }
+
+ @Override
+ public List<String> getNetworkedFields() {
+ List<String> fields = new ArrayList<String>();
+ fields.add("facing");
+ return fields;
+ }
+
+ @Override
+ public void updateEntity() {
+ super.updateEntity();
+ if (IC2.platform.isSimulating() && !this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+
+ if (lastFacing != facing) {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ lastFacing = facing;
+ }
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing() != side;
+ }
+
+ @Override
+ public short getFacing() {
+ return this.facing;
+ }
+
+ @Override
+ public void setFacing(short facing1) {
+ if (IC2.platform.isSimulating() && this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ facing = (short) Math.max(2, facing1);
+ if (IC2.platform.isSimulating()) {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ lastFacing = facing;
+ }
+ if (IC2.platform.isSimulating() && !this.addedToEnergyNet) {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ }
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
+ return true;
+ }
+
+ @Override
+ public float getWrenchDropRate() {
+ return 1F;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("vulcanizationExtrudingMold");
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound) {
+ super.readFromNBT(nbttagcompound);
+ this.fluidTank.readFromNBT(nbttagcompound.getCompoundTag("fluidTank"));
+ facing = nbttagcompound.getShort("facing");
+ energy = nbttagcompound.getDouble("energy");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound) {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound fluidTankTag = new NBTTagCompound();
+ this.fluidTank.writeToNBT(fluidTankTag);
+ nbttagcompound.setTag("fluidTank", fluidTankTag);
+ nbttagcompound.setShort("facing", facing);
+ nbttagcompound.setDouble("energy", this.energy);
+ }
+
+ @Override
+ public double getDemandedEnergy() {
+ return this.maxStorage - this.energy;
+ }
+
+ @Override
+ public int getSinkTier() {
+ return 4;
+ }
+
+ @Override
+ public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) {
+ if (this.energy < this.maxStorage) {
+ this.energy += amount;
+ return 0.0D;
+ } else {
+ return amount;
+ }
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) {
+ return true;
+ }
+
+ private ItemStack processWire(ItemStack wire, boolean doProcess) {
+ UniversalRecipeOutput rOutput = VulcanizationExtrudingMoldTileEntity.recipeManager.getOutputFor(
+ Arrays.asList(new FluidStack[] { this.fluidTank.getFluid() }), Arrays.asList(new ItemStack[] { wire }));
+ if (rOutput == null || this.energy < this.energyConsume) {
+ return wire;
+ }
+ UniversalRecipeInput rInput = VulcanizationExtrudingMoldTileEntity.recipeManager.getRecipeInput(
+ Arrays.asList(new FluidStack[] { this.fluidTank.getFluid() }), Arrays.asList(new ItemStack[] { wire }));
+ ItemStack cableAsRO = rOutput.getItemOutputs().get(0).itemStack;
+ ItemStack cable = wire.copy();
+ FlexibleCableItem fci = (FlexibleCableItem) cableAsRO.getItem();
+ cable.stackTagCompound.setString("insulationMaterial", fci.getInsulationMaterial(cableAsRO));
+ cable.stackTagCompound.setInteger("insulationThickness", fci.getInsulationThickness(cableAsRO));
+ cable.stackTagCompound.setInteger("maxVoltage", IHLUtils
+ .getInsulationMaxVoltage(fci.getInsulationMaterial(cableAsRO), fci.getInsulationThickness(cableAsRO)));
+ if (doProcess) {
+ this.energy -= this.energyConsume;
+ this.fluidTank.drain(rInput.getFluidInputs().get(0).getAmount() * IHLUtils.getWireLength(cable), true);
+ }
+ return cable;
+ }
+
+ @Override
+ public boolean canProcess(ItemStack wire) {
+ ItemStack cable = this.processWire(wire, false);
+ ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.UP);
+ TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
+ if (te instanceof IProductionLine) {
+ if (ForgeDirection.getOrientation(((IProductionLine) te).getFacing())
+ .equals(dir.getRotation(ForgeDirection.DOWN))) {
+ return ((IProductionLine) te).canProcess(cable);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void process(ItemStack wire) {
+ ItemStack cable = this.processWire(wire, true);
+ ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.UP);
+ TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
+ if (te instanceof IProductionLine && ForgeDirection.getOrientation(((IProductionLine) te).getFacing())
+ .equals(dir.getRotation(ForgeDirection.DOWN))) {
+ ((IProductionLine) te).process(cable);
+ }
+ }
+
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return false;
+ }
+
+ @Override
+ public boolean canFill(ForgeDirection arg0, Fluid arg1) {
+ return ForgeDirection.getOrientation(this.facing) == arg0;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, FluidStack arg1, boolean arg2) {
+ return null;
+ }
+
+ @Override
+ public FluidStack drain(ForgeDirection arg0, int arg1, boolean arg2) {
+ 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 static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/WireMillContainer.java b/src/main/java/ihl/processing/metallurgy/WireMillContainer.java new file mode 100644 index 0000000..34f79de --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WireMillContainer.java @@ -0,0 +1,113 @@ +package ihl.processing.metallurgy;
+
+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 WireMillContainer extends ContainerBase<WireMillTileEntity> {
+
+ public WireMillTileEntity tileEntity;
+ public int lastProgress = -1;
+ private short lastEnergy = -1;
+ public int lastFluidAmount = -1;
+ public int lastNumberOfFluids = -1;
+ public int lastFluidAmount2 = -1;
+ public int lastNumberOfFluids2 = -1;
+ public int lastFluidAmount3 = -1;
+ public int lastNumberOfFluids3 = -1;
+ private final static int height=166;
+ public List<FluidStack> fluidTankFluidList;
+ public List<FluidStack> fluidTankFluidList2;
+ public List<FluidStack> fluidTankFluidList3;
+
+ public WireMillContainer(EntityPlayer entityPlayer,
+ WireMillTileEntity lathePart1TileEntity) {
+ super(lathePart1TileEntity);
+ tileEntity=lathePart1TileEntity;
+ fluidTankFluidList = this.tileEntity.waterFluidTank.getFluidList();
+ fluidTankFluidList2 = this.tileEntity.oilFluidTank.getFluidList();
+ fluidTankFluidList3 = this.tileEntity.metalFluidTank.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(tileEntity.dice, 0, 99+18, 31));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.drainInputSlot, 0, 26+18, 14));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.fillInputSlot, 0, 26+18, 50));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.emptyFluidItemsSlot, 0, 26+18, 32));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity.dischargeSlot,0, 8, 14));
+ }
+
+ @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.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+ if (this.tileEntity.getEnergy() != this.lastEnergy)
+ {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy());
+ }
+
+ if (this.tileEntity.waterFluidTank.getFluidAmount() != this.lastFluidAmount || this.tileEntity.waterFluidTank.getNumberOfFluids() != this.lastNumberOfFluids)
+ {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList");
+ }
+
+ if (this.tileEntity.oilFluidTank.getFluidAmount() != this.lastFluidAmount2 || this.tileEntity.oilFluidTank.getNumberOfFluids() != this.lastNumberOfFluids2)
+ {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList2");
+ }
+
+ if (this.tileEntity.metalFluidTank.getFluidAmount() != this.lastFluidAmount3 || this.tileEntity.metalFluidTank.getNumberOfFluids() != this.lastNumberOfFluids3)
+ {
+ IC2.network.get().sendContainerField(this, "fluidTankFluidList3");
+ }
+ }
+ this.lastNumberOfFluids = this.tileEntity.waterFluidTank.getNumberOfFluids();
+ this.lastFluidAmount = this.tileEntity.waterFluidTank.getFluidAmount();
+ this.lastNumberOfFluids2 = this.tileEntity.oilFluidTank.getNumberOfFluids();
+ this.lastFluidAmount2 = this.tileEntity.oilFluidTank.getFluidAmount();
+ this.lastNumberOfFluids3 = this.tileEntity.metalFluidTank.getNumberOfFluids();
+ this.lastFluidAmount3 = this.tileEntity.metalFluidTank.getFluidAmount();
+ this.lastProgress = this.tileEntity.progress;
+ this.lastEnergy = (short) this.tileEntity.getEnergy();
+ }
+
+ @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.setEnergy(value);
+ break;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/WireMillGui.java b/src/main/java/ihl/processing/metallurgy/WireMillGui.java new file mode 100644 index 0000000..8a3d583 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WireMillGui.java @@ -0,0 +1,68 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import ihl.utils.IHLRenderUtils;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+public class WireMillGui extends GuiContainer {
+
+ private WireMillContainer container;
+ protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIWireMill.png");
+
+ public WireMillGui(WireMillContainer latheContainer) {
+ super(latheContainer);
+ container = latheContainer;
+ }
+
+ @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(tex);
+ 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);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.9F);
+ i1 = Math.min(this.container.tileEntity.getGUIEnergy(12),12);
+ this.drawTexturedModalRect(27, 15 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18);
+ this.drawTexturedModalRect(134, 33, 198, 0, i1 + 1, 13);
+ }
+ if (this.container.tileEntity.oilFluidTank.getFluid()!=null && this.container.tileEntity.oilFluidTank.getFluidAmount() > 0)
+ {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.oilFluidTank, 81, 16, 93, 63, zLevel, par1, par2, xOffset, yOffset);
+ }
+ if (this.container.tileEntity.waterFluidTank.getFluid()!=null && this.container.tileEntity.waterFluidTank.getFluidAmount() > 0)
+ {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.waterFluidTank, 64, 16, 76, 63, zLevel, par1, par2, xOffset, yOffset);
+ }
+ if (this.container.tileEntity.metalFluidTank.getFluid()!=null && this.container.tileEntity.metalFluidTank.getFluidAmount() > 0)
+ {
+ IHLRenderUtils.instance.renderIHLFluidTank(this.container.tileEntity.metalFluidTank, 98, 16, 110, 63, zLevel, par1, par2, xOffset, yOffset);
+ }
+
+ this.mc.renderEngine.bindTexture(tex);
+ IHLRenderUtils.instance.drawTooltip(par1,par2,9,11,xOffset,yOffset,StatCollector.translateToLocal("ihl.wiremill.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(tex);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/WireMillTileEntity.java b/src/main/java/ihl/processing/metallurgy/WireMillTileEntity.java new file mode 100644 index 0000000..d93eb4f --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WireMillTileEntity.java @@ -0,0 +1,378 @@ +package ihl.processing.metallurgy;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputOreDict;
+import ic2.core.ContainerBase;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotConsumableLiquid;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.IHLMod;
+import ihl.items_blocks.IHLTool;
+import ihl.processing.chemistry.ApparatusProcessableInvSlot;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.recipes.IRecipeInputFluid;
+import ihl.recipes.RecipeInputDie;
+import ihl.recipes.RecipeInputFluidDictionary;
+import ihl.recipes.RecipeInputFluidStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLFluidTank;
+import ihl.utils.IHLUtils;
+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;
+
+public class WireMillTileEntity extends BasicElectricMotorTileEntity implements IFluidHandler{
+
+ public final ApparatusProcessableInvSlot dice;
+ public final InvSlotConsumableLiquidIHL fillInputSlot;
+ public final InvSlotConsumableLiquidIHL drainInputSlot;
+ public final InvSlotOutput emptyFluidItemsSlot;
+ public final IHLFluidTank oilFluidTank = new IHLFluidTank(1100);
+ public final IHLFluidTank waterFluidTank = new IHLFluidTank(1100);
+ public final IHLFluidTank metalFluidTank = new IHLFluidTank(1100);
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("wiremill");
+ protected static final UniversalRecipeManager recipeManagerMelting = new UniversalRecipeManager("wiremillMelting");
+
+ public WireMillTileEntity()
+ {
+ super();
+ emptyFluidItemsSlot = new InvSlotOutput(this, "emptyWaterFluidItemsSlot", 2, 1);
+ fillInputSlot = new InvSlotConsumableLiquidIHL(this, "fillInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Fill);
+ drainInputSlot = new InvSlotConsumableLiquidIHL(this, "drainInput", -1, InvSlot.Access.I, 1, InvSlot.InvSide.BOTTOM, InvSlotConsumableLiquid.OpType.Drain, "ingot");
+ dice = new ApparatusProcessableInvSlot(this, "dice", 3, Access.IO, 1, 64);
+ this.operationLength=600;
+ }
+
+
+ @Override
+ public String getInventoryName() {
+ return "WireMill";
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player)
+ {
+ return IHLUtils.getThisModItemStack("wireMill");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1)
+ {
+ return new WireMillGui(new WireMillContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player)
+ {
+ return new WireMillContainer(player, this);
+ }
+
+ @Override
+ public void operate()
+ {
+ UniversalRecipeInput rInput = WireMillTileEntity.recipeManager.getRecipeInput(getInput());
+ IRecipeInput rInputDice = rInput.getItemInputs().get(0);
+ UniversalRecipeOutput rOutput = this.getOutput();
+ ItemStack rOutputItemStack=null;
+ if(!rOutput.getItemOutputs().isEmpty())
+ {
+ rOutputItemStack = rOutput.getItemOutputs().get(0).itemStack.copy();
+ }
+ List<IRecipeInputFluid> rInputFluidStacks = rInput.getFluidInputs();
+ int consumeMoltenMetalAmount=1;
+ if(!rInputFluidStacks.isEmpty() && rOutputItemStack!=null && rInputDice!=null && rInputDice instanceof RecipeInputDie)
+ {
+ if(rInputFluidStacks.size()>=3)
+ {
+ consumeMoltenMetalAmount=rInputFluidStacks.get(2).getAmount();
+ }
+ else
+ {
+ consumeMoltenMetalAmount=rInputFluidStacks.get(0).getAmount();
+ }
+ if(rOutputItemStack!=null && rInputDice!=null && rInputDice instanceof RecipeInputDie)
+ {
+ consumeMoltenMetalAmount*=((RecipeInputDie)rInputDice).transformOutput(this.dice.get(), rOutputItemStack);
+ }
+ }
+ if(dice.get()!=null)
+ {
+ if(dice.get().getItem() instanceof IHLTool)
+ {
+ IHLUtils.damageItemViaNBTTag(dice.get(), 1);
+ if(dice.get().stackSize<=0)
+ {
+ dice.put(null);
+ }
+ }
+ else
+ {
+ dice.consume(rInputDice);
+ }
+ }
+ if(this.drainInputSlot.get()!=null && !rInput.getItemInputs().isEmpty() && rInput.getItemInputs().get(0).matches(this.drainInputSlot.get()))
+ {
+ this.drainInputSlot.consume(1);
+ }
+ if(!rOutput.getFluidOutputs().isEmpty())
+ {
+ this.metalFluidTank.fill(rOutput.getFluidOutputs().get(0), true);
+ }
+ TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ);
+ if(rOutputItemStack!=null && te instanceof IProductionLine)
+ {
+ if(!rInputFluidStacks.isEmpty())
+ {
+ this.oilFluidTank.drain(1, true);
+ this.waterFluidTank.drain(1, true);
+ this.metalFluidTank.drain(consumeMoltenMetalAmount, true);
+ }
+ ((IProductionLine)te).process(rOutputItemStack);
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public List[] getInput()
+ {
+ return new List[]{Arrays.asList(new FluidStack[] {this.oilFluidTank.getFluid(),this.waterFluidTank.getFluid(),this.metalFluidTank.getFluid()}),Arrays.asList(new ItemStack[] {dice.get(),drainInputSlot.get()})};
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ return WireMillTileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ public static void addRecipe(FluidStack moltenMetal, IRecipeInput inputDice,ItemStack output1)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput((new IRecipeInputFluid[] {new RecipeInputFluidDictionary("lubricant", 1),new RecipeInputFluidDictionary("water", 1),new RecipeInputFluidStack(moltenMetal)}),(new IRecipeInput[] {inputDice})),new UniversalRecipeOutput(null,(new ItemStack[] {output1}),200));
+ }
+
+ public static void addRecipe(String string, FluidStack fluidStack)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput [] {new RecipeInputOreDict(string)})),new UniversalRecipeOutput((new FluidStack[] {fluidStack}),null,200));
+ }
+
+
+ @Override
+ public boolean canOperate()
+ {
+ UniversalRecipeOutput output = this.getOutput();
+ if(output!=null)
+ {
+ ForgeDirection dir = ForgeDirection.getOrientation(getFacing()).getRotation(ForgeDirection.DOWN);
+ TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ);
+ if(te instanceof IProductionLine && !output.getItemOutputs().isEmpty())
+ {
+ ItemStack isOut=this.getOutput().getItemOutputs().get(0).itemStack.copy();
+ if(this.dice.get()!=null)
+ {
+ isOut.stackTagCompound.setInteger("transverseSection", this.dice.get().stackTagCompound.getInteger("transverseSection"));
+ }
+ return ForgeDirection.getOrientation(((IProductionLine)te).getFacing()).equals(dir) && ((IProductionLine)te).canProcess(isOut);
+ }
+ else if(!output.getFluidOutputs().isEmpty())
+ {
+ FluidStack fstack = output.getFluidOutputs().get(0);
+ return metalFluidTank.fill(fstack, false)==fstack.amount;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ this.oilFluidTank.readFromNBT(nbttagcompound.getCompoundTag("oilFluidTank"));
+ this.waterFluidTank.readFromNBT(nbttagcompound.getCompoundTag("waterFluidTank"));
+ this.metalFluidTank.readFromNBT(nbttagcompound.getCompoundTag("metalFluidTank"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ NBTTagCompound oilFluidTankTag = new NBTTagCompound();
+ this.oilFluidTank.writeToNBT(oilFluidTankTag);
+ nbttagcompound.setTag("oilFluidTank", oilFluidTankTag);
+ NBTTagCompound waterFluidTankTag = new NBTTagCompound();
+ this.waterFluidTank.writeToNBT(waterFluidTankTag);
+ nbttagcompound.setTag("waterFluidTank", waterFluidTankTag);
+ NBTTagCompound metalFluidTankTag = new NBTTagCompound();
+ this.metalFluidTank.writeToNBT(metalFluidTankTag);
+ nbttagcompound.setTag("metalFluidTank", metalFluidTankTag);
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ FluidStack drainSlotContent = drainInputSlot.drain(null, Integer.MAX_VALUE, null, true);
+ if(drainSlotContent!=null)
+ {
+ String fluidDictionaryName = IHLMod.fluidDictionary.getFluidName(drainSlotContent.getFluid());
+ if(fluidDictionaryName!=null && fluidDictionaryName.equals("lubricant"))
+ {
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, oilFluidTank);
+ }
+ else if(fluidDictionaryName!=null && fluidDictionaryName.equals("water"))
+ {
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, waterFluidTank);
+ }
+ else
+ {
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, metalFluidTank);
+ }
+ }
+ else
+ {
+ if(metalFluidTank.getNumberOfFluids()>0)
+ {
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, metalFluidTank);
+ }
+ else if(oilFluidTank.getNumberOfFluids()>0)
+ {
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, oilFluidTank);
+ }
+ else
+ {
+ IHLUtils.handleFluidSlotsBehaviour(fillInputSlot, drainInputSlot, emptyFluidItemsSlot, waterFluidTank);
+ }
+ }
+
+ }
+ public int gaugeLiquidScaled(int i) {
+ if(this.oilFluidTank.getFluid()!=null)
+ {
+ return this.oilFluidTank.getFluidAmount() * i /this.oilFluidTank.getCapacity();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ @Override
+ public int gaugeProgressScaled(int i)
+ {
+ return this.progress * i / this.operationLength;
+ }
+
+ public int gaugeWaterScaled(int i)
+ {
+ if(this.waterFluidTank.getFluid()!=null)
+ {
+ return this.waterFluidTank.getFluidAmount() * i /this.waterFluidTank.getCapacity();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes()
+ {
+ return recipeManager.getRecipes();
+ }
+
+
+ @Override
+ public boolean canDrain(ForgeDirection arg0, Fluid arg1) {
+ return true;
+ }
+
+
+ @Override
+ public boolean canFill(ForgeDirection arg0, Fluid arg1) {
+ return true;
+ }
+
+
+ @Override
+ public FluidStack drain(ForgeDirection direction, FluidStack arg1, boolean arg2)
+ {
+ if(direction.equals(ForgeDirection.DOWN))
+ {
+ return this.metalFluidTank.drain(arg1, arg2);
+ }
+ else if(direction.equals(ForgeDirection.UP))
+ {
+ return this.waterFluidTank.drain(arg1, arg2);
+ }
+ else
+ {
+ return this.oilFluidTank.drain(arg1, arg2);
+ }
+ }
+
+
+ @Override
+ public FluidStack drain(ForgeDirection direction, int arg1, boolean arg2)
+ {
+ if(direction.equals(ForgeDirection.DOWN))
+ {
+ return this.metalFluidTank.drain(arg1, arg2);
+ }
+ else if(direction.equals(ForgeDirection.UP))
+ {
+ return this.waterFluidTank.drain(arg1, arg2);
+ }
+ else
+ {
+ return this.oilFluidTank.drain(arg1, arg2);
+ }
+ }
+
+
+ @Override
+ public int fill(ForgeDirection direction, FluidStack arg1, boolean arg2)
+ {
+ if(direction.equals(ForgeDirection.DOWN))
+ {
+ return this.metalFluidTank.fill(arg1, arg2);
+ }
+ else if(direction.equals(ForgeDirection.UP))
+ {
+ return this.waterFluidTank.fill(arg1, arg2);
+ }
+ else
+ {
+ return this.oilFluidTank.fill(arg1, arg2);
+ }
+ }
+
+ @Override
+ public FluidTankInfo[] getTankInfo(ForgeDirection direction)
+ {
+ if(direction.equals(ForgeDirection.DOWN))
+ {
+ return new FluidTankInfo[] {this.metalFluidTank.getInfo()};
+ }
+ else if(direction.equals(ForgeDirection.UP))
+ {
+ return new FluidTankInfo[] {this.waterFluidTank.getInfo()};
+ }
+ else
+ {
+ return new FluidTankInfo[] {this.oilFluidTank.getInfo()};
+ }
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineContainer.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineContainer.java new file mode 100644 index 0000000..ba191f8 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineContainer.java @@ -0,0 +1,77 @@ +package ihl.processing.metallurgy;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class WoodenRollingMachineContainer extends ContainerBase<WoodenRollingMachinePart1TileEntity> {
+
+ public WoodenRollingMachinePart1TileEntity tileEntity;
+ public int lastProgress = -1;
+ private short lastEnergy = -1;
+ private final static int height=166;
+
+ public WoodenRollingMachineContainer(EntityPlayer entityPlayer,
+ WoodenRollingMachinePart1TileEntity lathePart1TileEntity) {
+ super(lathePart1TileEntity);
+ tileEntity=lathePart1TileEntity;
+ 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(lathePart1TileEntity.output, 0, 54, 25));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 0, 123, 15));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 1, 123, 34));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.input, 2, 123, 53));
+ this.addSlotToContainer(new SlotInvSlot(lathePart1TileEntity.dischargeSlot,0, 22, 55));
+ }
+
+ @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.progress != this.lastProgress)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress);
+ }
+ if (this.tileEntity.getEnergy() != this.lastEnergy)
+ {
+ icrafting.sendProgressBarUpdate(this, 1, this.tileEntity.getEnergy());
+ }
+ }
+ this.lastProgress = this.tileEntity.progress;
+ this.lastEnergy = (short) this.tileEntity.getEnergy();
+ }
+
+ @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.setEnergy(value);
+ break;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineGui.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineGui.java new file mode 100644 index 0000000..085dae5 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineGui.java @@ -0,0 +1,60 @@ +package ihl.processing.metallurgy;
+
+import org.lwjgl.opengl.GL11;
+
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+public class WoodenRollingMachineGui extends GuiContainer {
+
+ private WoodenRollingMachineContainer container;
+ protected static final ResourceLocation tex = new ResourceLocation("ihl", "textures/gui/GUIWoodenRollingMachine.png");
+
+ public WoodenRollingMachineGui(WoodenRollingMachineContainer latheContainer) {
+ super(latheContainer);
+ container = latheContainer;
+ }
+
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(tex);
+ 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(39, 55 + 12 - i1, 179, 12 - i1, 14, i1 + 2);
+ }
+ if (this.container.tileEntity.progress > 0)
+ {
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(27),27);
+ this.drawTexturedModalRect(18, 22, getFrameX(i1), getFrameY(i1),24,24);
+ }
+ }
+
+ @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(tex);
+ int x = (width - xSize) / 2;
+ int y = (height - ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
+ }
+
+ private int getFrameY(int number)
+ {
+ return (number % 10) * 24 + 14;
+ }
+
+ private int getFrameX(int number)
+ {
+ return (number / 10) * 24 + 176;
+ }
+}
diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java new file mode 100644 index 0000000..ac7799b --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1Model.java @@ -0,0 +1,122 @@ +// Date: 15.02.2015 11:28:39 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class WoodenRollingMachinePart1Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + IHLModelRenderer RotatingPart2; + IHLModelRenderer MotorPart1; + IHLModelRenderer MotorPart2; + IHLModelRenderer RotatingPart1; + IHLModelRenderer RotatingPart3; + IHLModelRenderer RotatingPart4; + IHLModelRenderer Belt1; + IHLModelRenderer Belt2; + + public WoodenRollingMachinePart1Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 15); + setTextureOffset("Base.Shape16", 0, 23); + setTextureOffset("Base.PipeN18", 0, 0); + setTextureOffset("Base.PipeN19", 0, 0); + setTextureOffset("RotatingPart2.PipeN17", 0, 0); + setTextureOffset("RotatingPart2.PipeN21", 0, 0); + setTextureOffset("RotatingPart2.PipeN25", 0, 0); + setTextureOffset("MotorPart1.PipeN41", 0, 0); + setTextureOffset("MotorPart1.PipeN13", 0, 0); + setTextureOffset("MotorPart1.PipeN12", 0, 0); + setTextureOffset("MotorPart1.PipeN16", 0, 0); + setTextureOffset("MotorPart2.Shape4", 0, 24); + setTextureOffset("MotorPart2.Shape7", 0, 9); + setTextureOffset("MotorPart2.Shape10", 0, 9); + setTextureOffset("RotatingPart1.PipeN27", 0, 0); + setTextureOffset("RotatingPart1.PipN119", 0, 0); + setTextureOffset("RotatingPart1.pipeN24", 0, 0); + setTextureOffset("RotatingPart3.PipeN23", 0, 0); + setTextureOffset("RotatingPart3.PipeN22", 0, 0); + setTextureOffset("RotatingPart3.PipeN26", 0, 0); + setTextureOffset("RotatingPart4.PipeN28", 0, 0); + setTextureOffset("Belt1.Shape12", 60, 0); + setTextureOffset("Belt2.Shape17", 60, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape16", -6F, -1F, -7F, 12, 8, 1); + Base.addTube("PipeN18", -5F, -6.1F, -7.1F, 10, 10, 1, 0.9F,1F,ForgeDirection.NORTH); + Base.addTube("PipeN19", -1.5F, -6F, -7F, 3, 3, 1, 0.25F,1F,ForgeDirection.NORTH);; + RotatingPart2 = new IHLModelRenderer(this, "RotatingPart2"); + RotatingPart2.setRotationPoint(-2.2F, 16F, -8F); + setRotation(RotatingPart2, 0F, 0F, 0F); + RotatingPart2.mirror = true; + RotatingPart2.addTube("PipeN17", -2F, -2F, 2F, 4, 4, 28, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN21", -0.5F, -0.5F, 0F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart2.addTube("PipeN25", -0.5F, -0.5F, 30F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + MotorPart1 = new IHLModelRenderer(this, "MotorPart1"); + MotorPart1.setRotationPoint(4.5F, 20.5F, 0F); + setRotation(MotorPart1, 0F, 0F, 0F); + MotorPart1.mirror = true; + MotorPart1.addTube("PipeN41", -1.5F, -1.5F, -8F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN12", -0.5F, -0.5F, -7F, 1, 1, 1, 0F,1F,ForgeDirection.NORTH); + MotorPart1.addTube("PipeN13", -1.5F, -1.5F, -5F, 3, 3, 5, 0F,1F,ForgeDirection.NORTH); + MotorPart2 = new IHLModelRenderer(this, "MotorPart2"); + MotorPart2.setRotationPoint(0F, 16F, 0F); + setRotation(MotorPart2, 0F, 0F, 0F); + MotorPart2.mirror = true; + MotorPart2.addBox("Shape4", 3F, 3F, 0F, 3, 4, 4); + MotorPart2.addBox("Shape7", 6F, 3F, -5F, 2, 4, 5); + MotorPart2.addBox("Shape10", 1F, 3F, -5F, 2, 4, 5); + RotatingPart1 = new IHLModelRenderer(this, "RotatingPart1"); + RotatingPart1.setRotationPoint(0F, 11.5F, -6F); + setRotation(RotatingPart1, 0F, 0F, 0F); + RotatingPart1.mirror = true; + RotatingPart1.addTube("PipeN27", -2F, -2F, 0F, 4, 4, 28, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("PipN119", -0.5F, -0.5F, -2F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + RotatingPart1.addTube("pipeN24", -0.5F, -0.5F, 28F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + RotatingPart3 = new IHLModelRenderer(this, "RotatingPart3"); + RotatingPart3.setRotationPoint(2.2F, 16F, -8F); + setRotation(RotatingPart3, 0F, 0F, 0F); + RotatingPart3.mirror = true; + RotatingPart3.addTube("PipeN23", -2F, -2F, 2F, 4, 4, 28, 0F,1F,ForgeDirection.NORTH); + RotatingPart3.addTube("PipeN22", -1.5F, -1.5F, 0F, 3, 3, 1, 0F,1F,ForgeDirection.NORTH); + RotatingPart3.addTube("PipeN26", -0.5F, -0.5F, 30F, 1, 1, 2, 0F,1F,ForgeDirection.NORTH); + RotatingPart4 = new IHLModelRenderer(this, "RotatingPart4"); + RotatingPart4.setRotationPoint(0F, 15F, -5F); + setRotation(RotatingPart3, 0F, 0F, 0F); + RotatingPart4.mirror = true; + RotatingPart4.addTube("PipeN28", -0.5F, -0.5F, 0F, 1, 1, 27, 0F,1F,ForgeDirection.NORTH); + Belt1 = new IHLModelRenderer(this, "Belt1"); + Belt1.setRotationPoint(2.5F, 16F, -7.9F); + setRotation(Belt1, 0F, 0F, -0.45F); + Belt1.mirror = true; + Belt1.addBox("Shape12", 0F, 0F, 0F, 1, 5, 1); + Belt2 = new IHLModelRenderer(this, "Belt2"); + Belt2.setRotationPoint(2F, 16F, -7.9F); + setRotation(Belt2, 0F, 0F, -0.45F); + Belt2.mirror = true; + Belt2.addBox("Shape17", -1F, 0F, 0F, 1, 6, 1); + } + + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java new file mode 100644 index 0000000..857575a --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart1TileEntity.java @@ -0,0 +1,158 @@ +package ihl.processing.metallurgy;
+
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeInputOreDict;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.block.invslot.InvSlot.Access;
+import ihl.processing.chemistry.ApparatusProcessableInvSlot;
+import ihl.processing.invslots.IHLInvSlotOutput;
+import ihl.recipes.RecipeOutputItemStack;
+import ihl.recipes.UniversalRecipeInput;
+import ihl.recipes.UniversalRecipeManager;
+import ihl.recipes.UniversalRecipeOutput;
+import ihl.utils.IHLUtils;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class WoodenRollingMachinePart1TileEntity extends BasicElectricMotorTileEntity{
+
+ public final ApparatusProcessableInvSlot input;
+ public final IHLInvSlotOutput output;
+ public boolean assembled;
+ protected static final UniversalRecipeManager recipeManager = new UniversalRecipeManager("woodenrollingmachine");
+
+ public WoodenRollingMachinePart1TileEntity()
+ {
+ super();
+ input = new ApparatusProcessableInvSlot(this, "input", 1, Access.IO, 3, 64);
+ output = new IHLInvSlotOutput(this, "output", 2, 1);
+ }
+
+ public UniversalRecipeOutput getOutput()
+ {
+ return WoodenRollingMachinePart1TileEntity.recipeManager.getOutputFor(this.getInput());
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ fields.add("assembled");
+ return fields;
+ }
+
+
+ @Override
+ public String getInventoryName() {
+ return "WoodenRollingMachine";
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+ super.updateEntityServer();
+ if(assembled && !this.checkCorrectAccembly())
+ {
+ assembled=false;
+ IC2.network.get().updateTileEntityField(this, "assembled");
+ }
+ else if(!assembled && this.checkCorrectAccembly())
+ {
+ assembled=true;
+ IC2.network.get().updateTileEntityField(this, "assembled");
+ }
+ if (this.getActive() && this.progress == 0 && !this.canOperate())
+ {
+ this.setActive(false);
+ }
+
+ if (!this.getActive() && this.progress>0 && this.canOperate())
+ {
+ this.setActive(true);
+ }
+
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer player)
+ {
+ return IHLUtils.getThisModItemStack("woodenRollingMachinePart1");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer player, boolean arg1) {
+ return new WoodenRollingMachineGui(new WoodenRollingMachineContainer(player, this));
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer player) {
+ return new WoodenRollingMachineContainer(player, this);
+ }
+
+ @Override
+ public void operate()
+ {
+ List<IRecipeInput> rInput = WoodenRollingMachinePart1TileEntity.recipeManager.getRecipeInput(getInput()).getItemInputs();
+ List<RecipeOutputItemStack> rOutput = WoodenRollingMachinePart1TileEntity.recipeManager.getOutputFor(getInput()).getItemOutputs();
+ this.output.add(rOutput);
+ for(int i=0;i<rInput.size();i++)
+ {
+ this.input.consume(rInput.get(i));
+ }
+ }
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Override
+ public List[] getInput()
+ {
+ return new List[]{null, input.getItemStackList()};
+ }
+
+ @Override
+ public boolean canOperate()
+ {
+ return this.getOutput()!=null && this.output.canAdd(this.getOutput().getItemOutputs()) && checkCorrectAccembly();
+ }
+
+ private boolean checkCorrectAccembly()
+ {
+ TileEntity te = worldObj.getTileEntity(xCoord+ForgeDirection.getOrientation(getFacing()).offsetX,yCoord+ForgeDirection.getOrientation(getFacing()).offsetY,zCoord+ForgeDirection.getOrientation(getFacing()).offsetZ);
+ return te!=null && te instanceof WoodenRollingMachinePart2TileEntity && ((WoodenRollingMachinePart2TileEntity)te).getFacing()==this.getFacing();
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {}
+
+ public static void addRecipe(RecipeInputItemStack recipeInputItemStack, RecipeInputItemStack recipeInputItemStack2, RecipeInputOreDict recipeInputOreDict, ItemStack output)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] {recipeInputItemStack,recipeInputItemStack2,recipeInputOreDict})), new UniversalRecipeOutput(null,(new ItemStack[] {output}),20));
+ }
+
+
+ public static Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return recipeManager.getRecipes();
+ }
+
+ public static void addRecipe(RecipeInputOreDict recipeInputOreDict, RecipeInputOreDict recipeInputOreDict2, ItemStack output)
+ {
+ recipeManager.addRecipe(new UniversalRecipeInput(null, (new IRecipeInput[] {recipeInputOreDict,recipeInputOreDict2})), new UniversalRecipeOutput(null,(new ItemStack[] {output}),20));
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass==0;
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java new file mode 100644 index 0000000..6ebc58e --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2Model.java @@ -0,0 +1,44 @@ +// Date: 15.02.2015 11:31:12 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + +package ihl.processing.metallurgy; + +import ihl.model.IHLModelRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraftforge.common.util.ForgeDirection; + +public class WoodenRollingMachinePart2Model extends ModelBase +{ + //fields + IHLModelRenderer Base; + + public WoodenRollingMachinePart2Model() + { + textureWidth = 64; + textureHeight = 32; + setTextureOffset("Base.Shape6", 0, 15); + setTextureOffset("Base.Shape16", 0, 23); + setTextureOffset("Base.PipeN18", 0, 0); + setTextureOffset("Base.PipeN19", 0, 0); + + Base = new IHLModelRenderer(this, "Base"); + Base.setRotationPoint(0F, 16F, 0F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape6", -8F, 7F, -8F, 16, 1, 16); + Base.addBox("Shape16", -6F, -1F, 6F, 12, 8, 1); + Base.addTube("PipeN18", -5F, -6.1F, 6.1F, 10, 10, 1, 0.9F,1F,ForgeDirection.NORTH); + Base.addTube("PipeN19", -1.5F, -6F, 6F, 3, 3, 1, 0.25F,1F,ForgeDirection.NORTH);; + } + + private void setRotation(IHLModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java new file mode 100644 index 0000000..9aec41b --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachinePart2TileEntity.java @@ -0,0 +1,104 @@ +package ihl.processing.metallurgy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import ic2.api.network.INetworkDataProvider;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ihl.utils.IHLUtils;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+
+public class WoodenRollingMachinePart2TileEntity extends TileEntity implements IWrenchable, INetworkDataProvider{
+
+ private short facing=2;
+ private short lastFacing=2;
+
+ public WoodenRollingMachinePart2TileEntity()
+ {
+ super();
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return IC2.platform.isSimulating();
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = new ArrayList();
+ fields.add("facing");
+ return fields;
+ }
+
+ @Override
+ public void updateEntity()
+ {
+ super.updateEntity();
+ if(lastFacing!=facing)
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ lastFacing=facing;
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing()!=side;
+ }
+
+
+ @Override
+ public short getFacing() {
+ return this.facing;
+ }
+
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ facing=(short) Math.max(2,facing1);
+ if(IC2.platform.isSimulating())
+ {
+ IC2.network.get().updateTileEntityField(this, "facing");
+ }
+ }
+
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
+ return true;
+ }
+
+
+ @Override
+ public float getWrenchDropRate() {
+ return 1F;
+ }
+
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ return IHLUtils.getThisModItemStack("woodenRollingMachinePart2");
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ facing=nbttagcompound.getShort("facing");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setShort("facing", facing);
+ }
+
+}
diff --git a/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineRender.java b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineRender.java new file mode 100644 index 0000000..f180f75 --- /dev/null +++ b/src/main/java/ihl/processing/metallurgy/WoodenRollingMachineRender.java @@ -0,0 +1,91 @@ +package ihl.processing.metallurgy;
+import org.lwjgl.opengl.GL11;
+
+import ic2.api.tile.IWrenchable;
+import ihl.IHLModInfo;
+import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ResourceLocation;
+
+public class WoodenRollingMachineRender extends TileEntitySpecialRenderer{
+private WoodenRollingMachinePart1Model model = new WoodenRollingMachinePart1Model();
+private ResourceLocation tex = new ResourceLocation(IHLModInfo.MODID+":textures/blocks/woodenRollingMachine.png");
+private final float scale=1F/16F;
+
+ public WoodenRollingMachineRender() {}
+
+
+ @Override
+ public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par8)
+ {
+ int rotation = 0;
+ if(tile.getWorldObj() != null)
+ {
+ switch (((IWrenchable)tile).getFacing())
+ {
+ case 2:
+ rotation = 0;
+ break;
+ case 5:
+ rotation = 1;
+ break;
+ case 3:
+ rotation = 2;
+ break;
+ case 4:
+ rotation = 3;
+ break;
+ default:
+ rotation = 0;
+ }
+ }
+ else
+ {
+ return;
+ }
+ WoodenRollingMachinePart1TileEntity cte = (WoodenRollingMachinePart1TileEntity)tile;
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
+ GL11.glScalef(1.0F, -1F, -1F);
+ GL11.glRotatef(rotation*90, 0.0F, 1.0F, 0.0F);
+
+ bindTexture(tex);
+ model.Base.render(scale);
+ if(cte.getActive())
+ {
+ model.RotatingPart1.rotateAngleZ+=0.01F;
+ model.RotatingPart2.rotateAngleZ+=0.01F;
+ model.RotatingPart3.rotateAngleZ+=0.01F;
+ model.RotatingPart4.rotateAngleZ-=0.01F;
+ model.RotatingPart1.render(scale);
+ model.RotatingPart2.render(scale);
+ model.RotatingPart3.render(scale);
+ model.RotatingPart4.render(scale);
+ model.MotorPart1.rotateAngleZ-=0.03F;
+ model.MotorPart1.render(scale);
+ model.MotorPart2.render(scale);
+ model.Belt1.render(scale);
+ model.Belt2.render(scale);
+ }
+ else
+ {
+ model.RotatingPart1.rotateAngleZ=0.0F;
+ model.RotatingPart2.rotateAngleZ=0.0F;
+ model.RotatingPart3.rotateAngleZ=0.0F;
+ model.RotatingPart4.rotateAngleZ=0.0F;
+ if(cte.assembled)
+ {
+ model.RotatingPart1.render(scale);
+ model.RotatingPart2.render(scale);
+ model.RotatingPart3.render(scale);
+ model.RotatingPart4.render(scale);
+ }
+ model.MotorPart1.render(scale);
+ model.MotorPart2.render(scale);
+ model.Belt1.render(scale);
+ model.Belt2.render(scale);
+ }
+ GL11.glPopMatrix(); //end
+
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/recipes/IRecipeInputFluid.java b/src/main/java/ihl/recipes/IRecipeInputFluid.java new file mode 100644 index 0000000..774973c --- /dev/null +++ b/src/main/java/ihl/recipes/IRecipeInputFluid.java @@ -0,0 +1,11 @@ +package ihl.recipes; + +import java.util.List; + +import net.minecraftforge.fluids.FluidStack; + +public interface IRecipeInputFluid { + public boolean matches(FluidStack subject); + public int getAmount(); + public List<FluidStack> getInputs(); +} diff --git a/src/main/java/ihl/recipes/IronWorkbenchRecipe.java b/src/main/java/ihl/recipes/IronWorkbenchRecipe.java new file mode 100644 index 0000000..e471811 --- /dev/null +++ b/src/main/java/ihl/recipes/IronWorkbenchRecipe.java @@ -0,0 +1,214 @@ +package ihl.recipes;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeInputOreDict;
+import ihl.interfaces.IWire;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+
+public class IronWorkbenchRecipe {
+ public List<ItemStack> workspaceElements=new ArrayList<ItemStack>();
+ public List<IRecipeInput> tools=new ArrayList<IRecipeInput>();
+ public List<IRecipeInput> materials=new ArrayList<IRecipeInput>();
+ public List<ItemStack> outputs = new ArrayList<ItemStack>();
+
+ public IronWorkbenchRecipe(List<?> tools1, List<?> materials1, List<ItemStack> output1_1)
+ {
+ if(tools1!=null)
+ {
+ Iterator<?> iTools1 = tools1.iterator();
+ while(iTools1.hasNext())
+ {
+ Object tool = iTools1.next();
+ if(tool instanceof ItemStack)
+ {
+ ItemStack stack = (ItemStack) tool;
+ String oreDictName = IHLUtils.getFirstOreDictNameExcludingTagAny(stack);
+ if(!oreDictName.isEmpty() && oreDictName.length()>3)
+ {
+ tools.add(new RecipeInputOreDict(oreDictName));
+ }
+ else
+ {
+ tools.add(new RecipeInputItemStack(stack));
+ }
+ }
+ else
+ {
+ tools.add((IRecipeInput) tool);
+ }
+ }
+ }
+ Iterator<?> iMaterials1 = materials1.iterator();
+ while(iMaterials1.hasNext())
+ {
+ Object material = iMaterials1.next();
+ if(material instanceof ItemStack)
+ {
+ ItemStack stack = (ItemStack) material;
+ String oreDictName = IHLUtils.getFirstOreDictNameExcludingTagAny(stack);
+ if(stack.getItem() instanceof IWire)
+ {
+ materials.add(new RecipeInputWire(stack));
+ }
+ else if(!oreDictName.isEmpty() && oreDictName.length()>3)
+ {
+ materials.add(new RecipeInputOreDict(oreDictName,stack.stackSize));
+ }
+ else
+ {
+ materials.add(new RecipeInputItemStack(stack));
+ }
+ }
+ else
+ {
+ materials.add((IRecipeInput) material);
+ }
+
+ }
+ Iterator<ItemStack> iOutput = output1_1.iterator();
+ while(iOutput.hasNext())
+ {
+ ItemStack outputStack = iOutput.next();
+ if(outputStack==null)
+ throw new NullPointerException("Output shall not contain null.");
+ this.outputs.add(outputStack);
+ }
+ if(tools.size()>8 || materials.size()>12)
+ {
+ throw new IllegalArgumentException("Iron workbench recipe cannot contain more than 8 tools or more than 12 materials!");
+ }
+ }
+
+ public IronWorkbenchRecipe(List<?> asList, List<?> asList2, List<ItemStack> asList3, List<ItemStack> workspaceElements1) {
+ this(asList, asList2, asList3);
+ if(workspaceElements1!=null)
+ {
+ this.workspaceElements.addAll(workspaceElements1);
+ }
+ }
+
+ public boolean isTool(ItemStack tool1)
+ {
+ if(tools!=null && !tools.isEmpty())
+ {
+ if(tool1==null)
+ {
+ return false;
+ }
+ Iterator<IRecipeInput> i1 = tools.iterator();
+ while(i1.hasNext())
+ {
+ IRecipeInput tool = i1.next();
+ if(tool.matches(tool1))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean isCanBeCrafted(List<ItemStack> tools1, List<ItemStack> materials1, List<ItemStack> workspaceElements1)
+ {
+ if(workspaceElements!=null && !workspaceElements.isEmpty())
+ {
+ if(workspaceElements1==null||workspaceElements1.isEmpty())
+ {
+ return false;
+ }
+ Iterator<ItemStack> i1 = workspaceElements.iterator();
+ while(i1.hasNext())
+ {
+ ItemStack tool = i1.next();
+ if(!this.isItemStackInList(tool, workspaceElements1))
+ {
+ return false;
+ }
+ }
+ }
+
+ if(tools!=null && !tools.isEmpty())
+ {
+ if(tools1==null||tools1.isEmpty())
+ {
+ return false;
+ }
+ Iterator<IRecipeInput> i1 = tools.iterator();
+ while(i1.hasNext())
+ {
+ IRecipeInput tool = i1.next();
+ if(!this.isItemStackInList(tool, tools1))
+ {
+ return false;
+ }
+ }
+ }
+ if(materials!=null && !materials.isEmpty())
+ {
+ Iterator<IRecipeInput> i1 = materials.iterator();
+ while(i1.hasNext())
+ {
+ IRecipeInput material = i1.next();
+ if(!this.isItemStackInList(material, materials1))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private boolean isItemStackInList(IRecipeInput tool, List<ItemStack> tools1) {
+ Iterator<ItemStack> it = tools1.iterator();
+ while(it.hasNext())
+ {
+ ItemStack tool2 = it.next();
+ if(tool.matches(tool2))
+ {
+ if(tool2.getItem() instanceof IWire)
+ {
+ if(IHLUtils.getWireLength(tool2)>=tool.getAmount())
+ {
+ return true;
+ }
+ }
+ else if(tool2.stackSize>=tool.getAmount())
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean isItemStackInList(ItemStack tool, List<ItemStack> tools1)
+ {
+ Iterator<ItemStack> it = tools1.iterator();
+ while(it.hasNext())
+ {
+ ItemStack tool2 = it.next();
+ if(IHLUtils.isItemStacksIsEqual(tool,tool2,true))
+ {
+ if(tool2.getItem() instanceof IWire)
+ {
+ if(IHLUtils.getWireLength(tool2)>=IHLUtils.getWireLength(tool))
+ {
+ return true;
+ }
+ }
+ else if(tool2.stackSize>=tool.stackSize)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/main/java/ihl/recipes/RecipeInputDetonator.java b/src/main/java/ihl/recipes/RecipeInputDetonator.java new file mode 100644 index 0000000..15030fd --- /dev/null +++ b/src/main/java/ihl/recipes/RecipeInputDetonator.java @@ -0,0 +1,73 @@ +package ihl.recipes;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import ic2.api.recipe.IRecipeInput;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+
+public class RecipeInputDetonator implements IRecipeInput
+{
+ public final ItemStack input;
+ public final int detonator_delay;
+
+ public RecipeInputDetonator(String string, int detonator_delay)
+ {
+ this(IHLUtils.getItemStackWithTag(string, "detonator_delay", detonator_delay));
+ }
+
+ public RecipeInputDetonator(ItemStack itemStack)
+ {
+ input=itemStack;
+ detonator_delay=itemStack.stackTagCompound.getInteger("detonator_delay");
+ }
+
+ @Override
+ public boolean matches(ItemStack subject)
+ {
+ return subject.getItem() == this.input.getItem() && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767);
+ }
+
+ @Override
+ public int getAmount()
+ {
+ return 1;
+ }
+
+ @Override
+ public List<ItemStack> getInputs()
+ {
+ return Arrays.asList(new ItemStack[] {this.input});
+ }
+
+ @Override
+ public String toString()
+ {
+ ItemStack stack = this.input.copy();
+ return "RInputDice<" + stack + ">";
+ }
+
+ public List<ItemStack> transformOutput(ItemStack matchedItemStack, List<ItemStack> outputs)
+ {
+ List<ItemStack> newOutputs = new ArrayList<ItemStack>();
+ int misTS = matchedItemStack.stackTagCompound.getInteger("detonator_delay");
+ ItemStack material;
+ for(ItemStack material1:outputs)
+ {
+ if(IHLUtils.getFirstOreDictName(material1) == "blockExplosive")
+ {
+ material=material1.copy();
+ material.stackTagCompound.setInteger("detonator_delay", misTS);
+ newOutputs.add(material);
+ }
+ else
+ {
+ newOutputs.add(material1);
+ }
+ }
+ return newOutputs;
+ }
+}
+
diff --git a/src/main/java/ihl/recipes/RecipeInputDie.java b/src/main/java/ihl/recipes/RecipeInputDie.java new file mode 100644 index 0000000..8fbd4db --- /dev/null +++ b/src/main/java/ihl/recipes/RecipeInputDie.java @@ -0,0 +1,97 @@ +package ihl.recipes;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import ic2.api.recipe.IRecipeInput;
+import ihl.interfaces.IWire;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+
+public class RecipeInputDie implements IRecipeInput
+{
+ public final ItemStack input;
+ public final int transverseSection;
+
+ public RecipeInputDie(String string, int transverseSection)
+ {
+ this(IHLUtils.getItemStackWithTag(string, "transverseSection", transverseSection));
+ }
+
+ public RecipeInputDie(ItemStack itemStack)
+ {
+ input=itemStack;
+ transverseSection=itemStack.stackTagCompound.getInteger("transverseSection");
+ }
+
+ @Override
+ public boolean matches(ItemStack subject)
+ {
+ return subject.getItem() == this.input.getItem() && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767);
+ }
+
+ @Override
+ public int getAmount()
+ {
+ return 1;
+ }
+
+ @Override
+ public List<ItemStack> getInputs()
+ {
+ return Arrays.asList(new ItemStack[] {this.input});
+ }
+
+ @Override
+ public String toString()
+ {
+ ItemStack stack = this.input.copy();
+ return "RInputDice<" + stack + ">";
+ }
+
+ public List<ItemStack> transformOutput(ItemStack matchedItemStack, List<ItemStack> outputs)
+ {
+ List<ItemStack> newOutputs = new ArrayList<ItemStack>();
+ int misTS = matchedItemStack.stackTagCompound.getInteger("transverseSection");
+ ItemStack material;
+ for(ItemStack material1:outputs)
+ {
+ if(material1.getItem() instanceof IWire)
+ {
+ material=material1.copy();
+ int length = material.stackTagCompound.getInteger("length");
+ length = length * transverseSection / misTS;
+ material.stackTagCompound.setInteger("length", length);
+ material.stackTagCompound.setInteger("fullLength", length);
+ material.stackTagCompound.setInteger("transverseSection", misTS);
+ newOutputs.add(material);
+ }
+ else
+ {
+ newOutputs.add(material1);
+ }
+ }
+ return newOutputs;
+ }
+
+ public int transformOutput(ItemStack matchedItemStack, ItemStack material)
+ {
+ int consumeAmountMultiplier=1;
+ int misTS = matchedItemStack.stackTagCompound.getInteger("transverseSection");
+ if(misTS<=transverseSection)
+ {
+ int length = material.stackTagCompound.getInteger("length");
+ length = length * transverseSection / misTS;
+ material.stackTagCompound.setInteger("length", length);
+ material.stackTagCompound.setInteger("fullLength", length);
+ }
+ else
+ {
+ consumeAmountMultiplier=misTS/transverseSection+1;
+ }
+ material.stackTagCompound.setInteger("transverseSection", misTS);
+ return consumeAmountMultiplier;
+ }
+}
+
diff --git a/src/main/java/ihl/recipes/RecipeInputFluidDictionary.java b/src/main/java/ihl/recipes/RecipeInputFluidDictionary.java new file mode 100644 index 0000000..eb5b057 --- /dev/null +++ b/src/main/java/ihl/recipes/RecipeInputFluidDictionary.java @@ -0,0 +1,46 @@ +package ihl.recipes; + +import java.util.List; + +import ihl.IHLMod; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeInputFluidDictionary implements IRecipeInputFluid +{ + private final String input; + private final int amount; + public RecipeInputFluidDictionary(String input1, int amount1) + { + this.input=input1; + this.amount=amount1; + } + + @Override + public boolean matches(FluidStack subject) + { + if(subject==null) + { + return false; + } + String fName = IHLMod.fluidDictionary.getFluidName(subject.getFluid()); + return fName==null?false:fName.equals(input); + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List<FluidStack> getInputs() { + return IHLMod.fluidDictionary.getFluids(input); + } + + @Override + public String toString() + { + return "RInputFluidStackDictionary<" + this.amount + "x" + this.input; + } + + +} diff --git a/src/main/java/ihl/recipes/RecipeInputFluidStack.java b/src/main/java/ihl/recipes/RecipeInputFluidStack.java new file mode 100644 index 0000000..e4c116d --- /dev/null +++ b/src/main/java/ihl/recipes/RecipeInputFluidStack.java @@ -0,0 +1,45 @@ +package ihl.recipes; + +import java.util.Arrays; +import java.util.List; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class RecipeInputFluidStack implements IRecipeInputFluid +{ + private final Fluid fluid; + private final int amount; + public RecipeInputFluidStack(FluidStack fstack) + { + this.fluid=fstack.getFluid(); + this.amount=fstack.amount; + } + + @Override + public boolean matches(FluidStack subject) + { + if(subject==null || subject.getFluid()==null) + { + return false; + } + return fluid.getName().equals(subject.getFluid().getName()); + } + + @Override + public int getAmount() { + return amount; + } + + @Override + public List<FluidStack> getInputs() { + return Arrays.asList(new FluidStack[] {new FluidStack(fluid,amount)}); + } + + @Override + public String toString() + { + return "RInputFluidStack<" + this.amount + "x" + this.fluid.getName(); + } + +} diff --git a/src/main/java/ihl/recipes/RecipeInputObjectInstance.java b/src/main/java/ihl/recipes/RecipeInputObjectInstance.java new file mode 100644 index 0000000..42fdc26 --- /dev/null +++ b/src/main/java/ihl/recipes/RecipeInputObjectInstance.java @@ -0,0 +1,44 @@ +package ihl.recipes; + +import java.util.Arrays; +import java.util.List; + +import ic2.api.recipe.IRecipeInput; +import ihl.utils.IHLUtils; +import net.minecraft.item.ItemStack; + +public class RecipeInputObjectInstance implements IRecipeInput +{ + public final ItemStack input; + + public RecipeInputObjectInstance(ItemStack aInput) + { + this.input = aInput; + } + + @Override + public boolean matches(ItemStack subject) + { + return this.input==subject; + } + + @Override + public int getAmount() + { + return IHLUtils.getAmountOf(input); + } + + @Override + public List<ItemStack> getInputs() + { + return Arrays.asList(new ItemStack[] {this.input}); + } + + @Override + public String toString() + { + ItemStack stack = this.input.copy(); + return "RInputWireItemStack<" + stack + ">"; + } + +} diff --git a/src/main/java/ihl/recipes/RecipeInputOreDictionaryList.java b/src/main/java/ihl/recipes/RecipeInputOreDictionaryList.java new file mode 100644 index 0000000..e438d98 --- /dev/null +++ b/src/main/java/ihl/recipes/RecipeInputOreDictionaryList.java @@ -0,0 +1,122 @@ +package ihl.recipes;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import ic2.api.recipe.IRecipeInput;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
+
+public class RecipeInputOreDictionaryList implements IRecipeInput {
+
+ public final String[] input;
+ public final int amount;
+ public final Integer meta;
+ private List<ItemStack> ores;
+
+ public RecipeInputOreDictionaryList(String[] input1) {
+ this(input1, 1);
+ }
+
+ public RecipeInputOreDictionaryList(String[] input1, int amount1) {
+ this(input1, amount1, (Integer) null);
+ }
+
+ public RecipeInputOreDictionaryList(String[] input1, int amount1, Integer meta) {
+ this.input = input1;
+ this.amount = amount1;
+ this.meta = meta;
+ }
+
+ @Override
+ public boolean matches(ItemStack subject) {
+ List<ItemStack> inputs = this.getOres();
+ boolean useOreStackMeta = this.meta == null;
+ Item subjectItem = subject.getItem();
+ int subjectMeta = subject.getItemDamage();
+ Iterator<ItemStack> i$ = inputs.iterator();
+ Item oreItem;
+ int metaRequired;
+
+ do {
+ do {
+ ItemStack oreStack;
+
+ do {
+ if (!i$.hasNext()) {
+ return false;
+ }
+
+ oreStack = i$.next();
+ oreItem = oreStack.getItem();
+ } while (oreItem == null);
+
+ metaRequired = useOreStackMeta ? oreStack.getItemDamage() : this.meta.intValue();
+ } while (subjectItem != oreItem);
+ } while (subjectMeta != metaRequired && metaRequired != 32767);
+
+ return true;
+ }
+
+ @Override
+ public int getAmount() {
+ return this.amount;
+ }
+
+ @Override
+ public List<ItemStack> getInputs() {
+ List<ItemStack> ores = this.getOres();
+ boolean hasInvalidEntries = false;
+ Iterator<ItemStack> ret = ores.iterator();
+
+ while (ret.hasNext()) {
+ ItemStack i$ = ret.next();
+
+ if (i$.getItem() == null) {
+ hasInvalidEntries = true;
+ break;
+ }
+ }
+
+ if (!hasInvalidEntries) {
+ return ores;
+ } else {
+ ArrayList<ItemStack> ret1 = new ArrayList<ItemStack>(ores.size());
+ Iterator<ItemStack> i$1 = ores.iterator();
+
+ while (i$1.hasNext()) {
+ ItemStack stack = i$1.next();
+
+ if (stack.getItem() != null) {
+ ret1.add(stack);
+ }
+ }
+
+ return Collections.unmodifiableList(ret1);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.meta == null ? "RInputOreDict<" + this.amount + "x" + this.input + ">"
+ : "RInputOreDict<" + this.amount + "x" + this.input + "@" + this.meta + ">";
+ }
+
+ private List<ItemStack> getOres() {
+ if (this.ores != null) {
+ return this.ores;
+ } else {
+ this.ores = new ArrayList<ItemStack>();
+ for (int i = 0; i < this.input.length; i++) {
+ ArrayList<ItemStack> ret = OreDictionary.getOres(this.input[i]);
+ if (ret != OreDictionary.EMPTY_LIST) {
+ this.ores.addAll(ret);
+ }
+ }
+ return this.ores;
+ }
+ }
+}
diff --git a/src/main/java/ihl/recipes/RecipeInputWire.java b/src/main/java/ihl/recipes/RecipeInputWire.java new file mode 100644 index 0000000..a7d5310 --- /dev/null +++ b/src/main/java/ihl/recipes/RecipeInputWire.java @@ -0,0 +1,72 @@ +package ihl.recipes;
+
+import java.util.Arrays;
+import java.util.List;
+
+import ic2.api.recipe.IRecipeInput;
+import ihl.interfaces.IWire;
+import ihl.items_blocks.FlexibleCableItem;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+
+public class RecipeInputWire implements IRecipeInput {
+ public final ItemStack input;
+ public final int amount;
+
+ public RecipeInputWire(final ItemStack aInput) {
+ this(aInput, IHLUtils.getWireLength(aInput));
+ }
+
+ public RecipeInputWire(final ItemStack aInput, int aAmount) {
+ if (aInput.getItem() == null || !(aInput.getItem() instanceof IWire)) {
+ throw new IllegalArgumentException("Invalid item stack specfied");
+ } else {
+ this.input = aInput;
+ this.amount = aAmount;
+ }
+ }
+
+ public RecipeInputWire(String string, int i) {
+ this(IHLUtils.getThisModWireItemStackWithLength(string, i), i);
+ }
+
+ public RecipeInputWire(String material, int length, int transverseSection) {
+ this(IHLUtils.getUninsulatedWire(material, length, transverseSection), length);
+ }
+
+ public RecipeInputWire(String material, int length, int transverseSection, String insulationMaterial,
+ int insulationThickness, int insulationBreakdownVoltage) {
+ this(IHLUtils.getInsulatedWire(material, length, transverseSection, insulationMaterial, insulationThickness),
+ length);
+ }
+
+ @Override
+ public boolean matches(ItemStack subject) {
+ if (subject.getItem() == this.input.getItem()
+ && (subject.getItemDamage() == this.input.getItemDamage() || this.input.getItemDamage() == 32767)) {
+ if (subject.getItem() instanceof FlexibleCableItem) {
+ FlexibleCableItem item = (FlexibleCableItem) subject.getItem();
+ return item.isSameWire(this.input, subject);
+ } else {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int getAmount() {
+ return this.amount;
+ }
+
+ @Override
+ public List<ItemStack> getInputs() {
+ return Arrays.asList(new ItemStack[] { this.input });
+ }
+
+ @Override
+ public String toString() {
+ ItemStack stack = this.input.copy();
+ return "RInputWireItemStack<" + stack + ">";
+ }
+}
diff --git a/src/main/java/ihl/recipes/RecipeOutputItemStack.java b/src/main/java/ihl/recipes/RecipeOutputItemStack.java new file mode 100644 index 0000000..480d1f8 --- /dev/null +++ b/src/main/java/ihl/recipes/RecipeOutputItemStack.java @@ -0,0 +1,52 @@ +package ihl.recipes;
+
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.OreDictionary;
+
+public class RecipeOutputItemStack {
+ public final ItemStack itemStack;
+ public final float quantity;
+
+ public RecipeOutputItemStack(ItemStack itemStack1, float quantity1) {
+ itemStack = itemStack1;
+ quantity = quantity1;
+ itemStack.stackSize = 1;
+ }
+
+ public RecipeOutputItemStack(ItemStack itemStack1) {
+ this(itemStack1, itemStack1.stackSize);
+ }
+
+ public boolean matches(RecipeOutputItemStack is1) {
+ if (is1 == null || (itemStack.getItem() != is1.itemStack.getItem())) {
+ return false;
+ } else if (is1.itemStack.getItemDamage() != OreDictionary.WILDCARD_VALUE
+ && itemStack.getItemDamage() != is1.itemStack.getItemDamage()) {
+ return false;
+ }
+ return true;
+ }
+
+ public RecipeOutputItemStack copy(int mulipier) {
+ return new RecipeOutputItemStack(itemStack, quantity * mulipier);
+ }
+
+ public RecipeOutputItemStack copy() {
+ return new RecipeOutputItemStack(itemStack, quantity);
+ }
+
+ @Override
+ public String toString() {
+ return this.itemStack.getUnlocalizedName() + ":" + this.quantity;
+ }
+
+ public boolean matches(ItemStack is1) {
+ if (is1 == null || (itemStack.getItem() != is1.getItem())) {
+ return false;
+ } else if (is1.getItemDamage() != OreDictionary.WILDCARD_VALUE
+ && itemStack.getItemDamage() != is1.getItemDamage()) {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/ihl/recipes/UniversalRecipeInput.java b/src/main/java/ihl/recipes/UniversalRecipeInput.java new file mode 100644 index 0000000..7cdb386 --- /dev/null +++ b/src/main/java/ihl/recipes/UniversalRecipeInput.java @@ -0,0 +1,205 @@ +package ihl.recipes;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeInputOreDict;
+import ihl.interfaces.IWire;
+import ihl.utils.IHLUtils;
+import ihl.worldgen.ores.IHLFluid;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+public class UniversalRecipeInput {
+
+ private final List<IRecipeInputFluid> fluidInputs = new ArrayList<IRecipeInputFluid>();
+ private final List<IRecipeInput> itemInputs = new ArrayList<IRecipeInput>();
+
+ public UniversalRecipeInput(Object[] fluidStacks, Object[] iRecipeInputs) {
+ if (fluidStacks != null) {
+ for (Object material : fluidStacks) {
+ if (material == null) {
+ throw new NullPointerException("Recipe input cannot be null!");
+ }
+ if (material instanceof FluidStack) {
+ fluidInputs.add(new RecipeInputFluidStack((FluidStack) material));
+ } else {
+ fluidInputs.add((IRecipeInputFluid) material);
+ }
+ }
+ }
+ sortFluidsByDensity();
+ if (iRecipeInputs != null) {
+ for (Object material : iRecipeInputs) {
+ if (material == null) {
+ throw new NullPointerException("Recipe input cannot be null!");
+ }
+ if (material instanceof ItemStack) {
+ ItemStack stack = (ItemStack) material;
+ String oreDictName = IHLUtils.getFirstOreDictNameExcludingTagAny(stack);
+ if (stack.getItem() instanceof IWire) {
+ itemInputs.add(new RecipeInputWire(stack));
+ } else if (!oreDictName.isEmpty() && oreDictName.length() > 3) {
+ itemInputs.add(new RecipeInputOreDict(oreDictName, stack.stackSize));
+ } else {
+ itemInputs.add(new RecipeInputItemStack(stack));
+ }
+ } else {
+ itemInputs.add((IRecipeInput) material);
+ }
+ }
+ }
+ }
+
+ public void sortFluidsByDensity()
+ {
+ Map<Integer, IRecipeInputFluid> sortMap = new HashMap<Integer, IRecipeInputFluid>();
+ int[] keysArray = new int[fluidInputs.size()];
+ Iterator<IRecipeInputFluid> fli = fluidInputs.iterator();
+ while(fli.hasNext())
+ {
+ IRecipeInputFluid rinput = fli.next();
+ FluidStack fluid=rinput.getInputs().get(0);
+ if(fluid==null)
+ {
+ return;
+ }
+ int key = Math.round(IHLFluid.getRealDensity(fluid.getFluid())*100F);
+ while(sortMap.containsKey(key))
+ {
+ key++;
+ }
+ sortMap.put(key, rinput);
+ keysArray[fluidInputs.indexOf(rinput)]=key;
+ }
+ Arrays.sort(keysArray);
+ List<IRecipeInputFluid> newFluidList = new ArrayList<IRecipeInputFluid>();
+ for(int i=keysArray.length-1;i>=0;i--)
+ {
+ newFluidList.add(sortMap.get(keysArray[i]));
+ }
+ this.fluidInputs.clear();
+ this.fluidInputs.addAll(newFluidList);
+ }
+
+ public boolean matches(List<FluidStack> fluidInputs1, List<ItemStack> itemInputs1) {
+ return this.matches(fluidInputs1, itemInputs1, false);
+ }
+
+ public List<IRecipeInputFluid> getFluidInputs() {
+ return fluidInputs;
+ }
+
+ public List<IRecipeInput> getItemInputs() {
+ return itemInputs;
+ }
+
+ public boolean matches(UniversalRecipeInput input) {
+ List<IRecipeInput> rInputs = input.getItemInputs();
+ Iterator<IRecipeInput> ii = rInputs.iterator();
+ List<ItemStack> rInputsItems = new ArrayList<ItemStack>();
+ while (ii.hasNext()) {
+ IRecipeInput is = ii.next();
+ rInputsItems.add(is.getInputs().get(0));
+ }
+ List<FluidStack> rInputsFluids = new ArrayList<FluidStack>();
+ List<IRecipeInputFluid> rInputsF = input.getFluidInputs();
+ Iterator<IRecipeInputFluid> iiF = rInputsF.iterator();
+ while (iiF.hasNext()) {
+ IRecipeInputFluid is = iiF.next();
+ rInputsFluids.add(is.getInputs().get(0));
+ }
+ return this.matches(rInputsFluids, rInputsItems);
+ }
+
+ public boolean matches(List<FluidStack> fluidInputs1, List<ItemStack> itemInputs1, boolean doCheckAmounts) {
+ if (incorrectInputAmount(fluidInputs1, itemInputs1)) {
+ return false;
+ }
+ if (fluidInputs1 != null) {
+ Iterator<IRecipeInputFluid> fi = fluidInputs.iterator();
+ while (fi.hasNext()) {
+ IRecipeInputFluid fs = fi.next();
+ FluidStack fs1 = getMatchedFluidStack(fs, fluidInputs1);
+ if (fs1 == null || !fs.matches(fs1)) {
+ return false;
+ } else if (doCheckAmounts && fs1.amount < fs.getAmount()) {
+ return false;
+ }
+ }
+ }
+ if (itemInputs1 != null) {
+ Iterator<IRecipeInput> ii = itemInputs.iterator();
+ while (ii.hasNext()) {
+ IRecipeInput is = ii.next();
+ ItemStack is1 = getMatchedItemStack(is, itemInputs1);
+ if (is1 == null || !is.matches(is1)) {
+ return false;
+ } else if (doCheckAmounts && IHLUtils.getAmountOf(is1) < is.getAmount()) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ private ItemStack getMatchedItemStack(IRecipeInput is, List<ItemStack> itemInputs1) {
+ for (ItemStack is1 : itemInputs1) {
+ if (is1 != null) {
+ if (is.matches(is1)) {
+ return is1;
+ }
+ }
+ }
+ return null;
+ }
+
+ private FluidStack getMatchedFluidStack(IRecipeInputFluid fs, List<FluidStack> fluidInputs1) {
+ for (FluidStack fs1 : fluidInputs1) {
+ if (fs.matches(fs1)) {
+ return fs1;
+ }
+ }
+ return null;
+ }
+
+ public boolean containItemStack(ItemStack ingredient) {
+ if (itemInputs == null || itemInputs.isEmpty()) {
+ return false;
+ }
+ Iterator<IRecipeInput> ii = itemInputs.iterator();
+ while (ii.hasNext()) {
+ IRecipeInput is = ii.next();
+ if (is.matches(ingredient)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean containFluidStack(FluidStack fluidStack) {
+ if (fluidInputs == null || fluidInputs.isEmpty()) {
+ return false;
+ }
+ Iterator<IRecipeInputFluid> ii = fluidInputs.iterator();
+ while (ii.hasNext()) {
+ IRecipeInputFluid is = ii.next();
+ if (is != null && is.matches(fluidStack)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean incorrectInputAmount(List<FluidStack> fluidInputs1, List<ItemStack> itemInputs1) {
+ return (fluidInputs.size() > 0 && fluidInputs1 == null) || (itemInputs.size() > 0 && itemInputs1 == null)
+ || (fluidInputs1 != null && fluidInputs.size() > fluidInputs1.size())
+ || (itemInputs1 != null && itemInputs.size() > itemInputs1.size());
+ }
+}
diff --git a/src/main/java/ihl/recipes/UniversalRecipeManager.java b/src/main/java/ihl/recipes/UniversalRecipeManager.java new file mode 100644 index 0000000..cddc252 --- /dev/null +++ b/src/main/java/ihl/recipes/UniversalRecipeManager.java @@ -0,0 +1,195 @@ +package ihl.recipes;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import ic2.api.recipe.IRecipeInput;
+import ihl.utils.IHLUtils;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+public class UniversalRecipeManager {
+
+ public static Map<String, UniversalRecipeManager> machineRecipeManagers = new HashMap<String, UniversalRecipeManager>();
+ public final String machine;
+
+ public UniversalRecipeManager(String machine1) {
+ machine = machine1;
+ if (machineRecipeManagers.containsKey(machine1)) {
+ throw new IllegalArgumentException("Recipe manager for " + machine1 + " already exist!");
+ }
+ machineRecipeManagers.put(machine1, this);
+ }
+
+ private final Map<UniversalRecipeInput, UniversalRecipeOutput> recipes = new HashMap<UniversalRecipeInput, UniversalRecipeOutput>();
+ private final Map<String, UniversalRecipeInput> keywordMap = new HashMap<String, UniversalRecipeInput>();
+
+ public void addRecipe(UniversalRecipeInput input, UniversalRecipeOutput output) {
+ if (input == null) {
+ throw new NullPointerException("The recipe input is null");
+ } else {
+ if (output.getFluidOutputs() == null || output.getItemOutputs() == null
+ || (output.getFluidOutputs().size() == 0 && output.getItemOutputs().size() == 0)) {
+ throw new NullPointerException("The output is empty");
+ }
+ }
+
+ Iterator<UniversalRecipeInput> var8 = this.recipes.keySet().iterator();
+
+ while (var8.hasNext()) {
+ UniversalRecipeInput existingInput = (UniversalRecipeInput) var8.next();
+ if (existingInput.matches(input)) {
+ StringBuffer ssError = new StringBuffer(255);
+ ssError.append("Ambiguous recipe. \n");
+ ssError.append("Existing input: \n");
+ Iterator<IRecipeInput> iii1 = existingInput.getItemInputs().iterator();
+ Iterator<IRecipeInputFluid> fii1 = existingInput.getFluidInputs().iterator();
+ while (iii1 != null && iii1.hasNext()) {
+ ssError.append(iii1.next().toString());
+ ssError.append(" \n");
+ }
+ while (fii1 != null && fii1.hasNext()) {
+ ssError.append(fii1.next().toString());
+ ssError.append(" \n");
+ }
+ ssError.append("New input: \n");
+ Iterator<IRecipeInput> iii2 = input.getItemInputs().iterator();
+ Iterator<IRecipeInputFluid> fii2 = input.getFluidInputs().iterator();
+ while (iii2 != null && iii2.hasNext()) {
+ ssError.append(iii2.next().toString());
+ ssError.append(" \n");
+ }
+ while (fii2 != null && fii2.hasNext()) {
+ ssError.append(fii2.next().toString());
+ ssError.append(" \n");
+ }
+ throw new RuntimeException(ssError.toString());
+ }
+ }
+
+ this.recipes.put(input, output);
+ }
+
+ public void addRecipe(String keyword, UniversalRecipeInput input, UniversalRecipeOutput output) {
+ this.addRecipe(input, output);
+ this.keywordMap.put(keyword, input);
+ }
+
+ public UniversalRecipeOutput getOutputFor(List<FluidStack> fluidInputs, List<ItemStack> itemInputs) {
+ if (fluidInputs == null && itemInputs == null) {
+ return null;
+ } else {
+ Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.recipes.entrySet().iterator();
+
+ while (true) {
+ if (i$.hasNext()) {
+ Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
+ UniversalRecipeInput recipeInput = entry.getKey();
+
+ if (!recipeInput.matches(fluidInputs, itemInputs)) {
+ continue;
+ }
+
+ if (recipeInput.matches(fluidInputs, itemInputs, true)) {
+ return entry.getValue();
+ }
+ }
+
+ return null;
+ }
+ }
+ }
+
+ public Map<UniversalRecipeInput, UniversalRecipeOutput> getRecipes() {
+ return this.recipes;
+ }
+
+ public UniversalRecipeInput getRecipeInput(List<FluidStack> fluidInputs1, List<ItemStack> itemInputs1) {
+ {
+ Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.recipes.entrySet().iterator();
+
+ while (true) {
+ if (i$.hasNext()) {
+ Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
+ UniversalRecipeInput recipeInput = entry.getKey();
+
+ if (!recipeInput.matches(fluidInputs1, itemInputs1)) {
+ continue;
+ }
+
+ if (recipeInput.matches(fluidInputs1, itemInputs1, true)) {
+ return recipeInput;
+ }
+ }
+
+ return null;
+ }
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public UniversalRecipeOutput getOutputFor(List[] input) {
+ return this.getOutputFor(input[0], input[1]);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public UniversalRecipeInput getRecipeInput(List[] input) {
+ return this.getRecipeInput(input[0], input[1]);
+ }
+
+ public void removeRecipeByInput(UniversalRecipeInput uRecipeInput) {
+ List<FluidStack> fluidInputs = IHLUtils.convertRecipeInputToFluidStackList(uRecipeInput.getFluidInputs());
+ List<ItemStack> itemInputs = IHLUtils.convertRecipeInputToItemStackList(uRecipeInput.getItemInputs());
+ {
+ Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.recipes.entrySet().iterator();
+ while (i$.hasNext()) {
+ Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
+ UniversalRecipeInput recipeInput = entry.getKey();
+ if (recipeInput.matches(fluidInputs, itemInputs)) {
+ i$.remove();
+ break;
+ }
+ }
+ }
+ }
+
+ public void removeRecipeByOutput(UniversalRecipeOutput uRecipeOutput) {
+ Iterator<Entry<UniversalRecipeInput, UniversalRecipeOutput>> i$ = this.recipes.entrySet().iterator();
+ while (i$.hasNext()) {
+ Entry<UniversalRecipeInput, UniversalRecipeOutput> entry = i$.next();
+ UniversalRecipeOutput recipeOutput = entry.getValue();
+ if (recipeOutputHasCommonEntries(recipeOutput, uRecipeOutput)) {
+ i$.remove();
+ }
+ }
+ }
+
+ public boolean recipeOutputHasCommonEntries(UniversalRecipeOutput out, UniversalRecipeOutput out1) {
+ List<FluidStack> fluidOutputs = out.getFluidOutputs();
+ List<RecipeOutputItemStack> itemOutputs = out.getItemOutputs();
+ if (!fluidOutputs.isEmpty() && !out1.getFluidOutputs().isEmpty()) {
+ FluidStack fs1 = out1.getFluidOutputs().get(0);
+ Iterator<FluidStack> fi = fluidOutputs.iterator();
+ while (fi.hasNext()) {
+ FluidStack fs = fi.next();
+ if (fs.getFluid() == fs1.getFluid()) {
+ return true;
+ }
+ }
+ }
+ if (!itemOutputs.isEmpty() && !out1.getItemOutputs().isEmpty()) {
+ RecipeOutputItemStack is1 = out1.getItemOutputs().get(0);
+ Iterator<RecipeOutputItemStack> ii = itemOutputs.iterator();
+ while (ii.hasNext()) {
+ RecipeOutputItemStack is = ii.next();
+ if (is.matches(is1)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/ihl/recipes/UniversalRecipeOutput.java b/src/main/java/ihl/recipes/UniversalRecipeOutput.java new file mode 100644 index 0000000..17c20e4 --- /dev/null +++ b/src/main/java/ihl/recipes/UniversalRecipeOutput.java @@ -0,0 +1,149 @@ +package ihl.recipes;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.FluidStack;
+
+public class UniversalRecipeOutput{
+
+ private final List<FluidStack> fluidOutputs=new ArrayList<FluidStack>();
+ private final List<RecipeOutputItemStack> itemOutputs=new ArrayList<RecipeOutputItemStack>();
+ private final int time;
+ public final boolean specialConditions;
+
+ public UniversalRecipeOutput(FluidStack[] fluidOutputs1, Object[] itemOutputs1, int time1)
+ {
+ this(fluidOutputs1, itemOutputs1, time1,false);
+ }
+
+ public UniversalRecipeOutput(FluidStack[] fluidStacks, Object[] recipeOutputItemStacks, int time1, boolean specialConditions1)
+ {
+ if(fluidStacks!=null)
+ {
+ for(FluidStack fStack:fluidStacks)
+ {
+ if(fStack==null)
+ {
+ throw new NullPointerException("Recipe cannot contain null elements!");
+ }
+ fluidOutputs.add(fStack);
+ }
+ }
+ if(recipeOutputItemStacks!=null)
+ {
+ for(Object io:recipeOutputItemStacks)
+ {
+ if(io==null)
+ {
+ throw new NullPointerException("Recipe output cannot be null!");
+ }
+ if(io instanceof ItemStack)
+ {
+ this.itemOutputs.add(new RecipeOutputItemStack((ItemStack) io));
+ }
+ else
+ {
+ this.itemOutputs.add((RecipeOutputItemStack) io);
+ }
+ }
+ }
+ specialConditions=specialConditions1;
+ time=time1;
+ }
+
+ public UniversalRecipeOutput(List<FluidStack> recipeOutputsFluids,
+ List<RecipeOutputItemStack> recipeOutputsRecipeOut, int time1) {
+ this.fluidOutputs.addAll(recipeOutputsFluids);
+ this.itemOutputs.addAll(recipeOutputsRecipeOut);
+ this.time=time1;
+ this.specialConditions=false;
+ }
+
+ public boolean matches(List<FluidStack> fluidOutputs1, List<ItemStack> itemOutputs1)
+ {
+ if(fluidOutputs.size()!=fluidOutputs1.size()||itemOutputs.size()!=itemOutputs.size())
+ {
+ return false;
+ }
+ Iterator<FluidStack> fi1 = fluidOutputs1.iterator();
+ Iterator<ItemStack> ii1 = itemOutputs1.iterator();
+ Iterator<FluidStack> fi = fluidOutputs.iterator();
+ Iterator<RecipeOutputItemStack> ii = itemOutputs.iterator();
+ while(fi.hasNext())
+ {
+ FluidStack fs = fi.next();
+ FluidStack fs1 = fi1.next();
+ if(fs.getFluid()!=fs1.getFluid())
+ {
+ return false;
+ }
+ }
+ while(ii.hasNext())
+ {
+ RecipeOutputItemStack is = ii.next();
+ ItemStack is1 = ii1.next();
+ if(!is.matches(is1))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public List<FluidStack> getFluidOutputs() {
+ return fluidOutputs;
+ }
+
+ public List<RecipeOutputItemStack> getItemOutputs() {
+ return itemOutputs;
+ }
+
+ public UniversalRecipeOutput copyWithMultiplier(int mulipier) {
+ FluidStack[] fluidStacks = null;
+ RecipeOutputItemStack[] itemStacks = null;
+ if(fluidOutputs!=null && !fluidOutputs.isEmpty())
+ {
+ fluidStacks = new FluidStack[fluidOutputs.size()];
+ for(int i=0;i<fluidOutputs.size();i++)
+ {
+ FluidStack fs = fluidOutputs.get(i);
+ FluidStack newFs = fs.copy();
+ newFs.amount*=mulipier;
+ fluidStacks[i]=fs;
+ }
+ }
+ if(itemOutputs!=null && !itemOutputs.isEmpty())
+ {
+ itemStacks = new RecipeOutputItemStack[itemOutputs.size()];
+ for(int i=0;i<itemOutputs.size();i++)
+ {
+ RecipeOutputItemStack is = itemOutputs.get(i);
+ RecipeOutputItemStack newIs = is.copy(mulipier);
+ itemStacks[i]=newIs;
+ }
+ }
+ return new UniversalRecipeOutput(fluidStacks,itemStacks, getTime(),false);
+ }
+
+ public int getTime() {
+ return time;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer out = new StringBuffer();
+ for(FluidStack fluid: this.fluidOutputs)
+ {
+ out.append(fluid.getLocalizedName()+": "+fluid.amount+"/n");
+ }
+ for(RecipeOutputItemStack stack: this.itemOutputs)
+ {
+ out.append(stack.itemStack.getDisplayName()+": "+stack.quantity+"/n");
+ }
+ return out.toString();
+ }
+}
diff --git a/src/main/java/ihl/servitor/BoneBlock.java b/src/main/java/ihl/servitor/BoneBlock.java new file mode 100644 index 0000000..549a92b --- /dev/null +++ b/src/main/java/ihl/servitor/BoneBlock.java @@ -0,0 +1,108 @@ +package ihl.servitor;
+
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.passive.EntityPig;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+public class BoneBlock extends Block {
+ IIcon textureSide2,textureSide3,textureSide4,textureTop;
+
+ public BoneBlock(Material material) {
+ super(material);
+ this.setCreativeTab(CreativeTabs.tabBlock);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockSide1");
+ this.textureTop = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockTop");
+ this.textureSide2 = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockSide2");
+ this.textureSide3 = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockSide3");
+ this.textureSide4 = par1IconRegister.registerIcon(IHLModInfo.MODID + ":boneBlockSide4");
+ }
+
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
+ {
+ if(!world.isRemote)
+ {
+ if(world.getBlock(x, y+1, z)==Blocks.fire)
+ {
+ AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(x, y+1D, z, x+1D, y+2D, z+1D);
+ List pigList = world.getEntitiesWithinAABB(EntityPig.class, aabb);
+ if(pigList!=null && pigList.size()>0)
+ {
+ EntityPig pig = (EntityPig) pigList.get(0);
+ DamageSource ds = DamageSource.wither;
+ pig.attackEntityFrom(ds, 10F);
+ LostHeadEntity lh = new LostHeadEntity(world);
+ lh.setPosition(pig.posX,pig.posY,pig.posZ);
+ world.spawnEntityInWorld(lh);
+ }
+ }
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
+ {
+ Block topBlock = world.getBlock(x, y+1, z);
+ Block bottomBlock = world.getBlock(x, y-1, z);
+ IIcon sideIcon = this.blockIcon;
+ if(topBlock==this && bottomBlock==this)
+ {
+ sideIcon = this.textureSide4;
+ }
+ else if(topBlock==this)
+ {
+ sideIcon = this.textureSide3;
+ }
+ else if(bottomBlock==this)
+ {
+ sideIcon = this.textureSide2;
+ }
+ switch (side)
+ {
+ case 0:
+ return this.textureTop;
+ case 1:
+ return this.textureTop;
+ default:
+ return sideIcon;
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta)
+ {
+ IIcon sideIcon = this.blockIcon;
+ switch (side)
+ {
+ case 0:
+ return this.textureTop;
+ case 1:
+ return this.textureTop;
+ default:
+ return sideIcon;
+ }
+ }
+}
diff --git a/src/main/java/ihl/servitor/FlameEntityFX.java b/src/main/java/ihl/servitor/FlameEntityFX.java new file mode 100644 index 0000000..783476e --- /dev/null +++ b/src/main/java/ihl/servitor/FlameEntityFX.java @@ -0,0 +1,87 @@ +package ihl.servitor;
+
+import net.minecraft.client.particle.EntityFX;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.world.World;
+
+public class FlameEntityFX extends EntityFX {
+
+ public FlameEntityFX(World world, double x, double y, double z)
+ {
+ super(world, x, y, z);
+ this.renderDistanceWeight = 5.0D;
+ }
+
+ public FlameEntityFX(World par1World, double par2, double par4, double par6, double par8, double par10, double par12, float par14)
+ {
+ super(par1World, par2, par4, par6, 0.0D, 0.0D, 0.0D);
+ this.motionX *= 0.10000000149011612D;
+ this.motionY *= 0.10000000149011612D;
+ this.motionZ *= 0.10000000149011612D;
+ this.motionX += par8;
+ this.motionY += par10;
+ this.motionZ += par12;
+ this.particleScale *= par14;
+ this.particleMaxAge = (int)(8.0D / (Math.random() * 0.8D + 0.2D));
+ this.noClip = false;
+ this.renderDistanceWeight = 6.0D;
+ }
+
+ @Override
+ public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
+ {
+ float var8 = this.particleTextureIndexX / 4.0F;
+ float var9 = var8 + 0.0624375F*4F;
+ float var10 = this.particleTextureIndexY / 4.0F;
+ float var11 = var10 + 0.0624375F*4F;
+ float var12 = 0.1F * this.particleScale;
+
+ float var13 = (float)(this.prevPosX + (this.posX - this.prevPosX) * par2 - interpPosX);
+ float var14 = (float)(this.prevPosY + (this.posY - this.prevPosY) * par2 - interpPosY);
+ float var15 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * par2 - interpPosZ);
+ par1Tessellator.addVertexWithUV(var13 - par3 * var12 - par6 * var12, var14 - par4 * var12, var15 - par5 * var12 - par7 * var12, var9, var11);
+ par1Tessellator.addVertexWithUV(var13 - par3 * var12 + par6 * var12, var14 + par4 * var12, var15 - par5 * var12 + par7 * var12, var9, var10);
+ par1Tessellator.addVertexWithUV(var13 + par3 * var12 + par6 * var12, var14 + par4 * var12, var15 + par5 * var12 + par7 * var12, var8, var10);
+ par1Tessellator.addVertexWithUV(var13 + par3 * var12 - par6 * var12, var14 - par4 * var12, var15 + par5 * var12 - par7 * var12, var8, var11);
+ }
+
+ @Override
+ public void onUpdate()
+ {
+ this.prevPosX = this.posX;
+ this.prevPosY = this.posY;
+ this.prevPosZ = this.posZ;
+
+ if (this.particleAge++ >= this.particleMaxAge)
+ {
+ this.setDead();
+ }
+ this.setParticleTextureIndex(this.particleAge * 15 / this.particleMaxAge);
+ this.motionY += 0.004D;
+ this.moveEntity(this.motionX, this.motionY, this.motionZ);
+
+ if (this.posY == this.prevPosY)
+ {
+ this.motionX *= 1.1D;
+ this.motionZ *= 1.1D;
+ }
+
+ this.motionX *= 0.9599999785423279D;
+ this.motionY *= 0.9599999785423279D;
+ this.motionZ *= 0.9599999785423279D;
+
+ if (this.onGround)
+ {
+ this.motionX *= 0.699999988079071D;
+ this.motionZ *= 0.699999988079071D;
+ }
+ }
+
+ @Override
+ public void setParticleTextureIndex(int par1)
+ {
+ this.particleTextureIndexX = par1 % 4;
+ this.particleTextureIndexY = par1 / 4;
+ }
+
+}
diff --git a/src/main/java/ihl/servitor/FlameRenderFX.java b/src/main/java/ihl/servitor/FlameRenderFX.java new file mode 100644 index 0000000..f90e378 --- /dev/null +++ b/src/main/java/ihl/servitor/FlameRenderFX.java @@ -0,0 +1,55 @@ +package ihl.servitor;
+
+import org.lwjgl.opengl.GL11;
+
+import net.minecraft.client.particle.EntityFX;
+import net.minecraft.client.renderer.ActiveRenderInfo;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.entity.Entity;
+import net.minecraft.util.ResourceLocation;
+
+public class FlameRenderFX extends Render{
+ private ResourceLocation tex;
+
+public FlameRenderFX(String textureLocation)
+{
+ super();
+ tex = new ResourceLocation(textureLocation);
+}
+
+@Override
+public void doRender(Entity entity, double x, double y, double z,
+ float arg4, float arg5)
+{
+ float var3 = ActiveRenderInfo.rotationX;
+ float var4 = ActiveRenderInfo.rotationZ;
+ float var5 = ActiveRenderInfo.rotationYZ;
+ float var6 = ActiveRenderInfo.rotationXY;
+ float var7 = ActiveRenderInfo.rotationXZ;
+ EntityFX.interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * arg4;
+ EntityFX.interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * arg4;
+ EntityFX.interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * arg4;
+ this.renderManager.renderEngine.bindTexture(tex);
+ GL11.glPushMatrix();
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ GL11.glTranslatef((float)x, (float)y, (float)z);
+ GL11.glDepthMask(false);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
+ Tessellator var9 = Tessellator.instance;
+ var9.startDrawingQuads();
+ EntityFX var11 = (EntityFX) entity;
+ var11.renderParticle(var9, arg4, var3, var7, var4, var5, var6);
+ var9.draw();
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glDepthMask(true);
+ GL11.glPopMatrix();
+}
+
+ @Override
+ protected ResourceLocation getEntityTexture(Entity arg0)
+ {
+ return tex;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/servitor/LostHeadEntity.java b/src/main/java/ihl/servitor/LostHeadEntity.java new file mode 100644 index 0000000..704743b --- /dev/null +++ b/src/main/java/ihl/servitor/LostHeadEntity.java @@ -0,0 +1,475 @@ +package ihl.servitor;
+
+import java.util.List;
+
+import ic2.api.item.IC2Items;
+import ihl.IHLMod;
+import ihl.IHLModInfo;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityFlying;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.SharedMonsterAttributes;
+import net.minecraft.entity.monster.IMob;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.DamageSource;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.Vec3;
+import net.minecraft.world.EnumDifficulty;
+import net.minecraft.world.World;
+
+public class LostHeadEntity extends EntityFlying implements IMob
+{
+ public int courseChangeCooldown;
+ public double waypointX;
+ public double waypointY;
+ public double waypointZ;
+ private Entity targetedEntity;
+
+ /** Cooldown time between target loss and new target aquirement. */
+ private int aggroCooldown;
+ public int prevAttackCounter;
+ public int attackCounter;
+ public int attackCounterIncrement;
+
+ private final double psr = 0.5D;
+ private final double delta = 0.35D;
+
+ private final double damage = 4D;
+ private final double knockbackStrength=2D;
+
+
+ public LostHeadEntity(World par1World)
+ {
+ super(par1World);
+ this.setSize(1.0F, 1.0F);
+ this.isImmuneToFire = true;
+ this.experienceValue = 5;
+ }
+
+ public boolean func_110182_bF()
+ {
+ return this.dataWatcher.getWatchableObjectByte(16) != 0;
+ }
+
+ /**
+ * Called when the entity is attacked.
+ */
+ @Override
+ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
+ {
+ if (this.isEntityInvulnerable())
+ {
+ return false;
+ }
+ else
+ {
+ return super.attackEntityFrom(par1DamageSource, par2);
+ }
+ }
+
+ @Override
+ protected void entityInit()
+ {
+ super.entityInit();
+ this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
+ }
+
+ @Override
+ protected void applyEntityAttributes()
+ {
+ super.applyEntityAttributes();
+ this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void onLivingUpdate()
+ {
+ super.onLivingUpdate();
+ if(worldObj.isRemote)
+ {
+ double x1,y1,z1,x2,z2;
+ x1=this.prevPosX+psr*Math.sin(-rotationYaw/180D*Math.PI+delta+Math.random()*0.1D-0.05D);
+ z1=this.prevPosZ+psr*Math.cos(-rotationYaw/180D*Math.PI+delta+Math.random()*0.1D-0.05D);
+ x2=this.prevPosX+psr*Math.sin(-rotationYaw/180D*Math.PI-delta+Math.random()*0.1D-0.05D);
+ z2=this.prevPosZ+psr*Math.cos(-rotationYaw/180D*Math.PI-delta+Math.random()*0.1D-0.05D);
+ y1=this.prevPosY+psr*Math.sin(rotationPitch/180D*Math.PI+Math.random()*0.1D-0.05D)+0.4D;
+ IHLMod.proxy.spawnParticle(0,worldObj, x1,y1,z1,0D,0.1D,0D,1F);
+ IHLMod.proxy.spawnParticle(0,worldObj, x2,y1,z2,0D,0.1D,0D,1F);
+ }
+ //this part was mindlessly taken from EntityArrow.
+ Vec3 var17 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
+ Vec3 var3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
+ MovingObjectPosition var4 = this.worldObj.func_147447_a(var17, var3, false, true, false);
+ var17 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
+ var3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
+
+ if (var4 != null)
+ {
+ var3 = Vec3.createVectorHelper(var4.hitVec.xCoord, var4.hitVec.yCoord, var4.hitVec.zCoord);
+ }
+
+ Entity var5 = null;
+ List<Entity> var6 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
+ double var7 = 0.0D;
+ int var9;
+ float var11;
+
+ for (var9 = 0; var9 < var6.size(); ++var9)
+ {
+ Entity var10 = (Entity)var6.get(var9);
+
+ if (var10.canBeCollidedWith())
+ {
+ var11 = 0.3F;
+ AxisAlignedBB var12 = var10.boundingBox.expand(var11, var11, var11);
+ MovingObjectPosition var13 = var12.calculateIntercept(var17, var3);
+
+ if (var13 != null)
+ {
+ double var14 = var17.distanceTo(var13.hitVec);
+
+ if (var14 < var7 || var7 == 0.0D)
+ {
+ var5 = var10;
+ var7 = var14;
+ }
+ }
+ }
+ }
+
+
+ if (var5 != null)
+ {
+ var4 = new MovingObjectPosition(var5);
+ }
+
+ float var19;
+ float var26;
+
+ if (var4 != null)
+ {
+ if (var4.entityHit != null)
+ {
+ var19 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
+ int var23 = MathHelper.ceiling_double_int(var19 * this.damage);
+
+ DamageSource var21 = DamageSource.causeThrownDamage(this, this);
+
+ if (var4.entityHit.attackEntityFrom(var21, var23))
+ {
+ if (var4.entityHit instanceof EntityLivingBase)
+ {
+ var26 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
+ if (var26 > 0.0F)
+ {
+ var4.entityHit.addVelocity(this.motionX * this.knockbackStrength * 0.6D / var26, 0.1D, this.motionZ * this.knockbackStrength * 0.6D / var26);
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ @Override
+ protected void updateEntityActionState()
+ {
+ if (!this.worldObj.isRemote && this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL)
+ {
+ this.setDead();
+ }
+
+ this.despawnEntity();
+ this.prevAttackCounter = this.attackCounter;
+ double var1 = this.waypointX - this.posX;
+ double var3 = this.waypointY - this.posY;
+ double var5 = this.waypointZ - this.posZ;
+ double var7 = var1 * var1 + var3 * var3 + var5 * var5;
+
+ if (var7 < 1.0D || var7 > 3600.0D)
+ {
+ this.waypointX = this.posX + (this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F;
+ this.waypointY = this.posY + (this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F;
+ this.waypointZ = this.posZ + (this.rand.nextFloat() * 2.0F - 1.0F) * 16.0F;
+ }
+
+ if (this.courseChangeCooldown-- <= 0)
+ {
+ this.courseChangeCooldown += this.rand.nextInt(5) + 2;
+ var7 = MathHelper.sqrt_double(var7);
+
+ if (this.isCourseTraversable(this.waypointX, this.waypointY, this.waypointZ, var7))
+ {
+ this.motionX += var1 / var7 * 0.02D;
+ this.motionY += var3 / var7 * 0.02D;
+ this.motionZ += var5 / var7 * 0.02D;
+ }
+ else
+ {
+ this.waypointX = this.posX;
+ this.waypointY = this.posY;
+ this.waypointZ = this.posZ;
+ }
+ }
+
+ if (this.targetedEntity != null && this.targetedEntity.isDead)
+ {
+ if (!this.worldObj.isRemote)
+ {
+ this.playSound(IHLModInfo.MODID+":lostHeadLaughtLong", 10F, this.getSoundPitch());
+ }
+ this.targetedEntity = null;
+ }
+
+ if (this.targetedEntity == null || this.aggroCooldown-- <= 0)
+ {
+ this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D);
+
+ if (this.targetedEntity != null)
+ {
+ this.aggroCooldown = 20;
+ }
+ }
+
+ double var9 = 64.0D;
+
+ if (this.targetedEntity != null && this.targetedEntity.getDistanceSqToEntity(this) < var9 * var9)
+ {
+ double var11 = this.targetedEntity.posX - this.posX;
+ double var15 = this.targetedEntity.posZ - this.posZ;
+ this.renderYawOffset = this.rotationYaw = -((float)Math.atan2(var11, var15)) * 180.0F / (float)Math.PI;
+
+ if (this.canEntityBeSeen(this.targetedEntity))
+ {
+ if (this.attackCounter == 70)
+ {
+ //play attack scream before attack
+ if (!this.worldObj.isRemote)
+ {
+ this.playSound(IHLModInfo.MODID+":lostHeadLaught", 10F, this.getSoundPitch());
+ }
+ }
+
+ ++this.attackCounter;
+
+ if (this.attackCounter == 80)
+ {
+ //play fire sound before attack
+ this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1008, (int)this.posX, (int)this.posY, (int)this.posZ, 0);
+ double vX = this.targetedEntity.posX-this.posX;
+ double vY = this.targetedEntity.posY+this.targetedEntity.height-this.posY;
+ double vZ = this.targetedEntity.posZ-this.posZ;
+ this.motionX=vX*0.1D;
+ this.motionY=vY*0.1D;
+ this.motionZ=vZ*0.1D;
+ this.courseChangeCooldown=40;
+ this.attackCounter = -60;
+ }
+ }
+ else if (this.attackCounter > 0)
+ {
+ --this.attackCounter;
+ }
+ }
+ else
+ {
+ float rYaw=-((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI;
+ float rYawD=this.rotationYaw-rYaw;
+ this.renderYawOffset = this.rotationYaw -= rYawD*0.2F;
+
+ if (this.attackCounter > 0)
+ {
+ --this.attackCounter;
+ }
+ }
+
+ if (!this.worldObj.isRemote)
+ {
+ byte var21 = this.dataWatcher.getWatchableObjectByte(16);
+ byte var12 = (byte)(this.attackCounter > 10 ? 1 : 0);
+
+ if (var21 != var12)
+ {
+ this.dataWatcher.updateObject(16, Byte.valueOf(var12));
+ }
+ }
+ }
+
+ /**
+ * True if the ghast has an unobstructed line of travel to the waypoint.
+ */
+ private boolean isCourseTraversable(double par1, double par3, double par5, double par7)
+ {
+ double var9 = (this.waypointX - this.posX) / par7;
+ double var11 = (this.waypointY - this.posY) / par7;
+ double var13 = (this.waypointZ - this.posZ) / par7;
+ AxisAlignedBB var15 = this.boundingBox.copy();
+
+ for (int var16 = 1; var16 < par7; ++var16)
+ {
+ var15.offset(var9, var11, var13);
+
+ if (!this.worldObj.getCollidingBoundingBoxes(this, var15).isEmpty())
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns the sound this mob makes while it's alive.
+ */
+ @Override
+ protected String getLivingSound()
+ {
+ return IHLModInfo.MODID+":lostHeadCry";
+ }
+
+ @Override
+ public int getTalkInterval()
+ {
+ return 400;
+ }
+ /**
+ * Returns the sound this mob makes when it is hurt.
+ */
+ @Override
+ protected String getHurtSound()
+ {
+ return IHLModInfo.MODID+":lostHeadScream";
+ }
+
+ /**
+ * Returns the sound this mob makes on death.
+ */
+ @Override
+ protected String getDeathSound()
+ {
+ return IHLModInfo.MODID+":lostHeadDeath";
+ }
+
+ /**
+ * Drop 0-2 items of this living's type
+ */
+ @Override
+ protected void dropFewItems(boolean par1, int par2)
+ {
+ int var3 = this.rand.nextInt(2) + this.rand.nextInt(1 + par2);
+ int var4;
+
+ if(var3==0)
+ {
+ this.entityDropItem(new ItemStack(IHLMod.ihlSkull,1), 1);
+ }
+ else
+ {
+ for (var4 = 0; var4 < var3; ++var4)
+ {
+ this.entityDropItem(new ItemStack(Items.dye, 1, 15), 1);
+ }
+ }
+
+ var3 = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);
+
+ for (var4 = 0; var4 < var3; ++var4)
+ {
+ this.entityDropItem(IC2Items.getItem("smallTinDust"), 1);
+ }
+ }
+
+ /**
+ * Returns the volume for the sounds this mob makes.
+ */
+ @Override
+ protected float getSoundVolume()
+ {
+ return 1.0F;
+ }
+
+ /**
+ * Checks if the entity's current position is a valid location to spawn this entity.
+ */
+ @Override
+ public boolean getCanSpawnHere()
+ {
+ return this.rand.nextInt(20) == 0 && super.getCanSpawnHere() && this.worldObj.difficultySetting != EnumDifficulty.PEACEFUL;
+ }
+
+ /**
+ * Will return how many at most can spawn in a chunk at once.
+ */
+ @Override
+ public int getMaxSpawnedInChunk()
+ {
+ return 1;
+ }
+
+ /**
+ * (abstract) Protected helper method to write subclass entity data to NBT.
+ */
+ @Override
+ public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
+ {
+ super.writeEntityToNBT(par1NBTTagCompound);
+ }
+
+ /**
+ * (abstract) Protected helper method to read subclass entity data from NBT.
+ */
+ @Override
+ public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
+ {
+ super.readEntityFromNBT(par1NBTTagCompound);
+ }
+
+ @Override
+ public void moveEntityWithHeading(float par1, float par2)
+ {
+ if (this.isInWater())
+ {
+ this.moveFlying(par1, par2, 0.02F);
+ this.moveEntity(this.motionX, this.motionY, this.motionZ);
+ this.motionX *= 0.800000011920929D;
+ this.motionY *= 0.800000011920929D;
+ this.motionZ *= 0.800000011920929D;
+ }
+ else if (this.handleLavaMovement())
+ {
+ this.moveFlying(par1, par2, 0.02F);
+ this.moveEntity(this.motionX, this.motionY, this.motionZ);
+ this.motionX *= 0.5D;
+ this.motionY *= 0.5D;
+ this.motionZ *= 0.5D;
+ }
+ else
+ {
+ float var3 = 0.91F;
+
+ if (this.onGround)
+ {
+ var3 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F;
+ }
+
+ float var4 = 0.16277136F / (var3 * var3 * var3);
+ this.moveFlying(par1, par2, this.onGround ? 0.1F * var4 : 0.02F);
+ var3 = 0.98F;
+
+ if (this.onGround)
+ {
+ var3 = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.91F;
+ }
+ this.moveEntity(this.motionX, this.motionY, this.motionZ);
+ this.motionX *= var3;
+ this.motionY *= var3;
+ this.motionZ *= var3;
+ }
+ }
+}
diff --git a/src/main/java/ihl/servitor/LostHeadRender.java b/src/main/java/ihl/servitor/LostHeadRender.java new file mode 100644 index 0000000..f4e7cb9 --- /dev/null +++ b/src/main/java/ihl/servitor/LostHeadRender.java @@ -0,0 +1,40 @@ +package ihl.servitor;
+
+import org.lwjgl.opengl.GL11;
+
+import ihl.IHLModInfo;
+import net.minecraft.client.renderer.entity.Render;
+import net.minecraft.entity.Entity;
+import net.minecraft.util.ResourceLocation;
+
+public class LostHeadRender extends Render{
+ private SkullModel model = new SkullModel();
+ private ResourceLocation tex;
+ private float scale;
+
+public LostHeadRender()
+{
+ super();
+ scale = 1F/80F;
+ tex = new ResourceLocation(IHLModInfo.MODID+":textures/items/skull.png");
+}
+
+@Override
+public void doRender(Entity entity, double x, double y, double z,
+ float arg4, float arg5)
+{
+ bindTexture(tex);
+ GL11.glPushMatrix();
+ GL11.glTranslated(x, y, z);
+ GL11.glScalef(1.0F, -1F, -1F);
+ GL11.glRotated(entity.rotationYaw+180D, 0D, 1.0D, 0D);
+ model.Base.render(scale);
+ GL11.glPopMatrix();
+}
+
+ @Override
+ protected ResourceLocation getEntityTexture(Entity arg0)
+ {
+ return tex;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/servitor/SkullItemRender.java b/src/main/java/ihl/servitor/SkullItemRender.java new file mode 100644 index 0000000..8b9e2b7 --- /dev/null +++ b/src/main/java/ihl/servitor/SkullItemRender.java @@ -0,0 +1,78 @@ +package ihl.servitor;
+
+import org.lwjgl.opengl.GL11;
+
+import ihl.IHLModInfo;
+import net.minecraft.client.Minecraft;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.IItemRenderer;
+
+public class SkullItemRender implements IItemRenderer{
+ private SkullModel model = new SkullModel();
+ private ResourceLocation tex;
+ private float scale;
+
+public SkullItemRender()
+{
+ super();
+ scale = 1F/80F;
+ tex = new ResourceLocation(IHLModInfo.MODID+":textures/items/skull.png");
+}
+
+@Override
+public void renderItem(ItemRenderType type, ItemStack item, Object... data)
+{
+ GL11.glPushMatrix();
+ switch(type)
+ {
+ case EQUIPPED_FIRST_PERSON:
+ GL11.glRotatef(80F, 0.0F, 1.0F, 0.0F);
+ GL11.glTranslatef(0F, 0.18F, 1F);
+ GL11.glScalef(1.5F, -1.5F, -1.5F);
+ break;
+ case ENTITY:
+ GL11.glTranslatef(0F, 1.0F, 0F);
+ GL11.glScalef(1.0F, -1F, -1F);
+ break;
+ case INVENTORY:
+ GL11.glRotatef(210F, 0F, 1.0F, -0.15F);
+ GL11.glTranslatef(0.0F,-0.75F,0.0F);
+ GL11.glScalef(1.5F, -1.5F, -1.5F);
+ break;
+ case EQUIPPED:
+ GL11.glTranslatef(0.5F,0.5F,0.25F);
+ GL11.glScalef(1.0F, -1F, -1F);
+ break;
+ default:
+ break;
+ }
+ Minecraft.getMinecraft().renderEngine.bindTexture(tex);
+ model.Base.render(scale);
+ GL11.glPopMatrix();
+}
+
+/**
+ * IItemRenderer implementation *
+ */
+@Override
+public boolean handleRenderType(ItemStack item, ItemRenderType type) {
+ switch (type) {
+ case ENTITY:
+ return true;
+ case EQUIPPED:
+ return true;
+ case EQUIPPED_FIRST_PERSON:
+ return true;
+ case INVENTORY:
+ return true;
+ default:
+ return false;
+ }
+}
+
+@Override
+public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
+ return true;
+}
+}
\ No newline at end of file diff --git a/src/main/java/ihl/servitor/SkullModel.java b/src/main/java/ihl/servitor/SkullModel.java new file mode 100644 index 0000000..1bdbdcf --- /dev/null +++ b/src/main/java/ihl/servitor/SkullModel.java @@ -0,0 +1,153 @@ +package ihl.servitor; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; + +public class SkullModel extends ModelBase +{ + //fields + ModelRenderer Base; + + public SkullModel() + { + textureWidth = 256; + textureHeight = 256; + setTextureOffset("Base.Shape2", 110, 11); + setTextureOffset("Base.Shape3", 59, 62); + setTextureOffset("Base.Shape4", 83, 59); + setTextureOffset("Base.Shape5", 83, 59); + setTextureOffset("Base.Shape6", 0, 18); + setTextureOffset("Base.Shape8", 0, 26); + setTextureOffset("Base.Shape9", 2, 33); + setTextureOffset("Base.Shape10", 26, 37); + setTextureOffset("Base.Shape11", 28, 157); + setTextureOffset("Base.Shape12", 83, 111); + setTextureOffset("Base.Shape13", 67, 110); + setTextureOffset("Base.Shape14", 72, 99); + setTextureOffset("Base.Shape15", 92, 114); + setTextureOffset("Base.Shape16", 102, 112); + setTextureOffset("Base.Shape17", 82, 107); + setTextureOffset("Base.Shape18", 71, 108); + setTextureOffset("Base.Shape19", 89, 114); + setTextureOffset("Base.Shape20", 90, 124); + setTextureOffset("Base.Shape21", 106, 31); + setTextureOffset("Base.Shape22", 77, 139); + setTextureOffset("Base.Shape23", 115, 193); + setTextureOffset("Base.Shape24", 1, 163); + setTextureOffset("Base.Shape25", 127, 117); + setTextureOffset("Base.Shape26", 81, 116); + setTextureOffset("Base.Shape27", 81, 115); + setTextureOffset("Base.Shape28", 81, 114); + setTextureOffset("Base.Shape29", 6, 167); + setTextureOffset("Base.Shape1", 0, 154); + setTextureOffset("Base.Shape7", 92, 124); + setTextureOffset("Base.Shape30", 89, 124); + setTextureOffset("Base.Shape31", 128, 193); + setTextureOffset("Base.Shape32", 106, 88); + setTextureOffset("Base.Shape33", 109, 70); + setTextureOffset("Base.Shape34", 166, 109); + setTextureOffset("Base.Shape35", 100, 53); + setTextureOffset("Base.Shape36", 169, 98); + setTextureOffset("Base.Shape37", 99, 81); + setTextureOffset("Base.Shape38", 101, 108); + setTextureOffset("Base.Shape39", 92, 85); + setTextureOffset("Base.Shape40", 22, 89); + setTextureOffset("Base.Shape41", 62, 151); + setTextureOffset("Base.Shape42", 37, 97); + setTextureOffset("Base.Shape43", 9, 101); + setTextureOffset("Base.Shape44", 77, 15); + setTextureOffset("Base.Shape45", 18, 145); + setTextureOffset("Base.Shape46", 28, 156); + setTextureOffset("Base.Shape47", 28, 155); + setTextureOffset("Base.Shape48", 106, 104); + setTextureOffset("Base.Shape49", 77, 129); + setTextureOffset("Base.Shape50", 25, 82); + setTextureOffset("Base.Shape51", 46, 33); + setTextureOffset("Base.Shape52", 101, 85); + setTextureOffset("Base.Shape53", 141, 38); + setTextureOffset("Base.Shape54", 24, 149); + setTextureOffset("Base.Shape55", 83, 132); + setTextureOffset("Base.Shape56", 99, 132); + setTextureOffset("Base.Shape57", 30, 186); + setTextureOffset("Base.Shape58", 142, 220); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(0F, -30F, -30F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = false; + Base.addBox("Shape2", -25F, -24F, 18F, 8, 24, 34); + Base.addBox("Shape3", -23F, -28F, 13F, 46, 4, 38); + Base.addBox("Shape4", -22F, -30F, 14F, 44, 2, 37); + Base.addBox("Shape5", -21F, -32F, 12F, 42, 2, 39); + Base.addBox("Shape6", -19F, -34F, 9F, 38, 2, 43); + Base.addBox("Shape8", -17F, -36F, 11F, 34, 2, 46); + Base.addBox("Shape9", -15F, -38F, 13F, 28, 2, 42); + Base.addBox("Shape10", -9F, -40F, 21F, 20, 2, 24); + Base.addBox("Shape11", -13F, -24F, 1F, 26, 26, 3); + Base.addBox("Shape12", -16F, -11.2F, 66F, 14, 4, 2); + Base.addBox("Shape13", 2F, -11.2F, 66F, 14, 4, 2); + Base.addBox("Shape14", -9F, -24F, 66F, 18, 17, 1); + Base.addBox("Shape15", -2F, -7F, 65F, 4, 7, 3); + Base.addBox("Shape16", -2F, -4F, 68F, 4, 4, 1); + Base.addBox("Shape17", 2F, -10F, 64F, 3, 4, 5); + Base.addBox("Shape18", -5F, -10F, 64F, 3, 4, 5); + Base.addBox("Shape19", -6F, 0F, 65F, 4, 1, 1); + Base.addBox("Shape20", -16F, 1F, 63F, 12, 5, 4); + Base.addBox("Shape21", -24F, 0F, 18F, 8, 4, 38); + Base.addBox("Shape22", -8F, 10F, 66F, 16, 5, 2); + Base.addBox("Shape23", -16F, 4F, 7F, 9, 3, 56); + Base.addBox("Shape24", -10F, 7F, 16F, 8, 3, 52); + Base.addBox("Shape25", -10F, 16F, 17F, 20, 1, 12); + Base.addBox("Shape26", -10F, 15F, 15F, 20, 1, 15); + Base.addBox("Shape27", -11F, 14F, 13F, 22, 1, 18); + Base.addBox("Shape28", -11F, 13F, 11F, 22, 1, 21); + Base.addBox("Shape29", -12F, 7.1F, 8F, 24, 6, 26); + Base.addBox("Shape1", 2F, 7F, 16F, 8, 3, 52); + Base.addBox("Shape7", 2F, 0F, 65F, 4, 1, 1); + Base.addBox("Shape30", 4F, 1F, 63F, 12, 5, 4); + Base.addBox("Shape31", 7F, 4F, 7F, 9, 3, 56); + Base.addBox("Shape32", 16F, 0F, 18F, 8, 4, 38); + Base.addBox("Shape33", 17F, -24F, 18F, 8, 24, 34); + Base.addBox("Shape34", 18F, -7F, 52F, 6, 7, 9); + Base.addBox("Shape35", -24F, -7F, 52F, 6, 7, 9); + Base.addBox("Shape36", 16F, -13F, 56F, 6, 16, 6); + Base.addBox("Shape37", 18F, -24F, 52F, 2, 17, 12); + Base.addBox("Shape38", -22F, -13F, 56F, 6, 16, 6); + Base.addBox("Shape39", -20F, -24F, 52F, 2, 17, 12); + Base.addBox("Shape40", -18F, -28F, 51F, 36, 4, 13); + Base.addBox("Shape41", -17.5F, -30F, 34F, 35, 2, 29); + Base.addBox("Shape42", -18F, -24F, 62F, 36, 17, 4); + Base.addBox("Shape43", -17F, -32F, 7F, 34, 2, 54); + Base.addBox("Shape44", -16.2F, -34F, 51F, 32, 2, 8); + Base.addBox("Shape45", -19.5F, -33F, 8F, 39, 37, 8); + Base.addBox("Shape46", -14F, -26F, 2F, 28, 30, 1); + Base.addBox("Shape47", -15F, -28F, 3F, 30, 32, 2); + Base.addBox("Shape48", -18F, -1F, 56F, 3, 5, 8); + Base.addBox("Shape49", 15F, -1F, 56F, 3, 5, 8); + Base.addBox("Shape50", -5F, -39F, 15F, 12, 1, 6); + Base.addBox("Shape51", -6F, -39F, 45F, 12, 1, 6); + Base.addBox("Shape52", -21.5F, -31F, 11F, 43, 34, 6); + Base.addBox("Shape53", -23.5F, -24F, 13F, 47, 26, 5); + Base.addBox("Shape54", -17F, -30F, 5F, 34, 34, 3); + Base.addBox("Shape55", 8F, 10F, 58F, 2, 4, 9); + Base.addBox("Shape56", -10F, 10F, 58F, 2, 4, 8); + Base.addBox("Shape57", -9F, 4F, 3F, 18, 5, 5); + Base.addBox("Shape58", -8F, 10F, 41F, 16, 1, 25); + } + + @Override +public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + Base.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/ihl/servitor/SkullModel.txt b/src/main/java/ihl/servitor/SkullModel.txt new file mode 100644 index 0000000..be648bd --- /dev/null +++ b/src/main/java/ihl/servitor/SkullModel.txt @@ -0,0 +1,165 @@ +// Date: 12.07.2014 13:37:52 +// Template version 1.1 +// Java generated by Techne +// Keep in mind that you still need to fill in some blanks +// - ZeuX + + + + + + +package net.minecraft.src; + +public class ModelShieldModel extends ModelBase +{ + //fields + ModelRenderer Base; + + public ModelShieldModel() + { + textureWidth = 256; + textureHeight = 256; + setTextureOffset("Base.Shape2", 110, 11); + setTextureOffset("Base.Shape3", 59, 62); + setTextureOffset("Base.Shape4", 83, 59); + setTextureOffset("Base.Shape5", 83, 59); + setTextureOffset("Base.Shape6", 0, 18); + setTextureOffset("Base.Shape8", 0, 26); + setTextureOffset("Base.Shape9", 2, 33); + setTextureOffset("Base.Shape10", 26, 37); + setTextureOffset("Base.Shape11", 28, 157); + setTextureOffset("Base.Shape12", 83, 111); + setTextureOffset("Base.Shape13", 67, 110); + setTextureOffset("Base.Shape14", 72, 99); + setTextureOffset("Base.Shape15", 92, 114); + setTextureOffset("Base.Shape16", 102, 112); + setTextureOffset("Base.Shape17", 82, 107); + setTextureOffset("Base.Shape18", 71, 108); + setTextureOffset("Base.Shape19", 89, 114); + setTextureOffset("Base.Shape20", 90, 124); + setTextureOffset("Base.Shape21", 106, 31); + setTextureOffset("Base.Shape22", 77, 139); + setTextureOffset("Base.Shape23", 115, 193); + setTextureOffset("Base.Shape24", 1, 163); + setTextureOffset("Base.Shape25", 127, 117); + setTextureOffset("Base.Shape26", 81, 116); + setTextureOffset("Base.Shape27", 81, 115); + setTextureOffset("Base.Shape28", 81, 114); + setTextureOffset("Base.Shape29", 6, 167); + setTextureOffset("Base.Shape1", 0, 154); + setTextureOffset("Base.Shape7", 92, 124); + setTextureOffset("Base.Shape30", 89, 124); + setTextureOffset("Base.Shape31", 128, 193); + setTextureOffset("Base.Shape32", 106, 88); + setTextureOffset("Base.Shape33", 109, 70); + setTextureOffset("Base.Shape34", 166, 109); + setTextureOffset("Base.Shape35", 100, 53); + setTextureOffset("Base.Shape36", 169, 98); + setTextureOffset("Base.Shape37", 99, 81); + setTextureOffset("Base.Shape38", 101, 108); + setTextureOffset("Base.Shape39", 92, 85); + setTextureOffset("Base.Shape40", 22, 89); + setTextureOffset("Base.Shape41", 62, 151); + setTextureOffset("Base.Shape42", 37, 97); + setTextureOffset("Base.Shape43", 9, 101); + setTextureOffset("Base.Shape44", 77, 15); + setTextureOffset("Base.Shape45", 18, 145); + setTextureOffset("Base.Shape46", 28, 156); + setTextureOffset("Base.Shape47", 28, 155); + setTextureOffset("Base.Shape48", 106, 104); + setTextureOffset("Base.Shape49", 77, 129); + setTextureOffset("Base.Shape50", 25, 82); + setTextureOffset("Base.Shape51", 46, 33); + setTextureOffset("Base.Shape52", 101, 85); + setTextureOffset("Base.Shape53", 141, 38); + setTextureOffset("Base.Shape54", 24, 149); + setTextureOffset("Base.Shape55", 83, 132); + setTextureOffset("Base.Shape56", 99, 132); + setTextureOffset("Base.Shape57", 30, 186); + setTextureOffset("Base.Shape58", 142, 220); + + Base = new ModelRenderer(this, "Base"); + Base.setRotationPoint(0F, -30F, -30F); + setRotation(Base, 0F, 0F, 0F); + Base.mirror = true; + Base.addBox("Shape2", -25F, -24F, 18F, 8, 24, 34); + Base.addBox("Shape3", -23F, -28F, 13F, 46, 4, 38); + Base.addBox("Shape4", -22F, -30F, 14F, 44, 2, 37); + Base.addBox("Shape5", -21F, -32F, 12F, 42, 2, 39); + Base.addBox("Shape6", -19F, -34F, 9F, 38, 2, 43); + Base.addBox("Shape8", -17F, -36F, 11F, 34, 2, 46); + Base.addBox("Shape9", -15F, -38F, 13F, 28, 2, 42); + Base.addBox("Shape10", -9F, -40F, 21F, 20, 2, 24); + Base.addBox("Shape11", -13F, -24F, 1F, 26, 26, 3); + Base.addBox("Shape12", -16F, -11,2F, 66F, 14, 4, 2); + Base.addBox("Shape13", 2F, -11,2F, 66F, 14, 4, 2); + Base.addBox("Shape14", -9F, -24F, 66F, 18, 17, 1); + Base.addBox("Shape15", -2F, -7F, 65F, 4, 7, 3); + Base.addBox("Shape16", -2F, -4F, 68F, 4, 4, 1); + Base.addBox("Shape17", 2F, -10F, 64F, 3, 4, 5); + Base.addBox("Shape18", -5F, -10F, 64F, 3, 4, 5); + Base.addBox("Shape19", -6F, 0F, 65F, 4, 1, 1); + Base.addBox("Shape20", -16F, 1F, 63F, 12, 5, 4); + Base.addBox("Shape21", -24F, 0F, 18F, 8, 4, 38); + Base.addBox("Shape22", -8F, 10F, 66F, 16, 5, 2); + Base.addBox("Shape23", -16F, 4F, 7F, 9, 3, 56); + Base.addBox("Shape24", -10F, 7F, 16F, 8, 3, 52); + Base.addBox("Shape25", -10F, 16F, 17F, 20, 1, 12); + Base.addBox("Shape26", -10F, 15F, 15F, 20, 1, 15); + Base.addBox("Shape27", -11F, 14F, 13F, 22, 1, 18); + Base.addBox("Shape28", -11F, 13F, 11F, 22, 1, 21); + Base.addBox("Shape29", -12F, 7,1F, 8F, 24, 6, 26); + Base.addBox("Shape1", 2F, 7F, 16F, 8, 3, 52); + Base.addBox("Shape7", 2F, 0F, 65F, 4, 1, 1); + Base.addBox("Shape30", 4F, 1F, 63F, 12, 5, 4); + Base.addBox("Shape31", 7F, 4F, 7F, 9, 3, 56); + Base.addBox("Shape32", 16F, 0F, 18F, 8, 4, 38); + Base.addBox("Shape33", 17F, -24F, 18F, 8, 24, 34); + Base.addBox("Shape34", 18F, -7F, 52F, 6, 7, 9); + Base.addBox("Shape35", -24F, -7F, 52F, 6, 7, 9); + Base.addBox("Shape36", 16F, -13F, 56F, 6, 16, 6); + Base.addBox("Shape37", 18F, -24F, 52F, 2, 17, 12); + Base.addBox("Shape38", -22F, -13F, 56F, 6, 16, 6); + Base.addBox("Shape39", -20F, -24F, 52F, 2, 17, 12); + Base.addBox("Shape40", -18F, -28F, 51F, 36, 4, 13); + Base.addBox("Shape41", -17,5F, -30F, 34F, 35, 2, 29); + Base.addBox("Shape42", -18F, -24F, 62F, 36, 17, 4); + Base.addBox("Shape43", -17F, -32F, 7F, 34, 2, 54); + Base.addBox("Shape44", -16,24F, -34,04F, 51F, 32, 2, 8); + Base.addBox("Shape45", -19,5F, -33F, 8F, 39, 37, 8); + Base.addBox("Shape46", -14F, -26F, 2F, 28, 30, 1); + Base.addBox("Shape47", -15F, -28F, 3F, 30, 32, 2); + Base.addBox("Shape48", -18F, -1F, 56F, 3, 5, 8); + Base.addBox("Shape49", 15F, -1F, 56F, 3, 5, 8); + Base.addBox("Shape50", -5F, -39F, 15F, 12, 1, 6); + Base.addBox("Shape51", -6F, -39F, 45F, 12, 1, 6); + Base.addBox("Shape52", -21,5F, -31F, 11F, 43, 34, 6); + Base.addBox("Shape53", -23,5F, -24F, 13F, 47, 26, 5); + Base.addBox("Shape54", -17F, -30F, 5F, 34, 34, 3); + Base.addBox("Shape55", 8F, 10F, 58F, 2, 4, 9); + Base.addBox("Shape56", -10F, 10F, 58F, 2, 4, 8); + Base.addBox("Shape57", -9F, 4F, 3F, 18, 5, 5); + Base.addBox("Shape58", -8F, 10F, 41F, 16, 1, 25); + } + + public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) + { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5); + Base.render(f5); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) + { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) + { + super.setRotationAngles(f, f1, f2, f3, f4, f5); + } + +} diff --git a/src/main/java/ihl/trans_dimensional_item_teleporter/TDITBlock.java b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITBlock.java new file mode 100644 index 0000000..584692d --- /dev/null +++ b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITBlock.java @@ -0,0 +1,132 @@ +package ihl.trans_dimensional_item_teleporter;
+
+import java.util.Random;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.IC2Items;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+public class TDITBlock extends Block implements ITileEntityProvider{
+
+ IIcon textureLeft, textureRight, textureBack, textureBottom;
+
+ public TDITBlock(Material material)
+ {
+ super(material);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ }
+
+ @Override
+ public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
+ {
+ return IC2Items.getItem("machine").getItem();
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
+ {
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ return new TDITTileEntity();
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister par1IconRegister)
+ {
+ this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditTop");
+ this.textureBack = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditBack");
+ this.textureLeft = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditLeft");
+ this.textureRight = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditRight");
+ this.textureBottom = par1IconRegister.registerIcon(IHLModInfo.MODID + ":tditBottom");
+ }
+
+ @Override
+ public boolean hasTileEntity(int metadata)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){
+ TileEntity te = world.getTileEntity(x,y,z);
+ if(te instanceof TDITTileEntity)
+ {
+ TDITTileEntity bte = (TDITTileEntity)te;
+ if (bte == null || entityPlayer.isSneaking()) {
+ return false;
+ }
+ else if(entityPlayer.getCurrentEquippedItem()==null || !(entityPlayer.getCurrentEquippedItem().getItem() instanceof TDITFrequencyTransmitter))
+ {
+ return bte.getGui(entityPlayer);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Called when the block is placed in the world.
+ */
+
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side)
+ {
+ switch (side)
+ {
+ case 0:
+ return this.textureBottom;
+ case 1:
+ return this.blockIcon;
+ case 2:
+ return this.textureBack;
+ case 3:
+ return this.textureBack;
+ case 4:
+ return this.textureLeft;
+ case 5:
+ return this.textureRight;
+ default:
+ return this.blockIcon;
+ }
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int side, int meta)
+ {
+ switch (side)
+ {
+ case 0:
+ return this.textureBottom;
+ case 1:
+ return this.blockIcon;
+ case 2:
+ return this.textureBack;
+ case 3:
+ return this.textureBack;
+ case 4:
+ return this.textureLeft;
+ case 5:
+ return this.textureRight;
+ default:
+ return this.blockIcon;
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/trans_dimensional_item_teleporter/TDITContainer.java b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITContainer.java new file mode 100644 index 0000000..35dd1a0 --- /dev/null +++ b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITContainer.java @@ -0,0 +1,93 @@ +package ihl.trans_dimensional_item_teleporter;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.ICrafting;
+import net.minecraft.inventory.Slot;
+
+public class TDITContainer extends ContainerBase<TDITTileEntity> {
+
+ protected TDITTileEntity tileEntity;
+ public int lastStorage = -1;
+ private final static int height=166;
+
+ public TDITContainer(EntityPlayer entityPlayer, TDITTileEntity tileEntity1){
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ int col, row;
+
+ 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.dischargeSlot, 0, 8, 44));
+ for(row=0;row<=3;row++)
+ {
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.upgradeSlot, row, 152, 8+row*18));
+ }
+ for(row=0;row<=2;row++)
+ {
+ for(col=0;col<=2;col++)
+ {
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.inputSlot, row+col*3, 31+col*18, 8+row*18));
+ }
+ }
+ for(row=0;row<=2;row++)
+ {
+ for(col=0;col<=2;col++)
+ {
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.outputSlot, row+col*3, 89+col*18, 8+row*18));
+ }
+ }
+ }
+
+ @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.getStored() != this.lastStorage)
+ {
+ icrafting.sendProgressBarUpdate(this, 0, (this.tileEntity.getStored()>>15) & Short.MAX_VALUE);
+ icrafting.sendProgressBarUpdate(this, 1, (short)(this.tileEntity.getStored() & Short.MAX_VALUE));
+
+ }
+ }
+
+ this.lastStorage = this.tileEntity.getStored();
+ }
+
+ @Override
+ public void updateProgressBar(int index, int value)
+ {
+ super.updateProgressBar(index, value);
+
+ switch (index)
+ {
+ case 0:
+ this.tileEntity.setStored(value<<15);
+ break;
+ case 1:
+ this.tileEntity.setStored(this.tileEntity.getStored()+value);
+ break;
+ }
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java new file mode 100644 index 0000000..633b824 --- /dev/null +++ b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITFrequencyTransmitter.java @@ -0,0 +1,172 @@ +package ihl.trans_dimensional_item_teleporter;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.item.IItemHudInfo;
+import ic2.core.IC2;
+import ic2.core.util.StackUtil;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.World;
+
+public class TDITFrequencyTransmitter extends Item implements IItemHudInfo {
+
+ IIcon textureDamaged;
+
+ public TDITFrequencyTransmitter()
+ {
+ super();
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.maxStackSize=1;
+ this.setMaxDamage(0);
+ }
+
+ @Override
+ public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
+ {
+ if (IC2.platform.isSimulating())
+ {
+ if (itemstack.getItemDamage() == 0)
+ {
+ NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(itemstack);
+
+ if (nbtData.getBoolean("targetSet"))
+ {
+ nbtData.setBoolean("targetSet", false);
+ IC2.platform.messagePlayer(entityplayer, "TDIT Frequency Transmitter unlinked", new Object[0]);
+ }
+ }
+ else
+ {
+ itemstack.setItemDamage(0);
+ }
+ }
+
+ return itemstack;
+ }
+
+ @Override
+ public boolean onItemUseFirst(ItemStack itemstack, EntityPlayer entityPlayer, World world, int x, int y, int z, int l, float hitX, float hitY, float hitZ)
+ {
+ TileEntity tileEntity = world.getTileEntity(x, y, z);
+
+ if (tileEntity instanceof TDITTileEntity && IC2.platform.isSimulating())
+ {
+ NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(itemstack);
+ boolean targetSet = nbtData.getBoolean("targetSet");
+ int dimesionID = nbtData.getInteger("dimesionID");
+ int targetX = nbtData.getInteger("targetX");
+ int targetY = nbtData.getInteger("targetY");
+ int targetZ = nbtData.getInteger("targetZ");
+ TDITTileEntity tp = (TDITTileEntity)tileEntity;
+
+ if (!targetSet)
+ {
+ targetSet = true;
+ dimesionID = world.provider.dimensionId;
+ targetX = tp.xCoord;
+ targetY = tp.yCoord;
+ targetZ = tp.zCoord;
+ IC2.platform.messagePlayer(entityPlayer, "TDIT Frequency Transmitter linked to TDIT.", new Object[0]);
+ }
+ else if (tp.xCoord == targetX && tp.yCoord == targetY && tp.zCoord == targetZ)
+ {
+ IC2.platform.messagePlayer(entityPlayer, "Can\'t link TDIT to itself.", new Object[0]);
+ }
+ else if (tp.targetSet && tp.targetX == targetX && tp.targetY == targetY && tp.targetZ == targetZ)
+ {
+ IC2.platform.messagePlayer(entityPlayer, "TDIT link unchanged.", new Object[0]);
+ }
+ else
+ {
+ tp.setTarget(targetX, targetY, targetZ, dimesionID);
+
+ TileEntity te1 = MinecraftServer.getServer().worldServerForDimension(dimesionID).getTileEntity(targetX, targetY, targetZ);
+
+ if (te1 instanceof TDITTileEntity)
+ {
+ TDITTileEntity tp21 = (TDITTileEntity)te1;
+
+ if (!tp21.targetSet)
+ {
+ tp21.setTarget(tp.xCoord, tp.yCoord, tp.zCoord, dimesionID);
+ }
+ }
+
+ IC2.platform.messagePlayer(entityPlayer, "Teleportation link established.", new Object[0]);
+ }
+
+ nbtData.setBoolean("targetSet", targetSet);
+ nbtData.setInteger("dimesionID", dimesionID);
+ nbtData.setInteger("targetX", targetX);
+ nbtData.setInteger("targetY", targetY);
+ nbtData.setInteger("targetZ", targetZ);
+ itemstack.setItemDamage(1);
+ return false;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ @Override
+ public List<String> getHudInfo(ItemStack itemStack) {
+ LinkedList<String> info = new LinkedList<String>();
+ if(itemStack.stackTagCompound!=null)
+ {
+ NBTTagCompound nbtData = StackUtil.getOrCreateNbtData(itemStack);
+ boolean targetSet = nbtData.getBoolean("targetSet");
+ if(targetSet)
+ {
+ int dimesionID = nbtData.getInteger("dimesionID");
+ int targetX = nbtData.getInteger("targetX");
+ int targetY = nbtData.getInteger("targetY");
+ int targetZ = nbtData.getInteger("targetZ");
+ info.add("Dimesion ID: " + dimesionID);
+ info.add("X coord: " + targetX);
+ info.add("Y coord: " + targetY);
+ info.add("Z coord: " + targetZ);
+ }
+ else
+ {
+ info.add("Memory clean");
+ }
+ }
+ return info;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerIcons(IIconRegister iconRegister)
+ {
+ this.itemIcon=iconRegister.registerIcon(IHLModInfo.MODID + ":itemTDITFT");
+ this.textureDamaged=iconRegister.registerIcon(IHLModInfo.MODID + ":itemTDITFT_1");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIconFromDamage(int meta)
+ {
+ switch(meta)
+ {
+ case 0:
+ return this.itemIcon;
+ case 1:
+ return this.textureDamaged;
+ default:
+ return this.itemIcon;
+ }
+ }
+}
diff --git a/src/main/java/ihl/trans_dimensional_item_teleporter/TDITGui.java b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITGui.java new file mode 100644 index 0000000..5966e5e --- /dev/null +++ b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITGui.java @@ -0,0 +1,48 @@ +package ihl.trans_dimensional_item_teleporter;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+@SideOnly(Side.CLIENT)
+public class TDITGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUITDIT.png");
+ private TDITContainer container;
+
+ public TDITGui (TDITContainer container1) {
+ //the container is instanciated and passed to the superclass for handling
+ super(container1);
+ this.container=container1;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int param1, int param2)
+ {
+ //the parameters for drawString are: string, x, y, color
+ String status = StatCollector.translateToLocal("ihl.gui.tdit.message" + this.container.tileEntity.currentStatus);
+ fontRendererObj.drawString(status, 12, 68, 852037);
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ this.mc.renderEngine.bindTexture(background);
+ //charge
+ if (this.container.tileEntity.getStored() > 0)
+ {
+ int chargeLevel=Math.min(Math.round(this.container.tileEntity.getStored()*13.0F/this.container.tileEntity.maxStorage),13);
+ this.drawTexturedModalRect(11, 28+13-chargeLevel, xSize, 13-chargeLevel, 7, chargeLevel);
+ }
+ }
+
+ @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);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/trans_dimensional_item_teleporter/TDITTileEntity.java b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITTileEntity.java new file mode 100644 index 0000000..d54a705 --- /dev/null +++ b/src/main/java/ihl/trans_dimensional_item_teleporter/TDITTileEntity.java @@ -0,0 +1,497 @@ +package ihl.trans_dimensional_item_teleporter;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.api.energy.event.EnergyTileLoadEvent;
+import ic2.api.energy.event.EnergyTileUnloadEvent;
+import ic2.api.energy.tile.IEnergySink;
+import ic2.api.item.IC2Items;
+import ic2.api.network.NetworkHelper;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.audio.AudioSource;
+import ic2.core.audio.PositionSpec;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot;
+import ic2.core.block.invslot.InvSlot.Access;
+import ic2.core.block.invslot.InvSlotOutput;
+import ic2.core.block.invslot.InvSlotUpgrade;
+import ic2.core.upgrade.IUpgradableBlock;
+import ic2.core.upgrade.IUpgradeItem;
+import ic2.core.upgrade.UpgradableProperty;
+import ihl.IHLMod;
+import ihl.utils.IHLInvSlotDischarge;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class TDITTileEntity extends TileEntityInventory implements IEnergySink, IHasGui, IUpgradableBlock
+{
+ private int tier=4;
+ private int defaultTier=4;
+ public int maxStorage=12000;
+ private int defaultMaxStorage=12000;
+ private double energy=0D;
+ private double energyConsume=12000D;//per full stack
+ public boolean addedToEnergyNet = false;
+ public final InvSlotUpgrade upgradeSlot;
+ public final IHLInvSlotDischarge dischargeSlot;
+ public final InvSlotOutput outputSlot;
+ public final InvSlot inputSlot;
+
+ public int updateChecksum=-1;
+
+ private AudioSource startAS;
+ public boolean targetSet=false;
+ public int targetDimension;
+ public int targetX;
+ public int targetY;
+ public int targetZ;
+ /** 0 - Ready, 100%
+ * 1 - Not enough energy
+ * 2 - Receiver not responding
+ * 3 - Receiver not defined
+ * 4 - Clean receiver chamber!
+ */
+ public int currentStatus=0;
+ public int lastStatus=0;
+ private int timer=0;
+
+
+ public TDITTileEntity()
+ {
+ this.defaultTier=IHLMod.config.tditTier;
+ this.defaultMaxStorage=IHLMod.config.tditMaxEnergyStorage;
+ this.energyConsume=IHLMod.config.tditEnergyConsumePerStack;
+ this.dischargeSlot = new IHLInvSlotDischarge(this, 0, Access.IO, this.tier, InvSlot.InvSide.SIDE);
+ this.upgradeSlot = new InvSlotUpgrade(this, "upgrade", 1, 4);
+ this.outputSlot = new InvSlotOutput(this, "output", 2, 9);
+ this.inputSlot = new InvSlot(this, "input", 2, InvSlot.Access.I, 9, InvSlot.InvSide.TOP);
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> fields = super.getNetworkedFields();
+ fields.add("tier");
+ fields.add("maxStorage");
+ fields.add("currentStatus");
+ return fields;
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+ try
+ {
+ this.energy = nbttagcompound.getDouble("energy");
+ }
+ catch (Exception var3)
+ {
+ this.energy = nbttagcompound.getInteger("energy");
+
+ if (this.maxStorage > Integer.MAX_VALUE)
+ {
+ this.energy *= 10.0D;
+ }
+ }
+ this.targetSet = nbttagcompound.getBoolean("targetSet");
+ this.targetDimension = nbttagcompound.getInteger("targetDimension");
+ this.targetX = nbttagcompound.getInteger("targetX");
+ this.targetY = nbttagcompound.getInteger("targetY");
+ this.targetZ = nbttagcompound.getInteger("targetZ");
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+ nbttagcompound.setDouble("energy", this.energy);
+ nbttagcompound.setBoolean("targetSet", this.targetSet);
+ nbttagcompound.setInteger("targetDimension", this.targetDimension);
+ nbttagcompound.setInteger("targetX", this.targetX);
+ nbttagcompound.setInteger("targetY", this.targetY);
+ nbttagcompound.setInteger("targetZ", this.targetZ);
+ }
+
+ @Override
+ public void onLoaded()
+ {
+ super.onLoaded();
+ if (IC2.platform.isSimulating())
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
+ this.addedToEnergyNet = true;
+ }
+ if (IC2.platform.isRendering() && this.startAS==null)
+ {
+ this.startAS = IC2.audioManager.createSource(this, PositionSpec.Center, this.getStartSoundFile(),false,false, 1F);
+ }
+ }
+
+ @Override
+ public void onUnloaded()
+ {
+ if (IC2.platform.isRendering() && this.startAS != null)
+ {
+ this.startAS.stop();
+ this.startAS = null;
+ IC2.audioManager.removeSources(this);
+ }
+
+ if (IC2.platform.isSimulating() && this.addedToEnergyNet)
+ {
+ MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
+ this.addedToEnergyNet = false;
+ }
+ super.onUnloaded();
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return false;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
+ if(this.dischargeSlot.get()!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.dischargeSlot.get()));
+ if(this.upgradeSlot.get(0)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(0)));
+ if(this.upgradeSlot.get(1)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(1)));
+ if(this.upgradeSlot.get(2)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(2)));
+ if(this.upgradeSlot.get(3)!=null)this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.xCoord, this.yCoord+1, this.zCoord, this.upgradeSlot.get(3)));
+ return new ItemStack(IHLMod.tditBlock,1);
+ }
+
+ @Override
+ public void setFacing(short facing1)
+ {
+ super.setFacing(facing1);
+ this.updateChecksum=-1;
+ }
+
+ public boolean enableUpdateEntity()
+ {
+ return true;
+ }
+
+ public String getStartSoundFile()
+ {
+ return "Machines/IHL Industrial Fan/start.ogg";
+ }
+
+ public String getLoopSoundFile()
+ {
+ return "Machines/IHL Industrial Fan/loop.ogg";
+ }
+
+ public String getStopSoundFile()
+ {
+ return "Machines/IHL Industrial Fan/stop.ogg";
+ }
+
+ @Override
+ public void updateEntityServer()
+ {
+
+ if (IC2.platform.isSimulating())
+ {
+ this.setOverclockRates();
+ if(this.timer>0)
+ {
+ this.timer--;
+ }
+ else
+ {
+ this.timer=60;
+ int energyToOperate=this.countEnergyToOperate();
+ if(energyToOperate>0 && energyToOperate<=this.energy)
+ {
+ this.sendItemStack();
+ this.energy-=energyToOperate;
+ }
+ else if(energyToOperate==0 && this.energy>100D)
+ {
+ this.currentStatus=0;
+ }
+ else
+ {
+ this.currentStatus=1;
+ }
+ if(this.currentStatus!=this.lastStatus)
+ {
+ NetworkHelper.updateTileEntityField(this, "currentStatus");
+ this.lastStatus=this.currentStatus;
+ }
+
+ }
+
+ }
+ if(this.dischargeSlot.tier!=this.tier)
+ {
+ this.dischargeSlot.tier=this.tier;
+ }
+ if(this.getDemandedEnergy() > 1.0D)
+ {
+ double amount = this.dischargeSlot.discharge(this.getDemandedEnergy(), false);
+ this.energy += amount;
+ }
+ if(this.energy>this.maxStorage)
+ {
+ this.energy=this.maxStorage;
+ }
+
+
+ if(IC2.platform.isRendering() && this.startAS!=null)
+ {
+ if(this.getActive())
+ {
+ this.startAS.play();
+ }
+ else
+ {
+ this.startAS.stop();
+ }
+ }
+
+ }
+
+ @Override
+ public boolean acceptsEnergyFrom(TileEntity emitter,
+ ForgeDirection direction) {
+ return true;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return "tdit";
+ }
+
+ public int getStored() {
+ return Math.round((float)this.energy);
+ }
+
+ public void setStored(int value) {
+ this.energy=value;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer arg0, boolean arg1) {
+ return new TDITGui(new TDITContainer(arg0, this));
+ }
+
+ public boolean getGui(EntityPlayer player)
+ {
+ return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true) : false;
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer arg0) {
+ return new TDITContainer(arg0, this);
+ }
+ @Override
+ public void onGuiClosed(EntityPlayer arg0) {}
+
+ public void setOverclockRates()
+ {
+ int tierUp=0;
+ int capacityUp=0;
+ int checksum=0;
+ for(int i=0;i<this.upgradeSlot.size();i++)
+ {
+ if(this.upgradeSlot.get(i)!=null)
+ {
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("transformerUpgrade").getItemDamage())
+ {
+ tierUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ if(this.upgradeSlot.get(i).getItemDamage()==IC2Items.getItem("energyStorageUpgrade").getItemDamage())
+ {
+ capacityUp+=this.upgradeSlot.get(i).stackSize;
+ }
+ }
+ }
+ checksum=tierUp*64+capacityUp;
+ if(this.updateChecksum!=checksum)
+ {
+ this.maxStorage=this.defaultMaxStorage + capacityUp*10000;
+ NetworkHelper.updateTileEntityField(this, "maxStorage");
+ this.tier=this.defaultTier+tierUp;
+ NetworkHelper.updateTileEntityField(this, "tier");
+ this.updateChecksum=checksum;
+ }
+ }
+
+ //1.7.10 API
+ @Override
+ public double getDemandedEnergy()
+ {
+ return this.maxStorage - this.energy;
+ }
+
+ @Override
+ public int getSinkTier()
+ {
+ return this.tier;
+ }
+
+ @Override
+ public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
+ {
+ if (this.energy >= this.maxStorage)
+ {
+ return amount;
+ }
+ else
+ {
+ this.energy += amount;
+ return 0.0D;
+ }
+ }
+
+ public void setTarget(int targetX2, int targetY2, int targetZ2, int dimesionID) {
+ this.targetSet=true;
+ this.targetX=targetX2;
+ this.targetY=targetY2;
+ this.targetZ=targetZ2;
+ this.targetDimension=dimesionID;
+ }
+
+ public boolean canRecieve(List<ItemStack> itemStackList)
+ {
+ int countEmptySlots=0;
+ for(int i=0;i<this.outputSlot.size();i++)
+ {
+ if(this.outputSlot.get(i)==null)
+ {
+ countEmptySlots++;
+ }
+ }
+ return countEmptySlots>=itemStackList.size();
+ }
+
+ public void recieveItemStack(List<ItemStack> itemStackList)
+ {
+ this.outputSlot.add(itemStackList);
+ for (int i = 0; i < this.upgradeSlot.size(); ++i)
+ {
+ ItemStack stack = this.upgradeSlot.get(i);
+
+ if (stack != null && stack.getItem() instanceof ic2.core.upgrade.IUpgradeItem && ((IUpgradeItem)stack.getItem()).onTick(stack, this))
+ {
+ //needsInvUpdate = true;
+ }
+ }
+ }
+
+ private int countEnergyToOperate()
+ {
+ int energy = 0;
+ for(int i=0;i<this.inputSlot.size();i++)
+ {
+ if(this.inputSlot.get(i)!=null)
+ {
+ energy+=this.energyConsume*this.inputSlot.get(i).stackSize/this.inputSlot.get(i).getMaxStackSize();
+ }
+ }
+ return energy;
+
+ }
+
+ public void sendItemStack()
+ {
+ if(!this.inputSlot.isEmpty() && this.targetSet)
+ {
+ World targetWorld = MinecraftServer.getServer().worldServerForDimension(this.targetDimension);
+ if(targetWorld!=null)
+ {
+ TileEntity te = targetWorld.getTileEntity(targetX, targetY, targetZ);
+ if(te!=null && te instanceof TDITTileEntity)
+ {
+ TDITTileEntity tdit = (TDITTileEntity) te;
+ List<ItemStack> itemStackList = new ArrayList<ItemStack>();
+ for(int i=0;i<this.inputSlot.size();i++)
+ {
+ if(this.inputSlot.get(i)!=null)
+ {
+ itemStackList.add(this.inputSlot.get(i));
+ }
+ }
+ if(tdit.canRecieve(itemStackList))
+ {
+ tdit.recieveItemStack(itemStackList);
+ this.inputSlot.clear();
+ }
+ else
+ {
+ this.currentStatus=4;
+ }
+ }
+ else
+ {
+ this.currentStatus=2;
+ }
+ }
+ }
+ else
+ {
+ this.currentStatus=3;
+ }
+ }
+
+ public ItemStack getOutput(int arg0)
+ {
+ return this.outputSlot.get(arg0);
+ }
+
+ public int getOutputSize() {
+ return this.outputSlot.size();
+ }
+
+ public void setOutput(int arg0, ItemStack arg1)
+ {
+ this.outputSlot.put(arg0, arg1);
+ }
+
+ @Override
+ public Set<UpgradableProperty> getUpgradableProperties()
+ {
+ Set<UpgradableProperty> properties = new HashSet<UpgradableProperty>();
+ properties.add(UpgradableProperty.ItemProducing);
+ properties.add(UpgradableProperty.EnergyStorage);
+ return properties;
+ }
+
+ @Override
+ public double getEnergy() {
+ return this.energy;
+ }
+
+ @Override
+ public boolean useEnergy(double arg0) {
+ if(this.energy>=arg0)
+ {
+ this.energy-=arg0;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/utils/BlockItemRender.java b/src/main/java/ihl/utils/BlockItemRender.java new file mode 100644 index 0000000..34d1499 --- /dev/null +++ b/src/main/java/ihl/utils/BlockItemRender.java @@ -0,0 +1,218 @@ +package ihl.utils;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.block.RenderBlockDefault;
+import ihl.items_blocks.IHLItemBlock;
+import ihl.model.IHLModelRenderer;
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.entity.EntityClientPlayerMP;
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.model.ModelRenderer;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.entity.RenderPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.IItemRenderer;
+
+@SideOnly(value = Side.CLIENT)
+public class BlockItemRender implements IItemRenderer{
+ private ModelBase model;
+ private ResourceLocation tex;
+ private int renderFrom=0;
+ private int renderTo=0;
+ private RenderBlockDefault rbd;
+ private float amendment=0.0F;
+ private float inventoryOffset=0.0F;
+ private boolean renderHand;
+
+public BlockItemRender()
+{
+ rbd=new RenderBlockDefault();
+}
+
+public BlockItemRender(ModelBase model1, ResourceLocation texture, int renderFrom1, int renderTo1, float amendment1, float inventoryOffset1)
+{
+ this.model=model1;
+ this.tex=texture;
+ this.renderFrom=renderFrom1;
+ this.renderTo=renderTo1;
+ this.amendment=amendment1;
+ this.inventoryOffset=inventoryOffset1;
+ this.renderHand=false;
+}
+
+public BlockItemRender(ModelBase model1, ResourceLocation texture, int renderFrom1, int renderTo1, float amendment1, float inventoryOffset1, boolean renderHand1)
+{
+ this.model=model1;
+ this.tex=texture;
+ this.renderFrom=renderFrom1;
+ this.renderTo=renderTo1;
+ this.amendment=amendment1;
+ this.inventoryOffset=inventoryOffset1;
+ this.renderHand=renderHand1;
+}
+
+@Override
+public boolean handleRenderType(ItemStack item, ItemRenderType type) {
+ switch (type) {
+ case ENTITY:
+ return true;
+ case EQUIPPED:
+ return true;
+ case EQUIPPED_FIRST_PERSON:
+ return true;
+ case INVENTORY:
+ return true;
+ default:
+ return false;
+ }
+}
+
+@Override
+public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
+ return true;
+}
+
+@Override
+public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
+ if(tex!=null)
+ {
+ Minecraft.getMinecraft().renderEngine.bindTexture(tex);
+ }
+ GL11.glPushMatrix();
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ IHLItemBlock bItem =(IHLItemBlock) item.getItem();
+ Block block = bItem.getBlockContained();
+ GL11.glScalef(1F, -1F+amendment, -1F);
+ if(item.stackTagCompound!=null && item.stackTagCompound.hasKey("colour")){
+ int colour = item.stackTagCompound.getInteger("colour");
+ GL11.glColor4f((colour>>>16)/255f,((colour>>>8)&255)/255f, (colour&255)/255f,1f);
+ }
+ switch (type) {
+ case ENTITY:
+ GL11.glTranslatef(0,-1.5F,0);
+ if(model!=null)
+ {
+ for(int i = this.renderFrom;i<model.boxList.size()-this.renderTo;i++)
+ {
+ if(model.boxList.get(i) instanceof ModelRenderer)
+ {
+ ModelRenderer piece = (ModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ else if(model.boxList.get(i) instanceof IHLModelRenderer)
+ {
+ IHLModelRenderer piece = (IHLModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ }
+ }
+ else
+ {
+ rbd.renderInventoryBlock(block, 3, 0, new RenderBlocks());
+ }
+ GL11.glPopMatrix();
+ break;
+ case EQUIPPED:
+ GL11.glTranslatef(0.25F,-2F,-0.75F);
+ if(model!=null)
+ {
+ for(int i = this.renderFrom;i<model.boxList.size()-this.renderTo;i++)
+ {
+ if(model.boxList.get(i) instanceof ModelRenderer)
+ {
+ ModelRenderer piece = (ModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ else if(model.boxList.get(i) instanceof IHLModelRenderer)
+ {
+ IHLModelRenderer piece = (IHLModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ }
+ }
+ else
+ {
+ rbd.renderInventoryBlock(block, 3, 0, new RenderBlocks());
+ }
+ GL11.glPopMatrix();
+ break;
+ case EQUIPPED_FIRST_PERSON:
+ if(this.renderHand)
+ {
+ RenderPlayer var25;
+ EntityClientPlayerMP var3 = Minecraft.getMinecraft().thePlayer;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(var3.getLocationSkin());
+ var25 = (RenderPlayer)RenderManager.instance.getEntityRenderObject(Minecraft.getMinecraft().thePlayer);
+ GL11.glRotatef(135F, 1.0F, 0.0F, 0.0F);
+ GL11.glRotatef(35F, 0.0F, 1.0F, 0.0F);
+ var25.renderFirstPersonArm(Minecraft.getMinecraft().thePlayer);
+ GL11.glRotatef(-35F, 0.0F, 1.0F, 0.0F);
+ GL11.glRotatef(-135F, 1.0F, 0.0F, 0.0F);
+ Minecraft.getMinecraft().renderEngine.bindTexture(tex);
+ GL11.glTranslatef(0.0F,0.2F,0F);
+ }
+ GL11.glTranslatef(-0.25F,-2.0F-amendment,0F);
+ if(item.stackTagCompound!=null && item.stackTagCompound.hasKey("colour")){
+ int colour = item.stackTagCompound.getInteger("colour");
+ GL11.glColor4f((colour>>>16)/255f,((colour>>>8)&255)/255f, (colour&255)/255f,1f);
+ }
+ if(model!=null)
+ {
+ for(int i = this.renderFrom;i<model.boxList.size()-this.renderTo;i++)
+ {
+ if(model.boxList.get(i) instanceof ModelRenderer)
+ {
+ ModelRenderer piece = (ModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ else if(model.boxList.get(i) instanceof IHLModelRenderer)
+ {
+ IHLModelRenderer piece = (IHLModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ }
+ }
+ else
+ {
+ rbd.renderInventoryBlock(block, 3, 0, new RenderBlocks());
+ }
+ GL11.glPopMatrix();
+ break;
+ case INVENTORY:
+ GL11.glRotatef(15F, 0F, 1F, 0F);
+ GL11.glTranslatef(0.0F,-1.0F+inventoryOffset,0F);
+ if(model!=null)
+ {
+ for(int i = this.renderFrom;i<model.boxList.size()-this.renderTo;i++)
+ {
+ if(model.boxList.get(i) instanceof ModelRenderer)
+ {
+ ModelRenderer piece = (ModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ else if(model.boxList.get(i) instanceof IHLModelRenderer)
+ {
+ IHLModelRenderer piece = (IHLModelRenderer) model.boxList.get(i);
+ piece.render(1.0F/16.0F);
+ }
+ }
+ }
+ else
+ {
+
+ rbd.renderInventoryBlock(block, 3, 0, new RenderBlocks());
+ }
+ GL11.glDisable(GL11.GL_BLEND);
+ GL11.glPopMatrix();
+ break;
+ default:
+ }
+}
+}
\ No newline at end of file diff --git a/src/main/java/ihl/utils/EntityDropEventHandler.java b/src/main/java/ihl/utils/EntityDropEventHandler.java new file mode 100644 index 0000000..c8edf47 --- /dev/null +++ b/src/main/java/ihl/utils/EntityDropEventHandler.java @@ -0,0 +1,16 @@ +package ihl.utils;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import net.minecraft.entity.passive.EntitySheep;
+
+public class EntityDropEventHandler
+{
+ @SubscribeEvent
+ public void onEntityDropEvent(net.minecraftforge.event.entity.living.LivingDropsEvent event)
+ {
+ if(event.entityLiving instanceof EntitySheep && !event.entityLiving.isChild())
+ {
+ event.entityLiving.entityDropItem(IHLUtils.getThisModItemStackWithSize("muttonLard", event.entityLiving.worldObj.rand.nextInt(1)+1), 1f);
+ }
+ }
+}
diff --git a/src/main/java/ihl/utils/FluidDictionary.java b/src/main/java/ihl/utils/FluidDictionary.java new file mode 100644 index 0000000..8dcd18f --- /dev/null +++ b/src/main/java/ihl/utils/FluidDictionary.java @@ -0,0 +1,42 @@ +package ihl.utils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class FluidDictionary +{ + private Map<String,List<FluidStack>> nameToStack = new HashMap<String,List<FluidStack>>(); + private Map<Fluid,String> fluidToName = new HashMap<Fluid,String>(); + public FluidDictionary(){} + + public List<FluidStack> getFluids(String fdName) + { + return nameToStack.get(fdName); + } + + public void registerFluidStack(String fdName, FluidStack fstack) + { + if(nameToStack.containsKey(fdName)) + { + nameToStack.get(fdName).add(fstack); + } + else + { + List<FluidStack> list = new ArrayList<FluidStack>(); + list.add(fstack); + nameToStack.put(fdName, list); + } + fluidToName.put(fstack.getFluid(), fdName); + } + + public String getFluidName(Fluid f) + { + return fluidToName.get(f); + } + +} diff --git a/src/main/java/ihl/utils/GuiMultiTextureButton.java b/src/main/java/ihl/utils/GuiMultiTextureButton.java new file mode 100644 index 0000000..009c57f --- /dev/null +++ b/src/main/java/ihl/utils/GuiMultiTextureButton.java @@ -0,0 +1,47 @@ +package ihl.utils;
+
+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.gui.GuiButton;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(value = Side.CLIENT)
+public class GuiMultiTextureButton extends GuiButton {
+
+ private ResourceLocation texture;
+ private int textureX;
+ private int textureY;
+ private int textureActiveX;
+ private int textureActiveY;
+ public boolean isActive=false;
+
+ public GuiMultiTextureButton(int id1, int x, int y, int w, int h,
+ ResourceLocation texture1, int textureX1, int textureY1, int textureActiveX1, int textureActiveY1) {
+ super(id1, x, y, w, h, "");
+ texture=texture1;
+ textureX=textureX1;
+ textureY=textureY1;
+ textureActiveX=textureActiveX1;
+ textureActiveY=textureActiveY1;
+
+ }
+
+ @Override
+ public void drawButton(Minecraft minecraft, int i, int j)
+ {
+ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ minecraft.getTextureManager().bindTexture(this.texture);
+ if(this.isActive)
+ {
+ this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureActiveX, this.textureActiveY, this.width, this.height);
+ }
+ else
+ {
+ this.drawTexturedModalRect(this.xPosition, this.yPosition, this.textureX, this.textureY, this.width, this.height);
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/utils/IHLFluidTank.java b/src/main/java/ihl/utils/IHLFluidTank.java new file mode 100644 index 0000000..67597e1 --- /dev/null +++ b/src/main/java/ihl/utils/IHLFluidTank.java @@ -0,0 +1,322 @@ +package ihl.utils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import ihl.recipes.IRecipeInputFluid;
+import ihl.worldgen.ores.IHLFluid;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.FluidTankInfo;
+import net.minecraftforge.fluids.IFluidTank;
+
+public class IHLFluidTank implements IFluidTank {
+ private final List<FluidStack> fluidList = new ArrayList<FluidStack>();
+ private final int capacity;
+
+ public IHLFluidTank(int capacity) {
+ this.capacity = capacity;
+ }
+
+ public IHLFluidTank(int capacity, boolean isOpenVessel1) {
+ this.capacity = capacity;
+ }
+
+ public IHLFluidTank readFromNBT(NBTTagCompound nbt) {
+ if (!nbt.hasKey("Empty")) {
+ NBTTagList fluidList1 = nbt.getTagList("fluids", 10);
+ for (int i = 0; i < fluidList1.tagCount(); i++) {
+ NBTTagCompound fluidNBT1 = fluidList1.getCompoundTagAt(i);
+ FluidStack fluid = FluidStack.loadFluidStackFromNBT(fluidNBT1);
+ if (fluid != null) {
+ fluidList.add(fluid);
+ }
+ }
+ }
+ return this;
+ }
+
+ public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
+ if (!fluidList.isEmpty()) {
+ NBTTagList fluids = new NBTTagList();
+ Iterator<FluidStack> fli = fluidList.iterator();
+ while (fli.hasNext()) {
+ FluidStack fluid = fli.next();
+ if (fluid != null) {
+ NBTTagCompound fluidNBT1 = new NBTTagCompound();
+ fluid.writeToNBT(fluidNBT1);
+ fluids.appendTag(fluidNBT1);
+ }
+ }
+ nbt.setTag("fluids", fluids);
+ } else {
+ nbt.setString("Empty", "");
+ }
+ return nbt;
+ }
+
+ /* IFluidTank */
+ @Override
+ public FluidStack getFluid() {
+ if (this.fluidList.isEmpty()) {
+ return null;
+ }
+ return this.fluidList.get(0);
+ }
+
+ public FluidStack getLigthestFluid() {
+ if (this.fluidList.isEmpty()) {
+ return IHLUtils.getFluidStackWithSize("air", this.capacity);
+ }
+ return this.fluidList.get(this.fluidList.size() - 1);
+ }
+
+ @Override
+ public int getFluidAmount() {
+ int amount = 0;
+ Iterator<FluidStack> fli = fluidList.iterator();
+ while (fli.hasNext()) {
+ FluidStack fluid = fli.next();
+ if (fluid != null) {
+ amount += fluid.amount;
+ }
+ }
+ return amount;
+ }
+
+ @Override
+ public int getCapacity() {
+ return capacity;
+ }
+
+ @Override
+ public FluidTankInfo getInfo() {
+ return new FluidTankInfo(this);
+ }
+
+ @Override
+ public int fill(FluidStack resource, boolean doFill) {
+ if (resource == null)
+ return 0;
+ int freeSpace = capacity - this.getFluidAmount();
+ int amount1 = Math.min(freeSpace, resource.amount);
+ if (resource.getFluid() == null || amount1<=0) {
+ return 0;
+ }
+ if (!doFill) {
+ return amount1;
+ }
+ FluidStack fluid = getFluidStackWithSameFluid(resource);
+ if (fluid != null) {
+ fluid.amount += amount1;
+ return amount1;
+ }
+ fluid = copyWithSize(resource, amount1);
+ fluidList.add(fluid);
+ this.sortFluidsByDensity();
+ return amount1;
+ }
+
+ @Override
+ public FluidStack drain(int maxDrain, boolean doDrain) {
+ if (fluidList.isEmpty()) {
+ return null;
+ }
+ FluidStack fstack = this.getFluid().copy();
+ fstack.amount = maxDrain;
+ return this.drain(fstack, doDrain);
+ }
+
+ public FluidStack drainLightest(int maxDrain, boolean doDrain) {
+ if (fluidList.isEmpty()) {
+ return null;
+ }
+ FluidStack fstack = this.getLigthestFluid().copy();
+ fstack.amount = maxDrain;
+ return this.drain(fstack, doDrain);
+ }
+
+ public FluidStack drain(Object fluidStack, boolean doDrain) {
+ if (fluidList.isEmpty()) {
+ return null;
+ }
+ int drained = 0;
+ if (fluidStack instanceof FluidStack) {
+ drained = ((FluidStack) fluidStack).amount;
+ } else {
+ drained = ((IRecipeInputFluid) fluidStack).getAmount();
+ }
+ FluidStack fluid = this.getFluidStackWithSameFluid(fluidStack);
+ if (fluid == null) {
+ return null;
+ }
+ if (fluid.amount < drained) {
+ drained = fluid.amount;
+ }
+ FluidStack stack = copyWithSize(fluid, drained);
+ if (doDrain) {
+ fluid.amount -= drained;
+ if (fluid.amount <= 0) {
+ this.fluidList.remove(fluid);
+ }
+ }
+ return stack;
+ }
+
+ public FluidStack getFluidStackWithSameFluid(Object fluidStack) {
+ Iterator<FluidStack> fli = fluidList.iterator();
+ while (fli.hasNext()) {
+ FluidStack fluid = fli.next();
+ if (fluid != null) {
+ if (fluidStack instanceof FluidStack) {
+ if (fluid.isFluidEqual((FluidStack) fluidStack)) {
+ return fluid;
+ }
+ } else {
+ if (((IRecipeInputFluid) fluidStack).matches(fluid)) {
+ return fluid;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public int getNumberOfFluids() {
+ return this.fluidList.size();
+ }
+
+ public void setFluidAmount(int amount1, int index) {
+ if (this.fluidList.size() <= index) {
+ while (this.fluidList.size() <= index) {
+ this.fluidList.add(new FluidStack(FluidRegistry.WATER, 1));
+ }
+ }
+ this.fluidList.get(index).amount = amount1;
+ }
+
+ public int getFluidAmount(int index) {
+ if (this.fluidList.size() <= index || this.fluidList.get(index) == null) {
+ return 0;
+ }
+ return this.fluidList.get(index).amount;
+ }
+
+ public int getFluidID(int i) {
+ if (this.fluidList.get(i) == null) {
+ return -1;
+ }
+ return this.fluidList.get(i).getFluid().getID();
+ }
+
+ public void sortFluidsByDensity() {
+ Map<Integer, FluidStack> sortMap = new HashMap<Integer, FluidStack>();
+ int[] keysArray = new int[fluidList.size()];
+ Iterator<FluidStack> fli = fluidList.iterator();
+ while (fli.hasNext()) {
+ FluidStack fluid = fli.next();
+ if (fluid == null) {
+ return;
+ }
+ int key = Math.round(IHLFluid.getRealDensity(fluid.getFluid()) * 100F);
+ while (sortMap.containsKey(key)) {
+ key++;
+ }
+ sortMap.put(key, fluid);
+ keysArray[fluidList.indexOf(fluid)] = key;
+ }
+ Arrays.sort(keysArray);
+ ArrayList<FluidStack> newFluidList = new ArrayList<FluidStack>();
+ for (int i = keysArray.length - 1; i >= 0; i--) {
+ newFluidList.add(sortMap.get(keysArray[i]));
+ }
+ this.fluidList.clear();
+ this.fluidList.addAll(newFluidList);
+ }
+
+ public FluidStack getFluid(int i) {
+ return this.fluidList.get(i);
+ }
+
+ public void setTag(String string, int t1_1) {
+ if (this.getFluid().tag == null) {
+ this.getFluid().tag = new NBTTagCompound();
+ }
+ this.getFluid().tag.setInteger(string, t1_1);
+ }
+
+ public void setEmpty() {
+ this.fluidList.clear();
+ }
+
+ public List<FluidStack> getFluidList() {
+ return this.fluidList;
+ }
+
+ public void drain(List<?> fluidInputs, boolean doDrain) {
+ if (fluidInputs != null && !fluidInputs.isEmpty()) {
+ Iterator<?> fsi = fluidInputs.iterator();
+ while (fsi.hasNext()) {
+ this.drain(fsi.next(), doDrain);
+ }
+ }
+ }
+
+ public void fill(List<FluidStack> fluidOutputs, boolean doFill) {
+ if (fluidOutputs != null && !fluidOutputs.isEmpty()) {
+ Iterator<FluidStack> fsi = fluidOutputs.iterator();
+ while (fsi.hasNext()) {
+ this.fill(fsi.next(), doFill);
+ }
+ }
+ }
+
+ private FluidStack copyWithSize(FluidStack resource, int amount1) {
+ FluidStack fluid = resource.copy();
+ fluid.amount = amount1;
+ if (resource.tag != null) {
+ fluid.tag = (NBTTagCompound) resource.tag.copy();
+ }
+ return fluid;
+ }
+
+ public FluidStack drain(IRecipeInputFluid fluidStack, int amount, boolean doDrain) {
+ if (fluidList.isEmpty()) {
+ return null;
+ }
+ int drained = amount;
+ FluidStack fluid = this.getFluidStackWithSameFluid(fluidStack);
+ if (fluid == null) {
+ return null;
+ }
+ if (fluid.amount < drained) {
+ drained = fluid.amount;
+ }
+ FluidStack stack = copyWithSize(fluid, drained);
+ if (doDrain) {
+ fluid.amount -= drained;
+ if (fluid.amount <= 0) {
+ this.fluidList.remove(fluid);
+ }
+ }
+ return stack;
+ }
+
+ public void checkCorrectState() {
+ if (!this.fluidList.isEmpty()) {
+ Iterator<FluidStack> fsi = this.fluidList.iterator();
+ while (fsi.hasNext()) {
+ FluidStack fs = fsi.next();
+ if (fs.amount <= 0) {
+ fsi.remove();
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/ihl/utils/IHLInvSlotDischarge.java b/src/main/java/ihl/utils/IHLInvSlotDischarge.java new file mode 100644 index 0000000..ffa4216 --- /dev/null +++ b/src/main/java/ihl/utils/IHLInvSlotDischarge.java @@ -0,0 +1,83 @@ +package ihl.utils;
+
+import ic2.api.info.Info;
+import ic2.api.item.ElectricItem;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+
+public class IHLInvSlotDischarge extends InvSlot
+{
+ public int tier;
+ public boolean allowRedstoneDust;
+
+ public IHLInvSlotDischarge(TileEntityInventory base, int oldStartIndex, InvSlot.Access access, int tier)
+ {
+ this(base, oldStartIndex, access, tier, InvSlot.InvSide.ANY);
+ }
+
+ public IHLInvSlotDischarge(TileEntityInventory base, int oldStartIndex, InvSlot.Access access, int tier, InvSlot.InvSide preferredSide)
+ {
+ this(base, oldStartIndex, access, tier, true, preferredSide);
+ }
+
+ public IHLInvSlotDischarge(TileEntityInventory base, int oldStartIndex, InvSlot.Access access, int tier, boolean allowRedstoneDust, InvSlot.InvSide preferredSide)
+ {
+ super(base, "discharge", oldStartIndex, access, 1, preferredSide);
+ this.allowRedstoneDust = true;
+ this.tier = tier;
+ this.allowRedstoneDust = allowRedstoneDust;
+ }
+
+ @Override
+ public boolean accepts(ItemStack stack)
+ {
+ return stack == null ? false : (stack.getItem() == Items.redstone && !this.allowRedstoneDust ? false : Info.itemEnergy.getEnergyValue(stack) > 0.0D || ElectricItem.manager.discharge(stack, Double.POSITIVE_INFINITY, this.tier, true, true, true) > 0.0D);
+ }
+
+ public double discharge(double amount, boolean ignoreLimit)
+ {
+ if (amount <= 0.0D)
+ {
+ throw new IllegalArgumentException("Amount must be > 0.");
+ }
+ else
+ {
+ ItemStack stack = this.get(0);
+
+ if (stack == null)
+ {
+ return 0.0D;
+ }
+ else
+ {
+ double realAmount = ElectricItem.manager.discharge(stack, amount, this.tier, ignoreLimit, true, false);
+
+ if (realAmount <= 0.0D)
+ {
+ realAmount = Info.itemEnergy.getEnergyValue(stack);
+
+ if (realAmount <= 0.0D)
+ {
+ return 0.0D;
+ }
+
+ --stack.stackSize;
+
+ if (stack.stackSize <= 0)
+ {
+ this.put(0, (ItemStack)null);
+ }
+ }
+
+ return realAmount;
+ }
+ }
+ }
+
+ public void setTier(int tier1)
+ {
+ this.tier = tier1;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/utils/IHLItemRenderer.java b/src/main/java/ihl/utils/IHLItemRenderer.java new file mode 100644 index 0000000..0191edb --- /dev/null +++ b/src/main/java/ihl/utils/IHLItemRenderer.java @@ -0,0 +1,297 @@ +package ihl.utils;
+
+import java.util.Random;
+
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.ItemRenderer;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.entity.RenderManager;
+import net.minecraft.client.renderer.texture.TextureManager;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemCloth;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.client.IItemRenderer;
+import net.minecraftforge.client.IItemRenderer.ItemRenderType;
+import net.minecraftforge.client.MinecraftForgeClient;
+
+@SideOnly(value = Side.CLIENT)
+public class IHLItemRenderer {
+ private Random random = new Random();
+ private RenderBlocks renderBlocks = new RenderBlocks();
+ private boolean noRotation=false;
+
+ public IHLItemRenderer(){}
+
+ public IHLItemRenderer(boolean noRotation1)
+ {
+ noRotation=noRotation1;
+ }
+
+ public void doRender(RenderManager renderManager, ItemStack stack, double x, double y, double z)
+ {
+ if(stack!=null)
+ {
+ if(stack.getItem().isFull3D())
+ {
+ ItemRenderType type = ItemRenderType.ENTITY;
+ IItemRenderer itemRenderer = MinecraftForgeClient.getItemRenderer(stack, type);
+ if(itemRenderer!=null)
+ {
+ GL11.glPushMatrix();
+ GL11.glTranslatef((float)x, (float)y-0.5F, (float)z);
+ GL11.glScalef(0.5F, 0.5F, 0.5F);
+ Object[] data={null,null};
+ itemRenderer.renderItem(type, stack, data);
+ GL11.glPopMatrix();
+ }
+ else
+ {
+ this.doRenderNative(renderManager, stack, x, y-0.1F, z);
+ }
+ }
+ else
+ {
+ this.doRenderNative(renderManager, stack, x, y-0.1F, z);
+ }
+ }
+ }
+
+ public void doRenderNative(RenderManager renderManager, ItemStack var10, double par2, double par4, double par6)
+ {
+ float scale=0.8F;
+ if (var10.getItem() != null)
+ {
+ renderManager.renderEngine.bindTexture(renderManager.renderEngine.getResourceLocation(var10.getItemSpriteNumber()));
+ this.random.setSeed(187L);
+ GL11.glPushMatrix();
+ byte var13 = 1;
+
+ if (var10.stackSize > 1)
+ {
+ var13 = 2;
+ }
+
+ if (var10.stackSize > 5)
+ {
+ var13 = 3;
+ }
+
+ if (var10.stackSize > 20)
+ {
+ var13 = 4;
+ }
+
+ if (var10.stackSize > 40)
+ {
+ var13 = 5;
+ }
+
+ GL11.glTranslatef((float)par2, (float)par4, (float)par6);
+
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+ float var19;
+ float var18;
+ int var24;
+
+ if (var10.getItemSpriteNumber() == 0 && var10.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(var10.getItem()).getRenderType()))
+ {
+ Block var21 = Block.getBlockFromItem(var10.getItem());
+
+ float var25 = 0.25F*scale;
+ var24 = var21.getRenderType();
+
+ if (var24 == 1 || var24 == 19 || var24 == 12 || var24 == 2)
+ {
+ var25 = 0.5F*scale;
+ }
+
+ if (var21.getRenderBlockPass() > 0)
+ {
+ GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
+ GL11.glEnable(GL11.GL_BLEND);
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+ }
+
+ GL11.glScalef(var25, var25, var25);
+
+ for (int var26 = 0; var26 < var13; ++var26)
+ {
+ GL11.glPushMatrix();
+
+ if (var26 > 0)
+ {
+ var18 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var25;
+ var19 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var25;
+ float var20 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.2F / var25;
+ GL11.glTranslatef(var18, var19, var20);
+ }
+
+ this.renderBlocks.renderBlockAsItem(var21, var10.getItemDamage(), 1.0F);
+ GL11.glPopMatrix();
+ }
+
+ if (var21.getRenderBlockPass() > 0)
+ {
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+ }
+ else
+ {
+ float var17;
+
+ if (var10.getItemSpriteNumber() == 1 && var10.getItem().requiresMultipleRenderPasses())
+ {
+ GL11.glScalef(0.5F*scale, 0.5F*scale, 0.5F*scale);
+
+ for (int var23 = 0; var23 <= 1; ++var23)
+ {
+ this.random.setSeed(187L);
+ IIcon var22 = var10.getItem().getIconFromDamageForRenderPass(var10.getItemDamage(), var23);
+ var24 = var10.getItem().getColorFromItemStack(var10, var23);
+ var17 = (var24 >> 16 & 255) / 255.0F;
+ var18 = (var24 >> 8 & 255) / 255.0F;
+ var19 = (var24 & 255) / 255.0F;
+ GL11.glColor4f(var17, var18, var19, 1.0F);
+ this.renderDroppedItem(renderManager, var10, var22, var13, var17, var18, var19);
+
+ }
+ }
+ else
+ {
+ if (var10 != null && var10.getItem() instanceof ItemCloth)
+ {
+ GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
+ GL11.glEnable(GL11.GL_BLEND);
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
+ }
+ GL11.glScalef(0.5F*scale, 0.5F*scale, 0.5F*scale);
+ IIcon var14 = var10.getIconIndex();
+ int var15 = var10.getItem().getColorFromItemStack(var10, 0);
+ float var16 = (var15 >> 16 & 255) / 255.0F;
+ var17 = (var15 >> 8 & 255) / 255.0F;
+ var18 = (var15 & 255) / 255.0F;
+ this.renderDroppedItem(renderManager, var10, var14, var13, var16, var17, var18);
+ if (var10 != null && var10.getItem() instanceof ItemCloth)
+ {
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+ }
+ }
+
+ GL11.glDisable(GL12.GL_RESCALE_NORMAL);
+ GL11.glPopMatrix();
+ }
+ }
+
+ private void renderDroppedItem(RenderManager renderManager, ItemStack stack, IIcon par2Icon, int par3, float par5, float par6, float par7)
+ {
+ Tessellator var8 = Tessellator.instance;
+
+ if (par2Icon == null)
+ {
+ TextureManager var9 = Minecraft.getMinecraft().getTextureManager();
+ ResourceLocation var10 = var9.getResourceLocation(stack.getItemSpriteNumber());
+ par2Icon = ((TextureMap)var9.getTexture(var10)).getAtlasSprite("missingno");
+ }
+
+ float var25 = par2Icon.getMinU();
+ float var26 = par2Icon.getMaxU();
+ float var11 = par2Icon.getMinV();
+ float var12 = par2Icon.getMaxV();
+ float var13 = 1.0F;
+ float var14 = 0.5F;
+ float var15 = 0.25F;
+ float var17;
+
+ if (renderManager.options.fancyGraphics)
+ {
+ GL11.glPushMatrix();
+
+ //GL11.glRotatef((this.random .nextFloat() * 2.0F - 1.0F) * (180F / (float)Math.PI), 0.0F, 1.0F, 0.0F);
+
+ float var16 = 0.0625F;
+ var17 = 0.021875F;
+ ItemStack var18 = stack;
+ int var19 = var18.stackSize;
+ byte var24;
+
+ if (var19 < 2)
+ {
+ var24 = 1;
+ }
+ else if (var19 < 16)
+ {
+ var24 = 2;
+ }
+ else if (var19 < 32)
+ {
+ var24 = 3;
+ }
+ else
+ {
+ var24 = 4;
+ }
+
+ GL11.glTranslatef(-var14, -var15, -((var16 + var17) * var24 / 2.0F));
+
+ for (int var20 = 0; var20 < var24; ++var20)
+ {
+ GL11.glTranslatef(0.0F, 0.0F, var16 + var17);
+
+ if (var18.getItemSpriteNumber() == 0)
+ {
+ renderManager.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
+ }
+ else
+ {
+ renderManager.renderEngine.bindTexture(TextureMap.locationItemsTexture);
+ }
+
+ GL11.glColor4f(par5, par6, par7, 1.0F);
+ ItemRenderer.renderItemIn2D(var8, var26, var11, var25, var12, par2Icon.getIconWidth(), par2Icon.getIconHeight(), var16);
+ }
+
+ GL11.glPopMatrix();
+ }
+ else
+ {
+ for (int var27 = 0; var27 < par3; ++var27)
+ {
+ GL11.glPushMatrix();
+
+ if (var27 > 0)
+ {
+ var17 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
+ float var29 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
+ float var28 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.3F;
+ GL11.glTranslatef(var17, var29, var28);
+ }
+ if(!noRotation)
+ {
+ GL11.glRotatef(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
+ }
+ GL11.glColor4f(par5, par6, par7, 1.0F);
+ var8.startDrawingQuads();
+ var8.setNormal(0.0F, 1.0F, 0.0F);
+ var8.addVertexWithUV(0.0F - var14, 0.0F - var15, 0.0D, var25, var12);
+ var8.addVertexWithUV(var13 - var14, 0.0F - var15, 0.0D, var26, var12);
+ var8.addVertexWithUV(var13 - var14, 1.0F - var15, 0.0D, var26, var11);
+ var8.addVertexWithUV(0.0F - var14, 1.0F - var15, 0.0D, var25, var11);
+ var8.draw();
+ GL11.glPopMatrix();
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/utils/IHLMathUtils.java b/src/main/java/ihl/utils/IHLMathUtils.java new file mode 100644 index 0000000..8cab3c9 --- /dev/null +++ b/src/main/java/ihl/utils/IHLMathUtils.java @@ -0,0 +1,103 @@ +package ihl.utils; + +public class IHLMathUtils { + private final static int accuracy_level = 1024; + private final static float[] sqrt_table = new float[accuracy_level]; + + public static float sqrt(float value) { + float value1 = value; + int multiplier = 1; + while (value1 >= 1.0f) { + multiplier=multiplier<<2; + value1 = value / (multiplier * multiplier); + } + return multiplier * sqrt_table[(int) (value1 * accuracy_level)]; + } + + public static float[] vector_vector_multiply(float[] v1, float[] v2) { + float c_x = v1[1] * v2[2] - v2[1] * v1[2]; + float c_y = v2[0] * v1[2] - v1[0] * v2[2]; + float c_z = v1[0] * v2[1] - v2[0] * v1[1]; + return new float[] { c_x, c_y, c_z }; + } + + public static void normalize_vector(float[] v1) { + float d = (float) Math.sqrt(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]); + if (d == 0) { // Nothing can we do. Create new vector towards up + // direction. + v1[0] = 0; + v1[1] = 1; + v1[2] = 0; + } else { + v1[0] /= d; + v1[1] /= d; + v1[2] /= d; + } + } + + public static void scale_vector_to_value(float[] v1, float v2) { + float d = (float) Math.sqrt(v1[0] * v1[0] + v1[1] * v1[1] + v1[2] * v1[2]); + if (d == 0) { // Nothing can we do. Create new vector towards up + // direction. + v1[0] = 0; + v1[1] = v2; + v1[2] = 0; + } else { + v1[0] = v1[0] * v2 / d; + v1[1] = v1[1] * v2 / d; + v1[2] = v1[2] * v2 / d; + } + } + + public static void vector_add(float[] fs, float x, float y, float z) { + fs[0] += x; + fs[1] += y; + fs[2] += z; + } + + static { + for (int i = 0; i < accuracy_level; i++) { + sqrt_table[i] = (float) Math.sqrt((double) i / accuracy_level); + } + } + + public static float[] vector_return_difference(double[] v1, double[] v2) { + return new float[] { (float) (v1[0] - v2[0]), (float) (v1[1] - v2[1]), (float) (v1[2] - v2[2]) }; + } + + public static float[] vector_return_difference(float[] v1, double[] v2) { + return new float[] { (float) (v1[0] - v2[0]), (float) (v1[1] - v2[1]), (float) (v1[2] - v2[2]) }; + } + + public static float[] vector_return_difference(int[] v1, double[] v2) { + return new float[] { (float) (v1[0] - v2[0]), (float) (v1[1] - v2[1]), (float) (v1[2] - v2[2]) }; + } + + public static void multiply_vector_to_value(float[] v1, float v2) { + v1[0] *= v2; + v1[1] *= v2; + v1[2] *= v2; + } + + public static void vector_add(double[] v1, float[] v2) { + v1[0] += v2[0]; + v1[1] += v2[1]; + v1[2] += v2[2]; + } + + public static float[] get_triangle_normal(double[][] triangle1) { + float[] v1 = vector_return_difference(triangle1[1], triangle1[0]); + float[] v2 = vector_return_difference(triangle1[2], triangle1[0]); + return vector_vector_multiply(v1, v2); + } + + public static int sign(int value) { + if (value > 0) + return 1; + else if (value < 0) + return -1; + else + return 0; + } + +} diff --git a/src/main/java/ihl/utils/IHLRenderUtils.java b/src/main/java/ihl/utils/IHLRenderUtils.java new file mode 100644 index 0000000..d0d13f4 --- /dev/null +++ b/src/main/java/ihl/utils/IHLRenderUtils.java @@ -0,0 +1,819 @@ +package ihl.utils;
+
+import java.nio.FloatBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.util.DrawUtil;
+import ihl.IHLMod;
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.multiplayer.WorldClient;
+import net.minecraft.client.renderer.GLAllocation;
+import net.minecraft.client.renderer.RenderBlocks;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.StatCollector;
+import net.minecraftforge.client.event.DrawBlockHighlightEvent;
+import net.minecraftforge.common.util.ForgeDirection;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidStack;
+
+@SideOnly(value = Side.CLIENT)
+public class IHLRenderUtils
+{
+ private FloatBuffer colorBuffer;
+ private Map<Long, Integer> frameTooltipMap;
+ private int displayScaledWidth=-1;
+ private int displayScaledHeight=-1;
+ private int guiXPos=-1;
+ private int guiYPos=-1;
+ private int prevDisplayWidth=-1;
+ private int prevDisplayHeight=-1;
+ private final int guiContainerWidth = 166;
+ private final int guiContainerHeight = 176;
+ private float lastPlayerYaw;
+ private float lastPlayerPitch;
+ public double renderMinX=0d;
+ public double renderMaxX=1d;
+ public double renderMinY=0d;
+ public double renderMaxY=1d;
+ public double renderMinZ=0d;
+ public double renderMaxZ=1d;
+ public boolean renderFromInside=false;
+ private float rotationPointX;
+ private float rotationPointY;
+ private float rotationPointZ;
+ private double renderPositionX;
+ private double renderPositionY;
+ private double renderPositionZ;
+ private float rotationX;
+ private float rotationY;
+ private float rotationZ;
+ private float scale=1/16f;
+ public boolean swapXandZ=false;
+ public boolean swapXandY=false;
+ public boolean swapYandZ=false;
+ public boolean swapRenderBoundsX=false;
+ public boolean swapRenderBoundsY=false;
+ public boolean swapRenderBoundsZ=false;
+ public int scaleFactor=1;
+ public static IHLRenderUtils instance;
+
+ public IHLRenderUtils()
+ {
+ instance=this;
+ colorBuffer = GLAllocation.createDirectFloatBuffer(16);
+ frameTooltipMap = new HashMap<Long, Integer>();
+ }
+
+ public void renderIHLFluidTank(IHLFluidTank fluidTank, int x1, int y1, int x2, int y2, float zLevel, int par1, int par2, int xOffset, int yOffset)
+ {
+ int liquidHeight = 0;
+ int prevLiquidHeight = 0;
+ int i = y2-y1;
+ Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glColor4f(1f, 1f, 1f, 1f);
+ for(int i2 = 0;i2<fluidTank.getNumberOfFluids();i2++)
+ {
+ FluidStack fluidStack = fluidTank.getFluid(i2);
+ if(fluidStack!=null)
+ {
+ Fluid fluid = fluidStack.getFluid();
+ if(fluid!=null)
+ {
+ IIcon fluidIcon = fluid.getIcon();
+ if (fluidIcon != null)
+ {
+ liquidHeight = fluidTank.getFluidAmount(i2) * i /fluidTank.getCapacity();
+ DrawUtil.drawRepeated(fluidIcon, x1, y2 - liquidHeight-prevLiquidHeight, x2-x1, liquidHeight, zLevel);
+ prevLiquidHeight+=liquidHeight;
+ }
+ }
+ }
+ }
+ drawIHLFluidTankTooltip(par1, par2, x1+guiXPos-6, y1+guiYPos+6, x2+guiXPos-6, y2+guiYPos+6, fluidTank);
+ }
+
+ public void drawMissingEngineTooltip(GuiContainer gui, int par1, int par2, int xPos, int yPos, int xOffset, int yOffset)
+ {
+ gui.drawTexturedModalRect(xPos, yPos, 194, 0, 3, 14);
+ drawTooltip(par1,par2,3,14,xPos+xOffset,yPos+yOffset,StatCollector.translateToLocal("ihl.gui.missing.engine"));
+ }
+
+ public void drawWorkspaceElementTooltip(int par1, int par2, int xPos, int yPos, ItemStack workSpaceElement)
+ {
+ drawTooltip(par1,par2,16,16,xPos,yPos,StatCollector.translateToLocal(workSpaceElement.getUnlocalizedName()+".tooltip"));
+ }
+
+ public void drawIHLFluidTankTooltip(int par1, int par2, int x1, int y1, int x2, int y2, IHLFluidTank fluidTank)
+ {
+ String fluidListNames="";
+ List<FluidStack> fli = fluidTank.getFluidList();
+ for(int i=fli.size()-1;i>=0;i--)
+ {
+ FluidStack fluidStack = fli.get(i);
+ fluidListNames+=StatCollector.translateToLocal(fluidStack.getUnlocalizedName())+": "+fluidStack.amount+"mB /n ";
+ }
+ drawTooltip(par1,par2,x2-x1,y2-y1,x1,y1,fluidListNames);
+ }
+
+ public boolean drawTooltip(int cursorPosX, int cursorPosY, int width, int height, int xPos, int yPos, String text)
+ {
+ updateScreenSize();
+ long key = xPos+yPos*1024;
+ Integer frame=0;
+ if(frameTooltipMap.containsKey(key))
+ {
+ frame=frameTooltipMap.get(key);
+ }
+ boolean showString=true;
+ if(cursorPosX<xPos || cursorPosX>xPos+width||
+ cursorPosY<yPos || cursorPosY>yPos+height)
+ {
+ if(frame>0)
+ {
+ frame-=20;
+ frameTooltipMap.put(key, frame);
+ }
+ showString=false;
+ }
+ else
+ {
+ frame+=10;
+ frameTooltipMap.put(key, frame);
+ }
+ if(frame>0)
+ {
+ int strokeHeight=15;
+ int i,x1,x2,y1,y2,tooltipWidth,tooltipHeight;
+ tooltipWidth=tooltipHeight=0;
+ String[] splittedText = text.split(" /n ");
+ for(i=0;i<splittedText.length;i++)
+ {
+ if(Minecraft.getMinecraft().fontRenderer.getStringWidth(splittedText[i])+8>tooltipWidth)
+ {
+ tooltipWidth=Math.min(frame,Minecraft.getMinecraft().fontRenderer.getStringWidth(splittedText[i])+8);
+ }
+ }
+ tooltipHeight=Math.min(Math.max(frame-tooltipWidth,strokeHeight),strokeHeight*splittedText.length);
+ x1=cursorPosX-xPos;
+ x2=x1+tooltipWidth;
+ y1=cursorPosY-guiYPos+18;
+ y2=y1+tooltipHeight;
+ GL11.glPushAttrib(16704);
+ GL11.glDisable(GL11.GL_DEPTH_TEST);
+ GL11.glDisable(GL11.GL_TEXTURE_2D);
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ if(showString)
+ {
+ drawRectangle(Tessellator.instance, x1,y1,x2,y2,128);
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+ for(i=0;i<splittedText.length;i++)
+ {
+ if(i<tooltipHeight/strokeHeight)
+ {
+ Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(splittedText[i], x1+4, y1+i*strokeHeight+4, 16768125);
+ }
+ }
+ }
+ else
+ {
+ drawRectangle(Tessellator.instance, x1,y1,x2,y2,Math.min(128,frame/2));
+ GL11.glEnable(GL11.GL_TEXTURE_2D);
+ }
+ GL11.glPopAttrib();
+ frame=Math.min(tooltipWidth+tooltipHeight,frame);
+ frameTooltipMap.put(key, frame);
+ return true;
+ }
+ return false;
+ }
+
+ public void enableAmbientLighting()
+ {
+ GL11.glDisable(GL11.GL_LIGHT0);
+ GL11.glDisable(GL11.GL_LIGHT1);
+ GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, setColorBuffer(1.0f, 1.0f, 1.0f, 1.0F));
+ }
+
+ public void disableAmbientLighting()
+ {
+ GL11.glEnable(GL11.GL_LIGHT0);
+ GL11.glEnable(GL11.GL_LIGHT1);
+ GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, setColorBuffer(0.0f, 0.0f, 0.0f, 1.0F));
+ }
+
+ /**
+ * Update and return colorBuffer with the RGBA values passed as arguments
+ */
+ private FloatBuffer setColorBuffer(float par0, float par1, float par2, float par3)
+ {
+ colorBuffer.clear();
+ colorBuffer.put(par0).put(par1).put(par2).put(par3);
+ colorBuffer.flip();
+ return colorBuffer;
+ }
+
+ private void drawRectangle(Tessellator tessellator, int x1, int y1, int x2, int y2, int color)
+ {
+ tessellator.startDrawingQuads();
+ tessellator.setColorRGBA(color >>> 24 & 255, color >>> 16 & 255, color >>> 8 & 255, color & 255);
+ tessellator.addVertex(x2, y1, 300.0D);
+ tessellator.addVertex(x1, y1, 300.0D);
+ tessellator.addVertex(x1, y2, 300.0D);
+ tessellator.addVertex(x2, y2, 300.0D);
+ tessellator.draw();
+ }
+
+ public void drawThermometerTemperature(long temperature, boolean show)
+ {
+ updateScreenSize();
+ long key = 0;
+ int frame=0;
+ if(frameTooltipMap.containsKey(key))
+ {
+ frame=frameTooltipMap.get(key);
+ }
+ if(frame<=0)
+ {
+ updatePlayerView();
+ }
+ boolean showString=true;
+ if(show && frame<=122)
+ {
+ frame+=1;
+ frameTooltipMap.put(key, frame);
+ }
+ else
+ {
+ if(frame>0)
+ {
+ frame-=2;
+ frameTooltipMap.put(key, frame);
+ }
+ showString=false;
+ }
+ if(frame>0)
+ {
+ int width=Math.min(frame, 122);
+ int height=Math.min(frame, 48);
+ int xShift = Math.round(displayScaledWidth/100*(lastPlayerYaw - Minecraft.getMinecraft().renderViewEntity.prevRotationYaw));
+ int yShift = Math.round(displayScaledHeight/64*(lastPlayerPitch - Minecraft.getMinecraft().renderViewEntity.prevRotationPitch));
+ int xPos = displayScaledWidth/2+xShift;
+ int yPos = displayScaledHeight/2-48+yShift;
+ GL11.glEnable(GL11.GL_BLEND);
+ GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+ drawTexturedModalRect(xPos,yPos,0,0,width,height);
+ GL11.glDisable(GL11.GL_DEPTH_TEST);
+ if(showString)
+ {
+ Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(temperature+"\u00B0K", xPos+35, yPos+3, 16768125);
+ }
+ GL11.glEnable(GL11.GL_DEPTH_TEST);
+ GL11.glDisable(GL11.GL_BLEND);
+ }
+ }
+
+ public void drawTexturedModalRect(int x1, int y1, int u, int v, int x2, int y2) {
+ float f = 0.00390625F;
+ float f1 = 0.00390625F;
+ Tessellator tessellator = Tessellator.instance;
+ tessellator.startDrawingQuads();
+ tessellator.setColorRGBA_F(1f, 1f, 1f, 0.5f);
+ tessellator.addVertexWithUV(x1 + 0, y1 + y2, 300D, (u + 0) * f, (v + y2) * f1);
+ tessellator.addVertexWithUV(x1 + x2, y1 + y2, 300D, (u + x2) * f, (v + y2) * f1);
+ tessellator.addVertexWithUV(x1 + x2, y1 + 0, 300D, (u + x2) * f, (v + 0) * f1);
+ tessellator.addVertexWithUV(x1 + 0, y1 + 0, 300D, (u + 0) * f, (v + 0) * f1);
+ tessellator.draw();
+ }
+
+
+ public void updateScreenSize()
+ {
+ if(prevDisplayHeight!=Minecraft.getMinecraft().displayHeight || prevDisplayWidth!=Minecraft.getMinecraft().displayWidth)
+ {
+ ScaledResolution var2 = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
+ displayScaledWidth = var2.getScaledWidth();
+ displayScaledHeight = var2.getScaledHeight();
+ scaleFactor=var2.getScaleFactor();
+ guiXPos = (displayScaledWidth - guiContainerWidth)/2;
+ guiYPos = (displayScaledHeight - guiContainerHeight)/2;
+ prevDisplayWidth=Minecraft.getMinecraft().displayWidth;
+ prevDisplayHeight=Minecraft.getMinecraft().displayHeight;
+ }
+ }
+
+ public void updatePlayerView()
+ {
+ lastPlayerYaw = Minecraft.getMinecraft().renderViewEntity.prevRotationYaw;
+ lastPlayerPitch = Minecraft.getMinecraft().renderViewEntity.prevRotationPitch;
+ }
+
+ public void drawKnee(double xPos, double yPos, double zPos, ForgeDirection direction12, ForgeDirection direction22, double radius1, double radius2, IIcon icon)
+ {
+ ForgeDirection direction1=direction12;
+ ForgeDirection direction2=direction22;
+ if(this.swapRenderBoundsX)
+ {
+ if(direction1.offsetX!=0)
+ {
+ direction1=direction1.getOpposite();
+ }
+ if(direction2.offsetX!=0)
+ {
+ direction2=direction2.getOpposite();
+ }
+ }
+ if(this.swapRenderBoundsY)
+ {
+ if(direction1.offsetY!=0)
+ {
+ direction1=direction1.getOpposite();
+ }
+ if(direction2.offsetY!=0)
+ {
+ direction2=direction2.getOpposite();
+ }
+ }
+ if(this.swapRenderBoundsZ)
+ {
+ if(direction1.offsetZ!=0)
+ {
+ direction1=direction1.getOpposite();
+ }
+ if(direction2.offsetZ!=0)
+ {
+ direction2=direction2.getOpposite();
+ }
+ }
+ double[][] outervertexes1 = new double[8][3];
+ double[][] innervertexes1 = new double[8][3];
+ double[][] outervertexes2 = new double[8][3];
+ double[][] innervertexes2 = new double[8][3];
+ int i=0;
+ for(i=0;i<8;i++)
+ {
+ if(direction1.equals(direction2))
+ {
+ switch(direction1)
+ {
+ case UP:
+ outervertexes1[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes1[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ break;
+ case DOWN:
+ outervertexes1[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes1[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i)};
+ outervertexes2[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ break;
+ case SOUTH:
+ outervertexes1[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ innervertexes1[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0d};
+ innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0d};
+ break;
+ case NORTH:
+ outervertexes1[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ innervertexes1[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ outervertexes2[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i), 0d};
+ innervertexes2[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0d};
+ break;
+ case EAST:
+ outervertexes1[i] = new double[] {0d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i)};
+ innervertexes1[i] = new double[] {0d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i)};
+ outervertexes2[i] = new double[] {1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {1d, 0.5F+0.5F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i)};
+ break;
+ case WEST:
+ outervertexes1[i] = new double[] {0d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i)};
+ innervertexes1[i] = new double[] {0d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i)};
+ outervertexes2[i] = new double[] {1d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {1d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i)};
+ break;
+ default:
+ outervertexes1[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes1[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ break;
+ }
+
+ }
+ else
+ {
+ switch(direction1)
+ {
+ case UP:
+ outervertexes1[i] = new double[] {0.5F+0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i+Math.PI), 1d, 0.5F-0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i+Math.PI)};
+ innervertexes1[i] = new double[] {0.5F+radius1*radius2*0.25F*(float)Math.cos(2D*Math.PI/8D*i+Math.PI), 1d, 0.5F-0.25F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i+Math.PI)};
+ break;
+ case DOWN:
+ outervertexes1[i] = new double[] {0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes1[i] = new double[] {0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0d, 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ break;
+ case SOUTH:
+ outervertexes1[i] = new double[] {0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ innervertexes1[i] = new double[] {0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ break;
+ case NORTH:
+ outervertexes1[i] = new double[] {0.5F+0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ innervertexes1[i] = new double[] {0.5F+radius1*radius2*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius1*radius2*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ break;
+ case EAST:
+ outervertexes1[i] = new double[] {0d, 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i)};
+ innervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i)};
+ break;
+ case WEST:
+ outervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.52F*radius2*(float)Math.cos(2D*Math.PI/8D*i)};
+ innervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i)};
+ break;
+ default:
+ outervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius2*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+0.52F*radius2*(float)Math.cos(2D*Math.PI/8D*i)};
+ innervertexes1[i] = new double[] {0d, 0.5F+0.25F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0.5F+radius1*0.25F*radius2*(float)Math.cos(2D*Math.PI/8D*i)};
+ break;
+ }
+
+ switch(direction2)
+ {
+ case UP:
+ outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ break;
+ case DOWN:
+ outervertexes2[i] = new double[] {0.5F+0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {0.5F+radius1*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ break;
+ case WEST:
+ outervertexes2[i] = new double[] {1d, 0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F-0.25F*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {1d, 0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F-0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ break;
+ case EAST:
+ outervertexes2[i] = new double[] {0d, 0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {0d, 0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ break;
+ case NORTH:
+ outervertexes2[i] = new double[] {0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 1d-0.5F-0.25F*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ innervertexes2[i] = new double[] {0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 1d-0.5F-0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 1d};
+ break;
+ case SOUTH:
+ outervertexes2[i] = new double[] {0.5F+0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*(float)Math.sin(2D*Math.PI/8D*i), 0d};
+ innervertexes2[i] = new double[] {0.5F+radius1*0.25F*(float)Math.cos(2D*Math.PI/8D*i), 0.5F+0.25F*radius1*(float)Math.sin(2D*Math.PI/8D*i), 0d};
+ break;
+ default:
+ outervertexes2[i] = new double[] {0.5F+0.5F*radius2*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*(float)Math.sin(2D*Math.PI/8D*i)};
+ innervertexes2[i] = new double[] {0.5F+radius1*radius2*0.5F*(float)Math.cos(2D*Math.PI/8D*i), 1d, 0.5F+0.5F*radius2*radius1*(float)Math.sin(2D*Math.PI/8D*i)};
+ break;
+ }
+
+ }
+ }
+ double[][][] quadList = new double[32][4][3];
+ for(i=0;i<32;i++)
+ {
+ if(i<7)
+ {
+ quadList[i]=new double[][] {outervertexes1[i],outervertexes1[i+1],innervertexes1[i+1],innervertexes1[i]};
+ }
+ else if(i==7)
+ {
+ quadList[i]=new double[][] {outervertexes1[i],outervertexes1[0],innervertexes1[0],innervertexes1[i]};
+ }
+ else if(i<15)
+ {
+ quadList[i]=new double[][] {innervertexes2[i-8],innervertexes2[i+1-8],outervertexes2[i+1-8],outervertexes2[i-8]};
+ }
+ else if(i==15)
+ {
+ quadList[i]=new double[][] {innervertexes2[i-8],innervertexes2[0],outervertexes2[0],outervertexes2[i-8]};
+ }
+ else if(i<23)
+ {
+ quadList[i]=new double[][] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[i-16+1],outervertexes1[i-16+1]};
+ }
+ else if(i==23)
+ {
+ quadList[i]=new double[][] {outervertexes1[i-16],outervertexes2[i-16],outervertexes2[0],outervertexes1[0]};
+ }
+ else if(i<31)
+ {
+ quadList[i]=new double[][] {innervertexes1[i-24+1],innervertexes2[i-24+1], innervertexes2[i-24], innervertexes1[i-24]};
+ }
+ else if(i==31)
+ {
+ quadList[i]=new double[][] {innervertexes1[0],innervertexes2[0],innervertexes2[i-24],innervertexes1[i-24]};
+ }
+ }
+ for(i=0;i<32;i++)
+ {
+ this.drawSquare(xPos, yPos, zPos, quadList[i], icon);
+ }
+
+
+ }
+ public void drawPipe(double xPos, double yPos, double zPos, ForgeDirection direction1, double radius1, double radius2, IIcon icon)
+ {
+ this.drawKnee(xPos, yPos, zPos, direction1, direction1, radius1, radius2, icon);
+ }
+
+ public void drawSquare(double xPos, double yPos, double zPos, double[][] vertexes, IIcon icon)
+ {
+ double u1 = icon.getInterpolatedU(this.renderMinZ * 16.0D);
+ double u2 = icon.getInterpolatedU(this.renderMaxZ * 16.0D);
+ double v2 = icon.getInterpolatedV(16.0D - this.renderMaxY * 16.0D);
+ double v1 = icon.getInterpolatedV(16.0D - this.renderMinY * 16.0D);
+ if (this.renderMinZ < 0.0D || this.renderMaxZ > 1.0D)
+ {
+ u1 = icon.getMinU();
+ u2 = icon.getMaxU();
+ }
+ if (this.renderMinY < 0.0D || this.renderMaxY > 1.0D)
+ {
+ v2 = icon.getMinV();
+ v1 = icon.getMaxV();
+ }
+ this.drawSquare(xPos, yPos, zPos, u1, u2, v1, v2, vertexes);
+ }
+
+
+ public void drawSquare(double xPos, double yPos, double zPos, double u1, double u2, double v1, double v2, double[][] vertexes)
+ {
+ Tessellator var9 = Tessellator.instance;
+ double[] us = new double[]{u1,u1,u2,u2};
+ double[] vs = new double[]{v1,v2,v2,v1};
+ double xDelta=this.renderMaxX-this.renderMinX;
+ double yDelta=this.renderMaxY-this.renderMinY;
+ double zDelta=this.renderMaxZ-this.renderMinZ;
+ int startFrom=0;
+ int endTo=vertexes.length-1;
+ if(this.renderFromInside)
+ {
+ startFrom=vertexes.length-1;
+ endTo=0;
+ }
+ for(int i=startFrom;(i<=endTo&&!this.renderFromInside)||(i>=endTo&&this.renderFromInside);i+=(endTo-startFrom)/3)
+ {
+ double vX=vertexes[i][0]*xDelta+this.renderMinX;
+ double vY=vertexes[i][1]*yDelta+this.renderMinY;
+ double vZ=vertexes[i][2]*zDelta+this.renderMinZ;
+ double[] vYZ=null;
+ double[] vXZ=null;
+ double[] vXY=null;
+ if(this.rotationX!=0)
+ {
+ vYZ = this.rotateCoordinateByAngle(vY-(this.rotationPointY-8f)*scale, vZ-(this.rotationPointZ+8f)*scale, this.rotationX);
+ vY=vYZ[0]+(this.rotationPointY-8f)*scale;
+ vZ=vYZ[1]+(this.rotationPointZ+8f)*scale;
+ }
+ if(this.rotationY!=0)
+ {
+ vXZ = this.rotateCoordinateByAngle(vX-(this.rotationPointX+8f)*scale, vZ-(this.rotationPointZ+8f)*scale, this.rotationY);
+ vX=vXZ[0]+(this.rotationPointX+8f)*scale;
+ vZ=vXZ[1]-(this.rotationPointZ+8f)*scale;
+ }
+ if(this.rotationZ!=0)
+ {
+ vXY = this.rotateCoordinateByAngle(vX-(this.rotationPointX+8f)*scale, vY-(this.rotationPointY-8f)*scale, this.rotationZ);
+ vX=vXY[0]+(this.rotationPointX+8f)*scale;
+ vY=vXY[1]+(this.rotationPointY-8f)*scale;
+ if(swappingAxisOrBoundsAffectRotationOnAxisZ())
+ {
+ vY-=(this.renderMaxZ-(this.rotationPointZ+8f))*scale*Math.sin(this.rotationZ);
+ }
+ }
+ if(this.swapXandY)
+ {
+ double var0 = vX;
+ vX=vY;
+ vY=var0;
+ }
+ if(this.swapXandZ)
+ {
+ double var0 = vX;
+ vX=vZ;
+ vZ=var0;
+ }
+ if(this.swapYandZ)
+ {
+ double var0 = vY;
+ vY=vZ;
+ vZ=var0;
+ }
+ var9.addVertexWithUV(xPos+vX, yPos+vY, zPos+vZ, us[i], vs[i]);
+ }
+ }
+
+
+ public void setRenderBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
+ {
+ if(this.swapRenderBoundsX)
+ {
+ this.renderMinX = 1-maxX;
+ this.renderMaxX = 1-minX;
+ }
+ else
+ {
+ this.renderMinX = minX;
+ this.renderMaxX = maxX;
+ }
+ if(this.swapRenderBoundsY)
+ {
+ this.renderMinY = 1-maxY;
+ this.renderMaxY = 1-minY;
+ }
+ else
+ {
+ this.renderMinY = minY;
+ this.renderMaxY = maxY;
+ }
+ if(this.swapRenderBoundsZ)
+ {
+ this.renderMinZ = 1-maxZ;
+ this.renderMaxZ = 1-minZ;
+ }
+ else
+ {
+ this.renderMinZ = minZ;
+ this.renderMaxZ = maxZ;
+ }
+ }
+
+ public void setRotationPoint(float rX, float rY, float rZ)
+ {
+ this.rotationPointX=rX;
+ this.rotationPointY=rY;
+ this.rotationPointZ=rZ;
+ }
+
+ public void setPosition(double xPos, double yPos, double zPos)
+ {
+ this.renderPositionX=xPos;
+ this.renderPositionY=yPos;
+ this.renderPositionZ=zPos;
+ }
+
+ public void drawPipe(float fx,float fy,float fz, int xSize,int ySize,int zSize, float radius1, float radius2, ForgeDirection direction, IIcon icon)
+ {
+ this.setRenderBoundsFromModel(fx, fy, fz, xSize, ySize, zSize);
+ this.drawPipe(renderPositionX,renderPositionY, renderPositionZ, direction, radius1, radius2, icon);
+ }
+
+ public void drawKnee(float fx,float fy,float fz, int xSize,int ySize,int zSize, float radius1, float radius2, ForgeDirection direction1, ForgeDirection direction2, IIcon icon)
+ {
+ this.setRenderBoundsFromModel(fx, fy, fz, xSize, ySize, zSize);
+ this.drawKnee(renderPositionX,renderPositionY, renderPositionZ, direction1, direction2, radius1, radius2, icon);
+ }
+
+ public void drawBox(float fx,float fy,float fz, int xSize,int ySize,int zSize, Block block, int meta, RenderBlocks blockRenderer)
+ {
+ this.setRenderBoundsFromModel(fx, fy, fz, xSize, ySize, zSize);
+ blockRenderer.renderStandardBlock(block, (int)this.renderPositionX, (int)this.renderPositionY, (int)this.renderPositionZ);
+ }
+
+ public void setRenderBoundsFromModel(float fx,float fy,float fz, int xSize,int ySize,int zSize)
+ {
+ float boundMinX=(-this.rotationPointX+8f-fx-xSize)*scale;
+ float boundMaxX=(-this.rotationPointX+8f-fx)*scale;
+ float boundMinZ=(-this.rotationPointZ+8f-fz-zSize)*scale;
+ float boundMaxZ=(-this.rotationPointZ+8f-fz)*scale;
+ float boundMinY=(this.rotationPointY-8f-fy-ySize)*scale;
+ float boundMaxY=(this.rotationPointY-8f-fy)*scale;
+ this.setRenderBounds(boundMinX, boundMinY, boundMinZ, boundMaxX, boundMaxY, boundMaxZ);
+ }
+
+ public double[] rotateCoordinateByAngle(double coord1, double coord2, double angle)
+ {
+ double r = Math.sqrt(coord2*coord2+coord1*coord1);
+ double alpha0=Math.asin(coord2/r);
+ if(coord1<0d)
+ {
+ alpha0=Math.PI-Math.asin(coord2/r);
+ }
+ double alpha2=alpha0+angle;
+ double coord21=Math.sin(alpha2)*r;
+ double coord11=Math.cos(alpha2)*r;
+ return new double[]{coord11,coord21};
+ }
+
+ public void setRotation(float rotationX1, float rotationY1, float rotationZ1)
+ {
+ if(this.swapRenderBoundsX)
+ {
+ this.rotationX=-rotationX1;
+ }
+ else
+ {
+ this.rotationX=rotationX1;
+ }
+ if(this.swapRenderBoundsY)
+ {
+ this.rotationY=-rotationY1;
+ }
+ else
+ {
+ this.rotationY=rotationY1;
+ }
+ if(swappingAxisOrBoundsAffectRotationOnAxisZ())
+ {
+ this.rotationZ=-rotationZ1;
+ }
+ else
+ {
+ this.rotationZ=rotationZ1;
+ }
+ }
+
+ public void reset()
+ {
+ this.renderFromInside=false;
+ this.swapXandZ=false;
+ this.swapXandY=false;
+ this.swapYandZ=false;
+ this.swapRenderBoundsX=false;
+ this.swapRenderBoundsY=false;
+ this.swapRenderBoundsZ=false;
+ this.setRotation(0f, 0f, 0f);
+ this.setRotationPoint(0f, 0f, 0f);
+ }
+
+ private boolean swappingAxisOrBoundsAffectRotationOnAxisZ()
+ {
+ return (this.swapRenderBoundsZ && !this.swapXandZ && !this.swapYandZ)||
+ (this.swapRenderBoundsX && this.swapXandZ) ||
+ (this.swapRenderBoundsY && this.swapYandZ);
+ }
+
+ public List<String> splitStringByWidth(String string, int stringWidth)
+ {
+ List<String> output = new ArrayList<String>();
+ StringBuffer sb = new StringBuffer();
+ String[] splittedBySpaces = string.split(" ");
+ for(String word:splittedBySpaces)
+ {
+ if(!word.contains("/n") && getStringWidth(sb)+getStringWidth(word)<stringWidth)
+ {
+ sb.append(word);
+ sb.append(" ");
+ }
+ else
+ {
+ output.add(sb.toString());
+ sb.delete(0, sb.length());
+ if(!word.contains("/n"))
+ {
+ sb.append(word);
+ sb.append(" ");
+ }
+ else
+ {
+ sb.append(" ");
+ }
+ }
+ }
+ output.add(sb.toString());
+ return output;
+ }
+
+ public int getStringWidth(StringBuffer sb)
+ {
+ return getStringWidth(sb.toString());
+ }
+
+ public int getStringWidth(String sb)
+ {
+ return Minecraft.getMinecraft().fontRenderer.getStringWidth(sb);
+ }
+
+ @SubscribeEvent
+ public void drawBlockSelectionBox(DrawBlockHighlightEvent event)
+ {
+ if(event.target!=null && event.target.typeOfHit.equals(MovingObjectPosition.MovingObjectType.BLOCK))
+ {
+ WorldClient world = Minecraft.getMinecraft().theWorld;
+ TileEntity te = world.getTileEntity(event.target.blockX, event.target.blockY, event.target.blockZ);
+ if(te!=null)
+ {
+ IHLMod.proxy.renderTESpecialSelectionBox(te, event.player,event.currentItem,event.target,event.partialTicks) ;
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/ihl/utils/IHLUtils.java b/src/main/java/ihl/utils/IHLUtils.java new file mode 100644 index 0000000..0f23f01 --- /dev/null +++ b/src/main/java/ihl/utils/IHLUtils.java @@ -0,0 +1,953 @@ +package ihl.utils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang3.mutable.MutableObject;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import ic2.api.recipe.IRecipeInput;
+import ic2.api.recipe.RecipeInputItemStack;
+import ic2.api.recipe.RecipeInputOreDict;
+import ic2.api.recipe.Recipes;
+import ic2.core.BasicMachineRecipeManager;
+import ic2.core.IC2;
+import ic2.core.block.invslot.InvSlotOutput;
+import ihl.IHLMod;
+import ihl.flexible_cable.IHLCable;
+import ihl.interfaces.IEnergyNetNode;
+import ihl.interfaces.IMultiPowerCableHolder;
+import ihl.interfaces.IWire;
+import ihl.metallurgy.constants.ElectricConductor;
+import ihl.metallurgy.constants.Insulation;
+import ihl.processing.invslots.InvSlotConsumableLiquidIHL;
+import ihl.recipes.IRecipeInputFluid;
+import net.minecraft.block.Block;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
+import net.minecraft.util.Vec3;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraft.world.chunk.NibbleArray;
+import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidTank;
+import net.minecraftforge.oredict.OreDictionary;
+
+public class IHLUtils {
+ private static Map<String, ItemStack> ihlItemStackRegistry = new HashMap<String, ItemStack>();
+ private static final String Digits = "(\\p{Digit}+)";
+ private static final String HexDigits = "(\\p{XDigit}+)";
+ private static final String Exp = "[eE][+-]?" + Digits;
+ private static final String fpRegex = ("[\\x00-\\x20]*" + // Optional
+ // leading
+ // "whitespace"
+ "[+-]?(" + // Optional sign character
+ "NaN|" + // "NaN" string
+ "Infinity|" + // "Infinity" string
+ "(((" + Digits + "(\\.)?(" + Digits + "?)(" + Exp + ")?)|" + "(\\.(" + Digits + ")(" + Exp + ")?)|" + "(("
+ + "(0[xX]" + HexDigits + "(\\.)?)|" + "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" + ")[pP][+-]?"
+ + Digits + "))" + "[fFdD]?))" + "[\\x00-\\x20]*");// Optional
+ // trailing
+ // "whitespace"
+
+ public static void registerLocally(String name, ItemStack stack) {
+ ihlItemStackRegistry.put(name, stack);
+ }
+
+ public static ItemStack getOreDictItemStack(String name) {
+ ItemStack ore = OreDictionary.getOres(name).get(0);
+ if (ore == null)
+ return null;
+ ItemStack orecopy = ore.copy();
+ orecopy.stackSize = 1;
+ return orecopy;
+ }
+
+ public static boolean hasOreDictionaryEntry(String name) {
+ return !OreDictionary.getOres(name).isEmpty();
+ }
+
+ public static Item getOreDictItem(String name) {
+ return OreDictionary.getOres(name).get(0).getItem();
+ }
+
+ public static Block getOreDictBlock(String name) {
+ return Block.getBlockFromItem(OreDictionary.getOres(name).get(0).getItem());
+ }
+
+ public static ItemStack getOreDictItemStackWithSize(String name, int size) {
+ ItemStack ore = OreDictionary.getOres(name).get(0);
+ if (ore == null)
+ return null;
+ ItemStack orecopy = ore.copy();
+ orecopy.stackSize = size;
+ return orecopy;
+ }
+
+ public static String getFirstOreDictName(ItemStack stack) {
+ int[] arrayIDs = OreDictionary.getOreIDs(stack);
+ if (arrayIDs.length > 0) {
+ return OreDictionary.getOreName(arrayIDs[0]);
+ }
+ return "";
+ }
+
+ public static ItemStack getThisModItemStack(String name) {
+ if (ihlItemStackRegistry.get(name) != null) {
+ return ihlItemStackRegistry.get(name).copy();
+ }
+ if (GameRegistry.findItem("ihl", name) != null) {
+ return new ItemStack(GameRegistry.findItem("ihl", name));
+ } else if (GameRegistry.findBlock("ihl", name) == null) {
+ throw new IllegalArgumentException("No such item in item registry: ihl:" + name);
+ } else {
+ return new ItemStack(GameRegistry.findBlock("ihl", name));
+ }
+ }
+
+ public static ItemStack getThisModItemStackWithSize(String name, int i) {
+ if (ihlItemStackRegistry.get(name) != null) {
+ ItemStack stack = ihlItemStackRegistry.get(name).copy();
+ stack.stackSize = i;
+ return stack;
+ }
+ if (GameRegistry.findItem("ihl", name) != null) {
+ return new ItemStack(GameRegistry.findItem("ihl", name), i);
+ } else if (GameRegistry.findBlock("ihl", name) == null) {
+ throw new IllegalArgumentException("No such item in item registry: ihl:" + name);
+ } else {
+ return new ItemStack(GameRegistry.findBlock("ihl", name), i);
+ }
+ }
+
+ public static ItemStack getOtherModItemStackWithDamage(String modname, String name, int damage, int quantity) {
+ if (GameRegistry.findItem(modname, name) != null) {
+ return new ItemStack(GameRegistry.findItem(modname, name), quantity, damage);
+ } else if (GameRegistry.findBlock(modname, name) == null) {
+ return null;
+ } else {
+ return new ItemStack(GameRegistry.findBlock(modname, name), quantity, damage);
+ }
+ }
+
+ public static Item getThisModItem(String name) {
+ if (GameRegistry.findItem("ihl", name) != null) {
+ return GameRegistry.findItem("ihl", name);
+ } else if (GameRegistry.findBlock("ihl", name) == null) {
+ throw new IllegalArgumentException("No such item in item registry: ihl:" + name);
+ } else {
+ return Item.getItemFromBlock(GameRegistry.findBlock("ihl", name));
+ }
+ }
+
+ public static FluidStack getFluidStackWithSize(String name, int i) {
+ if (FluidRegistry.isFluidRegistered(name)) {
+ return FluidRegistry.getFluidStack(name, i);
+ } else {
+ throw new IllegalArgumentException("No such fluid: " + name);
+ }
+ }
+
+ public static Block getThisModBlock(String name) {
+ if (GameRegistry.findBlock("ihl", name) == null) {
+ throw new IllegalArgumentException("No such block in item registry: ihl:" + name);
+ } else {
+ return GameRegistry.findBlock("ihl", name);
+ }
+ }
+
+ public static ItemStack getThisModItemStackWithDamage(String name, int value) {
+ ItemStack stack = getThisModItemStack(name);
+ stack.setItemDamage(value);
+ return stack;
+ }
+
+ public static boolean adjustWireLength(ItemStack stack, int adjustBy) {
+ int length = getWireLength(stack);
+ if (length <= 0) {
+ return true;
+ } else {
+ int newLength = Math.max(length + adjustBy, 0);
+ stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTag(), newLength);
+ stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTagSecondary(), newLength);
+ if (newLength == 0) {
+ return true;
+ }
+ return false;
+ }
+ }
+
+ public static int getWireLength(ItemStack itemStack) {
+ return itemStack.stackTagCompound.getInteger(((IWire) itemStack.getItem()).getTag());
+ }
+
+ public static ItemStack getThisModWireItemStackWithLength(String name, int i) {
+ if (getThisModItemStack(name) != null) {
+ ItemStack stack = getThisModItemStack(name);
+ if (stack.getItem() instanceof IWire) {
+ stack.stackTagCompound = new NBTTagCompound();
+ stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTag(), i);
+ stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTagSecondary(), i);
+ return stack;
+ } else {
+ throw new IllegalArgumentException("ihl:" + name + " is not an instance of IWire.");
+ }
+ } else {
+ throw new IllegalArgumentException("No such item in item registry: ihl:" + name);
+ }
+ }
+
+ public static ItemStack getThisModWireItemStackWithLength(ItemStack stack1, int i) {
+ ItemStack stack = stack1.copy();
+ if (stack1.getItem() instanceof IWire) {
+ stack.stackTagCompound = new NBTTagCompound();
+ stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTag(), i);
+ stack.stackTagCompound.setInteger(((IWire) stack.getItem()).getTagSecondary(), i);
+ return stack;
+ } else {
+ throw new IllegalArgumentException(stack1.getUnlocalizedName() + " is not an instance of IWire.");
+ }
+ }
+
+ public static boolean isItemsHaveSameOreDictionaryEntry(ItemStack is, ItemStack is1) {
+ int[] odids1 = OreDictionary.getOreIDs(is);
+ int[] odids2 = OreDictionary.getOreIDs(is1);
+ if (odids1 != null && odids1.length > 0 && odids2 != null && odids2.length > 0) {
+ for (int i1 = 0; i1 < odids1.length; i1++) {
+ for (int i2 = 0; i2 < odids2.length; i2++) {
+ if (!OreDictionary.getOreName(odids1[i1]).contains("Any") && odids1[i1] == odids2[i2]) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static List<ItemStack> getEntryListForOre(String name) {
+ ArrayList<ItemStack> outputList = new ArrayList<ItemStack>();
+ ArrayList<ItemStack> oreList = OreDictionary.getOres(name);
+ Iterator<ItemStack> oreListIterator = oreList.iterator();
+ while (oreListIterator.hasNext()) {
+ outputList.add(oreListIterator.next().copy());
+ }
+ return outputList;
+ }
+
+ public static ItemStack getItemStackIfExist(String name) {
+ if (hasOreDictionaryEntry(name)) {
+ return getOreDictItemStack(name);
+ } else {
+ if (ihlItemStackRegistry.get(name) != null) {
+ return ihlItemStackRegistry.get(name).copy();
+ }
+ if (GameRegistry.findItem("ihl", name) != null) {
+ return new ItemStack(GameRegistry.findItem("ihl", name));
+ } else if (GameRegistry.findBlock("ihl", name) == null) {
+ return null;
+ } else {
+ return new ItemStack(GameRegistry.findBlock("ihl", name));
+ }
+ }
+ }
+
+ public static FluidStack getFluidStackIfExist(String string, int meltingFluidAmount) {
+ if (FluidRegistry.isFluidRegistered(string)) {
+ return getFluidStackWithSize(string, meltingFluidAmount);
+ }
+ return null;
+ }
+
+ public static boolean addItemStackToInventory(EntityPlayer player, ItemStack stack) {
+ ItemStack[] inv = player.inventory.mainInventory;
+ for (int i = 0; i <= 35; i++) {
+ if (inv[i] != null) {
+ if (inv[i].getItem() == stack.getItem()) {
+ if (inv[i].getItemDamage() == stack.getItemDamage()
+ && inv[i].stackSize < inv[i].getMaxStackSize()) {
+ inv[i].stackSize += stack.stackSize;
+ if (inv[i].stackSize > inv[i].getMaxStackSize()) {
+ stack.stackSize = inv[i].stackSize - inv[i].getMaxStackSize();
+ } else {
+ return true;
+ }
+ }
+ }
+ } else {
+ inv[i] = stack;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static FluidStack getFluidStackWithSizeChemicallyPure(String name, int amount) {
+ FluidStack fstack = getFluidStackWithSize(name, amount);
+ fstack.tag = new NBTTagCompound();
+ fstack.tag.setBoolean("chemicallyPure", true);
+ return fstack;
+ }
+
+ public static void removeItemStackFromOreDictionaryEntry(String orename, ItemStack itemStack) {
+ ArrayList<ItemStack> orelist = OreDictionary.getOres(orename);
+ Iterator<ItemStack> oreListIterator = orelist.iterator();
+ ItemStack odstack = null;
+ while (oreListIterator.hasNext()) {
+ odstack = oreListIterator.next();
+ if (odstack.getItem() == itemStack.getItem()) {
+ break;
+ } else {
+ odstack = null;
+ }
+ }
+ if (odstack != null) {
+ orelist.remove(odstack);
+ IHLMod.log.debug("Stack " + odstack.getDisplayName() + " (" + odstack.toString() + ")"
+ + " removed from ore entry '" + orename + "'");
+ }
+ }
+
+ public static void addIC2MaceratorRecipe(String input, ItemStack output) {
+ if (Recipes.macerator.getOutputFor(getOreDictItemStack(input), false) == null) {
+ ((BasicMachineRecipeManager) Recipes.macerator).addRecipe(new RecipeInputOreDict(input),
+ new NBTTagCompound(), true, output);
+ } else {
+ // IHLMod.log.info("IC2 macerator recipe for "+input+" already
+ // exist. Skipped.");
+ }
+ }
+
+ public static void addIC2MaceratorRecipe(String input, int stacksize, ItemStack output) {
+ if (Recipes.macerator.getOutputFor(getOreDictItemStackWithSize(input, stacksize), false) == null) {
+ ((BasicMachineRecipeManager) Recipes.macerator).addRecipe(new RecipeInputOreDict(input, stacksize),
+ new NBTTagCompound(), true, output);
+ } else {
+ // IHLMod.log.info("IC2 macerator recipe for "+input+" already
+ // exist. Skipped.");
+ }
+ }
+
+ public static void addIC2MaceratorRecipe(ItemStack input, ItemStack output) {
+ if (Recipes.macerator.getOutputFor(input, false) == null) {
+ NBTTagCompound tag = new NBTTagCompound();
+ Recipes.macerator.addRecipe(new RecipeInputItemStack(input), tag, output);
+ } else {
+ // IHLMod.log.info("IC2 macerator recipe for
+ // "+input.getDisplayName()+" already exist. Skipped.");
+ }
+ }
+
+ public static void addIC2RollingRecipe(ItemStack input, ItemStack output) {
+ if (Recipes.metalformerRolling.getOutputFor(input, false) == null) {
+ NBTTagCompound tag = new NBTTagCompound();
+ Recipes.metalformerRolling.addRecipe(new RecipeInputItemStack(input), tag, output);
+ } else {
+ // IHLMod.log.info("IC2 metal former (rolling) recipe for
+ // "+input.getDisplayName()+" already exist. Skipped.");
+ }
+ }
+
+ public static void addIC2RollingRecipe(String input, ItemStack output) {
+ if (Recipes.metalformerRolling.getOutputFor(getThisModItemStack(input), false) == null) {
+ NBTTagCompound tag = new NBTTagCompound();
+ Recipes.metalformerRolling.addRecipe(new RecipeInputOreDict(input), tag, output);
+ } else {
+ // IHLMod.log.info("IC2 metal former (rolling) recipe for "+input+"
+ // already exist. Skipped.");
+ }
+ }
+
+ public static void addIC2ExtrudingRecipe(ItemStack input, ItemStack output) {
+ if (Recipes.metalformerExtruding.getOutputFor(input, false) == null) {
+ NBTTagCompound tag = new NBTTagCompound();
+ Recipes.metalformerExtruding.addRecipe(new RecipeInputItemStack(input), tag, output);
+ } else {
+ // IHLMod.log.info("IC2 metal former (rolling) recipe for "+input+"
+ // already exist. Skipped.");
+ }
+ }
+
+ public static void addIC2CentrifugeRecipe(String input, ItemStack output, ItemStack output2) {
+ if (Recipes.centrifuge.getOutputFor(getOreDictItemStack(input), false) == null) {
+ NBTTagCompound tag = new NBTTagCompound();
+ tag.setInteger("minHeat", 2000);
+ Recipes.centrifuge.addRecipe(new RecipeInputOreDict(input), tag, new ItemStack[] { output, output2 });
+ } else {
+ // IHLMod.log.info("IC2 centrifuge recipe for "+input+" already
+ // exist. Skipped.");
+ }
+ }
+
+ public static void damageItemViaNBTTag(ItemStack stack, int amount) {
+ NBTTagCompound gtTagCompound;
+ if (stack.stackTagCompound.hasKey("GT.ToolStats")) {
+ gtTagCompound = stack.stackTagCompound.getCompoundTag("GT.ToolStats");
+ } else {
+ stack.stackSize--;
+ return;
+ }
+ int damage = 0;
+ int maxDamage = 0;
+ if (gtTagCompound.hasKey("MaxDamage")) {
+ maxDamage = gtTagCompound.getInteger("MaxDamage");
+ } else {
+ stack.stackSize--;
+ return;
+ }
+
+ if (gtTagCompound.hasKey("Damage")) {
+ damage = gtTagCompound.getInteger("Damage");
+ }
+ if (damage < maxDamage - amount) {
+ damage += amount;
+ gtTagCompound.setInteger("Damage", damage);
+ gtTagCompound.setInteger("MaxDamage", maxDamage);
+ stack.stackTagCompound.setTag("GT.ToolStats", gtTagCompound);
+ } else {
+ stack.stackSize--;
+ }
+ }
+
+ public static int getDamageValueViaNBTTag(ItemStack stack) {
+ NBTTagCompound gtTagCompound = null;
+ if (stack != null && stack.stackTagCompound != null && stack.stackTagCompound.hasKey("GT.ToolStats")) {
+ gtTagCompound = stack.stackTagCompound.getCompoundTag("GT.ToolStats");
+ } else {
+ return 0;
+ }
+ if (gtTagCompound != null && gtTagCompound.hasKey("Damage")) {
+ return gtTagCompound.getInteger("Damage");
+ } else {
+ return 0;
+ }
+ }
+
+ public static int getMaxDamageValueViaNBTTag(ItemStack stack) {
+ NBTTagCompound gtTagCompound = null;
+ if (stack != null && stack.stackTagCompound != null && stack.stackTagCompound.hasKey("GT.ToolStats")) {
+ gtTagCompound = stack.stackTagCompound.getCompoundTag("GT.ToolStats");
+ } else {
+ return 0;
+ }
+ if (gtTagCompound != null && gtTagCompound.hasKey("MaxDamage")) {
+ return gtTagCompound.getInteger("MaxDamage");
+ } else {
+ return 0;
+ }
+ }
+
+ public static boolean isItemStacksIsEqual(ItemStack stack1, ItemStack stack2, boolean useOreDictionary) {
+ if(stack2==null && stack1==null){
+ return true;
+ }
+ else if(stack2==null || stack1==null){
+ return false;
+ }
+ if (useOreDictionary && isItemsHaveSameOreDictionaryEntry(stack1, stack2)) {
+ return true;
+ } else {
+ if (stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE
+ || stack2.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
+ return stack1.getItem() == stack2.getItem();
+ } else {
+ return stack1.getItem() == stack2.getItem() && stack1.getItemDamage() == stack2.getItemDamage();
+ }
+ }
+ }
+
+ public static boolean isItemStacksIsEqual(ItemStack stack1, String stack2name, boolean useOreDictionary) {
+ return isItemStacksIsEqual(stack1, getThisModItemStack(stack2name), useOreDictionary);
+ }
+
+ public static boolean isIRecipeInputMatchesWithAmount(IRecipeInput input, ItemStack stack) {
+ if (input.matches(stack)) {
+ if (stack.getItem() instanceof IWire) {
+ return getWireLength(stack) >= input.getAmount();
+ } else {
+ return stack.stackSize >= input.getAmount();
+ }
+ }
+ return false;
+ }
+
+ public static boolean reduceItemStackAmountUsingIRecipeInput(IRecipeInput input, ItemStack stack, int multiplier) {
+ if (stack.getItem() instanceof IWire) {
+ return adjustWireLength(stack, -input.getAmount()*multiplier);
+ } else {
+ stack.stackSize -= input.getAmount()*multiplier;
+ return stack.stackSize <= 0;
+ }
+ }
+
+ public static String getFirstOreDictNameExcludingTagAny(ItemStack stack) {
+ int[] arrayIDs = OreDictionary.getOreIDs(stack);
+ for (int i = 0; i < arrayIDs.length; i++) {
+ if (!OreDictionary.getOreName(arrayIDs[i]).contains("Any")) {
+ return OreDictionary.getOreName(arrayIDs[i]);
+ }
+ }
+ return "";
+ }
+
+ public static void handleFluidSlotsBehaviour(InvSlotConsumableLiquidIHL fillInputSlot,
+ InvSlotConsumableLiquidIHL drainInputSlot, InvSlotOutput emptyFluidItemsSlot, IFluidTank fluidTank) {
+ MutableObject<ItemStack> output;
+ if (drainInputSlot != null && !drainInputSlot.isEmpty()) {
+ output = new MutableObject<ItemStack>();
+ if (fluidTank
+ .fill(drainInputSlot.drain(null, fluidTank.getCapacity() - fluidTank.getFluidAmount(), output,
+ true), false) > 0
+ && (output.getValue() == null || emptyFluidItemsSlot.canAdd(output.getValue()))) {
+ fluidTank.fill(
+ drainInputSlot.drain(null, fluidTank.getCapacity() - fluidTank.getFluidAmount(), output, false),
+ true);
+ if (output.getValue() != null) {
+ emptyFluidItemsSlot.add(output.getValue());
+ }
+ }
+ }
+ if (fillInputSlot != null && !fillInputSlot.isEmpty()) {
+ output = new MutableObject<ItemStack>();
+ if (fillInputSlot.transferFromTank(fluidTank, output, true)
+ && (output.getValue() == null || emptyFluidItemsSlot.canAdd(output.getValue()))) {
+ fillInputSlot.transferFromTank(fluidTank, output, false);
+ if (output.getValue() != null) {
+ emptyFluidItemsSlot.add(output.getValue());
+ }
+ }
+ }
+ }
+
+ public static double[] tracePlayerView(EntityLivingBase player) {
+ float f1 = player.rotationPitch;
+ float f2 = player.rotationYaw;
+ double x = player.posX;
+ double y = player.posY;
+ double z = player.posZ;
+ if (IC2.platform.isSimulating()) {
+ y += player.getEyeHeight();
+ }
+ float f3 = MathHelper.cos(-f2 * 0.01745329F - (float) Math.PI);
+ float f4 = MathHelper.sin(-f2 * 0.01745329F - (float) Math.PI);
+ float f5 = -MathHelper.cos(-f1 * 0.01745329F);
+ float f6 = MathHelper.sin(-f1 * 0.01745329F);
+ float f7 = f4 * f5;
+ float f9 = f3 * f5;
+ double d3 = 1.0D;
+ return new double[] { x + f7 * d3, y + f6 * d3, z + f9 * d3 };
+ }
+
+ public static MovingObjectPosition returnMOPFromPlayer(EntityPlayer entityplayer, World world) {
+ float f1 = entityplayer.rotationPitch;
+ float f2 = entityplayer.rotationYaw;
+ double x = entityplayer.posX;
+ double y = entityplayer.posY + entityplayer.getEyeHeight();
+
+ if (world.isRemote) {
+ y -= entityplayer.getDefaultEyeHeight();
+ }
+
+ double z = entityplayer.posZ;
+ Vec3 vec3d = Vec3.createVectorHelper(x, y, z);
+ float f3 = MathHelper.cos(-f2 * 0.01745329F - (float) Math.PI);
+ float f4 = MathHelper.sin(-f2 * 0.01745329F - (float) Math.PI);
+ float f5 = -MathHelper.cos(-f1 * 0.01745329F);
+ float f6 = MathHelper.sin(-f1 * 0.01745329F);
+ float f7 = f4 * f5;
+ float f9 = f3 * f5;
+ double d3 = 5.0D;
+ Vec3 vec3d1 = vec3d.addVector(f7 * d3, f6 * d3, f9 * d3);
+ MovingObjectPosition movingobjectposition = world.rayTraceBlocks(vec3d, vec3d1, true);
+
+ if (movingobjectposition == null) {
+ return null;
+ }
+
+ if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
+ return movingobjectposition;
+ }
+ return null;
+ }
+
+ public static short getFacingFromPlayerView(EntityLivingBase player, boolean ignoreSneaking) {
+ int var6 = MathHelper.floor_double(player.rotationPitch * 4.0F / 360.0F + 0.5D) & 3;
+ int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
+ {
+ if (var6 == 1) {
+ return 1;
+ } else if (var6 == 3) {
+ return 0;
+ } else {
+ if (player.isSneaking() && !ignoreSneaking) {
+ switch (var7) {
+ case 0:
+ return 3;
+ case 1:
+ return 4;
+ case 2:
+ return 2;
+ case 3:
+ return 5;
+ default:
+ break;
+ }
+ } else {
+ switch (var7) {
+ case 0:
+ return 2;
+ case 1:
+ return 5;
+ case 2:
+ return 3;
+ case 3:
+ return 4;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ return 3;
+ }
+
+ public static int getChainID(ItemStack itemStack) {
+ if (itemStack != null && itemStack.stackTagCompound != null && itemStack.stackTagCompound.hasKey("chainUID")) {
+ return itemStack.stackTagCompound.getInteger("chainUID");
+ }
+ return -1;
+ }
+
+ public static List<ItemStack> convertRecipeInputToItemStackList(List<IRecipeInput> input) {
+ Iterator<IRecipeInput> irii = input.iterator();
+ List<ItemStack> output = new ArrayList<ItemStack>();
+ while (irii.hasNext()) {
+ IRecipeInput iri = irii.next();
+ ItemStack stack = iri.getInputs().get(0);
+ stack.stackSize = iri.getAmount();
+ output.add(stack);
+ }
+ return output;
+ }
+
+ public static List<FluidStack> convertRecipeInputToFluidStackList(List<IRecipeInputFluid> input) {
+ Iterator<IRecipeInputFluid> irii = input.iterator();
+ List<FluidStack> output = new ArrayList<FluidStack>();
+ while (irii.hasNext()) {
+ IRecipeInputFluid iri = irii.next();
+ FluidStack stack = iri.getInputs().get(0);
+ stack.amount = iri.getAmount();
+ output.add(stack);
+ }
+ return output;
+ }
+
+ public static String trim(String str) {
+ int len = str.length();
+ int start;
+ char c;
+ for (start = 0; start < len; ++start) {
+ c = str.charAt(start);
+ if (c > 32 && c != 65279) {
+ break;
+ }
+ }
+ int end;
+ for (end = len - 1; end >= start; --end) {
+ c = str.charAt(end);
+ if (c > 32 && c != 65279) {
+ break;
+ }
+ }
+ return start <= 0 && end >= len - 1 ? str : str.substring(start, end + 1);
+ }
+
+ public static int getAmountOf(ItemStack is) {
+ if (is.getItem() instanceof IWire) {
+ return getWireLength(is);
+ } else {
+ return is.stackSize;
+ }
+ }
+
+ public static ItemStack getWireItemStackCopyWithLengthMultiplied(ItemStack stack, int multiplier) {
+ ItemStack out = stack.copy();
+ adjustWireLength(out, getWireLength(stack) * (multiplier - 1));
+ return out;
+ }
+
+ public static ItemStack getUninsulatedWire(String material, int length, int transverseSection) {
+ ItemStack is = getThisModItemStack("copperWire");
+ is.stackTagCompound = new NBTTagCompound();
+ is.stackTagCompound.setBoolean("firstConnection", false);
+ is.stackTagCompound.setInteger("fullLength", length);
+ is.stackTagCompound.setInteger("length", length);
+ is.stackTagCompound.setString("material", material);
+ is.stackTagCompound.setInteger("transverseSection", transverseSection);
+ return is;
+ }
+
+ public static ItemStack getInsulatedWire(String material, int length, int transverseSection,
+ String insulationMaterial, int insulationThickness) {
+ ItemStack is = getUninsulatedWire(material, length, transverseSection);
+ is.stackTagCompound.setString("insulationMaterial", insulationMaterial);
+ is.stackTagCompound.setInteger("insulationThickness", insulationThickness);
+ is.stackTagCompound.setInteger("maxVoltage", getInsulationMaxVoltage(insulationMaterial, insulationThickness));
+ return is;
+ }
+
+ public static long getResistance(NBTTagCompound cable) {
+ String material = cable.getString("material");
+ int transverseSection = cable.getInteger("transverseSection");
+ return ElectricConductor.getResistivity(material) * 100L / transverseSection;
+ }
+
+ public static int getInsulationMaxVoltage(String insulationMaterial, int insulationThickness) {
+ return Math.min(Insulation.getMaxVoltagePermm(insulationMaterial) * insulationThickness / 10,
+ Insulation.getMaxVoltageCap(insulationMaterial));
+ }
+
+ public static ItemStack getItemStackWithTag(String unLocalizedName, String tag, int tagValue) {
+ ItemStack stack = IHLUtils.getThisModItemStack(unLocalizedName);
+ if (stack.stackTagCompound == null) {
+ stack.stackTagCompound = new NBTTagCompound();
+ }
+ stack.stackTagCompound.setInteger(tag, tagValue);
+ return stack;
+ }
+
+ public static boolean isSegmentInsideAABB(AxisAlignedBB collisionBox, double posX, double posY, double posZ,
+ double posX2, double posY2, double posZ2) {
+ if (isInsideofBoundingBox(collisionBox, (float) posX, (float) posY, (float) posZ)
+ || isInsideofBoundingBox(collisionBox, (float) posX2, (float) posY2, (float) posZ2)) {
+ return true;
+ } else {
+ double minX = Math.min(posX, posX2);
+ double maxX = Math.max(posX, posX2);
+ double minY = Math.min(posY, posY2);
+ double maxY = Math.max(posY, posY2);
+ double minZ = Math.min(posZ, posZ2);
+ double maxZ = Math.max(posZ, posZ2);
+ return !(maxX < collisionBox.minX || minX > collisionBox.maxX || maxY < collisionBox.minY
+ || minY > collisionBox.maxY || maxZ < collisionBox.minZ || minZ > collisionBox.maxZ);
+ }
+ }
+
+ public static boolean isInsideofBoundingBox(AxisAlignedBB bb, float xi, float yi, float zi) {
+ return bb.maxX > xi && bb.minX < xi && bb.maxY > yi && bb.minY < yi && bb.maxZ > zi && bb.minZ < zi;
+ }
+
+ public static boolean isBlockCanBeReplaced(World world, int x, int y, int z) {
+ Block block = world.getBlock(x, y, z);
+ if (block == Blocks.air || block.isAir(world, x, y, z) || block == Blocks.vine || block == Blocks.tallgrass
+ || block == Blocks.deadbush || block == Blocks.snow_layer || block == Blocks.snow) {
+ return true;
+ }
+ return false;
+ }
+
+ public static void removeChains(IEnergyNetNode te, World world) {
+ Set<IHLCable> cableList = te.getCableList();
+ Iterator<IHLCable> cli = cableList.iterator();
+ while (cli.hasNext()) {
+ IHLCable c = cli.next();
+ cli.remove();
+ IHLMod.enet.removeCableEntities(c);
+ ItemStack is = IHLUtils.getThisModItemStack("copperWire");
+ is.stackTagCompound = c.toNBT();
+ double[] pps = te.getPortPos(null);
+ EntityItem eitem = new EntityItem(world, pps[0], pps[1], pps[2], is);
+ world.spawnEntityInWorld(eitem);
+ removeChain(c, null);
+ }
+ if (te.getGridID() != -1) {
+ IHLMod.enet.splitGrids(te.getGridID(), te);
+ }
+ cableList.clear();
+ }
+
+ public static void removeChain(IHLCable cable, IEnergyNetNode excludeNode) {
+ int x = cable.connectorX1;
+ int y = cable.connectorY1;
+ int z = cable.connectorZ1;
+ int t2DimensionId = cable.connectorDimensionId1;
+ short facing2 = cable.connectorFacing1;
+ TileEntity t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x, y, z);
+ IEnergyNetNode te2;
+ if (t2 instanceof IMultiPowerCableHolder) {
+ te2 = ((IMultiPowerCableHolder) t2).getEnergyNetNode(facing2);
+ } else if (t2 instanceof IEnergyNetNode) {
+ te2 = (IEnergyNetNode) t2;
+ } else {
+ return;
+ }
+ if (excludeNode != te2) {
+ te2.remove(cable);
+ }
+ x = cable.connectorX;
+ y = cable.connectorY;
+ z = cable.connectorZ;
+ t2DimensionId = cable.connectorDimensionId;
+ facing2 = cable.connectorFacing;
+ t2 = MinecraftServer.getServer().worldServerForDimension(t2DimensionId).getTileEntity(x, y, z);
+ if (t2 instanceof IMultiPowerCableHolder) {
+ te2 = ((IMultiPowerCableHolder) t2).getEnergyNetNode(facing2);
+ } else if (t2 instanceof IEnergyNetNode) {
+ te2 = (IEnergyNetNode) t2;
+ } else {
+ return;
+ }
+ if (excludeNode != te2) {
+ te2.remove(cable);
+ }
+ }
+
+ public static boolean isPlayerLookingAt(EntityLivingBase player, AxisAlignedBB aabb) {
+ double[] pView = tracePlayerView(player);
+ double x = player.posX;
+ double y = player.posY;
+ double z = player.posZ;
+ if (IC2.platform.isSimulating()) {
+ y += player.getEyeHeight();
+ }
+ if (isLineSegmentInterseptRectangle(x, y, pView[0], pView[1], aabb.minX, aabb.minY, aabb.maxX, aabb.maxY)
+ && isLineSegmentInterseptRectangle(x, z, pView[0], pView[2], aabb.minX, aabb.minZ, aabb.maxX, aabb.maxZ)
+ && isLineSegmentInterseptRectangle(z, y, pView[2], pView[1], aabb.minZ, aabb.minY, aabb.maxZ,
+ aabb.maxY)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isLineSegmentInterseptRectangle(double sx0_1, double sy0_1, double sx1_1, double sy1_1,
+ double rx0_1, double ry0_1, double rx1_1, double ry1_1) {
+ double sx0 = sx0_1;
+ double sy0 = sy0_1;
+ double sx1 = sx1_1;
+ double sy1 = sy1_1;
+ double rx0 = rx0_1;
+ double ry0 = ry0_1;
+ double rx1 = rx1_1;
+ double ry1 = ry1_1;
+ if (sx1_1 < sx0_1) {
+ sx0 = sx1_1;
+ sy0 = sy1_1;
+ sx1 = sx0_1;
+ sy1 = sy0_1;
+ }
+ if (rx1_1 < rx0_1) {
+ rx0 = rx1_1;
+ ry0 = ry1_1;
+ rx1 = rx0_1;
+ ry1 = ry0_1;
+ }
+ double ay = (sy1 - sy0) / (sx1 - sx0);
+ double by = sy1 - ay * sx1;
+
+ double ax = (sx1 - sx0) / (sy1 - sy0);
+ double bx = sx1 - ax * sy1;
+
+ double maxx0 = Math.max(sx0, rx0);
+ double minx1 = Math.min(sx1, rx1);
+ double maxy0 = Math.max(sy0, ry0);
+ double miny1 = Math.min(sy1, ry1);
+ double y0 = ay * maxx0 + by;
+ double y1 = ay * minx1 + by;
+
+ double x0 = ax * maxy0 + bx;
+ double x1 = ax * miny1 + bx;
+ return (ry0 <= y0 && ry1 >= y0) || (ry0 <= y1 && ry1 >= y1) || (rx0 <= x0 && rx1 >= x0)
+ || (rx0 <= x1 && rx1 >= x1);
+ }
+
+ public static float parseFloatSafe(String string, float useSafeValue) {
+ if (Pattern.matches(fpRegex, string))
+ return Float.valueOf(string);
+ else {
+ return useSafeValue;
+ }
+ }
+
+ public static int parseIntSafe(String string, int useSafeValue) {
+ if (Pattern.matches(fpRegex, string))
+ return Integer.valueOf(string);
+ else {
+ return useSafeValue;
+ }
+ }
+
+ public static boolean isBlockRegisteredInOreDictionaryAs(Block block, String string) {
+ Iterator<ItemStack> isoi = OreDictionary.getOres(string).iterator();
+ while (isoi.hasNext()) {
+ if (Block.getBlockFromItem(isoi.next().getItem()) == block) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static void setBlockAndTileEntityRaw(World world, int x, int y, int z, Block block, TileEntity te) {
+ Chunk chunk = world.getChunkProvider().provideChunk(x >> 4, z >> 4);
+ ExtendedBlockStorage[] ebsA = chunk.getBlockStorageArray();
+ ExtendedBlockStorage ebs = ebsA[y >> 4];
+ if (ebs == null) {
+ ebs = new ExtendedBlockStorage(y, true);
+ ebsA[y >> 4] = ebs;
+ }
+ setBlockRaw(ebs, x & 15, y & 15, z & 15, block);
+ te.xCoord = x;
+ te.yCoord = y;
+ te.zCoord = z;
+ te.setWorldObj(world);
+ chunk.addTileEntity(te);
+ }
+
+ public static void setBlockRaw(ExtendedBlockStorage ebs, int x, int y, int z, Block block) {
+ int l = ebs.blockLSBArray[y << 8 | z << 4 | x] & 255;
+
+ if (ebs.blockMSBArray != null) {
+ l |= ebs.blockMSBArray.get(x, y, z) << 8;
+ }
+
+ Block block1 = Block.getBlockById(l);
+
+ if (block1 != Blocks.air) {
+ --ebs.blockRefCount;
+ }
+
+ if (block != Blocks.air) {
+ ++ebs.blockRefCount;
+ }
+
+ int i1 = Block.getIdFromBlock(block);
+ ebs.blockLSBArray[y << 8 | z << 4 | x] = (byte) (i1 & 255);
+
+ if (i1 > 255) {
+ if (ebs.blockMSBArray == null) {
+ ebs.blockMSBArray = new NibbleArray(ebs.blockLSBArray.length, 4);
+ }
+
+ ebs.blockMSBArray.set(x, y, z, (i1 & 3840) >> 8);
+ } else if (ebs.blockMSBArray != null) {
+ ebs.blockMSBArray.set(x, y, z, 0);
+ }
+ }
+
+
+}
diff --git a/src/main/java/ihl/worldgen/IHLWorldGenerator.java b/src/main/java/ihl/worldgen/IHLWorldGenerator.java new file mode 100644 index 0000000..a6f3b6b --- /dev/null +++ b/src/main/java/ihl/worldgen/IHLWorldGenerator.java @@ -0,0 +1,101 @@ +package ihl.worldgen;
+
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+
+import cpw.mods.fml.common.IWorldGenerator;
+import ihl.IHLMod;
+import ihl.utils.IHLUtils;
+import ihl.worldgen.ores.IHLFluid;
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.IChunkProvider;
+
+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, Blocks.obsidian};
+ public static IHLWorldGenerator instance;
+ private final Set<WorldGeneratorBase> generators = new HashSet<WorldGeneratorBase>(8);
+
+ public IHLWorldGenerator()
+ {
+ super();
+ if (IHLMod.config.generateApatiteOre)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreApatite"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateSaltpeterOre)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreSaltpeter"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateGyubnera)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreGyubnera"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateCinnabar)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreCinnabar"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateRocksalt)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreRockSalt"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateLimestone)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreLimestone"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateGypsum)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreGypsum"), replaceableMinerals));
+ }
+ if (IHLMod.config.generatePotassiumFeldspar)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("orePotassiumFeldspar"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateTrona)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreTrona"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateBauxite)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreBauxite"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateChromite)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreChromite"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateMuscovite)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreMica"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateOil)
+ {
+ generators.add(new WorldGeneratorUndergroundLake(IHLFluid.getBlock("oil"), Blocks.obsidian, replaceableForOil));
+ }
+ if (IHLMod.config.generateSaltwater)
+ {
+ generators.add(new WorldGeneratorSurfaceLake(IHLFluid.getBlock("saltwater"), replaceableSand));
+ }
+ if (IHLMod.config.generateDatolite)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreDatolite"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateBischofite)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreBischofite"), replaceableMinerals));
+ }
+ instance=this;
+ }
+
+ @Override
+ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator,
+ IChunkProvider chunkProvider) {
+ for (WorldGeneratorBase generator : generators) {
+ generator.generate(world, chunkX, chunkZ);
+ }
+ }
+}
diff --git a/src/main/java/ihl/worldgen/WorldGeneratorBase.java b/src/main/java/ihl/worldgen/WorldGeneratorBase.java new file mode 100644 index 0000000..dc68135 --- /dev/null +++ b/src/main/java/ihl/worldgen/WorldGeneratorBase.java @@ -0,0 +1,90 @@ +package ihl.worldgen; + +import java.util.HashSet; +import java.util.Random; +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; + +public abstract class WorldGeneratorBase { + private final Random random = new Random(); + protected final Block ore; + protected final Set<Block> replaceableBlocks = new HashSet<Block>(2); + + public WorldGeneratorBase(Block oreIn, Block... replaceableBlocksIn) { + ore = oreIn; + for (Block block : replaceableBlocksIn) { + replaceableBlocks.add(block); + } + } + + public void generate(World world, int chunkX, int chunkZ) { + int[] centralPOI = this.getPOI(world, chunkX, chunkZ, 0, 0); + int[] xz = new int[] { 0, 1, 0, -1, 0 }; + for (int i = 0; i < 4; i++) { + int[] surroundPOI = this.getPOI(world, chunkX + xz[i], chunkZ + xz[i + 1], xz[i], xz[i + 1]); + this.replaceBlocks(world, centralPOI, surroundPOI, chunkX << 4, chunkZ << 4); + } + } + + protected abstract void replaceBlocks(World world, final int[] centralPOI, final int[] surroundPOI, + final int startX, final int startZ); + + protected boolean replace(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 && replaceableBlocks.contains(ebs.getBlockByExtId(absX & 15, absY & 15, absZ & 15))) { + IHLUtils.setBlockRaw(ebs, absX & 15, absY & 15, absZ & 15, block); + return true; + } + return false; + } + + protected boolean replaceAll(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) { + IHLUtils.setBlockRaw(ebs, absX & 15, absY & 15, absZ & 15, block); + return true; + } + 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), + random.nextInt(16) + zOffset * 16 }; + } +} diff --git a/src/main/java/ihl/worldgen/WorldGeneratorSurfaceLake.java b/src/main/java/ihl/worldgen/WorldGeneratorSurfaceLake.java new file mode 100644 index 0000000..11abf5e --- /dev/null +++ b/src/main/java/ihl/worldgen/WorldGeneratorSurfaceLake.java @@ -0,0 +1,42 @@ +package ihl.worldgen; + +import ihl.utils.IHLMathUtils; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + +public class WorldGeneratorSurfaceLake extends WorldGeneratorBase { + + public WorldGeneratorSurfaceLake(Block oreIn, Block[] replaceableBlocksIn) { + super(oreIn, replaceableBlocksIn); + } + + @Override + protected void replaceBlocks(World world, int[] centralPOI, int[] surroundPOI, int startX, int startZ) { + BiomeGenBase biome = world.getBiomeGenForCoords(startX, startZ); + if (biome.temperature < 1.9f || biome.rainfall != 0f) { + return; + } + int x = centralPOI[0], y = centralPOI[1], 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)) { + y2 += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y2); + 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; + } + } + if (surroundPOI[0] == x) { + break; + } + } + } +} diff --git a/src/main/java/ihl/worldgen/WorldGeneratorUndergroundLake.java b/src/main/java/ihl/worldgen/WorldGeneratorUndergroundLake.java new file mode 100644 index 0000000..7abee8e --- /dev/null +++ b/src/main/java/ihl/worldgen/WorldGeneratorUndergroundLake.java @@ -0,0 +1,60 @@ +package ihl.worldgen; + +import ihl.utils.IHLMathUtils; +import ihl.utils.IHLUtils; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; + +public class WorldGeneratorUndergroundLake extends WorldGeneratorBase { + + private final Block clayBlock; + + public WorldGeneratorUndergroundLake(Block oreIn, Block clayIn, Block[] replaceableBlocksIn) { + super(oreIn, replaceableBlocksIn); + clayBlock = clayIn; + } + + @Override + protected void replaceBlocks(World world, int[] centralPOI, int[] surroundPOI, int startX, int startZ) { + 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); + nextZ:for (int iz = z; iz < 16 && iz >= 0; iz += IHLMathUtils.sign(surroundPOI[2] - z)) { + y2 += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y2); + 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 absX = ix + startX; + int absZ = iz + startZ; + int absY = iy; + Chunk chunk = world.getChunkFromBlockCoords(absX, absZ); + ExtendedBlockStorage ebs = chunk.getBlockStorageArray()[absY >> 4]; + if (ebs != null && replaceableBlocks.contains(ebs.getBlockByExtId(absX & 15, absY & 15, absZ & 15))) { + int[] xyz = new int[] { 0, 0, -1, 0, 0, 1, 0, 0 }; + for (int i = 2; i < xyz.length; i++) { + int absX2 = absX + xyz[i - 2]; + int absZ2 = absZ + xyz[i]; + if (!world.getChunkProvider().chunkExists(absX2 >> 4, absZ2 >> 4)) { + continue nextZ; + } + this.replaceAllExceptOre(world, absX2, iy + xyz[i - 1], absZ2, clayBlock); + } + IHLUtils.setBlockRaw(ebs, absX & 15, absY & 15, absZ & 15, ore); + } + } + } + if (surroundPOI[2] == z) { + break; + } + } + if (surroundPOI[0] == x) { + break; + } + } + } + +} diff --git a/src/main/java/ihl/worldgen/WorldGeneratorVein.java b/src/main/java/ihl/worldgen/WorldGeneratorVein.java new file mode 100644 index 0000000..3be74e0 --- /dev/null +++ b/src/main/java/ihl/worldgen/WorldGeneratorVein.java @@ -0,0 +1,26 @@ +package ihl.worldgen; + +import ihl.utils.IHLMathUtils; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public class WorldGeneratorVein extends WorldGeneratorBase { + + public WorldGeneratorVein(Block oreIn, Block[] replaceableBlocksIn) { + super(oreIn, replaceableBlocksIn); + } + + @Override + protected void replaceBlocks(World world, int[] centralPOI, int[] surroundPOI, int startX, int startZ) { + int x = centralPOI[0], y = centralPOI[1], z = centralPOI[2]; + while (x < 16 && x >= 0 && y >= 0 && y < world.getActualHeight() && z >= 0 && z < 16) { + this.replace(world, x + startX, y, z + startZ, ore); + x += IHLMathUtils.sign(surroundPOI[0] - x); + y += IHLMathUtils.sign(surroundPOI[1] - y); + z += IHLMathUtils.sign(surroundPOI[2] - z); + if (IHLMathUtils.sign(surroundPOI[0] - x) == 0 && IHLMathUtils.sign(surroundPOI[1] - y) == 0 + && IHLMathUtils.sign(surroundPOI[2] - z) == 0) + break; + } + } +} diff --git a/src/main/java/ihl/worldgen/ores/BlockOre.java b/src/main/java/ihl/worldgen/ores/BlockOre.java new file mode 100644 index 0000000..00a8bcc --- /dev/null +++ b/src/main/java/ihl/worldgen/ores/BlockOre.java @@ -0,0 +1,137 @@ +package ihl.worldgen.ores;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.World;
+import net.minecraftforge.oredict.OreDictionary;
+
+public class BlockOre extends Block
+{
+ private Type type;
+ private static List<BlockOre> instances = new ArrayList<BlockOre>();
+ private static Map<Type, IIcon> iconMap = new HashMap<Type, IIcon>();
+
+ public BlockOre(Type type1)
+ {
+ super(Material.rock);
+ this.type=type1;
+ this.setCreativeTab(IHLCreativeTab.tab);
+ this.setBlockName(type.unLocalizedName);
+ instances.add(this);
+ this.setHardness(2.0F).setResistance(4.0F);
+ }
+
+ public static void init()
+ {
+ Type[] var1 = Type.values();
+ for(int i=0;i<var1.length;i++)
+ {
+ new BlockOre(var1[i]);
+ }
+ Iterator<BlockOre> ii = instances.iterator();
+ while(ii.hasNext())
+ {
+ BlockOre instance = ii.next();
+ GameRegistry.registerBlock(instance,instance.type.unLocalizedName);
+ OreDictionary.registerOre(instance.type.unLocalizedName, instance);
+ }
+ }
+
+ @Override
+ public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
+ {
+ super.dropBlockAsItemWithChance(world, x, y, z, meta, chance, flag);
+ if(this.type.fortuneAffectsDrops)
+ {
+ this.dropXpOnBlockBreak(world, x, y, z, MathHelper.getRandomIntegerInRange(world.rand, 1, 4));
+ }
+ }
+
+ @Override
+ public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
+ ArrayList<ItemStack> drops = new ArrayList<ItemStack>();
+ int fortmod = world.rand.nextInt(fortune + 2) - 1;
+ if (fortmod < 0 || !type.fortuneAffectsDrops)fortmod = 0;
+ ItemStack drop = null;
+ int amount = 1;
+ amount = (type.amountFrom + (type.amountTo>0?world.rand.nextInt(type.amountTo):0)) * (fortmod + 1);
+ drop = OreDictionary.getOres(type.oreDrop).get(0);
+ if (drop != null && amount > 0)
+ {
+ drop.stackSize=amount;
+ drops.add(drop);
+ }
+ return drops;
+ }
+
+
+ public enum Type
+ {
+ Bischofite("oreBischofite", "dustBischofite",1,2),
+ Datolite("oreDatolite", "dustDatolite",1,2),
+ Stibnite("oreStibnite"),
+ Chromite("oreChromite"),
+ Muscovite("oreMica"),
+ Bauxite("oreBauxite"),
+ Cinnabar("oreCinnabar"),
+ RockSalt("oreRockSalt", "dustRockSalt",1,2),
+ Limestone("oreLimestone", "dustCalcite",1,2),
+ Gypsum("oreGypsum"),
+ Gyubnera("oreGyubnera"),//(Mn,Fe)WO4 Mn:Fe 5/1
+ OreTrona("oreTrona", "dustTrona",1,2),
+ PotassiumFeldspar("orePotassiumFeldspar"),
+ Apatite("oreApatite", "gemApatite",2,5),
+ Saltpeter("oreSaltpeter", "dustSaltpeter",1,2);
+ Type(String unlocalizedName1, String oreDrop1, int amountFrom1, int amountTo1 )
+ {
+ unLocalizedName=unlocalizedName1;
+ oreDrop=oreDrop1;
+ amountFrom=amountFrom1;
+ amountTo=amountTo1;
+ }
+ Type(String unlocalizedName1)
+ {
+ unLocalizedName=unlocalizedName1;
+ oreDrop=unlocalizedName1;
+ amountFrom=1;
+ amountTo=0;
+ fortuneAffectsDrops=false;
+ }
+ String unLocalizedName;
+ String oreDrop;
+ int amountFrom;
+ int amountTo;
+ boolean fortuneAffectsDrops=true;
+ }
+
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister register)
+ {
+ iconMap.put(this.type, register.registerIcon(IHLModInfo.MODID + ":"+this.type.unLocalizedName));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int i, int j)
+ {
+ return iconMap.get(type);
+ }
+}
diff --git a/src/main/java/ihl/worldgen/ores/DebugScannerBlock.java b/src/main/java/ihl/worldgen/ores/DebugScannerBlock.java new file mode 100644 index 0000000..a934f60 --- /dev/null +++ b/src/main/java/ihl/worldgen/ores/DebugScannerBlock.java @@ -0,0 +1,46 @@ +package ihl.worldgen.ores;
+
+import ihl.IHLCreativeTab;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+
+public class DebugScannerBlock extends Block implements ITileEntityProvider{
+
+ public DebugScannerBlock(Material material)
+ {
+ super(material);
+ this.setCreativeTab(IHLCreativeTab.tab);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int var2) {
+ return new DebugScannerTileEntity();
+ }
+
+ @Override
+ public boolean hasTileEntity(int metadata)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer entityPlayer,int i,float pos_x,float pos_y,float pos_z){
+ TileEntity te = world.getTileEntity(x,y,z);
+ if(te instanceof DebugScannerTileEntity)
+ {
+ DebugScannerTileEntity bte = (DebugScannerTileEntity)te;
+ if (bte == null || entityPlayer.isSneaking()) {
+ return false;
+ }
+ else
+ {
+ return bte.getGui(entityPlayer);
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/ihl/worldgen/ores/DebugScannerContainer.java b/src/main/java/ihl/worldgen/ores/DebugScannerContainer.java new file mode 100644 index 0000000..1413ddb --- /dev/null +++ b/src/main/java/ihl/worldgen/ores/DebugScannerContainer.java @@ -0,0 +1,49 @@ +package ihl.worldgen.ores;
+
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.Slot;
+
+public class DebugScannerContainer extends ContainerBase<DebugScannerTileEntity> {
+
+ protected DebugScannerTileEntity tileEntity;
+ public int lastFluidAmount = -1;
+ public int lastFuel = -1;
+ public short lastProgress = -1;
+ public final static int height=256;
+ public final static int width=248;
+
+ public DebugScannerContainer(EntityPlayer entityPlayer, DebugScannerTileEntity tileEntity1){
+ super(tileEntity1);
+ this.tileEntity = tileEntity1;
+ int col,row;
+
+ for (row = 0; row < 3; ++row)
+ {
+ for (col = 0; col < 13; ++col)
+ {
+ int slotnum = col + row * 13 + 9;
+ if(slotnum < entityPlayer.inventory.getSizeInventory()-4)
+ {
+ this.addSlotToContainer(new Slot(entityPlayer.inventory, slotnum, 8 + col * 18, 196 + row * 18));
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ for (col = 0; col < 9; ++col)
+ {
+ this.addSlotToContainer(new Slot(entityPlayer.inventory, col, 80 + col * 18, 232));
+ }
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.itemsSlot, 0, 8, 8));
+ this.addSlotToContainer(new SlotInvSlot(tileEntity1.itemsSlot, 1, 8+18, 8));
+ }
+
+ @Override
+ public boolean canInteractWith(EntityPlayer var1) {
+ return tileEntity.isUseableByPlayer(var1);
+ }
+}
diff --git a/src/main/java/ihl/worldgen/ores/DebugScannerGui.java b/src/main/java/ihl/worldgen/ores/DebugScannerGui.java new file mode 100644 index 0000000..56be263 --- /dev/null +++ b/src/main/java/ihl/worldgen/ores/DebugScannerGui.java @@ -0,0 +1,69 @@ +package ihl.worldgen.ores;
+
+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.gui.inventory.GuiContainer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class DebugScannerGui extends GuiContainer {
+ private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIDebugScanner.png");
+ private DebugScannerContainer container;
+
+ public DebugScannerGui (DebugScannerContainer container1)
+ {
+ super(container1);
+ this.container=container1;
+ this.ySize=DebugScannerContainer.height;
+ this.xSize=DebugScannerContainer.width;
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(int par1, int par2) {
+ List<String> ode = container.tileEntity.oreDictionaryEntries;
+ int verticalOffset = 31;
+ for(int i=0;i<ode.size();i++)
+ {
+ int colorIndex = 16777215;
+ String string = ode.get(i);
+ if(string.startsWith(" "))
+ {
+ colorIndex = 15658734;
+ }
+ if(string.startsWith(" -"))
+ {
+ colorIndex = 14540253;
+ }
+ if(string.startsWith(" "))
+ {
+ colorIndex = 13421772;
+ }
+ if(string.length()>38)
+ {
+ String string1=string.substring(0,38);
+ String string2=string.substring(38);
+ fontRendererObj.drawStringWithShadow(string1, 9, i*10+verticalOffset, colorIndex);
+ verticalOffset+=10;
+ fontRendererObj.drawStringWithShadow(string2, 9, i*10+verticalOffset, colorIndex);
+ }
+ else
+ {
+ fontRendererObj.drawStringWithShadow(string, 9, i*10+verticalOffset, colorIndex);
+ }
+ }
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(float par1, int par2,
+ int par3) {
+ 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);
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/worldgen/ores/DebugScannerTileEntity.java b/src/main/java/ihl/worldgen/ores/DebugScannerTileEntity.java new file mode 100644 index 0000000..b32f3e8 --- /dev/null +++ b/src/main/java/ihl/worldgen/ores/DebugScannerTileEntity.java @@ -0,0 +1,157 @@ +package ihl.worldgen.ores;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import ic2.core.ContainerBase;
+import ic2.core.IC2;
+import ic2.core.IHasGui;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.block.invslot.InvSlot;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidStack;
+import net.minecraftforge.fluids.IFluidContainerItem;
+import net.minecraftforge.oredict.OreDictionary;
+
+public class DebugScannerTileEntity extends TileEntityInventory implements IHasGui {
+ public final InvSlot itemsSlot;
+ private ItemStack lastItem;
+ public List<String> oreDictionaryEntries = new ArrayList<String>();
+
+ public DebugScannerTileEntity() {
+ this.itemsSlot = new InvSlot(this, "drainInput", 0, InvSlot.Access.I, 2);
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
+ return this.getFacing() != (short) side && side != 0 && side != 1;
+ }
+
+ @Override
+ public void updateEntityClient() {
+ if (IC2.platform.isRendering()) {
+ if (this.itemsSlot.get(0) != null && this.itemsSlot.get(0) != lastItem) {
+ this.oreDictionaryEntries.clear();
+ int[] ids = OreDictionary.getOreIDs(this.itemsSlot.get());
+ String itemNameFromIR = Item.itemRegistry.getNameForObject(this.itemsSlot.get().getItem());
+ this.oreDictionaryEntries.add("ItemRegistry entry:");
+ this.oreDictionaryEntries.add(" " + itemNameFromIR);
+ this.oreDictionaryEntries.add("Item damage: " + this.itemsSlot.get().getItemDamage());
+ this.oreDictionaryEntries.add("Item class:");
+ this.oreDictionaryEntries.add(" " + this.itemsSlot.get().getItem().getClass().getCanonicalName());
+ if (this.itemsSlot.get().stackTagCompound != null) {
+ this.oreDictionaryEntries.add("NBT keys:");
+ Iterator<?> iterator = this.itemsSlot.get().stackTagCompound.func_150296_c().iterator();
+ while (iterator.hasNext()) {
+ String entry = (String) iterator.next();
+ if (this.itemsSlot.get().stackTagCompound.getTag(entry) instanceof NBTTagCompound) {
+ this.oreDictionaryEntries.add(" " + entry);
+ NBTTagCompound ct = this.itemsSlot.get().stackTagCompound.getCompoundTag(entry);
+ if (ct != null && ct.func_150296_c() != null && !ct.func_150296_c().isEmpty()) {
+ this.oreDictionaryEntries.add(" -NBT compound tag subkeys:");
+ Iterator<?> stIterator = ct.func_150296_c().iterator();
+ while (stIterator.hasNext()) {
+ String entry2 = (String) stIterator.next();
+ this.oreDictionaryEntries.add(" " + entry2 + "=" + ct.getString(entry2));
+ }
+ }
+ } else {
+ this.oreDictionaryEntries
+ .add(" " + entry + "=" + this.itemsSlot.get().stackTagCompound.getString(entry));
+ }
+ }
+ }
+ if (ids.length > 0) {
+ this.oreDictionaryEntries.add("Ore dict. entries:");
+ for (int i = 0; i < ids.length; i++) {
+ this.oreDictionaryEntries.add(" " + OreDictionary.getOreName(ids[i]));
+ }
+ }
+ lastItem = this.itemsSlot.get(0);
+ }
+ if (this.itemsSlot.get(1) != null && this.itemsSlot.get(1) != lastItem) {
+ this.oreDictionaryEntries.clear();
+ FluidStack fluid = null;
+ this.oreDictionaryEntries.add("Fluid related item type:");
+ if (this.itemsSlot.get(1).getItem() instanceof IFluidContainerItem) {
+ this.oreDictionaryEntries.add(" IFluidContainerItem");
+ fluid = ((IFluidContainerItem) this.itemsSlot.get(1).getItem()).getFluid(this.itemsSlot.get(1));
+ } else if (FluidContainerRegistry.isContainer(this.itemsSlot.get(1))) {
+ this.oreDictionaryEntries.add(" FluidContainerRegistry entry");
+ if (FluidContainerRegistry.isBucket(this.itemsSlot.get(1))) {
+ this.oreDictionaryEntries.add("This is bucket.");
+ } else {
+ this.oreDictionaryEntries.add("This is not a bucket.");
+ }
+ ItemStack emptyContainer = FluidContainerRegistry.drainFluidContainer(this.itemsSlot.get(1));
+ if (emptyContainer != null) {
+ this.oreDictionaryEntries.add("This container could return empty container:");
+ this.oreDictionaryEntries.add(" " + emptyContainer.getDisplayName());
+ } else {
+ this.oreDictionaryEntries.add("This container has no empty version.");
+ }
+ fluid = FluidContainerRegistry.getFluidForFilledItem(this.itemsSlot.get(1));
+ } else {
+ this.oreDictionaryEntries.add(" none");
+ }
+ if (fluid != null) {
+ this.oreDictionaryEntries.add("Internal fluid name:");
+ this.oreDictionaryEntries.add(" " + fluid.getFluid().getName());
+ this.oreDictionaryEntries.add("Fluid class:");
+ this.oreDictionaryEntries.add(" " + fluid.getFluid().getClass().getName());
+ this.oreDictionaryEntries.add("Fluid id:");
+ this.oreDictionaryEntries.add(" " + fluid.getFluid().getID());
+ this.oreDictionaryEntries.add("Fluid still icon:");
+ if (fluid.getFluid().getStillIcon() != null) {
+ this.oreDictionaryEntries.add(" " + fluid.getFluid().getStillIcon().getIconName());
+ } else {
+ this.oreDictionaryEntries.add(" <missing icon> ");
+ }
+ this.oreDictionaryEntries.add("Fluid flowing icon:");
+ if (fluid.getFluid().getFlowingIcon() != null) {
+ this.oreDictionaryEntries.add(" " + fluid.getFluid().getFlowingIcon().getIconName());
+ } else {
+ this.oreDictionaryEntries.add(" <missing icon> ");
+ }
+ }
+ lastItem = this.itemsSlot.get(1);
+ }
+ }
+ }
+
+ /**
+ * Returns the name of the inventory
+ */
+ @Override
+ public String getInventoryName() {
+ return "debugScanner";
+ }
+
+ @Override
+ public ContainerBase<?> getGuiContainer(EntityPlayer entityPlayer) {
+ return new DebugScannerContainer(entityPlayer, this);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public GuiScreen getGui(EntityPlayer entityPlayer, boolean isAdmin) {
+ return new DebugScannerGui(new DebugScannerContainer(entityPlayer, this));
+ }
+
+ @Override
+ public void onGuiClosed(EntityPlayer entityPlayer) {
+ }
+
+ public boolean getGui(EntityPlayer player) {
+ return this instanceof IHasGui ? (IC2.platform.isSimulating() ? IC2.platform.launchGui(player, this) : true)
+ : false;
+ }
+}
\ No newline at end of file diff --git a/src/main/java/ihl/worldgen/ores/IHLFluid.java b/src/main/java/ihl/worldgen/ores/IHLFluid.java new file mode 100644 index 0000000..5e2e08b --- /dev/null +++ b/src/main/java/ihl/worldgen/ores/IHLFluid.java @@ -0,0 +1,333 @@ +package ihl.worldgen.ores;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import ic2.core.Ic2Items;
+import ihl.IHLCreativeTab;
+import ihl.IHLModInfo;
+import ihl.items_blocks.IHLFluidBlock;
+import net.minecraft.block.Block;
+import net.minecraft.block.material.MapColor;
+import net.minecraft.block.material.Material;
+import net.minecraft.block.material.MaterialLiquid;
+import net.minecraft.client.renderer.texture.TextureMap;
+import net.minecraft.init.Items;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemBucket;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.fluids.Fluid;
+import net.minecraftforge.fluids.FluidContainerRegistry;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+public class IHLFluid extends Fluid {
+ private IHLFluidType type;
+ private static List<Fluid> fluidInstances = new ArrayList<Fluid>();
+ private static Map<String, IHLFluidType> localFluidRegistry = new HashMap<String, IHLFluidType>();
+ private static Map<String, Float> realDensityMap = new HashMap<String, Float>();
+ private static Map<String, String> condensationMap = new HashMap<String, String>();
+ private static Map<String, List<String>> solutionMap = new HashMap<String, List<String>>();
+ public static final int maxGaseousStateVapoursDensity = 40;
+
+ public IHLFluid(IHLFluidType type1) {
+ super(type1.fluidRegistryName);
+ type = type1;
+ this.setTemperature(type.temperature);
+ this.setDensity(Math.round(type.density));
+ realDensityMap.put(type1.fluidRegistryName, type.density);
+ this.setUnlocalizedName(type.fluidRegistryName.replaceFirst("fluid", ""));
+ this.setGaseous(type.isGaseous);
+ Fluid instance = this;
+ if (!FluidRegistry.registerFluid(instance)) {
+ instance = FluidRegistry.getFluid(type.fluidRegistryName);
+ }
+ if (instance.getBlock() == null) {
+ instance.setBlock(new IHLFluidBlock(instance, type.blockMaterial, type.textureName,
+ "fluid" + type.fluidName.replaceFirst("fluid", "")).setFlammable(type.flammable)
+ .setBlockName("block" + type.fluidName).setCreativeTab(IHLCreativeTab.tab));
+ }
+ instance.setGaseous(type.isGaseous);
+ if (type.haveBucket) {
+ Item bucket = new ItemBucket(block).setTextureName(IHLModInfo.MODID + ":bucket_" + type.fluidName)
+ .setUnlocalizedName("bucket_" + type.fluidName).setCreativeTab(IHLCreativeTab.tab);
+ GameRegistry.registerItem(bucket, "bucket_" + type.fluidName);
+ FluidContainerRegistry.registerFluidContainer(instance, new ItemStack(bucket),
+ FluidContainerRegistry.EMPTY_BUCKET);
+ bucket.setContainerItem(Items.bucket);
+ }
+ type.fluid = instance;
+ localFluidRegistry.put(type1.fluidRegistryName, type);
+ fluidInstances.add(this);
+ }
+
+ public static void init() {
+ IHLFluidType[] var1 = IHLFluidType.values();
+ for (int i = 0; i < var1.length; i++) {
+ new IHLFluid(var1[i]);
+ }
+ condensationMap.put("steam", "ic2distilledwater");
+ condensationMap.put("ic2steam", "ic2distilledwater");
+ condensationMap.put("ic2superheatedsteam", "ic2distilledwater");
+ condensationMap.put("vapour.sulfuricacid", "sulfuricacid");
+ solutionMap.put("water", Arrays.asList(
+ new String[] { "aquaregia", "sulfuricacid", "solution.nickelsulfate", "solution.bluevitriol" }));
+ solutionMap.put("ic2distilledwater", Arrays.asList(
+ new String[] { "aquaregia", "sulfuricacid", "solution.nickelsulfate", "solution.bluevitriol" }));
+ }
+
+ public static void registerIcons(TextureMap iconRegistry) {
+ Iterator<Fluid> ii = fluidInstances.iterator();
+ while (ii.hasNext()) {
+ Fluid instance = ii.next();
+ IHLFluidType instanceType = localFluidRegistry.get(instance.getName());
+ instance.setIcons(iconRegistry.registerIcon(IHLModInfo.MODID + ":" + instanceType.textureName + "Still"),
+ iconRegistry.registerIcon(IHLModInfo.MODID + ":" + instanceType.textureName + "Flowing"));
+ }
+ }
+
+ public static ItemStack getCell(String fluidname1) {
+ ItemStack filledCell = FluidContainerRegistry.fillFluidContainer(
+ new FluidStack(FluidRegistry.getFluid(fluidname1), FluidContainerRegistry.BUCKET_VOLUME),
+ Ic2Items.cell.copy());
+ return filledCell;
+ }
+
+ public static Block getBlock(String fluidname) {
+ return localFluidRegistry.get(fluidname).fluid.getBlock();
+ }
+
+ public static int getMeltingPoint(Fluid fluid) {
+ if (localFluidRegistry.get(fluid.getName()) != null) {
+ IHLFluidType type = localFluidRegistry.get(fluid.getName());
+ return type.meltingPoint;
+ } else {
+ if (fluid.isGaseous()) {
+ return fluid.getTemperature() > 100 ? fluid.getTemperature() - 100 : 0;
+ } else {
+ return fluid.getTemperature();
+ }
+ }
+ }
+
+ public static int getBoilingPoint(Fluid fluid) {
+ if (localFluidRegistry.containsKey(fluid.getName())) {
+ IHLFluidType type = localFluidRegistry.get(fluid.getName());
+ return type.boilingPoint;
+ } else {
+ return 373;
+ }
+ }
+
+ public enum IHLFluidType {
+ // Methane("Methane","fluidAcetylene",10047, 293, 249, 373, 1150,
+ // "methane", Material.water, false, false, false, false),
+ NitroGlyceryl("NitroGlycerin", 10052, 293, 291, 583, 1595, "nitroglycerin", Material.water, true, false, true),
+ Ammonia("Ammonia", 10051, 273, 273 - 78, 273
+ - 33, 0.772F, "ammonia", new MaterialLiquid(MapColor.airColor), true, false, true),
+ Acetaldehyde("Acetaldehyde", 10050, 273, 273
+ - 123, 294, 784, "acetaldehyde", Material.water, false, false, false),
+ Formaldehyde("Formaldehyde", 10049, 254, 273
+ - 118, 254, 815, "formaldehyde", Material.water, false, false, false),
+ TarWater("TarWater", 10048, 293, 176, 338, 1032, "tarwater", Material.water, false, false, false),
+ Methanol("Methanol", 10047, 293, 176, 338, 792, "methanol", Material.water, true, false, false),
+ LithiumChloride("LithiumChlorideDissolvedInWater", 10046, 293, 249, 373, 1530, "solution.lithiumchloride", Material.water, false, false, false),
+ CalciumChloride("CalciumChlorideDissolvedInWater", 10045, 293, 249, 373, 1630, "solution.calciumchloride", Material.water, false, false, false),
+ ZeolitePulp("ZeolitePulp", "fluidPulpZeolite", 10044, 293, 249, 373, 1150, "pulp.sodiumzeolite", Material.water, false, false, false),
+ MoltenTarPitch("MoltenTarPitch", "fluidOil", 10043, 373, 373, 800, 1250, "molten.tarpitch", Material.lava, false, false, false),
+ CrackingGas("CrackingGas", "fluidAcetylene", 10042, 293, 135, 273, 2.27f, "crackinggas", new MaterialLiquid(
+ MapColor.blackColor), false, false, false),
+ Trichlorosilane("Trichlorosilane", "fluidHydrogenChloride", 10041, 293, 147, 305, 1342, "trichlorosilane", new MaterialLiquid(
+ MapColor.greenColor), true, false, false),
+ SiliconTetrachloride("SiliconTetrachloride", "fluidChlorine", 10040, 293, 204, 330, 584, "silicontetrachloride", new MaterialLiquid(
+ MapColor.cyanColor), true, false, false),
+ Chlorine("Chlorine", 10039, 293, 172, 238, 3.21F),
+ BoricAcid("BoricAcid", 10038, 373, 249, 373, 1275, "boricacid", Material.water, false, false, false),
+ MicaPulp("PulpMica", 10037, 293, 249, 373, 1150, "pulp.mica", Material.water, false, false, false),
+ CellulosePulp("PulpCellulose", 10036, 293, 249, 373, 1075, "pulp.cellulose", Material.water, false, false, false),
+ Fuel("Fuel", 10035, 293, 268, 633, 840, "fuel", Material.water, true, false, true),
+ MineralOil("MineralOil", 10034, 293, 238, 704, 845, "mineraloil", Material.water, true, false, true),
+ FuelOil("FuelOil", 10033, 293, 293, 693, 991, "fueloil", Material.water, true, false, true),
+ Oil("Oil", "fluidOil", 10032, 293, 284, 773, 850f, "oil", Material.water, true, false, true),
+ Mercury("Mercury", 10031, 293, 234, 630, 13546),
+ VapourMercury("VapourMercury", 10030, 630, 234, 630, 9.229F, "vapour.mercury", new MaterialLiquid(
+ MapColor.cyanColor), false, false, false),
+ Hydrogen("Hydrogen", 10029, 293, 14, 20, 0.046F, "hydrogen", new MaterialLiquid(
+ MapColor.blueColor), true, false, true),
+ SaltWater("SaltWater", "fluidSaltWater", 10028, 293, 253, 373, 1360f, "saltwater", Material.water, true, false, false),
+ HydrogenChloride("HydrogenChloride", 10027, 293, 159, 188, 1.477F, "hydrogenchloride", new MaterialLiquid(
+ MapColor.yellowColor), true, false, true),
+ NatriumTungstate("NatriumTungstateDissolvedInWater", 10026, 293, 249, 373, 1730, "solution.natriumtungstate", Material.water, true, false, false),
+ Turpentine("Turpentine", 10025, 293, 217, 453, 1470, "turpentine", Material.water, true, false, true),
+ Air("Air", 293, 55, 93, 1.292F, Ic2Items.airCell),
+ Nitrogen("Nitrogen", 10024, 92, 56, 92, 1.251F, "nitrogen", new MaterialLiquid(
+ MapColor.airColor), true, false, true),
+ Acetylene("Acetylene", 10023, 293, 17, 190, 1.173F, "acetylene", Material.water, true, false, true),
+ Oxygen("Oxygen", 10022, 93, 55, 93, 1.429F, "oxygen", new MaterialLiquid(MapColor.airColor), true, false, true),
+ NatriumHydroxide("NatriumHydroxideDissolvedInWater", 10021, 293, 249, 373, 1525, "solution.natriumhydroxide", Material.water, true, false, false),
+ LiquidGlass("LiquidGlass", 10020, 293, 253, 373, 2400),
+ fluidRubberTreeSap("fluidRubberTreeSap", "fluidRubberTreeSap", 10019, 293, 273, 393, 1200f, "fluidrubbertreesap", Material.water, true, true, false),
+ SpruceResin("SpruceResin","fluidSpruceResin", 10018, 293, 273, 533, 1080, "spruceresin", Material.water, true, true, true),
+ CablingColophony("CablingColophony", 10017, 363, 363, 533, 1070, "cablingcolophony", Material.water, true, false, true),
+ Glycerol("Glycerol", 10016, 293, 291, 583, 1261, "glycerol", Material.water, true, false, true),
+ SeedOil("SeedOil", 10015, 293, 256, 583, 920, "seedoil", Material.water, true, false, true),
+ AquaRegia("AquaRegia", 10014, 293, 231, 356, 1060),
+ SodiumPeroxide("SodiumPeroxide", 10013, 950, 950, 2223, 1800),
+ OsmiumTetroxide("OsmiumTetroxide", 10012, 313, 313, 403, 9),
+ OleicAcid("OleicAcid", 10011, 293, 288, 633, 895, "oleicacid", Material.water, true, false, true),
+ Limemilk("Limemilk", 10010, 293, 250, 373, 1020),
+ NickelSulfateDissolvedInWater("NickelSulfateDissolvedInWater", 10009, 293, 253, 373, 1220, "solution.nickelsulfate", Material.water, true, false, false),
+ BlueVitriolDissolvedInWater("BlueVitriolDissolvedInWater", 10008, 293, 253, 373, 1180, "solution.bluevitriol", Material.water, true, false, false),
+ MoltenRubberWithSulfur("MoltenRubberWithSulfur", 10007, 600, 600, 1000, 1200, "molten.rubber", Material.lava, false, false, true),
+ MoltenPotassium("MoltenPotassium", "fluidMolten", 10042, 336, 336, 1047, 856, "molten.potassium", Material.lava, false, false, false),
+ MoltenLithium("MoltenLithium", "fluidMolten", 10042, 454, 454, 1613, 512, "molten.lithium", Material.lava, false, false, false),
+ MoltenPotassiumChloride("MoltenPotassiumChloride", "fluidMolten", 10006, 776 + 273, 776 + 273, 1407
+ + 273, 1556, "molten.potassiumchloride", Material.lava, false, false, false),
+ MoltenSodiumChloride("MoltenSodiumChloride", "fluidMolten", 10006, 1273, 1273, 1740, 1556, "molten.sodiumchloride", Material.lava, false, false, false),
+ MoltenGlass("MoltenGlass", "fluidMolten", 10048, 600, 600, 1950, 2270, "molten.glass", Material.lava, false, false, false),
+ MoltenMagnesium("MoltenMagnesium", "fluidMolten", 10006, 923, 923, 1623, 1584, "molten.magnesium", Material.lava, false, false, false),
+ MoltenSteel("MoltenSteel", "fluidMolten", 10006, 1800, 1800, 3134, 6980, "molten.steel", Material.lava, false, false, false),
+ MoltenCopper("MoltenCopper", "fluidMolten", 10048, 1356, 1356, 2840, 8920, "molten.copper", Material.lava, false, false, false),
+ MoltenBronze("MoltenBronze", 10005, 940, 940, 2840, 8000, "molten.bronze", Material.lava, false, false, false),
+ MoltenGold("MoltenGold", 10005, 1337, 1337, 3129, 17310, "molten.gold", Material.lava, false, false, false),
+ SulfuricAcid("SulfuricAcid", 10002, 293, 283, 610, 1836),
+ NitricAcid("NitricAcid", 10001, 293, 231, 356, 1100);
+
+ IHLFluidType(String fluidName1, int celldamage, int temperature1, int meltingPoint1, int boilingPoint1,
+ float density1) {
+ fluidName = fluidName1;
+ fluidRegistryName = fluidName.toLowerCase();
+ textureName = "fluid" + fluidName.replaceFirst("fluid", "");
+ temperature = temperature1;
+ density = density1;
+ cellName = "itemCell" + fluidName;
+ haveBucket = false;
+ isGaseous = density1 < maxGaseousStateVapoursDensity;
+ boilingPoint = boilingPoint1;
+ meltingPoint = meltingPoint1;
+ damage = celldamage;
+ }
+
+ IHLFluidType(String fluidName1, int temperature1, int meltingPoint1, int boilingPoint1, float density1,
+ ItemStack cell1) {
+ fluidName = fluidName1;
+ fluidRegistryName = fluidName.toLowerCase();
+ textureName = "fluid" + fluidName.replaceFirst("fluid", "");
+ temperature = temperature1;
+ density = density1;
+ cellName = "itemCell" + fluidName;
+ haveBucket = false;
+ isGaseous = density1 < maxGaseousStateVapoursDensity;
+ boilingPoint = boilingPoint1;
+ meltingPoint = meltingPoint1;
+ damage = 99999;
+ hasCell = false;
+ cell = cell1;
+ }
+
+ IHLFluidType(String fluidName1, int celldamage, int temperature1, int meltingPoint1, int boilingPoint1,
+ float density1, String fluidRegistryName1, Material blockMaterial1, boolean hasCell1,
+ boolean haveBucket1, boolean flammable1) {
+ fluidName = fluidName1;
+ fluidRegistryName = fluidRegistryName1;
+ textureName = "fluid" + fluidName.replaceFirst("fluid", "");
+ temperature = temperature1;
+ density = density1;
+ cellName = "itemCell" + fluidName;
+ haveBucket = haveBucket1;
+ flammable = flammable1;
+ isGaseous = density1 < maxGaseousStateVapoursDensity;
+ blockMaterial = blockMaterial1;
+ boilingPoint = boilingPoint1;
+ meltingPoint = meltingPoint1;
+ hasCell = hasCell1;
+ damage = celldamage;
+ }
+
+ IHLFluidType(String fluidName1, String textureName1, int celldamage, int temperature1, int meltingPoint1,
+ int boilingPoint1, float density1, String fluidRegistryName1, Material blockMaterial1, boolean hasCell1,
+ boolean haveBucket1, boolean flammable1) {
+ fluidName = fluidName1;
+ fluidRegistryName = fluidRegistryName1;
+ textureName = textureName1;
+ temperature = temperature1;
+ density = density1;
+ cellName = "itemCell" + fluidName;
+ haveBucket = haveBucket1;
+ flammable = flammable1;
+ isGaseous = density1 < maxGaseousStateVapoursDensity;
+ blockMaterial = blockMaterial1;
+ boilingPoint = boilingPoint1;
+ meltingPoint = meltingPoint1;
+ hasCell = hasCell1;
+ damage = celldamage;
+ }
+
+ public String fluidName;
+ public String fluidRegistryName;
+ public String cellName;
+ public String textureName;
+ int temperature;
+ float density;
+ boolean isGaseous;
+ boolean flammable = false;
+ boolean haveBucket;
+ Material blockMaterial = Material.water;
+ int meltingPoint;
+ int boilingPoint;
+ public boolean hasCell = true;
+ public ItemStack cell;
+ public Fluid fluid;
+ public final int damage;
+ }
+
+ @SuppressWarnings("deprecation")
+ public static FluidStack getCondensationResult(FluidStack condensatedGas) {
+ String fluidname = condensationMap.get(condensatedGas.getFluid().getName());
+ Fluid fluid = FluidRegistry.getFluid(fluidname);
+ if (fluid != null) {
+ int quantity = Math.round(condensatedGas.amount * getCondensationConversionRate(condensatedGas.getFluid()));
+ if (quantity > 0) {
+ return new FluidStack(fluid.getID(), quantity);
+ }
+ }
+ return null;
+ }
+
+ public static float getCondensationConversionRate(Fluid gas) {
+ String fluidname = condensationMap.get(gas.getName());
+ Fluid fluid = FluidRegistry.getFluid(fluidname);
+ if (fluid != null) {
+ float rate = (float) gas.getDensity() / (float) fluid.getDensity();
+ if (gas.getDensity() < 0) {
+ // IC2 steam density -800, 100 mb steam from 1 mb water
+ rate = (-8000F / gas.getDensity()) / fluid.getDensity();
+ }
+ return rate;
+ }
+ return 0F;
+ }
+
+ public static boolean canBeDissolvedIn(FluidStack solvent, String impurity) {
+ return solutionMap.get(solvent.getFluid().getName()).contains(impurity);
+ }
+
+ public static float getRealDensity(Fluid gas) {
+ if (realDensityMap.containsKey(gas.getName())) {
+ return realDensityMap.get(gas.getName());
+ } else {
+ float density = gas.getDensity();
+ if (gas.getDensity() < 0) {
+ // IC2 steam density -800, 100 mb steam from 1 mb water
+ density = -8000F / gas.getDensity();
+ }
+ return density;
+ }
+ }
+
+}
|
