mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
made guide book useful again, interface for diagnostic overlay
This commit is contained in:
parent
2c9a36640d
commit
efad0a8ff2
12
src/main/java/com/hbm/blocks/ILookOverlay.java
Normal file
12
src/main/java/com/hbm/blocks/ILookOverlay.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.hbm.blocks;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
|
||||
public interface ILookOverlay {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void printHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z);
|
||||
}
|
||||
@ -1,10 +1,16 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.interfaces.Untested;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
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;
|
||||
@ -12,8 +18,9 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
|
||||
public class Guide extends Block {
|
||||
public class Guide extends Block implements ILookOverlay {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconTop;
|
||||
@ -142,6 +149,12 @@ public class Guide extends Block {
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
|
||||
|
||||
if(!player.isSneaking())
|
||||
MainRegistry.proxy.openLink("ntm.fandom.com");
|
||||
|
||||
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
|
||||
|
||||
/*if(!player.isSneaking())
|
||||
{
|
||||
|
||||
@ -214,8 +227,21 @@ public class Guide extends Block {
|
||||
} else {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Untested
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
ScaledResolution resolution = event.resolution;
|
||||
|
||||
int pX = resolution.getScaledWidth() / 2 + 8;
|
||||
int pZ = resolution.getScaledHeight() / 2;
|
||||
|
||||
String title = "Click to open wiki";
|
||||
mc.fontRenderer.drawString(title, pX + 1, pZ - 19, 0x006000);
|
||||
mc.fontRenderer.drawString(title, pX, pZ - 20, 0x00FF00);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.hbm.blocks.machine.rbmk;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.handler.MultiblockHandlerXR;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemRBMKLid;
|
||||
@ -13,6 +14,8 @@ import api.hbm.block.IToolable;
|
||||
import api.hbm.block.IToolable.ToolType;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
@ -22,9 +25,10 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class RBMKBase extends BlockDummyable implements IToolable {
|
||||
public abstract class RBMKBase extends BlockDummyable implements IToolable, ILookOverlay {
|
||||
|
||||
public static boolean dropLids = true;
|
||||
public static boolean digamma = false;
|
||||
@ -187,6 +191,12 @@ public abstract class RBMKBase extends BlockDummyable implements IToolable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void printHook(Pre event, World world, int x, int y, int z) {
|
||||
TileEntityRBMKBase.diagnosticPrintHook(event, world, x, y, z);
|
||||
}
|
||||
|
||||
public static int renderIDRods = RenderingRegistry.getNextAvailableRenderId();
|
||||
public static int renderIDPassive = RenderingRegistry.getNextAvailableRenderId();
|
||||
public static int renderIDControl = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@ -28,6 +28,8 @@ import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.net.URI;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
@ -1548,5 +1550,12 @@ public class ClientProxy extends ServerProxy {
|
||||
public EntityPlayer me() {
|
||||
return Minecraft.getMinecraft().thePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openLink(String url) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI(url));
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,8 +6,10 @@ import java.util.Random;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.ILookOverlay;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.blocks.generic.BlockAshes;
|
||||
import com.hbm.blocks.machine.rbmk.RBMKBase;
|
||||
import com.hbm.entity.mob.EntityHunterChopper;
|
||||
import com.hbm.entity.projectile.EntityChopperMine;
|
||||
import com.hbm.extprop.HbmLivingProps;
|
||||
@ -86,6 +88,7 @@ import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
@ -133,7 +136,14 @@ public class ModEventHandlerClient {
|
||||
|
||||
/// DODD DIAG HOOK FOR RBMK
|
||||
if(event.type == ElementType.CROSSHAIRS) {
|
||||
TileEntityRBMKBase.diagnosticPrintHook(event);
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
World world = mc.theWorld;
|
||||
MovingObjectPosition mop = mc.objectMouseOver;
|
||||
ScaledResolution resolution = event.resolution;
|
||||
|
||||
if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK && world.getBlock(mop.blockX, mop.blockY, mop.blockZ) instanceof ILookOverlay) {
|
||||
((ILookOverlay) world.getBlock(mop.blockX, mop.blockY, mop.blockZ)).printHook(event, world, mop.blockX, mop.blockY, mop.blockZ);
|
||||
}
|
||||
}
|
||||
|
||||
/// HANLDE ANIMATION BUSES ///
|
||||
|
||||
@ -39,4 +39,6 @@ public class ServerProxy {
|
||||
public boolean isVanished(Entity e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void openLink(String url) { }
|
||||
}
|
||||
@ -257,63 +257,58 @@ public abstract class TileEntityRBMKBase extends TileEntity implements INBTPacke
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void diagnosticPrintHook(RenderGameOverlayEvent.Pre event) {
|
||||
public static void diagnosticPrintHook(RenderGameOverlayEvent.Pre event, World world, int x, int y, int z) {
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
World world = mc.theWorld;
|
||||
MovingObjectPosition mop = mc.objectMouseOver;
|
||||
ScaledResolution resolution = event.resolution;
|
||||
|
||||
if(mop != null && mop.typeOfHit == mop.typeOfHit.BLOCK && world.getBlock(mop.blockX, mop.blockY, mop.blockZ) instanceof RBMKBase) {
|
||||
|
||||
RBMKBase rbmk = (RBMKBase)world.getBlock(mop.blockX, mop.blockY, mop.blockZ);
|
||||
int[] pos = rbmk.findCore(world, mop.blockX, mop.blockY, mop.blockZ);
|
||||
|
||||
if(pos == null)
|
||||
return;
|
||||
|
||||
TileEntityRBMKBase te = (TileEntityRBMKBase)world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
NBTTagCompound flush = new NBTTagCompound();
|
||||
te.getDiagData(flush);
|
||||
Set<String> keys = flush.func_150296_c();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
int pX = resolution.getScaledWidth() / 2 + 8;
|
||||
int pZ = resolution.getScaledHeight() / 2;
|
||||
|
||||
List<String> exceptions = new ArrayList();
|
||||
exceptions.add("x");
|
||||
exceptions.add("y");
|
||||
exceptions.add("z");
|
||||
exceptions.add("items");
|
||||
exceptions.add("id");
|
||||
|
||||
String title = "Dump of Ordered Data Diagnostic (DODD)";
|
||||
mc.fontRenderer.drawString(title, pX + 1, pZ - 19, 0x006000);
|
||||
mc.fontRenderer.drawString(title, pX, pZ - 20, 0x00FF00);
|
||||
RBMKBase rbmk = (RBMKBase) world.getBlock(x, y, z);
|
||||
int[] pos = rbmk.findCore(world, x, y, z);
|
||||
|
||||
mc.fontRenderer.drawString(I18nUtil.resolveKey(rbmk.getUnlocalizedName() + ".name"), pX + 1, pZ - 9, 0x606000);
|
||||
mc.fontRenderer.drawString(I18nUtil.resolveKey(rbmk.getUnlocalizedName() + ".name"), pX, pZ - 10, 0xffff00);
|
||||
|
||||
String[] ents = new String[keys.size()];
|
||||
keys.toArray(ents);
|
||||
Arrays.sort(ents);
|
||||
|
||||
for(String key : ents) {
|
||||
|
||||
if(exceptions.contains(key))
|
||||
continue;
|
||||
|
||||
mc.fontRenderer.drawString(key + ": " + flush.getTag(key), pX, pZ, 0xFFFFFF);
|
||||
pZ += 10;
|
||||
}
|
||||
if(pos == null)
|
||||
return;
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
TileEntityRBMKBase te = (TileEntityRBMKBase) world.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
NBTTagCompound flush = new NBTTagCompound();
|
||||
te.getDiagData(flush);
|
||||
Set<String> keys = flush.func_150296_c();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(Gui.icons);
|
||||
GL11.glPushMatrix();
|
||||
|
||||
int pX = resolution.getScaledWidth() / 2 + 8;
|
||||
int pZ = resolution.getScaledHeight() / 2;
|
||||
|
||||
List<String> exceptions = new ArrayList();
|
||||
exceptions.add("x");
|
||||
exceptions.add("y");
|
||||
exceptions.add("z");
|
||||
exceptions.add("items");
|
||||
exceptions.add("id");
|
||||
|
||||
String title = "Dump of Ordered Data Diagnostic (DODD)";
|
||||
mc.fontRenderer.drawString(title, pX + 1, pZ - 19, 0x006000);
|
||||
mc.fontRenderer.drawString(title, pX, pZ - 20, 0x00FF00);
|
||||
|
||||
mc.fontRenderer.drawString(I18nUtil.resolveKey(rbmk.getUnlocalizedName() + ".name"), pX + 1, pZ - 9, 0x606000);
|
||||
mc.fontRenderer.drawString(I18nUtil.resolveKey(rbmk.getUnlocalizedName() + ".name"), pX, pZ - 10, 0xffff00);
|
||||
|
||||
String[] ents = new String[keys.size()];
|
||||
keys.toArray(ents);
|
||||
Arrays.sort(ents);
|
||||
|
||||
for(String key : ents) {
|
||||
|
||||
if(exceptions.contains(key))
|
||||
continue;
|
||||
|
||||
mc.fontRenderer.drawString(key + ": " + flush.getTag(key), pX, pZ, 0xFFFFFF);
|
||||
pZ += 10;
|
||||
}
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(Gui.icons);
|
||||
}
|
||||
|
||||
public void onOverheat() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user