diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-02-07 06:08:52 +0100 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-02-07 06:08:52 +0100 |
commit | e412e90f5f9e571aaebf1e05d593a1f0627c8405 (patch) | |
tree | d53de922025012de510cdd68b344fcc29e8f0f2c /src/main/java | |
parent | 2d3981ea0fe5c1d38e2f431e45860bb8c530eb90 (diff) | |
download | GT5-Unofficial-e412e90f5f9e571aaebf1e05d593a1f0627c8405.tar.gz GT5-Unofficial-e412e90f5f9e571aaebf1e05d593a1f0627c8405.tar.bz2 GT5-Unofficial-e412e90f5f9e571aaebf1e05d593a1f0627c8405.zip |
API Changes
+ added a SimpleWaterGenerator
+ fixed the Diode not working on servers.
Former-commit-id: cd0d74153a5a1279b1ff2409eaac39fbccd5c3cf
Diffstat (limited to 'src/main/java')
21 files changed, 1042 insertions, 9 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/API_REFERENCE.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/API_REFERENCE.java index 2767d56168..7c2793f2b1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/API_REFERENCE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/API_REFERENCE.java @@ -23,5 +23,5 @@ package com.github.bartimaeusnek.bartworks.API; public final class API_REFERENCE { - public static final String VERSION = "@version@"; + public static final String VERSION = "@apiversion@"; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java index 0f81d266f0..feedb79761 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java @@ -53,7 +53,7 @@ public final class BioRecipeAdder { * @param aSpecialValue 0 = STANDART, -100 = LowGravity, -200 = Cleanroom * @return if the recipe was added. */ - public static boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { + public static boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, FluidStack aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { return BWRecipes.instance.addBioLabRecipeIncubation(aInput, aOutput, aChances, aFluidInputs, aDuration, aEUt, aSpecialValue); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileAddsInformation.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileAddsInformation.java new file mode 100644 index 0000000000..002b175bbf --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileAddsInformation.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +public interface ITileAddsInformation { + String[] getInfoData(); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java new file mode 100644 index 0000000000..a9318ca7f0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileHasDifferentTextureSides.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; + + +public interface ITileHasDifferentTextureSides { + + IIcon[] texture = new IIcon[7]; + + @SideOnly(Side.CLIENT) + default IIcon getTextureForSide(ForgeDirection side, int meta) { + return texture[side.ordinal()]; + } + + ; + + @SideOnly(Side.CLIENT) + default IIcon getTextureForSide(int side, int meta) { + return getTextureForSide(ForgeDirection.values()[side], meta); + } + + ; + + @SideOnly(Side.CLIENT) + void registerBlockIcons(IIconRegister par1IconRegister); + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileWithGUI.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileWithGUI.java new file mode 100644 index 0000000000..636fcb3a31 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/ITileWithGUI.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.API; + +import com.github.bartimaeusnek.bartworks.MainMod; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; + +public interface ITileWithGUI { + + /** + * @return the ID of the GUI, see @link com.github.bartimaeusnek.bartworks.GuiHandler + */ + int getGUIID(); + + /** + * gets called from BW_TileEntityContainer(or _Multiple) when right clicked. + * + * @param tileEntity this tile entity + * @param player the player right clicking it + * @return true always. + */ + default boolean openGUI(TileEntity tileEntity, EntityPlayer player) { + if (!tileEntity.getWorldObj().isRemote) + player.openGui(MainMod.MOD_ID, getGUIID(), tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java index 00b9317d5a..5476c65e72 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java @@ -22,9 +22,12 @@ package com.github.bartimaeusnek.bartworks; +import com.github.bartimaeusnek.bartworks.client.gui.BW_GUIContainer_HeatedWaterPump; import com.github.bartimaeusnek.bartworks.client.gui.BW_GUIContainer_RadLevel; import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_CircuitProgrammer; import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_Destructopack; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; +import com.github.bartimaeusnek.bartworks.server.container.BW_Container_HeatedWaterPump; import com.github.bartimaeusnek.bartworks.server.container.BW_Container_RadioHatch; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_CircuitProgrammer; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_Item_Destructopack; @@ -49,6 +52,8 @@ public class GuiHandler implements IGuiHandler { return new BW_Container_RadioHatch(player.inventory, te.getMetaTileEntity()); } } + case 3: + return new BW_Container_HeatedWaterPump((BW_TileEntity_HeatedWaterPump) world.getTileEntity(x, y, z), player); } return null; } @@ -67,6 +72,8 @@ public class GuiHandler implements IGuiHandler { return new BW_GUIContainer_RadLevel(new BW_Container_RadioHatch(player.inventory, te.getMetaTileEntity())); } } + case 3: + return new BW_GUIContainer_HeatedWaterPump(new BW_Container_HeatedWaterPump((BW_TileEntity_HeatedWaterPump) world.getTileEntity(x, y, z), player)); } } else return getServerGuiElement(ID, player, world, x, y, z); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index 52b282646f..1d48b16f2e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -56,6 +56,7 @@ public final class MainMod { public static final String NAME = "BartWorks"; public static final String VERSION = "@version@"; public static final String MOD_ID = "bartworks"; + public static final String APIVERSION = "@apiversion@"; public static final Logger LOGGER = LogManager.getLogger(NAME); public static final CreativeTabs GT2 = new GT2Tab("GT2C"); public static final CreativeTabs BIO_TAB = new BioTab("BioTab"); @@ -72,7 +73,7 @@ public final class MainMod { public void preInit(FMLPreInitializationEvent preinit) { //fixing BorosilicateGlass... -_-' Materials.BorosilicateGlass.add(SubTag.CRYSTAL, SubTag.NO_SMASHING, SubTag.NO_RECYCLING, SubTag.SMELTING_TO_FLUID); - if (!(API_REFERENCE.VERSION.equals(VERSION))) { + if (!(API_REFERENCE.VERSION.equals(APIVERSION))) { LOGGER.error("Something has loaded an old API. Please contact the Mod authors to update!"); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_HeatedWaterPump.java new file mode 100644 index 0000000000..b8cd2e9799 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_HeatedWaterPump.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.gui; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.server.container.BW_Container_HeatedWaterPump; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Container; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +public class BW_GUIContainer_HeatedWaterPump extends GuiContainer { + private static final ResourceLocation furnaceGuiTextures = new ResourceLocation(MainMod.MOD_ID + ":textures/GUI/GUIheatedPump.png"); + final BW_Container_HeatedWaterPump container; + + public BW_GUIContainer_HeatedWaterPump(Container p_i1072_1_) { + super(p_i1072_1_); + container = (BW_Container_HeatedWaterPump) p_i1072_1_; + } + + @Override + protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(furnaceGuiTextures); + int k = (this.width - this.xSize) / 2; + int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + this.drawString(this.fontRendererObj, "Fuel:" + container.fuel + " Water:" + container.water, k, l, 0xffffff); + + if (this.container.fuel > 0) { + this.mc.getTextureManager().bindTexture(furnaceGuiTextures); + int ik = this.container.maxfuel > 200 ? this.container.maxfuel : 200; + int i1 = ((this.container.fuel * 13) / ik); + this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 13 - i1, 14, i1 + 1); + } + +// if (this.container.water > 0){ +// this.mc.getTextureManager().bindTexture( new ResourceLocation("textures/blocks/water_still.png")); +// this.drawTexturedModalRect(k+85,l+32,32,32,18,18); +// } + + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java new file mode 100644 index 0000000000..bb93e0e506 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.IIconContainer; +import net.minecraft.block.Block; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +@SideOnly(Side.CLIENT) +public class BW_GT_Vanilla_Texture implements IIconContainer { + + IIcon packed; + + public BW_GT_Vanilla_Texture(Block block, ForgeDirection side) { + this.packed = block.getBlockTextureFromSide(side.flag); + } + + public BW_GT_Vanilla_Texture(Block block, int side) { + this.packed = block.getBlockTextureFromSide(side); + } + + public BW_GT_Vanilla_Texture(IIcon packed) { + this.packed = packed; + } + + @Override + public IIcon getIcon() { + return packed; + } + + @Override + public IIcon getOverlayIcon() { + return null; + } + + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation(packed.getIconName()); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java index a067dae815..9860ec1c41 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java @@ -78,6 +78,7 @@ public class BW_Blocks extends Block { } @Override + @SideOnly(Side.CLIENT) public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { for (int i = 0; i < textureNames.length; i++) { list.add(new ItemStack(item, 1, i)); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java index b9d59c2294..34dc223140 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java @@ -22,20 +22,33 @@ package com.github.bartimaeusnek.bartworks.common.blocks; +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; +import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; +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 net.minecraft.block.BlockContainer; 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.EnumCreatureType; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; 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; +import net.minecraftforge.fluids.IFluidContainerItem; -public class BW_TileEntityContainer extends BlockContainer { +public class BW_TileEntityContainer extends BlockContainer implements ITileAddsInformation { Class<? extends TileEntity> tileEntity = null; @@ -52,13 +65,24 @@ public class BW_TileEntityContainer extends BlockContainer { if (worldObj.isRemote) { return true; } + final TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile instanceof BW_TileEntity_HeatedWaterPump) { + if (player.getHeldItem() != null && (player.getHeldItem().getItem().equals(Items.bucket) || player.getHeldItem().getItem() instanceof IFluidContainerItem) && ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, false) != null) + if (player.getHeldItem().getItem().equals(Items.bucket)) { + player.getHeldItem().stackSize--; + if (player.getHeldItem().stackSize <= 0) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + player.inventory.addItemStackToInventory(new ItemStack(Items.water_bucket)); + return true; + } + } if (!player.isSneaking()) { - final TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof IHasGui) { return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); + } else if (tile instanceof ITileWithGUI) { + return worldObj.isRemote || ((ITileWithGUI) tile).openGUI(tile, player); } } - return false; } @@ -90,6 +114,33 @@ public class BW_TileEntityContainer extends BlockContainer { } @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + if (ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) { + try { + return ((ITileHasDifferentTextureSides) this.tileEntity.newInstance()).getTextureForSide(side, meta); + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + return super.getIcon(side, meta); + } + } else + return super.getIcon(side, meta); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + if (ITileHasDifferentTextureSides.class.isAssignableFrom(this.tileEntity)) { + try { + ((ITileHasDifferentTextureSides) this.tileEntity.newInstance()).registerBlockIcons(par1IconRegister); + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + } else + super.registerBlockIcons(par1IconRegister); + } + + @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { try { return this.tileEntity.newInstance(); @@ -99,4 +150,30 @@ public class BW_TileEntityContainer extends BlockContainer { return null; } + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public String[] getInfoData() { + if (ITileAddsInformation.class.isAssignableFrom(this.tileEntity)) { + try { + return ((ITileAddsInformation) this.tileEntity.newInstance()).getInfoData(); + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + } + return new String[0]; + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java new file mode 100644 index 0000000000..112d57de9b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.blocks; + +import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; +import com.github.bartimaeusnek.bartworks.MainMod; +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 net.minecraft.block.BlockContainer; +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.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +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; + +import java.util.List; + +public class BW_TileEntityContainer_Multiple extends BlockContainer { + + final protected String[] textureNames; + final protected String name; + final Class<? extends TileEntity>[] tileEntityArray; + @SideOnly(Side.CLIENT) + protected IIcon[] texture; + + public BW_TileEntityContainer_Multiple(Material p_i45386_1_, Class<? extends TileEntity>[] tileEntity, String blockName, String[] textureNames, CreativeTabs tabs) { + super(p_i45386_1_); + this.setHardness(15.0F); + this.setResistance(30.0F); + tileEntityArray = tileEntity; + name = blockName; + this.textureNames = textureNames; + this.setCreativeTab(tabs); + this.setBlockName(blockName); + this.setBlockTextureName(MainMod.MOD_ID + ":" + blockName); + } + + @Override + public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { + if (worldObj.isRemote) { + return true; + } + if (!player.isSneaking()) { + final TileEntity tile = worldObj.getTileEntity(x, y, z); + if (tile instanceof IHasGui) { + return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); + } else if (tile instanceof ITileWithGUI) { + return worldObj.isRemote || ((ITileWithGUI) tile).openGUI(tile, player); + } + } + + return false; + } + + public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack itemStack) { + final TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof IWrenchable && itemStack != null) { + final IWrenchable tile2 = (IWrenchable) tile; + int meta = itemStack.getItemDamage(); + world.setBlockMetadataWithNotify(x, y, z, meta, 2); + if (entity != null) { + final int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; + switch (face) { + case 0: + tile2.setFacing((short) 2); + break; + case 1: + tile2.setFacing((short) 5); + break; + case 2: + tile2.setFacing((short) 3); + break; + case 3: + tile2.setFacing((short) 4); + break; + } + } + } + } + + @Override + public int damageDropped(final int meta) { + return meta; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { + for (int i = 0; i < textureNames.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return meta < texture.length ? texture[meta] : texture[0]; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister par1IconRegister) { + texture = new IIcon[textureNames.length]; + for (int i = 0; i < textureNames.length; i++) { + texture[i] = par1IconRegister.registerIcon(textureNames[i]); + } + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + try { + return this.tileEntityArray[p_149915_2_].newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java index 01af8ef53f..cf5e0aab78 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java @@ -41,6 +41,7 @@ public class ConfigHandler { public static Configuration c; public static boolean DEHPDirectSteam = false; public static int megaMachinesMax = 256; + public static int mbWaterperSec = 150; private static boolean ezmode = false; public ConfigHandler(@Nonnull FMLPreInitializationEvent e) { @@ -55,6 +56,7 @@ public class ConfigHandler { BioLab = !c.get("System", "Disable BioLab", false, "This switch disables the BioLab, BioVat etc. If you use GT5.08 or equivalent, this needs to be turned off!").getBoolean(false); DEHPDirectSteam = c.get("Multiblocks", "DEHP Direct Steam Mode", false, "This switch enables the Direct Steam Mode of the DEHP. If enabled it will take in Waterand output steam. If disabled it will Input IC2Coolant and output hot coolant").getBoolean(false); megaMachinesMax = c.get("Multiblocks", "Mega Machines Maximum Recipes per Operation", 256, "This changes the Maximum Recipes per Operation to the specified Valure").getInt(256); + mbWaterperSec = c.get("Singleblocks", "mL Water per Sec for the StirlingPump", 150).getInt(150); if (ConfigHandler.IDOffset == 0) { ConfigHandler.IDOffset = 12600; c.get("System", "ID Offset", 12600, "ID Offset for this mod. This Mod uses " + IDU + " IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS").set(12600); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java index 1b631cc5fe..8386ebb857 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java @@ -22,6 +22,7 @@ package com.github.bartimaeusnek.bartworks.common.items; +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks; import com.github.bartimaeusnek.bartworks.util.BW_Util; @@ -31,6 +32,7 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_LanguageManager; import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -65,8 +67,14 @@ public class BW_ItemBlocks extends ItemBlock { public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { if (this.field_150939_a instanceof BW_GlasBlocks) aList.add("Glass-Tier: " + BW_Util.getColorForTier(BW_Util.getTierFromGlasMeta(aStack.getItemDamage())) + GT_Values.VN[BW_Util.getTierFromGlasMeta(aStack.getItemDamage())]); + if (this.field_150939_a instanceof ITileAddsInformation) { + for (int i = 0; i < ((ITileAddsInformation) this.field_150939_a).getInfoData().length; i++) { + aList.add(((ITileAddsInformation) this.field_150939_a).getInfoData()[i]); + } + } aList.add(this.mNoMobsToolTip); - aList.add(this.mNoTileEntityToolTip); + if (!(this.field_150939_a instanceof ITileEntityProvider)) + aList.add(this.mNoTileEntityToolTip); aList.add("Added by" + ChatColorHelper.DARKGREEN + " BartWorks"); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java index 169655c4a5..09e4d6be98 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java @@ -29,6 +29,7 @@ import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.items.*; import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_RotorBlock; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_DEHP; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaBlastFurnace; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaVacuumFreezer; @@ -67,6 +68,8 @@ public class ItemRegistry { public static final Item CRAFTING_PARTS = new SimpleSubItemClass(new String[]{"grindstone_top", "grindstone_bottom", "completed_grindstone", "rotors/leatherParts", "rotors/woolParts", "rotors/paperParts", "rotors/combinedParts"}); public static final Item TAB = new SimpleIconItem("GT2Coin"); public static final Item WINDMETER = new BW_SimpleWindMeter(); + public static final Block PUMPBLOCK = new BW_TileEntityContainer(Material.anvil, BW_TileEntity_HeatedWaterPump.class, "BWHeatedWaterPump"); + public static final Item PUMPPARTS = new SimpleSubItemClass(new String[]{"BWrawtube", "BWmotor"}); public static final Block[] bw_glasses = { new BW_GlasBlocks( @@ -136,7 +139,10 @@ public class ItemRegistry { GameRegistry.registerItem(COMBINED_ROTOR, "BW_CombinedRotor"); GameRegistry.registerItem(CRAFTING_PARTS, "craftingParts"); GameRegistry.registerTileEntity(BW_RotorBlock.class, "BWRotorBlockTE"); - GameRegistry.registerBlock(ROTORBLOCK, "BWRotorBlock"); + GameRegistry.registerBlock(ROTORBLOCK, BW_ItemBlocks.class, "BWRotorBlock"); + GameRegistry.registerTileEntity(BW_TileEntity_HeatedWaterPump.class, "BWHeatedWaterPumpTE"); + GameRegistry.registerBlock(PUMPBLOCK, BW_ItemBlocks.class, "BWHeatedWaterPumpBlock"); + GameRegistry.registerItem(PUMPPARTS, "BWPumpParts"); GameRegistry.registerItem(WINDMETER, "BW_SimpleWindMeter"); for (int i = 0; i < GT_Values.VN.length; i++) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java index 6a40941703..c381b92587 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java @@ -33,6 +33,7 @@ import gregtech.api.enums.*; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; +import ic2.core.Ic2Items; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -181,6 +182,42 @@ public class RecipeLoader implements Runnable { }); if (newStuff) { + + GT_ModHandler.addCraftingRecipe(new ItemStack(ItemRegistry.PUMPPARTS, 1, 0),//tube + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{ + " fG", + " G ", + "G ", + 'G', ItemList.Circuit_Parts_Glass_Tube.get(1L) + } + ); + GT_ModHandler.addCraftingRecipe(new ItemStack(ItemRegistry.PUMPPARTS, 1, 1),//motor + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{ + "GLP", + "LSd", + "PfT", + 'G', GT_OreDictUnificator.get(OrePrefixes.gearGtSmall, Materials.Steel, 1L), + 'L', GT_OreDictUnificator.get(OrePrefixes.stickLong, Materials.Steel, 1L), + 'S', GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Steel, 1L), + 'P', new ItemStack(Blocks.piston), + 'T', new ItemStack(ItemRegistry.PUMPPARTS, 1, 0) + } + ); + GT_ModHandler.addCraftingRecipe(new ItemStack(ItemRegistry.PUMPBLOCK, 1, 0), + GT_ModHandler.RecipeBits.NOT_REMOVABLE, + new Object[]{ + "IPI", + "PMP", + "ISI", + 'I', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iron, 1L), + 'P', GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Wood, 1L), + 'M', new ItemStack(ItemRegistry.PUMPPARTS, 1, 1), + 'S', Ic2Items.ironFurnace + } + ); + if (!MainMod.GTNH) GT_ModHandler.addCraftingRecipe( ItemRegistry.dehp, diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java new file mode 100644 index 0000000000..ed4fe3ce78 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java @@ -0,0 +1,281 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.common.tileentities.classic; + +import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; +import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; +import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityFurnace; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.*; + +public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ISidedInventory, IFluidHandler, IFluidTank, ITileWithGUI, ITileAddsInformation, ITileHasDifferentTextureSides { + + public static final int FUELSLOT = 0; + public static final Fluid WATER = FluidRegistry.WATER; + public ItemStack fuelstack; + public FluidStack outputstack = new FluidStack(FluidRegistry.WATER, 0); + public int fuel = 0; + public byte tick = 0; + public int maxfuel = 0; + public ItemStack fakestack = new ItemStack(Blocks.water); + + @Override + public void writeToNBT(NBTTagCompound p_145841_1_) { + NBTTagCompound subItemStack = new NBTTagCompound(); + if (fuelstack == null) + p_145841_1_.setTag("ItemStack", subItemStack); + else { + fuelstack.writeToNBT(subItemStack); + p_145841_1_.setTag("ItemStack", subItemStack); + } + NBTTagCompound subFluidStack = new NBTTagCompound(); + outputstack.writeToNBT(subFluidStack); + p_145841_1_.setTag("FluidStack", subFluidStack); + p_145841_1_.setInteger("fuel", fuel); + p_145841_1_.setInteger("maxfuel", maxfuel); + p_145841_1_.setByte("tick", tick); + super.writeToNBT(p_145841_1_); + } + + @Override + public void readFromNBT(NBTTagCompound p_145839_1_) { + tick = p_145839_1_.getByte("tick"); + fuel = p_145839_1_.getInteger("fuel"); + maxfuel = p_145839_1_.getInteger("maxfuel"); + outputstack = FluidStack.loadFluidStackFromNBT(p_145839_1_.getCompoundTag("FluidStack")); + if (!p_145839_1_.getCompoundTag("ItemStack").equals(new NBTTagCompound())) + fuelstack = ItemStack.loadItemStackFromNBT(p_145839_1_.getCompoundTag("ItemStack")); + super.readFromNBT(p_145839_1_); + } + + @Override + public void updateEntity() { + if (worldObj.isRemote || ((fuelstack == null || fuelstack.stackSize <= 0) && fuel <= 0) || (tick == 0 && worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord) == Blocks.air)) { + return; + } + + if (fuel < 0) + fuel = 0; + + if (fuelstack != null && fuel == 0) { + fuel = maxfuel = TileEntityFurnace.getItemBurnTime(fuelstack); + --fuelstack.stackSize; + if (this.fuelstack.stackSize <= 0) + this.fuelstack = null; + } + + if (fuel > 0) { + ++tick; + --fuel; + if (tick % 20 == 0) { + if (outputstack.amount <= (8000 - ConfigHandler.mbWaterperSec)) + outputstack.amount += ConfigHandler.mbWaterperSec; + tick = 0; + } + } + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[]{0}; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return TileEntityFurnace.getItemBurnTime(p_102007_2_) > 0; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return 2; + } + + @Override + public ItemStack getStackInSlot(int p_70301_1_) { + if (p_70301_1_ == 0) + return fuelstack; + else + return fakestack; + } + + @Override + public ItemStack decrStackSize(int slot, int ammount) { + if (slot != FUELSLOT || fuelstack == null || ammount > fuelstack.stackSize) + return null; + + return fuelstack.splitStack(ammount); + } + + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(int slot, ItemStack p_70299_2_) { + if (slot == FUELSLOT) + fuelstack = p_70299_2_; + else + fakestack = p_70299_2_; + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void openInventory() { + } + + @Override + public void closeInventory() { + + } + + @Override + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + return TileEntityFurnace.getItemBurnTime(p_94041_2_) > 0 && p_94041_1_ == FUELSLOT; + } + + @Override + public FluidStack getFluid() { + return outputstack.amount > 0 ? outputstack : null; + } + + @Override + public int getFluidAmount() { + return outputstack.amount; + } + + @Override + public int getCapacity() { + return 8000; + } + + @Override + public FluidTankInfo getInfo() { + return new FluidTankInfo(this); + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + int actualdrain = maxDrain; + if (actualdrain > outputstack.amount) + actualdrain = outputstack.amount; + FluidStack ret = new FluidStack(WATER, actualdrain); + if (ret.amount == 0) + ret = null; + if (doDrain) { + outputstack.amount -= actualdrain; + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(outputstack, this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord, this, actualdrain)); + } + return ret; + } + + @Override + public int getGUIID() { + return 3; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (resource != null && resource.getFluid() == WATER && drain(resource.amount, false) != null) + return drain(resource.amount, doDrain); + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return drain(maxDrain, doDrain); + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return fluid == null || fluid == WATER; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[]{getInfo()}; + } + + @Override + public String[] getInfoData() { + return new String[]{"Produces " + ConfigHandler.mbWaterperSec + "L/s Water when fueled.", "Must be placed on the Ground."}; + } + + @Override + public void registerBlockIcons(IIconRegister par1IconRegister) { + texture[ForgeDirection.UP.ordinal()] = par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpTop"); + texture[ForgeDirection.DOWN.ordinal()] = par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpDown"); + for (int i = 2; i < 7; i++) { + texture[i] = par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpSide"); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java index 0d51cb828b..3c4e1c73a7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java @@ -52,6 +52,10 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + + if (this.getBaseMetaTileEntity().getWorld().isRemote) + return; + --aAmps; if (aAmps < 0) aAmps = maxAmps; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java new file mode 100644 index 0000000000..a3b951b34e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.server.container; + +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_Slot_Render; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import java.nio.ByteBuffer; +import java.util.Iterator; + +public class BW_Container_HeatedWaterPump extends Container { + + final BW_TileEntity_HeatedWaterPump TILE; + final IInventory INVENTORY; + public int fuel, water, awater, maxfuel; + long timer = 0; + byte[] anetfuel, netfuel, anetmaxfuel, netmaxfuel; + + public BW_Container_HeatedWaterPump(BW_TileEntity_HeatedWaterPump TILE, EntityPlayer INVENTORY) { + this.TILE = TILE; + this.INVENTORY = INVENTORY.inventory; + + this.addSlotToContainer(new Slot(TILE, 0, 56, 53)); + this.addSlotToContainer(new GT_Slot_Render(TILE, 1, 86, 33)); + int i; + + for (i = 0; i < 3; ++i) { + for (int j = 0; j < 9; ++j) { + this.addSlotToContainer(new Slot(this.INVENTORY, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (i = 0; i < 9; ++i) { + this.addSlotToContainer(new Slot(this.INVENTORY, i, 8 + i * 18, 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return true; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { + return null; + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (TILE.getWorldObj().isRemote) + return; + + fuel = this.TILE.fuel; + maxfuel = this.TILE.maxfuel; + water = this.TILE.outputstack.amount; + netfuel = ByteBuffer.allocate(8).putInt(fuel).array(); + netmaxfuel = ByteBuffer.allocate(8).putInt(maxfuel).array(); + ++timer; + Iterator var2 = this.crafters.iterator(); + if (timer >= Long.MAX_VALUE - 1) + timer = 0; + while (true) { + do { + if (!var2.hasNext()) { + netfuel = anetfuel; + netmaxfuel = anetmaxfuel; + water = awater; + return; + } + ICrafting var1 = (ICrafting) var2.next(); + if (this.timer % 500 == 10 || this.water != awater) + var1.sendProgressBarUpdate(this, 0, water); + if (this.timer % 500 == 10 || netfuel != anetfuel) + for (int i = 0; i < netfuel.length; i++) { + var1.sendProgressBarUpdate(this, i + 1, netfuel[i]); + } + if (this.timer % 500 == 10 || netmaxfuel != anetmaxfuel) + for (int i = 0; i < netmaxfuel.length; i++) { + var1.sendProgressBarUpdate(this, i + 9, netmaxfuel[i]); + } + } while (this.timer % 500 != 10 && this.water != awater); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void updateProgressBar(int packetID, int valure) { + if (netfuel == null) + netfuel = new byte[8]; + if (netmaxfuel == null) + netmaxfuel = new byte[8]; + switch (packetID) { + case 0: { + water = valure; + this.getSlot(1).putStack(this.getSlot(1).getStack().setStackDisplayName(this.water + "L Water")); + break; + } + case 1: + netfuel[0] = (byte) valure; + break; + case 2: + netfuel[1] = (byte) valure; + break; + case 3: + netfuel[2] = (byte) valure; + break; + case 4: + netfuel[3] = (byte) valure; + break; + case 5: + netfuel[4] = (byte) valure; + break; + case 6: + netfuel[5] = (byte) valure; + break; + case 7: + netfuel[6] = (byte) valure; + break; + case 8: + netfuel[7] = (byte) valure; + break; + case 9: + netmaxfuel[0] = (byte) valure; + break; + case 10: + netmaxfuel[1] = (byte) valure; + break; + case 11: + netmaxfuel[2] = (byte) valure; + break; + case 12: + netmaxfuel[3] = (byte) valure; + break; + case 13: + netmaxfuel[4] = (byte) valure; + break; + case 14: + netmaxfuel[5] = (byte) valure; + break; + case 15: + netmaxfuel[6] = (byte) valure; + break; + case 16: + netmaxfuel[7] = (byte) valure; + break; + default: + break; + } + if (packetID > 0 && packetID < 9) + this.fuel = ByteBuffer.wrap(netfuel).getInt(); + if (packetID > 8 && packetID < 17) + this.maxfuel = ByteBuffer.wrap(netmaxfuel).getInt(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java index 0dec15b274..cba13261d0 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -329,6 +329,12 @@ public class BWRecipes { return false; } + public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, FluidStack aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { + if (sBiolab.addRecipe(new BioLabRecipe(true, new ItemStack[]{BioItemList.getPetriDish(null), aInput}, new ItemStack[]{BioItemList.getPetriDish(aOutput)}, null, aChances, new FluidStack[]{aFluidInputs}, new FluidStack[]{GT_Values.NF}, aDuration, aEUt, aSpecialValue)) != null) + return true; + return false; + } + @Deprecated public boolean addBioLabRecipeDNAExtraction(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[0], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java index 5027760ab7..1392184d13 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -259,7 +259,7 @@ public class BW_Util { } public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, int height, Block block, int dmg, int offset, boolean controllerLayer, boolean freeCorners, int aBaseCasingIndex) { - return check_layer(aBaseMetaTileEntity, radius, yLevel, height, block, dmg, offset, controllerLayer, freeCorners, true, block, dmg, true, aBaseCasingIndex); + return check_layer(aBaseMetaTileEntity, radius, yLevel, height, block, dmg, offset, controllerLayer, freeCorners, false, block, dmg, true, aBaseCasingIndex); } public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int radius, int yLevel, int height, Block block, int dmg, int offset, boolean controllerLayer, boolean insideCheck, Block inside, int dmginside, int aBaseCasingIndex) { |