Jump to content

Tyhone

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Tyhone

  1. Hey all, I've got 2 issues that I think are most likely related. First is that my Tileenttity "Jar" is sharing its NBT with other instances of "Jar", seemingly at random, whenever one sends a new packet. Next is that the NBT is being found at world load, but then not being applied, until the "Jar" is being updated. See below Loading world And reloading world Here is the code for my TileEntityJar //ModTileEntityBase extends TilEntity @Override public NBTTagCompound getUpdateTag() { return writeToNBT(new NBTTagCompound()); } @Nullable @Override public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound nbtTag = new NBTTagCompound(); this.writeToNBT(nbtTag); return new SPacketUpdateTileEntity(getPos(), 1, nbtTag); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { this.readFromNBT(packet.getNbtCompound()); } //This is called whenever the contained TinktureStacks amount/type is changed public void markForClean(){ markDirty(); if (world != null){ IBlockState state = getWorld().getBlockState(getPos()); getWorld().notifyBlockUpdate(getPos(), state, state, 3); } } //TileEntityJar @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if(compound.hasKey(TAG_TYPE)){ Arcanacraft.logger.info("Compoud load: " + compound); TinktureType type = TinktureStackUtil.getTinktureTypeFromString(compound.getString(TAG_TYPE)); int amount = compound.getInteger(TAG_AMOUNT); tinktureStack = new TinktureStack(type, amount); } else{ Arcanacraft.logger.info("Compoud failed to load"); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); if(!tinktureStack.isEmpty()){ compound.setString(TAG_TYPE, tinktureStack.getTinktureType().getTinktureName()); compound.setInteger(TAG_AMOUNT, tinktureStack.getAmount()); Arcanacraft.logger.info("Compoud save: " + compound); } else{ Arcanacraft.logger.info("Compoud did not save (empty)"); } return compound; } Any help would be greatly appreciated, I dont have any of these issues with other TileEntities that contain ItemStacks and whatnot Edit: Github link for Jar https://github.com/The-PurpleOrange/Arcanacraft/blob/master/src/main/java/com/tyhone/arcanacraft/common/tileentity/TileEntityJar.java Edit Edit: Oh my god. I was comparing two strings with "==" instead of ".equals", I thought I was going insane, that's what 14 straight hours of coding does to you, second time ive made that mistake, eclipse should flag it as an error honestly. Can someone lock this please?
  2. Hey all, first time posting. I'm having difficulty with rendering a simple cube in a tileentities TESR, I'm not great with rendering in general, so any help would be appreciated. EDIT: I should note that I have simplified this code to be as bare bones as it can be, until I can get the cube to render correctly. https://github.com/The-PurpleOrange/Arcanacraft/blob/master/src/main/java/com/tyhone/arcanacraft/client/render/tesr/RenderTileEntityJar.java There's the offender When using DefaultVertexFormats.BLOCK I get this, but with DefaultVertexFormats.POSITION I get a cube, but I cant control the rgba, and it randomly flickers and goes invisible. POSITION _COLOR does something similar to BLOCK as well Heres the TESR code: public void render(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage, float alpha){ TileEntityJar jar = (TileEntityJar) te; double fluidLevel = jar.getFluidLevel(); double maxFluid = jar.getMaxFluid(); String fluidType = jar.getFluidType(); if(true){ Tessellator tess = Tessellator.getInstance(); BufferBuilder buffer = tess.getBuffer(); GlStateManager.pushMatrix(); //Render smooth stuff RenderHelper.disableStandardItemLighting(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); /*if(Minecraft.isAmbientOcclusionEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); } else { GL11.glShadeModel(GL11.GL_FLAT); }*/ GlStateManager.translate(x, y+1, z); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); buffer.color(255, 0, 0, 255); buildQuad(buffer, 0, 0, 0, 1, 1, 1, EnumFacing.DOWN); buildQuad(buffer, 0, 0, 0, 1, 1, 1, EnumFacing.UP); buildQuad(buffer, 0, 0, 0, 1, 1, 1, EnumFacing.NORTH); buildQuad(buffer, 0, 0, 0, 1, 1, 1, EnumFacing.SOUTH); buildQuad(buffer, 0, 0, 0, 1, 1, 1, EnumFacing.EAST); buildQuad(buffer, 0, 0, 0, 1, 1, 1, EnumFacing.WEST); tess.draw(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); RenderHelper.enableStandardItemLighting(); } } And here is buildQuad: public static void buildQuad(BufferBuilder renderer, double x, double y, double z, double w, double h, double d, EnumFacing face) { double s = 0.1; double x1 = x + s; double x2 = x + w - s; double y1 = y + s; double y2 = y + h - s; double z1 = z + s; double z2 = z + d - s; switch(face) { case DOWN: renderer.pos(x1, y1, z1).endVertex(); renderer.pos(x2, y1, z1).endVertex(); renderer.pos(x2, y1, z2).endVertex(); renderer.pos(x1, y1, z2).endVertex(); break; case UP: renderer.pos(x1, y2, z1).endVertex(); renderer.pos(x1, y2, z2).endVertex(); renderer.pos(x2, y2, z2).endVertex(); renderer.pos(x2, y2, z1).endVertex(); break; case NORTH: renderer.pos(x1, y1, z1).endVertex(); renderer.pos(x1, y2, z1).endVertex(); renderer.pos(x2, y2, z1).endVertex(); renderer.pos(x2, y1, z1).endVertex(); break; case SOUTH: renderer.pos(x1, y1, z2).endVertex(); renderer.pos(x2, y1, z2).endVertex(); renderer.pos(x2, y2, z2).endVertex(); renderer.pos(x1, y2, z2).endVertex(); break; case WEST: renderer.pos(x1, y1, z1).endVertex(); renderer.pos(x1, y1, z2).endVertex(); renderer.pos(x1, y2, z2).endVertex(); renderer.pos(x1, y2, z1).endVertex(); break; case EAST: renderer.pos(x2, y1, z1).endVertex(); renderer.pos(x2, y2, z1).endVertex(); renderer.pos(x2, y2, z2).endVertex(); renderer.pos(x2, y1, z2).endVertex(); break; } }
×
×
  • Create New...

Important Information

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