NaturesAura/src/main/java/de/ellpeck/naturesaura/proxy/ClientProxy.java

88 lines
3.7 KiB
Java
Raw Normal View History

2018-10-13 20:35:18 +02:00
package de.ellpeck.naturesaura.proxy;
2018-10-18 13:34:37 +02:00
import de.ellpeck.naturesaura.blocks.tiles.TileEntityNatureAltar;
2018-10-16 11:49:30 +02:00
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
2018-10-18 13:34:37 +02:00
import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
2018-10-16 11:49:30 +02:00
import de.ellpeck.naturesaura.blocks.tiles.render.RenderWoodStand;
import de.ellpeck.naturesaura.compat.Compat;
2018-10-13 20:35:18 +02:00
import de.ellpeck.naturesaura.events.ClientEvents;
import de.ellpeck.naturesaura.particles.ParticleHandler;
import de.ellpeck.naturesaura.particles.ParticleMagic;
import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import de.ellpeck.naturesaura.renderers.PlayerLayerTrinkets;
2018-10-13 20:35:18 +02:00
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.color.ItemColors;
2018-10-20 22:13:00 +02:00
import net.minecraft.client.renderer.entity.RenderPlayer;
2018-10-13 20:35:18 +02:00
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
2018-10-16 11:49:30 +02:00
import net.minecraftforge.fml.client.registry.ClientRegistry;
2018-10-13 20:35:18 +02:00
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
2018-10-20 22:13:00 +02:00
import java.util.Map;
2018-10-13 20:35:18 +02:00
public class ClientProxy implements IProxy {
@Override
public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new ClientEvents());
}
@Override
public void init(FMLInitializationEvent event) {
2018-10-16 11:49:30 +02:00
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWoodStand.class, new RenderWoodStand());
2018-10-18 13:34:37 +02:00
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityNatureAltar.class, new RenderNatureAltar());
2018-10-20 22:13:00 +02:00
Map<String, RenderPlayer> skinMap = Minecraft.getMinecraft().getRenderManager().getSkinMap();
for (RenderPlayer render : new RenderPlayer[]{skinMap.get("default"), skinMap.get("slim")}) {
render.addLayer(new PlayerLayerTrinkets());
2018-10-20 22:13:00 +02:00
}
2018-10-13 20:35:18 +02:00
}
@Override
public void postInit(FMLPostInitializationEvent event) {
}
@Override
public void registerRenderer(ItemStack stack, ModelResourceLocation location) {
ModelLoader.setCustomModelResourceLocation(stack.getItem(), stack.getItemDamage(), location);
2018-10-13 20:35:18 +02:00
}
@Override
public void addColorProvidingItem(IColorProvidingItem item) {
2018-10-13 20:45:32 +02:00
ItemColors colors = Minecraft.getMinecraft().getItemColors();
2018-10-13 20:35:18 +02:00
IItemColor color = item.getItemColor();
if (item instanceof Item) {
2018-10-13 20:45:32 +02:00
colors.registerItemColorHandler(color, (Item) item);
2018-10-13 20:35:18 +02:00
} else if (item instanceof Block) {
2018-10-13 20:45:32 +02:00
colors.registerItemColorHandler(color, (Block) item);
2018-10-13 20:35:18 +02:00
}
}
@Override
public void addColorProvidingBlock(IColorProvidingBlock block) {
if (block instanceof Block) {
2018-10-13 20:45:32 +02:00
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(block.getBlockColor(), (Block) block);
2018-10-13 20:35:18 +02:00
}
}
@Override
2018-10-14 14:27:18 +02:00
public void spawnMagicParticle(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision, boolean fade) {
2018-10-14 17:46:00 +02:00
ParticleHandler.spawnParticle(() -> new ParticleMagic(world, posX, posY, posZ, motionX, motionY, motionZ, color, scale, maxAge, gravity, collision, fade), posX, posY, posZ, 32);
2018-10-13 20:35:18 +02:00
}
@Override
public void scheduleTask(Runnable runnable) {
2018-10-13 20:45:32 +02:00
Minecraft.getMinecraft().addScheduledTask(runnable);
2018-10-13 20:35:18 +02:00
}
}