this isn't working

This commit is contained in:
petrak@ 2023-02-17 20:56:39 -06:00
parent 74690580f6
commit e44892389c
30 changed files with 191 additions and 74 deletions

View file

@ -1,4 +0,0 @@
package at.petrak.hexcasting.client;
public class PatternShapeMatcher {
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.client.be;
import at.petrak.hexcasting.api.casting.math.HexPattern;
import at.petrak.hexcasting.client.RenderLib;
import at.petrak.hexcasting.client.render.RenderLib;
import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf;
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf;
import com.mojang.blaze3d.systems.RenderSystem;

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.client.be;
import at.petrak.hexcasting.client.RenderLib;
import at.petrak.hexcasting.client.render.RenderLib;
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
import at.petrak.hexcasting.common.blocks.circles.BlockSlate;
import com.mojang.blaze3d.systems.RenderSystem;

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.client.entity;
import at.petrak.hexcasting.client.RenderLib;
import at.petrak.hexcasting.client.render.RenderLib;
import at.petrak.hexcasting.common.entities.EntityWallScroll;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;

View file

@ -1,8 +1,5 @@
package at.petrak.hexcasting.client.gui
import at.petrak.hexcasting.api.misc.DiscoveryHandlers
import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.api.mod.HexTags
import at.petrak.hexcasting.api.casting.eval.ControllerInfo
import at.petrak.hexcasting.api.casting.eval.ResolvedPattern
import at.petrak.hexcasting.api.casting.eval.ResolvedPatternType
@ -10,9 +7,14 @@ import at.petrak.hexcasting.api.casting.math.HexAngle
import at.petrak.hexcasting.api.casting.math.HexCoord
import at.petrak.hexcasting.api.casting.math.HexDir
import at.petrak.hexcasting.api.casting.math.HexPattern
import at.petrak.hexcasting.api.misc.DiscoveryHandlers
import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.api.mod.HexTags
import at.petrak.hexcasting.api.utils.asTranslatedComponent
import at.petrak.hexcasting.client.*
import at.petrak.hexcasting.client.ClientTickCounter
import at.petrak.hexcasting.client.ShiftScrollListener
import at.petrak.hexcasting.client.ktxt.accumulatedScroll
import at.petrak.hexcasting.client.render.*
import at.petrak.hexcasting.client.sound.GridSoundInstance
import at.petrak.hexcasting.common.lib.HexSounds
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.client.gui;
import at.petrak.hexcasting.api.casting.math.HexPattern;
import at.petrak.hexcasting.client.RenderLib;
import at.petrak.hexcasting.client.render.RenderLib;
import at.petrak.hexcasting.common.misc.PatternTooltip;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;

View file

@ -1,8 +1,9 @@
package at.petrak.hexcasting.client;
package at.petrak.hexcasting.client.render;
import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry;
import at.petrak.hexcasting.api.misc.DiscoveryHandlers;
import at.petrak.hexcasting.api.player.Sentinel;
import at.petrak.hexcasting.client.ClientTickCounter;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.platform.GlStateManager;

View file

@ -0,0 +1,4 @@
package at.petrak.hexcasting.client.render;
public class PatternShapeMatcher {
}

View file

@ -1,10 +1,11 @@
@file:JvmName("RenderLib")
package at.petrak.hexcasting.client
package at.petrak.hexcasting.client.render
import at.petrak.hexcasting.api.casting.math.HexPattern
import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.api.utils.TAU
import at.petrak.hexcasting.client.ClientTickCounter
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.DefaultVertexFormat
import com.mojang.blaze3d.vertex.PoseStack

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.client.shader;
package at.petrak.hexcasting.client.render.shader;
import at.petrak.hexcasting.mixin.accessor.client.AccessorCompositeRenderType;
import at.petrak.hexcasting.mixin.accessor.client.AccessorEmptyTextureStateShard;
@ -13,7 +13,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.Optional;
import java.util.function.Function;
public record FakeBufferSource(MultiBufferSource parent, Function<ResourceLocation, RenderType> mapper) implements MultiBufferSource {
public record FakeBufferSource(MultiBufferSource parent,
Function<ResourceLocation, RenderType> mapper) implements MultiBufferSource {
@Override
@SuppressWarnings("ConstantConditions")

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.client.shader;
package at.petrak.hexcasting.client.render.shader;
import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.mixin.accessor.client.AccessorRenderType;
@ -13,7 +13,8 @@ import java.util.function.Function;
// https://github.com/VazkiiMods/Botania/blob/3a43accc2fbc439c9f2f00a698f8f8ad017503db/Common/src/main/java/vazkii/botania/client/core/helper/RenderHelper.java
public final class HexRenderTypes extends RenderType {
private HexRenderTypes(String string, VertexFormat vertexFormat, VertexFormat.Mode mode, int i, boolean bl, boolean bl2, Runnable runnable, Runnable runnable2) {
private HexRenderTypes(String string, VertexFormat vertexFormat, VertexFormat.Mode mode, int i, boolean bl,
boolean bl2, Runnable runnable, Runnable runnable2) {
super(string, vertexFormat, mode, i, bl, bl2, runnable, runnable2);
throw new UnsupportedOperationException("Should not be instantiated");
}
@ -33,7 +34,8 @@ public final class HexRenderTypes extends RenderType {
.setOverlayState(OVERLAY)
.createCompositeState(true);
return makeLayer(HexAPI.MOD_ID + ":grayscale", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, glState);
return makeLayer(HexAPI.MOD_ID + ":grayscale", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256,
true, false, glState);
});
public static RenderType getGrayscaleLayer(ResourceLocation texture) {

View file

@ -1,4 +1,4 @@
package at.petrak.hexcasting.client.shader;
package at.petrak.hexcasting.client.render.shader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.datafixers.util.Pair;
@ -11,6 +11,7 @@ import java.util.function.Consumer;
// https://github.com/VazkiiMods/Botania/blob/3a43accc2fbc439c9f2f00a698f8f8ad017503db/Common/src/main/java/vazkii/botania/client/core/helper/CoreShaders.java
public class HexShaders {
private static ShaderInstance grayscale;
public static void init(ResourceManager resourceManager,
Consumer<Pair<ShaderInstance, Consumer<ShaderInstance>>> registrations) throws IOException {
registrations.accept(Pair.of(

View file

@ -3,7 +3,7 @@ package at.petrak.hexcasting.common.entities;
import at.petrak.hexcasting.api.casting.math.HexPattern;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.api.utils.NBTHelper;
import at.petrak.hexcasting.client.RenderLib;
import at.petrak.hexcasting.client.render.RenderLib;
import at.petrak.hexcasting.common.items.storage.ItemScroll;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.lib.HexSounds;

View file

@ -2,7 +2,7 @@ package at.petrak.hexcasting.interop.patchouli;
import at.petrak.hexcasting.api.casting.math.HexCoord;
import at.petrak.hexcasting.api.casting.math.HexPattern;
import at.petrak.hexcasting.client.RenderLib;
import at.petrak.hexcasting.client.render.RenderLib;
import at.petrak.hexcasting.interop.utils.PatternDrawingUtil;
import at.petrak.hexcasting.interop.utils.PatternEntry;
import com.mojang.blaze3d.vertex.PoseStack;

View file

@ -3,7 +3,7 @@ package at.petrak.hexcasting.interop.utils;
import at.petrak.hexcasting.api.casting.math.HexCoord;
import at.petrak.hexcasting.api.casting.math.HexPattern;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.client.RenderLib;
import at.petrak.hexcasting.client.render.RenderLib;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;

View file

@ -0,0 +1,41 @@
package at.petrak.hexcasting.mixin.client;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.layers.ElytraLayer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
// Do this with a mixin instead of a model like you're supposed to because
// 1. cause it's easier
// 2. players wearing normal elytra and altiora won't get z fighting
@Mixin(ElytraLayer.class)
public class MixinElytraLayer {
private static final ResourceLocation ALTIORA_LOC = modLoc("textures/misc/altiora.png");
// The "do i draw" check is one of the thing forge clobbers, so we do that in side-specific mixins
@ModifyVariable(
method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;" +
"ILnet/minecraft/world/entity/LivingEntity;FFFFFF)V",
at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V", ordinal = 0),
ordinal = 0
)
private ResourceLocation injectAltioraLocation(ResourceLocation texLoc, PoseStack ps, MultiBufferSource mbs,
int packedLight, LivingEntity e) {
if (e instanceof Player player) {
if (IXplatAbstractions.INSTANCE.getAltiora(player) != null) {
return ALTIORA_LOC;
}
}
return texLoc;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B

View file

@ -25,6 +25,7 @@
"accessor.client.AccessorMouseHandler",
"accessor.client.AccessorRenderStateShard",
"accessor.client.AccessorRenderType",
"client.MixinClientLevel"
"client.MixinClientLevel",
"client.MixinElytraLayer"
]
}

View file

@ -1,10 +1,10 @@
package at.petrak.hexcasting.fabric
import at.petrak.hexcasting.client.ClientTickCounter
import at.petrak.hexcasting.client.HexAdditionalRenderers
import at.petrak.hexcasting.client.RegisterClientStuff
import at.petrak.hexcasting.client.ShiftScrollListener
import at.petrak.hexcasting.client.gui.PatternTooltipComponent
import at.petrak.hexcasting.client.render.HexAdditionalRenderers
import at.petrak.hexcasting.common.casting.PatternRegistryManifest
import at.petrak.hexcasting.common.lib.HexParticles
import at.petrak.hexcasting.fabric.event.MouseScrollCallback

View file

@ -64,13 +64,12 @@ public class HexCardinalComponents implements EntityComponentInitializer, ItemCo
registry.registerFor(Mob.class, BRAINSWEPT, CCBrainswept::new);
registry.registerForPlayers(FAVORED_COLORIZER, CCFavoredColorizer::new, RespawnCopyStrategy.ALWAYS_COPY);
registry.registerForPlayers(SENTINEL, CCSentinel::new, RespawnCopyStrategy.ALWAYS_COPY);
registry.registerForPlayers(ALTIORA, CCAltiora::new, RespawnCopyStrategy.LOSSLESS_ONLY);
// Fortunately these are all both only needed on the server and don't want to be copied across death
registry.registerFor(ServerPlayer.class, FLIGHT, CCFlight::new);
registry.registerFor(ServerPlayer.class, HARNESS, CCHarness::new);
registry.registerFor(ServerPlayer.class, PATTERNS, CCPatterns::new);
// On Fabric, this is needed on the client because the c/s need to agree on when wings are being deployed
registry.registerForPlayers(ALTIORA, CCAltiora::new, RespawnCopyStrategy.LOSSLESS_ONLY);
registry.registerFor(ItemEntity.class, IOTA_HOLDER, wrapItemEntityDelegate(
ItemDelegatingEntityIotaHolder.ToItemEntity::new));

View file

@ -16,7 +16,7 @@ import java.util.List;
import java.util.stream.Collectors;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
import static at.petrak.hexcasting.client.RenderLib.renderEntity;
import static at.petrak.hexcasting.client.render.RenderLib.renderEntity;
public class BrainsweepeeEmiStack extends EmiStack {
public final BrainsweepeeIngredient ingredient;

View file

@ -0,0 +1,35 @@
package at.petrak.hexcasting.fabric.mixin.client;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.layers.ElytraLayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ElytraLayer.class)
public class FabricMixinElytraLayer {
@Redirect(
method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;" +
"ILnet/minecraft/world/entity/LivingEntity;FFFFFF)V",
at = @At(value = "INVOKE", ordinal = 0, target = "Lnet/minecraft/world/item/ItemStack;is" +
"(Lnet/minecraft/world/item/Item;)Z")
)
private boolean renderIfAltiora(ItemStack stack, Item elytraItem, PoseStack ps, MultiBufferSource mbs, int light,
LivingEntity entity) {
if (entity instanceof Player player) {
var altiora = IXplatAbstractions.INSTANCE.getAltiora(player);
if (altiora != null) {
return true;
}
}
return stack.is(elytraItem);
}
}

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.fabric.mixin.client;
import at.petrak.hexcasting.client.shader.HexShaders;
import at.petrak.hexcasting.client.render.shader.HexShaders;
import com.mojang.blaze3d.shaders.Program;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.GameRenderer;

View file

@ -17,6 +17,7 @@
"client": [
"client.FabricAbstractTextureMixin",
"client.FabricLevelRendererMixin",
"client.FabricMixinElytraLayer",
"client.FabricMixinGameRenderer",
"client.FabricModelManagerMixin",
"client.FabricMouseHandlerMixin",

View file

@ -1,11 +1,11 @@
package at.petrak.hexcasting.forge;
import at.petrak.hexcasting.client.ClientTickCounter;
import at.petrak.hexcasting.client.HexAdditionalRenderers;
import at.petrak.hexcasting.client.RegisterClientStuff;
import at.petrak.hexcasting.client.ShiftScrollListener;
import at.petrak.hexcasting.client.gui.PatternTooltipComponent;
import at.petrak.hexcasting.client.shader.HexShaders;
import at.petrak.hexcasting.client.render.HexAdditionalRenderers;
import at.petrak.hexcasting.client.render.shader.HexShaders;
import at.petrak.hexcasting.common.casting.PatternRegistryManifest;
import at.petrak.hexcasting.common.lib.HexParticles;
import at.petrak.hexcasting.common.misc.PatternTooltip;

View file

@ -25,6 +25,7 @@ public class CapSyncers {
// Copy data from this to new player
var x = IXplatAbstractions.INSTANCE;
x.setFlight(player, x.getFlight(proto));
x.setAltiora(player, x.getAltiora(proto));
x.setSentinel(player, x.getSentinel(proto));
x.setColorizer(player, x.getColorizer(proto));
x.setHarness(player, x.getHarness(proto, InteractionHand.MAIN_HAND));

View file

@ -26,7 +26,7 @@ import java.util.Collections;
import java.util.List;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
import static at.petrak.hexcasting.client.RenderLib.renderEntity;
import static at.petrak.hexcasting.client.render.RenderLib.renderEntity;
public class BrainsweepRecipeCategory implements IRecipeCategory<BrainsweepRecipe> {
public static final ResourceLocation UID = modLoc("brainsweep");

View file

@ -0,0 +1,30 @@
package at.petrak.hexcasting.forge.mixin.client;
import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.client.renderer.entity.layers.ElytraLayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
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.CallbackInfoReturnable;
@Mixin(ElytraLayer.class)
public class ForgeMixinElytraLayer {
@Inject(
method = "shouldRender", at = @At("RETURN"),
cancellable = true,
remap = false
)
private void renderIfAltiora(ItemStack stack, LivingEntity entity, CallbackInfoReturnable<Boolean> cir) {
if (entity instanceof Player player) {
var altiora = IXplatAbstractions.INSTANCE.getAltiora(player);
HexAPI.LOGGER.warn(altiora);
if (altiora != null) {
cir.setReturnValue(true);
}
}
}
}

View file

@ -244,12 +244,7 @@ public class ForgeXplatImpl implements IXplatAbstractions {
}
@Override
public AltioraAbility getAltiora(Player anyPlayer) {
if (!(anyPlayer instanceof ServerPlayer player)) {
// the check only needs to happen client-side on fabric
// which is great, cause it's not even synced on forge
return null;
}
public AltioraAbility getAltiora(Player player) {
CompoundTag tag = player.getPersistentData();
boolean allowed = tag.getBoolean(TAG_ALTIORA_ALLOWED);
if (allowed) {

View file

@ -4,7 +4,13 @@
"compatibilityLevel": "JAVA_17",
"refmap": "hexcasting.mixins.refmap.json",
"package": "at.petrak.hexcasting.forge.mixin",
"mixins": ["ForgeAccessorRegistry", "ForgeMixinCursedRecipeSerializerBase"], "client": [
"ForgeMixinBlockColors", "ForgeMixinItemColors"
]
"mixins": [
"ForgeAccessorRegistry",
"ForgeMixinCursedRecipeSerializerBase"
],
"client": [
"ForgeMixinBlockColors",
"ForgeMixinItemColors",
"client.ForgeMixinElytraLayer"
]
}