Skip to content

Commit

Permalink
24w34a
Browse files Browse the repository at this point in the history
  • Loading branch information
gnembon committed Aug 21, 2024
1 parent f6d5529 commit 6d0c959
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check https://fabricmc.net/develop/
minecraft_version=24w33a
minecraft_version=24w34a
loader_version=0.15.11
jsr305_version=3.0.2
fabric_version=0.102.0+1.21
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/carpet/commands/PerimeterInfoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static int perimeterDiagnose(CommandSourceStack source, BlockPos pos, St
{
nbttagcompound.putString("id", mobId);
Entity baseEntity = EntityType.loadEntityRecursive(nbttagcompound, source.getLevel(), EntitySpawnReason.COMMAND, (entity_1x) -> {
entity_1x.moveTo(new BlockPos(pos.getX(), source.getLevel().getMinBuildHeight()-10, pos.getZ()), entity_1x.getYRot(), entity_1x. getXRot());
entity_1x.moveTo(new BlockPos(pos.getX(), source.getLevel().getMinY()-10, pos.getZ()), entity_1x.getYRot(), entity_1x. getXRot());
return !source.getLevel().addWithUUID(entity_1x) ? null : entity_1x;
});
if (!(baseEntity instanceof Mob))
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/carpet/helpers/EntityPlayerActionPack.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ boolean execute(ServerPlayer player, Action action)
BlockHitResult blockHit = (BlockHitResult) hit;
BlockPos pos = blockHit.getBlockPos();
Direction side = blockHit.getDirection();
if (pos.getY() < player.level().getMaxBuildHeight() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos))
if (pos.getY() < player.level().getMaxY() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos))
{
InteractionResult result = player.gameMode.useItemOn(player, world, player.getItemInHand(hand), hand, blockHit);
if (result instanceof InteractionResult.Success success)
Expand Down Expand Up @@ -402,17 +402,17 @@ boolean execute(ServerPlayer player, Action action) {
boolean blockBroken = false;
if (player.gameMode.getGameModeForPlayer().isCreative())
{
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxY(), -1);
ap.blockHitDelay = 5;
blockBroken = true;
}
else if (ap.currentBlock == null || !ap.currentBlock.equals(pos))
{
if (ap.currentBlock != null)
{
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, side, player.level().getMaxY(), -1);
}
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxY(), -1);
boolean notAir = !state.isAir();
if (notAir && ap.curBlockDamageMP == 0)
{
Expand All @@ -435,7 +435,7 @@ else if (ap.currentBlock == null || !ap.currentBlock.equals(pos))
ap.curBlockDamageMP += state.getDestroyProgress(player, player.level(), pos);
if (ap.curBlockDamageMP >= 1)
{
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, side, player.level().getMaxY(), -1);
ap.currentBlock = null;
ap.blockHitDelay = 5;
blockBroken = true;
Expand All @@ -457,7 +457,7 @@ void inactiveTick(ServerPlayer player, Action action)
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
if (ap.currentBlock == null) return;
player.level().destroyBlockProgress(-1, ap.currentBlock, -1);
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.level().getMaxBuildHeight(), -1);
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.level().getMaxY(), -1);
ap.currentBlock = null;
}
},
Expand Down
28 changes: 16 additions & 12 deletions src/main/java/carpet/mixins/RedstoneWireBlock_fastMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockInterface {

@Shadow
private void updatePowerStrength(Level world_1, BlockPos blockPos_1, BlockState blockState_1, @Nullable final Orientation orientation) { }
private void updatePowerStrength(Level world_1, BlockPos blockPos_1, BlockState blockState_1, @Nullable final Orientation orientation, boolean sup) { }

@Override
@Accessor("shouldSignal")
Expand All @@ -57,22 +57,22 @@ private void onRedstoneWireBlockCTOR(BlockBehaviour.Properties settings, Callbac

// =

public void fastUpdate(Level world, BlockPos pos, BlockState state, Orientation o) {
public void fastUpdate(Level world, BlockPos pos, BlockState state, Orientation o, boolean sup) {
// [CM] fastRedstoneDust -- update based on carpet rule
if (CarpetSettings.fastRedstoneDust) {
BlockPos source = null; // todo this probably removes all improvements from the original method
// so needs to be evaluated if its worth keeping
wireTurbo.updateSurroundingRedstone(world, pos, state, source);
return;
}
updatePowerStrength(world, pos, state, o);
updatePowerStrength(world, pos, state, o, sup);
}

/**
* @author theosib, soykaf, gnembon
*/
@Inject(method = "updatePowerStrength", at = @At("HEAD"), cancellable = true)
private void updateLogicAlternative(Level world, BlockPos pos, BlockState state, Orientation orientation, CallbackInfo cir) {
private void updateLogicAlternative(Level world, BlockPos pos, BlockState state, Orientation orientation, boolean sup, CallbackInfo cir) {
if (CarpetSettings.fastRedstoneDust) {
updateLogicPublic(world, pos, state);
cir.cancel();
Expand Down Expand Up @@ -114,17 +114,20 @@ public BlockState updateLogicPublic(Level world_1, BlockPos blockPos_1, BlockSta
// =


@Redirect(method = "onPlace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"))
private void redirectOnBlockAddedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1, Orientation o) {
fastUpdate(world_1, blockPos_1, blockState_1, o);
@Redirect(method = "onPlace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;Z)V"))
private void redirectOnBlockAddedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1, Orientation o, boolean sup) {
fastUpdate(world_1, blockPos_1, blockState_1, o, sup);
}

@Redirect(method = "onRemove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"))
private void redirectOnStateReplacedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1, Orientation o) {
fastUpdate(world_1, blockPos_1, blockState_1, o);
@Redirect(method = "onRemove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;Z)V"))
private void redirectOnStateReplacedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1, Orientation o, boolean sup) {
fastUpdate(world_1, blockPos_1, blockState_1, o, sup);
}

@Redirect(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"))
@Redirect(method = "neighborChanged", at = @At(value = "INVOKE", target =
"Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;Z)V"
//"Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"
))
//private void red(final RedStoneWireBlock instance, final Level level,
// final BlockPos blockPos, final BlockState blockState, final Orientation orientation)
private void redirectNeighborUpdateUpdate(
Expand All @@ -133,6 +136,7 @@ private void redirectNeighborUpdateUpdate(
BlockPos blockPos_1,
BlockState blockState_1,
Orientation o,
boolean sup,
BlockState blockState_2,
Level world_2,
BlockPos blockPos_2,
Expand All @@ -141,6 +145,6 @@ private void redirectNeighborUpdateUpdate(
boolean b
)
{
fastUpdate(world_1, blockPos_1, blockState_1, o);
fastUpdate(world_1, blockPos_1, blockState_1, o, sup);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public CompletableFuture<Void> relight(ChunkAccess chunk)

this.addTask(pos.x, pos.z, () -> 0, ThreadedLevelLightEngine.TaskType.PRE_UPDATE, Util.name(() -> {
super.propagateLightSources(pos);
int minY = chunk.getMinBuildHeight();
int maxY = chunk.getMaxBuildHeight();
int minY = chunk.getMinY();
int maxY = chunk.getMaxY();
int minX = pos.getMinBlockX();
int minZ = pos.getMinBlockZ();
BlockPos.MutableBlockPos poss = new BlockPos.MutableBlockPos();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/carpet/script/api/WorldAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,7 @@ LivingEntity getIndirectSourceEntity()
int biomeZ = QuartPos.fromBlock(pos.getZ());
try
{
int i = QuartPos.fromBlock(chunk.getMinBuildHeight());
int i = QuartPos.fromBlock(chunk.getMinY());
int j = i + QuartPos.fromBlock(chunk.getHeight()) - 1;
int k = Mth.clamp(biomeY, i, j);
int l = chunk.getSectionIndex(QuartPos.toBlock(k));
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/carpet/script/utils/ShapesRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.CoreShaders;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.LightTexture;
Expand Down Expand Up @@ -121,7 +122,7 @@ public void render(Matrix4f modelViewMatrix, Camera camera, float partialTick)
}
long currentTime = client.level.getGameTime();
RenderSystem.enableDepthTest();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
RenderSystem.setShader(CoreShaders.POSITION_COLOR);
RenderSystem.depthFunc(515);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
Expand Down Expand Up @@ -407,7 +408,7 @@ public void renderLines(PoseStack matrices, Tesselator tesselator, double cx, do
if (blockState.getBlock() instanceof LeavesBlock && !Minecraft.useFancyGraphics()) {
type = RenderType.solid();
} else {
type = ItemBlockRenderTypes.getRenderType(blockState, false);
type = ItemBlockRenderTypes.getRenderType(blockState);
}
client.getBlockRenderer().getModelRenderer().renderModel(matrices.last(), immediate.getBuffer(type), blockState, bakedModel, red, green, blue, light, OverlayTexture.NO_OVERLAY);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/carpet/script/utils/SystemInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public class SystemInfo
put("world_dimensions", c -> ListValue.wrap(c.server().levelKeys().stream().map(k -> ValueConversions.of(k.location()))));
put("world_spawn_point", c -> ValueConversions.of(c.server().overworld().getLevelData().getSpawnPos()));

put("world_bottom", c -> new NumericValue(c.level().getMinBuildHeight()));
put("world_bottom", c -> new NumericValue(c.level().getMinY()));

put("world_top", c -> new NumericValue(c.level().getMaxBuildHeight()));
put("world_top", c -> new NumericValue(c.level().getMaxY()));

put("world_center", c -> {
WorldBorder worldBorder = c.level().getWorldBorder();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/carpet/utils/PerimeterDiagnostics.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ else if (el instanceof AmbientCreature)
PerimeterDiagnostics diagnostic = new PerimeterDiagnostics(worldserver,ctype,el);
EntityType<?> type = EntityType.ZOMBIE;
if (el != null) type = el.getType();
int minY = worldserver.getMinBuildHeight();
int maxY = worldserver.getMaxBuildHeight();
int minY = worldserver.getMinY();
int maxY = worldserver.getMaxY();
for (int x = -128; x <= 128; ++x)
{
for (int z = -128; z <= 128; ++z)
Expand Down

0 comments on commit 6d0c959

Please sign in to comment.