MC 1.12.2 refactoring and cleanup

This commit is contained in:
James Seibel
2026-05-12 21:38:07 -05:00
parent 7448483f84
commit fbf812091d
24 changed files with 458 additions and 175 deletions
@@ -566,6 +566,7 @@ if (isNotCommonProject) {
outputs.file(output) outputs.file(output)
doLast { doLast {
output.withWriter("UTF-8") { writer -> output.withWriter("UTF-8") { writer ->
writer.writeLine("#PARSE_ESCAPES")
new JsonSlurper() new JsonSlurper()
.parse(input) .parse(input)
.each { key, value -> .each { key, value ->
+3 -1
View File
@@ -43,4 +43,6 @@ sourcesJar {
def commonSources = project(":common").sourcesJar def commonSources = project(":common").sourcesJar
dependsOn commonSources dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) } from commonSources.archiveFile.map { zipTree(it) }
} }
@@ -59,13 +59,6 @@ import org.lwjgl.opengl.GL32;
import java.util.concurrent.AbstractExecutorService; import java.util.concurrent.AbstractExecutorService;
/**
* This handles all events sent to the client,
* and is the starting point for most of the mod.
*
* @author James_Seibel
* @version 2023-7-27
*/
public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy
{ {
private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class); private static final IMinecraftClientWrapper MC = SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class);
@@ -124,6 +117,7 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy
//==============// //==============//
// chunk events // // chunk events //
//==============// //==============//
//region
@SubscribeEvent @SubscribeEvent
public void rightClickBlockEvent(PlayerInteractEvent.RightClickBlock event) public void rightClickBlockEvent(PlayerInteractEvent.RightClickBlock event)
@@ -185,11 +179,14 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy
} }
} }
//endregion
//==============// //==============//
// key bindings // // key bindings //
//==============// //==============//
//region
@SubscribeEvent @SubscribeEvent
public void registerKeyBindings(InputEvent.KeyInputEvent event) public void registerKeyBindings(InputEvent.KeyInputEvent event)
@@ -206,10 +203,14 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy
ClientApi.INSTANCE.keyPressedEvent(event.getKey());*/ ClientApi.INSTANCE.keyPressedEvent(event.getKey());*/
} }
//endregion
//===========// //===========//
// rendering // // rendering //
//===========// //===========//
//region
@SubscribeEvent @SubscribeEvent
public void afterLevelRenderEvent(TickEvent.RenderTickEvent event) public void afterLevelRenderEvent(TickEvent.RenderTickEvent event)
@@ -231,11 +232,20 @@ public class CleanroomClientProxy implements AbstractModInitializer.IEventProxy
} }
@SubscribeEvent @SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent.Text event) { public void onRenderOverlay(RenderGameOverlayEvent.Text event)
{
Minecraft mc = Minecraft.getMinecraft(); Minecraft mc = Minecraft.getMinecraft();
if (event.isCanceled() || !mc.gameSettings.showDebugInfo) return; if (event.isCanceled()
|| !mc.gameSettings.showDebugInfo)
{
return;
}
F3Screen.addStringToDisplay(event.getRight()); F3Screen.addStringToDisplay(event.getRight());
} }
//endregion
} }
@@ -82,15 +82,18 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy
//=============// //=============//
// constructor // // constructor //
//=============// //=============//
//region
public CleanroomServerProxy(boolean isDedicated) { this.isDedicated = isDedicated; } public CleanroomServerProxy(boolean isDedicated) { this.isDedicated = isDedicated; }
//endregion
//========// //========//
// events // // events //
//========// //========//
//region
// ServerLevelLoadEvent // ServerLevelLoadEvent
@SubscribeEvent @SubscribeEvent
@@ -132,9 +135,11 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy
@SubscribeEvent @SubscribeEvent
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event)
{ this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event)); } { this.serverApi.serverPlayerJoinEvent(getServerPlayerWrapper(event)); }
@SubscribeEvent @SubscribeEvent
public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event) public void playerLoggedOutEvent(PlayerEvent.PlayerLoggedOutEvent event)
{ this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event)); } { this.serverApi.serverPlayerDisconnectEvent(getServerPlayerWrapper(event)); }
@SubscribeEvent @SubscribeEvent
public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event) public void playerChangedDimensionEvent(PlayerEvent.PlayerChangedDimensionEvent event)
{ {
@@ -145,15 +150,17 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy
); );
} }
//endregion
//================// //================//
// helper methods // // helper methods //
//================// //================//
//region
private static ServerLevelWrapper getServerLevelWrapper(WorldServer level) { return ServerLevelWrapper.getWrapper(level); } private static ServerLevelWrapper getServerLevelWrapper(WorldServer level) { return ServerLevelWrapper.getWrapper(level); }
private static ServerLevelWrapper getServerLevelWrapper(int dimensionId, PlayerEvent event) private static ServerLevelWrapper getServerLevelWrapper(int dimensionId, PlayerEvent event)
{ {
MinecraftServer server = event.player.getServer(); MinecraftServer server = event.player.getServer();
@@ -166,8 +173,9 @@ public class CleanroomServerProxy implements AbstractModInitializer.IEventProxy
} }
private static ServerPlayerWrapper getServerPlayerWrapper(PlayerEvent event) private static ServerPlayerWrapper getServerPlayerWrapper(PlayerEvent event)
{ { return ServerPlayerWrapper.getWrapper((EntityPlayerMP) event.player); }
return ServerPlayerWrapper.getWrapper((EntityPlayerMP) event.player);
} //endregion
} }
@@ -46,23 +46,21 @@ public abstract class MixinEntityPlayerMP implements IMixinServerPlayer
@Nullable @Nullable
private volatile WorldServer distantHorizons$dimensionChangeDestination; private volatile WorldServer distantHorizons$dimensionChangeDestination;
@Override @Override
@Nullable @Nullable
public WorldServer distantHorizons$getDimensionChangeDestination() public WorldServer distantHorizons$getDimensionChangeDestination()
{ { return this.distantHorizons$dimensionChangeDestination; }
return this.distantHorizons$dimensionChangeDestination;
}
@Inject(at = @At("HEAD"), method = "changeDimension(ILnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;") @Inject(at = @At("HEAD"), method = "changeDimension(ILnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/entity/Entity;")
public void setDimensionChangeDestination(int destinationDimensionID, ITeleporter teleporter, CallbackInfoReturnable<Entity> cir) public void setDimensionChangeDestination(int destinationDimensionID, ITeleporter teleporter, CallbackInfoReturnable<Entity> cir)
{ { this.distantHorizons$dimensionChangeDestination = this.server.getWorld(destinationDimensionID); }
this.distantHorizons$dimensionChangeDestination = this.server.getWorld(destinationDimensionID);
}
@Inject(at = @At("RETURN"), method = "clearInvulnerableDimensionChange") @Inject(at = @At("RETURN"), method = "clearInvulnerableDimensionChange")
public void clearDimensionChangeDestination(CallbackInfo ci) public void clearDimensionChangeDestination(CallbackInfo ci)
{ { this.distantHorizons$dimensionChangeDestination = null; }
this.distantHorizons$dimensionChangeDestination = null;
}
} }
@@ -1,6 +1,9 @@
package com.seibel.distanthorizons.common.commands; package com.seibel.distanthorizons.common.commands;
#if MC_VER > MC_1_12_2 #if MC_VER <= MC_1_12_2
public abstract class AbstractCommand {}
#else
import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.CommandContext;
import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper; import com.seibel.distanthorizons.common.wrappers.misc.ServerPlayerWrapper;
@@ -38,6 +38,8 @@ public class CommandInitializer
private static final PermissionCheck COMMAND_PERMISSION_CHECK = new PermissionCheck.Require(Permissions.COMMANDS_OWNER); private static final PermissionCheck COMMAND_PERMISSION_CHECK = new PermissionCheck.Require(Permissions.COMMANDS_OWNER);
#endif #endif
#if MC_VER <= MC_1_12_2 #if MC_VER <= MC_1_12_2
public static ICommand initCommands() public static ICommand initCommands()
{ {
@@ -98,7 +100,9 @@ public class CommandInitializer
}; };
} }
#else #else
/** /**
* A received command dispatcher, which is held until the server is ready to initialize the commands. * A received command dispatcher, which is held until the server is ready to initialize the commands.
*/ */
@@ -33,7 +33,7 @@ import java.util.function.ToIntBiFunction;
/** /**
* Command for managing config. * Command for managing config.
*/ */
public class ConfigCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif public class ConfigCommand extends AbstractCommand
{ {
#if MC_VER <= MC_1_12_2 #if MC_VER <= MC_1_12_2
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({"unchecked", "rawtypes"})
@@ -94,7 +94,9 @@ public class ConfigCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif
} }
} }
} }
#else #else
private static final List<CommandArgumentData<?>> commandArguments = Arrays.asList( private static final List<CommandArgumentData<?>> commandArguments = Arrays.asList(
new CommandArgumentData<>(Integer.class, configEntry -> integer(configEntry.getMin(), configEntry.getMax()), IntegerArgumentType::getInteger), new CommandArgumentData<>(Integer.class, configEntry -> integer(configEntry.getMin(), configEntry.getMax()), IntegerArgumentType::getInteger),
new CommandArgumentData<>(Double.class, configEntry -> doubleArg(configEntry.getMin(), configEntry.getMax()), DoubleArgumentType::getDouble), new CommandArgumentData<>(Double.class, configEntry -> doubleArg(configEntry.getMin(), configEntry.getMax()), DoubleArgumentType::getDouble),
@@ -17,7 +17,7 @@ import static net.minecraft.commands.Commands.literal;
#endif #endif
public class CrashCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif public class CrashCommand extends AbstractCommand
{ {
#if MC_VER <= MC_1_12_2 #if MC_VER <= MC_1_12_2
public void execute(ICommandSender sender, String[] args) public void execute(ICommandSender sender, String[] args)
@@ -16,7 +16,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class DebugCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif public class DebugCommand extends AbstractCommand
{ {
private static String getDebugString() private static String getDebugString()
{ {
@@ -32,7 +32,7 @@ import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class PregenCommand #if MC_VER > MC_1_12_2 extends AbstractCommand #endif public class PregenCommand extends AbstractCommand
{ {
private PregenManager getPregenManager() private PregenManager getPregenManager()
{ {
@@ -18,8 +18,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
public class MixinChunkMapCommon public class MixinChunkMapCommon
{ {
#if MC_VER <= MC_1_12_2
public static void onChunkSave(#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif level, #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk #if MC_VER > MC_1_12_2, CallbackInfoReturnable<Boolean> ci #endif) public static void onChunkSave(WorldServer level, Chunk chunk)
#else
public static void onChunkSave(ServerLevel level, ChunkAccess chunk, CallbackInfoReturnable<Boolean> ci)
#endif
{ {
IServerLevelWrapper levelWrapper = ServerLevelWrapper.getWrapper(level); IServerLevelWrapper levelWrapper = ServerLevelWrapper.getWrapper(level);
@@ -77,8 +80,13 @@ public class MixinChunkMapCommon
// biome validation // // biome validation //
// some chunks may be missing their biomes, which cause issues when attempting to save them // some chunks may be missing their biomes, which cause issues when attempting to save them
#if MC_VER <= MC_1_17_1 #if MC_VER <= MC_1_12_2
if (chunk.#if MC_VER <= MC_1_12_2 getBiomeArray() #else getBiomes() #endif == null) if (chunk. getBiomeArray() == null)
{
return;
}
#elif MC_VER <= MC_1_17_1
if (chunk.getBiomes() == null)
{ {
return; return;
} }
@@ -182,13 +182,20 @@ public class GLState implements AutoCloseable
if (frameBufferSet) if (frameBufferSet)
{ {
if (GL32.glIsTexture(this.frameBufferTexture0)) if (GL32.glIsTexture(this.frameBufferTexture0))
{
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.frameBufferTexture0, 0); GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT0, GL32.GL_TEXTURE_2D, this.frameBufferTexture0, 0);
}
if (this.frameBufferTexture1 != 0 && GL32.glIsTexture(this.frameBufferTexture1)) if (this.frameBufferTexture1 != 0 && GL32.glIsTexture(this.frameBufferTexture1))
{
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_TEXTURE_2D, this.frameBufferTexture1, 0); GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_COLOR_ATTACHMENT1, GL32.GL_TEXTURE_2D, this.frameBufferTexture1, 0);
}
if (GL32.glIsTexture(this.frameBufferDepthTexture)) if (GL32.glIsTexture(this.frameBufferDepthTexture))
{
GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_TEXTURE_2D, this.frameBufferDepthTexture, 0); GL32.glFramebufferTexture2D(GL32.GL_FRAMEBUFFER, GL32.GL_DEPTH_ATTACHMENT, GL32.GL_TEXTURE_2D, this.frameBufferDepthTexture, 0);
}
} }
GL32.glBindVertexArray(GL32.glIsVertexArray(this.vao) ? this.vao : 0); GL32.glBindVertexArray(GL32.glIsVertexArray(this.vao) ? this.vao : 0);
@@ -34,16 +34,22 @@ import net.minecraft.world.level.LevelAccessor;
public class ProxyUtil public class ProxyUtil
{ {
public static ILevelWrapper getLevelWrapper(#if MC_VER <= MC_1_12_2 World #else LevelAccessor #endif level) public static ILevelWrapper getLevelWrapper(
#if MC_VER <= MC_1_12_2 World #else LevelAccessor #endif level
)
{ {
ILevelWrapper levelWrapper; ILevelWrapper levelWrapper;
if (level instanceof #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif) if (level instanceof #if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif)
{ {
levelWrapper = ServerLevelWrapper.getWrapper(#if MC_VER <= MC_1_12_2 (WorldServer) #else (ServerLevel) #endif level); levelWrapper = ServerLevelWrapper.getWrapper(
#if MC_VER <= MC_1_12_2 (WorldServer) #else (ServerLevel) #endif level
);
} }
else else
{ {
levelWrapper = ClientLevelWrapper.getWrapper(#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif level); levelWrapper = ClientLevelWrapper.getWrapper(
#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif level
);
} }
return levelWrapper; return levelWrapper;
@@ -49,8 +49,6 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
#endif #endif
private static final ConcurrentHashMap<BlockBiomeWrapperPair, Integer> COLOR_BY_BLOCK_BIOME_PAIR = new ConcurrentHashMap<>(); private static final ConcurrentHashMap<BlockBiomeWrapperPair, Integer> COLOR_BY_BLOCK_BIOME_PAIR = new ConcurrentHashMap<>();
/** returned if the color cache is incomplete */
public static final int INVALID_COLOR = -1;
protected BiomeWrapper biomeWrapper; protected BiomeWrapper biomeWrapper;
@@ -102,7 +100,7 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
* Can be called by DH directly, skipping some of MC's logic * Can be called by DH directly, skipping some of MC's logic
* to speed up tint getting slightly. * to speed up tint getting slightly.
* *
* @return {@link AbstractDhTintGetter#INVALID_COLOR} if any of the biomes needed for this position * @return {@link ClientBlockStateColorCache#INVALID_COLOR} if any of the biomes needed for this position
* were not cached. In that case calling {@link AbstractDhTintGetter#getBlockTint(BlockPos, ColorResolver)} * were not cached. In that case calling {@link AbstractDhTintGetter#getBlockTint(BlockPos, ColorResolver)}
* will need to be called by MC's ColorResolver so we can * will need to be called by MC's ColorResolver so we can
* populate the color cache. * populate the color cache.
@@ -163,9 +161,9 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
int id = FullDataPointUtil.getId(dataPoint); int id = FullDataPointUtil.getId(dataPoint);
BiomeWrapper biomeWrapper = (BiomeWrapper) this.fullDataSource.mapping.getBiomeWrapper(id); BiomeWrapper biomeWrapper = (BiomeWrapper) this.fullDataSource.mapping.getBiomeWrapper(id);
int color = this.tryGetClientBiomeColor(colorResolver, biomeWrapper); int color = this.tryGetClientBiomeColor(colorResolver, biomeWrapper);
if (color == INVALID_COLOR) if (color == ClientBlockStateColorCache.INVALID_COLOR)
{ {
return INVALID_COLOR; return ClientBlockStateColorCache.INVALID_COLOR;
} }
@@ -214,7 +212,7 @@ public abstract class AbstractDhTintGetter implements BlockAndTintGetter
// no color resolver is present, // no color resolver is present,
// the cache needs to be populated before // the cache needs to be populated before
// we can use the fast path // we can use the fast path
return INVALID_COLOR; return ClientBlockStateColorCache.INVALID_COLOR;
} }
@@ -342,7 +342,9 @@ public class BiomeWrapper implements IBiomeWrapper
} }
} }
public static BiomeDeserializeResult deserializeBiome(String resourceLocationString #if MC_VER > MC_1_12_2, net.minecraft.core.RegistryAccess registryAccess #endif) throws IOException public static BiomeDeserializeResult deserializeBiome(String resourceLocationString
#if MC_VER > MC_1_12_2, net.minecraft.core.RegistryAccess registryAccess #endif
) throws IOException
{ {
// parse the resource location // parse the resource location
int separatorIndex = resourceLocationString.indexOf(":"); int separatorIndex = resourceLocationString.indexOf(":");
@@ -373,10 +375,10 @@ public class BiomeWrapper implements IBiomeWrapper
boolean success; boolean success;
#if MC_VER == MC_1_12_2 #if MC_VER <= MC_1_12_2
Biome biome = Biome.REGISTRY.getObject(resourceLocation); Biome biome = Biome.REGISTRY.getObject(resourceLocation);
success = (biome != null); success = (biome != null);
#elif MC_VER == MC_1_16_5 || MC_VER == MC_1_17_1 #elif MC_VER <= MC_1_17_1
Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation); Biome biome = registryAccess.registryOrThrow(Registry.BIOME_REGISTRY).get(resourceLocation);
success = (biome != null); success = (biome != null);
#elif MC_VER <= MC_1_19_2 #elif MC_VER <= MC_1_19_2
@@ -153,33 +153,58 @@ public class BlockStateWrapper implements IBlockStateWrapper
// constructors // // constructors //
//==============// //==============//
//region //region
#if MC_VER <= MC_1_12_2
/** /**
* Can be faster than {@link BlockStateWrapper#fromBlockState(IBlockState, ILevelWrapper)} * Can be faster than BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)
* in cases where the same block state is expected to be referenced multiple times. * in cases where the same block state is expected to be referenced multiple times.
*/ */
#else public static BlockStateWrapper fromBlockState(
/** #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState,
* Can be faster than {@link BlockStateWrapper#fromBlockState(BlockState, ILevelWrapper)} ILevelWrapper levelWrapper, IBlockStateWrapper guess)
* in cases where the same block state is expected to be referenced multiple times.
*/
#endif
public static BlockStateWrapper fromBlockState(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper, IBlockStateWrapper guess)
{ {
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif guessBlockState = (guess == null || guess.isAir()) ? null : (#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif) guess.getWrappedMcObject(); if (guess == null)
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif inputBlockState = (blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif) ? null : blockState;
if (guess instanceof BlockStateWrapper
&& guessBlockState == inputBlockState)
{
return (BlockStateWrapper) guess;
}
else
{ {
return fromBlockState(blockState, levelWrapper); return fromBlockState(blockState, levelWrapper);
} }
// guess block state
BlockStateWrapper wrapperGuess = (BlockStateWrapper) guess;
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif guessBlockState;
if(isAir(wrapperGuess.blockState))
{
guessBlockState = null;
}
else
{
#if MC_VER <= MC_1_12_2
guessBlockState = (IBlockState) guess.getWrappedMcObject();
#else
guessBlockState = (BlockState) guess.getWrappedMcObject();
#endif
}
// input block state
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif inputBlockState;
if (isAir(blockState))
{
inputBlockState = null;
}
else
{
inputBlockState = blockState;
}
if (guessBlockState == inputBlockState)
{
return (BlockStateWrapper) guess;
}
return fromBlockState(blockState, levelWrapper);
} }
public static BlockStateWrapper fromBlockState(@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, ILevelWrapper levelWrapper) public static BlockStateWrapper fromBlockState(
@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState,
ILevelWrapper levelWrapper)
{ {
// air is a special case // air is a special case
if (isAir(blockState)) if (isAir(blockState))
@@ -248,13 +273,13 @@ public class BlockStateWrapper implements IBlockStateWrapper
} }
else else
{ {
#if MC_VER <= MC_1_12_2 #if MC_VER <= MC_1_12_2
this.isLiquid = this.blockState.getMaterial().isLiquid() || this.blockState.getBlock() instanceof IFluidBlock; this.isLiquid = this.blockState.getMaterial().isLiquid() || this.blockState.getBlock() instanceof IFluidBlock;
#elif MC_VER < MC_1_20_1 #elif MC_VER < MC_1_20_1
this.isLiquid = this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty(); this.isLiquid = this.blockState.getMaterial().isLiquid() || !this.blockState.getFluidState().isEmpty();
#else #else
this.isLiquid = !this.blockState.getFluidState().isEmpty(); this.isLiquid = !this.blockState.getFluidState().isEmpty();
#endif #endif
} }
} }
@@ -349,7 +374,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
// beacon tint color // beacon tint color
Color beaconTintColor = null; Color beaconTintColor = null;
// 1.12.2 doesn't have block for beacon beam // 1.12.2 doesn't support changing the beacon beam color
#if MC_VER > MC_1_12_2 #if MC_VER > MC_1_12_2
if (this.blockState != null if (this.blockState != null
// beacon blocks also show up here, but since they block the beacon beam we don't want their color // beacon blocks also show up here, but since they block the beacon beam we don't want their color
@@ -462,71 +487,188 @@ public class BlockStateWrapper implements IBlockStateWrapper
@Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, @Nullable #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState,
String lowercaseSerialString, String lowercaseSerialString,
boolean isLiquid boolean isLiquid
) )
{ {
if (blockState == null) if (isAir(blockState))
{ {
return EDhApiBlockMaterial.AIR; return EDhApiBlockMaterial.AIR;
} }
if (#if MC_VER <= MC_1_12_2 blockState.getBlock() instanceof BlockLeaves #else blockState.is(BlockTags.LEAVES) #endif
//========//
// leaves //
//========//
//region
boolean isLeafBlock;
#if MC_VER <= MC_1_12_2
isLeafBlock = blockState.getBlock() instanceof BlockLeaves;
#else
isLeafBlock = blockState.is(BlockTags.LEAVES);
#endif
if (isLeafBlock
|| lowercaseSerialString.contains("bamboo") || lowercaseSerialString.contains("bamboo")
|| lowercaseSerialString.contains("cactus") || lowercaseSerialString.contains("cactus")
|| lowercaseSerialString.contains("chorus_flower") || lowercaseSerialString.contains("chorus_flower")
|| lowercaseSerialString.contains("mushroom") || lowercaseSerialString.contains("mushroom")
) )
{ {
return EDhApiBlockMaterial.LEAVES; return EDhApiBlockMaterial.LEAVES;
} }
else if (#if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.LAVA || blockState.getBlock() == Blocks.FLOWING_LAVA #else blockState.is(Blocks.LAVA) #endif) //endregion
//======//
// lava //
//======//
//region
boolean isLavaBlock;
#if MC_VER <= MC_1_12_2
isLavaBlock = blockState.getBlock() == Blocks.LAVA || blockState.getBlock() == Blocks.FLOWING_LAVA;
#else
isLavaBlock = blockState.is(Blocks.LAVA);
#endif
if (isLavaBlock)
{ {
return EDhApiBlockMaterial.LAVA; return EDhApiBlockMaterial.LAVA;
} }
else if (isLiquid || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.FLOWING_WATER #else blockState.is(Blocks.WATER) #endif)
//endregion
//=======//
// water //
//=======//
//region
boolean isWaterBlock;
#if MC_VER <= MC_1_12_2
isWaterBlock = blockState.getBlock() == Blocks.WATER || blockState.getBlock() == Blocks.FLOWING_WATER;
#else
isWaterBlock = blockState.is(Blocks.WATER);
#endif
if (isLiquid
|| isWaterBlock)
{ {
return EDhApiBlockMaterial.WATER; return EDhApiBlockMaterial.WATER;
} }
else if (#if MC_VER <= MC_1_12_2 blockState.getBlock().getSoundType() #else blockState.getSoundType() #endif == SoundType.WOOD
//endregion
//======//
// wood //
//======//
//region
boolean isWoodSoundingBlock;
#if MC_VER <= MC_1_12_2
isWoodSoundingBlock = blockState.getBlock().getSoundType() == SoundType.WOOD;
#else
isWoodSoundingBlock = blockState.getSoundType() == SoundType.WOOD;
#endif
boolean isCherryWood;
#if MC_VER <= MC_1_19_2
isCherryWood = false;
#else
isWoodSoundingBlock = blockState.getSoundType() == SoundType.CHERRY_WOOD;
#endif
if (isWoodSoundingBlock
|| lowercaseSerialString.contains("root") || lowercaseSerialString.contains("root")
#if MC_VER >= MC_1_19_4 || isCherryWood
|| blockState.getSoundType() == SoundType.CHERRY_WOOD )
#endif
)
{ {
return EDhApiBlockMaterial.WOOD; return EDhApiBlockMaterial.WOOD;
} }
else if (#if MC_VER <= MC_1_12_2 blockState.getBlock().getSoundType() #else blockState.getSoundType() #endif == SoundType.METAL
#if MC_VER >= MC_1_19_2 //endregion
|| blockState.getSoundType() == SoundType.COPPER
#endif
#if MC_VER >= MC_1_20_4
|| blockState.getSoundType() == SoundType.COPPER_BULB //=======//
|| blockState.getSoundType() == SoundType.COPPER_GRATE // metal //
#endif //=======//
) //region
boolean isMetalSoundingBlock;
#if MC_VER <= MC_1_12_2
isMetalSoundingBlock = blockState.getBlock().getSoundType() == SoundType.METAL;
#else
isMetalSoundingBlock = blockState.getSoundType() == SoundType.METAL;
#endif
boolean isCopperSounding;
#if MC_VER <= MC_1_18_2
isCopperSounding = false;
#elif MC_VER <= MC_1_20_2
isCopperSounding = blockState.getSoundType() == SoundType.COPPER
#else
isCopperSounding
= blockState.getSoundType() == SoundType.COPPER
|| blockState.getSoundType() == SoundType.COPPER_BULB
|| blockState.getSoundType() == SoundType.COPPER_GRATE;
#endif
if (isMetalSoundingBlock
|| isCopperSounding)
{ {
return EDhApiBlockMaterial.METAL; return EDhApiBlockMaterial.METAL;
} }
else if (
lowercaseSerialString.contains("grass_block") //endregion
|| lowercaseSerialString.contains("grass_slab")
)
//=======//
// grass //
//=======//
//region
if (lowercaseSerialString.contains("grass_block")
|| lowercaseSerialString.contains("grass_slab")
)
{ {
return EDhApiBlockMaterial.GRASS; return EDhApiBlockMaterial.GRASS;
} }
else if (
//endregion
//======//
// dirt //
//======//
//region
if (
lowercaseSerialString.contains("dirt") lowercaseSerialString.contains("dirt")
|| lowercaseSerialString.contains("gravel") || lowercaseSerialString.contains("gravel")
|| lowercaseSerialString.contains("mud") || lowercaseSerialString.contains("mud")
|| lowercaseSerialString.contains("podzol") || lowercaseSerialString.contains("podzol")
|| lowercaseSerialString.contains("mycelium") || lowercaseSerialString.contains("mycelium")
) )
{ {
return EDhApiBlockMaterial.DIRT; return EDhApiBlockMaterial.DIRT;
} }
//endregion
//===========//
// deepslate //
//===========//
//region
#if MC_VER >= MC_1_17_1 #if MC_VER >= MC_1_17_1
else if (blockState.getSoundType() == SoundType.DEEPSLATE if (blockState.getSoundType() == SoundType.DEEPSLATE
|| blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS || blockState.getSoundType() == SoundType.DEEPSLATE_BRICKS
|| blockState.getSoundType() == SoundType.DEEPSLATE_TILES || blockState.getSoundType() == SoundType.DEEPSLATE_TILES
|| blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE || blockState.getSoundType() == SoundType.POLISHED_DEEPSLATE
@@ -535,35 +677,68 @@ public class BlockStateWrapper implements IBlockStateWrapper
return EDhApiBlockMaterial.DEEPSLATE; return EDhApiBlockMaterial.DEEPSLATE;
} }
#endif #endif
else if (lowercaseSerialString.contains("snow"))
{ //endregion
return EDhApiBlockMaterial.SNOW;
}
else if (lowercaseSerialString.contains("sand"))
{ //============//
return EDhApiBlockMaterial.SAND; // netherrack //
} //============//
else if (lowercaseSerialString.contains("terracotta")) //region
{
return EDhApiBlockMaterial.TERRACOTTA; boolean isNetherRack;
} #if MC_VER <= MC_1_12_2
else if (#if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.NETHERRACK #else blockState.is(BlockTags.BASE_STONE_NETHER) #endif) isNetherRack = blockState.getBlock() == Blocks.NETHERRACK;
#else
isNetherRack = blockState.is(BlockTags.BASE_STONE_NETHER);
#endif
if (isNetherRack)
{ {
return EDhApiBlockMaterial.NETHER_STONE; return EDhApiBlockMaterial.NETHER_STONE;
} }
else if (lowercaseSerialString.contains("stone")
//endregion
//=============//
// misc/simple //
//=============//
//region
if (lowercaseSerialString.contains("snow"))
{
return EDhApiBlockMaterial.SNOW;
}
if (lowercaseSerialString.contains("sand"))
{
return EDhApiBlockMaterial.SAND;
}
if (lowercaseSerialString.contains("terracotta"))
{
return EDhApiBlockMaterial.TERRACOTTA;
}
if (lowercaseSerialString.contains("stone")
|| lowercaseSerialString.contains("ore")) || lowercaseSerialString.contains("ore"))
{ {
return EDhApiBlockMaterial.STONE; return EDhApiBlockMaterial.STONE;
} }
else if (#if MC_VER <= MC_1_12_2 blockState.getLightValue() #else blockState.getLightEmission() #endif > 0)
if (getLightEmission(blockState) > 0)
{ {
return EDhApiBlockMaterial.ILLUMINATED; return EDhApiBlockMaterial.ILLUMINATED;
} }
else
{ //endregion
return EDhApiBlockMaterial.UNKNOWN;
}
return EDhApiBlockMaterial.UNKNOWN;
} }
private static int calculateOpacity( private static int calculateOpacity(
@@ -691,8 +866,10 @@ public class BlockStateWrapper implements IBlockStateWrapper
return waterSurfaceReplacementBlocks; return waterSurfaceReplacementBlocks;
} }
ObjectOpenHashSet<String> baseIgnoredBlock = new ObjectOpenHashSet<>(); ObjectOpenHashSet<String> baseIgnoredBlockResourceSet = new ObjectOpenHashSet<>();
waterSurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSurfaceBlockReplacementCsv, baseIgnoredBlock, levelWrapper); waterSurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSurfaceBlockReplacementCsv, baseIgnoredBlockResourceSet, levelWrapper);
waterSubsurfaceReplacementBlocks.remove(AIR);
return waterSurfaceReplacementBlocks; return waterSurfaceReplacementBlocks;
} }
public static ObjectOpenHashSet<IBlockStateWrapper> getWaterSubsurfaceReplacementBlocks(ILevelWrapper levelWrapper) public static ObjectOpenHashSet<IBlockStateWrapper> getWaterSubsurfaceReplacementBlocks(ILevelWrapper levelWrapper)
@@ -703,8 +880,10 @@ public class BlockStateWrapper implements IBlockStateWrapper
return waterSubsurfaceReplacementBlocks; return waterSubsurfaceReplacementBlocks;
} }
ObjectOpenHashSet<String> baseIgnoredBlock = new ObjectOpenHashSet<>(); ObjectOpenHashSet<String> baseIgnoredBlockResourceSet = new ObjectOpenHashSet<>();
waterSubsurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSubSurfaceBlockReplacementCsv, baseIgnoredBlock, levelWrapper); waterSubsurfaceReplacementBlocks = getAllBlockWrappers(Config.Client.Advanced.Graphics.Culling.waterSubSurfaceBlockReplacementCsv, baseIgnoredBlockResourceSet, levelWrapper);
// air will be present if any invalid resource locations are present
// but we don't want to replace air with water, that'll cause monoliths
waterSubsurfaceReplacementBlocks.remove(AIR); waterSubsurfaceReplacementBlocks.remove(AIR);
return waterSubsurfaceReplacementBlocks; return waterSubsurfaceReplacementBlocks;
@@ -826,7 +1005,21 @@ public class BlockStateWrapper implements IBlockStateWrapper
public int getOpacity() { return this.opacity; } public int getOpacity() { return this.opacity; }
@Override @Override
public int getLightEmission() { return (this.blockState != null) ? #if MC_VER <= MC_1_12_2 this.blockState.getLightValue() #else this.blockState.getLightEmission() #endif : 0; } public int getLightEmission() { return getLightEmission(this.blockState); }
public static int getLightEmission(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState)
{
if (blockState == null)
{
return 0;
}
#if MC_VER <= MC_1_12_2
return blockState.getLightValue();
#else
return blockState.getLightEmission();
#endif
}
@Override @Override
public String getSerialString() { return this.serialString; } public String getSerialString() { return this.serialString; }
@@ -836,7 +1029,19 @@ public class BlockStateWrapper implements IBlockStateWrapper
@Override @Override
public boolean isAir() { return isAir(this.blockState); } public boolean isAir() { return isAir(this.blockState); }
public static boolean isAir(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState) { return blockState == null || #if MC_VER <= MC_1_12_2 blockState.getBlock() == Blocks.AIR #else blockState.isAir() #endif; } public static boolean isAir(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState)
{
if (blockState == null)
{
return true;
}
#if MC_VER <= MC_1_12_2
return blockState.getBlock() == Blocks.AIR;
#else
return blockState.isAir();
#endif
}
@Override @Override
public boolean isSolid() { return this.isSolid; } public boolean isSolid() { return this.isSolid; }
@@ -1056,7 +1261,12 @@ public class BlockStateWrapper implements IBlockStateWrapper
} }
} }
foundState = #if MC_VER <= MC_1_12_2 block.getDefaultState() #else block.defaultBlockState() #endif;
#if MC_VER <= MC_1_12_2
foundState = block.getDefaultState();
#else
foundState = block.defaultBlockState();
#endif
} }
foundWrapper = fromBlockState(foundState, levelWrapper); foundWrapper = fromBlockState(foundState, levelWrapper);
@@ -1086,12 +1296,13 @@ public class BlockStateWrapper implements IBlockStateWrapper
// get the property list for this block (doesn't contain this block state's values, just the names and possible values) // get the property list for this block (doesn't contain this block state's values, just the names and possible values)
#if MC_VER <= MC_1_12_2 #if MC_VER <= MC_1_12_2
java.util.Collection<IProperty<?>> blockPropertyCollection = blockState.getPropertyKeys(); java.util.Collection<IProperty<?>> blockPropertyCollection = blockState.getPropertyKeys();
List<IProperty<?>> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection);
#else #else
java.util.Collection<net.minecraft.world.level.block.state.properties.Property<?>> blockPropertyCollection = blockState.getProperties();; java.util.Collection<net.minecraft.world.level.block.state.properties.Property<?>> blockPropertyCollection = blockState.getProperties();;
List<net.minecraft.world.level.block.state.properties.Property<?>> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection);
#endif #endif
// alphabetically sort the list so they are always in the same order // alphabetically sort the list so they are always in the same order
List<#if MC_VER <= MC_1_12_2 IProperty<?> #else net.minecraft.world.level.block.state.properties.Property<?> #endif> sortedBlockPropteryList = new ArrayList<>(blockPropertyCollection);
sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName())); sortedBlockPropteryList.sort((a, b) -> a.getName().compareTo(b.getName()));
@@ -94,7 +94,11 @@ public class ClientBlockStateColorCache
private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif; private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif;
private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>(); #if MC_VER <= MC_1_12_2
#else
private static final HashSet<BlockState> BLOCK_STATES_THAT_NEED_LEVEL = new HashSet<>();
#endif
private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BROKEN_BLOCK_STATES = new HashSet<>(); private static final HashSet<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif> BROKEN_BLOCK_STATES = new HashSet<>();
/** /**
@@ -107,6 +111,8 @@ public class ClientBlockStateColorCache
*/ */
private static final ReentrantLock RESOLVE_LOCK = new ReentrantLock(); private static final ReentrantLock RESOLVE_LOCK = new ReentrantLock();
public static final int INVALID_COLOR = -1;
/** This is the order each direction on a block is processed when attempting to get the texture/color */ /** This is the order each direction on a block is processed when attempting to get the texture/color */
private static final @Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[] COLOR_RESOLUTION_DIRECTION_ORDER = private static final @Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif[] COLOR_RESOLUTION_DIRECTION_ORDER =
@@ -225,7 +231,9 @@ public class ClientBlockStateColorCache
//=============// //=============//
//region //region
public ClientBlockStateColorCache(#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState, IClientLevelWrapper clientLevelWrapper) public ClientBlockStateColorCache(
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState,
IClientLevelWrapper clientLevelWrapper)
{ {
this.blockState = blockState; this.blockState = blockState;
this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper); this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper);
@@ -241,6 +249,7 @@ public class ClientBlockStateColorCache
//===================// //===================//
// color calculation // // color calculation //
//===================// //===================//
//region
private void resolveColors() private void resolveColors()
{ {
@@ -268,11 +277,7 @@ public class ClientBlockStateColorCache
} }
#endif #endif
#if MC_VER <= MC_1_12_2 if (!this.blockStateWrapper.isLiquid())
if (!this.blockState.getMaterial().isLiquid())
#else
if (this.blockState.getFluidState().isEmpty())
#endif
{ {
// look for the first non-empty direction // look for the first non-empty direction
List<BakedQuad> quads = null; List<BakedQuad> quads = null;
@@ -593,6 +598,8 @@ public class ClientBlockStateColorCache
EColorMode.getColorMode(this.blockState.getBlock())); EColorMode.getColorMode(this.blockState.getBlock()));
} }
//endregion
//===============// //===============//
@@ -602,11 +609,7 @@ public class ClientBlockStateColorCache
public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos) public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos)
{ {
// only get the tint if the block needs to be tinted // only get the tint if the block needs to be tinted
#if MC_VER <= MC_1_12_2 int tintColor = INVALID_COLOR;
int tintColor = -1;
#else
int tintColor = AbstractDhTintGetter.INVALID_COLOR;
#endif
if (this.needPostTinting) if (this.needPostTinting)
{ {
@@ -624,8 +627,10 @@ public class ClientBlockStateColorCache
// 1.12.2 doesn't have BlockAndTintGetter -> get tintColor from biome // 1.12.2 doesn't have BlockAndTintGetter -> get tintColor from biome
WorldClient world = (WorldClient) this.clientLevelWrapper.getWrappedMcObject(); WorldClient world = (WorldClient) this.clientLevelWrapper.getWrappedMcObject();
BlockPos mcPos = new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); BlockPos mcPos = new BlockPos(blockPos.getX(), blockPos.getY(), blockPos.getZ());
Block block = this.blockState.getBlock(); Block block = this.blockState.getBlock();
if (block instanceof BlockGrass || block instanceof BlockBush) if (block instanceof BlockGrass
|| block instanceof BlockBush)
{ {
tintColor = biomeWrapper.biome.getGrassColorAtPos(mcPos); tintColor = biomeWrapper.biome.getGrassColorAtPos(mcPos);
} }
@@ -635,7 +640,8 @@ public class ClientBlockStateColorCache
} }
else if (block instanceof BlockLiquid) // We don't want lava to fall into the else block else if (block instanceof BlockLiquid) // We don't want lava to fall into the else block
{ {
if(block == Blocks.WATER || block == Blocks.FLOWING_WATER) if(block == Blocks.WATER
|| block == Blocks.FLOWING_WATER)
{ {
tintColor = biomeWrapper.biome.getWaterColor(); tintColor = biomeWrapper.biome.getWaterColor();
} }
@@ -721,29 +727,32 @@ public class ClientBlockStateColorCache
} }
} }
#endif #endif
// level-specific logic is only needed for MC 1.21.11 and older
#if MC_VER <= MC_1_21_11 && MC_VER > MC_1_12_2
// use the level logic only if requested
if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
{
// the level shouldn't be used all the time due to it breaking some blocks tinting
// specifically oceans don't render correctly
TintGetterOverride tintOverride = TintOverrideGetter.get();
tintOverride.update(biomeWrapper, this.blockStateWrapper, fullDataSource, this.clientLevelWrapper);
tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos)); // level-specific logic is only needed for MC 1.21.11 and older
if (tintColor == AbstractDhTintGetter.INVALID_COLOR) #if MC_VER <= MC_1_21_11 && MC_VER > MC_1_12_2
// use the level logic only if requested
if (BLOCK_STATES_THAT_NEED_LEVEL.contains(this.blockState))
{ {
tintColor = Minecraft.getInstance() // the level shouldn't be used all the time due to it breaking some blocks tinting
.getBlockColors() // specifically oceans don't render correctly
.getColor(this.blockState,
tintOverride, TintGetterOverride tintOverride = TintOverrideGetter.get();
McObjectConverter.Convert(blockPos), tintOverride.update(biomeWrapper, this.blockStateWrapper, fullDataSource, this.clientLevelWrapper);
this.tintIndex);
tintColor = tintOverride.tryGetBlockTint(new DhBlockPosMutable(blockPos));
if (tintColor == AbstractDhTintGetter.INVALID_COLOR)
{
tintColor = Minecraft.getInstance()
.getBlockColors()
.getColor(this.blockState,
tintOverride,
McObjectConverter.Convert(blockPos),
this.tintIndex);
}
} }
} #endif
#endif
} }
catch (Exception e) catch (Exception e)
{ {
@@ -758,11 +767,7 @@ public class ClientBlockStateColorCache
int returnColor; int returnColor;
#if MC_VER <= MC_1_12_2 if (tintColor != INVALID_COLOR)
if (tintColor != -1)
#else
if (tintColor != AbstractDhTintGetter.INVALID_COLOR)
#endif
{ {
returnColor = ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor); returnColor = ColorUtil.multiplyARGBwithRGB(this.baseColor, tintColor);
} }
@@ -15,7 +15,11 @@ public class GetConfigScreen
{ {
protected static final DhLogger LOGGER = new DhLoggerBuilder().build(); protected static final DhLogger LOGGER = new DhLoggerBuilder().build();
public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent) #if MC_VER <= MC_1_12_2
public static GuiScreen getScreen(GuiScreen parent)
#else
public static Screen getScreen(Screen parent)
#endif
{ {
if (ModInfo.IS_DEV_BUILD) if (ModInfo.IS_DEV_BUILD)
{ {
@@ -34,7 +34,11 @@ import java.util.*;
public class MinecraftScreen public class MinecraftScreen
{ {
public static #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif getScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName) #if MC_VER <= MC_1_12_2
public static GuiScreen getScreen(GuiScreen parent, AbstractScreen screen, String translationName)
#else
public static Screen getScreen(Screen parent, AbstractScreen screen, String translationName)
#endif
{ {
return new ConfigScreenRenderer(parent, screen, translationName); return new ConfigScreenRenderer(parent, screen, translationName);
} }
@@ -56,7 +60,9 @@ public class MinecraftScreen
{ return net.minecraft.network.chat.Component.translatable(str, args); } { return net.minecraft.network.chat.Component.translatable(str, args); }
#endif #endif
protected ConfigScreenRenderer(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, AbstractScreen screen, String translationName) protected ConfigScreenRenderer(
#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent,
AbstractScreen screen, String translationName)
{ {
super(translate(translationName)); super(translate(translationName));
#if MC_VER <= MC_1_12_2 #if MC_VER <= MC_1_12_2
@@ -77,7 +83,13 @@ public class MinecraftScreen
protected void init() protected void init()
#endif #endif
{ {
super.#if MC_VER <= MC_1_12_2 initGui(); #else init(); #endif // Init Minecraft's screen #if MC_VER <= MC_1_12_2
super.initGui();
#else
super.init();
#endif
#if MC_VER <= MC_1_12_2 #if MC_VER <= MC_1_12_2
this.screen.width = Display.getWidth(); this.screen.width = Display.getWidth();
this.screen.height = Display.getHeight(); this.screen.height = Display.getHeight();
@@ -1,4 +1,5 @@
package com.seibel.distanthorizons.common.wrappers.gui; package com.seibel.distanthorizons.common.wrappers.gui;
#if MC_VER <= MC_1_12_2 #if MC_VER <= MC_1_12_2
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
@@ -85,7 +85,8 @@ public class ClientLevelWrapper implements IClientLevelWrapper
private final ConcurrentHashMap<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>(); private final ConcurrentHashMap<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> blockColorCacheByBlockState = new ConcurrentHashMap<>();
/** cached method reference to reduce GC overhead */ /** cached method reference to reduce GC overhead */
private final Function<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> createCachedBlockColorCacheFunc = (blockState) -> new ClientBlockStateColorCache(blockState, this); private final Function<#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif, ClientBlockStateColorCache> createCachedBlockColorCacheFunc
= (blockState) -> new ClientBlockStateColorCache(blockState, this);
private boolean cloudColorFailLogged = false; private boolean cloudColorFailLogged = false;
+1 -1
View File
@@ -48,7 +48,7 @@ versionStr=
# This defines what MC version Intellij will use for the preprocessor # This defines what MC version Intellij will use for the preprocessor
# and what version is used automatically by build and run commands # and what version is used automatically by build and run commands
mcVer=26.1.2 mcVer=1.12.2
# Defines the maximum amount of memory Minecraft is allowed when run in a development environment # Defines the maximum amount of memory Minecraft is allowed when run in a development environment
minecraftMemoryJavaArg=-Xmx6G minecraftMemoryJavaArg=-Xmx6G
+1 -1
View File
@@ -8,7 +8,7 @@ builds_for=cleanroom
embed_joml=true embed_joml=true
# Netty # Netty
netty_version=4.2.9.Final netty_version=4.1.9.Final
# LWJGL # LWJGL
lwjgl_version=3.3.6 lwjgl_version=3.3.6