1
0
mirror of https://github.com/chylex/Hardcore-Ender-Expansion.git synced 2025-04-10 20:15:42 +02:00

Added Tile Entity support for large structures

This commit is contained in:
chylex 2014-07-18 22:12:32 +02:00
parent 638f84d6fb
commit 4d9f404336
2 changed files with 12 additions and 1 deletions
src/main/java/chylex/hee/world/structure

View File

@ -2,6 +2,7 @@ package chylex.hee.world.structure;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
@ -64,4 +65,9 @@ public abstract class ComponentScatteredFeatureCustom extends StructureComponent
}
else return false;
}
public final TileEntity getBlockTileEntity(int x, int y, int z, World world, StructureBoundingBox bb){
int xx = this.getXWithOffset(x,z), yy = this.getYWithOffset(y), zz = this.getZWithOffset(x,z);
return bb.isVecInside(xx,yy,zz) ? world.getTileEntity(xx,yy,zz) : null;
}
}

View File

@ -83,7 +83,7 @@ public final class LargeStructureChunk{
public void generateInStructure(ComponentScatteredFeatureCustom structure, World world, StructureBoundingBox bb, int addX, int addY, int addZ){
if (minBlockY == ySize && maxBlockY == 0)return;
boolean hasBlocksToUpdate = !scheduledForUpdate.isEmpty(), continueY = true;
boolean hasBlocksToUpdate = !scheduledForUpdate.isEmpty(), hasTileEntities = !storedTileEntities.isEmpty(), continueY = true;
Block block;
for(int x = 0; x < 16; x++){
@ -93,6 +93,11 @@ public final class LargeStructureChunk{
if (hasBlocksToUpdate && isBlockScheduledForUpdate(x,y,z))continueY = structure.placeBlockAndUpdate(block,getMetadata(x,y,z),addX+this.x*16+x,addY+y,addZ+this.z*16+z,world,bb);
else continueY = structure.placeBlockWithoutUpdate(block,getMetadata(x,y,z),addX+this.x*16+x,addY+y,addZ+this.z*16+z,world,bb);
if (continueY && hasTileEntities && storedTileEntityClues.containsKey(y*256+x*16+z)){
String key = storedTileEntityClues.get(y*256+x*16+z);
storedTileEntities.get(key).onTileEntityRequested(key,structure.getBlockTileEntity(addX+this.x*16+x,addY+y,addZ+this.z*16+z,world,bb),world.rand);
}
}
continueY = true;