preprocessor cleanup
This commit is contained in:
@@ -413,9 +413,12 @@ if (isNotCommonProject) {
|
||||
modsDir.mkdirs()
|
||||
|
||||
// Remove any stale DH jars before copying the fresh one
|
||||
modsDir.listFiles()?.each { file ->
|
||||
if (file.name.startsWith(rootProject.mod_name)) file.delete()
|
||||
modsDir.listFiles()?.each({ file ->
|
||||
if (file.name.startsWith(rootProject.mod_name))
|
||||
{
|
||||
file.delete()
|
||||
}
|
||||
});
|
||||
|
||||
// Copy shadow jar into mods folder so (Neo)Forge discovers it properly
|
||||
copy {
|
||||
|
||||
+25
-20
@@ -71,28 +71,23 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.client.color.block.BlockTintSource;
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
/**
|
||||
* This stores and calculates the colors
|
||||
* the given {@link IBlockState} should have based
|
||||
* the given BlockState should have based
|
||||
* on the given {@link IClientLevelWrapper}.
|
||||
*
|
||||
* @see ColorUtil
|
||||
*/
|
||||
#else
|
||||
/**
|
||||
* This stores and calculates the colors
|
||||
* the given {@link BlockState} should have based
|
||||
* on the given {@link IClientLevelWrapper}.
|
||||
*
|
||||
* @see ColorUtil
|
||||
*/
|
||||
#endif
|
||||
public class ClientBlockStateColorCache
|
||||
{
|
||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
|
||||
private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private static final Minecraft MC = Minecraft.getMinecraft();
|
||||
#else
|
||||
private static final Minecraft MC = Minecraft.getInstance();
|
||||
#endif
|
||||
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
#else
|
||||
@@ -115,15 +110,17 @@ public class ClientBlockStateColorCache
|
||||
|
||||
|
||||
/** 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 =
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.UP,
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing.UP #else Direction.UP #endif,
|
||||
null, // null represents "unculled" faces, IE the top of farmland
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.NORTH,
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.EAST,
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.WEST,
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.SOUTH,
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif.DOWN
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing.NORTH #else Direction.NORTH #endif,
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing.EAST #else Direction.EAST #endif,
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing.WEST #else Direction.WEST #endif,
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing.SOUTH #else Direction.SOUTH #endif,
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing.DOWN #else Direction.DOWN #endif
|
||||
};
|
||||
|
||||
private static final int FLOWER_COLOR_SCALE = 5;
|
||||
@@ -281,8 +278,16 @@ public class ClientBlockStateColorCache
|
||||
{
|
||||
// look for the first non-empty direction
|
||||
List<BakedQuad> quads = null;
|
||||
for (#if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction : COLOR_RESOLUTION_DIRECTION_ORDER)
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
EnumFacing direction;
|
||||
#else
|
||||
Direction direction;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < COLOR_RESOLUTION_DIRECTION_ORDER.length; i++)
|
||||
{
|
||||
direction = COLOR_RESOLUTION_DIRECTION_ORDER[i];
|
||||
quads = this.getQuadsForDirection(direction);
|
||||
if (quads != null && !quads.isEmpty()
|
||||
&& !(
|
||||
|
||||
+50
-9
@@ -74,7 +74,8 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_20_4 && MC_VER > MC_1_12_2
|
||||
#if MC_VER <= MC_1_12_2
|
||||
#elif MC_VER <= MC_1_20_4
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
#elif MC_VER > MC_1_12_2
|
||||
import net.minecraft.world.level.chunk.status.ChunkStatus;
|
||||
@@ -93,8 +94,12 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
private static boolean heightmapThreadWarningLogged = false;
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private final Chunk chunk;
|
||||
#else
|
||||
private final ChunkAccess chunk;
|
||||
#endif
|
||||
|
||||
private final #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk;
|
||||
private final DhChunkPos chunkPos;
|
||||
private final ILevelWrapper wrappedLevel;
|
||||
|
||||
@@ -125,7 +130,9 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
* fast since it will be called frequently on the MC
|
||||
* server thread and a slow method will cause server lag.
|
||||
*/
|
||||
public ChunkWrapper(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk, ILevelWrapper wrappedLevel)
|
||||
public ChunkWrapper(
|
||||
#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk,
|
||||
ILevelWrapper wrappedLevel)
|
||||
{
|
||||
this.chunk = chunk;
|
||||
this.wrappedLevel = wrappedLevel;
|
||||
@@ -257,7 +264,9 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
return this.maxNonEmptyHeight;
|
||||
}
|
||||
private static boolean isChunkSectionEmpty(#if MC_VER <= MC_1_12_2 ExtendedBlockStorage #else LevelChunkSection #endif section)
|
||||
private static boolean isChunkSectionEmpty(
|
||||
#if MC_VER <= MC_1_12_2 ExtendedBlockStorage #else LevelChunkSection #endif section
|
||||
)
|
||||
{
|
||||
#if MC_VER <= MC_1_17_1
|
||||
return section.isEmpty();
|
||||
@@ -373,8 +382,12 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
public IBiomeWrapper getBiome(int relX, int relY, int relZ)
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
BlockPos.MutableBlockPos blockPos = MUTABLE_BLOCK_POS_REF.get();
|
||||
blockPos.setPos(relX, relY, relZ);
|
||||
|
||||
World world = (World) this.wrappedLevel.getWrappedMcObject();
|
||||
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiome(new BlockPos(relX, relY, relZ), world.getBiomeProvider()), wrappedLevel);
|
||||
|
||||
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiome(blockPos, world.getBiomeProvider()), wrappedLevel);
|
||||
#elif MC_VER < MC_1_17_1
|
||||
return BiomeWrapper.getBiomeWrapper(this.chunk.getBiomes().getNoiseBiome(
|
||||
relX >> 2, relY >> 2, relZ >> 2),
|
||||
@@ -572,13 +585,41 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
#endif
|
||||
|
||||
@Override
|
||||
public int getMaxBlockX() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getXEnd() #else getMaxBlockX() #endif; }
|
||||
public int getMaxBlockX()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return this.chunk.getPos().getXEnd();
|
||||
#else
|
||||
return this.chunk.getPos().getMaxBlockX();
|
||||
#endif
|
||||
}
|
||||
@Override
|
||||
public int getMaxBlockZ() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getZEnd() #else getMaxBlockZ() #endif; }
|
||||
public int getMaxBlockZ()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return this.chunk.getPos().getZEnd();
|
||||
#else
|
||||
return this.chunk.getPos().getMaxBlockZ();
|
||||
#endif
|
||||
}
|
||||
@Override
|
||||
public int getMinBlockX() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getXStart() #else getMinBlockX() #endif; }
|
||||
public int getMinBlockX()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return this.chunk.getPos().getXStart();
|
||||
#else
|
||||
return this.chunk.getPos().getMinBlockX();
|
||||
#endif
|
||||
}
|
||||
@Override
|
||||
public int getMinBlockZ() { return this.chunk.getPos().#if MC_VER <= MC_1_12_2 getZStart() #else getMinBlockZ() #endif; }
|
||||
public int getMinBlockZ()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return this.chunk.getPos().getZStart();
|
||||
#else
|
||||
return this.chunk.getPos().getMinBlockZ();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+11
-10
@@ -76,28 +76,29 @@ public class GuiHelper
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void SetX(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif w, int x)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static void SetX(GuiButton widget, int x)
|
||||
#else
|
||||
public static void SetX(AbstractWidget widget, int x)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER < MC_1_19_4
|
||||
w.x = x;
|
||||
widget.x = x;
|
||||
#else
|
||||
w.setX(x);
|
||||
widget.setX(x);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static void SetY(GuiTextField w, int y)
|
||||
{
|
||||
w.y = y;
|
||||
}
|
||||
public static void SetY(GuiTextField textField, int y) { textField.y = y; }
|
||||
#endif
|
||||
|
||||
public static void SetY(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif w, int y)
|
||||
public static void SetY(#if MC_VER <= MC_1_12_2 GuiButton #else AbstractWidget #endif widget, int y)
|
||||
{
|
||||
#if MC_VER < MC_1_19_4
|
||||
w.y = y;
|
||||
widget.y = y;
|
||||
#else
|
||||
w.setY(y);
|
||||
widget.setY(y);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+18
-4
@@ -101,7 +101,11 @@ public class ClassicConfigGUI
|
||||
//==============//
|
||||
|
||||
/** if you want to get this config gui's screen call this */
|
||||
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, String category)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static GuiScreen getScreen(GuiScreen parent, String category)
|
||||
#else
|
||||
public static Screen getScreen(Screen parent, String category)
|
||||
#endif
|
||||
{ return new DhConfigScreen(parent, category); }
|
||||
|
||||
|
||||
@@ -110,7 +114,11 @@ public class ClassicConfigGUI
|
||||
// helper classes //
|
||||
//================//
|
||||
|
||||
public static class ConfigListWidget extends #if MC_VER <= MC_1_12_2 GuiListExtended #else ContainerObjectSelectionList<DhButtonEntry> #endif
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static class ConfigListWidget extends GuiListExtended
|
||||
#else
|
||||
public static class ConfigListWidget extends ContainerObjectSelectionList<DhButtonEntry>
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public List<DhButtonEntry> children = new ArrayList<>();
|
||||
@@ -261,8 +269,13 @@ public class ClassicConfigGUI
|
||||
private final EConfigCommentTextPosition textPosition;
|
||||
public final AbstractConfigBase dhConfigType;
|
||||
|
||||
public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> TEXT_BY_WIDGET = new HashMap<>();
|
||||
public static final Map< #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>();
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static final Map<Gui, ITextComponent> TEXT_BY_WIDGET = new HashMap<>();
|
||||
public static final Map<Gui, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>();
|
||||
#else
|
||||
public static final Map<AbstractWidget, Component> TEXT_BY_WIDGET = new HashMap<>();
|
||||
public static final Map<AbstractWidget, DhButtonEntry> BUTTON_BY_WIDGET = new HashMap<>();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -364,6 +377,7 @@ public class ClassicConfigGUI
|
||||
if (this.resetButton != null)
|
||||
{
|
||||
SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.resetButton, y);
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
((GuiButton) this.resetButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta);
|
||||
#elif MC_VER <= MC_1_21_11
|
||||
|
||||
+7
-1
@@ -42,7 +42,13 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
@Override
|
||||
public IServerKeyedClientLevel setServerKeyedLevel(IClientLevelWrapper clientLevel, String serverKey, String levelKey)
|
||||
{
|
||||
IServerKeyedClientLevel keyedLevel = new ServerKeyedClientLevelWrapper(#if MC_VER <= MC_1_12_2 (WorldClient) #else (ClientLevel) #endif clientLevel.getWrappedMcObject(), serverKey, levelKey);
|
||||
IServerKeyedClientLevel keyedLevel;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
keyedLevel = new ServerKeyedClientLevelWrapper((WorldClient) clientLevel.getWrappedMcObject(), serverKey, levelKey);
|
||||
#else
|
||||
keyedLevel = new ServerKeyedClientLevelWrapper((ClientLevel) clientLevel.getWrappedMcObject(), serverKey, levelKey);
|
||||
#endif
|
||||
|
||||
this.serverKeyedLevel = keyedLevel;
|
||||
this.enabled = true;
|
||||
return keyedLevel;
|
||||
|
||||
+5
-1
@@ -22,7 +22,11 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
public ServerKeyedClientLevelWrapper(#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level, String serverKey, String serverLevelKey)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public ServerKeyedClientLevelWrapper(WorldClient level, String serverKey, String serverLevelKey)
|
||||
#else
|
||||
public ServerKeyedClientLevelWrapper(ClientLevel level, String serverKey, String serverLevelKey)
|
||||
#endif
|
||||
{
|
||||
super(level);
|
||||
this.serverKey = serverKey;
|
||||
|
||||
+25
-4
@@ -83,7 +83,12 @@ import net.minecraft.client.GraphicsStatus;
|
||||
public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecraftSharedWrapper
|
||||
{
|
||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
private static final Minecraft MINECRAFT = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif;
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private static final Minecraft MINECRAFT = Minecraft.getMinecraft();
|
||||
#else
|
||||
private static final Minecraft MINECRAFT = Minecraft.getInstance();
|
||||
#endif
|
||||
|
||||
public static final MinecraftClientWrapper INSTANCE = new MinecraftClientWrapper();
|
||||
|
||||
@@ -98,20 +103,36 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
//region
|
||||
|
||||
@Override
|
||||
public boolean hasSinglePlayerServer() { return MINECRAFT.#if MC_VER <= MC_1_12_2 isSingleplayer() #else hasSingleplayerServer() #endif; }
|
||||
public boolean hasSinglePlayerServer()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return MINECRAFT.isSingleplayer();
|
||||
#else
|
||||
return MINECRAFT.hasSingleplayerServer();
|
||||
#endif
|
||||
}
|
||||
@Override
|
||||
public boolean clientConnectedToDedicatedServer()
|
||||
{
|
||||
return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif != null
|
||||
return this.hasServerConnection()
|
||||
&& !this.hasSinglePlayerServer();
|
||||
}
|
||||
@Override
|
||||
public boolean connectedToReplay()
|
||||
{
|
||||
return MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif == null
|
||||
return !this.hasServerConnection()
|
||||
&& !this.hasSinglePlayerServer() ;
|
||||
}
|
||||
|
||||
private boolean hasServerConnection()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return MINECRAFT.getCurrentServerData() != null;
|
||||
#else
|
||||
MINECRAFT.getCurrentServer() != null;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCurrentServerName()
|
||||
|
||||
+6
-1
@@ -114,7 +114,12 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
private static final IOptifineAccessor OPTIFINE_ACCESSOR = ModAccessorInjector.INSTANCE.get(IOptifineAccessor.class);
|
||||
|
||||
private static final DhLogger LOGGER = new DhLoggerBuilder().build();
|
||||
private static final Minecraft MC = Minecraft.#if MC_VER <= MC_1_12_2 getMinecraft() #else getInstance() #endif;
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private static final Minecraft MC = Minecraft.getMinecraft();
|
||||
#else
|
||||
private static final Minecraft MC = Minecraft.getInstance();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* In the case of immersive portals multiple levels may be active at once, causing conflicting lightmaps. <br>
|
||||
|
||||
+5
-1
@@ -56,7 +56,11 @@ public class MinecraftServerWrapper implements IMinecraftSharedWrapper
|
||||
throw new IllegalStateException("Trying to get player count before dedicated server completed initialization!");
|
||||
}
|
||||
|
||||
return this.dedicatedServer.#if MC_VER <= MC_1_12_2 getCurrentPlayerCount() #else getPlayerCount() #endif;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return this.dedicatedServer.getCurrentPlayerCount();
|
||||
#else
|
||||
return this.dedicatedServer.getPlayerCount();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user