2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.blocks.render;
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
2017-03-16 12:05:02 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
2016-02-17 23:15:56 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.misc.cloud.ISmileyCloudEasterEgg;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.misc.cloud.SmileyCloudEasterEggs;
|
2017-02-14 18:40:45 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.misc.special.RenderSpecial;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.misc.special.SpecialRenderInit;
|
2016-02-17 21:45:02 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
2016-02-17 23:15:56 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
2020-09-07 20:33:27 +02:00
|
|
|
import net.minecraft.block.BlockState;
|
|
|
|
import net.minecraft.block.HorizontalBlock;
|
2016-02-17 21:45:02 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2020-09-07 20:33:27 +02:00
|
|
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|
|
|
import net.minecraft.client.renderer.Quaternion;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
import java.util.Locale;
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
// todo: migrate to client package
|
|
|
|
public class RenderSmileyCloud extends TileEntityRenderer<TileEntitySmileyCloud> {
|
2015-08-25 17:59:50 +02:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
public RenderSmileyCloud(TileEntityRendererDispatcher rendererDispatcherIn) {
|
|
|
|
super(rendererDispatcherIn);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(TileEntitySmileyCloud theCloud, float partialTicks, MatrixStack matrices, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
|
|
|
matrices.push();
|
|
|
|
// matrices.translate((float) x + 0.5F, (float) y - 0.5F, (float) z + 0.5F);
|
|
|
|
matrices.rotate(new Quaternion(180F, 0.0F, 0.0F, 1.0F));
|
|
|
|
matrices.translate(0.0F, -2F, 0.0F);
|
2015-08-23 23:41:46 +02:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
if (theCloud.name != null && !theCloud.name.isEmpty()) {
|
|
|
|
boolean renderedEaster = false;
|
2017-02-14 18:40:45 +01:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
easterEggs: for (ISmileyCloudEasterEgg cloud : SmileyCloudEasterEggs.CLOUD_STUFF) {
|
|
|
|
for (String triggerName : cloud.getTriggerNames()) {
|
|
|
|
if (triggerName != null && theCloud.name != null) {
|
|
|
|
if (triggerName.equalsIgnoreCase(theCloud.name)) {
|
|
|
|
matrices.push();
|
2017-02-14 18:18:38 +01:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
BlockState state = theCloud.getWorld().getBlockState(theCloud.getPos());
|
|
|
|
if (state.getBlock() == InitBlocks.blockSmileyCloud) {
|
|
|
|
switch (state.get(HorizontalBlock.HORIZONTAL_FACING)) {
|
2019-05-02 09:10:29 +02:00
|
|
|
case NORTH:
|
2020-09-07 20:33:27 +02:00
|
|
|
matrices.rotate(new Quaternion(180, 0, 1, 0));
|
2019-05-02 09:10:29 +02:00
|
|
|
break;
|
|
|
|
case EAST:
|
2020-09-07 20:33:27 +02:00
|
|
|
matrices.rotate(new Quaternion(270, 0, 1, 0));
|
2019-05-02 09:10:29 +02:00
|
|
|
break;
|
|
|
|
case WEST:
|
2020-09-07 20:33:27 +02:00
|
|
|
matrices.rotate(new Quaternion(90, 0, 1, 0));
|
2019-05-02 09:10:29 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2020-09-07 20:33:27 +02:00
|
|
|
}
|
2017-02-14 18:18:38 +01:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
cloud.renderExtra(0.0625F);
|
|
|
|
matrices.pop();
|
2017-02-14 18:40:45 +01:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
renderedEaster = true;
|
|
|
|
break easterEggs;
|
2015-10-03 10:16:18 +02:00
|
|
|
}
|
2015-08-24 20:08:14 +02:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
}
|
2020-09-07 20:33:27 +02:00
|
|
|
}
|
2017-02-14 18:40:45 +01:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
String nameLower = theCloud.name.toLowerCase(Locale.ROOT);
|
|
|
|
if (SpecialRenderInit.SPECIAL_LIST.containsKey(nameLower)) {
|
|
|
|
RenderSpecial render = SpecialRenderInit.SPECIAL_LIST.get(nameLower);
|
|
|
|
if (render != null) {
|
|
|
|
matrices.push();
|
|
|
|
matrices.translate(0F, renderedEaster ? 0.05F : 0.25F, 0F);
|
|
|
|
matrices.rotate(new Quaternion(180F, 1.0F, 0.0F, 1.0F));
|
|
|
|
matrices.scale(0.75F, 0.75F, 0.75F);
|
|
|
|
render.render();
|
|
|
|
matrices.pop();
|
2017-02-14 18:40:45 +01:00
|
|
|
}
|
2015-08-24 20:08:14 +02:00
|
|
|
}
|
2020-09-07 20:33:27 +02:00
|
|
|
}
|
|
|
|
matrices.pop();
|
2015-08-24 17:57:11 +02:00
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
Minecraft mc = Minecraft.getInstance();
|
|
|
|
if (theCloud.name != null && !theCloud.name.isEmpty() && !mc.gameSettings.hideGUI) {
|
|
|
|
BlockPos pos = theCloud.getPos();
|
|
|
|
if (mc.player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) <= 36) {
|
|
|
|
AssetUtil.renderNameTag(theCloud.name, pos.getX() + 0.5F, pos.getY() + 1.5F, pos.getZ() + 0.5F);
|
2015-08-23 23:41:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|