From 9fe3f693f1d6d015f45898818b7958b3a57a9f4a Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Fri, 26 Jul 2019 04:23:36 +0100 Subject: + Added config option to adjust ingame BGM delays. (Should be working) + Added a Pest Killer for quick removal of Butterflies and Bats. + Added Hydrogen Cyanide. % Replaced existing assets for the Bat King. % Replaced Bat King Logic, it's now an offensive mob. $ Fixed Bat King model scaling. --- .../gtPlusPlus/core/client/model/ModelBatKing.java | 120 +++++++++++++++++++++ .../core/client/renderer/RenderBatKing.java | 42 ++++---- 2 files changed, 142 insertions(+), 20 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/client/model/ModelBatKing.java (limited to 'src/Java/gtPlusPlus/core/client') diff --git a/src/Java/gtPlusPlus/core/client/model/ModelBatKing.java b/src/Java/gtPlusPlus/core/client/model/ModelBatKing.java new file mode 100644 index 0000000000..ac64dee26a --- /dev/null +++ b/src/Java/gtPlusPlus/core/client/model/ModelBatKing.java @@ -0,0 +1,120 @@ +package gtPlusPlus.core.client.model; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.entity.monster.EntityBatKing; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.util.MathHelper; + +@SideOnly(Side.CLIENT) +public class ModelBatKing extends ModelBase +{ + private ModelRenderer batHead; + /** The body box of the bat model. */ + private ModelRenderer batBody; + /** The inner right wing box of the bat model. */ + private ModelRenderer batRightWing; + /** The inner left wing box of the bat model. */ + private ModelRenderer batLeftWing; + /** The outer right wing box of the bat model. */ + private ModelRenderer batOuterRightWing; + /** The outer left wing box of the bat model. */ + private ModelRenderer batOuterLeftWing; + + public ModelBatKing() + { + this.textureWidth = 64; + this.textureHeight = 64; + + this.batHead = new ModelRenderer(this, 0, 0); + this.batHead.addBox(-3.0F, -3.0F, -3.0F, 6, 6, 6); + ModelRenderer modelrenderer = new ModelRenderer(this, 24, 0); + modelrenderer.addBox(-4.0F, -6.0F, -2.0F, 3, 4, 1); + this.batHead.addChild(modelrenderer); + ModelRenderer modelrenderer1 = new ModelRenderer(this, 24, 0); + modelrenderer1.mirror = true; + modelrenderer1.addBox(1.0F, -6.0F, -2.0F, 3, 4, 1); + this.batHead.addChild(modelrenderer1); + this.batBody = new ModelRenderer(this, 0, 16); + this.batBody.addBox(-3.0F, 4.0F, -3.0F, 6, 12, 6); + this.batBody.setTextureOffset(0, 34).addBox(-5.0F, 16.0F, 0.0F, 10, 6, 1); + this.batRightWing = new ModelRenderer(this, 42, 0); + this.batRightWing.addBox(-12.0F, 1.0F, 1.5F, 10, 16, 1); + this.batOuterRightWing = new ModelRenderer(this, 24, 16); + this.batOuterRightWing.setRotationPoint(-12.0F, 1.0F, 1.5F); + this.batOuterRightWing.addBox(-8.0F, 1.0F, 0.0F, 8, 12, 1); + this.batLeftWing = new ModelRenderer(this, 42, 0); + this.batLeftWing.mirror = true; + this.batLeftWing.addBox(2.0F, 1.0F, 1.5F, 10, 16, 1); + this.batOuterLeftWing = new ModelRenderer(this, 24, 16); + this.batOuterLeftWing.mirror = true; + this.batOuterLeftWing.setRotationPoint(12.0F, 1.0F, 1.5F); + this.batOuterLeftWing.addBox(0.0F, 1.0F, 0.0F, 8, 12, 1); + this.batBody.addChild(this.batRightWing); + this.batBody.addChild(this.batLeftWing); + this.batRightWing.addChild(this.batOuterRightWing); + this.batLeftWing.addChild(this.batOuterLeftWing); + } + + /** + * not actually sure this is size, is not used as of now, but the model would be recreated if the value changed and + * it seems a good match for a bats size + */ + public int getBatSize() + { + return 72; + } + + /** + * Sets the models various rotation angles then renders the model. + */ + public void render(Entity p_78088_1_, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_) + { + EntityBatKing entitybat = (EntityBatKing)p_78088_1_; + float f6; + + if (entitybat.getIsBatHanging()) + { + f6 = (180F / (float)Math.PI); + this.batHead.rotateAngleX = p_78088_6_ / (180F / (float)Math.PI); + this.batHead.rotateAngleY = (float)Math.PI - p_78088_5_ / (180F / (float)Math.PI); + this.batHead.rotateAngleZ = (float)Math.PI; + this.batHead.setRotationPoint(0.0F, -2.0F, 0.0F); + this.batRightWing.setRotationPoint(-3.0F, 0.0F, 3.0F); + this.batLeftWing.setRotationPoint(3.0F, 0.0F, 3.0F); + this.batBody.rotateAngleX = (float)Math.PI; + this.batRightWing.rotateAngleX = -0.15707964F; + this.batRightWing.rotateAngleY = -((float)Math.PI * 2F / 5F); + this.batOuterRightWing.rotateAngleY = -1.7278761F; + this.batLeftWing.rotateAngleX = this.batRightWing.rotateAngleX; + this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY; + this.batOuterLeftWing.rotateAngleY = -this.batOuterRightWing.rotateAngleY; + } + else + { + f6 = (180F / (float)Math.PI); + this.batHead.rotateAngleX = p_78088_6_ / (180F / (float)Math.PI); + this.batHead.rotateAngleY = p_78088_5_ / (180F / (float)Math.PI); + this.batHead.rotateAngleZ = 0.0F; + this.batHead.setRotationPoint(0.0F, 0.0F, 0.0F); + this.batRightWing.setRotationPoint(0.0F, 0.0F, 0.0F); + this.batLeftWing.setRotationPoint(0.0F, 0.0F, 0.0F); + this.batBody.rotateAngleX = ((float)Math.PI / 4F) + MathHelper.cos(p_78088_4_ * 0.1F) * 0.15F; + this.batBody.rotateAngleY = 0.0F; + this.batRightWing.rotateAngleY = MathHelper.cos(p_78088_4_ * 1.3F) * (float)Math.PI * 0.25F; + this.batLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY; + this.batOuterRightWing.rotateAngleY = this.batRightWing.rotateAngleY * 0.5F; + this.batOuterLeftWing.rotateAngleY = -this.batRightWing.rotateAngleY * 0.5F; + } + + + GL11.glScalef(4, 4, 4); + this.batHead.render(p_78088_7_); + this.batBody.render(p_78088_7_); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderBatKing.java b/src/Java/gtPlusPlus/core/client/renderer/RenderBatKing.java index fb260eedeb..000badb80f 100644 --- a/src/Java/gtPlusPlus/core/client/renderer/RenderBatKing.java +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderBatKing.java @@ -1,21 +1,23 @@ package gtPlusPlus.core.client.renderer; +import org.lwjgl.opengl.GL11; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.model.ModelBat; +import gtPlusPlus.core.client.model.ModelBatKing; +import gtPlusPlus.core.entity.monster.EntityBatKing; +import gtPlusPlus.core.lib.CORE; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.passive.EntityBat; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class RenderBatKing extends RenderLiving { - private static final ResourceLocation batTextures = new ResourceLocation("textures/entity/bat.png"); + private static final ResourceLocation batTextures = new ResourceLocation(CORE.MODID+":"+"textures/entity/batKing.png"); /** * not actually sure this is size, is not used as of now, but the model would be @@ -24,8 +26,8 @@ public class RenderBatKing extends RenderLiving { private int renderedBatSize; public RenderBatKing() { - super(new ModelBat(), 1F); - this.renderedBatSize = ((ModelBat) this.mainModel).getBatSize(); + super(new ModelBatKing(), 0.7F); + this.renderedBatSize = (((ModelBatKing) this.mainModel).getBatSize()); } /** @@ -36,13 +38,13 @@ public class RenderBatKing extends RenderLiving { * func_76986_a(T entity, double d, double d1, double d2, float f, float f1). * But JAD is pre 1.5 so doesn't do that. */ - public void doRender(EntityBat p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, + public void doRender(EntityBatKing p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - int i = ((ModelBat) this.mainModel).getBatSize(); + int i = ((ModelBatKing) this.mainModel).getBatSize(); if (i != this.renderedBatSize) { this.renderedBatSize = i; - this.mainModel = new ModelBat(); + this.mainModel = new ModelBatKing(); } super.doRender((EntityLiving) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); @@ -52,7 +54,7 @@ public class RenderBatKing extends RenderLiving { * Returns the location of an entity's texture. Doesn't seem to be called unless * you call Render.bindEntityTexture. */ - protected ResourceLocation getEntityTexture(EntityBat p_110775_1_) { + protected ResourceLocation getEntityTexture(EntityBatKing p_110775_1_) { return batTextures; } @@ -60,18 +62,18 @@ public class RenderBatKing extends RenderLiving { * Allows the render to do any OpenGL state modifications necessary before the * model is rendered. Args: entityLiving, partialTickTime */ - protected void preRenderCallback(EntityBat p_77041_1_, float p_77041_2_) { + protected void preRenderCallback(EntityBatKing p_77041_1_, float p_77041_2_) { GL11.glScalef(0.35F, 0.35F, 0.35F); } /** * Sets a simple glTranslate on a LivingEntity. */ - protected void renderLivingAt(EntityBat p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_) { + protected void renderLivingAt(EntityBatKing p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_) { super.renderLivingAt(p_77039_1_, p_77039_2_, p_77039_4_, p_77039_6_); } - protected void rotateCorpse(EntityBat p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { + protected void rotateCorpse(EntityBatKing p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { if (!p_77043_1_.getIsBatHanging()) { GL11.glTranslatef(0.0F, MathHelper.cos(p_77043_2_ * 0.3F) * 0.1F, 0.0F); } else { @@ -91,7 +93,7 @@ public class RenderBatKing extends RenderLiving { */ public void doRender(EntityLiving p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - this.doRender((EntityBat) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + this.doRender((EntityBatKing) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } /** @@ -99,11 +101,11 @@ public class RenderBatKing extends RenderLiving { * model is rendered. Args: entityLiving, partialTickTime */ protected void preRenderCallback(EntityLivingBase p_77041_1_, float p_77041_2_) { - this.preRenderCallback((EntityBat) p_77041_1_, p_77041_2_); + this.preRenderCallback((EntityBatKing) p_77041_1_, p_77041_2_); } protected void rotateCorpse(EntityLivingBase p_77043_1_, float p_77043_2_, float p_77043_3_, float p_77043_4_) { - this.rotateCorpse((EntityBat) p_77043_1_, p_77043_2_, p_77043_3_, p_77043_4_); + this.rotateCorpse((EntityBatKing) p_77043_1_, p_77043_2_, p_77043_3_, p_77043_4_); } /** @@ -111,7 +113,7 @@ public class RenderBatKing extends RenderLiving { */ protected void renderLivingAt(EntityLivingBase p_77039_1_, double p_77039_2_, double p_77039_4_, double p_77039_6_) { - this.renderLivingAt((EntityBat) p_77039_1_, p_77039_2_, p_77039_4_, p_77039_6_); + this.renderLivingAt((EntityBatKing) p_77039_1_, p_77039_2_, p_77039_4_, p_77039_6_); } /** @@ -124,7 +126,7 @@ public class RenderBatKing extends RenderLiving { */ public void doRender(EntityLivingBase p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - this.doRender((EntityBat) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + this.doRender((EntityBatKing) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } /** @@ -132,7 +134,7 @@ public class RenderBatKing extends RenderLiving { * you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity p_110775_1_) { - return this.getEntityTexture((EntityBat) p_110775_1_); + return this.getEntityTexture((EntityBatKing) p_110775_1_); } /** @@ -145,6 +147,6 @@ public class RenderBatKing extends RenderLiving { */ public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { - this.doRender((EntityBat) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); + this.doRender((EntityBatKing) p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } } \ No newline at end of file -- cgit From ede55e818ba0312f061e154402cd82ec4603480d Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 14 Aug 2019 20:04:13 +0100 Subject: + Attempted to add custom covers for Ztones blocks. Should close #521. --- .../client/renderer/CustomItemBlockRenderer.java | 85 +++++++++ src/Java/gtPlusPlus/core/common/CommonProxy.java | 23 ++- .../core/item/bauble/FireProtectionBauble.java | 6 +- src/Java/gtPlusPlus/core/proxy/ClientProxy.java | 25 ++- .../xmod/gregtech/common/Meta_GT_Proxy.java | 2 + .../common/blocks/textures/TexturesGtBlock.java | 13 +- .../blocks/textures/TexturesGtCutomCovers.java | 32 ++++ .../xmod/gregtech/common/covers/CoverManager.java | 41 +++++ .../common/covers/GTPP_Cover_ToggleVisual.java | 123 +++++++++++++ .../common/covers/GTPP_Cover_VisualPlate.java | 67 ------- .../gregtech/common/items/MetaCustomCoverItem.java | 204 +++++++++++++++++++++ .../common/items/MetaGeneratedGregtechItems.java | 6 +- 12 files changed, 544 insertions(+), 83 deletions(-) create mode 100644 src/Java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_ToggleVisual.java delete mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_VisualPlate.java create mode 100644 src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java (limited to 'src/Java/gtPlusPlus/core/client') diff --git a/src/Java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java b/src/Java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java new file mode 100644 index 0000000000..f40357495a --- /dev/null +++ b/src/Java/gtPlusPlus/core/client/renderer/CustomItemBlockRenderer.java @@ -0,0 +1,85 @@ +package gtPlusPlus.core.client.renderer; + +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.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + + +/** + * Easy way of rendering an item which should look like a block. + * Borrowed. + * + * @author King Lemming + * + */ +public class CustomItemBlockRenderer implements IItemRenderer { + + public static CustomItemBlockRenderer instance = new CustomItemBlockRenderer(); + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return true; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + + double offset = -0.5; + if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + offset = 0; + } else if (type == ItemRenderType.ENTITY) { + GL11.glScalef(0.5F, 0.5F, 0.5F); + } + renderItemAsBlock((RenderBlocks) data[0], item, offset, offset, offset); + } + + public static void renderItemAsBlock(RenderBlocks renderer, ItemStack item, double translateX, double translateY, double translateZ) { + + renderTextureAsBlock(renderer, item.getIconIndex(), translateX, translateY, translateZ); + } + + public static void renderTextureAsBlock(RenderBlocks renderer, IIcon texture, double translateX, double translateY, double translateZ) { + + Tessellator tessellator = Tessellator.instance; + Block block = Blocks.stone; + + if (texture == null) { + return; + } + renderer.setRenderBoundsFromBlock(block); + GL11.glTranslated(translateX, translateY, translateZ); + tessellator.startDrawingQuads(); + + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, texture); + + tessellator.draw(); + } + +} diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index 03b0f944b7..23bd46d5b0 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -12,6 +12,8 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.api.objects.minecraft.ChunkManager; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.creative.AddToCreativeTab; @@ -51,12 +53,13 @@ import gtPlusPlus.plugin.villagers.block.BlockGenericSpawner; import gtPlusPlus.xmod.eio.handler.HandlerTooltip_EIO; import gtPlusPlus.xmod.galacticraft.handler.HandlerTooltip_GC; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.thermalfoundation.item.TF_Items; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.monster.EntityZombie; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.common.ForgeChunkManager; public class CommonProxy { @@ -258,7 +261,7 @@ public class CommonProxy { //Special mobs Support if (ReflectionUtils.doesClassExist("toast.specialMobs.entity.zombie.EntityBrutishZombie")) { - Class aBrutishZombie = ReflectionUtils.getClass("toast.specialMobs.entity.zombie.EntityBrutishZombie"); + Class aBrutishZombie = ReflectionUtils.getClass("toast.specialMobs.entity.zombie.EntityBrutishZombie"); ItemStack aFortune1 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); ItemStack aFortune2 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); ItemStack aFortune3 = ItemUtils.getEnchantedBook(Enchantment.fortune, 1); @@ -271,5 +274,21 @@ public class CommonProxy { } + + protected final AutoMap> mItemRenderMappings = new AutoMap>(); + + + public static void registerItemRendererGlobal(Item aItem, IItemRenderer aRenderer) { + GTplusplus.proxy.registerItemRenderer(aItem, aRenderer); + } + + public void registerItemRenderer(Item aItem, IItemRenderer aRenderer) { + if (Utils.isServer()) { + return; + } + else { + mItemRenderMappings.add(new Pair(aItem, aRenderer)); + } + } } diff --git a/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java b/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java index 3c7ea9d2c9..93a5a969f7 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/FireProtectionBauble.java @@ -37,7 +37,11 @@ public class FireProtectionBauble extends BaseBauble { } public static boolean setEntityImmuneToFire(Entity aEntity, boolean aImmune) { - return ReflectionUtils.setField(aEntity, isImmuneToFire, aImmune); + try { + return ReflectionUtils.setField(aEntity, isImmuneToFire, aImmune); + } + catch (Throwable t) {} + return false; } public FireProtectionBauble() { diff --git a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java index 71befe0a37..2372762e0d 100644 --- a/src/Java/gtPlusPlus/core/proxy/ClientProxy.java +++ b/src/Java/gtPlusPlus/core/proxy/ClientProxy.java @@ -1,9 +1,5 @@ package gtPlusPlus.core.proxy; -import java.net.URL; -import java.util.HashSet; -import java.util.Scanner; - import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Optional; @@ -17,6 +13,7 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.australia.entity.model.ModelBoar; import gtPlusPlus.australia.entity.model.ModelDingo; import gtPlusPlus.australia.entity.model.ModelOctopus; @@ -29,6 +26,7 @@ import gtPlusPlus.australia.entity.type.EntityBoar; import gtPlusPlus.australia.entity.type.EntityDingo; import gtPlusPlus.australia.entity.type.EntityOctopus; import gtPlusPlus.core.client.model.ModelGiantChicken; +import gtPlusPlus.core.client.renderer.CustomItemBlockRenderer; import gtPlusPlus.core.client.renderer.CustomOreBlockRenderer; import gtPlusPlus.core.client.renderer.RenderBatKing; import gtPlusPlus.core.client.renderer.RenderDecayChest; @@ -61,11 +59,13 @@ import gtPlusPlus.core.util.minecraft.particles.EntityParticleFXMysterious; import gtPlusPlus.xmod.gregtech.common.render.GTPP_CapeRenderer; import gtPlusPlus.xmod.gregtech.common.render.GTPP_Render_MachineBlock; import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelBat; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.entity.RenderFireball; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.entity.Entity; +import net.minecraft.item.Item; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxy extends CommonProxy implements Runnable{ @@ -113,6 +113,7 @@ public class ClientProxy extends CommonProxy implements Runnable{ * Custom Block Renderers */ new CustomOreBlockRenderer(); + new CustomItemBlockRenderer(); new GTPP_Render_MachineBlock(); super.init(e); @@ -164,6 +165,20 @@ public class ClientProxy extends CommonProxy implements Runnable{ RenderingRegistry.registerEntityRenderingHandler(EntityBoar.class, new RenderBoar(new ModelBoar(), new ModelBoar(0.5F), 0.7F)); RenderingRegistry.registerEntityRenderingHandler(EntityDingo.class, new RenderDingo(new ModelDingo(), new ModelDingo(), 0.5F)); RenderingRegistry.registerEntityRenderingHandler(EntityOctopus.class, new RenderOctopus(new ModelOctopus(), 0.7F)); + + + + + + + + /** + * Items + */ + for (Pair sItemRenderMappings : mItemRenderMappings) { + MinecraftForgeClient.registerItemRenderer(sItemRenderMappings.getKey(), sItemRenderMappings.getValue()); + } + } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 61c563d7c7..629c584f70 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -38,6 +38,7 @@ import gtPlusPlus.core.util.minecraft.MaterialUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.BaseCustomTileEntity; import gtPlusPlus.xmod.gregtech.api.metatileentity.custom.power.BaseCustomPower_MTE; +import gtPlusPlus.xmod.gregtech.common.covers.CoverManager; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -106,6 +107,7 @@ public class Meta_GT_Proxy { GT_Log.out.println("GT++ Mod: Registering the BaseMetaTileEntity."); GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntity_GTPP"); GameRegistry.registerTileEntity(tBaseMetaTileEntity2.getClass(), "BaseMetaTileEntity_GTPP2"); + CoverManager.generateCustomCovers(); } public void init() { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java index aaacbcd3a0..aed50ebae8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java @@ -30,9 +30,15 @@ public class TexturesGtBlock { public static class CustomIcon implements IIconContainer, Runnable { protected IIcon mIcon; protected String mIconName; + protected String mModID; public CustomIcon(final String aIconName) { + this(CORE.MODID, aIconName); + } + + public CustomIcon(final String aModID, final String aIconName) { this.mIconName = aIconName; + this.mModID = aModID; mCustomiconMap.put(this); Logger.WARNING("Constructing a Custom Texture. " + this.mIconName); GregTech_API.sGTBlockIconload.add(this); @@ -50,7 +56,7 @@ public class TexturesGtBlock { @Override public void run() { - this.mIcon = GregTech_API.sBlockIcons.registerIcon(CORE.MODID + ":" + this.mIconName); + this.mIcon = GregTech_API.sBlockIcons.registerIcon(this.mModID + ":" + this.mIconName); Logger.WARNING("FIND ME _ Processing texture: "+this.getTextureFile().getResourcePath()); } @@ -555,10 +561,7 @@ public class TexturesGtBlock { - public static Object Casing_Material_Turbine; - - - + public static Object Casing_Material_Turbine; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java new file mode 100644 index 0000000000..cc5cf3d55e --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtCutomCovers.java @@ -0,0 +1,32 @@ +package gtPlusPlus.xmod.gregtech.common.blocks.textures; + +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; + +public class TexturesGtCutomCovers { + + public static final CustomIcon[] TEXTURE_ZTONES_AGON = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_ISZM = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_KORP = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_JELT = new CustomIcon[16]; + public static final CustomIcon[] TEXTURE_ZTONES_BITT = new CustomIcon[16]; + + public static void init() { + generateZTones(); + } + + private static void generateZTones() { + // ZTONES + String[] aZtoneCoverTextureNames = new String[] { "agon", "iszm", "korp", "jelt", "bitt" }; + int aArrayIndex = 0; + CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, + TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT }; + + for (CustomIcon[] t : aArrays) { + for (int s = 0; s < 16; s++) { + t[s] = new CustomIcon("Ztones", "sets/" + aZtoneCoverTextureNames[aArrayIndex] + "/"+aZtoneCoverTextureNames[aArrayIndex]+"_ (" + s + ")"); + } + aArrayIndex++; + } + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java new file mode 100644 index 0000000000..b412e0fe60 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/CoverManager.java @@ -0,0 +1,41 @@ +package gtPlusPlus.xmod.gregtech.common.covers; + +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_AGON; +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_BITT; +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_ISZM; +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_JELT; +import static gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers.TEXTURE_ZTONES_KORP; + +import cpw.mods.fml.common.Loader; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtCutomCovers; +import gtPlusPlus.xmod.gregtech.common.items.MetaCustomCoverItem; + +public class CoverManager { + + //ZTones + public static MetaCustomCoverItem Cover_Agon; + public static MetaCustomCoverItem Cover_Iszm; + public static MetaCustomCoverItem Cover_Korp; + public static MetaCustomCoverItem Cover_Jelt; + public static MetaCustomCoverItem Cover_Bitt; + + + public static void generateCustomCovers() { + + // init textures + TexturesGtCutomCovers.init(); + + if (Loader.isModLoaded("Ztones")) { + String[] aZtoneCoverTextureNames = new String[] { "agon", "iszm", "korp", "jelt", "bitt" }; + MetaCustomCoverItem[] aZtoneCoverItems = new MetaCustomCoverItem[] { Cover_Agon, Cover_Iszm, Cover_Korp, Cover_Jelt, Cover_Bitt}; + CustomIcon[][] aArrays = new CustomIcon[][] { TEXTURE_ZTONES_AGON, TEXTURE_ZTONES_ISZM, TEXTURE_ZTONES_KORP, TEXTURE_ZTONES_JELT, TEXTURE_ZTONES_BITT }; + for (int y=0;y sConnectionStateForEntityMap = new ConcurrentHashMap(); + private static final Map sPrefixMap = new ConcurrentHashMap(); + + public static String generateUniqueKey(byte aSide, ICoverable aEntity) { + try { + BlockPos aPos = new BlockPos(aEntity.getIGregTechTileEntity(aEntity.getXCoord(), aEntity.getYCoord(), aEntity.getZCoord())); + ForgeDirection aDir = ForgeDirection.getOrientation(aSide); + String s = aEntity.getInventoryName()+"."+aPos.getUniqueIdentifier()+aDir.name(); + return s; + } + catch (Throwable t) {} + XSTR x = new XSTR(); + return "ERROR."+x.getSeed()+x.hashCode()+x.nextDouble()+".ID"; + } + + public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + return true; + } + + public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + return aCoverVariable; + } + + public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aSide, aTileEntity); + } + + public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aSide, aTileEntity); + } + + public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return getConnectionState(aSide, aTileEntity); + } + + public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { + return getConnectionState(aSide, aTileEntity); + } + + public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return getConnectionState(aSide, aTileEntity); + } + + public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { + return getConnectionState(aSide, aTileEntity); + } + + public String getDescription(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return this.trans("756", "Connectable: ") + getConnectionState(aSide, aTileEntity); + } + + public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 0; + } + + @Override + public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + long aTimer) { + return aCoverVariable; + } + + @Override + public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aSide, aTileEntity); + } + + @Override + public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return getConnectionState(aSide, aTileEntity); + } + + @Override + public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return super.alwaysLookConnected(aSide, aCoverID, aCoverVariable, aTileEntity); + } + + @Override + public byte getRedstoneInput(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity) { + if (!getConnectionState(aSide, aTileEntity)) { + return 0; + } + return super.getRedstoneInput(aSide, aInputRedstone, aCoverID, aCoverVariable, aTileEntity); + } + + @Override + public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) { + String aKey = generateUniqueKey(aSide, aTileEntity); + sPrefixMap.put(aKey, aCover.getUnlocalizedName()); + sConnectionStateForEntityMap.put(aKey, MetaCustomCoverItem.getCoverConnections(aCover)); + super.placeCover(aSide, aCover, aTileEntity); + } + + @Override + public boolean onCoverRemoval(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + boolean aForced) { + sConnectionStateForEntityMap.remove(generateUniqueKey(aSide, aTileEntity)); + return true; + } + + public static boolean getConnectionState(byte aSide, ICoverable aTile) { + return sConnectionStateForEntityMap.get(generateUniqueKey(aSide, aTile)); + } +} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_VisualPlate.java b/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_VisualPlate.java deleted file mode 100644 index 7d2ed2c21a..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/covers/GTPP_Cover_VisualPlate.java +++ /dev/null @@ -1,67 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.covers; - -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.util.GT_CoverBehavior; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.fluids.Fluid; - -public class GTPP_Cover_VisualPlate extends GT_CoverBehavior { - - public GTPP_Cover_VisualPlate() { - } - - public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - long aTimer) { - return aCoverVariable; - } - - public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - return aCoverVariable; - } - - public boolean onCoverRightclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, - EntityPlayer aPlayer, float aX, float aY, float aZ) { - return true; - } - - public boolean letsRedstoneGoIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return false; - } - - public boolean letsRedstoneGoOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return false; - } - - public boolean letsEnergyIn(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return false; - } - - public boolean letsEnergyOut(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return false; - } - - public boolean letsFluidIn(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return false; - } - - public boolean letsFluidOut(byte aSide, int aCoverID, int aCoverVariable, Fluid aFluid, ICoverable aTileEntity) { - return false; - } - - public boolean letsItemsIn(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return false; - } - - public boolean letsItemsOut(byte aSide, int aCoverID, int aCoverVariable, int aSlot, ICoverable aTileEntity) { - return false; - } - - public boolean alwaysLookConnected(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return false; - } - - public int getTickRate(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { - return 0; - } -} \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java new file mode 100644 index 0000000000..6075261254 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaCustomCoverItem.java @@ -0,0 +1,204 @@ +package gtPlusPlus.xmod.gregtech.common.items; + +import java.util.List; + +import cofh.core.render.IconRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.GregTech_API; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GT_MultiTexture; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.client.renderer.CustomItemBlockRenderer; +import gtPlusPlus.core.common.CommonProxy; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.sys.KeyboardUtils; +import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; +import gtPlusPlus.xmod.gregtech.common.covers.GTPP_Cover_ToggleVisual; +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.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class MetaCustomCoverItem extends Item { + + private final IIcon[] icons; + private final String mModID; + private final String mTextureSetName; + private final CustomIcon[] mTextures; + + public MetaCustomCoverItem(String aModId, int aTextureCount, String aTextureSetName, CustomIcon[] aTextures) { + super(); + icons = new IIcon[aTextureCount]; + mModID = aModId; + mTextureSetName = aTextureSetName; + mTextures = aTextures; + this.setHasSubtypes(true); + String unlocalizedName = "itemCustomMetaCover." + mModID + "." + mTextureSetName + "." + aTextureCount; + this.setUnlocalizedName(unlocalizedName); + this.setCreativeTab(AddToCreativeTab.tabMisc); + this.setMaxStackSize(1); + GameRegistry.registerItem(this, unlocalizedName); + registerCover(); + Logger.INFO("[Covers] Generated Custom covers for "+mModID+" using "+aTextureCount+" textures from "+mTextureSetName+"."); + } + + private final void registerCover() { + //CommonProxy.registerItemRendererGlobal(this, new CustomItemBlockRenderer()); + for (int i=0;i