Jump to content

Zeide

Members
  • Posts

    13
  • Joined

  • Last visited

Everything posted by Zeide

  1. Hello, First, here is the method that i'm using to render my fluid. public static void renderFluid(IRenderTypeBuffer buffer, MatrixStack stack, Fluid fluid, float size, World world, BlockPos pos, int light) { ILightReader lightReader = MinecraftForgeClient.getRegionRenderCache(world, pos); TextureAtlasSprite[] sprites = ForgeHooksClient.getFluidSprites(lightReader, pos, fluid.getDefaultState()); TextureAtlasSprite sprite = sprites[0]; // Get first sprite IVertexBuilder builder = buffer.getBuffer(RenderType.getTranslucent()); float[] color = getARGBFromInt(fluid.getFluid().getAttributes().getColor()); float minU = sprite.getMinU(); float maxU = sprite.getMaxU(); float minV = sprite.getMinV(); float maxV = sprite.getMaxV(); float m = (1 - size) / 2; builder.pos(stack.getLast().getMatrix(), m, 0, 1 - m).color(color[1], color[2], color[3], color[0]).tex(minU, maxV).lightmap(light).normal(1, 0, 0).endVertex(); builder.pos(stack.getLast().getMatrix(), 1 - m, 0, 1 - m).color(color[1], color[2], color[3], color[0]).tex(maxU, maxV).lightmap(light).normal(1, 0, 0).endVertex(); builder.pos(stack.getLast().getMatrix(), 1 - m, 0, m).color(color[1], color[2], color[3], color[0]).tex(maxU, minV).lightmap(light).normal(1, 0, 0).endVertex(); builder.pos(stack.getLast().getMatrix(), m, 0, m).color(color[1], color[2], color[3], color[0]).tex(minU, minV).lightmap(light).normal(1, 0, 0).endVertex(); } The rendering looks good but when I move the light is weird : I tried to hardcode lightmap value but the problem doesn't seem to come from here. Thanks for reading. Bye. EDIT : This was due to an other TileEntityRenderer using RenderHelper.enabledStandartItemLightning() and RenderHelper.disableStandartItemLightning()
  2. Hello, I tried to port my TileEntityRenderer from 1.12.2 to 1.15.2, i've almost rewrited all. Objectively, I want to render the fluid contained in the TileEntity First, here is the RenderType public static RenderType getPedestalRenderType(ResourceLocation resourceLocation) { RenderType.State state = RenderType.State.getBuilder() .texture(new TextureState(resourceLocation, false, false)) .cull(CULL_DISABLED) .lightmap(LIGHTMAP_DISABLED) .transparency(TRANSLUCENT_TRANSPARENCY) .build(true); return RenderType.makeType(SkillsStones.MOD_ID + ":pedestal_fluid", DefaultVertexFormats.POSITION_COLOR_TEX, GL11.GL_QUADS, 256, true, false, state); } And here is the TileEntityRenderer private static final float MIN_HEIGHT = 0.5625f; private static final float MAX_HEIGHT = 0.78125f; @Override public void render(TileEntityNaturalTotemPedestal tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) { Minecraft.getInstance().getProfiler().startSection("pedestalFluidRenderer"); float level = ((float) tileEntityIn.getFluidTank().getFluidAmount()) / (float) tileEntityIn.getFluidTank().getCapacity(); if(!(level > 0)) return; Fluid fluid = tileEntityIn.getFluidTank().getFluid().getFluid(); ResourceLocation resourceLocation; int color; if(fluid.getAttributes().getStillTexture() != null) { resourceLocation = fluid.getAttributes().getStillTexture(); color = getFluidColor(tileEntityIn.getWorld(), tileEntityIn.getPos(), fluid); } else if(fluid.getAttributes().getFlowingTexture() != null) { // In case that Still Texture don't exist resourceLocation = fluid.getAttributes().getFlowingTexture(); color = getFluidColor(tileEntityIn.getWorld(), tileEntityIn.getPos(), fluid); } else { // In case that no texture exist resourceLocation = Fluids.WATER.getAttributes().getStillTexture(); color = getFluidColor(tileEntityIn.getWorld(), tileEntityIn.getPos(), Fluids.WATER); } TextureAtlasSprite textureAtlasSprite = Minecraft.getInstance().getAtlasSpriteGetter(PlayerContainer.LOCATION_BLOCKS_TEXTURE).apply(resourceLocation); float uMin = textureAtlasSprite.getMinU(); float uMax = textureAtlasSprite.getMaxU(); float vMin = textureAtlasSprite.getMinV(); float vMax = textureAtlasSprite.getMaxV(); float a = 1.0F; float r = (color >> 16 & 0xFF) / 255.0F; float g = (color >> 8 & 0xFF) / 255.0F; float b = (color & 0xFF) / 255.0F; Matrix4f matrix4f = matrixStackIn.getLast().getMatrix(); float y = MIN_HEIGHT + (level) * (MAX_HEIGHT - MIN_HEIGHT); matrixStackIn.translate(0, y, 0); IVertexBuilder buffer = bufferIn.getBuffer(SSRenderType.getPedestalRenderType(resourceLocation)); buffer.pos(matrix4f, 0, 0, 0).color(r, g, b, a).tex(uMin, vMin).endVertex(); buffer.pos(matrix4f, 0, 0, 1).color(r, g, b, a).tex(uMin, vMax).endVertex(); buffer.pos(matrix4f, 1, 0, 1).color(r, g, b, a).tex(uMax, vMax).endVertex(); buffer.pos(matrix4f, 1, 0, 0).color(r, g, b, a).tex(uMax, vMin).endVertex(); Minecraft.getInstance().getProfiler().endSection(); } private static int getFluidColor(World world, BlockPos pos, Fluid fluid) { if(fluid.isEquivalentTo(Fluids.WATER)) { return BiomeColors.getWaterColor(world, pos); } return fluid.getAttributes().getColor(); } In this case, i've an error that tell me that texture doesn't exists (with an Java IO FileNotFound Exception) When i hardcode the ResourceLocation value to "minecraft:textures/block/water_still.png" It's working but the texture look weird (also, i've a weird smooth effect) I don't know how I can properly render my fluid. (Sorry for approximative English) Thanks a lot.
  3. i'm not sure, try if the tile entity persist.
  4. It's Minecraft Launcher but with Forge custom start menu.
  5. I don't really understand what is your problem x)
  6. Just launch Minecraft and you can find in your game profiles ""forge-yourforgeversion".
  7. Hello, Just go here : Minecraft Forge Click on "Show all versions" (large orange button at the bottom) and find your desired version. Bye.
  8. Hello, You can "delete" a block by changing his blockstate to AIR blockstate. world.setBlockState(blockPos, Blocks.AIR.getDefaultState()); Bye.
  9. Hello, Just override getRenderLayer() method in Block class and return BlockRenderLayer.CUTOUT. @Override public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; } Let me know if it's working. Bye.
  10. Hello, I had a problem while Minecraft is trying to generate my structure (located in : "data/skillsstones/structures/"), the game produce a Null Pointer Exception, here is the entire error : Here is my Structure Piece : Here is my Structure : Finally here is where i'm registering all : (I call initStructurePieceType() and createFeatures() in an other class) Last thing, i saw that Minecraft use the seed modifier : "165745296". So, I use it but I don't know what does it change. Also, I want to my structure be really really rare and i don't know how can I do this. Thanks a lot. EDIT : I forgot to provide BlockPos with my Structure Piece.
  11. Hello, Here is the model file of diamond sword { "parent": "item/handheld", "textures": { "layer0": "item/diamond_sword" } } So you need to change the "parent" value to "item/handheld" like any sword. Bye.
  12. Hello, I have a TE and I want to show the content of ItemStack Handler on client screen using RenderGameOverlay.Post event. My code is working good, but, when i'm trying to get ItemStackHandler capability, he is empty. All of these slots are empty, even though I put items inside. I think it's a syncing problem between Server and Client. HUDHandler class : package com.zeide.skillsstones.handler; import com.zeide.skillsstones.blocks.tileentities.TileEntityNaturalPedestal; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.item.ItemStack; import net.minecraft.profiler.Profiler; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.RayTraceResult; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import org.lwjgl.opengl.GL11; import java.util.ArrayList; import java.util.List; @Mod.EventBusSubscriber public class HUDHandler { private static void renderItemsInPedestal(ScaledResolution res, TileEntityNaturalPedestal tile) { Minecraft mc = Minecraft.getMinecraft(); Profiler profiler = mc.mcProfiler; profiler.startSection("itemsInPedestal"); int x = res.getScaledWidth() / 2 - 11; int y = res.getScaledHeight() / 2 + 10; GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.color(1F, 1F, 1F, 1F); IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); List<ItemStack> items = new ArrayList<>(); for(int i=0; i < itemHandler.getSlots(); i++){ if(itemHandler.getStackInSlot(i).isEmpty()) { items.add(itemHandler.getStackInSlot(i)); } } int r = x + ((items.size() * 10) - 10); RenderHelper.enableGUIStandardItemLighting(); for(ItemStack is : items) { mc.getRenderItem().renderItemAndEffectIntoGUI(is, r, y); System.out.println("Itemstack " + is.getDisplayName()); r -= 20; } RenderHelper.disableStandardItemLighting(); GlStateManager.disableLighting(); GlStateManager.disableBlend(); profiler.endSection(); } @SubscribeEvent public static void onDrawScreenPost(RenderGameOverlayEvent.Post event) { if(event.getType() == RenderGameOverlayEvent.ElementType.ALL) { if(Minecraft.getMinecraft().objectMouseOver != null) { RayTraceResult pos = Minecraft.getMinecraft().objectMouseOver; TileEntity tile = pos.typeOfHit == RayTraceResult.Type.BLOCK ? Minecraft.getMinecraft().world.getTileEntity(pos.getBlockPos()) : null; if(tile instanceof TileEntityNaturalPedestal) { renderItemsInPedestal(event.getResolution(), (TileEntityNaturalPedestal) tile); } } } } } Tile Entity class : package com.zeide.skillsstones.blocks.tileentities; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; import javax.annotation.Nullable; public class TileEntityNaturalPedestal extends TileEntity implements ICapabilityProvider { private ItemStackHandler inventory = new ItemStackHandler(8) { @Override protected void onContentsChanged(int slot) { markDirty(); } }; @Override public void readFromNBT(NBTTagCompound compound) { inventory.deserializeNBT(compound.getCompoundTag("inventory")); super.readFromNBT(compound); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setTag("inventory", inventory.serializeNBT()); return super.writeToNBT(compound); } @Override public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } @Nullable @Override public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T) inventory : super.getCapability(capability, facing); } @Override public NBTTagCompound getUpdateTag() { return this.writeToNBT(new NBTTagCompound()); } @Override public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(getPos(), 0, writeToNBT(new NBTTagCompound())); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { setPos(pkt.getPos()); readFromNBT(pkt.getNbtCompound()); } public void collideEntityItem(EntityItem item) { if(checkNextFreeSlot() != 100) { ItemStack copy = item.getItem().copy(); int count = copy.getCount(); if(count <= 1) { item.setDead(); copy.setCount(1); } else { item.getItem().setCount(item.getItem().getCount() - 1); copy.setCount(1); } inventory.insertItem(checkNextFreeSlot(), copy, false); } } public int checkNextFreeSlot() { for(int i=0; i < inventory.getSlots(); i++){ if(inventory.getStackInSlot(i).isEmpty()) { return i; } } return 100; } } Thanks for listening to me. Bye. EDIT: I'm just an idiot i forgot the "!" before itemStackHandler.getStackFromSlot(i).isEmpty()
  13. Hello, My Forge version : Forge 14.23.5.2768 First, my crafting JSON file is here : My item class is here : (I have this hammer, and three other similar classes for Iron hammer, diamond and emerald.) And i register my ore dict like this : So, my problem is that i can craft one times the lithium block, then, when the hammer is damaged, I can't craft the block once again. I don't know if adding WILDCARD_VALUE when registering Ore is doing something. I tried to put "data": 32767 in json file but doesn't work. Thanks for helping me. Bye.
×
×
  • Create New...

Important Information

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