Jump to content

kajacx

Members
  • Posts

    5
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

kajacx's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I can render a Tile entity with special renderer (like a chest) anywhere I want (currently even from another dimension), but blocks are just so much more complicated it seems.
  2. I'm working on implementing custom airships for my mod, something like http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1289952-archimedes-ships-v1-7-banking-ships but I'm stuck on how to render blocks at different position than they acctually are. I have managed to locate code that is likely responsible for rendering blocks inside RenderChunk class, extend from that class, and have my own code executed. I have copied the original code, and tried to modify it so that each block gets rendered at a position 16 blocks higher than it should be, but with no effect. I know that this is a difficult task, but if someone knows something of use, any help would be appriciated. Here is my code so far: public void rebuildChunk1(float x, float y, float z, ChunkCompileTaskGenerator generator) { CompiledChunk compiledchunk = new CompiledChunk(); int i = 1; //L.d("Getting position"); BlockPos blockpos = Util.getField(thiz, "position"); //L.d("Position get"); BlockPos blockpos1 = blockpos.add(15, 15, 15); generator.getLock().lock(); try { if (generator.getStatus() != ChunkCompileTaskGenerator.Status.COMPILING) { return; } generator.setCompiledChunk(compiledchunk); } finally { generator.getLock().unlock(); } VisGraph lvt_9_1_ = new VisGraph(); HashSet lvt_10_1_ = Sets.newHashSet(); ChunkCache region = Util.getField(thiz, "region"); if (!region.extendedLevelsInChunkCache()) { ++thiz.renderChunksUpdated; boolean[] aboolean = new boolean[blockRenderLayer.values().length]; BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher(); BlockPos.MutableBlockPos renderPos = new MutableBlockPos(); BlockPos.MutableBlockPos renderPos0 = new MutableBlockPos(blockpos); renderPos0.add(0, 16, 0); for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos1)) { renderPos.setPos(blockpos$mutableblockpos); //renderPos.add(0, 16, 0); //L.d("REndering in: " + blockpos$mutableblockpos); IBlockState iblockstate = region.getBlockState(blockpos$mutableblockpos); Block block = iblockstate.getBlock(); if (block == Blocks.GOLD_ORE) { L.d("Gold confirmed"); } //L.s("block state: " + iblockstate); if (iblockstate.isOpaqueCube()) { lvt_9_1_.setOpaqueCube(renderPos); } /*if (block.hasTileEntity(iblockstate)) { TileEntity tileentity = region.func_190300_a(blockpos$mutableblockpos, Chunk.EnumCreateEntityType.CHECK); if (tileentity != null) { TileEntitySpecialRenderer<TileEntity> tileentityspecialrenderer = TileEntityRendererDispatcher.instance.<TileEntity>getSpecialRenderer(tileentity); if (tileentityspecialrenderer != null) { compiledchunk.addTileEntity(tileentity); if (tileentityspecialrenderer.isGlobalRenderer(tileentity)) { lvt_10_1_.add(tileentity); } } } }*/ for (BlockRenderLayer blockrenderlayer1 : BlockRenderLayer.values()) { if (!block.canRenderInLayer(iblockstate, blockrenderlayer1)) continue; net.minecraftforge.client.ForgeHooksClient.setRenderLayer(blockrenderlayer1); int j = blockrenderlayer1.ordinal(); if (block.getDefaultState().getRenderType() != EnumBlockRenderType.INVISIBLE) { net.minecraft.client.renderer.VertexBuffer vertexbuffer = generator.getRegionRenderCacheBuilder().getWorldRendererByLayerId(j); if (!compiledchunk.isLayerStarted(blockrenderlayer1)) { compiledchunk.setLayerStarted(blockrenderlayer1); //thiz.preRenderBlocks(vertexbuffer, blockpos); Util.callMethod1(thiz, "preRenderBlocks", vertexbuffer, renderPos0); } aboolean[j] |= blockrendererdispatcher.renderBlock(iblockstate, renderPos, region, vertexbuffer); } } net.minecraftforge.client.ForgeHooksClient.setRenderLayer(null); } for (BlockRenderLayer blockrenderlayer : BlockRenderLayer.values()) { if (aboolean[blockrenderlayer.ordinal()]) { //compiledchunk.setLayerUsed(blockrenderlayer); Util.callMethod1(compiledchunk, "setLayerUsed", blockrenderlayer); } if (compiledchunk.isLayerStarted(blockrenderlayer)) { //thiz.postRenderBlocks(blockrenderlayer, x, y, z, generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(blockrenderlayer), compiledchunk); Util.callMethod1(thiz, "postRenderBlocks", blockrenderlayer, x, y, z, generator.getRegionRenderCacheBuilder().getWorldRendererByLayer(blockrenderlayer), compiledchunk); } } } compiledchunk.setVisibility(lvt_9_1_.computeVisibility()); ReentrantLock lockCompileTask = Util.getField(thiz, "lockCompileTask"); Set<TileEntity> setTileEntities = Util.getField(thiz, "setTileEntities"); RenderGlobal renderGlobal = Util.getField(thiz, "renderGlobal"); lockCompileTask.lock(); try { Set<TileEntity> set = Sets.newHashSet(lvt_10_1_); Set<TileEntity> set1 = Sets.newHashSet(setTileEntities); set.removeAll(setTileEntities); set1.removeAll(lvt_10_1_); setTileEntities.clear(); setTileEntities.addAll(lvt_10_1_); renderGlobal.updateTileEntities(set1, set); } finally { lockCompileTask.unlock(); } } Note: the lines if (block == Blocks.GOLD_ORE) { L.d("Gold confirmed"); } Correctly detect when I place a gold block in the targeted area, so I got that going for me at least.
  3. Thanks, works perfectly. How do mark this the correct answer? (first time on this site)
  4. I have began implementing tile entity teleportation for my mod, then updated to 1.10.2 and then found a stunning bug (at least in my opinion). When client logs into a server, that server no longer sends the client the NBT data about surrounding tile entities, at least not correctly. My Tile entity is a custom chest, and I have chosen to store facing in NBT instead of metadata, since it seemed like less work for me. But the NBT synchronization is completely ludicrous now. Code: @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); String location = thiz.getWorld().isRemote ? "Client" : "Server"; L.d(" -- " + location + " WRITE TO NBT -- "); L.d(location + " write facing: " + thiz.facing.getHorizontalIndex()); compound.setInteger("Facing", thiz.facing.getHorizontalIndex()); int rngCode = MathUtils.random.nextInt(1_000_000); L.d(location + " write rng code to: " + rngCode); compound.setInteger("RandomInt", rngCode); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); String location = thiz.getWorld() == null ? "Unknown" : (thiz.getWorld().isRemote ? "Client" : "Server"); L.d(" -- " + location + " READ FROM NBT -- "); int facingInt = compound.getInteger("Facing"); L.d(location + " read Facing int: " + facingInt); EnumFacing facing = EnumFacing.getHorizontal(facingInt); L.d(location + " read Facing: " + facing); this.setEnumFacing(facing); L.d(location + " read rng: " + compound.getInteger("RandomInt")); } I have also added some random code for more testing. This is what hapeens when I place my tile entity for the first time in world: So the first write-read is server sending NBT to client, the second write on server is server saving NBT internally, everything works as intended. But then, I log out and log in, and this is displayed on login: And it just doesn't work. Why on earth does minecraft not send NBT to clients who log in? The facing is saved on server correctly (I have tested this), but on client, it just thinks the tile entity is facing south and renderes it as such. I can guess that the solution could be to send the update packet myself, BUT: 1) writing code that sends NBT of existing tile entities to client when they log in is retarded, MC should do this on it's own 2) such message send data via ByteBuf, which would be fine, except you cannot store NBT in ByteBuf (WTF?) since there is no method for in the ByteBuf class nor is NBT serializable (really?) This just seems like a gigantic mess, and the worst part is, that the tile entity teleportation part acctually works! When I teleport my tile entity on server from one place to another and then set it's NBT, it is acctually send to the client automaticly (well, the getUpdatePacket and onDataPacket are called, which I implemented to just read/write NBT, but they are called automaticly). So, how to force minecraft to send NBT information to players who log in to server, without using that packet system that uses ByteBuf, since that can't store NBT?
×
×
  • Create New...

Important Information

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