Bonemeal hotfix
This commit is contained in:
parent
4141ce7f60
commit
5adf385813
2 changed files with 35 additions and 30 deletions
|
@ -26,8 +26,7 @@ import ru.betterend.world.biome.EndBiome;
|
|||
|
||||
@Mixin(BoneMealItem.class)
|
||||
public class BoneMealItemMixin {
|
||||
private static final MutableBlockPos POS = new MutableBlockPos();
|
||||
private static final Vec3i[] DIR;
|
||||
private static final MutableBlockPos BE_BLOCK_POS = new MutableBlockPos();
|
||||
|
||||
@Inject(method = "useOn", at = @At("HEAD"), cancellable = true)
|
||||
private void be_onUse(UseOnContext context, CallbackInfoReturnable<InteractionResult> info) {
|
||||
|
@ -81,15 +80,15 @@ public class BoneMealItemMixin {
|
|||
for (int i = 0; i < 64; i++) {
|
||||
int x = (int) (pos.getX() + world.random.nextGaussian() * 2);
|
||||
int z = (int) (pos.getZ() + world.random.nextGaussian() * 2);
|
||||
POS.setX(x);
|
||||
POS.setZ(z);
|
||||
BE_BLOCK_POS.setX(x);
|
||||
BE_BLOCK_POS.setZ(z);
|
||||
for (int y = y1; y >= y2; y--) {
|
||||
POS.setY(y);
|
||||
BlockPos down = POS.below();
|
||||
if (world.isEmptyBlock(POS) && !world.isEmptyBlock(down)) {
|
||||
BE_BLOCK_POS.setY(y);
|
||||
BlockPos down = BE_BLOCK_POS.below();
|
||||
if (world.isEmptyBlock(BE_BLOCK_POS) && !world.isEmptyBlock(down)) {
|
||||
BlockState grass = be_getGrassState(world, down);
|
||||
if (grass != null) {
|
||||
BlocksHelper.setWithoutUpdate(world, POS, grass);
|
||||
BlocksHelper.setWithoutUpdate(world, BE_BLOCK_POS, grass);
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
|
@ -106,15 +105,15 @@ public class BoneMealItemMixin {
|
|||
for (int i = 0; i < 64; i++) {
|
||||
int x = (int) (pos.getX() + world.random.nextGaussian() * 2);
|
||||
int z = (int) (pos.getZ() + world.random.nextGaussian() * 2);
|
||||
POS.setX(x);
|
||||
POS.setZ(z);
|
||||
BE_BLOCK_POS.setX(x);
|
||||
BE_BLOCK_POS.setZ(z);
|
||||
for (int y = y1; y >= y2; y--) {
|
||||
POS.setY(y);
|
||||
BlockPos down = POS.below();
|
||||
if (world.getBlockState(POS).is(Blocks.WATER) && world.getBlockState(down).is(EndTags.END_GROUND)) {
|
||||
BE_BLOCK_POS.setY(y);
|
||||
BlockPos down = BE_BLOCK_POS.below();
|
||||
if (world.getBlockState(BE_BLOCK_POS).is(Blocks.WATER) && world.getBlockState(down).is(EndTags.END_GROUND)) {
|
||||
BlockState grass = be_getWaterGrassState(world, down);
|
||||
if (grass != null) {
|
||||
BlocksHelper.setWithoutUpdate(world, POS, grass);
|
||||
BlocksHelper.setWithoutUpdate(world, BE_BLOCK_POS, grass);
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
|
@ -149,8 +148,8 @@ public class BoneMealItemMixin {
|
|||
}
|
||||
|
||||
private BlockState be_getNylium(Level world, BlockPos pos) {
|
||||
MHelper.shuffle(DIR, world.getRandom());
|
||||
for (Vec3i dir : DIR) {
|
||||
Vec3i[] offsets = MHelper.getOffsets(world.getRandom());
|
||||
for (Vec3i dir : offsets) {
|
||||
BlockPos p = pos.offset(dir);
|
||||
BlockState state = world.getBlockState(p);
|
||||
if (BlocksHelper.isEndNylium(state) && !world.getBlockState(p.above()).is(EndTags.END_GROUND)) {
|
||||
|
@ -159,18 +158,4 @@ public class BoneMealItemMixin {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static {
|
||||
int index = 0;
|
||||
DIR = new Vec3i[3 * 3 * 3 - 1];
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
if (x != 0 || y != 0 || z != 0) {
|
||||
DIR[index++] = new Vec3i(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.util.Random;
|
|||
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class MHelper {
|
||||
|
@ -12,6 +13,7 @@ public class MHelper {
|
|||
public static final Random RANDOM = new Random();
|
||||
private static final float RAD_TO_DEG = 57.295779513082320876798154814105F;
|
||||
public static final float PHI = (float) (Math.PI * (3 - Math.sqrt(5)));
|
||||
private static final Vec3i[] RANDOM_OFFSETS = new Vec3i[3 * 3 * 3 - 1];
|
||||
|
||||
public static int color(int r, int g, int b) {
|
||||
return ALPHA | (r << 16) | (g << 8) | b;
|
||||
|
@ -346,4 +348,22 @@ public class MHelper {
|
|||
float vz = (float) Math.cos(angleY);
|
||||
return new Vector3f(vx, 0, vz);
|
||||
}
|
||||
|
||||
public static Vec3i[] getOffsets(Random random) {
|
||||
MHelper.shuffle(RANDOM_OFFSETS, random);
|
||||
return RANDOM_OFFSETS;
|
||||
}
|
||||
|
||||
static {
|
||||
int index = 0;
|
||||
for (int x = -1; x <= 1; x++) {
|
||||
for (int y = -1; y <= 1; y++) {
|
||||
for (int z = -1; z <= 1; z++) {
|
||||
if (x != 0 || y != 0 || z != 0) {
|
||||
RANDOM_OFFSETS[index++] = new Vec3i(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue