Jump to content

Sanshirou

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by Sanshirou

  1. Hmmm, that's because "theWorld" is an instance of "ClientWorld", right? I'll check on ways to get "World" by itself.
  2. I'm going to sleep now, but at the end I ended up doing this: public class TorchDestroyer extends TileEntity{ private long worldTime; public TorchDestroyer(){ super(); worldTime = Minecraft.getMinecraft().theWorld.getTotalWorldTime(); } public long getWorldTime() { return worldTime; } public void setWorldTime(long worldTime) { this.worldTime = worldTime; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound){ super.writeToNBT(compound); compound.setLong("torchBorn", getWorldTime()); return compound; } @Override public void readFromNBT(NBTTagCompound compound){ super.readFromNBT(compound); setWorldTime(compound.getLong("torchBorn")); } } And then: @SubscribeEvent public void listTorch(PlaceEvent event) { if (event.getPlacedBlock().getBlock() == Blocks.TORCH) { TorchDestroyer n = new TorchDestroyer(); n.setPos(event.getPos()); Minecraft.getMinecraft().theWorld.addTileEntity(n); } } int deathTorchTick = 0; @SubscribeEvent public void cancelarAntorcha(WorldTickEvent event) { deathTorchTick++; if (deathTorchTick >= 1000 && !event.isCanceled()) { World w = Minecraft.getMinecraft().theWorld; for (TileEntity obj : w.loadedTileEntityList) { if (obj instanceof TorchDestroyer) { TorchDestroyer torchKiller = (TorchDestroyer) obj; if (Minecraft.getMinecraft().theWorld.getTotalWorldTime() > torchKiller.getWorldTime()+ Configuracion.TORCH_DECAY_TIME) { if (Minecraft.getMinecraft().theWorld.getBlockState(torchKiller.getPos()).getBlock() == Blocks.TORCH) { Minecraft.getMinecraft().theWorld.setBlockToAir(torchKiller.getPos()); Minecraft.getMinecraft().theWorld.removeTileEntity(torchKiller.getPos()); } else { Minecraft.getMinecraft().theWorld.removeTileEntity(torchKiller.getPos()); } } } } deathTorchTick = 0; } } And for now it works (In singleplayer), I don't know if I should rename the post in case someone has a trouble like this Will this have any troubles when moving it to a multiplayer environment?
  3. Thank you for the answers. I tried using the "Current world total time" answer, but I don't exactly know where to store it, in a simple Array it will get cleared when the game instance is closed, so I guess I'll have to find a place to store it into NBT or something. If that doesn't work I'll end up using some other kind of hack.
  4. Is it possible to get how much time has a block been on the world? And if so, how? Specifically, the block I'm trying to get it's age from are regular torches, and their only properties is "where are they facing", and then I've been trying to find something like a "getAge()" for the block, or it's BlockState, but so far I haven't been succesful on finding it. The objective behind this is to make a WorldTick event to check if torches in the loaded chunks have more than X age, and if so, they break. This is my first time going through this stuff, so I'm still getting lost
  5. I know it's 1.10.2, but it's a very simple question, please. I've been searching for a while, and I've tested the following functions (these functions are called in a PlayerTickEvent) Block.getLightValue() IBlockState.getLightValue(WorldClient, BlockPos) World.getCombinedLight(blockPos, lightValue) World.getBlockLightOpacity(blockPos) World.getLightBrightness(blockPos) All I want to find out is a way to get the Block light level that appears on the debug screen: The block light value level that changes as you move around. I must be missing something, the results I get from debugging are really uncertain, most of the time they show 0, but if the player is standing on a block right next to a torch, sometimes the light value will catch 14, and sometimes it won't. SOLVED BY USING THIS: I still haven't tested if this is exactly what I want, but by using the source of this file from this mod: (https://github.com/oldjunyi/LightLevelOverlayReloaded/blob/1.12/src/main/java/com/mmyzd/llor/OverlayPoller.java) I've managed to get the block light, apparently it's gotta be based on the CHUNK, not on the world. Chunk chunk = w.getChunkFromChunkCoords(player.chunkCoordX, player.chunkCoordZ); int light = chunk.getLightFor(EnumSkyBlock.BLOCK, player.getPosition()); That's what I've done for now, in the future I'll add more checks, but at least I've managed to find something that patches the problem.
×
×
  • Create New...

Important Information

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