2015-11-02 20:39:44 +00:00
|
|
|
package WayofTime.bloodmagic.proxy;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
|
|
|
import WayofTime.bloodmagic.client.helper.ShaderHelper;
|
2018-03-08 03:43:00 +00:00
|
|
|
import WayofTime.bloodmagic.client.hud.Elements;
|
2016-10-18 23:05:37 +00:00
|
|
|
import WayofTime.bloodmagic.client.key.KeyBindings;
|
2017-08-16 04:30:48 +00:00
|
|
|
import WayofTime.bloodmagic.client.render.LayerBloodElytra;
|
2016-12-12 01:28:47 +00:00
|
|
|
import WayofTime.bloodmagic.client.render.block.*;
|
2017-08-16 04:30:48 +00:00
|
|
|
import WayofTime.bloodmagic.client.render.entity.*;
|
|
|
|
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
|
|
|
import WayofTime.bloodmagic.entity.mob.*;
|
|
|
|
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
|
|
|
|
import WayofTime.bloodmagic.entity.projectile.EntityMeteor;
|
|
|
|
import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow;
|
|
|
|
import WayofTime.bloodmagic.entity.projectile.EntitySoulSnare;
|
2018-03-08 03:43:00 +00:00
|
|
|
import WayofTime.bloodmagic.soul.DemonWillHolder;
|
2016-12-12 01:28:47 +00:00
|
|
|
import WayofTime.bloodmagic.tile.*;
|
2017-08-16 04:30:48 +00:00
|
|
|
import WayofTime.bloodmagic.tile.routing.TileRoutingNode;
|
2018-03-18 00:18:20 +00:00
|
|
|
import WayofTime.bloodmagic.util.BMLog;
|
2018-03-08 03:43:00 +00:00
|
|
|
import WayofTime.bloodmagic.util.Constants;
|
2017-08-16 04:30:48 +00:00
|
|
|
import com.google.common.collect.ImmutableMap;
|
2016-07-10 16:46:03 +00:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderManager;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
2016-07-27 00:55:15 +00:00
|
|
|
import net.minecraft.potion.PotionUtils;
|
2016-07-10 16:46:03 +00:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-09-14 12:47:46 +00:00
|
|
|
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
|
|
|
import net.minecraftforge.client.model.animation.AnimationTESR;
|
2016-07-10 16:46:03 +00:00
|
|
|
import net.minecraftforge.client.model.obj.OBJLoader;
|
2016-09-14 12:47:46 +00:00
|
|
|
import net.minecraftforge.common.animation.Event;
|
|
|
|
import net.minecraftforge.common.animation.ITimeValue;
|
|
|
|
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
2016-07-10 16:46:03 +00:00
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
|
|
|
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
|
|
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
import java.awt.Color;
|
|
|
|
import java.util.Map;
|
2016-09-14 12:47:46 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
public class ClientProxy extends CommonProxy {
|
2016-07-10 19:27:26 +00:00
|
|
|
public static DemonWillHolder currentAura = new DemonWillHolder();
|
|
|
|
|
2015-10-30 03:22:14 +00:00
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public void preInit() {
|
2016-01-03 20:39:59 +00:00
|
|
|
super.preInit();
|
|
|
|
|
2017-08-15 03:53:42 +00:00
|
|
|
OBJLoader.INSTANCE.addDomain(BloodMagic.MODID);
|
2016-01-10 06:05:03 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileInversionPillar.class, new AnimationTESR<TileInversionPillar>() {
|
2016-09-14 12:47:46 +00:00
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public void handleEvents(TileInversionPillar chest, float time, Iterable<Event> pastEvents) {
|
2016-09-14 12:47:46 +00:00
|
|
|
chest.handleEvents(time, pastEvents);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-23 20:20:26 +00:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileAlchemyArray.class, new RenderAlchemyArray());
|
2016-01-01 14:03:21 +00:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderAltar());
|
2016-01-15 20:06:03 +00:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileRoutingNode.class, new RenderItemRoutingNode());
|
2016-02-17 21:31:11 +00:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileDemonCrucible.class, new RenderDemonCrucible());
|
2016-08-22 23:55:15 +00:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileMimic.class, new RenderMimic());
|
2016-12-12 01:28:47 +00:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileBloodTank.class, new RenderBloodTank());
|
2016-10-18 23:05:37 +00:00
|
|
|
|
|
|
|
// Initialize key-binds during startup so they load correctly
|
|
|
|
for (KeyBindings key : KeyBindings.values())
|
|
|
|
key.getKey();
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
|
2016-01-08 19:56:36 +00:00
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public void registerRenderers() {
|
2016-01-08 19:56:36 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntitySoulSnare.class, new SoulSnareRenderFactory());
|
2016-01-09 15:47:36 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntitySentientArrow.class, new SentientArrowRenderFactory());
|
2016-01-31 19:31:16 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityBloodLight.class, new BloodLightRenderFactory());
|
2016-07-13 21:18:34 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityMeteor.class, new MeteorRenderFactory());
|
2016-08-14 18:14:25 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntitySentientSpecter.class, new SentientSpecterRenderFactory());
|
2016-08-22 18:22:18 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityMimic.class, new MimicRenderFactory());
|
2016-09-13 21:20:35 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedZombie.class, new CorruptedZombieRenderFactory());
|
2016-09-17 12:06:31 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedSheep.class, new CorruptedSheepRenderFactory());
|
2016-09-20 21:28:58 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedChicken.class, new CorruptedChickenRenderFactory());
|
2016-09-22 18:20:05 +00:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedSpider.class, new CorruptedSpiderRenderFactory());
|
2016-02-06 03:25:26 +00:00
|
|
|
|
2016-01-16 00:59:00 +00:00
|
|
|
ShaderHelper.init();
|
2016-01-08 19:56:36 +00:00
|
|
|
}
|
|
|
|
|
2015-10-30 03:22:14 +00:00
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public void init() {
|
2017-06-02 05:17:46 +00:00
|
|
|
super.init();
|
2017-08-16 03:21:54 +00:00
|
|
|
Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> {
|
2017-08-16 04:30:48 +00:00
|
|
|
try {
|
2017-08-16 03:21:54 +00:00
|
|
|
if (stack.hasTagCompound() && stack.getTagCompound().hasKey(Constants.NBT.COLOR))
|
|
|
|
if (tintIndex == 1)
|
|
|
|
return Color.decode(stack.getTagCompound().getString(Constants.NBT.COLOR)).getRGB();
|
2017-08-16 04:30:48 +00:00
|
|
|
} catch (NumberFormatException e) {
|
2016-06-24 01:43:27 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2017-08-16 03:21:54 +00:00
|
|
|
return -1;
|
2017-08-15 03:53:42 +00:00
|
|
|
}, RegistrarBloodMagicItems.SIGIL_HOLDING);
|
2017-08-16 03:21:54 +00:00
|
|
|
Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> {
|
|
|
|
if (tintIndex != 0 && tintIndex != 2)
|
|
|
|
return -1;
|
2016-07-27 00:55:15 +00:00
|
|
|
|
2017-08-16 03:21:54 +00:00
|
|
|
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("empty"))
|
|
|
|
return -1;
|
2016-12-31 02:27:16 +00:00
|
|
|
|
2017-08-16 03:21:54 +00:00
|
|
|
return PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromStack(stack));
|
2017-08-15 03:53:42 +00:00
|
|
|
}, RegistrarBloodMagicItems.POTION_FLASK);
|
2016-05-31 02:48:28 +00:00
|
|
|
|
|
|
|
addElytraLayer();
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public void postInit() {
|
2018-02-18 23:55:40 +00:00
|
|
|
Elements.createHUDElements();
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
2016-03-16 05:48:01 +00:00
|
|
|
|
2017-08-16 04:30:48 +00:00
|
|
|
private void addElytraLayer() {
|
2016-05-31 02:48:28 +00:00
|
|
|
RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
|
2017-08-16 04:30:48 +00:00
|
|
|
try {
|
2017-08-16 03:21:54 +00:00
|
|
|
Map<String, RenderPlayer> skinMap = ObfuscationReflectionHelper.getPrivateValue(RenderManager.class, renderManager, "skinMap", "field_178636_l");
|
|
|
|
skinMap.get("default").addLayer(new LayerBloodElytra(skinMap.get("default")));
|
|
|
|
skinMap.get("slim").addLayer(new LayerBloodElytra(skinMap.get("slim")));
|
2018-03-18 00:18:20 +00:00
|
|
|
BMLog.DEBUG.info("Elytra layer added");
|
2017-08-16 04:30:48 +00:00
|
|
|
} catch (Exception e) {
|
2018-03-18 00:18:20 +00:00
|
|
|
BMLog.DEBUG.error("Failed to set custom Elytra Layer for Elytra Living Armour Upgrade: {}", e.getMessage());
|
2016-05-31 02:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 12:47:46 +00:00
|
|
|
|
|
|
|
@Override
|
2017-08-16 04:30:48 +00:00
|
|
|
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters) {
|
2016-09-14 12:47:46 +00:00
|
|
|
return ModelLoaderRegistry.loadASM(location, parameters);
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|