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 | |
| 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')
28 files changed, 1047 insertions, 10 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: + |
