Jump to content

JeanMiecraft

Members
  • Posts

    16
  • Joined

  • Last visited

Posts posted by JeanMiecraft

  1. package net.mymod.entities.render;
    
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.renderer.GlStateManager;
    import net.minecraft.client.renderer.Tessellator;
    import net.minecraft.client.renderer.VertexBuffer;
    import net.minecraft.client.renderer.entity.Render;
    import net.minecraft.client.renderer.entity.RenderManager;
    import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
    import net.minecraft.entity.projectile.EntityFishHook;
    import net.minecraft.util.EnumHandSide;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.math.MathHelper;
    import net.minecraft.util.math.Vec3d;
    import net.mymod.Minecraft_mod;
    import net.mymod.entities.EntityHook;
    
    public class RendeHook extends Render<EntityHook>
    {
        private static final ResourceLocation HOOK_PARTICLES = new ResourceLocation(Minecraft_mod.MOD_ID + ":textures/particles/particles.png");
    
        public RenderHook(RenderManager renderManagerIn)
        {
            super(renderManagerIn);
        }
    
        public void doRender(EntityHook entity, double x, double y, double z, float entityYaw, float partialTicks)
        {
            GlStateManager.pushMatrix();
            GlStateManager.translate((float)x, (float)y, (float)z);
            GlStateManager.enableRescaleNormal();
            GlStateManager.scale(0.5F, 0.5F, 0.5F);
            this.bindEntityTexture(entity);
            Tessellator tessellator = Tessellator.getInstance();
            VertexBuffer vertexbuffer = tessellator.getBuffer();
            int i = 1;
            int j = 2;
            float f = 0.0625F;
            float f1 = 0.125F;
            float f2 = 0.125F;
            float f3 = 0.1875F;
            float f4 = 1.0F;
            float f5 = 0.5F;
            float f6 = 0.5F;
            GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
            GlStateManager.rotate((float)(this.renderManager.options.thirdPersonView == 2 ? -1 : 1) * -this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    
            if (this.renderOutlines)
            {
                GlStateManager.enableColorMaterial();
                GlStateManager.enableOutlineMode(this.getTeamColor(entity));
            }
    
            vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL);
            vertexbuffer.pos(-0.5D, -0.5D, 0.0D).tex(0.0625D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex();
            vertexbuffer.pos(0.5D, -0.5D, 0.0D).tex(0.125D, 0.1875D).normal(0.0F, 1.0F, 0.0F).endVertex();
            vertexbuffer.pos(0.5D, 0.5D, 0.0D).tex(0.125D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex();
            vertexbuffer.pos(-0.5D, 0.5D, 0.0D).tex(0.0625D, 0.125D).normal(0.0F, 1.0F, 0.0F).endVertex();
            tessellator.draw();
    
            if (this.renderOutlines)
            {
                GlStateManager.disableOutlineMode();
                GlStateManager.disableColorMaterial();
            }
    
            GlStateManager.disableRescaleNormal();
            GlStateManager.popMatrix();
    
            if (entity.angler != null && !this.renderOutlines)
            {
                int k = entity.angler.getPrimaryHand() == EnumHandSide.RIGHT ? 1 : -1;
                float f7 = entity.angler.getSwingProgress(partialTicks);
                float f8 = MathHelper.sin(MathHelper.sqrt_float(f7) * (float)Math.PI);
                float f9 = (entity.angler.prevRenderYawOffset + (entity.angler.renderYawOffset - entity.angler.prevRenderYawOffset) * partialTicks) * 0.017453292F;
                double d0 = (double)MathHelper.sin(f9);
                double d1 = (double)MathHelper.cos(f9);
                double d2 = (double)k * 0.35D;
                double d3 = 0.8D;
                double d4;
                double d5;
                double d6;
                double d7;
    
                if ((this.renderManager.options == null || this.renderManager.options.thirdPersonView <= 0) && entity.angler == Minecraft.getMinecraft().thePlayer)
                {
                    Vec3d vec3d = new Vec3d((double)k * -0.36D, -0.05D, 0.4D);
                    vec3d = vec3d.rotatePitch(-(entity.angler.prevRotationPitch + (entity.angler.rotationPitch - entity.angler.prevRotationPitch) * partialTicks) * 0.017453292F);
                    vec3d = vec3d.rotateYaw(-(entity.angler.prevRotationYaw + (entity.angler.rotationYaw - entity.angler.prevRotationYaw) * partialTicks) * 0.017453292F);
                    vec3d = vec3d.rotateYaw(f8 * 0.5F);
                    vec3d = vec3d.rotatePitch(-f8 * 0.7F);
                    d4 = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks + vec3d.xCoord;
                    d5 = entity.angler.prevPosY + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks + vec3d.yCoord;
                    d6 = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks + vec3d.zCoord;
                    d7 = (double)entity.angler.getEyeHeight();
                }
                else
                {
                    d4 = entity.angler.prevPosX + (entity.angler.posX - entity.angler.prevPosX) * (double)partialTicks - d1 * d2 - d0 * 0.8D;
                    d5 = entity.angler.prevPosY + (double)entity.angler.getEyeHeight() + (entity.angler.posY - entity.angler.prevPosY) * (double)partialTicks - 0.45D;
                    d6 = entity.angler.prevPosZ + (entity.angler.posZ - entity.angler.prevPosZ) * (double)partialTicks - d0 * d2 + d1 * 0.8D;
                    d7 = entity.angler.isSneaking() ? -0.1875D : 0.0D;
                }
    
                double d13 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTicks;
                double d8 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTicks + 0.25D;
                double d9 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTicks;
                double d10 = (double)((float)(d4 - d13));
                double d11 = (double)((float)(d5 - d8)) + d7;
                double d12 = (double)((float)(d6 - d9));
                GlStateManager.disableTexture2D();
                GlStateManager.disableLighting();
                vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
                int l = 16;
    
                for (int i1 = 0; i1 <= 16; ++i1)
                {
                    float f10 = (float)i1 / 16.0F;
                    vertexbuffer.pos(x + d10 * (double)f10, y + d11 * (double)(f10 * f10 + f10) * 0.5D + 0.25D, z + d12 * (double)f10).color(0, 0, 0, 255).endVertex();
                }
    
                tessellator.draw();
                GlStateManager.enableLighting();
                GlStateManager.enableTexture2D();
                super.doRender(entity, x, y, z, entityYaw, partialTicks);
            }
        }
    
        protected ResourceLocation getEntityTexture(EntityHook entity)
        {
            return HOOK_PARTICLES;
        }
    }

    Hello, this is my code for the render!

    - JM.

  2. In your ClientProxy, you can replace by that:

        @Override
        public void registerFluid(Block block, String name) 
        {
            final ModelResourceLocation location = new ModelResourceLocation(MOD_ID + ":" + name, "fluid");
    
            ModelLoader.setCustomStateMapper(block, new StateMapperBase()
            {
                @Override
                protected ModelResourceLocation getModelResourceLocation(IBlockState state)
                {
                    return location;
                }
            });
        }

     

  3. 23 hours ago, TheMario said:

    You speak about the movement of water but it is the push if the liquid flow. I do not understand the relation with the swimming.

    No, it is the swimming... The problem maintaining, it is to apply this method when the entity jumps or if the player presses the space key...

  4. 7 minutes ago, Draco18s said:

    That is not what that does.

    If you change that value, it means the entity can not swim in anything. And again, the concept of "swimming" as far as Minecraft is concerned is Material.WATER and only Material.WATER

    We can "swim" in lava too. 

    Okay, I understand... but it's possible to recreate with a event the swimming effect and the entity can move?

    I want my custom material because with the Material.WATER or Material.LAVA, there are secondary effects... :/

    Thank you for your help!

  5. Okay, hum... in my fluid I use:

        public static void registry() 
        {
            ClassMod.FLUID = Fluid.instance;
            FluidRegistry.registerFluid(ClassMod.FLUID);
            ClassMod.FLUID_BLOCK = registerFluidBlock(fluid, new BlockFluid(ClassMod.FLUID), "fluid");
            
            ClassMod.FLUID_BUCKET = registerBucket((new ItemBucket(ClassMod.FLUID_BLOCK)).setContainerItem(Items.BUCKET), "bucket_fluid").setCreativeTab(CREATIVETAB);
        }
        
        private static Item registerBucket(Item setContainerItem, String name) 
        {
            setContainerItem.setUnlocalizedName(name);
            setContainerItem.setRegistryName(name);
    
            GameRegistry.register(setContainerItem);
            return setContainerItem;
        }
    
        public static Block registerFluidBlock(Fluid fluid, Block fluidBlock, String name)
        {
            Block block = GameRegistry.register(fluidBlock, new ResourceLocation(Minecraft_mod.MOD_ID, name));
            ClassMod.proxy.registerFluidBlockRendering(block, name);
            fluid.setBlock(fluidBlock);
            return block;
        }

    I do not really understand why this does not work in your code but it maybe due to incompatibility...

    You can use that, but I no sure if it will work...

     

    - JM

  6. Hello...

    Thank you for this answer!

    I see, this method is in the PathNavigate, in the PathNavigateGround and in the PathNavigateSwimmer... In the EntityAISwimming, I found that:

     

    ((PathNavigateGround)entitylivingIn.getNavigator()).setCanSwim(true);

     

    The "getNavigator" is register in the EntityLiving. It's possible to change the boolean value if an entity is in my fluid?

    If yes, where I can place this method?

  7. Hello, no this isn't resolved but with the help, I modified the respiration in the liquid.

     

    On 8/18/2018 at 5:47 PM, jabelar said:

    It's pretty tough actually, you have to sort of replace a lot of vanilla movement code. I actually submitted a PR to add ability for custom fluids to automatically do this, but the Forge gods are really busy with 1.13 right now. Some day...

     

    Here is how I did it using events though: http://jabelarminecraft.blogspot.com/p/minecraft-modding-custom-fluid-blocks.html

     

    It is intrusive and a lot of coding but it is possible to make your custom fluids behave mostly like vanilla.

     

     

    With that, I add to my fluid the finishes as the drown and the bubbles.

    Now the problem is the entity's motionY when she jump and the water or lava movement for the player.

    In the EntityLivingBase for the entity I compare the levitation potion but it's doesn't work...

    Can you tell me where is the class with the swimming for the entities and the player please.

    It's very important for me!

     

    - JM

  8. For the player, I use this:

     

    Minecraft mc = Minecraft.getMinecraft();
    boolean jump = mc.gameSettings.keyBindJump.isKeyDown();
     if (jump == true)
     {
         entity.motionY = 0.10000001192092896D;
     }

     

     

    The problem for the player is the speed, it's possible to slow down look like the slowness potion?

    And for the other EntityLiving, I don't know because if I use:

     

     entity.motionY = 0.10000001192092896D;
    


    It work, but they can't move. For example, if I have in my hand a carrot and the entity in my custom fluid is a pig. The motionX and motionZ equal 0;

    Thank you for your answer!

     

    - JM

  9. Hello, I create a custom Fluid with a custom material, but if I wrote this topic, it's because I don't know how create the swimming and the slow movements in the material. I sought in the EntityLivingBase in the moveEntityWithHeading and in the onLivingUpdate but it doesn't work. Can you help me for this problem?

    Thank you so much for your help!

     

    -JM

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.