2015-11-02 12:39:44 -08:00
|
|
|
package WayofTime.bloodmagic.proxy;
|
2015-10-29 20:22:14 -07:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
2018-02-05 17:04:38 -08:00
|
|
|
import WayofTime.bloodmagic.apibutnotreally.Constants;
|
|
|
|
import WayofTime.bloodmagic.apibutnotreally.soul.DemonWillHolder;
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.client.IMeshProvider;
|
|
|
|
import WayofTime.bloodmagic.client.IVariantProvider;
|
|
|
|
import WayofTime.bloodmagic.client.helper.ShaderHelper;
|
|
|
|
import WayofTime.bloodmagic.client.hud.HUDElementDemonWillAura;
|
|
|
|
import WayofTime.bloodmagic.client.hud.HUDElementHolding;
|
2016-10-18 16:05:37 -07:00
|
|
|
import WayofTime.bloodmagic.client.key.KeyBindings;
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.client.render.LayerBloodElytra;
|
2016-12-11 20:28:47 -05:00
|
|
|
import WayofTime.bloodmagic.client.render.block.*;
|
2017-08-15 21:30:48 -07: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;
|
2016-12-11 20:28:47 -05:00
|
|
|
import WayofTime.bloodmagic.tile.*;
|
2017-08-15 21:30:48 -07:00
|
|
|
import WayofTime.bloodmagic.tile.routing.TileRoutingNode;
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
2016-07-10 12:46:03 -04:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderManager;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
2016-07-26 17:55:15 -07:00
|
|
|
import net.minecraft.potion.PotionUtils;
|
2016-07-10 12:46:03 -04:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraftforge.client.model.ModelLoader;
|
2016-09-14 08:47:46 -04:00
|
|
|
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
|
|
|
import net.minecraftforge.client.model.animation.AnimationTESR;
|
2016-07-10 12:46:03 -04:00
|
|
|
import net.minecraftforge.client.model.obj.OBJLoader;
|
2016-09-14 08:47:46 -04:00
|
|
|
import net.minecraftforge.common.animation.Event;
|
|
|
|
import net.minecraftforge.common.animation.ITimeValue;
|
|
|
|
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
2016-07-10 12:46:03 -04:00
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
|
|
|
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
|
|
|
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
import java.awt.Color;
|
|
|
|
import java.util.Map;
|
2016-09-14 08:47:46 -04:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
public class ClientProxy extends CommonProxy {
|
2016-07-10 15:27:26 -04:00
|
|
|
public static DemonWillHolder currentAura = new DemonWillHolder();
|
|
|
|
|
2015-10-29 20:22:14 -07:00
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void preInit() {
|
2016-01-03 15:39:59 -05:00
|
|
|
super.preInit();
|
|
|
|
|
2017-08-14 20:53:42 -07:00
|
|
|
OBJLoader.INSTANCE.addDomain(BloodMagic.MODID);
|
2016-01-09 22:05:03 -08:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileInversionPillar.class, new AnimationTESR<TileInversionPillar>() {
|
2016-09-14 08:47:46 -04:00
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void handleEvents(TileInversionPillar chest, float time, Iterable<Event> pastEvents) {
|
2016-09-14 08:47:46 -04:00
|
|
|
chest.handleEvents(time, pastEvents);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-23 15:20:26 -05:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileAlchemyArray.class, new RenderAlchemyArray());
|
2016-01-01 09:03:21 -05:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderAltar());
|
2016-01-15 15:06:03 -05:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileRoutingNode.class, new RenderItemRoutingNode());
|
2016-02-17 16:31:11 -05:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileDemonCrucible.class, new RenderDemonCrucible());
|
2016-08-22 19:55:15 -04:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileMimic.class, new RenderMimic());
|
2016-12-11 20:28:47 -05:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(TileBloodTank.class, new RenderBloodTank());
|
2016-10-18 16:05:37 -07:00
|
|
|
|
|
|
|
// Initialize key-binds during startup so they load correctly
|
|
|
|
for (KeyBindings key : KeyBindings.values())
|
|
|
|
key.getKey();
|
2015-10-29 20:22:14 -07:00
|
|
|
}
|
|
|
|
|
2016-01-08 14:56:36 -05:00
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void registerRenderers() {
|
2016-01-08 14:56:36 -05:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntitySoulSnare.class, new SoulSnareRenderFactory());
|
2016-01-09 10:47:36 -05:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntitySentientArrow.class, new SentientArrowRenderFactory());
|
2016-01-31 14:31:16 -05:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityBloodLight.class, new BloodLightRenderFactory());
|
2016-07-13 17:18:34 -04:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityMeteor.class, new MeteorRenderFactory());
|
2016-08-14 14:14:25 -04:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntitySentientSpecter.class, new SentientSpecterRenderFactory());
|
2016-08-22 14:22:18 -04:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityMimic.class, new MimicRenderFactory());
|
2016-09-13 17:20:35 -04:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedZombie.class, new CorruptedZombieRenderFactory());
|
2016-09-17 08:06:31 -04:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedSheep.class, new CorruptedSheepRenderFactory());
|
2016-09-20 17:28:58 -04:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedChicken.class, new CorruptedChickenRenderFactory());
|
2016-09-22 14:20:05 -04:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityCorruptedSpider.class, new CorruptedSpiderRenderFactory());
|
2016-02-05 22:25:26 -05:00
|
|
|
|
2016-01-15 19:59:00 -05:00
|
|
|
ShaderHelper.init();
|
2016-01-08 14:56:36 -05:00
|
|
|
}
|
|
|
|
|
2015-10-29 20:22:14 -07:00
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void init() {
|
2017-06-01 22:17:46 -07:00
|
|
|
super.init();
|
2017-08-15 20:21:54 -07:00
|
|
|
Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> {
|
2017-08-15 21:30:48 -07:00
|
|
|
try {
|
2017-08-15 20:21:54 -07: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-15 21:30:48 -07:00
|
|
|
} catch (NumberFormatException e) {
|
2016-06-23 21:43:27 -04:00
|
|
|
return -1;
|
|
|
|
}
|
2017-08-15 20:21:54 -07:00
|
|
|
return -1;
|
2017-08-14 20:53:42 -07:00
|
|
|
}, RegistrarBloodMagicItems.SIGIL_HOLDING);
|
2017-08-15 20:21:54 -07:00
|
|
|
Minecraft.getMinecraft().getItemColors().registerItemColorHandler((stack, tintIndex) -> {
|
|
|
|
if (tintIndex != 0 && tintIndex != 2)
|
|
|
|
return -1;
|
2016-07-26 17:55:15 -07:00
|
|
|
|
2017-08-15 20:21:54 -07:00
|
|
|
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("empty"))
|
|
|
|
return -1;
|
2016-12-30 18:27:16 -08:00
|
|
|
|
2017-08-15 20:21:54 -07:00
|
|
|
return PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromStack(stack));
|
2017-08-14 20:53:42 -07:00
|
|
|
}, RegistrarBloodMagicItems.POTION_FLASK);
|
2016-05-30 19:48:28 -07:00
|
|
|
|
|
|
|
addElytraLayer();
|
2015-10-29 20:22:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void postInit() {
|
2016-06-16 18:12:20 -07:00
|
|
|
new HUDElementHolding();
|
2016-07-10 12:46:03 -04:00
|
|
|
new HUDElementDemonWillAura();
|
2015-10-29 20:22:14 -07:00
|
|
|
}
|
2016-03-15 22:48:01 -07:00
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void tryHandleBlockModel(Block block, String name) {
|
|
|
|
if (block instanceof IVariantProvider) {
|
2016-03-15 22:48:01 -07:00
|
|
|
IVariantProvider variantProvider = (IVariantProvider) block;
|
|
|
|
for (Pair<Integer, String> variant : variantProvider.getVariants())
|
2017-08-14 20:53:42 -07:00
|
|
|
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), variant.getLeft(), new ModelResourceLocation(new ResourceLocation(BloodMagic.MODID, name), variant.getRight()));
|
2016-03-15 22:48:01 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public void tryHandleItemModel(Item item, String name) {
|
|
|
|
if (item instanceof IMeshProvider) {
|
2016-03-15 22:48:01 -07:00
|
|
|
IMeshProvider meshProvider = (IMeshProvider) item;
|
|
|
|
ModelLoader.setCustomMeshDefinition(item, meshProvider.getMeshDefinition());
|
2016-03-20 23:21:07 -07:00
|
|
|
ResourceLocation resourceLocation = meshProvider.getCustomLocation();
|
|
|
|
if (resourceLocation == null)
|
2017-08-14 20:53:42 -07:00
|
|
|
resourceLocation = new ResourceLocation(BloodMagic.MODID, "item/" + name);
|
2016-03-15 22:48:01 -07:00
|
|
|
for (String variant : meshProvider.getVariants())
|
2016-03-20 23:21:07 -07:00
|
|
|
ModelLoader.registerItemVariants(item, new ModelResourceLocation(resourceLocation, variant));
|
2017-08-15 21:30:48 -07:00
|
|
|
} else if (item instanceof IVariantProvider) {
|
2016-03-15 22:48:01 -07:00
|
|
|
IVariantProvider variantProvider = (IVariantProvider) item;
|
|
|
|
for (Pair<Integer, String> variant : variantProvider.getVariants())
|
2017-08-14 20:53:42 -07:00
|
|
|
ModelLoader.setCustomModelResourceLocation(item, variant.getLeft(), new ModelResourceLocation(new ResourceLocation(BloodMagic.MODID, "item/" + name), variant.getRight()));
|
2016-03-15 22:48:01 -07:00
|
|
|
}
|
|
|
|
}
|
2016-05-30 19:48:28 -07:00
|
|
|
|
2017-08-15 21:30:48 -07:00
|
|
|
private void addElytraLayer() {
|
2016-05-30 19:48:28 -07:00
|
|
|
RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
|
2017-08-15 21:30:48 -07:00
|
|
|
try {
|
2017-08-15 20:21:54 -07: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")));
|
2017-08-14 20:53:42 -07:00
|
|
|
BloodMagic.instance.logger.info("Elytra layer added");
|
2017-08-15 21:30:48 -07:00
|
|
|
} catch (Exception e) {
|
2017-08-14 20:53:42 -07:00
|
|
|
BloodMagic.instance.logger.error("Failed to set custom Elytra Layer for Elytra Living Armour Upgrade.");
|
|
|
|
BloodMagic.instance.logger.error(e.getLocalizedMessage());
|
2016-05-30 19:48:28 -07:00
|
|
|
}
|
|
|
|
}
|
2016-09-14 08:47:46 -04:00
|
|
|
|
|
|
|
@Override
|
2017-08-15 21:30:48 -07:00
|
|
|
public IAnimationStateMachine load(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters) {
|
2016-09-14 08:47:46 -04:00
|
|
|
return ModelLoaderRegistry.loadASM(location, parameters);
|
|
|
|
}
|
2015-10-29 20:22:14 -07:00
|
|
|
}
|