-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
SmallPineTree.java
59 lines (48 loc) · 2.45 KB
/
SmallPineTree.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package voronoiaoc.byg.common.world.feature.features.overworld.trees.pine;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Blocks;
import net.minecraft.util.Mirror;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.GenerationSettings;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import net.minecraft.world.gen.feature.template.PlacementSettings;
import net.minecraft.world.gen.feature.template.Template;
import net.minecraft.world.gen.feature.template.TemplateManager;
import net.minecraft.world.server.ServerWorld;
import voronoiaoc.byg.BYG;
import java.util.Random;
import java.util.function.Function;
public class SmallPineTree extends Feature<NoFeatureConfig> {
public static Template template = null;
public SmallPineTree(Function<Dynamic<?>, ? extends NoFeatureConfig> configIn) {
super(configIn);
}
public boolean place(IWorld world, ChunkGenerator<? extends GenerationSettings> generator, Random rand, BlockPos pos, NoFeatureConfig config) {
if (pos.getX() == -2 && pos.getZ() == -1) {
for (int checkX = pos.getX() + -16; checkX <= pos.getX() + 16; checkX++) {
for (int checkY = pos.getY(); checkY <= 25; checkY++) {
for (int checkZ = pos.getZ() + -16; checkZ <= pos.getZ() + 16; checkZ++) {
BlockPos.Mutable block = new BlockPos.Mutable(checkX, checkY, checkZ);
world.setBlockState(block, Blocks.AIR.getDefaultState(), 2);
}
}
}
TemplateManager templatemanager = ((ServerWorld) world.getWorld()).getSaveHandler().getStructureTemplateManager();
if (template == null)
template = templatemanager.getTemplate(new ResourceLocation(BYG.MOD_ID + ":features/trees/mini_wood_blewit"));
if (template == null) {
BYG.LOGGER.warn("NBT does not exist!");
return false;
}
PlacementSettings placementsettings = (new PlacementSettings()).setMirror(Mirror.NONE).setRotation(Rotation.NONE).setIgnoreEntities(false).setChunk(null);
template.addBlocksToWorld(world, pos, placementsettings);
return true;
}
return false;
}
}