2016-06-06 21:27:09 +02:00
/ *
* This file ( " RenderDisplayStand.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-06-06 21:27:09 +02:00
* /
package de.ellpeck.actuallyadditions.mod.blocks.render ;
2021-02-27 21:24:26 +01:00
import com.mojang.blaze3d.matrix.MatrixStack ;
2018-05-10 11:38:58 +02:00
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions ;
2016-06-06 21:27:09 +02:00
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand ;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil ;
2016-11-16 20:31:16 +01:00
import de.ellpeck.actuallyadditions.mod.util.StackUtil ;
2021-02-27 21:24:26 +01:00
import net.minecraft.client.renderer.IRenderTypeBuffer ;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer ;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher ;
2021-02-28 11:35:10 +01:00
import net.minecraft.item.BlockItem ;
2016-06-06 21:27:09 +02:00
import net.minecraft.item.ItemStack ;
2021-02-28 11:35:10 +01:00
import net.minecraft.util.Util ;
import net.minecraft.util.math.vector.Quaternion ;
2022-02-16 02:36:31 +01:00
import net.minecraft.util.math.vector.Vector3f ;
2016-06-06 21:27:09 +02:00
2022-06-24 21:23:43 +02:00
import javax.annotation.Nonnull ;
2021-02-27 21:24:26 +01:00
public class RenderDisplayStand extends TileEntityRenderer < TileEntityDisplayStand > {
public RenderDisplayStand ( TileEntityRendererDispatcher rendererDispatcherIn ) {
super ( rendererDispatcherIn ) ;
}
2016-06-06 21:27:09 +02:00
@Override
2022-06-24 21:23:43 +02:00
public void render ( TileEntityDisplayStand tile , float partialTicks , @Nonnull MatrixStack matrices , @Nonnull IRenderTypeBuffer buffer , int combinedLightIn , int combinedOverlayIn ) {
2021-02-28 11:35:10 +01:00
ItemStack stack = tile . inv . getStackInSlot ( 0 ) ;
2022-06-24 21:23:43 +02:00
if ( stack . isEmpty ( ) ) {
2021-02-26 22:15:48 +01:00
return ;
}
2016-06-06 21:27:09 +02:00
2021-08-22 17:09:06 +02:00
matrices . pushPose ( ) ;
2021-02-28 11:35:10 +01:00
matrices . translate ( 0 . 5F , 1F , 0 . 5F ) ;
2022-02-16 02:36:31 +01:00
float boop = Util . getMillis ( ) / 800F ;
2021-02-28 11:35:10 +01:00
matrices . translate ( 0D , Math . sin ( boop % ( 2 * Math . PI ) ) * 0 . 065 , 0D ) ;
2022-02-16 02:36:31 +01:00
matrices . mulPose ( Vector3f . YP . rotationDegrees ( boop * 40F % 360 . 0F ) ) ;
2021-02-28 11:35:10 +01:00
float scale = stack . getItem ( ) instanceof BlockItem
? 0 . 85F
: 0 . 65F ;
matrices . scale ( scale , scale , scale ) ;
try {
AssetUtil . renderItemInWorld ( stack , combinedLightIn , combinedOverlayIn , matrices , buffer ) ;
} catch ( Exception e ) {
ActuallyAdditions . LOGGER . error ( " Something went wrong trying to render an item in a display stand! The item is " + stack . getItem ( ) . getRegistryName ( ) + " ! " , e ) ;
2016-06-06 21:27:09 +02:00
}
2021-02-27 21:24:26 +01:00
2021-08-22 17:09:06 +02:00
matrices . popPose ( ) ;
2021-02-27 21:24:26 +01:00
}
2016-06-06 21:27:09 +02:00
}