Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Awesome_Spider

Forge Modder
  • Posts

    892
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Awesome_Spider

  1. Yes, I'm pretty sure. The TileEntity would have a model where different parts rotate depending on which inventory around the TileEntity it is interacting with, if that makes sense. Code in an ItemStack (last topic) would tell it where to move/which inventory to interact with. I'm thinking this might be way more complex than a IBakedModel or something along those lines could provide.

  2. I am working on a robot mod that adds robots that interact with nearby inventories. I am kind of stuck with this however. What I would like to do is have the players program the behaviors of the robots into an item (using a drag and drop interface maybe) that could be dropped into the robot's (or controller of a multiblock) gui. I am trying to wrap my head around how I would implement this. Any ideas?

     

    I was thinking I could save Json to the nbt of an item stack that would have instructions for what the robot would do, but I'm unsure if this would be feasable. Any suggestions are appreciated.

  3. I know you are probably working really hard on fixing stuff already, but when you get around to it, there is another issue. When I try to go to the second page of a thread, it shows a loading symbol that never actually loads. This isn't a big problem though, as I can reload the page and it loads just fine.

  4. 10 minutes ago, GregoriMarow said:

    During early testing of a demomod I used "Examplemod" as the mod id, and encountered a minecraft forge warning that lower case modnames will be enforce at 1.12+.

    This has been enforced as long as I have been modding, and I have been modding since 1.7.10. It didn't just start now, just so you know.

  5. I'm trying to build a hud to display information to the player. It's rendering really wierd, in that it is binding a texture to the vanilla lives, xp meter, food meter, etc. What am I doing wrong?

     

    Here is an image of what it's doing:

    Spoiler

    JLQe112.png

     

    Here is my code:

    Spoiler

    Event that is called to render my Hud:

    
    @SubscribeEvent
        public void onGameOverlay(RenderGameOverlayEvent event) {
            FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
            ScaledResolution scaledResolution = event.getResolution();
    
            HudRenderer.doRender(scaledResolution, fontRenderer);
        }

     

    HudRenderer:

    
    public class HudRenderer {
        private static float hydration = EnviroSettings.startingHydration;
        private static float temperature = EnviroSettings.startingTemperature;
        private static float sanity = EnviroSettings.startingSanity;
        private static float airQuality = EnviroSettings.startingAirQuality;
    
        public static void updateStatusBar(int id, float value) {
            if(id > 3) {
                throw new FieldIdOutOfBoundsException("ID must be between 0 and 3 inclusive.");
            }
    
            hydration = id == 0 ? value : hydration;
            temperature = id == 1 ? value : temperature;
            sanity = id == 2 ? value : sanity;
            airQuality = id == 3 ? value : airQuality;
        }
    
        public static float getField(int id) {
            if(id > 3) {
                throw new FieldIdOutOfBoundsException("ID must be between 0 and 3 inclusive.");
            }
    
            return id == 0 ? hydration : id == 1 ? temperature : id == 2 ? sanity : id == 3 ? airQuality : 0;
        }
    
        public static void doRender(ScaledResolution scaledResolution, FontRenderer fontRenderer) {
            TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    
            float width = scaledResolution.getScaledWidth();
            float height = scaledResolution.getScaledHeight();
    
            //Hydration
            textureManager.bindTexture(new ResourceLocation(EnviroMineRevived.ModId + ":textures/gui/status_gui.png"));
            RenderUtil.drawTexturedModalRect(5, height - 30, 0, 1, 61, 6);
    
            textureManager.bindTexture(new ResourceLocation(EnviroMineRevived.ModId + ":textures/gui/status_gui.png"));
            RenderUtil.drawTexturedModalRect(5, height - 30, 64, 1, getScaledHydration(61, (int)EnviroSettings.maxHydration, (int)hydration), 6);
    
            textureManager.bindTexture(new ResourceLocation(EnviroMineRevived.ModId + ":textures/gui/status_gui.png"));
            RenderUtil.drawTexturedModalRect(4, height - 31, 32, 1, 40, 63);
        }
    
        public static int getScaledHydration(int pixels, int totalHydration, int hydration) {
            return hydration / totalHydration * pixels;
        }
    }

     

    RenderUtil (partially taken from a Gui class):

    
    public class RenderUtil {
    
        protected static float zLevel;
    
        /**
         * Draws a textured rectangle at the current z-value.
         *
         * Taken from Gui class in vanilla source.
         */
        public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height)
        {
            float f = 0.00390625F;
            float f1 = 0.00390625F;
            Tessellator tessellator = Tessellator.getInstance();
            VertexBuffer vertexbuffer = tessellator.getBuffer();
            vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
            vertexbuffer.pos((double)(x + 0), (double)(y + height), (double)zLevel).tex((double)((float)(textureX + 0) * 0.00390625F), (double)((float)(textureY + height) * 0.00390625F)).endVertex();
            vertexbuffer.pos((double)(x + width), (double)(y + height), (double)zLevel).tex((double)((float)(textureX + width) * 0.00390625F), (double)((float)(textureY + height) * 0.00390625F)).endVertex();
            vertexbuffer.pos((double)(x + width), (double)(y + 0), (double)zLevel).tex((double)((float)(textureX + width) * 0.00390625F), (double)((float)(textureY + 0) * 0.00390625F)).endVertex();
            vertexbuffer.pos((double)(x + 0), (double)(y + 0), (double)zLevel).tex((double)((float)(textureX + 0) * 0.00390625F), (double)((float)(textureY + 0) * 0.00390625F)).endVertex();
            tessellator.draw();
        }
    
        /**
         * Draws a textured rectangle using the texture currently bound to the TextureManager
         *
         * Taken from Gui class in vanilla source.
         */
        public static void drawTexturedModalRect(float xCoord, float yCoord, int minU, int minV, int maxU, int maxV)
        {
            float f = 0.00390625F;
            float f1 = 0.00390625F;
            Tessellator tessellator = Tessellator.getInstance();
            VertexBuffer vertexbuffer = tessellator.getBuffer();
            vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
            vertexbuffer.pos((double)(xCoord + 0.0F), (double)(yCoord + (float)maxV), (double)zLevel).tex((double)((float)(minU + 0) * 0.00390625F), (double)((float)(minV + maxV) * 0.00390625F)).endVertex();
            vertexbuffer.pos((double)(xCoord + (float)maxU), (double)(yCoord + (float)maxV), (double)zLevel).tex((double)((float)(minU + maxU) * 0.00390625F), (double)((float)(minV + maxV) * 0.00390625F)).endVertex();
            vertexbuffer.pos((double)(xCoord + (float)maxU), (double)(yCoord + 0.0F), (double)zLevel).tex((double)((float)(minU + maxU) * 0.00390625F), (double)((float)(minV + 0) * 0.00390625F)).endVertex();
            vertexbuffer.pos((double)(xCoord + 0.0F), (double)(yCoord + 0.0F), (double)zLevel).tex((double)((float)(minU + 0) * 0.00390625F), (double)((float)(minV + 0) * 0.00390625F)).endVertex();
            tessellator.draw();
        }
    
        /**
         * Draws a texture rectangle using the texture currently bound to the TextureManager
         *
         * Taken from Gui class in vanilla source.
         */
        public static void drawTexturedModalRect(int xCoord, int yCoord, TextureAtlasSprite textureSprite, int widthIn, int heightIn)
        {
            Tessellator tessellator = Tessellator.getInstance();
            VertexBuffer vertexbuffer = tessellator.getBuffer();
            vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
            vertexbuffer.pos((double)(xCoord + 0), (double)(yCoord + heightIn), (double)zLevel).tex((double)textureSprite.getMinU(), (double)textureSprite.getMaxV()).endVertex();
            vertexbuffer.pos((double)(xCoord + widthIn), (double)(yCoord + heightIn), (double)zLevel).tex((double)textureSprite.getMaxU(), (double)textureSprite.getMaxV()).endVertex();
            vertexbuffer.pos((double)(xCoord + widthIn), (double)(yCoord + 0), (double)zLevel).tex((double)textureSprite.getMaxU(), (double)textureSprite.getMinV()).endVertex();
            vertexbuffer.pos((double)(xCoord + 0), (double)(yCoord + 0), (double)zLevel).tex((double)textureSprite.getMinU(), (double)textureSprite.getMinV()).endVertex();
            tessellator.draw();
        }
    }

     

     

  6. I have created a custom capability using the documentation that I store in the player.

     

    My capability code is in the following package in my mod:

    https://github.com/WiseOwl5/EnviroMineRevived/tree/master/src/main/java/wiseowl5/EnviroMineRevived/Capability

     

    I am having no trouble attaching it. But how would I get the capability data stored in the player? I know it is probably EntityPlayer#capabilities , but what do I do with that to manipulate my capability data?

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.