• Recently Browsing

    No registered users viewing this page.

  • Posts

    • So im trying to render some fluid inside my tank but it doesnt render anything idk why, please I need some help with this here is the code package com.tigres810.testmod.tileentitys.renders; import org.lwjgl.opengl.GL11; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.tigres810.testmod.tileentitys.TileFluidTankBlock; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.AtlasTexture; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.fluid.Fluid; import net.minecraft.inventory.container.PlayerContainer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.vector.Matrix4f; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.FluidAttributes; import net.minecraftforge.fluids.FluidStack; @OnlyIn(Dist.CLIENT) public class RenderFluidTankBlock extends TileEntityRenderer<TileFluidTankBlock> { public static final float TANK_THICKNESS = 0.3f; public static final float TANK_HEIGHT = 0.2f; public static final float TANK_BOTTOM = 0.0f; public RenderFluidTankBlock(TileEntityRendererDispatcher rendererDispatcherIn) { super(rendererDispatcherIn); } private void add(IVertexBuilder renderer, MatrixStack stack, float x, float y, float z, float u, float v) { renderer.pos(stack.getLast().getMatrix(), x, y, z) .color(1.0f, 1.0f, 1.0f, 1.0f) .tex(u, v) .lightmap(0, 240) .normal(1, 0, 0) .endVertex(); } @Override public void render(TileFluidTankBlock tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { if(tileEntityIn == null || tileEntityIn.isRemoved()) return; FluidStack fluid = tileEntityIn.getTank().getFluid(); if (fluid == null) return; Fluid renderFluid = fluid.getFluid(); if (renderFluid == null) return; FluidAttributes attributes = renderFluid.getAttributes(); ResourceLocation fluidStill = attributes.getStillTexture(fluid); TextureAtlasSprite sprite = Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStill); IVertexBuilder builder = bufferIn.getBuffer(RenderType.getTranslucent()); float scale = (1.0f - TANK_THICKNESS/2 - TANK_THICKNESS) * fluid.getAmount() / (tileEntityIn.getTank().getCapacity()); matrixStackIn.push(); matrixStackIn.translate(tileEntityIn.getPos().getX()+0.5, tileEntityIn.getPos().getY()+1.01/16.0, tileEntityIn.getPos().getZ()+0.5); matrixStackIn.scale(0.25f, 10.8f/16.0f, 0.25f); float u1 = sprite.getMinU(); float v1 = sprite.getMinV(); float u2 = sprite.getMaxU(); float v2 = sprite.getMaxV(); int color = renderFluid.getAttributes().getColor(); float a = 1.0F; float r = (color >> 16 & 0xFF) / 255.0F; float g = (color >> 8 & 0xFF) / 255.0F; float b = (color & 0xFF) / 255.0F; add(builder, matrixStackIn, TANK_THICKNESS, scale + TANK_HEIGHT, TANK_THICKNESS, u1, v1); matrixStackIn.pop(); } } I got no idea why is not working, also im trying to render one side to test if it works later ill add the rest of the faces.
    • I am working on an entity that functions in a similar way to the arrow. its a projectile that flies in a straight line and gets stuck in blocks / entities. It renders as an item that is oriented in the way the projectile is going. This all works as expected, but sometimes when I summon my entity  it glitches around: The rotation yaw and pitch just randomly change to other values for like one render tick and then change back. I'm pretty sure Ive got all the partialTicks interpolation right, and the values for rotationyaw/pitch are correct at the end of the entity tick on both client and server. I have debugged that by logging the values. However, in my entityrenderer sometimes the rotation fields values have weird spikes for a single tick. This means that somethign happens in between the ticks that changes the value somehow and I have no clue what it is. Any ideas? //ENTITY RENDERER matrixStack.push(); matrixStack.rotate(Vector3f.YP.rotationDegrees(90 - MathHelper.lerp(partialTicks, entity.prevRotationYaw, entity.rotationYaw))); matrixStack.rotate(Vector3f.ZP.rotationDegrees(-45 - MathHelper.lerp(partialTicks, entity.prevRotationPitch, entity.rotationPitch))); ItemRenderer renderer = Minecraft.getInstance().getItemRenderer(); renderer.renderItem(new ItemStack(ModItems.MANA_SHARD.get()), TransformType.GROUND, lightlevel, OverlayTexture.NO_OVERLAY, matrixStack, buffer); matrixStack.pop(); super.render(entity, entityYaw, partialTicks, matrixStack, buffer, lightlevel);   //ENTITY TICK super.tick(); this.prevPosX = this.getPosX(); this.prevPosY = this.getPosY(); this.prevPosZ = this.getPosZ(); this.prevRotationPitch = this.rotationPitch; this.prevRotationYaw = this.rotationYaw; this.ticksAlive++; if (!inGround) { this.ticksInAir++; Vec3d motion = this.getMotion(); float f = this.isInWater() ? this.getMotionFactor() : 0.7F; double x = this.getPosX() + motion.x * f; double y = this.getPosY() + motion.y * f; double z = this.getPosZ() + motion.z * f; ProjectileHelper.rotateTowardsMovement(this, 0.2F); if (this.isInWater()) { for (int i = 0; i < 4; ++i) { this.world.addParticle(ParticleTypes.BUBBLE, x - motion.x * 0.25D, y - motion.y * 0.25D, z - motion.z * 0.25D, motion.x, motion.y, motion.z); } } Vec3d newMotion = motion.add(this.accelerationX, this.accelerationY, this.accelerationZ); this.setMotion(newMotion); this.setPosition(x, y, z);  
    • Do you just want your ContainerScreen to read the NBT for an item?  That should be automatically transmitted to the client container, assuming you have set the NBT properly.  Your ContainerScreen should be able to just read the tag for the ItemStack. Or do you mean - you want your screen to be able to modify the nbt for an item? If so - your Screen will need to send custom packets to the server.  Have a look at the vanilla code for Screens, how they drag ItemStacks from one slot to another.  Basically, the screen sends a packet back to the server saying "drag the ItemStack from slot X to slot Y". In your case - your Screen will need to send a packet to the server that says "Change the NBT for the ItemStack in slot X for the currently open container", and you will need a packet handler on the server that makes the corresponding modification to the ItemStack in the Server Container.   -TGG    
    • Hi DieSieben That diagram is for an ItemStack which has an inventory of other ItemStacks (held in an Item_Handler_Capability)    There is no client side link between the Client ItemStack and the inventory contents of the Client Container.  If I recall correctly the Client ItemStack doesn't even get a copy of the server's ItemStackHandler unless you manually synchronise it.     The equivalent diagram for TileEntity might be a bit clearer what the intent is, ie that the client side container is initialised with empty inventory that is not linked to the client-side inventory.  The synchronisation is always from server container to server inventory then to client inventory.  If you try to link the client-side container to the client-side inventory, you get two different synchronisation methods fighting with each other (quite noticeable when there is a bit of lag).   -TGG    
    • I have the exact same problem. Are there any workarounds?
  • Topics

  • Who's Online (See full list)