2015-08-29 14:33:25 +02:00
/ *
* This file ( " ClientProxy.java " ) is part of the Actually Additions Mod for Minecraft .
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-01-03 16:05:51 +01:00
* http : //ellpeck.de/actaddlicense/
2015-08-29 14:33:25 +02:00
* View the source code at https : //github.com/Ellpeck/ActuallyAdditions
*
2016-01-03 16:05:51 +01:00
* © 2016 Ellpeck
2015-08-29 14:33:25 +02:00
* /
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.proxy ;
2014-12-03 21:55:53 +01:00
2015-02-20 22:45:33 +01:00
2016-01-07 23:42:42 +01:00
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderLaserRelay ;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderReconstructorLens ;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderSmileyCloud ;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderTileEntity ;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.blocks.render.model.* ;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues ;
import de.ellpeck.actuallyadditions.mod.event.InitEvents ;
import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit ;
import de.ellpeck.actuallyadditions.mod.tile.* ;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil ;
import de.ellpeck.actuallyadditions.mod.util.ModUtil ;
import de.ellpeck.actuallyadditions.mod.util.playerdata.PersistentClientData ;
2015-09-22 23:32:19 +02:00
import net.minecraft.client.Minecraft ;
2016-01-08 20:51:03 +01:00
import net.minecraft.client.resources.model.ModelBakery ;
2016-01-08 16:52:53 +01:00
import net.minecraft.client.resources.model.ModelResourceLocation ;
import net.minecraft.item.Item ;
import net.minecraft.item.ItemStack ;
2015-11-13 18:56:15 +01:00
import net.minecraft.tileentity.TileEntity ;
2016-01-08 20:51:03 +01:00
import net.minecraft.util.ResourceLocation ;
2016-01-07 18:20:59 +01:00
import net.minecraftforge.fml.client.registry.ClientRegistry ;
import net.minecraftforge.fml.common.event.FMLInitializationEvent ;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent ;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent ;
2015-03-07 02:23:31 +01:00
2015-08-30 19:10:10 +02:00
import java.io.File ;
2015-10-18 19:56:18 +02:00
import java.util.Calendar ;
2016-01-08 20:51:03 +01:00
import java.util.HashMap ;
import java.util.Map ;
2015-08-30 19:10:10 +02:00
2014-12-03 21:55:53 +01:00
@SuppressWarnings ( " unused " )
public class ClientProxy implements IProxy {
2016-01-08 20:51:03 +01:00
private static Map < ItemStack , ResourceLocation > modelLocationsForRegistering = new HashMap < ItemStack , ResourceLocation > ( ) ;
private static Map < Item , ResourceLocation [ ] > modelVariantsForRegistering = new HashMap < Item , ResourceLocation [ ] > ( ) ;
2015-10-18 19:56:18 +02:00
public static boolean pumpkinBlurPumpkinBlur ;
public static boolean jingleAllTheWay ;
2015-10-23 23:08:53 +02:00
public static boolean bulletForMyValentine ;
2015-10-18 19:56:18 +02:00
2015-02-20 22:45:33 +01:00
@Override
2015-08-30 19:10:10 +02:00
public void preInit ( FMLPreInitializationEvent event ) {
2015-07-01 21:32:48 +02:00
ModUtil . LOGGER . info ( " PreInitializing ClientProxy... " ) ;
2015-06-15 22:06:07 +02:00
2015-10-24 12:18:42 +02:00
if ( ConfigBoolValues . ENABLE_SEASONAL . isEnabled ( ) ) {
Calendar c = Calendar . getInstance ( ) ;
pumpkinBlurPumpkinBlur = c . get ( Calendar . MONTH ) = = Calendar . OCTOBER ;
jingleAllTheWay = c . get ( Calendar . MONTH ) = = Calendar . DECEMBER & & c . get ( Calendar . DAY_OF_MONTH ) > = 6 & & c . get ( Calendar . DAY_OF_MONTH ) < = 26 ;
bulletForMyValentine = c . get ( Calendar . MONTH ) = = Calendar . FEBRUARY & & c . get ( Calendar . DAY_OF_MONTH ) > = 12 & & c . get ( Calendar . DAY_OF_MONTH ) < = 16 ;
}
else {
ModUtil . LOGGER . warn ( " You have turned Seasonal Mode off. Therefore, you are evil. " ) ;
}
2015-10-18 19:56:18 +02:00
2015-09-30 06:56:33 +02:00
PersistentClientData . setTheFile ( new File ( Minecraft . getMinecraft ( ) . mcDataDir , ModUtil . MOD_ID + " Data.dat " ) ) ;
2016-01-08 20:51:03 +01:00
for ( Map . Entry < Item , ResourceLocation [ ] > entry : modelVariantsForRegistering . entrySet ( ) ) {
ModelBakery . registerItemVariants ( entry . getKey ( ) , entry . getValue ( ) ) ;
}
2014-12-03 21:55:53 +01:00
}
2015-02-20 22:45:33 +01:00
@Override
2015-08-30 19:10:10 +02:00
public void init ( FMLInitializationEvent event ) {
2015-07-01 21:32:48 +02:00
ModUtil . LOGGER . info ( " Initializing ClientProxy... " ) ;
2015-03-30 18:42:14 +02:00
2015-09-29 17:08:47 +02:00
InitEvents . initClient ( ) ;
2015-09-02 20:06:34 +02:00
2015-11-13 18:56:15 +01:00
registerRenderer ( TileEntityCompost . class , new RenderTileEntity ( new ModelCompost ( ) ) , AssetUtil . compostRenderId ) ;
registerRenderer ( TileEntityFishingNet . class , new RenderTileEntity ( new ModelFishingNet ( ) ) , AssetUtil . fishingNetRenderId ) ;
registerRenderer ( TileEntityFurnaceSolar . class , new RenderTileEntity ( new ModelFurnaceSolar ( ) ) , AssetUtil . furnaceSolarRenderId ) ;
registerRenderer ( TileEntityCoffeeMachine . class , new RenderTileEntity ( new ModelCoffeeMachine ( ) ) , AssetUtil . coffeeMachineRenderId ) ;
registerRenderer ( TileEntityPhantomBooster . class , new RenderTileEntity ( new ModelPhantomBooster ( ) ) , AssetUtil . phantomBoosterRenderId ) ;
registerRenderer ( TileEntitySmileyCloud . class , new RenderSmileyCloud ( new ModelSmileyCloud ( ) ) , AssetUtil . smileyCloudRenderId ) ;
registerRenderer ( TileEntityLaserRelay . class , new RenderLaserRelay ( new ModelLaserRelay ( ) ) , AssetUtil . laserRelayRenderId ) ;
2015-11-24 19:59:33 +01:00
registerRenderer ( TileEntityBookletStand . class , new RenderTileEntity ( new ModelBookletStand ( ) ) , AssetUtil . bookletStandRenderId ) ;
2015-11-29 13:17:45 +01:00
ClientRegistry . bindTileEntitySpecialRenderer ( TileEntityAtomicReconstructor . class , new RenderReconstructorLens ( ) ) ;
2015-10-18 19:21:32 +02:00
2016-01-08 08:10:55 +01:00
//TODO Fix villager
//VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png"));
2016-01-08 16:52:53 +01:00
2016-01-08 20:51:03 +01:00
for ( Map . Entry < ItemStack , ResourceLocation > entry : modelLocationsForRegistering . entrySet ( ) ) {
Minecraft . getMinecraft ( ) . getRenderItem ( ) . getItemModelMesher ( ) . register ( entry . getKey ( ) . getItem ( ) , entry . getKey ( ) . getItemDamage ( ) , new ModelResourceLocation ( entry . getValue ( ) , " inventory " ) ) ;
2016-01-08 16:52:53 +01:00
}
2014-12-03 21:55:53 +01:00
}
2015-02-20 22:45:33 +01:00
@Override
2015-08-30 19:10:10 +02:00
public void postInit ( FMLPostInitializationEvent event ) {
2015-07-01 21:32:48 +02:00
ModUtil . LOGGER . info ( " PostInitializing ClientProxy... " ) ;
2015-11-02 22:37:44 +01:00
SpecialRenderInit . init ( ) ;
2014-12-03 21:55:53 +01:00
}
2015-11-13 18:56:15 +01:00
2016-01-08 20:51:03 +01:00
@Override
public void addRenderRegister ( ItemStack stack , ResourceLocation location ) {
modelLocationsForRegistering . put ( stack , location ) ;
}
@Override
public void addRenderVariant ( Item item , ResourceLocation [ ] location ) {
modelVariantsForRegistering . put ( item , location ) ;
}
2015-11-13 18:56:15 +01:00
private static void registerRenderer ( Class < ? extends TileEntity > tileClass , RenderTileEntity tileRender , int renderID ) {
ClientRegistry . bindTileEntitySpecialRenderer ( tileClass , tileRender ) ;
2016-01-07 23:42:42 +01:00
//TODO Fix inventory rendering
//RenderingRegistry.registerBlockHandler(new RenderInventory(tileRender, renderID));
2015-11-13 18:56:15 +01:00
}
2014-12-03 21:55:53 +01:00
}