Skip to content

Commit

Permalink
fix #192
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexModGuy committed Dec 18, 2024
1 parent 3881735 commit ef45663
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 37 deletions.
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ org.gradle.daemon=true
mod_version=2.6.0
modid=citadel
mc_version=1.20.1
forge_version=47.0.34
forge_version=47.0.34
# Gradle
systemProp.org.gradle.internal.http.connectionTimeout=180000
systemProp.org.gradle.internal.http.socketTimeout=180000
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.Date;

public class CitadelConstants {
public static final boolean REMAPREFS = true;
public static final boolean REMAPREFS = false;
public static final boolean DEBUG = false;

private static boolean initDate = false;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/github/alexthe666/citadel/ServerProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.alexthe666.citadel.server.entity.IDancesToJukebox;
import com.github.alexthe666.citadel.server.event.EventChangeEntityTickRate;
import com.github.alexthe666.citadel.server.generation.SurfaceRulesManager;
import com.github.alexthe666.citadel.server.tick.ServerTickRateTracker;
import com.github.alexthe666.citadel.server.world.CitadelServerData;
import com.github.alexthe666.citadel.server.world.ModifiableTickRateServer;
Expand All @@ -13,6 +14,9 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.SurfaceRules;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.EventPriority;
Expand All @@ -27,6 +31,7 @@ public ServerProxy() {
}

public void onPreInit() {
SurfaceRulesManager.registerOverworldSurfaceRule(SurfaceRules.isBiome(Biomes.BEACH), SurfaceRules.state(Blocks.BEDROCK.defaultBlockState()));
}

public void handleAnimationPacket(int entityId, int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private void masterTick() {

@ModifyConstant(
method = {"Lnet/minecraft/server/MinecraftServer;runServer()V"},
remap = CitadelConstants.REMAPREFS,
constant = @Constant(longValue = 50L),
expect = 4)
private long citadel_serverMsPerTick(long value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.github.alexthe666.citadel.mixin;

import com.github.alexthe666.citadel.CitadelConstants;
import com.github.alexthe666.citadel.server.generation.SurfaceRulesManager;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
import net.minecraft.world.level.levelgen.SurfaceRules;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;

@Mixin(value = NoiseBasedChunkGenerator.class, priority = 500)
public class NoiseBasedChunkGeneratorMixin {

@Unique
private SurfaceRules.RuleSource mergedSurfaceRules;

private SurfaceRules.RuleSource getOrCreateMergedSurfaceRules(SurfaceRules.RuleSource ruleSource){
if(mergedSurfaceRules == null){
this.mergedSurfaceRules = SurfaceRulesManager.mergeOverworldRules(ruleSource);
}
return this.mergedSurfaceRules;
}

@ModifyArg(
method = "Lnet/minecraft/world/level/levelgen/NoiseBasedChunkGenerator;buildSurface(Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/world/level/levelgen/WorldGenerationContext;Lnet/minecraft/world/level/levelgen/RandomState;Lnet/minecraft/world/level/StructureManager;Lnet/minecraft/world/level/biome/BiomeManager;Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;)V",
remap = CitadelConstants.REMAPREFS,
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/SurfaceSystem;buildSurface(Lnet/minecraft/world/level/levelgen/RandomState;Lnet/minecraft/world/level/biome/BiomeManager;Lnet/minecraft/core/Registry;ZLnet/minecraft/world/level/levelgen/WorldGenerationContext;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/world/level/levelgen/NoiseChunk;Lnet/minecraft/world/level/levelgen/SurfaceRules$RuleSource;)V"),
index = 7
)
private SurfaceRules.RuleSource citadel_buildSurface_modifySurfaceRules(SurfaceRules.RuleSource ruleSource) {
return getOrCreateMergedSurfaceRules(ruleSource);
}

@ModifyArg(
method = "Lnet/minecraft/world/level/levelgen/NoiseBasedChunkGenerator;applyCarvers(Lnet/minecraft/server/level/WorldGenRegion;JLnet/minecraft/world/level/levelgen/RandomState;Lnet/minecraft/world/level/biome/BiomeManager;Lnet/minecraft/world/level/StructureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;Lnet/minecraft/world/level/levelgen/GenerationStep$Carving;)V",
remap = CitadelConstants.REMAPREFS,
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/levelgen/carver/CarvingContext;<init>(Lnet/minecraft/world/level/levelgen/NoiseBasedChunkGenerator;Lnet/minecraft/core/RegistryAccess;Lnet/minecraft/world/level/LevelHeightAccessor;Lnet/minecraft/world/level/levelgen/NoiseChunk;Lnet/minecraft/world/level/levelgen/RandomState;Lnet/minecraft/world/level/levelgen/SurfaceRules$RuleSource;)V"),
index = 5
)
private SurfaceRules.RuleSource citadel_applyCarvers_modifySurfaceRules(SurfaceRules.RuleSource ruleSource) {
return getOrCreateMergedSurfaceRules(ruleSource);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@ public class LevelRendererMixin {
private Minecraft minecraft;

@Inject(method = "Lnet/minecraft/client/renderer/LevelRenderer;initOutline()V",
remap = CitadelConstants.REMAPREFS,
at = @At("TAIL"))
private void citadel_initOutline(CallbackInfo ci) {
PostEffectRegistry.onInitializeOutline();
}

@Inject(method = "Lnet/minecraft/client/renderer/LevelRenderer;resize(II)V",
remap = CitadelConstants.REMAPREFS,
at = @At("TAIL"))
private void citadel_resize(int x, int y, CallbackInfo ci) {
PostEffectRegistry.resize(x, y);
}


@Inject(method = "Lnet/minecraft/client/renderer/LevelRenderer;renderLevel(Lcom/mojang/blaze3d/vertex/PoseStack;FJZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lorg/joml/Matrix4f;)V",
remap = CitadelConstants.REMAPREFS,
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/RenderBuffers;bufferSource()Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;",
Expand All @@ -55,6 +58,7 @@ private void citadel_renderLevel_beforeEntities(PoseStack poseStack, float f, lo
}

@Inject(method = "Lnet/minecraft/client/renderer/LevelRenderer;renderLevel(Lcom/mojang/blaze3d/vertex/PoseStack;FJZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lorg/joml/Matrix4f;)V",
remap = CitadelConstants.REMAPREFS,
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/renderer/OutlineBufferSource;endOutlineBatch()V",
Expand All @@ -65,6 +69,7 @@ private void citadel_renderLevel_process(PoseStack poseStack, float f, long l, b
}

@Inject(method = "Lnet/minecraft/client/renderer/LevelRenderer;renderLevel(Lcom/mojang/blaze3d/vertex/PoseStack;FJZLnet/minecraft/client/Camera;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lorg/joml/Matrix4f;)V",
remap = CitadelConstants.REMAPREFS,
at = @At(
value = "TAIL"
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ protected void citadel_render_setupAnim_before(LivingEntity livingEntity, float

@Inject(
method = {"Lnet/minecraft/client/renderer/entity/LivingEntityRenderer;render(Lnet/minecraft/world/entity/LivingEntity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V"},
remap = true,

remap = CitadelConstants.REMAPREFS,
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/model/EntityModel;setupAnim(Lnet/minecraft/world/entity/Entity;FFFFF)V",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ protected void citadel_postRenderSplashText(GuiGraphics guiGraphics, int width,

@ModifyConstant(
method = {"Lnet/minecraft/client/gui/components/SplashRenderer;render(Lnet/minecraft/client/gui/GuiGraphics;ILnet/minecraft/client/gui/Font;I)V"},
remap = CitadelConstants.REMAPREFS,
constant = @Constant(intValue = 16776960))
private int citadel_splashTextColor(int value) {
return splashTextColor == -1 ? value : splashTextColor;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/citadel.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"LevelMixin",
"LivingEntityMixin",
"MinecraftServerMixin",
"NoiseGeneratorSettingsMixin",
"NoiseBasedChunkGeneratorMixin",
"ServerLevelMixin",
"SmithingMenuMixin"
],
Expand Down

0 comments on commit ef45663

Please sign in to comment.