Skip to content

Commit

Permalink
Merge remote-tracking branch 'xcube/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Caedis committed Jul 6, 2024
2 parents b37022d + a77adde commit 5cfa470
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ public ComponentTFNagaCourtyardHedge() {
super();
}

public float hedgeFloof = 1.0f;

public ComponentTFNagaCourtyardHedge(int i, int x, int y, int z, int rotation, float floof) {
public ComponentTFNagaCourtyardHedge(int i, int x, int y, int z, int rotation) {
super(i, x, y, z, rotation);
this.coordBaseMode = rotation;
this.boundingBox = new StructureBoundingBox(x, y + 1, z, x + 4, y + 6, z + 4);
this.hedgeFloof = floof;
}

@Override
Expand Down Expand Up @@ -158,7 +155,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo
TFBlocks.leaves,
4,
random,
hedgeFloof);
ComponentTFNagaCourtyardMain.HEDGE_FLOOF);
this.partiallyFillWithMetadataBlocks(
world,
structureBoundingBox,
Expand All @@ -171,7 +168,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo
TFBlocks.leaves,
4,
random,
hedgeFloof);
ComponentTFNagaCourtyardMain.HEDGE_FLOOF);
this.partiallyFillWithMetadataBlocks(
world,
structureBoundingBox,
Expand All @@ -184,7 +181,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo
TFBlocks.leaves,
4,
random,
hedgeFloof);
ComponentTFNagaCourtyardMain.HEDGE_FLOOF);
this.partiallyFillWithMetadataBlocks(
world,
structureBoundingBox,
Expand All @@ -197,7 +194,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo
TFBlocks.leaves,
4,
random,
hedgeFloof);
ComponentTFNagaCourtyardMain.HEDGE_FLOOF);
this.partiallyFillWithMetadataBlocks(
world,
structureBoundingBox,
Expand All @@ -210,7 +207,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo
TFBlocks.leaves,
4,
random,
hedgeFloof);
ComponentTFNagaCourtyardMain.HEDGE_FLOOF);

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ public ComponentTFNagaCourtyardHedgePadder() {
super();
}

public float hedgeFloof = 1.0f;

public ComponentTFNagaCourtyardHedgePadder(int i, int x, int y, int z, int rotation, float floof) {
public ComponentTFNagaCourtyardHedgePadder(int i, int x, int y, int z, int rotation) {
super(i, x, y, z, rotation);
this.coordBaseMode = rotation;
this.boundingBox = new StructureBoundingBox(x, y + 1, z - 1, x + 4, y + 6, z + 1);
this.hedgeFloof = floof;
}

@Override
Expand Down Expand Up @@ -108,7 +105,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo
TFBlocks.leaves,
4,
random,
hedgeFloof);
ComponentTFNagaCourtyardMain.HEDGE_FLOOF);
this.partiallyFillWithMetadataBlocks(
world,
structureBoundingBox,
Expand All @@ -121,7 +118,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo
TFBlocks.leaves,
4,
random,
hedgeFloof);
ComponentTFNagaCourtyardMain.HEDGE_FLOOF);
this.partiallyFillWithMetadataBlocks(
world,
structureBoundingBox,
Expand All @@ -134,7 +131,7 @@ public boolean addComponentParts(World world, Random random, StructureBoundingBo
TFBlocks.leaves,
4,
random,
hedgeFloof);
ComponentTFNagaCourtyardMain.HEDGE_FLOOF);

for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public ComponentTFNagaCourtyardHedgePillar() {
super();
}

