mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 12:19:47 +00:00
Fixed leaves
This commit is contained in:
1 parent
57eea26c1a
commit
876b214a97
3 files changed
+23
-9
No files matched your search
@@ -1,7 +1,6 @@
|
||||
package binnie.extratrees.gen;
|
||||
|
||||
import binnie.extratrees.worldgen.BlockType;
|
||||
import binnie.extratrees.worldgen.BlockTypeLeaf;
|
||||
import binnie.extratrees.worldgen.BlockTypeLog;
|
||||
import forestry.api.world.ITreeGenData;
|
||||
|
||||
@@ -26,11 +25,6 @@ public class WorldGenDefault extends WorldGenTree {
|
||||
this.girth = this.determineGirth(this.treeGen.getGirth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getLeaf() {
|
||||
return new BlockTypeLeaf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getWood() {
|
||||
return new BlockTypeLog(this.treeGen);
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package binnie.extratrees.gen;
|
||||
|
||||
import binnie.core.util.TileUtil;
|
||||
import binnie.extratrees.worldgen.BlockType;
|
||||
import binnie.extratrees.worldgen.BlockTypeLeaf;
|
||||
import binnie.extratrees.worldgen.BlockTypeLog;
|
||||
import binnie.extratrees.worldgen.BlockTypeVoid;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.world.ITreeGenData;
|
||||
import forestry.arboriculture.tiles.TileTreeContainer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
public class WorldGenTree extends WorldGenerator {
|
||||
@@ -84,7 +88,7 @@ public class WorldGenTree extends WorldGenerator {
|
||||
}
|
||||
|
||||
public BlockType getLeaf() {
|
||||
return new BlockTypeLeaf();
|
||||
return leaf!=null?leaf:(leaf=new BlockTypeLeaf(null));
|
||||
}
|
||||
|
||||
public BlockType getWood() {
|
||||
@@ -93,9 +97,19 @@ public class WorldGenTree extends WorldGenerator {
|
||||
|
||||
@Override
|
||||
public boolean generate(World worldIn, Random rand, BlockPos position) {
|
||||
this.leaf = new BlockTypeLeaf(getOwner(worldIn, position));
|
||||
return generate(worldIn, rand, position.getX(), position.getY(), position.getZ(), false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static GameProfile getOwner(World world, BlockPos pos) {
|
||||
TileTreeContainer tile = TileUtil.getTile(world, pos, TileTreeContainer.class);
|
||||
if (tile == null) {
|
||||
return null;
|
||||
}
|
||||
return tile.getOwnerHandler().getOwner();
|
||||
}
|
||||
|
||||
public final boolean generate(final World world, final Random random, final int x, final int y, final int z, final boolean force) {
|
||||
this.world = world;
|
||||
this.rand = random;
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
package binnie.extratrees.worldgen;
|
||||
|
||||
import binnie.core.Mods;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import forestry.api.world.ITreeGenData;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockTypeLeaf extends BlockType {
|
||||
public BlockTypeLeaf() {
|
||||
GameProfile owner;
|
||||
|
||||
public BlockTypeLeaf(@Nullable GameProfile owner) {
|
||||
super(Mods.Forestry.block("leaves"), 0);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(final World world, final ITreeGenData tree, final BlockPos pos) {
|
||||
tree.setLeaves(world, null, pos);
|
||||
tree.setLeaves(world, owner, pos);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user