[vintage] Add biome blend option, small changes to .lang file #19
No files matched your search
+22
-20
@@ -9,47 +9,50 @@ import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class CyclingControl<T extends Enum<T>> implements Control<T> {
|
||||
public class CyclingControl<T> implements Control<T> {
|
||||
private final Option<T> option;
|
||||
private final T[] allowedValues;
|
||||
private final Component[] names;
|
||||
|
||||
public CyclingControl(Option<T> option, Class<T> enumType) {
|
||||
this(option, enumType, enumType.getEnumConstants());
|
||||
this(option, enumType.getEnumConstants(), determineNames(enumType.getEnumConstants()));
|
||||
}
|
||||
|
||||
public CyclingControl(Option<T> option, Class<T> enumType, Component[] names) {
|
||||
T[] universe = enumType.getEnumConstants();
|
||||
|
||||
Validate.isTrue(universe.length == names.length, "Mismatch between universe length and names array length");
|
||||
Validate.notEmpty(universe, "The enum universe must contain at least one item");
|
||||
|
||||
this.option = option;
|
||||
this.allowedValues = universe;
|
||||
this.names = names;
|
||||
this(option, enumType.getEnumConstants(), names);
|
||||
}
|
||||
|
||||
public CyclingControl(Option<T> option, Class<T> enumType, T[] allowedValues) {
|
||||
T[] universe = enumType.getEnumConstants();
|
||||
this(option, allowedValues, determineNames(allowedValues));
|
||||
}
|
||||
|
||||
public CyclingControl(Option<T> option, T[] allowedValues, Component[] names) {
|
||||
this.option = option;
|
||||
if (allowedValues.length != names.length) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.allowedValues = allowedValues;
|
||||
this.names = new Component[universe.length];
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.names.length; i++) {
|
||||
private static Component[] determineNames(Object[] universe) {
|
||||
Component[] names = new Component[universe.length];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
Component name;
|
||||
T value = universe[i];
|
||||
Object value = universe[i];
|
||||
|
||||
if (value instanceof TextProvider) {
|
||||
name = ((TextProvider) value).getLocalizedName();
|
||||
} else if (value instanceof Enum<?> e) {
|
||||
name = ComponentUtil.literal(e.name());
|
||||
} else {
|
||||
name = ComponentUtil.literal(value.name());
|
||||
throw new IllegalArgumentException("Could not figure out name of object " + value);
|
||||
}
|
||||
|
||||
this.names[i] = name;
|
||||
names[i] = name;
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public Component[] getNames() {
|
||||
@@ -71,7 +74,7 @@ public class CyclingControl<T extends Enum<T>> implements Control<T> {
|
||||
return 70;
|
||||
}
|
||||
|
||||
private static class CyclingControlElement<T extends Enum<T>> extends ControlElement<T> {
|
||||
private static class CyclingControlElement<T> extends ControlElement<T> {
|
||||
private final T[] allowedValues;
|
||||
private final Component[] names;
|
||||
|
||||
@@ -96,8 +99,7 @@ public class CyclingControl<T extends Enum<T>> implements Control<T> {
|
||||
public void render(GuiGraphics drawContext, int mouseX, int mouseY, float delta) {
|
||||
super.render(drawContext, mouseX, mouseY, delta);
|
||||
|
||||
Enum<T> value = this.option.getValue();
|
||||
Component name = this.names[value.ordinal()];
|
||||
Component name = this.names[getCurrentIndex()];
|
||||
|
||||
if(!this.option.isAvailable()) {
|
||||
name = ComponentUtil.empty().append(name).withStyle(ChatFormatting.GRAY, ChatFormatting.STRIKETHROUGH);
|
||||
|
||||
@@ -101,12 +101,6 @@ public class Celeritas /*? if fabric {*/ /*implements ClientModInitializer *//*?
|
||||
mainEventBus.addListener((RegisterClientCommandsEvent event) -> DevCommands.register(event.getDispatcher()));
|
||||
}
|
||||
|
||||
if (options().advanced.enableCeleritasIncognitoMode) {
|
||||
MODNAME = "Embeddium";
|
||||
MOD_VERSION = "1.0.11-beta.420";
|
||||
EmbeddiumConstants.MODNAME = "Embeddium";
|
||||
}
|
||||
|
||||
// TODO remove
|
||||
//? if shaders {
|
||||
modEventBus.addListener((RegisterKeyMappingsEvent ev) -> {
|
||||
|
||||
@@ -67,7 +67,6 @@ public class SodiumGameOptions {
|
||||
public boolean enableMemoryTracing = false;
|
||||
public boolean useAdvancedStagingBuffers = true;
|
||||
public boolean disableIncompatibleModWarnings = false;
|
||||
public boolean enableCeleritasIncognitoMode = false;
|
||||
|
||||
public int cpuRenderAheadLimit = 3;
|
||||
}
|
||||
|
||||
+2
-20
@@ -9,18 +9,16 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.embeddedt.embeddium.impl.model.BlockEntityImplInfo;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Mixin(Level.class)
|
||||
public abstract class LevelMixin {
|
||||
@@ -52,9 +50,6 @@ public abstract class LevelMixin {
|
||||
listRef.set(list);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static final ConcurrentHashMap<Class<? extends BlockEntity>, Boolean> OVERRIDES_GET_MODEL_DATA = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason Scan through block entities that are loaded for the first time and trigger section rebuilds if they have
|
||||
@@ -74,20 +69,7 @@ public abstract class LevelMixin {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean overridesModelData = OVERRIDES_GET_MODEL_DATA.computeIfAbsent(be.getClass(), clz -> {
|
||||
try {
|
||||
Method method = clz.getMethod("getModelData");
|
||||
//? if neoforge
|
||||
/*return method.getDeclaringClass() != net.neoforged.neoforge.common.extensions.IBlockEntityExtension.class;*/
|
||||
//? if forge && >=1.17
|
||||
return method.getDeclaringClass() != net.minecraftforge.common.extensions.IForgeBlockEntity.class;
|
||||
//? if forge && <1.17
|
||||
/*return method.getDeclaringClass() != net.minecraftforge.common.extensions.IForgeTileEntity.class;*/
|
||||
} catch (NoSuchMethodException e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (overridesModelData) {
|
||||
if (BlockEntityImplInfo.providesModelData(be)) {
|
||||
// We need to trigger a section rebuild to take the newly loaded model data into account.
|
||||
// Not doing this can cause issues like Mekanism cables being disconnected when loading
|
||||
// into singleplayer for the first time.
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package org.embeddedt.embeddium.impl.mixin.features.model;
|
||||
|
||||
//? if forge {
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataManager;
|
||||
import org.embeddedt.embeddium.impl.model.BlockEntityImplInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(ModelDataManager.class)
|
||||
public class ModelDataManagerMixin {
|
||||
@Inject(method = "requestRefresh", at = @At("HEAD"), cancellable = true)
|
||||
private void celeritas$skipIfNotModelDataProvider(BlockEntity be, CallbackInfo ci) {
|
||||
if (!BlockEntityImplInfo.providesModelData(be)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason Avoid inserting ModelData.EMPTY into the map, as it's redundant.
|
||||
*/
|
||||
@WrapOperation(method = "refreshAt", at = @At(value = "INVOKE", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"))
|
||||
private Object celeritas$skipPuttingEmpty(Map<BlockPos, ModelData> instance, Object k, Object v, Operation<Object> original) {
|
||||
if (v == ModelData.EMPTY) {
|
||||
return instance.remove(k);
|
||||
} else {
|
||||
return original.call(instance, k, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
//?}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.embeddedt.embeddium.impl.model;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class BlockEntityImplInfo {
|
||||
private static final ConcurrentHashMap<Class<? extends BlockEntity>, Boolean> OVERRIDES_GET_MODEL_DATA = new ConcurrentHashMap<>();
|
||||
|
||||
public static boolean providesModelData(BlockEntity be) {
|
||||
//? if forgelike {
|
||||
return OVERRIDES_GET_MODEL_DATA.computeIfAbsent(be.getClass(), clz -> {
|
||||
try {
|
||||
Method method = clz.getMethod("getModelData");
|
||||
//? if neoforge
|
||||
/*return method.getDeclaringClass() != net.neoforged.neoforge.common.extensions.IBlockEntityExtension.class;*/
|
||||
//? if forge && >=1.17
|
||||
return method.getDeclaringClass() != net.minecraftforge.common.extensions.IForgeBlockEntity.class;
|
||||
//? if forge && <1.17
|
||||
/*return method.getDeclaringClass() != net.minecraftforge.common.extensions.IForgeTileEntity.class;*/
|
||||
} catch (NoSuchMethodException e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
//?} else
|
||||
/*return false;*/
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -28,7 +28,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
public class ShaderTransformer {
|
||||
|
||||
private static final int CACHE_SIZE = 100;
|
||||
private static final int CACHE_SIZE = 256;
|
||||
private static final Object2ObjectLinkedOpenHashMap<TransformKey, Map<ShaderType, String>> shaderTransformationCache = new Object2ObjectLinkedOpenHashMap<>();
|
||||
public static final boolean useCache = true;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class IrisDefines {
|
||||
}
|
||||
|
||||
public static ImmutableList<StringPair> createIrisReplacements() {
|
||||
ArrayList<StringPair> s = new ArrayList<>(StandardMacros.createStandardEnvironmentDefines());
|
||||
ArrayList<StringPair> s = new ArrayList<>();
|
||||
|
||||
BiomeUniforms.getBiomeMap().forEach((biome, id) -> define(s, "BIOME_" + biome.location().getPath().toUpperCase(Locale.ROOT), String.valueOf(id)));
|
||||
|
||||
|
||||
Reference in new issue
Block a user