Preprocessor cleanup
This commit is contained in:
+14
@@ -118,6 +118,7 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
//==============//
|
||||
// constructors //
|
||||
//==============//
|
||||
//region
|
||||
|
||||
#if MC_VER < MC_1_18_2
|
||||
public static BiomeWrapper getBiomeWrapper(Biome biome, ILevelWrapper levelWrapper)
|
||||
@@ -157,11 +158,14 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
//LOGGER.trace("Created BiomeWrapper ["+this.serialString+"] for ["+biome+"]");
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//=========//
|
||||
// methods //
|
||||
//=========//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
@@ -207,11 +211,14 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
@Override
|
||||
public String toString() { return this.getSerialString(); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//=======================//
|
||||
// serialization methods //
|
||||
//=======================//
|
||||
//region
|
||||
|
||||
public String serialize(ILevelWrapper levelWrapper)
|
||||
{
|
||||
@@ -435,10 +442,14 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
return new BiomeDeserializeResult(success, biome);
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// helper classes //
|
||||
//================//
|
||||
//region
|
||||
|
||||
public static class BiomeDeserializeResult
|
||||
{
|
||||
@@ -461,5 +472,8 @@ public class BiomeWrapper implements IBiomeWrapper
|
||||
}
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -547,6 +547,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
{
|
||||
return EDhApiBlockMaterial.LEAVES;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
@@ -639,7 +640,7 @@ public class BlockStateWrapper implements IBlockStateWrapper
|
||||
#if MC_VER <= MC_1_18_2
|
||||
isCopperSounding = false;
|
||||
#elif MC_VER <= MC_1_20_2
|
||||
isCopperSounding = blockState.getSoundType() == SoundType.COPPER
|
||||
isCopperSounding = blockState.getSoundType() == SoundType.COPPER;
|
||||
#else
|
||||
isCopperSounding
|
||||
= blockState.getSoundType() == SoundType.COPPER
|
||||
|
||||
+95
-18
@@ -94,7 +94,11 @@ public class ClientBlockStateColorCache
|
||||
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<>();
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private static final HashSet<IBlockState> BROKEN_BLOCK_STATES = new HashSet<>();
|
||||
#else
|
||||
private static final HashSet<BlockState> BROKEN_BLOCK_STATES = new HashSet<>();
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Methods using MC's "RandomSource" object aren't thread safe <br>
|
||||
@@ -110,18 +114,29 @@ 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 =
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private static final @Nullable EnumFacing[] COLOR_RESOLUTION_DIRECTION_ORDER =
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 EnumFacing.UP #else Direction.UP #endif,
|
||||
EnumFacing.UP,
|
||||
null, // null represents "unculled" faces, IE the top of farmland
|
||||
#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
|
||||
EnumFacing.NORTH,
|
||||
EnumFacing.EAST,
|
||||
EnumFacing.WEST,
|
||||
EnumFacing.SOUTH,
|
||||
EnumFacing.DOWN
|
||||
};
|
||||
#else
|
||||
private static final @Nullable Direction[] COLOR_RESOLUTION_DIRECTION_ORDER =
|
||||
{
|
||||
Direction.UP,
|
||||
null, // null represents "unculled" faces, IE the top of farmland
|
||||
Direction.NORTH,
|
||||
Direction.EAST,
|
||||
Direction.WEST,
|
||||
Direction.SOUTH,
|
||||
Direction.DOWN
|
||||
};
|
||||
#endif
|
||||
|
||||
private static final int FLOWER_COLOR_SCALE = 5;
|
||||
|
||||
@@ -135,7 +150,11 @@ public class ClientBlockStateColorCache
|
||||
#endif
|
||||
|
||||
private final IClientLevelWrapper clientLevelWrapper;
|
||||
private final #if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private final IBlockState blockState;
|
||||
#else
|
||||
private final BlockState blockState;
|
||||
#endif
|
||||
private final BlockStateWrapper blockStateWrapper;
|
||||
|
||||
private boolean isColorResolved = false;
|
||||
@@ -228,9 +247,11 @@ public class ClientBlockStateColorCache
|
||||
//=============//
|
||||
//region
|
||||
|
||||
public ClientBlockStateColorCache(
|
||||
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif blockState,
|
||||
IClientLevelWrapper clientLevelWrapper)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public ClientBlockStateColorCache(IBlockState blockState, IClientLevelWrapper clientLevelWrapper)
|
||||
#else
|
||||
public ClientBlockStateColorCache(BlockState blockState, IClientLevelWrapper clientLevelWrapper)
|
||||
#endif
|
||||
{
|
||||
this.blockState = blockState;
|
||||
this.blockStateWrapper = BlockStateWrapper.fromBlockState(blockState, clientLevelWrapper);
|
||||
@@ -394,9 +415,17 @@ public class ClientBlockStateColorCache
|
||||
@Nullable
|
||||
private List<BakedQuad> getUnculledQuads() { return this.getQuadsForDirection(null); }
|
||||
@Nullable
|
||||
private List<BakedQuad> getQuadsForDirection(@Nullable #if MC_VER <= MC_1_12_2 EnumFacing #else Direction #endif direction)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private List<BakedQuad> getQuadsForDirection(@Nullable EnumFacing direction)
|
||||
#else
|
||||
private List<BakedQuad> getQuadsForDirection(@Nullable Direction direction)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 IBlockState #else BlockState #endif effectiveBlockState = this.blockState;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
IBlockState effectiveBlockState = this.blockState;
|
||||
#else
|
||||
BlockState effectiveBlockState = this.blockState;
|
||||
#endif
|
||||
|
||||
// if this block is a slab, use it's double variant so we can get the top face,
|
||||
// otherwise the color will use the side, which isn't as accurate
|
||||
@@ -610,6 +639,7 @@ public class ClientBlockStateColorCache
|
||||
//===============//
|
||||
// public getter //
|
||||
//===============//
|
||||
//region
|
||||
|
||||
public int getColor(BiomeWrapper biomeWrapper, FullDataSourceV2 fullDataSource, DhBlockPos blockPos)
|
||||
{
|
||||
@@ -802,6 +832,8 @@ public class ClientBlockStateColorCache
|
||||
return returnColor;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
@@ -819,14 +851,54 @@ public class ClientBlockStateColorCache
|
||||
|
||||
static EColorMode getColorMode(Block block)
|
||||
{
|
||||
if (block instanceof #if MC_VER <= MC_1_12_2 BlockLeaves #else LeavesBlock #endif)
|
||||
|
||||
|
||||
|
||||
//========//
|
||||
// leaves //
|
||||
//========//
|
||||
//region
|
||||
|
||||
boolean isLeavesBlock;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
isLeavesBlock = block instanceof BlockLeaves;
|
||||
#else
|
||||
isLeavesBlock = block instanceof LeavesBlock;
|
||||
#endif
|
||||
if (isLeavesBlock)
|
||||
{
|
||||
return Leaves;
|
||||
}
|
||||
if (block instanceof #if MC_VER <= MC_1_12_2 BlockFlower #else FlowerBlock #endif)
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//========//
|
||||
// flower //
|
||||
//========//
|
||||
//region
|
||||
|
||||
boolean isFlowerBlock;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
isFlowerBlock = block instanceof BlockFlower;
|
||||
#else
|
||||
isFlowerBlock = block instanceof FlowerBlock;
|
||||
#endif
|
||||
if (isFlowerBlock)
|
||||
{
|
||||
return Flower;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// misc/simple //
|
||||
//=============//
|
||||
//region
|
||||
|
||||
if (block.toString().contains("glass"))
|
||||
{
|
||||
return Glass;
|
||||
@@ -835,6 +907,11 @@ public class ClientBlockStateColorCache
|
||||
{
|
||||
return Chisel;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
return Default;
|
||||
}
|
||||
}
|
||||
|
||||
+45
-11
@@ -124,15 +124,17 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
|
||||
//region
|
||||
/**
|
||||
* Note: this constructor should be very
|
||||
* 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)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public ChunkWrapper(Chunk chunk, ILevelWrapper wrappedLevel)
|
||||
#else
|
||||
public ChunkWrapper(ChunkAccess chunk, ILevelWrapper wrappedLevel)
|
||||
#endif
|
||||
{
|
||||
this.chunk = chunk;
|
||||
this.wrappedLevel = wrappedLevel;
|
||||
@@ -147,15 +149,22 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
@Override
|
||||
public ChunkWrapper copy() { return new ChunkWrapper(this.chunk, this.wrappedLevel); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//=========//
|
||||
// getters //
|
||||
//=========//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public int getHeight() { return getHeight(this.chunk); }
|
||||
public static int getHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static int getHeight(Chunk chunk)
|
||||
#else
|
||||
public static int getHeight(ChunkAccess chunk)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER < MC_1_17_1
|
||||
return 255;
|
||||
@@ -166,7 +175,11 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
@Override
|
||||
public int getInclusiveMinBuildHeight() { return getInclusiveMinBuildHeight(this.chunk); }
|
||||
public static int getInclusiveMinBuildHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static int getInclusiveMinBuildHeight(Chunk chunk)
|
||||
#else
|
||||
public static int getInclusiveMinBuildHeight(ChunkAccess chunk)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER < MC_1_17_1
|
||||
return 0;
|
||||
@@ -179,7 +192,11 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
@Override
|
||||
public int getExclusiveMaxBuildHeight() { return getExclusiveMaxBuildHeight(this.chunk); }
|
||||
public static int getExclusiveMaxBuildHeight(#if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif chunk)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static int getExclusiveMaxBuildHeight(Chunk chunk)
|
||||
#else
|
||||
public static int getExclusiveMaxBuildHeight(ChunkAccess chunk)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return 256;
|
||||
@@ -264,9 +281,11 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
|
||||
return this.maxNonEmptyHeight;
|
||||
}
|
||||
private static boolean isChunkSectionEmpty(
|
||||
#if MC_VER <= MC_1_12_2 ExtendedBlockStorage #else LevelChunkSection #endif section
|
||||
)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private static boolean isChunkSectionEmpty(ExtendedBlockStorage section)
|
||||
#else
|
||||
private static boolean isChunkSectionEmpty(LevelChunkSection section)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_17_1
|
||||
return section.isEmpty();
|
||||
@@ -556,7 +575,12 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
@Override
|
||||
public DhChunkPos getChunkPos() { return this.chunkPos; }
|
||||
|
||||
public #if MC_VER <= MC_1_12_2 Chunk #else ChunkAccess #endif getChunk() { return this.chunk; }
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public Chunk getChunk()
|
||||
#else
|
||||
public ChunkAccess getChunk()
|
||||
#endif
|
||||
{ return this.chunk; }
|
||||
|
||||
#if MC_VER > MC_1_12_2
|
||||
public void trySetStatus(ChunkStatus status) { trySetStatus(this.getChunk(), status); }
|
||||
@@ -621,11 +645,14 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
#endif
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//==========//
|
||||
// lighting //
|
||||
//==========//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public void setIsDhSkyLightCorrect(boolean isDhLightCorrect) { this.isDhSkyLightCorrect = isDhLightCorrect; }
|
||||
@@ -740,11 +767,14 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
return this.blockLightPosList;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// base overrides //
|
||||
//================//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public String toString() { return this.chunk.getClass().getSimpleName() + this.chunk.getPos(); }
|
||||
@@ -760,4 +790,8 @@ public class ChunkWrapper implements IChunkWrapper
|
||||
// return this.blockBiomeHashCode;
|
||||
//}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,10 +23,17 @@ import net.minecraft.client.gui.GuiGraphicsExtractor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DhScreen extends #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public class DhScreen extends GuiScreen
|
||||
#else
|
||||
public class DhScreen extends Screen
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
protected ITextComponent title;
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
protected DhScreen(ITextComponent title)
|
||||
{
|
||||
this.title = title;
|
||||
@@ -40,7 +47,11 @@ public class DhScreen extends #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #en
|
||||
|
||||
// addRenderableWidget in 1.17 and over
|
||||
// addButton in 1.16 and below
|
||||
protected #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif addBtn(#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif button)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
protected GuiButton addBtn(GuiButton button)
|
||||
#else
|
||||
protected Button addBtn(Button button)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.buttonList.add(button);
|
||||
@@ -53,7 +64,6 @@ public class DhScreen extends #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #en
|
||||
}
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton button)
|
||||
{
|
||||
|
||||
@@ -29,8 +29,11 @@ public class GuiHelper
|
||||
public static final Map<GuiButton, OnPressed> HANDLER_BY_BUTTON = new HashMap<>();
|
||||
#endif
|
||||
|
||||
public static #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif MakeBtn(#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif base, int posX, int posZ, int width, int height,
|
||||
#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif action)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static GuiButton MakeBtn(ITextComponent base, int posX, int posZ, int width, int height, OnPressed action)
|
||||
#else
|
||||
public static Button MakeBtn(Component base, int posX, int posZ, int width, int height, Button.OnPress action)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GuiButton button = new GuiButton(HANDLER_BY_BUTTON.size(), posX, posZ, width, height, base.getFormattedText());
|
||||
@@ -43,7 +46,11 @@ public class GuiHelper
|
||||
#endif
|
||||
}
|
||||
|
||||
public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif TextOrLiteral(String text)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static ITextComponent TextOrLiteral(String text)
|
||||
#else
|
||||
public static MutableComponent TextOrLiteral(String text)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return new TextComponentString(text);
|
||||
@@ -54,7 +61,11 @@ public class GuiHelper
|
||||
#endif
|
||||
}
|
||||
|
||||
public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif TextOrTranslatable(String text)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static ITextComponent TextOrTranslatable(String text)
|
||||
#else
|
||||
public static MutableComponent TextOrTranslatable(String text)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return new TextComponentString(text);
|
||||
@@ -65,7 +76,11 @@ public class GuiHelper
|
||||
#endif
|
||||
}
|
||||
|
||||
public static #if MC_VER <= MC_1_12_2 ITextComponent #else MutableComponent #endif Translatable(String text, Object... args)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static ITextComponent Translatable(String text, Object... args)
|
||||
#else
|
||||
public static MutableComponent Translatable(String text, Object... args)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return new TextComponentTranslation(text, args);
|
||||
@@ -93,7 +108,11 @@ public class GuiHelper
|
||||
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 widget, int y)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static void SetY(GuiButton widget, int y)
|
||||
#else
|
||||
public static void SetY(AbstractWidget widget, int y)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER < MC_1_19_4
|
||||
widget.y = y;
|
||||
|
||||
@@ -6,9 +6,11 @@ import net.minecraft.client.resources.I18n;
|
||||
#else
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
#endif
|
||||
|
||||
public class LangWrapper implements ILangWrapper
|
||||
{
|
||||
public static final LangWrapper INSTANCE = new LangWrapper();
|
||||
|
||||
@Override
|
||||
public boolean langExists(String str)
|
||||
{
|
||||
|
||||
+23
-9
@@ -45,7 +45,11 @@ public class MinecraftScreen
|
||||
|
||||
private static class ConfigScreenRenderer extends DhScreen
|
||||
{
|
||||
private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private final GuiScreen parent;
|
||||
#else
|
||||
private final Screen parent;
|
||||
#endif
|
||||
private ConfigListWidget configListWidget;
|
||||
private AbstractScreen screen;
|
||||
|
||||
@@ -60,9 +64,11 @@ public class MinecraftScreen
|
||||
{ return net.minecraft.network.chat.Component.translatable(str, args); }
|
||||
#endif
|
||||
|
||||
protected ConfigScreenRenderer(
|
||||
#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent,
|
||||
AbstractScreen screen, String translationName)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
protected ConfigScreenRenderer(GuiScreen parent, AbstractScreen screen, String translationName)
|
||||
#else
|
||||
protected ConfigScreenRenderer(Screen parent, AbstractScreen screen, String translationName)
|
||||
#endif
|
||||
{
|
||||
super(translate(translationName));
|
||||
#if MC_VER <= MC_1_12_2
|
||||
@@ -89,7 +95,6 @@ public class MinecraftScreen
|
||||
super.init();
|
||||
#endif
|
||||
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.screen.width = Display.getWidth();
|
||||
this.screen.height = Display.getHeight();
|
||||
@@ -102,16 +107,21 @@ public class MinecraftScreen
|
||||
this.screen.scaledHeight = this.height;
|
||||
this.screen.init(); // Init our own config screen
|
||||
|
||||
this.configListWidget = new ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width, this.height, 0, 0, 25); // Select the area to tint
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.configListWidget = new ConfigListWidget(this.mc, this.width, this.height, 0, 0, 25); // Select the area to tint
|
||||
#else
|
||||
this.configListWidget = new ConfigListWidget(this.minecraft, this.width, this.height, 0, 0, 25); // Select the area to tint
|
||||
#endif
|
||||
|
||||
#if MC_VER > MC_1_12_2
|
||||
#if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
||||
#if MC_VER <= MC_1_12_2
|
||||
#elif MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
||||
if (this.minecraft != null && this.minecraft.level != null) // Check if in game
|
||||
{
|
||||
this.configListWidget.setRenderBackground(false); // Disable from rendering
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MC_VER > MC_1_12_2
|
||||
this.addWidget(this.configListWidget); // Add the tint to the things to be rendered
|
||||
#endif
|
||||
}
|
||||
@@ -240,7 +250,11 @@ public class MinecraftScreen
|
||||
#endif
|
||||
}
|
||||
|
||||
public static class ConfigListWidget extends #if MC_VER <= MC_1_12_2 GuiListExtended #else ContainerObjectSelectionList #endif
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static class ConfigListWidget extends GuiListExtended
|
||||
#else
|
||||
public static class ConfigListWidget extends ContainerObjectSelectionList
|
||||
#endif
|
||||
{
|
||||
public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
|
||||
{
|
||||
|
||||
+22
-15
@@ -103,23 +103,30 @@ public class TexturedButtonWidget extends Button
|
||||
private final int textureHeight;
|
||||
#endif
|
||||
|
||||
|
||||
public TexturedButtonWidget(
|
||||
#if MC_VER <= MC_1_12_2 int id, #endif int x, int y, int width, int height, int u, int v, int hoveredVOffset,
|
||||
#if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation,
|
||||
#else Identifier textureResourceLocation,
|
||||
#endif
|
||||
int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public TexturedButtonWidget(int id, int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, String text)
|
||||
{
|
||||
this(#if MC_VER <= MC_1_12_2 id, #endif x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, #if MC_VER > MC_1_12_2 pressAction, #endif text, true);
|
||||
this(id, x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, text, true);
|
||||
}
|
||||
public TexturedButtonWidget(
|
||||
#if MC_VER <= MC_1_12_2 int id, #endif int x, int y, int width, int height, int u, int v, int hoveredVOffset,
|
||||
#if MC_VER <= MC_1_21_10 ResourceLocation textureResourceLocation,
|
||||
#else Identifier textureResourceLocation,
|
||||
#endif
|
||||
int textureWidth, int textureHeight, #if MC_VER > MC_1_12_2 OnPress pressAction,#endif #if MC_VER <= MC_1_12_2 String #else Component #endif text,
|
||||
boolean renderBackground)
|
||||
#elif MC_VER <= MC_1_21_10
|
||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text)
|
||||
{
|
||||
this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true);
|
||||
}
|
||||
#else
|
||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, Identifier textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text)
|
||||
{
|
||||
this(x, y, width, height, u, v, hoveredVOffset, textureResourceLocation, textureWidth, textureHeight, pressAction, text, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public TexturedButtonWidget(int id, int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, String text, boolean renderBackground)
|
||||
#elif MC_VER <= MC_1_21_10
|
||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, ResourceLocation textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text, boolean renderBackground)
|
||||
#else
|
||||
public TexturedButtonWidget(int x, int y, int width, int height, int u, int v, int hoveredVOffset, Identifier textureResourceLocation, int textureWidth, int textureHeight, OnPress pressAction, Component text, boolean renderBackground)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
super(id, x, y, width, height, text);
|
||||
|
||||
+80
-25
@@ -74,6 +74,7 @@ public class ClassicConfigGUI
|
||||
//==============//
|
||||
// Initializers //
|
||||
//==============//
|
||||
//region
|
||||
|
||||
// Some regexes to check if an input is valid
|
||||
public static final Pattern INTEGER_ONLY_REGEX = Pattern.compile("(-?[0-9]*)");
|
||||
@@ -94,12 +95,14 @@ public class ClassicConfigGUI
|
||||
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// GUI handling //
|
||||
//==============//
|
||||
|
||||
//region
|
||||
/** if you want to get this config gui's screen call this */
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static GuiScreen getScreen(GuiScreen parent, String category)
|
||||
@@ -108,11 +111,14 @@ public class ClassicConfigGUI
|
||||
#endif
|
||||
{ return new DhConfigScreen(parent, category); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// helper classes //
|
||||
//================//
|
||||
//region
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static class ConfigListWidget extends GuiListExtended
|
||||
@@ -124,7 +130,11 @@ public class ClassicConfigGUI
|
||||
public List<DhButtonEntry> children = new ArrayList<>();
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2 FontRenderer #else Font #endif textRenderer;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
FontRenderer textRenderer;
|
||||
#else
|
||||
Font textRenderer;
|
||||
#endif
|
||||
|
||||
public ConfigListWidget(Minecraft minecraftClient, int canvasWidth, int canvasHeight, int topMargin, int botMargin, int itemSpacing)
|
||||
{
|
||||
@@ -142,7 +152,7 @@ public class ClassicConfigGUI
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MC_VER<= MC_1_12_2
|
||||
#if MC_VER <= MC_1_12_2
|
||||
@Override
|
||||
protected int getSize()
|
||||
{
|
||||
@@ -180,11 +190,24 @@ public class ClassicConfigGUI
|
||||
}
|
||||
|
||||
@Override
|
||||
public int #if MC_VER <= MC_1_12_2 getListWidth() #else getRowWidth() #endif { return 10_000; }
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public int getListWidth()
|
||||
#else
|
||||
public int getRowWidth()
|
||||
#endif
|
||||
{ return 10_000; }
|
||||
|
||||
public #if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif getHoveredButton(double mouseX, double mouseY)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public Gui getHoveredButton(double mouseX, double mouseY)
|
||||
#else
|
||||
public AbstractWidget getHoveredButton(double mouseX, double mouseY)
|
||||
#endif
|
||||
{
|
||||
for (DhButtonEntry buttonEntry : #if MC_VER <= MC_1_12_2 this.children #else this.children() #endif)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
for (DhButtonEntry buttonEntry : this.children)
|
||||
#else
|
||||
for (DhButtonEntry buttonEntry : this.children())
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
Gui gui = buttonEntry.button;
|
||||
@@ -244,14 +267,18 @@ public class ClassicConfigGUI
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class DhButtonEntry #if MC_VER <= MC_1_12_2 implements GuiListExtended.IGuiListEntry #else extends ContainerObjectSelectionList.Entry<DhButtonEntry> #endif
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static class DhButtonEntry implements GuiListExtended.IGuiListEntry
|
||||
#else
|
||||
public static class DhButtonEntry extends ContainerObjectSelectionList.Entry<DhButtonEntry>
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private static final FontRenderer textRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
#else
|
||||
private static final Font textRenderer = Minecraft.getInstance().font;
|
||||
#endif
|
||||
|
||||
private final DhConfigScreen gui;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public final Gui button;
|
||||
@@ -262,8 +289,18 @@ public class ClassicConfigGUI
|
||||
private final AbstractWidget resetButton;
|
||||
private final AbstractWidget button;
|
||||
#endif
|
||||
private final #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif text;
|
||||
private final List<#if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif> children = new ArrayList<>();
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private final ITextComponent text;
|
||||
#else
|
||||
private final Component text;
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private final List<Gui> children = new ArrayList<>();
|
||||
#else
|
||||
private final List<AbstractWidget> children = new ArrayList<>();
|
||||
#endif
|
||||
|
||||
@NotNull
|
||||
private final EConfigCommentTextPosition textPosition;
|
||||
@@ -366,17 +403,23 @@ public class ClassicConfigGUI
|
||||
}
|
||||
#else
|
||||
SetY(this.button, y);
|
||||
#if MC_VER <= MC_1_21_11
|
||||
this.button.render(matrices, mouseX, mouseY, tickDelta);
|
||||
#else
|
||||
this.button.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_21_11
|
||||
this.button.render(matrices, mouseX, mouseY, tickDelta);
|
||||
#else
|
||||
this.button.extractRenderState(matrices, mouseX, mouseY, tickDelta);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (this.resetButton != null)
|
||||
{
|
||||
SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.resetButton, y);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
SetY((GuiButton) this.resetButton, y);
|
||||
#else
|
||||
SetY(this.resetButton, y);
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
((GuiButton) this.resetButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta);
|
||||
@@ -389,7 +432,12 @@ public class ClassicConfigGUI
|
||||
|
||||
if (this.indexButton != null)
|
||||
{
|
||||
SetY(#if MC_VER <= MC_1_12_2 (GuiButton) #endif this.indexButton, y);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
SetY((GuiButton) this.indexButton, y);
|
||||
#else
|
||||
SetY(this.indexButton, y);
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
((GuiButton) this.indexButton).drawButton(Minecraft.getMinecraft(), mouseX, mouseY, tickDelta);
|
||||
#elif MC_VER <= MC_1_21_11
|
||||
@@ -439,17 +487,20 @@ public class ClassicConfigGUI
|
||||
}
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
textRenderer.drawString(this.text.getFormattedText(), textXPos, y + 5,0xFFFFFF);
|
||||
textRenderer.drawString(
|
||||
this.text.getFormattedText(),
|
||||
textXPos, y + 5,
|
||||
0xFFFFFF);
|
||||
#elif MC_VER < MC_1_20_1
|
||||
GuiComponent.drawString(matrices, textRenderer,
|
||||
this.text,
|
||||
textXPos, y + 5,
|
||||
0xFFFFFF);
|
||||
this.text,
|
||||
textXPos, y + 5,
|
||||
0xFFFFFF);
|
||||
#elif MC_VER < MC_1_21_6
|
||||
matrices.drawString(textRenderer,
|
||||
this.text,
|
||||
textXPos, y + 5,
|
||||
0xFFFFFF);
|
||||
matrices.drawString(textRenderer,
|
||||
this.text,
|
||||
textXPos, y + 5,
|
||||
0xFFFFFF);
|
||||
#elif MC_VER <= MC_1_21_11
|
||||
matrices.drawString(textRenderer,
|
||||
this.text,
|
||||
@@ -500,11 +551,14 @@ public class ClassicConfigGUI
|
||||
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// event handling //
|
||||
//================//
|
||||
//region
|
||||
|
||||
public static class ConfigCoreInterface implements IConfigGui
|
||||
{
|
||||
@@ -523,4 +577,5 @@ public class ClassicConfigGUI
|
||||
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
+169
-65
@@ -95,21 +95,34 @@ class DhConfigScreen extends DhScreen
|
||||
|
||||
private static final MinecraftClientWrapper MC_CLIENT = MinecraftClientWrapper.INSTANCE;
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private final GuiScreen parent;
|
||||
#else
|
||||
private final Screen parent;
|
||||
#endif
|
||||
|
||||
private final #if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent;
|
||||
private final String category;
|
||||
private ClassicConfigGUI.ConfigListWidget configListWidget;
|
||||
private boolean reload = false;
|
||||
|
||||
private #if MC_VER <= MC_1_12_2 GuiButton #else Button #endif doneButton;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private GuiButton doneButton;
|
||||
#else
|
||||
private Button doneButton;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
//region
|
||||
|
||||
protected DhConfigScreen(#if MC_VER <= MC_1_12_2 GuiScreen #else Screen #endif parent, String category)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
protected DhConfigScreen(GuiScreen parent, String category)
|
||||
#else
|
||||
protected DhConfigScreen(Screen parent, String category)
|
||||
#endif
|
||||
{
|
||||
super(Translatable(
|
||||
LANG_WRAPPER.langExists(ModInfo.ID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ?
|
||||
@@ -120,27 +133,35 @@ class DhConfigScreen extends DhScreen
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
|
||||
|
||||
//===================//
|
||||
// menu UI lifecycle //
|
||||
//===================//
|
||||
//region
|
||||
|
||||
@Override
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public void updateScreen() { super.updateScreen(); }
|
||||
#else
|
||||
@Override
|
||||
public void tick() { super.tick(); }
|
||||
#endif
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==================//
|
||||
// menu UI creation //
|
||||
//==================//
|
||||
//region
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
@Override
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public void initGui()
|
||||
#else
|
||||
@Override
|
||||
protected void init()
|
||||
#endif
|
||||
{
|
||||
@@ -225,16 +246,21 @@ class DhConfigScreen extends DhScreen
|
||||
#endif
|
||||
}));
|
||||
|
||||
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(#if MC_VER <= MC_1_12_2 this.mc #else this.minecraft #endif, this.width * 2, this.height, 32, 32, 25);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.mc, this.width * 2, this.height, 32, 32, 25);
|
||||
#else
|
||||
this.configListWidget = new ClassicConfigGUI.ConfigListWidget(this.minecraft, this.width * 2, this.height, 32, 32, 25);
|
||||
#endif
|
||||
|
||||
#if MC_VER > MC_1_12_2
|
||||
#if MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
||||
#if MC_VER <= MC_1_12_2
|
||||
#elif MC_VER < MC_1_20_6 // no background is rendered in MC 1.20.6+
|
||||
if (this.minecraft != null && this.minecraft.level != null)
|
||||
{
|
||||
this.configListWidget.setRenderBackground(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MC_VER > MC_1_12_2
|
||||
this.addWidget(this.configListWidget);
|
||||
#endif
|
||||
|
||||
@@ -407,40 +433,47 @@ class DhConfigScreen extends DhScreen
|
||||
|
||||
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) booleanConfigEntry.guiValue);
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
configGuiInfo.buttonOptionMap =
|
||||
#if MC_VER <= MC_1_12_2
|
||||
new AbstractMap.SimpleEntry<OnPressed, Function<Object, ITextComponent>>(
|
||||
(button) ->
|
||||
{
|
||||
button.enabled = !booleanConfigEntry.apiIsOverriding();
|
||||
|
||||
booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get());
|
||||
button.displayString = func.apply(booleanConfigEntry.get()).getFormattedText();
|
||||
}, func);
|
||||
#else
|
||||
configGuiInfo.buttonOptionMap =
|
||||
#else
|
||||
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
||||
#endif
|
||||
(button) ->
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
button.enabled = !booleanConfigEntry.apiIsOverriding();
|
||||
#else
|
||||
button.active = !booleanConfigEntry.apiIsOverriding();
|
||||
|
||||
#endif
|
||||
|
||||
booleanConfigEntry.uiSetWithoutSaving(!booleanConfigEntry.get());
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
button.displayString = func.apply(booleanConfigEntry.get()).getFormattedText();
|
||||
#else
|
||||
button.setMessage(func.apply(booleanConfigEntry.get()));
|
||||
#endif
|
||||
}, func);
|
||||
#endif
|
||||
}
|
||||
private static void setupEnumMenuOption(ConfigEntry<Enum<?>> enumConfigEntry, Class<? extends Enum<?>> enumClass)
|
||||
{
|
||||
List<Enum<?>> enumList = Arrays.asList(enumClass.getEnumConstants());
|
||||
|
||||
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) enumConfigEntry.guiValue);
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
Function<Object, ITextComponent > getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
|
||||
#else
|
||||
Function<Object, Component> getEnumTranslatableFunc = (value) -> Translatable(TRANSLATION_PREFIX + "enum." + enumClass.getSimpleName() + "." + enumConfigEntry.get().toString());
|
||||
#endif
|
||||
|
||||
configGuiInfo.buttonOptionMap =
|
||||
new AbstractMap.SimpleEntry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function<Object, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif>>(
|
||||
#if MC_VER <= MC_1_12_2
|
||||
new AbstractMap.SimpleEntry<OnPressed, Function<Object, ITextComponent>>(
|
||||
#else
|
||||
new AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>>(
|
||||
#endif
|
||||
(button) ->
|
||||
{
|
||||
// get the currently selected enum and enum index
|
||||
@@ -525,6 +558,7 @@ class DhConfigScreen extends DhScreen
|
||||
//==============//
|
||||
// reset button //
|
||||
//==============//
|
||||
//region
|
||||
|
||||
#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif btnAction = (button) ->
|
||||
{
|
||||
@@ -567,13 +601,20 @@ class DhConfigScreen extends DhScreen
|
||||
resetButton.#if MC_VER <= MC_1_12_2 enabled #else active #endif = true;
|
||||
}
|
||||
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//==============//
|
||||
// option field //
|
||||
//==============//
|
||||
//region
|
||||
|
||||
#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
||||
#else
|
||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configEntry);
|
||||
#endif
|
||||
|
||||
int optionFieldPosX = this.width
|
||||
- ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN
|
||||
@@ -590,20 +631,28 @@ class DhConfigScreen extends DhScreen
|
||||
#else
|
||||
Map.Entry<Button.OnPress, Function<Object, Component>> widget = configGuiInfo.buttonOptionMap;
|
||||
#endif
|
||||
|
||||
if (configEntry.getType().isEnum())
|
||||
{
|
||||
widget.setValue((value) -> Translatable(TRANSLATION_PREFIX + "enum." + configEntry.getType().getSimpleName() + "." + configEntry.get().toString()));
|
||||
}
|
||||
|
||||
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif button = MakeBtn(
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GuiButton button = MakeBtn(
|
||||
#else
|
||||
Button button = MakeBtn(
|
||||
#endif
|
||||
widget.getValue().apply(configEntry.get()),
|
||||
optionFieldPosX, optionFieldPosZ,
|
||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||
widget.getKey());
|
||||
|
||||
// deactivate the button if the API is overriding it
|
||||
button.#if MC_VER <= MC_1_12_2 enabled #else active #endif = !configEntry.apiIsOverriding();
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
button.enabled = !configEntry.apiIsOverriding();
|
||||
#else
|
||||
button.active = !configEntry.apiIsOverriding();
|
||||
#endif
|
||||
|
||||
this.configListWidget.addButton(this, configEntry,
|
||||
button,
|
||||
@@ -616,15 +665,20 @@ class DhConfigScreen extends DhScreen
|
||||
else
|
||||
{
|
||||
// text box input
|
||||
|
||||
#if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif widget = new #if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif(
|
||||
#if MC_VER <= MC_1_12_2 0, #endif
|
||||
#if MC_VER <= MC_1_12_2 this.fontRenderer #else this.font #endif,
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GuiTextField widget = new GuiTextField(0, this.fontRenderer,
|
||||
optionFieldPosX, optionFieldPosZ,
|
||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT
|
||||
#if MC_VER > MC_1_12_2 ,Translatable("") #endif);
|
||||
widget.#if MC_VER <= MC_1_12_2 setMaxStringLength(3_000_000); #else setMaxLength(3_000_000); #endif // hopefully 3 million characters should be enough for any normal use-case, lol
|
||||
widget.#if MC_VER <= MC_1_12_2 setText #else insertText #endif (String.valueOf(configEntry.get()));
|
||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT);
|
||||
widget.setMaxStringLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
|
||||
widget.setText(String.valueOf(configEntry.get()));
|
||||
#else
|
||||
EditBox widget = new EditBox(this.font,
|
||||
optionFieldPosX, optionFieldPosZ,
|
||||
ClassicConfigGUI.ConfigScreenConfigs.OPTION_FIELD_WIDTH - 4, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||
Translatable(""));
|
||||
widget.setMaxLength(3_000_000); // hopefully 3 million characters should be enough for any normal use-case, lol
|
||||
widget.insertText(String.valueOf(configEntry.get()));
|
||||
#endif
|
||||
|
||||
Predicate<String> processor = configGuiInfo.tooltipFunction.apply(widget, this.doneButton);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
@@ -639,6 +693,8 @@ class DhConfigScreen extends DhScreen
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -649,12 +705,21 @@ class DhConfigScreen extends DhScreen
|
||||
{
|
||||
ConfigCategory configCategory = (ConfigCategory) configType;
|
||||
|
||||
#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
||||
#else
|
||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configCategory);
|
||||
#endif
|
||||
|
||||
int categoryPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||
int categoryPosZ = this.height - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT; // Note: the posZ value here seems to be ignored
|
||||
|
||||
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent,
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GuiButton widget = MakeBtn(
|
||||
#else
|
||||
Button widget = MakeBtn(
|
||||
#endif
|
||||
textComponent,
|
||||
categoryPosX, categoryPosZ,
|
||||
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||
((button) ->
|
||||
@@ -679,11 +744,20 @@ class DhConfigScreen extends DhScreen
|
||||
{
|
||||
ConfigUIButton configUiButton = (ConfigUIButton) configType;
|
||||
|
||||
#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
||||
#else
|
||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiButton);
|
||||
#endif
|
||||
|
||||
int buttonPosX = this.width - ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH - ClassicConfigGUI.ConfigScreenConfigs.SPACE_FROM_RIGHT_SCREEN;
|
||||
|
||||
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif widget = MakeBtn(textComponent,
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GuiButton widget = MakeBtn(
|
||||
#else
|
||||
Button widget = MakeBtn(
|
||||
#endif
|
||||
textComponent,
|
||||
buttonPosX, this.height - 28,
|
||||
ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_WIDTH, ClassicConfigGUI.ConfigScreenConfigs.CATEGORY_BUTTON_HEIGHT,
|
||||
(button) -> ((ConfigUIButton) configType).runAction());
|
||||
@@ -700,7 +774,11 @@ class DhConfigScreen extends DhScreen
|
||||
{
|
||||
ConfigUIComment configUiComment = (ConfigUIComment) configType;
|
||||
|
||||
#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
ITextComponent textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
||||
#else
|
||||
Component textComponent = this.GetTranslatableTextComponentForConfig(configUiComment);
|
||||
#endif
|
||||
if (configUiComment.parentConfigPath != null)
|
||||
{
|
||||
textComponent = Translatable(TRANSLATION_PREFIX + configUiComment.parentConfigPath);
|
||||
@@ -716,8 +794,13 @@ class DhConfigScreen extends DhScreen
|
||||
private boolean tryCreateSpacer(AbstractConfigBase<?> configType)
|
||||
{
|
||||
if (configType instanceof ConfigUISpacer)
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif spacerButton = MakeBtn(Translatable("distanthorizons.general.spacer"),
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
GuiButton spacerButton = MakeBtn(
|
||||
#else
|
||||
Button spacerButton = MakeBtn(
|
||||
#endif
|
||||
Translatable("distanthorizons.general.spacer"),
|
||||
10, 10, // having too small of a size causes division by 0 errors in older MC versions (IE 1.20.1)
|
||||
1, 1,
|
||||
(button) -> { });
|
||||
@@ -742,14 +825,21 @@ class DhConfigScreen extends DhScreen
|
||||
return false;
|
||||
}
|
||||
|
||||
private #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private ITextComponent GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
||||
#else
|
||||
private Component GetTranslatableTextComponentForConfig(AbstractConfigBase<?> configType)
|
||||
#endif
|
||||
{ return Translatable(TRANSLATION_PREFIX + configType.getNameAndCategory()); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//===========//
|
||||
// rendering //
|
||||
//===========//
|
||||
//region
|
||||
|
||||
@Override
|
||||
#if MC_VER <= MC_1_12_2
|
||||
@@ -823,10 +913,11 @@ class DhConfigScreen extends DhScreen
|
||||
#endif);
|
||||
}
|
||||
|
||||
this.renderTooltip(
|
||||
#if MC_VER > MC_1_12_2 matrices,
|
||||
#endif
|
||||
mouseX, mouseY, delta);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.renderTooltip(mouseX, mouseY, delta);
|
||||
#else
|
||||
this.renderTooltip(matrices, mouseX, mouseY, delta);
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
super.drawScreen(mouseX, mouseY, delta);
|
||||
@@ -841,11 +932,15 @@ class DhConfigScreen extends DhScreen
|
||||
private void renderTooltip(PoseStack matrices, int mouseX, int mouseY, float delta)
|
||||
#elif MC_VER <= MC_1_21_11
|
||||
private void renderTooltip(GuiGraphics matrices, int mouseX, int mouseY, float delta)
|
||||
#else
|
||||
#else
|
||||
private void renderTooltip(GuiGraphicsExtractor matrices, int mouseX, int mouseY, float delta)
|
||||
#endif
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 Gui #else AbstractWidget #endif hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
Gui hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
||||
#else
|
||||
AbstractWidget hoveredWidget = this.configListWidget.getHoveredButton(mouseX, mouseY);
|
||||
#endif
|
||||
if (hoveredWidget == null)
|
||||
{
|
||||
return;
|
||||
@@ -877,27 +972,32 @@ class DhConfigScreen extends DhScreen
|
||||
final ConfigGuiInfo configGuiInfo = ((ConfigGuiInfo) configBase.guiValue);
|
||||
if (configGuiInfo.errorMessage != null)
|
||||
{
|
||||
this.DhRenderTooltip(
|
||||
#if MC_VER > MC_1_12_2
|
||||
matrices, this.font,
|
||||
#endif
|
||||
configGuiInfo.errorMessage, mouseX, mouseY);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.DhRenderTooltip(configGuiInfo.errorMessage, mouseX, mouseY);
|
||||
#else
|
||||
this.DhRenderTooltip(matrices, this.font, configGuiInfo.errorMessage, mouseX, mouseY);
|
||||
#endif
|
||||
}
|
||||
// display the tooltip if present
|
||||
else if (LANG_WRAPPER.langExists(key))
|
||||
{
|
||||
List<#if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif> list = new ArrayList<>();
|
||||
#if MC_VER <= MC_1_12_2
|
||||
List<ITextComponent> list = new ArrayList<>();
|
||||
#else
|
||||
List<Component> list = new ArrayList<>();
|
||||
#endif
|
||||
|
||||
String lang = LANG_WRAPPER.getLang(key);
|
||||
for (String langLine : lang.split("\n"))
|
||||
{
|
||||
list.add(TextOrTranslatable(langLine));
|
||||
}
|
||||
|
||||
this.DhRenderComponentTooltip(
|
||||
#if MC_VER > MC_1_12_2
|
||||
matrices, this.font,
|
||||
#endif
|
||||
list, mouseX, mouseY);
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.DhRenderComponentTooltip(list, mouseX, mouseY);
|
||||
#else
|
||||
this.DhRenderComponentTooltip(matrices, this.font, list, mouseX, mouseY);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -959,11 +1059,14 @@ class DhConfigScreen extends DhScreen
|
||||
}
|
||||
#endif
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//==========//
|
||||
// shutdown //
|
||||
//==========//
|
||||
|
||||
//region
|
||||
/** When you close it, it goes to the previous screen and saves */
|
||||
@Override
|
||||
#if MC_VER <= MC_1_12_2
|
||||
@@ -979,5 +1082,6 @@ class DhConfigScreen extends DhScreen
|
||||
ClassicConfigGUI.CONFIG_CORE_INTERFACE.onScreenChangeListenerList.forEach((listener) -> listener.run());
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
}
|
||||
|
||||
+16
-3
@@ -32,10 +32,23 @@ public class ConfigGuiInfo implements IConfigGuiInfo
|
||||
*/
|
||||
|
||||
@Nullable
|
||||
public #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif errorMessage;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public ITextComponent errorMessage;
|
||||
#else
|
||||
public Component errorMessage;
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public BiFunction<GuiTextField, GuiButton, Predicate<String>> tooltipFunction;
|
||||
#else
|
||||
public BiFunction<EditBox, Button , Predicate<String>> tooltipFunction;
|
||||
#endif
|
||||
|
||||
public BiFunction<#if MC_VER <= MC_1_12_2 GuiTextField #else EditBox #endif,#if MC_VER <= MC_1_12_2 GuiButton #else Button #endif, Predicate<String>> tooltipFunction;
|
||||
/** determines which options the button will show */
|
||||
public AbstractMap.SimpleEntry<#if MC_VER <= MC_1_12_2 OnPressed #else Button.OnPress #endif, Function<Object, #if MC_VER <= MC_1_12_2 ITextComponent #else Component #endif>> buttonOptionMap;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public AbstractMap.SimpleEntry<OnPressed, Function<Object, ITextComponent>> buttonOptionMap;
|
||||
#else
|
||||
public AbstractMap.SimpleEntry<Button.OnPress, Function<Object, Component>> buttonOptionMap;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -26,14 +26,18 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
//region
|
||||
|
||||
private KeyedClientLevelManager() { }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//======================//
|
||||
// level override logic //
|
||||
//======================//
|
||||
//region
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@@ -61,5 +65,8 @@ public class KeyedClientLevelManager implements IKeyedClientLevelManager
|
||||
@Override
|
||||
public void disable() { this.enabled = false; }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+9
-2
@@ -21,6 +21,7 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
//region
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public ServerKeyedClientLevelWrapper(WorldClient level, String serverKey, String serverLevelKey)
|
||||
@@ -33,13 +34,17 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements
|
||||
this.serverLevelKey = serverLevelKey;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
@Override
|
||||
public String getServerKey() { return this.serverKey; }
|
||||
|
||||
//======================//
|
||||
// level identification //
|
||||
//======================//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public String getServerKey() { return this.serverKey; }
|
||||
|
||||
@Override
|
||||
public String getServerLevelKey() { return this.serverLevelKey; }
|
||||
@@ -47,6 +52,8 @@ public class ServerKeyedClientLevelWrapper extends ClientLevelWrapper implements
|
||||
@Override
|
||||
public String getDhIdentifier() { return this.getServerLevelKey(); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+103
-16
@@ -156,17 +156,46 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif;
|
||||
return (server != null) ? server.#if MC_VER <= MC_1_12_2 serverIP #else ip #endif : "NA";
|
||||
ServerData server = getCurrentServerData();
|
||||
return getServerIp(server);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getCurrentServerVersion()
|
||||
{
|
||||
ServerData server = MINECRAFT.#if MC_VER <= MC_1_12_2 getCurrentServerData() #else getCurrentServer() #endif;
|
||||
return (server != null) ? server.#if MC_VER <= MC_1_12_2 gameVersion #else version.getString() #endif : "UNKOWN";
|
||||
ServerData server = getCurrentServerData();
|
||||
return getServerVersion(server);
|
||||
}
|
||||
|
||||
private ServerData getCurrentServerData()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return MINECRAFT.getCurrentServerData();
|
||||
#else
|
||||
return MINECRAFT.getCurrentServer();
|
||||
#endif
|
||||
}
|
||||
private String getServerIp(ServerData server)
|
||||
{
|
||||
if (server == null) { return "NA"; }
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return server.serverIP;
|
||||
#else
|
||||
return server.ip;
|
||||
#endif
|
||||
}
|
||||
private String getServerVersion(ServerData server)
|
||||
{
|
||||
if (server == null) { return "UNKOWN"; }
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return server.gameVersion;
|
||||
#else
|
||||
return server.version.getString();
|
||||
#endif
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
@@ -176,7 +205,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
//=================//
|
||||
//region
|
||||
|
||||
public #if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif getPlayer() { return MINECRAFT.player; }
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public EntityPlayerSP getPlayer() { return MINECRAFT.player; }
|
||||
#else
|
||||
public LocalPlayer getPlayer() { return MINECRAFT.player; }
|
||||
#endif
|
||||
|
||||
@Override
|
||||
public boolean playerExists() { return MINECRAFT.player != null; }
|
||||
@@ -184,20 +217,32 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
@Override
|
||||
public DhBlockPos getPlayerBlockPos()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer();
|
||||
#if MC_VER <= MC_1_12_2
|
||||
EntityPlayerSP player = this.getPlayer();
|
||||
#else
|
||||
LocalPlayer player = this.getPlayer();
|
||||
#endif
|
||||
if (player == null)
|
||||
{
|
||||
return new DhBlockPos(0, 0, 0);
|
||||
}
|
||||
|
||||
BlockPos playerPos = player.#if MC_VER <= MC_1_12_2 getPosition() #else blockPosition() #endif;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
BlockPos playerPos = player.getPosition();
|
||||
#else
|
||||
BlockPos playerPos = player.blockPosition();
|
||||
#endif
|
||||
return new DhBlockPos(playerPos.getX(), playerPos.getY(), playerPos.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DhChunkPos getPlayerChunkPos()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer();
|
||||
#if MC_VER <= MC_1_12_2
|
||||
EntityPlayerSP player = this.getPlayer();
|
||||
#else
|
||||
LocalPlayer player = this.getPlayer();
|
||||
#endif
|
||||
if (player == null)
|
||||
{
|
||||
return new DhChunkPos(0, 0);
|
||||
@@ -235,7 +280,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
@Nullable
|
||||
public IClientLevelWrapper getWrappedClientLevel(boolean bypassLevelKeyManager)
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 WorldClient #else ClientLevel #endif level = MINECRAFT.#if MC_VER <= MC_1_12_2 world #else level #endif;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
WorldClient level = MINECRAFT.world;
|
||||
#else
|
||||
ClientLevel level = MINECRAFT.level;
|
||||
#endif
|
||||
if (level == null)
|
||||
{
|
||||
return null;
|
||||
@@ -256,7 +305,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
@Override
|
||||
public void sendChatMessage(String string)
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer();
|
||||
#if MC_VER <= MC_1_12_2
|
||||
EntityPlayerSP player = this.getPlayer();
|
||||
#else
|
||||
LocalPlayer player = this.getPlayer();
|
||||
#endif
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
@@ -284,7 +337,11 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
@Override
|
||||
public void sendOverlayMessage(String string)
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 EntityPlayerSP #else LocalPlayer #endif player = this.getPlayer();
|
||||
#if MC_VER <= MC_1_12_2
|
||||
EntityPlayerSP player = this.getPlayer();
|
||||
#else
|
||||
LocalPlayer player = this.getPlayer();
|
||||
#endif
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
@@ -395,7 +452,12 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
@Override
|
||||
public IProfilerWrapper getProfiler()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
Profiler profiler;
|
||||
#else
|
||||
ProfilerFiller profiler;
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
profiler = MINECRAFT.profiler;
|
||||
#elif MC_VER < MC_1_21_3
|
||||
@@ -438,7 +500,14 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeOnRenderThread(Runnable runnable) { MINECRAFT.#if MC_VER <= MC_1_12_2 addScheduledTask #else execute #endif(runnable); }
|
||||
public void executeOnRenderThread(Runnable runnable)
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
MINECRAFT.addScheduledTask(runnable);
|
||||
#else
|
||||
MINECRAFT.execute(runnable);
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showDialog(String title, String message, String dialogType, String iconType)
|
||||
@@ -454,7 +523,14 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
//region
|
||||
|
||||
@Override
|
||||
public Object getOptionsObject() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameSettings #else options #endif; }
|
||||
public Object getOptionsObject()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return MINECRAFT.gameSettings;
|
||||
#else
|
||||
return MINECRAFT.options;
|
||||
#endif
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
@@ -469,13 +545,24 @@ public class MinecraftClientWrapper implements IMinecraftClientWrapper, IMinecra
|
||||
public boolean isDedicatedServer() { return false; }
|
||||
|
||||
@Override
|
||||
public File getInstallationDirectory() { return MINECRAFT.#if MC_VER <= MC_1_12_2 gameDir #else gameDirectory #endif; }
|
||||
public File getInstallationDirectory()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return MINECRAFT.gameDir;
|
||||
#else
|
||||
return MINECRAFT.gameDirectory;
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPlayerCount()
|
||||
{
|
||||
// can be null if the server hasn't finished booting up yet
|
||||
if (MINECRAFT.#if MC_VER <= MC_1_12_2 getIntegratedServer() #else getSingleplayerServer() #endif == null)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
if (MINECRAFT.getIntegratedServer() == null)
|
||||
#else
|
||||
if (MINECRAFT.getSingleplayerServer() == null)
|
||||
#endif
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
+5
-1
@@ -173,7 +173,11 @@ public class MinecraftRenderWrapper implements IMinecraftRenderWrapper
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (MC.player.#if MC_VER <= MC_1_12_2 getActivePotionMap() #else getActiveEffectsMap() #endif == null)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
else if (MC.player.getActivePotionMap() == null)
|
||||
#else
|
||||
else if (MC.player.getActiveEffectsMap() == null)
|
||||
#endif
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
+38
-8
@@ -29,21 +29,38 @@ import net.minecraft.util.profiling.ProfilerFiller;
|
||||
|
||||
public class ProfilerWrapper implements IProfilerWrapper
|
||||
{
|
||||
public #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public Profiler profiler;
|
||||
#else
|
||||
public ProfilerFiller profiler;
|
||||
#endif
|
||||
|
||||
public ProfilerWrapper(#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif newProfiler) { this.profiler = newProfiler; }
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public ProfilerWrapper(Profiler newProfiler)
|
||||
#else
|
||||
public ProfilerWrapper(ProfilerFiller newProfiler)
|
||||
#endif
|
||||
{ this.profiler = newProfiler; }
|
||||
|
||||
@Override
|
||||
public IProfileBlock push(String newSection)
|
||||
{
|
||||
this.profiler.#if MC_VER <= MC_1_12_2 startSection(newSection) #else push(newSection) #endif;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.profiler.startSection(newSection);
|
||||
#else
|
||||
this.profiler.push(newSection);
|
||||
#endif
|
||||
return new ProfileBlock(this.profiler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popPush(String newSection)
|
||||
{
|
||||
this.profiler.#if MC_VER <= MC_1_12_2 endStartSection(newSection) #else popPush(newSection) #endif;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.profiler.endStartSection(newSection);
|
||||
#else
|
||||
this.profiler.popPush(newSection) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -55,14 +72,27 @@ public class ProfilerWrapper implements IProfilerWrapper
|
||||
|
||||
public static class ProfileBlock implements IProfileBlock
|
||||
{
|
||||
public #if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif profiler;
|
||||
public ProfileBlock(#if MC_VER <= MC_1_12_2 Profiler #else ProfilerFiller #endif newProfiler) { this.profiler = newProfiler; }
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public Profiler profiler;
|
||||
#else
|
||||
public ProfilerFiller profiler;
|
||||
#endif
|
||||
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public ProfileBlock(Profiler newProfiler)
|
||||
#else
|
||||
public ProfileBlock(ProfilerFiller newProfiler)
|
||||
#endif
|
||||
{ this.profiler = newProfiler; }
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
this.profiler.#if MC_VER <= MC_1_12_2 endSection() #else pop() #endif;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
this.profiler.endSection();
|
||||
#else
|
||||
this.profiler.pop();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -11,7 +11,11 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface IMixinServerPlayer
|
||||
{
|
||||
@Nullable
|
||||
#if MC_VER <= MC_1_12_2 WorldServer #else ServerLevel #endif distantHorizons$getDimensionChangeDestination();
|
||||
#if MC_VER <= MC_1_12_2
|
||||
WorldServer distantHorizons$getDimensionChangeDestination();
|
||||
#else
|
||||
ServerLevel distantHorizons$getDimensionChangeDestination();
|
||||
#endif
|
||||
|
||||
#if MC_VER == MC_1_16_5
|
||||
void distantHorizons$setDimensionChangeDestination(ServerLevel dimensionChangeDestination);
|
||||
|
||||
+8
@@ -16,19 +16,27 @@ public class MutableBlockPosWrapper implements IMutableBlockPosWrapper
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
//region
|
||||
|
||||
public MutableBlockPosWrapper()
|
||||
{
|
||||
this.pos = new BlockPos.MutableBlockPos();
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//===========//
|
||||
// overrides //
|
||||
//===========//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public Object getWrappedMcObject() { return this.pos; }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+46
-6
@@ -36,31 +36,64 @@ import java.util.concurrent.ConcurrentMap;
|
||||
#endif
|
||||
public class ServerPlayerWrapper implements IServerPlayerWrapper
|
||||
{
|
||||
private static final ConcurrentMap<#if MC_VER <= MC_1_12_2 NetHandlerPlayServer #else ServerGamePacketListenerImpl #endif , ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap();
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private static final ConcurrentMap<NetHandlerPlayServer, ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap();
|
||||
#else
|
||||
private static final ConcurrentMap<ServerGamePacketListenerImpl, ServerPlayerWrapper> serverPlayerWrapperMap = new MapMaker().weakKeys().weakValues().makeMap();
|
||||
#endif
|
||||
|
||||
private final #if MC_VER <= MC_1_12_2 NetHandlerPlayServer #else ServerGamePacketListenerImpl #endif connection;
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private final NetHandlerPlayServer connection;
|
||||
#else
|
||||
private final ServerGamePacketListenerImpl connection;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// constructor //
|
||||
//=============//
|
||||
//region
|
||||
|
||||
public static ServerPlayerWrapper getWrapper(#if MC_VER <= MC_1_12_2 EntityPlayerMP #else ServerPlayer #endif serverPlayer)
|
||||
#if MC_VER <= MC_1_12_2
|
||||
public static ServerPlayerWrapper getWrapper(EntityPlayerMP serverPlayer)
|
||||
#else
|
||||
public static ServerPlayerWrapper getWrapper(ServerPlayer serverPlayer)
|
||||
#endif
|
||||
{ return serverPlayerWrapperMap.computeIfAbsent(serverPlayer.connection, ignored -> new ServerPlayerWrapper(serverPlayer.connection)); }
|
||||
|
||||
private ServerPlayerWrapper(#if MC_VER <= MC_1_12_2 NetHandlerPlayServer #else ServerGamePacketListenerImpl #endif connection) { this.connection = connection; }
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private ServerPlayerWrapper(NetHandlerPlayServer connection)
|
||||
#else
|
||||
private ServerPlayerWrapper(ServerGamePacketListenerImpl connection)
|
||||
#endif
|
||||
{ this.connection = connection; }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//=========//
|
||||
// getters //
|
||||
//=========//
|
||||
//region
|
||||
|
||||
private #if MC_VER <= MC_1_12_2 EntityPlayerMP #else ServerPlayer #endif getServerPlayer() { return this.connection.player; }
|
||||
#if MC_VER <= MC_1_12_2
|
||||
private EntityPlayerMP getServerPlayer()
|
||||
#else
|
||||
private ServerPlayer getServerPlayer()
|
||||
#endif
|
||||
{ return this.connection.player; }
|
||||
|
||||
@Override
|
||||
public String getName() { return this.getServerPlayer().getName()#if MC_VER > MC_1_12_2 .getString() #endif ; }
|
||||
public String getName()
|
||||
{
|
||||
#if MC_VER <= MC_1_12_2
|
||||
return this.getServerPlayer().getName();
|
||||
#else
|
||||
return this.getServerPlayer().getName().getString();
|
||||
#endif
|
||||
}
|
||||
|
||||
@Override
|
||||
public IServerLevelWrapper getLevel()
|
||||
@@ -103,11 +136,14 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper
|
||||
#endif
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// base overrides //
|
||||
//================//
|
||||
//region
|
||||
|
||||
@Override
|
||||
public Object getWrappedMcObject() { return this.getServerPlayer(); }
|
||||
@@ -133,4 +169,8 @@ public class ServerPlayerWrapper implements IServerPlayerWrapper
|
||||
@Override
|
||||
public int hashCode() { return Objects.hashCode(this.connection); }
|
||||
|
||||
//endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user