mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 05:08:34 +01:00
parent
dffeeab4d8
commit
9f47487dca
5 changed files with 36 additions and 91 deletions
|
@ -39,7 +39,9 @@ public final class NaturesAura {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static NaturesAura instance;
|
public static NaturesAura instance;
|
||||||
public static IProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> ServerProxy::new);
|
// this causes a classloading issue if it's not wrapped like this
|
||||||
|
@SuppressWarnings("Convert2MethodRef")
|
||||||
|
public static IProxy proxy = DistExecutor.unsafeRunForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy());
|
||||||
|
|
||||||
public NaturesAura() {
|
public NaturesAura() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
|
@ -2,6 +2,10 @@ package de.ellpeck.naturesaura.proxy;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.NaturesAura;
|
import de.ellpeck.naturesaura.NaturesAura;
|
||||||
import de.ellpeck.naturesaura.compat.Compat;
|
import de.ellpeck.naturesaura.compat.Compat;
|
||||||
|
import de.ellpeck.naturesaura.entities.ModEntities;
|
||||||
|
import de.ellpeck.naturesaura.entities.render.RenderEffectInhibitor;
|
||||||
|
import de.ellpeck.naturesaura.entities.render.RenderMoverMinecart;
|
||||||
|
import de.ellpeck.naturesaura.entities.render.RenderStub;
|
||||||
import de.ellpeck.naturesaura.events.ClientEvents;
|
import de.ellpeck.naturesaura.events.ClientEvents;
|
||||||
import de.ellpeck.naturesaura.gui.GuiEnderCrate;
|
import de.ellpeck.naturesaura.gui.GuiEnderCrate;
|
||||||
import de.ellpeck.naturesaura.gui.ModContainers;
|
import de.ellpeck.naturesaura.gui.ModContainers;
|
||||||
|
@ -13,25 +17,19 @@ import de.ellpeck.naturesaura.reg.*;
|
||||||
import de.ellpeck.naturesaura.renderers.PlayerLayerTrinkets;
|
import de.ellpeck.naturesaura.renderers.PlayerLayerTrinkets;
|
||||||
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler;
|
import de.ellpeck.naturesaura.renderers.SupporterFancyHandler;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.color.item.ItemColor;
|
|
||||||
import net.minecraft.client.color.item.ItemColors;
|
|
||||||
import net.minecraft.client.gui.screens.MenuScreens;
|
import net.minecraft.client.gui.screens.MenuScreens;
|
||||||
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
import net.minecraft.client.renderer.ItemBlockRenderTypes;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||||
|
import net.minecraft.client.renderer.entity.ThrownItemRenderer;
|
||||||
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
import net.minecraft.client.renderer.entity.player.PlayerRenderer;
|
||||||
import net.minecraft.client.renderer.item.ItemProperties;
|
import net.minecraft.client.renderer.item.ItemProperties;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class ClientProxy implements IProxy {
|
public class ClientProxy implements IProxy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,6 +53,20 @@ public class ClientProxy implements IProxy {
|
||||||
living.addLayer(new PlayerLayerTrinkets(living));
|
living.addLayer(new PlayerLayerTrinkets(living));
|
||||||
}
|
}
|
||||||
new SupporterFancyHandler();
|
new SupporterFancyHandler();
|
||||||
|
|
||||||
|
for (var item : ModRegistry.ALL_ITEMS) {
|
||||||
|
if (item instanceof IColorProvidingBlock color)
|
||||||
|
this.addColorProvidingBlock(color);
|
||||||
|
if (item instanceof IColorProvidingItem color)
|
||||||
|
this.addColorProvidingItem(color);
|
||||||
|
if (item instanceof ITESRProvider provider)
|
||||||
|
provider.registerTESR();
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityRenderers.register(ModEntities.MOVER_CART, RenderMoverMinecart::new);
|
||||||
|
EntityRenderers.register(ModEntities.EFFECT_INHIBITOR, RenderEffectInhibitor::new);
|
||||||
|
EntityRenderers.register(ModEntities.LIGHT_PROJECTILE, RenderStub::new);
|
||||||
|
EntityRenderers.register(ModEntities.STRUCTURE_FINDER, c -> new ThrownItemRenderer<>(c, 1, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,24 +77,6 @@ public class ClientProxy implements IProxy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addColorProvidingItem(IColorProvidingItem item) {
|
|
||||||
var colors = Minecraft.getInstance().getItemColors();
|
|
||||||
var color = item.getItemColor();
|
|
||||||
|
|
||||||
if (item instanceof Item) {
|
|
||||||
colors.register(color, (Item) item);
|
|
||||||
} else if (item instanceof Block) {
|
|
||||||
colors.register(color, (Block) item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addColorProvidingBlock(IColorProvidingBlock block) {
|
|
||||||
if (block instanceof Block)
|
|
||||||
Minecraft.getInstance().getBlockColors().register(block.getBlockColor(), (Block) block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
|
public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
|
||||||
ParticleHandler.spawnParticle(() -> new ParticleMagic(Minecraft.getInstance().level,
|
ParticleHandler.spawnParticle(() -> new ParticleMagic(Minecraft.getInstance().level,
|
||||||
|
@ -106,9 +100,20 @@ public class ClientProxy implements IProxy {
|
||||||
ParticleHandler.culling = cull;
|
ParticleHandler.culling = cull;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void addColorProvidingItem(IColorProvidingItem item) {
|
||||||
public <T extends Entity> void registerEntityRenderer(EntityType<T> entityClass, Supplier<EntityRendererProvider<T>> renderFactory) {
|
var colors = Minecraft.getInstance().getItemColors();
|
||||||
EntityRenderers.register(entityClass, renderFactory.get());
|
var color = item.getItemColor();
|
||||||
|
|
||||||
|
if (item instanceof Item) {
|
||||||
|
colors.register(color, (Item) item);
|
||||||
|
} else if (item instanceof Block) {
|
||||||
|
colors.register(color, (Block) item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addColorProvidingBlock(IColorProvidingBlock block) {
|
||||||
|
if (block instanceof Block)
|
||||||
|
Minecraft.getInstance().getBlockColors().register(block.getBlockColor(), (Block) block);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,14 +1,7 @@
|
||||||
package de.ellpeck.naturesaura.proxy;
|
package de.ellpeck.naturesaura.proxy;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
|
|
||||||
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public interface IProxy {
|
public interface IProxy {
|
||||||
|
|
||||||
void preInit(FMLCommonSetupEvent event);
|
void preInit(FMLCommonSetupEvent event);
|
||||||
|
@ -17,10 +10,6 @@ public interface IProxy {
|
||||||
|
|
||||||
void postInit(FMLCommonSetupEvent event);
|
void postInit(FMLCommonSetupEvent event);
|
||||||
|
|
||||||
void addColorProvidingItem(IColorProvidingItem item);
|
|
||||||
|
|
||||||
void addColorProvidingBlock(IColorProvidingBlock block);
|
|
||||||
|
|
||||||
void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade);
|
void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade);
|
||||||
|
|
||||||
void setParticleDepth(boolean depth);
|
void setParticleDepth(boolean depth);
|
||||||
|
@ -28,6 +17,4 @@ public interface IProxy {
|
||||||
void setParticleSpawnRange(int range);
|
void setParticleSpawnRange(int range);
|
||||||
|
|
||||||
void setParticleCulling(boolean cull);
|
void setParticleCulling(boolean cull);
|
||||||
|
|
||||||
<T extends Entity> void registerEntityRenderer(EntityType<T> entityClass, Supplier<EntityRendererProvider<T>> renderFactory);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
package de.ellpeck.naturesaura.proxy;
|
package de.ellpeck.naturesaura.proxy;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
|
|
||||||
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
import net.minecraft.world.entity.EntityType;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class ServerProxy implements IProxy {
|
public class ServerProxy implements IProxy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,16 +19,6 @@ public class ServerProxy implements IProxy {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addColorProvidingItem(IColorProvidingItem item) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addColorProvidingBlock(IColorProvidingBlock block) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
|
public void spawnMagicParticle(double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
|
||||||
|
|
||||||
|
@ -55,9 +38,4 @@ public class ServerProxy implements IProxy {
|
||||||
public void setParticleCulling(boolean cull) {
|
public void setParticleCulling(boolean cull) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends Entity> void registerEntityRenderer(EntityType<T> entityClass, Supplier<EntityRendererProvider<T>> renderFactory) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -10,9 +10,6 @@ import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
|
||||||
import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment;
|
import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment;
|
||||||
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
import de.ellpeck.naturesaura.enchant.ModEnchantments;
|
||||||
import de.ellpeck.naturesaura.entities.*;
|
import de.ellpeck.naturesaura.entities.*;
|
||||||
import de.ellpeck.naturesaura.entities.render.RenderEffectInhibitor;
|
|
||||||
import de.ellpeck.naturesaura.entities.render.RenderMoverMinecart;
|
|
||||||
import de.ellpeck.naturesaura.entities.render.RenderStub;
|
|
||||||
import de.ellpeck.naturesaura.gen.LevelGenAncientTree;
|
import de.ellpeck.naturesaura.gen.LevelGenAncientTree;
|
||||||
import de.ellpeck.naturesaura.gen.LevelGenAuraBloom;
|
import de.ellpeck.naturesaura.gen.LevelGenAuraBloom;
|
||||||
import de.ellpeck.naturesaura.gen.LevelGenNetherWartMushroom;
|
import de.ellpeck.naturesaura.gen.LevelGenNetherWartMushroom;
|
||||||
|
@ -25,9 +22,6 @@ import de.ellpeck.naturesaura.potion.ModPotions;
|
||||||
import de.ellpeck.naturesaura.potion.PotionBreathless;
|
import de.ellpeck.naturesaura.potion.PotionBreathless;
|
||||||
import de.ellpeck.naturesaura.recipes.EnabledCondition;
|
import de.ellpeck.naturesaura.recipes.EnabledCondition;
|
||||||
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
import de.ellpeck.naturesaura.recipes.ModRecipes;
|
||||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
|
||||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|
||||||
import net.minecraft.client.renderer.entity.ThrownItemRenderer;
|
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
import net.minecraft.data.BuiltinRegistries;
|
import net.minecraft.data.BuiltinRegistries;
|
||||||
import net.minecraft.world.effect.MobEffect;
|
import net.minecraft.world.effect.MobEffect;
|
||||||
|
@ -275,7 +269,6 @@ public final class ModRegistry {
|
||||||
Helper.populateObjectHolders(ModEnchantments.class, event.getRegistry());
|
Helper.populateObjectHolders(ModEnchantments.class, event.getRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("Convert2Lambda")
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
|
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event) {
|
||||||
event.getRegistry().registerAll(
|
event.getRegistry().registerAll(
|
||||||
|
@ -297,17 +290,6 @@ public final class ModRegistry {
|
||||||
.setRegistryName("structure_finder")
|
.setRegistryName("structure_finder")
|
||||||
);
|
);
|
||||||
Helper.populateObjectHolders(ModEntities.class, event.getRegistry());
|
Helper.populateObjectHolders(ModEntities.class, event.getRegistry());
|
||||||
|
|
||||||
NaturesAura.proxy.registerEntityRenderer(ModEntities.MOVER_CART, () -> RenderMoverMinecart::new);
|
|
||||||
NaturesAura.proxy.registerEntityRenderer(ModEntities.EFFECT_INHIBITOR, () -> RenderEffectInhibitor::new);
|
|
||||||
NaturesAura.proxy.registerEntityRenderer(ModEntities.LIGHT_PROJECTILE, () -> RenderStub::new);
|
|
||||||
// for some reason, only this one causes classloading issues if shortened to a lambda, what
|
|
||||||
NaturesAura.proxy.registerEntityRenderer(ModEntities.STRUCTURE_FINDER, () -> new EntityRendererProvider<>() {
|
|
||||||
@Override
|
|
||||||
public EntityRenderer<EntityStructureFinder> create(Context context) {
|
|
||||||
return new ThrownItemRenderer<>(context, 1, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -331,15 +313,6 @@ public final class ModRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
for (var item : ALL_ITEMS) {
|
|
||||||
if (item instanceof IColorProvidingBlock)
|
|
||||||
NaturesAura.proxy.addColorProvidingBlock((IColorProvidingBlock) item);
|
|
||||||
if (item instanceof IColorProvidingItem)
|
|
||||||
NaturesAura.proxy.addColorProvidingItem((IColorProvidingItem) item);
|
|
||||||
if (item instanceof ITESRProvider provider)
|
|
||||||
provider.registerTESR();
|
|
||||||
}
|
|
||||||
|
|
||||||
// register features 27 more times for some reason
|
// register features 27 more times for some reason
|
||||||
for (var entry : ModFeatures.Configured.class.getFields()) {
|
for (var entry : ModFeatures.Configured.class.getFields()) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue