Jump to content

wefewdsad

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by wefewdsad

  1. Thank you for the explanation, that really helps! I have one more question though, what if I want to build a bridge between 2 points? There is no way I can do that with the structure class right?
  2. Ah well that makes sense, so far it didn't cause any problems though, maybe because the world is completely empty so the worldgen completes really fast? How do I know I have access to a specific chunk?
  3. Hi, I want to spawn some structures when a player enters my dimension, however, I don't really see the point of using the forge Structure class instead of just looping over all blocks I want to set and using setBlockState. From what I see in the Structure class, it still uses setBlockState, so it should not perform better than just doing it myself? I also want to put some data in the TileEntities after placing them and that would be harder using the Structure class as well. I currently already have everything working with setBlockState, should I change this to use the Structure method?
  4. Wow that solved it, cant believe it was that simple. Thank you very much!
  5. Hello, I am currently making my first mod and am currently struggling with tile entities. When the block is placed it is working fine, however, if i save and quit to title and start the world again, the completionBlocks list does not have anything in it. I tried placing breakpoints on CompletionBlockTileEntity#write and CompletionBlockTileEntity#read, and noticed read is not triggered when the world is loaded so I guess that is why completionBlocks is empty? How do I solve this problem? Is this even the proper way of storing data for a tile entity? I read stuff about capabilities but don't really see why that should be used here. My TileEntity public class CompletionBlockTileEntity extends TileEntity { public List<MyVector> completionBlocks = null; private final String delimiter = "_"; private final String nbtName = "locations"; public CompletionBlockTileEntity() { super(BorisRegistry.completion_block_entity.get()); if(completionBlocks == null) { completionBlocks = new ArrayList<>(); } } ... // region Storage private String listToString() { return completionBlocks.stream().map(MyVector::toStringRounded).collect(Collectors.joining(delimiter)); } private List<MyVector> stringToList(String string) { return Arrays.stream(string.split(delimiter)).map(MyVector::new).collect(Collectors.toList()); } @Override public CompoundNBT write(CompoundNBT nbt) { nbt.putString(nbtName, listToString()); return nbt; } @Override public void read(CompoundNBT nbt) { completionBlocks = stringToList(nbt.getString(nbtName)); } // endregion } The code that sets completionBlocks. public void Spawn() { if(!world.isRemote) { for (Map.Entry<MyVector, BlockState> entry : structure.entrySet()) { BlockPos position = entry.getKey().Add(this.coordinates).toBlockPos(); BlockState block = entry.getValue(); ... if(block == BorisRegistry.completion_block.get().getDefaultState()){ completionBlocks.add(new MyVector(position)); } } for(MyVector blockloc : completionBlocks) { CompletionBlockTileEntity cbte = (CompletionBlockTileEntity) this.world.getTileEntity(blockloc.toBlockPos()); cbte.completionBlocks = completionBlocks; cbte.markDirty(); } } }
×
×
  • Create New...

Important Information

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