public ComponentTFNagaCourtyardHedgePillar(int i, int x, int y, int z, int rotation, float floof) {
super(i, x, y, z, rotation, floof);
public ComponentTFNagaCourtyardHedgePillar(int i, int x, int y, int z, int rotation) {
super(i, x, y, z, rotation);
this.coordBaseMode = rotation;
this.boundingBox = new StructureBoundingBox(x, y + 1, z, x + 4, y + 11, z + 4);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Random;

import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;
Expand Down Expand Up @@ -163,8 +164,7 @@ else if (random.nextBoolean()) terrace = new ComponentTFNagaCourtyardTerraceBraz
boundingBox.minX + 3 + x * 6,
boundingBox.minY,
boundingBox.minZ + 3 + z * 6,
0,
HEDGE_FLOOF);
0);
list.add(hedge);
hedge.buildComponent(this, list, random);
}
Expand Down Expand Up @@ -202,8 +202,7 @@ else if (random.nextBoolean()) terrace = new ComponentTFNagaCourtyardTerraceBraz
boundingBox.minX + 3 + x1 * 6,
boundingBox.minY,
boundingBox.minZ + 3 + z1 * 6,
0,
HEDGE_FLOOF);
0);
list.add(hedge);
hedge.buildComponent(this, list, random);
}
Expand All @@ -221,8 +220,7 @@ else if (random.nextBoolean()) terrace = new ComponentTFNagaCourtyardTerraceBraz
boundingBox.minX + 3 + x * 6,
boundingBox.minY,
boundingBox.minZ + 3 + z * 6,
0,
HEDGE_FLOOF);
0);
list.add(pillar);
pillar.buildComponent(this, list, random);
}
Expand Down Expand Up @@ -257,8 +255,7 @@ else if (random.nextBoolean()) terrace = new ComponentTFNagaCourtyardTerraceBraz
boundingBox.minX + 1 + (x + 1) * 6,
boundingBox.minY,
boundingBox.minZ + 6 + z * 6,
3,
HEDGE_FLOOF);
3);
list.add(padder);
padder.buildComponent(this, list, random);
}
Expand All @@ -273,8 +270,7 @@ else if (random.nextBoolean()) terrace = new ComponentTFNagaCourtyardTerraceBraz
boundingBox.minX + 1 + x * 6,
boundingBox.minY,
boundingBox.minZ + 6 + z * 6,
3,
HEDGE_FLOOF);
3);
list.add(padder);
padder.buildComponent(this, list, random);
}
Expand All @@ -284,8 +280,7 @@ else if (random.nextBoolean()) terrace = new ComponentTFNagaCourtyardTerraceBraz
boundingBox.minX + 3 + x * 6,
boundingBox.minY,
boundingBox.minZ + 2 + (z + 1) * 6,
0,
HEDGE_FLOOF);
0);
list.add(padder);
padder.buildComponent(this, list, random);
}
Expand All @@ -295,8 +290,7 @@ else if (random.nextBoolean()) terrace = new ComponentTFNagaCourtyardTerraceBraz
boundingBox.minX + 3 + x * 6,
boundingBox.minY,
boundingBox.minZ + 2 + z * 6,
0,
HEDGE_FLOOF);
0);
list.add(padder);
padder.buildComponent(this, list, random);
}
Expand Down Expand Up @@ -1107,6 +1101,69 @@ else if (random.nextBoolean()) terrace = new ComponentTFNagaCourtyardTerraceBraz

}

/**
* Save to NBT
*/
@Override
protected void func_143012_a(NBTTagCompound tag) {
super.func_143012_a(tag);

// We don't really need to storeanything other than null vs CellType.EMPTY
// This data is used by addComponentParts to generate paths in empty areas
int numBits = tableWidth * tableWidth;
// Use a byte array to store the tableWidth and a packed bit array
byte[] emptySpots = new byte[1 + numBits / 8 + (numBits % 8 > 0 ? 1 : 0)];
emptySpots[0] = (byte) tableWidth;
for (int x = 0; x < this.tableWidth; x++) {
for (int z = 0; z < this.tableWidth; z++) {
if (this.courtyard[x][z] == CellType.EMPTY) {
int bitIndex = this.tableWidth * x + z;
emptySpots[1 + (bitIndex / 8)] |= 1 << (bitIndex % 8);
}
}
}
tag.setByteArray("CY", emptySpots);
}

/**
* Load from NBT
*/
@Override
protected void func_143011_b(NBTTagCompound tag) {
super.func_143011_b(tag);

// We don't really care about anything other than null vs CellType.EMPTY
// This data is used by addComponentParts to generate paths in empty areas
byte[] emptySpots = tag.getByteArray("CY");
if (emptySpots.length > 1) {
this.tableWidth = emptySpots[0];
this.courtyard = new CellType[tableWidth][tableWidth];

// Load boolean values from a packed bit array starting at index 1
// 0 => Leave the CellType as null
// 1 => Use CellType.EMPTY (it's the only one that gets used durring block generation)
int index = 1;
int shift = 0;
read_bits_array: for (int x = 0; x < this.tableWidth; x++) {
for (int z = 0; z < this.tableWidth; z++) {
if ((((emptySpots[index] & 0xFF) >> shift++) & 1) == 1) {
this.courtyard[x][z] = CellType.EMPTY;
}

// Incronmnet our bit index and break if we hit the end, that's it.
if (shift >= 8) {
shift = 0;
index++;
// Sanity check just in case
if (index >= emptySpots.length) {
break read_bits_array;
}
}
}
}
}
}

/**
* second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes Mineshafts at
* the end, it adds Fences...
Expand Down

0 comments on commit 5cfa470

Please sign in to comment.