2016-08-03 04:01:47 +02:00
/ *
* This file ( " RenderEmpowerer.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
* http : //ellpeck.de/actaddlicense
* View the source code at https : //github.com/Ellpeck/ActuallyAdditions
*
2017-01-01 16:23:26 +01:00
* © 2015 - 2017 Ellpeck
2016-08-03 04:01:47 +02:00
* /
package de.ellpeck.actuallyadditions.mod.blocks.render ;
2016-12-09 21:36:43 +01:00
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI ;
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe ;
2018-05-10 11:38:58 +02:00
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions ;
2016-08-03 04:01:47 +02:00
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer ;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil ;
2016-11-16 20:31:16 +01:00
import de.ellpeck.actuallyadditions.mod.util.StackUtil ;
2016-08-03 04:01:47 +02:00
import net.minecraft.client.Minecraft ;
import net.minecraft.client.renderer.GlStateManager ;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer ;
import net.minecraft.item.ItemBlock ;
import net.minecraft.item.ItemStack ;
2016-12-09 21:36:43 +01:00
import net.minecraft.util.EnumFacing ;
import net.minecraft.util.math.BlockPos ;
2016-12-18 17:28:29 +01:00
import net.minecraftforge.fml.relauncher.Side ;
import net.minecraftforge.fml.relauncher.SideOnly ;
2016-08-03 04:01:47 +02:00
2016-12-18 17:28:29 +01:00
@SideOnly ( Side . CLIENT )
2019-05-02 09:10:29 +02:00
public class RenderEmpowerer extends TileEntitySpecialRenderer < TileEntityEmpowerer > {
2016-08-03 04:01:47 +02:00
@Override
2019-05-02 09:10:29 +02:00
public void render ( TileEntityEmpowerer tile , double x , double y , double z , float par5 , int par6 , float f ) {
if ( ! ( tile instanceof TileEntityEmpowerer ) ) { return ; }
2016-08-03 04:01:47 +02:00
2019-02-27 19:53:05 +01:00
ItemStack stack = tile . inv . getStackInSlot ( 0 ) ;
2019-05-02 09:10:29 +02:00
if ( StackUtil . isValid ( stack ) ) {
2016-08-03 04:01:47 +02:00
GlStateManager . pushMatrix ( ) ;
2019-05-02 09:10:29 +02:00
GlStateManager . translate ( ( float ) x + 0 . 5F , ( float ) y + 1F , ( float ) z + 0 . 5F ) ;
2016-08-03 04:01:47 +02:00
2019-05-02 09:10:29 +02:00
double boop = Minecraft . getSystemTime ( ) / 800D ;
GlStateManager . translate ( 0D , Math . sin ( boop % ( 2 * Math . PI ) ) * 0 . 065 , 0D ) ;
GlStateManager . rotate ( ( float ) ( boop * 40D % 360 ) , 0 , 1 , 0 ) ;
2016-08-03 04:01:47 +02:00
float scale = stack . getItem ( ) instanceof ItemBlock ? 0 . 85F : 0 . 65F ;
GlStateManager . scale ( scale , scale , scale ) ;
2019-05-02 09:10:29 +02:00
try {
2016-08-03 04:01:47 +02:00
AssetUtil . renderItemInWorld ( stack ) ;
2019-05-02 09:10:29 +02:00
} catch ( Exception e ) {
2018-05-10 11:38:58 +02:00
ActuallyAdditions . LOGGER . error ( " Something went wrong trying to render an item in an empowerer! The item is " + stack . getItem ( ) . getRegistryName ( ) + " : " + stack . getMetadata ( ) + " ! " , e ) ;
2016-08-03 04:01:47 +02:00
}
GlStateManager . popMatrix ( ) ;
}
2016-12-09 21:36:43 +01:00
2019-02-27 19:53:05 +01:00
int index = tile . recipeForRenderIndex ;
2019-05-02 09:10:29 +02:00
if ( index > = 0 & & ActuallyAdditionsAPI . EMPOWERER_RECIPES . size ( ) > index ) {
2016-12-09 21:36:43 +01:00
EmpowererRecipe recipe = ActuallyAdditionsAPI . EMPOWERER_RECIPES . get ( index ) ;
2019-05-02 09:10:29 +02:00
if ( recipe ! = null ) {
for ( int i = 0 ; i < EnumFacing . HORIZONTALS . length ; i + + ) {
2016-12-09 21:36:43 +01:00
EnumFacing facing = EnumFacing . HORIZONTALS [ i ] ;
BlockPos offset = tile . getPos ( ) . offset ( facing , 3 ) ;
2019-05-02 09:10:29 +02:00
AssetUtil . renderLaser ( tile . getPos ( ) . getX ( ) + 0 . 5 , tile . getPos ( ) . getY ( ) + 0 . 5 , tile . getPos ( ) . getZ ( ) + 0 . 5 , offset . getX ( ) + 0 . 5 , offset . getY ( ) + 0 . 95 , offset . getZ ( ) + 0 . 5 , 80 , 1F , 0 . 1F , recipe . getParticleColors ( ) ) ;
2016-12-09 21:36:43 +01:00
}
}
}
2016-08-03 04:01:47 +02:00
}
}