Manual stand now has hud info

This commit is contained in:
Ellpeck 2015-12-22 00:30:08 +01:00
parent 47b79ce8ea
commit 252fbab4ec
2 changed files with 49 additions and 10 deletions

View file

@ -14,22 +14,31 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ellpeck.actuallyadditions.ActuallyAdditions;
import ellpeck.actuallyadditions.blocks.base.BlockContainerBase;
import ellpeck.actuallyadditions.booklet.EntrySet;
import ellpeck.actuallyadditions.booklet.page.BookletPage;
import ellpeck.actuallyadditions.inventory.GuiHandler;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.tile.TileEntityBookletStand;
import ellpeck.actuallyadditions.util.AssetUtil;
import ellpeck.actuallyadditions.util.StringUtil;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class BlockBookletStand extends BlockContainerBase{
public class BlockBookletStand extends BlockContainerBase implements IHudDisplay{
public BlockBookletStand(String name){
super(Material.wood, name);
@ -114,4 +123,31 @@ public class BlockBookletStand extends BlockContainerBase{
public TileEntity createNewTileEntity(World world, int i){
return new TileEntityBookletStand();
}
@Override
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, MovingObjectPosition posHit, Profiler profiler, ScaledResolution resolution){
TileEntity tile = minecraft.theWorld.getTileEntity(posHit.blockX, posHit.blockY, posHit.blockZ);
if(tile instanceof TileEntityBookletStand){
EntrySet set = ((TileEntityBookletStand)tile).assignedEntry;
String strg1;
String strg2;
if(set.entry == null){
strg1 = "No entry saved! Save one if";
strg2 = "you are the player who placed it!";
}
else if(set.chapter == null){
strg1 = set.entry.getLocalizedName();
strg2 = "Page "+set.pageInIndex;
}
else{
strg1 = set.chapter.getLocalizedName();
strg2 = "Page "+set.page.getID();
BookletPage.renderItem(null, set.chapter.displayStack != null ? set.chapter.displayStack : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+10, 1F);
}
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg1, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+8, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRenderer.drawStringWithShadow(EnumChatFormatting.YELLOW+""+EnumChatFormatting.ITALIC+strg2, resolution.getScaledWidth()/2+25, resolution.getScaledHeight()/2+18, StringUtil.DECIMAL_COLOR_WHITE);
}
}
}

View file

@ -21,6 +21,7 @@ import net.minecraft.block.BlockRedstoneTorch;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.profiler.Profiler;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumChatFormatting;
@ -31,12 +32,13 @@ public class HudEvent{
@SubscribeEvent
public void onGameOverlay(RenderGameOverlayEvent.Post event){
if(event.type == RenderGameOverlayEvent.ElementType.ALL){
if(event.type == RenderGameOverlayEvent.ElementType.ALL && Minecraft.getMinecraft().currentScreen == null){
Minecraft minecraft = Minecraft.getMinecraft();
Profiler profiler = minecraft.mcProfiler;
EntityPlayer player = minecraft.thePlayer;
MovingObjectPosition posHit = minecraft.objectMouseOver;
FontRenderer font = minecraft.fontRenderer;
ItemStack stack = player.getCurrentEquippedItem();
profiler.startSection(ModUtil.MOD_ID+"Hud");
@ -46,21 +48,22 @@ public class HudEvent{
if(blockHit instanceof IHudDisplay){
profiler.startSection("BlockHudDisplay");
((IHudDisplay)blockHit).displayHud(minecraft, player, player.getCurrentEquippedItem(), posHit, profiler, event.resolution);
((IHudDisplay)blockHit).displayHud(minecraft, player, stack, posHit, profiler, event.resolution);
profiler.endSection();
}
if(tileHit instanceof IRedstoneToggle){
if(player.getCurrentEquippedItem() != null && Block.getBlockFromItem(player.getCurrentEquippedItem().getItem()) instanceof BlockRedstoneTorch){
profiler.startSection("RedstoneToggleHudDisplay");
profiler.startSection("RedstoneToggleHudDisplay");
String strg = "Redstone Mode: "+EnumChatFormatting.DARK_RED+(((IRedstoneToggle)tileHit).isPulseMode() ? "Pulse" : "Deactivation")+EnumChatFormatting.RESET;
String expl = "Right-Click to toggle!";
font.drawStringWithShadow(strg, event.resolution.getScaledWidth()/2+5, event.resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
String strg = "Redstone Mode: "+EnumChatFormatting.DARK_RED+(((IRedstoneToggle)tileHit).isPulseMode() ? "Pulse" : "Deactivation")+EnumChatFormatting.RESET;
font.drawStringWithShadow(strg, event.resolution.getScaledWidth()/2+5, event.resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){
String expl = EnumChatFormatting.GREEN+"Right-Click to toggle!";
font.drawStringWithShadow(expl, event.resolution.getScaledWidth()/2+5, event.resolution.getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE);
profiler.endSection();
}
profiler.endSection();
}
if(tileHit instanceof IEnergyDisplay){