Fixed issue with sodium
This commit is contained in:
parent
c949652e99
commit
2e8564a26c
2 changed files with 46 additions and 25 deletions
|
@ -2,17 +2,24 @@ package ru.betterend.blocks;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import ru.betterend.blocks.basis.BlockBase;
|
||||
import ru.betterend.registry.EndBlocks;
|
||||
import ru.betterend.util.BlocksHelper;
|
||||
|
@ -29,6 +36,32 @@ public class BrimstoneBlock extends BlockBase {
|
|||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
|
||||
stateManager.add(ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
|
||||
if (world.isClient()) {
|
||||
updateChunks((ClientWorld) world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
public void onBroken(WorldAccess world, BlockPos pos, BlockState state) {
|
||||
if (world.isClient()) {
|
||||
updateChunks((ClientWorld) world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateChunks(ClientWorld world, BlockPos pos) {
|
||||
int y = pos.getY() >> 4;
|
||||
int x1 = (pos.getX() - 2) >> 4;
|
||||
int z1 = (pos.getZ() - 2) >> 4;
|
||||
int x2 = (pos.getX() + 2) >> 4;
|
||||
int z2 = (pos.getZ() + 2) >> 4;
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
world.scheduleBlockRenders(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||
|
|
|
@ -23,8 +23,7 @@ import ru.betterend.util.MHelper;
|
|||
public class BiomeColorsMixin {
|
||||
private static final int POISON_COLOR = MHelper.color(92, 160, 78);
|
||||
private static final int STREAM_COLOR = MHelper.color(105, 213, 244);
|
||||
private static final Point[] OUTER_POINTS;
|
||||
private static final Point[] INNER_POINTS;
|
||||
private static final Point[] OFFSETS;
|
||||
private static final boolean HAS_SODIUM;
|
||||
|
||||
@Inject(method = "getWaterColor", at = @At("RETURN"), cancellable = true)
|
||||
|
@ -33,22 +32,11 @@ public class BiomeColorsMixin {
|
|||
BlockRenderView view = HAS_SODIUM ? MinecraftClient.getInstance().world : world;
|
||||
Mutable mut = new Mutable();
|
||||
mut.setY(pos.getY());
|
||||
|
||||
for (Point offset: INNER_POINTS) {
|
||||
mut.setX(pos.getX() + offset.x);
|
||||
mut.setZ(pos.getZ() + offset.y);
|
||||
for (int i = 0; i < OFFSETS.length; i++) {
|
||||
mut.setX(pos.getX() + OFFSETS[i].x);
|
||||
mut.setZ(pos.getZ() + OFFSETS[i].y);
|
||||
if ((view.getBlockState(mut).isOf(EndBlocks.BRIMSTONE))) {
|
||||
info.setReturnValue(POISON_COLOR);
|
||||
info.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (Point offset: OUTER_POINTS) {
|
||||
mut.setX(pos.getX() + offset.x);
|
||||
mut.setZ(pos.getZ() + offset.y);
|
||||
if ((view.getBlockState(mut).isOf(EndBlocks.BRIMSTONE))) {
|
||||
info.setReturnValue(STREAM_COLOR);
|
||||
info.setReturnValue(i < 16 ? STREAM_COLOR : POISON_COLOR);
|
||||
info.cancel();
|
||||
return;
|
||||
}
|
||||
|
@ -59,21 +47,21 @@ public class BiomeColorsMixin {
|
|||
static {
|
||||
HAS_SODIUM = FabricLoader.getInstance().isModLoaded("sodium");
|
||||
|
||||
OUTER_POINTS = new Point[16];
|
||||
OFFSETS = new Point[20];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int p = i - 1;
|
||||
OUTER_POINTS[i] = new Point(p, -2);
|
||||
OUTER_POINTS[i + 3] = new Point(p, 2);
|
||||
OUTER_POINTS[i + 6] = new Point(-2, p);
|
||||
OUTER_POINTS[i + 9] = new Point(2, p);
|
||||
OFFSETS[i] = new Point(p, -2);
|
||||
OFFSETS[i + 3] = new Point(p, 2);
|
||||
OFFSETS[i + 6] = new Point(-2, p);
|
||||
OFFSETS[i + 9] = new Point(2, p);
|
||||
}
|
||||
|
||||
INNER_POINTS = new Point[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int inner = i + 16;
|
||||
Direction dir = BlocksHelper.HORIZONTAL[i];
|
||||
INNER_POINTS[i] = new Point(dir.getOffsetX(), dir.getOffsetZ());
|
||||
OFFSETS[inner] = new Point(dir.getOffsetX(), dir.getOffsetZ());
|
||||
dir = BlocksHelper.HORIZONTAL[(i + 1) & 3];
|
||||
OUTER_POINTS[i + 12] = new Point(INNER_POINTS[i].x + dir.getOffsetX(), INNER_POINTS[i].y + dir.getOffsetZ());
|
||||
OFFSETS[i + 12] = new Point(OFFSETS[inner].x + dir.getOffsetX(), OFFSETS[inner].y + dir.getOffsetZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue