2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia.client;
|
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
import com.minelittlepony.unicopia.UEntities;
|
2020-04-22 16:28:20 +02:00
|
|
|
import com.minelittlepony.unicopia.client.particle.ChangelingMagicParticle;
|
2021-02-19 15:56:01 +01:00
|
|
|
import com.minelittlepony.unicopia.client.particle.CloudsEscapingParticle;
|
2020-04-22 16:28:20 +02:00
|
|
|
import com.minelittlepony.unicopia.client.particle.DiskParticle;
|
2021-02-05 20:19:41 +01:00
|
|
|
import com.minelittlepony.unicopia.client.particle.GroundPoundParticle;
|
2021-02-02 11:52:50 +01:00
|
|
|
import com.minelittlepony.unicopia.client.particle.HealthDrainParticle;
|
2020-04-22 16:28:20 +02:00
|
|
|
import com.minelittlepony.unicopia.client.particle.MagicParticle;
|
2020-10-13 17:44:49 +02:00
|
|
|
import com.minelittlepony.unicopia.client.particle.RainboomParticle;
|
2020-10-14 21:07:36 +02:00
|
|
|
import com.minelittlepony.unicopia.client.particle.RainbowTrailParticle;
|
2020-04-22 16:28:20 +02:00
|
|
|
import com.minelittlepony.unicopia.client.particle.RaindropsParticle;
|
|
|
|
import com.minelittlepony.unicopia.client.particle.SphereParticle;
|
2021-02-27 16:47:54 +01:00
|
|
|
import com.minelittlepony.unicopia.client.render.AccessoryFeatureRenderer;
|
|
|
|
import com.minelittlepony.unicopia.client.render.AmuletFeatureRenderer;
|
|
|
|
import com.minelittlepony.unicopia.client.render.BraceletFeatureRenderer;
|
2021-02-18 21:30:43 +01:00
|
|
|
import com.minelittlepony.unicopia.client.render.FloatingArtefactEntityRenderer;
|
2021-02-27 21:05:57 +01:00
|
|
|
import com.minelittlepony.unicopia.client.render.WingsFeatureRenderer;
|
2021-02-14 21:15:30 +01:00
|
|
|
import com.minelittlepony.unicopia.item.ChameleonItem;
|
2021-02-03 21:25:42 +01:00
|
|
|
import com.minelittlepony.unicopia.item.UItems;
|
2020-09-22 15:11:20 +02:00
|
|
|
import com.minelittlepony.unicopia.particle.UParticles;
|
2020-04-22 16:28:20 +02:00
|
|
|
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
|
2020-09-27 17:44:39 +02:00
|
|
|
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry.PendingParticleFactory;
|
2020-09-22 15:11:20 +02:00
|
|
|
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
|
2021-02-14 21:15:30 +01:00
|
|
|
import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry;
|
2021-02-03 21:25:42 +01:00
|
|
|
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
2021-02-14 21:15:30 +01:00
|
|
|
import net.minecraft.client.MinecraftClient;
|
2020-09-27 17:44:39 +02:00
|
|
|
import net.minecraft.client.particle.Particle;
|
|
|
|
import net.minecraft.client.particle.SpriteProvider;
|
2021-02-14 21:15:30 +01:00
|
|
|
import net.minecraft.client.render.DiffuseLighting;
|
|
|
|
import net.minecraft.client.render.OverlayTexture;
|
|
|
|
import net.minecraft.client.render.VertexConsumerProvider;
|
2020-09-22 15:11:20 +02:00
|
|
|
import net.minecraft.client.render.entity.FlyingItemEntityRenderer;
|
2021-02-14 21:15:30 +01:00
|
|
|
import net.minecraft.client.render.item.ItemRenderer;
|
|
|
|
import net.minecraft.client.render.model.json.ModelTransformation;
|
2020-09-27 17:44:39 +02:00
|
|
|
import net.minecraft.client.world.ClientWorld;
|
2021-02-03 21:25:42 +01:00
|
|
|
import net.minecraft.item.DyeableItem;
|
2020-09-27 17:44:39 +02:00
|
|
|
import net.minecraft.particle.ParticleEffect;
|
2020-04-15 14:22:03 +02:00
|
|
|
|
|
|
|
public interface URenderers {
|
|
|
|
static void bootstrap() {
|
2020-09-27 17:44:39 +02:00
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.UNICORN_MAGIC, createFactory(MagicParticle::new));
|
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.CHANGELING_MAGIC, createFactory(ChangelingMagicParticle::new));
|
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.RAIN_DROPS, createFactory(RaindropsParticle::new));
|
2021-02-02 11:52:50 +01:00
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.HEALTH_DRAIN, createFactory(HealthDrainParticle::new));
|
2020-10-13 17:44:49 +02:00
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.RAINBOOM_RING, RainboomParticle::new);
|
2020-10-14 21:07:36 +02:00
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.RAINBOOM_TRAIL, RainbowTrailParticle::new);
|
2020-05-03 19:20:51 +02:00
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.SPHERE, SphereParticle::new);
|
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.DISK, DiskParticle::new);
|
2021-02-05 20:19:41 +01:00
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.GROUND_POUND, GroundPoundParticle::new);
|
2021-02-19 15:56:01 +01:00
|
|
|
ParticleFactoryRegistry.getInstance().register(UParticles.CLOUDS_ESCAPING, CloudsEscapingParticle::new);
|
2020-04-26 22:40:43 +02:00
|
|
|
|
2021-02-27 16:47:54 +01:00
|
|
|
AccessoryFeatureRenderer.register(BraceletFeatureRenderer::new);
|
|
|
|
AccessoryFeatureRenderer.register(AmuletFeatureRenderer::new);
|
2021-02-27 21:05:57 +01:00
|
|
|
AccessoryFeatureRenderer.register(WingsFeatureRenderer::new);
|
2021-02-27 16:47:54 +01:00
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
EntityRendererRegistry.INSTANCE.register(UEntities.THROWN_ITEM, (manager, context) -> new FlyingItemEntityRenderer<>(manager, context.getItemRenderer()));
|
2021-02-18 21:30:43 +01:00
|
|
|
EntityRendererRegistry.INSTANCE.register(UEntities.FLOATING_ARTEFACT, FloatingArtefactEntityRenderer::new);
|
2021-02-03 21:25:42 +01:00
|
|
|
|
|
|
|
ColorProviderRegistry.ITEM.register((stack, i) -> i > 0 ? -1 : ((DyeableItem)stack.getItem()).getColor(stack), UItems.FRIENDSHIP_BRACELET);
|
2021-02-14 21:15:30 +01:00
|
|
|
BuiltinItemRendererRegistry.INSTANCE.register(UItems.FILLED_JAR, (stack, mode, matrices, vertexConsumers, light, overlay) -> {
|
|
|
|
|
|
|
|
ItemRenderer renderer = MinecraftClient.getInstance().getItemRenderer();
|
|
|
|
|
|
|
|
ChameleonItem item = (ChameleonItem)stack.getItem();
|
|
|
|
|
|
|
|
// Reset stuff done in the beforelands
|
|
|
|
matrices.pop();
|
|
|
|
|
|
|
|
if (mode == ModelTransformation.Mode.GUI) {
|
|
|
|
DiffuseLighting.disableGuiDepthLighting();
|
|
|
|
}
|
|
|
|
|
|
|
|
VertexConsumerProvider.Immediate immediate = MinecraftClient.getInstance().getBufferBuilders().getEntityVertexConsumers();
|
|
|
|
|
|
|
|
if (item.hasAppearance(stack)) {
|
|
|
|
matrices.push();
|
|
|
|
matrices.scale(0.5F, 0.5F, 0.5F);
|
|
|
|
matrices.translate(0.0125, 0.1, 0);
|
|
|
|
renderer.renderItem(item.getAppearanceStack(stack), mode, light, overlay, matrices, immediate);
|
|
|
|
matrices.pop();
|
|
|
|
}
|
|
|
|
renderer.renderItem(item.createAppearanceStack(stack, UItems.EMPTY_JAR), mode, light, OverlayTexture.DEFAULT_UV, matrices, immediate);
|
|
|
|
immediate.draw();
|
|
|
|
|
|
|
|
if (mode == ModelTransformation.Mode.GUI) {
|
|
|
|
DiffuseLighting.enableGuiDepthLighting();
|
|
|
|
}
|
|
|
|
matrices.push();
|
|
|
|
|
|
|
|
});
|
2020-04-15 14:22:03 +02:00
|
|
|
}
|
2020-09-27 17:44:39 +02:00
|
|
|
|
|
|
|
static <T extends ParticleEffect> PendingParticleFactory<T> createFactory(ParticleSupplier<T> supplier) {
|
2021-02-02 11:52:50 +01:00
|
|
|
return provider -> (effect, world, x, y, z, dx, dy, dz) -> supplier.get(effect, provider, world, x, y, z, dx, dy, dz);
|
2020-09-27 17:44:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
interface ParticleSupplier<T extends ParticleEffect> {
|
2021-02-02 11:52:50 +01:00
|
|
|
Particle get(T effect, SpriteProvider provider, ClientWorld world, double x, double y, double z, double dx, double dy, double dz);
|
2020-09-27 17:44:39 +02:00
|
|
|
}
|
2020-04-15 14:22:03 +02:00
|
|
|
}
|