Skip to content

Commit

Permalink
Update to 1.20.1 (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadiboo committed Sep 3, 2023
1 parent 8eb247f commit 6b56089
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 29 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ modGroup = io.github.cadiboo.nocubes
modFileName = NoCubes

# The version of Minecraft we are modding for
modMinecraftVersion = 1.19.4
modMinecraftVersion = 1.20.1

# The Forge version the mod is being made for
modForgeVersion = 45.0.43
modForgeVersion = 47.0.14
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.DirtPathBlock;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;

import java.util.function.Consumer;
import java.util.function.Predicate;
Expand Down Expand Up @@ -86,8 +83,8 @@ static void renderFaceWithConnectedTextures(ChunkRenderInfo renderer, MutableObj
var state = renderState.state;
var worldPos = objects.pos.set(renderState.relativePos()).move(area.start);

var material = state.getMaterial();
var renderBothSides = material != Material.GLASS && material != Material.PORTAL && material != Material.TOP_SNOW && !MeshRenderer.isSolidRender(state);
var block = state.getBlock();
var renderBothSides = !(block instanceof BeaconBeamBlock) && !(block instanceof NetherPortalBlock || block instanceof EndPortalBlock) && !(block instanceof SnowLayerBlock) && !MeshRenderer.isSolidRender(state);

var light = renderer.light.get(area.start, faceInfo.face, faceInfo.normal, objects.light);
var shade = renderer.getShade(faceInfo.approximateDirection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraftforge.client.event.RenderHighlightEvent;
import net.minecraftforge.client.event.RenderLevelLastEvent;
import net.minecraftforge.client.event.RenderLevelStageEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -54,7 +54,7 @@ public static void register(IEventBus events) {
Pair.of("drawNearbyCollisions", OverlayRenderers::drawNearbyCollisions),
Pair.of("drawNearbyDensities", OverlayRenderers::drawNearbyDensities)
);
events.addListener((RenderLevelLastEvent event) -> renderDebugOverlays(event, debugOverlays));
events.addListener((RenderLevelStageEvent event) -> renderDebugOverlays(event, debugOverlays));
}


Expand Down Expand Up @@ -91,10 +91,13 @@ public static void renderBlockHighlight(RenderHighlightEvent event) {
}
}

public static void renderDebugOverlays(RenderLevelLastEvent event, List<Pair<String, DebugOverlay>> overlays) {
public static void renderDebugOverlays(RenderLevelStageEvent event, List<Pair<String, DebugOverlay>> overlays) {
if (!NoCubesConfig.Common.debugEnabled)
return;

if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_LEVEL)
return;

var minecraft = Minecraft.getInstance();
var camera = minecraft.gameRenderer.getMainCamera();

Expand Down Expand Up @@ -148,7 +151,7 @@ private static void drawOutlineAroundNearbySmoothableBlocks(Camera camera, PoseS
var start = viewer.blockPosition().offset(-5, -5, -5);
var end = viewer.blockPosition().offset(5, 5, 5);
BlockPos.betweenClosed(start, end).forEach(pos -> {
if (isSmoothable.test(viewer.level.getBlockState(pos)))
if (isSmoothable.test(viewer.level().getBlockState(pos)))
drawShape(matrix, buffer.get(), Shapes.block(), pos, camera.getPosition(), color);
});
}
Expand All @@ -164,7 +167,7 @@ private static void drawNearbyDensities(Camera camera, PoseStack matrix, Supplie
var distanceIndicator = Shapes.box(0, 0, 0, 1 / 8F, 1 / 8F, 1 / 8F);
var densityColor = new Color(0F, 0F, 1F, 0.5F);
var viewer = camera.getEntity();
try (var area = new Area(viewer.level, getTargetedPosForDebugRendering(viewer).offset(-2, -2, -2), new BlockPos(4, 4, 4), NoCubesConfig.Server.mesher)) {
try (var area = new Area(viewer.level(), getTargetedPosForDebugRendering(viewer).offset(-2, -2, -2), new BlockPos(4, 4, 4), NoCubesConfig.Server.mesher)) {
var states = area.getAndCacheBlocks();
var densities = new float[area.numBlocks()];
for (int i = 0; i < densities.length; ++i)
Expand Down Expand Up @@ -217,7 +220,7 @@ private static void drawNearbyCollisions(Camera camera, PoseStack matrix, Suppli
var deviatingColor = new Color(0, 1, 0, 0.4F);
var viewer = camera.getEntity();
var viewerShape = Shapes.create(viewer.getBoundingBox());
viewer.level.getBlockCollisions(viewer, viewer.getBoundingBox().inflate(collisionsRenderRadius)).forEach(voxelShape -> {
viewer.level().getBlockCollisions(viewer, viewer.getBoundingBox().inflate(collisionsRenderRadius)).forEach(voxelShape -> {
boolean intersects = Shapes.joinIsNotEmpty(voxelShape, viewerShape, BooleanOp.AND);
drawShape(matrix, buffer.get(), voxelShape, BlockPos.ZERO, camera.getPosition(), intersects ? intersectingColor : deviatingColor);
});
Expand All @@ -231,7 +234,7 @@ private static void drawNearbyMeshCollisions(Camera camera, PoseStack matrix, Su
var color = new Color(NoCubesConfig.Client.debugRenderCollisions ? 1 : 0, 1, 0, 0.4F);
var viewer = camera.getEntity();
var start = viewer.blockPosition().offset(-collisionsRenderRadius, -collisionsRenderRadius, -collisionsRenderRadius);
CollisionHandler.forEachCollisionShapeRelativeToStart(viewer.level, new MutableBlockPos(),
CollisionHandler.forEachCollisionShapeRelativeToStart(viewer.level(), new MutableBlockPos(),
start.getX(), start.getX() + collisionsRenderRadius * 2,
start.getY(), start.getY() + collisionsRenderRadius * 2,
start.getZ(), start.getZ() + collisionsRenderRadius * 2,
Expand All @@ -258,8 +261,8 @@ private static void drawNearbyMesh(Entity viewer, Vec3 camera, PoseStack matrix,
var meshSize = new BlockPos(16, 16, 16);
var meshStart = viewer.blockPosition().offset(-meshSize.getX() / 2, -meshSize.getY() / 2 + 2, -meshSize.getZ() / 2);
try (
var area = new Area(viewer.level, meshStart, meshSize, mesher);
var light = new LightCache((ClientLevel) viewer.level, meshStart, meshSize)
var area = new Area(viewer.level(), meshStart, meshSize, mesher);
var light = new LightCache((ClientLevel) viewer.level(), meshStart, meshSize)
) {
var faceInfo = new FaceInfo();
var objects = new MutableObjects();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/github/cadiboo/nocubes/mesh/OldNoCubes.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import io.github.cadiboo.nocubes.util.Vec;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;

import java.util.function.Predicate;

Expand Down Expand Up @@ -237,7 +236,7 @@ public static void givePointRoughness(float roughness, Area area, Vec point) {
}

public static boolean isBlockAirPlantOrSnowLayer(BlockState state) {
return state.getMaterial() == Material.AIR || ModUtil.isPlant(state) || ModUtil.isSnowLayer(state);
return state.isAir() || ModUtil.isPlant(state) || ModUtil.isSnowLayer(state);
}

public static boolean doesPointTopIntersectWithAir(Area area, Vec point, MutableBlockPos pos) {
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/io/github/cadiboo/nocubes/util/ModUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.Material;
import net.minecraftforge.common.IPlantable;
import org.apache.logging.log4j.LogManager;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -79,15 +79,7 @@ public static boolean isShortPlant(BlockState state) {
}

public static boolean isPlant(BlockState state) {
Material material = state.getMaterial();
return material == Material.PLANT ||
material == Material.WATER_PLANT ||
material == Material.REPLACEABLE_PLANT ||
material == Material.REPLACEABLE_FIREPROOF_PLANT ||
material == Material.REPLACEABLE_WATER_PLANT ||
material == Material.BAMBOO_SAPLING ||
material == Material.BAMBOO ||
material == Material.VEGETABLE;
return state.getBlock() instanceof IPlantable;
}

/**
Expand Down

0 comments on commit 6b56089

Please sign in to comment.