-
Notifications
You must be signed in to change notification settings - Fork 81
/
GreenGlowshroomGenerator.java
202 lines (168 loc) · 7.72 KB
/
GreenGlowshroomGenerator.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package com.progwml6.natura.world.worldgen.glowshroom.nether;
import java.util.Random;
import com.progwml6.natura.nether.NaturaNether;
import com.progwml6.natura.nether.block.shrooms.BlockNetherLargeGlowshroom;
import com.progwml6.natura.nether.block.shrooms.BlockNetherLargeGlowshroom.EnumType;
import com.progwml6.natura.world.worldgen.glowshroom.BaseGlowshroomGenerator;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockPos.MutableBlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
public class GreenGlowshroomGenerator extends BaseGlowshroomGenerator
{
public final IBlockState glowshroom;
public GreenGlowshroomGenerator(IBlockState glowshroom)
{
this.glowshroom = glowshroom;
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
}
@Override
public void generateShroom(Random random, World world, BlockPos pos)
{
int height = random.nextInt(3) + 4;
boolean flag = true;
if (pos.getY() >= 1 && pos.getY() + height + 1 < 256)
{
for (int j = pos.getY(); j <= pos.getY() + 1 + height; ++j)
{
int k = 3;
if (j <= pos.getY() + 3)
{
k = 0;
}
MutableBlockPos mutableblockpos = new MutableBlockPos();
for (int l = pos.getX() - k; l <= pos.getX() + k && flag; ++l)
{
for (int i1 = pos.getZ() - k; i1 <= pos.getZ() + k && flag; ++i1)
{
if (j >= 0 && j < 256)
{
IBlockState state = world.getBlockState(mutableblockpos.setPos(l, j, i1));
if (!state.getBlock().isAir(state, world, mutableblockpos) && !state.getBlock().isLeaves(state, world, mutableblockpos))
{
flag = false;
}
}
else
{
flag = false;
}
}
}
}
if (!flag)
{
}
else
{
Block block1 = world.getBlockState(pos.down()).getBlock();
if (block1 != Blocks.MYCELIUM && block1 != Blocks.NETHERRACK && block1 != Blocks.SOUL_SAND && block1 != NaturaNether.netherTaintedSoil)
{
}
else
{
int k2 = pos.getY() + height;
for (int l2 = k2; l2 <= pos.getY() + height; ++l2)
{
int j3 = 3;
int k3 = pos.getX() - j3;
int l3 = pos.getX() + j3;
int j1 = pos.getZ() - j3;
int k1 = pos.getZ() + j3;
for (int l1 = k3; l1 <= l3; ++l1)
{
for (int i2 = j1; i2 <= k1; ++i2)
{
int j2 = 5;
if (l1 == k3)
{
--j2;
}
else if (l1 == l3)
{
++j2;
}
if (i2 == j1)
{
j2 -= 3;
}
else if (i2 == k1)
{
j2 += 3;
}
EnumType enumtype = EnumType.byMetadata(j2);
if (l2 < pos.getY() + height)
{
if ((l1 == k3 || l1 == l3) && (i2 == j1 || i2 == k1))
{
continue;
}
if (l1 == pos.getX() - (j3 - 1) && i2 == j1)
{
enumtype = EnumType.NORTH_WEST;
}
if (l1 == k3 && i2 == pos.getZ() - (j3 - 1))
{
enumtype = EnumType.NORTH_WEST;
}
if (l1 == pos.getX() + (j3 - 1) && i2 == j1)
{
enumtype = EnumType.NORTH_EAST;
}
if (l1 == l3 && i2 == pos.getZ() - (j3 - 1))
{
enumtype = EnumType.NORTH_EAST;
}
if (l1 == pos.getX() - (j3 - 1) && i2 == k1)
{
enumtype = EnumType.SOUTH_WEST;
}
if (l1 == k3 && i2 == pos.getZ() + (j3 - 1))
{
enumtype = EnumType.SOUTH_WEST;
}
if (l1 == pos.getX() + (j3 - 1) && i2 == k1)
{
enumtype = EnumType.SOUTH_EAST;
}
if (l1 == l3 && i2 == pos.getZ() + (j3 - 1))
{
enumtype = EnumType.SOUTH_EAST;
}
}
if (enumtype == EnumType.CENTER && l2 < pos.getY() + height)
{
enumtype = EnumType.ALL_INSIDE;
}
if (pos.getY() >= pos.getY() + height - 1 || enumtype != EnumType.ALL_INSIDE)
{
BlockPos blockpos = new BlockPos(l1, l2, i2);
IBlockState state = world.getBlockState(blockpos);
if (state.getBlock().canBeReplacedByLeaves(state, world, blockpos))
{
world.setBlockState(blockpos, this.glowshroom.withProperty(BlockNetherLargeGlowshroom.VARIANT, enumtype), 2);
}
}
}
}
}
for (int i3 = 0; i3 < height; ++i3)
{
IBlockState iblockstate = world.getBlockState(pos.up(i3));
if (iblockstate.getBlock().canBeReplacedByLeaves(iblockstate, world, pos.up(i3)))
{
world.setBlockState(pos.up(i3), this.glowshroom.withProperty(BlockNetherLargeGlowshroom.VARIANT, EnumType.STEM), 2);
}
}
}
}
}
}
}