mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 23:27:59 +01:00
Fix startup errors
This commit is contained in:
parent
2c626b4376
commit
3c37c7136d
11 changed files with 52 additions and 80 deletions
|
@ -20,6 +20,10 @@ public class BatEyesApplicator {
|
||||||
return 0.6F;
|
return 0.6F;
|
||||||
}
|
}
|
||||||
return initial;
|
return initial;
|
||||||
|
/*StatusEffectInstance statusEffectInstance = entity.getStatusEffect(StatusEffects.NIGHT_VISION);
|
||||||
|
return !statusEffectInstance.isDurationBelow(200)
|
||||||
|
? 1.0F
|
||||||
|
: 0.7F + MathHelper.sin(((float)statusEffectInstance.getDuration() - tickDelta) * (float) Math.PI * 0.2F) * 0.3F;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enable() {
|
public void enable() {
|
||||||
|
|
|
@ -24,10 +24,12 @@ public final class LeavesAdditionsModel extends ForwardingBakedModel {
|
||||||
ModelLoadingPlugin.register(ctx -> {
|
ModelLoadingPlugin.register(ctx -> {
|
||||||
ctx.modifyModelAfterBake().register(ModelModifier.WRAP_PHASE, (model, context) -> {
|
ctx.modifyModelAfterBake().register(ModelModifier.WRAP_PHASE, (model, context) -> {
|
||||||
Identifier id = context.resourceId();
|
Identifier id = context.resourceId();
|
||||||
if (!id.getPath().endsWith("_flowering") || !(Registries.BLOCK.get(id.withPath(p -> p.replace("block/", "").replace("_flowering", ""))) instanceof FruitBearingBlock)) {
|
if (model == null || id == null
|
||||||
|
|| !id.getPath().endsWith("_flowering")
|
||||||
|
|| !(Registries.BLOCK.get(id.withPath(p -> p.replace("block/", "").replace("_flowering", ""))) instanceof FruitBearingBlock)) {
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
return model == null ? null : new LeavesAdditionsModel(model);
|
return new LeavesAdditionsModel(model);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class PolearmRenderer implements DynamicItemRenderer, ClampedModelPredica
|
||||||
|
|
||||||
static Identifier getModelId(ItemConvertible item) {
|
static Identifier getModelId(ItemConvertible item) {
|
||||||
Identifier id = Registries.ITEM.getId(item.asItem());
|
Identifier id = Registries.ITEM.getId(item.asItem());
|
||||||
return id.withPath(p -> p + "_in_inventory");
|
return id.withPath(p -> "item/" + p + "_in_inventory");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TexturedModelData getTexturedModelData() {
|
public static TexturedModelData getTexturedModelData() {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
|
||||||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gl.*;
|
import net.minecraft.client.gl.*;
|
||||||
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
import net.minecraft.resource.ResourceManager;
|
import net.minecraft.resource.ResourceManager;
|
||||||
import net.minecraft.resource.SynchronousResourceReloader;
|
import net.minecraft.resource.SynchronousResourceReloader;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -27,8 +28,8 @@ public class ViewportShader implements SynchronousResourceReloader, Identifiable
|
||||||
|
|
||||||
public static final ViewportShader INSTANCE = new ViewportShader();
|
public static final ViewportShader INSTANCE = new ViewportShader();
|
||||||
|
|
||||||
public static final Identifier CREEPER_SHADER = Identifier.ofVanilla("shaders/post/invert.json");
|
public static final Identifier CREEPER_SHADER = Identifier.ofVanilla("shaders/post/creeper.json");
|
||||||
public static final Identifier DESATURATION_SHADER = Identifier.ofVanilla("shaders/post/desaturate.json");
|
public static final Identifier DESATURATION_SHADER = Unicopia.id("shaders/post/desaturate.json");
|
||||||
|
|
||||||
private final MinecraftClient client = MinecraftClient.getInstance();
|
private final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ public class ViewportShader implements SynchronousResourceReloader, Identifiable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(float tickDelta) {
|
public void render(RenderTickCounter tickCounter) {
|
||||||
if (Unicopia.getConfig().disableShaders.get()) {
|
if (Unicopia.getConfig().disableShaders.get()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +86,7 @@ public class ViewportShader implements SynchronousResourceReloader, Identifiable
|
||||||
corruption = 1 - corruption + 0.05F;
|
corruption = 1 - corruption + 0.05F;
|
||||||
|
|
||||||
shader.setUniformValue("color_convolve", "Saturation", corruption);
|
shader.setUniformValue("color_convolve", "Saturation", corruption);
|
||||||
shader.render(tickDelta);
|
shader.render(tickCounter.getLastFrameDuration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,8 +348,8 @@ public class SpellbookScreenHandler extends ScreenHandler {
|
||||||
ItemStack current = slot.getStack();
|
ItemStack current = slot.getStack();
|
||||||
|
|
||||||
if (current.isEmpty() && slot.canInsert(stack)) {
|
if (current.isEmpty() && slot.canInsert(stack)) {
|
||||||
if (stack.getCount() > slot.getMaxItemCount()) {
|
if (stack.getCount() > slot.getMaxItemCount(stack)) {
|
||||||
slot.setStack(stack.split(slot.getMaxItemCount()));
|
slot.setStack(stack.split(slot.getMaxItemCount(stack)));
|
||||||
} else {
|
} else {
|
||||||
slot.setStack(stack.split(stack.getCount()));
|
slot.setStack(stack.split(stack.getCount()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,6 @@ public interface UEnchantmentEffects {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void register(String name, MapCodec<? extends EnchantmentEntityEffect> codec) {
|
private static void register(String name, MapCodec<? extends EnchantmentEntityEffect> codec) {
|
||||||
Registry.register(Registries.ENCHANTMENT_ENTITY_EFFECT_TYPE, Unicopia.id("name"), codec);
|
Registry.register(Registries.ENCHANTMENT_ENTITY_EFFECT_TYPE, Unicopia.id(name), codec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.registry.Registry;
|
|
||||||
import net.minecraft.registry.RegistryKey;
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.registry.RegistryKeys;
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
|
||||||
|
@ -121,10 +120,6 @@ public interface UEnchantments {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void register(Registry<Enchantment> registry, RegistryKey<Enchantment> key, Enchantment.Builder builder) {
|
|
||||||
Registry.register(registry, key, builder.build(key.getValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void bootstrap() {
|
static void bootstrap() {
|
||||||
UEnchantmentEffects.bootstrap();
|
UEnchantmentEffects.bootstrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,6 @@ import org.spongepowered.asm.mixin.*;
|
||||||
import org.spongepowered.asm.mixin.injection.*;
|
import org.spongepowered.asm.mixin.injection.*;
|
||||||
import org.spongepowered.asm.mixin.injection.At.Shift;
|
import org.spongepowered.asm.mixin.injection.At.Shift;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||||
import com.minelittlepony.unicopia.client.BatEyesApplicator;
|
import com.minelittlepony.unicopia.client.BatEyesApplicator;
|
||||||
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
import com.minelittlepony.unicopia.client.UnicopiaClient;
|
||||||
|
@ -43,25 +41,19 @@ abstract class MixinGameRenderer implements AutoCloseable, SynchronousResourceRe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "renderWorld",
|
@Inject(method = "renderWorld", at = @At("RETURN"))
|
||||||
at = @At("RETURN"))
|
|
||||||
private void afterRenderWorld(RenderTickCounter counter, CallbackInfo info) {
|
private void afterRenderWorld(RenderTickCounter counter, CallbackInfo info) {
|
||||||
BatEyesApplicator.INSTANCE.disable();
|
BatEyesApplicator.INSTANCE.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyReturnValue(method = "getNightVisionStrength(Lnet/minecraft/entity/LivingEntity;F)F", at = @At("RETURN"))
|
@ModifyReturnValue(method = "getNightVisionStrength", at = @At("RETURN"))
|
||||||
private static float modifyWorldBrightness(float initial, LivingEntity entity, float tickDelta, CallbackInfoReturnable<Float> info) {
|
private static float modifyNightVisionStrength(float initial, LivingEntity entity, float tickDelta) {
|
||||||
return BatEyesApplicator.getWorldBrightness(initial, entity, tickDelta);
|
return BatEyesApplicator.getWorldBrightness(initial, entity, tickDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "render",
|
@Inject(method = "render", at = @At(value = "INVOKE", target = "net/minecraft/client/gl/Framebuffer.beginWrite(Z)V", shift = Shift.BEFORE))
|
||||||
at = @At(
|
private void onBeforeFrameEnd(RenderTickCounter tickCounter, boolean tick, CallbackInfo info) {
|
||||||
value = "INVOKE",
|
ViewportShader.INSTANCE.render(tickCounter);
|
||||||
target = "net/minecraft/client/gl/Framebuffer.beginWrite(Z)V",
|
|
||||||
shift = Shift.BEFORE)
|
|
||||||
)
|
|
||||||
private void onBeforeFrameEnd(float tickDelta, long startTime, boolean tick, CallbackInfo info) {
|
|
||||||
ViewportShader.INSTANCE.render(tickDelta);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "onResized", at = @At("HEAD"))
|
@Inject(method = "onResized", at = @At("HEAD"))
|
||||||
|
|
|
@ -3,63 +3,19 @@ package com.minelittlepony.unicopia.mixin.trinkets;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.spongepowered.asm.mixin.*;
|
import org.spongepowered.asm.mixin.*;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.compat.trinkets.TrinketsDelegate;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.screen.slot.Slot;
|
import net.minecraft.screen.slot.Slot;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
|
||||||
|
|
||||||
// fixed shift-clicking (handles other 10%)
|
// fixed shift-clicking (handles other 10%)
|
||||||
@Mixin(ScreenHandler.class)
|
@Mixin(ScreenHandler.class)
|
||||||
abstract class MixinScreenHandler {
|
abstract class MixinScreenHandler {
|
||||||
@Nullable
|
@ModifyExpressionValue(
|
||||||
private Slot currentSlot;
|
method = "canInsertItemIntoSlot",
|
||||||
|
at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getMaxCount()I")
|
||||||
@Redirect(method = "insertItem",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/util/collection/DefaultedList;get(I)Ljava/lang/Object;"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
// manual capture of the current slot since @Redirect doesn't support local captures
|
private static int modifyMaxCount(int maxCount, @Nullable Slot slot, ItemStack stack, boolean allowOverflow) {
|
||||||
private Object onGetSlot(DefaultedList<Slot> sender, int index) {
|
return slot.getMaxItemCount(stack);
|
||||||
currentSlot = sender.get(index);
|
|
||||||
return currentSlot;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "insertItem",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/screen/slot/Slot;getMaxItemCount()I"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// redirect slot.getMaxItemCount() to stack aware version
|
|
||||||
protected int onGetMaxItemCount(Slot sender, ItemStack stack) {
|
|
||||||
return TrinketsDelegate.getInstance(null).isTrinketSlot(sender) ? sender.getMaxItemCount(stack) : sender.getMaxItemCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "insertItem",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/item/ItemStack;isEmpty()Z",
|
|
||||||
ordinal = 1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
// redirect "if (!itemStack.isEmpty() && ItemStack.canCombine(stack, itemStack))" -> "if (!canNotInsert(itemStack, slot) && ItemStack.canCombine(stack, itemStack))"
|
|
||||||
protected boolean canNotInsert(ItemStack sender) {
|
|
||||||
return sender.isEmpty() || (TrinketsDelegate.getInstance(null).isTrinketSlot(currentSlot) && (currentSlot.getStack().getCount() + sender.getCount()) <= currentSlot.getMaxItemCount(sender));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Redirect(method = "canInsertItemIntoSlot",
|
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/item/ItemStack;getMaxCount()I"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private static int onGetMaxCount(ItemStack sender, @Nullable Slot slot) {
|
|
||||||
return TrinketsDelegate.getInstance(null).isTrinketSlot(slot) ? slot.getMaxItemCount(sender) : sender.getMaxCount();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ abstract class MixinTrinketInventory implements Inventory {
|
||||||
ItemStack existingStack = getStack(slot);
|
ItemStack existingStack = getStack(slot);
|
||||||
SlotReference ref = new SlotReference((TrinketInventory)(Object)this, slot);
|
SlotReference ref = new SlotReference((TrinketInventory)(Object)this, slot);
|
||||||
|
|
||||||
|
|
||||||
int max = Math.min(
|
int max = Math.min(
|
||||||
existingStack.isEmpty() ? 64 : TrinketsDelegateImpl.getMaxCount(existingStack, ref, existingStack.getMaxCount()),
|
existingStack.isEmpty() ? 64 : TrinketsDelegateImpl.getMaxCount(existingStack, ref, existingStack.getMaxCount()),
|
||||||
stack.isEmpty() ? 64 : TrinketsDelegateImpl.getMaxCount(stack, ref, stack.getMaxCount())
|
stack.isEmpty() ? 64 : TrinketsDelegateImpl.getMaxCount(stack, ref, stack.getMaxCount())
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"targets": [
|
||||||
|
"swap"
|
||||||
|
],
|
||||||
|
"passes": [
|
||||||
|
{
|
||||||
|
"name": "color_convolve",
|
||||||
|
"intarget": "minecraft:main",
|
||||||
|
"outtarget": "swap",
|
||||||
|
"uniforms": [
|
||||||
|
{
|
||||||
|
"name": "Saturation",
|
||||||
|
"values": [ 0.2 ]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "blit",
|
||||||
|
"intarget": "swap",
|
||||||
|
"outtarget": "minecraft:main"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue