holder DC
This commit is contained in:
@@ -156,4 +156,6 @@ dependencies {
|
||||
runtimeOnly "dev.xkmc:l2itemselector:3.0.7"
|
||||
runtimeOnly "dev.xkmc:l2library:3.0.2"
|
||||
runtimeOnly "dev.xkmc:l2complements:3.0.2+3"
|
||||
|
||||
runtimeOnly "curse.maven:embeddium-908741:5630163"
|
||||
}
|
||||
@@ -8,17 +8,17 @@ org.gradle.debug=false
|
||||
neogradle.subsystems.parchment.minecraftVersion=1.20.6
|
||||
neogradle.subsystems.parchment.mappingsVersion=2024.06.02
|
||||
|
||||
minecraft_version=1.21
|
||||
minecraft_version_range=[1.21,1.22)
|
||||
neo_version=21.0.147
|
||||
neo_version_range=[21.0,)
|
||||
minecraft_version=1.21.1
|
||||
minecraft_version_range=[1.21.1,1.22)
|
||||
neo_version=21.1.4
|
||||
neo_version_range=[21.1.4,)
|
||||
loader_version_range=[2,)
|
||||
|
||||
## Mod Properties
|
||||
mod_id=l2core
|
||||
mod_name=L2Core
|
||||
mod_license=LGPL-2.1
|
||||
mod_version=3.0.7+18
|
||||
mod_version=3.0.7+20
|
||||
mod_group_id=dev.xkmc
|
||||
mod_authors=lcy0x1
|
||||
mod_description=Core Library mod for all L2 mods
|
||||
|
||||
@@ -35,7 +35,9 @@ import net.neoforged.neoforge.client.event.RenderLevelStageEvent;
|
||||
import net.neoforged.neoforge.client.event.RenderLivingEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@EventBusSubscriber(value = Dist.CLIENT, modid = L2Core.MODID, bus = EventBusSubscriber.Bus.GAME)
|
||||
public class ClientEffectRenderEvents {
|
||||
@@ -62,11 +64,15 @@ public class ClientEffectRenderEvents {
|
||||
Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||
PoseStack stack = event.getPoseStack();
|
||||
|
||||
// cache the previous handler
|
||||
for (DelayedEntityRender icon : ICONS) {
|
||||
renderIcon(stack, buffers, icon,
|
||||
event.getPartialTick().getGameTimeDeltaPartialTick(true),
|
||||
camera, renderer.entityRenderDispatcher);
|
||||
Map<ResourceLocation, List<DelayedEntityRender>> map = new HashMap<>();
|
||||
for (var e : ICONS) map.computeIfAbsent(e.rl(), k -> new ArrayList<>()).add(e);
|
||||
for (var ent : map.entrySet()) {
|
||||
VertexConsumer vc = buffers.getBuffer(get2DIcon(ent.getKey()));
|
||||
for (var e : ent.getValue()) {
|
||||
renderIcon(stack, vc, e,
|
||||
event.getPartialTick().getGameTimeDeltaPartialTick(true),
|
||||
camera, renderer.entityRenderDispatcher);
|
||||
}
|
||||
}
|
||||
buffers.endBatch();
|
||||
|
||||
@@ -113,7 +119,7 @@ public class ClientEffectRenderEvents {
|
||||
|
||||
}
|
||||
|
||||
private static void renderIcon(PoseStack pose, MultiBufferSource buffer, DelayedEntityRender icon,
|
||||
private static void renderIcon(PoseStack pose, VertexConsumer vc, DelayedEntityRender icon,
|
||||
float partial, Camera camera, EntityRenderDispatcher dispatcher) {
|
||||
LivingEntity entity = icon.entity();
|
||||
float f = entity.getBbHeight() / 2;
|
||||
@@ -130,7 +136,6 @@ public class ClientEffectRenderEvents {
|
||||
pose.translate(d2, d3 + f, d0);
|
||||
pose.mulPose(camera.rotation());
|
||||
PoseStack.Pose entry = pose.last();
|
||||
VertexConsumer ivertexbuilder = buffer.getBuffer(get2DIcon(icon.rl()));
|
||||
|
||||
float ix0 = -0.5f + icon.region().x();
|
||||
float ix1 = ix0 + icon.region().scale();
|
||||
@@ -141,10 +146,10 @@ public class ClientEffectRenderEvents {
|
||||
float u1 = icon.tx() + icon.tw();
|
||||
float v1 = icon.ty() + icon.th();
|
||||
|
||||
iconVertex(entry, ivertexbuilder, ix0, iy0, u0, v1);
|
||||
iconVertex(entry, ivertexbuilder, ix1, iy0, u1, v1);
|
||||
iconVertex(entry, ivertexbuilder, ix1, iy1, u1, v0);
|
||||
iconVertex(entry, ivertexbuilder, ix0, iy1, u0, v0);
|
||||
iconVertex(entry, vc, ix0, iy0, u0, v1);
|
||||
iconVertex(entry, vc, ix1, iy0, u1, v1);
|
||||
iconVertex(entry, vc, ix1, iy1, u1, v0);
|
||||
iconVertex(entry, vc, ix0, iy1, u0, v0);
|
||||
pose.popPose();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.mojang.serialization.Codec;
|
||||
import dev.xkmc.l2core.util.DCStack;
|
||||
import dev.xkmc.l2serial.serialization.codec.CodecAdaptor;
|
||||
import dev.xkmc.l2serial.util.Wrappers;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.UUIDUtil;
|
||||
import net.minecraft.core.component.DataComponentType;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
@@ -81,6 +83,10 @@ public record DCReg(DeferredRegister<DataComponentType<?>> reg) {
|
||||
return reg(id, codec.codec(), codec.stream(), true);
|
||||
}
|
||||
|
||||
public <T> DCVal<Holder<T>> registry(String id, Registry<T> reg) {
|
||||
return reg(id, reg.holderByNameCodec(), ByteBufCodecs.holderRegistry(reg.key()), false);
|
||||
}
|
||||
|
||||
public DCVal<ResourceLocation> loc(String id) {
|
||||
return reg(id, ResourceLocation.CODEC, ResourceLocation.STREAM_CODEC, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user