Jump to content

1Mangomaster1

Members
  • Posts

    68
  • Joined

  • Last visited

Everything posted by 1Mangomaster1

  1. I've already managed to draw lined shapes using RenderType.lined() but whenever I am trying to swap it to RenderType.solid() my game crashed and I don't know what to do... Also if I could add a texture/shader on top of that quad that'd also be nice but just drawing a quad is the important thing
  2. I guess this can work, I'll give that a try
  3. What I have so far, is a way to store the "world name"(the String I can use the get the ResourceKey<Level> from), and a method called initAndGetWorld(MinecraftServer) that checks if the world is null and if not gives it a value, as well as a method to load the world without the server just by filling in that String, but the problem with that is: I don't know whether I init the world at any point of the code.... so I'm just gonna have to use it anywhere(?)
  4. Well yeah but if my Location class only contains the ResourceKey<Level> then how is it gonna use the Level internally? There are short methods such as getBlockState(), getBlockEntity() etc. Are they all gonna demand a MinecraftServer instance?
  5. How will I use it later tho?? When I need to use the Level? I don't want to always be forced to input a MinecraftServer into my get method
  6. Also, wdym? How do I do that? I just looked at tutorials for BlockEntitiy and all of them used BlockEntity#saveAdditional and BlockEntity#load
  7. The data I use a Location, which is a class I made containing a BlockPos and a Level, the reason I need a level iis because it might not be the same world as the BlockEntity's one. Basically I am making wireless redstone and I want it to work accross dimensions too and I am trying to load the transmitter's target, but to load a world you need to use MinecraftServer#getLevel which I can only access using Level#getServer
  8. During the load() method, BlockEntity.level is always null.. which means I cannot use it to get the MinecraftServer(Level#getServer), which means I cannot get the data I need when loading, causing it so when I rejoin the world(or Ig reload the chunk, never tried), Some data about my block is not saved... How can I get around this? What I need is: The MinecraftServer instance, which I thought of getting using BlockEntity.level, but it is null during the BlockEntity#load method
  9. How do I work with "BlockEntityTag"s?
  10. I have a boolean on my BlockEntity that determines something.. However, I want this value to be saved even after the block is broken and replacd(this way, seprating the blocks who have it as TRUE in the ItemStack, an NBT perhaps) How can I do it so blocks with that value set to TRUE will drop this variation of the item with a different NBT, that when placed down, will make sure the newly created BlockEntity will have this boolean set that way? Basically I want to be able to destroy and place a block with a certain state and have that block remember that state(also be seperated from the same types of blocks who are not in that state in the Inventroy, prob using NBT)
  11. Ik this is kinda the thing that a block is not used if you crouch... but what do I do if I want something to happen when you right click a block while crouching, regardless of the item(so don't tell me Item#useOn)
  12. Then how can I store and retreive a world via NBT?
  13. So far I've been able to obtain a world object using the MinecraftServer#getLevel method, obtaining the instance from Level#getServer. However, only ServerLevel#getServer actually returns a result that is not null, meaning that you can only get a world using its location on the server... How can I get it from the CLIENT?? I can't do Level#getServer as it returns null, because of that, I cannot use MinecraftServer#getLevel to get the world from its location name
  14. Anyways.... my way around it was to add to my BlockEntity a boolean for "hasSignal", unliked "powered", has signal becomes true for any direciton inputted, not only the front(or when the redstone controls are off), so I can check if there's signal rather than checking for "powered" public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos changedPos, boolean _unknownBoolean) { if (world.isClientSide) return; RedstoneTransmitterBlockEntity blockEntity = (RedstoneTransmitterBlockEntity)world.getBlockEntity(pos); boolean powered = blockEntity.hasSignal(); boolean neighborPowred = world.hasNeighborSignal(pos); if (powered != neighborPowred) { blockEntity.setSignal(neighborPowred); if (!neighborPowred || !blockEntity.hasRedstoneControls()) { world.setBlock(pos, state.setValue(POWERED, neighborPowred), UPDATE_ALL); updateWirelessConnection(world, state, pos); return; } if (changedPos.equals(front(state, pos))) world.setBlock(pos, state.setValue(POWERED, neighborPowred), UPDATE_ALL); else if (changedPos.equals(left(state, pos))) blockEntity.setChannel(blockEntity.getChannel() + 1); else if (changedPos.equals(right(state, pos))) blockEntity.setChannel(blockEntity.getChannel() - 1); else if (changedPos.equals(back(state, pos))) world.setBlock(pos, state.cycle(TRANSMISSION_KIND), UPDATE_ALL); updateWirelessConnection(world, state, pos); } } If anybody ever needs that--
  15. @Override public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos changedPos, boolean _unknownBoolean) { if (world.isClientSide) return; boolean hasPower = powered(state); boolean neighborPowred = world.hasNeighborSignal(pos); if (hasPower != neighborPowred) { RedstoneTransmitterBlockEntity blockEntity = (RedstoneTransmitterBlockEntity)world.getBlockEntity(pos); if (!neighborPowred || !blockEntity.hasRedstoneControls()) { cyclePowerState(world, pos, state); return; } System.out.println("Update from " + changedPos); if (changedPos.equals(front(state, pos))) { cyclePowerState(world, pos, state); } else if (changedPos.equals(left(state, pos))) { blockEntity.setChannel(blockEntity.getChannel() + 1); } else if (changedPos.equals(right(state, pos))) { blockEntity.setChannel(blockEntity.getChannel() - 1); } else if (changedPos.equals(back(state, pos))) { world.setBlock(pos, state.cycle(TRANSMISSION_KIND), UPDATE_ALL); } } } the front(), left(), right() and back() get the relative direction of a block in relation to its FACING state, it works I've checked that many times The idea of this method was to make each face of the block to behave differently when powered, it works, except when using some redstone stuff many updates are called and it presents a problem as cycles and additions and subtractions happen many times
  16. So I noticed on Block#neighborChanged that when redstone is activated/deactivated, between 2 to 9 updates are sent, using a repeater or even just dust, they're all sent from the same position and at the same tick. But why?? The RedstoneBlock only sends a single update when placed and destroyed, so why does activating and deactivating redstone signal sends so many?(and identical ones nontheless) and how can I make it so I ignore them all except one, because one is all I need Buttons send 2 updates, one using a regular BlockPos, and one using an mutable version of that... which is odd aswell
  17. Oh.. Appearntly I did not do super Block#onRemove.... that was dumb of me... sorry for this whole thing but if anyone does the same mistake as me... here's why it happens!
  18. I've noticed that data that is on the BlockEntity remains if I break and place the block again. However, if I place annother block that requires a block entity, break it, and place the original block back, it resets. Also, if I place that block anywhere else the data does not reamin, but placing it on that position where it was changed keeps that data I suspect that perhaps the BlockEntity is not "destroyed" when the block is, and actually remains there altho there's no air in there and not the block that previously was there... I thought it is something MC is supposed to do on its own, I don't get any console errors or anything but when I checked I noticed there are some BlockEntites of my blocks that the block in their position is air, and those positions are ones my blocks were placed before... Quitting and joining the world resets this. Why does it happen and how can I fix this? EDIT: The BlockEntity only changes if I place another block in that position THAT ALSO HAS A BLOCK ENTITY! If I place a block that does not implement EntityBlock, then that BlockEntity stays there I have noticed Level#removeBlockEntity, but I assume I am not supposed to use that on every Block#onBreak... it just makes no sense.. does MC not supposed to do it on its own?
  19. is the worldString good at least? or did I get that wrong?
  20. So... you're saying I can make another CompoundTag, and place them in it... and place that tag in the given tag? How do I rectreive that tag back then?
  21. And yeah, I know, this is how I store it: public static void saveNBT(CompoundTag nbt, Location location, String name) { String worldString = location.getWorld().dimension().location().toString(); BlockPos pos = location.getPos(); nbt.putString(name + ".world", worldString); nbt.putInt(name + ".pos.x", pos.getX()); nbt.putInt(name + ".pos.y", pos.getY()); nbt.putInt(name + ".pos.z", pos.getZ()); } Location is literally just a class with a Level and a BlockPos, that's all it has, nothing special Is that a proper way to save it? Also I know NBTUtils has a BlockPos write and read but it RETURNS a CompoundTag and I am not sure what I need to do with that(since I already have an existing instnace of it) I assume CompoundTag#put has someting to do with it because it can receive a tag but idrk and what I did here is not too difficault either so no biggy ig
  22. I mean I see it structred like a .java file I see all the code and everything, the name just says .class after it but it is decompiled
  23. Ooh I mean I CTRL+Clicked on the Level#getServer method and saw its content... Ik it is a .class file but for some reason I can still see the entire thing, on all files Regardless, this is not the point, because even if Level#getServer does actually work, I do not have access to the world at this specific point. I am talking about me trying to LOAD a world from its resource location, something you told me is possible, so if I am trying to load a world, clearly I do not have one... I am trying to find it, so I don't have an instance to call level#getServer on anyways
×
×
  • Create New...

Important Information

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