mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 21:04:27 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f67c3328a | ||
|
|
db751c462c | ||
|
|
7e06be509d |
No files matched your search
@@ -13,10 +13,20 @@ import kamkeel.npcs.util.ByteBufUtils;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
|
import noppes.npcs.LogWriter;
|
||||||
import noppes.npcs.NoppesUtilServer;
|
import noppes.npcs.NoppesUtilServer;
|
||||||
|
import noppes.npcs.blocks.tiles.ITilePermission;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience packet for saving extra data about Tile Entities. <br>
|
||||||
|
* <br>
|
||||||
|
* <b>Any tile entity that uses this packet should implement {@link ITilePermission}</b> <br>
|
||||||
|
* Not implementing results in the packet treated as malformed and rejected.
|
||||||
|
*/
|
||||||
public final class TileEntitySavePacket extends AbstractPacket {
|
public final class TileEntitySavePacket extends AbstractPacket {
|
||||||
public static final String packetName = "Request|TileEntitySave";
|
public static final String packetName = "Request|TileEntitySave";
|
||||||
|
|
||||||
@@ -50,9 +60,40 @@ public final class TileEntitySavePacket extends AbstractPacket {
|
|||||||
if (!(player instanceof EntityPlayerMP))
|
if (!(player instanceof EntityPlayerMP))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
NBTTagCompound incomingCompound = ByteBufUtils.readNBT(in);
|
||||||
|
|
||||||
|
if (!isCorrectPermission(incomingCompound, player))
|
||||||
|
return;
|
||||||
|
|
||||||
if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK))
|
if (!PacketUtil.verifyItemPacket(packetName, player, EnumItemPacketType.WAND, EnumItemPacketType.BLOCK))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NoppesUtilServer.saveTileEntity((EntityPlayerMP) player, ByteBufUtils.readNBT(in));
|
NoppesUtilServer.saveTileEntity((EntityPlayerMP) player, incomingCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isCorrectPermission(NBTTagCompound incomingCompound, EntityPlayer player) {
|
||||||
|
int x = incomingCompound.getInteger("x");
|
||||||
|
int y = incomingCompound.getInteger("y");
|
||||||
|
int z = incomingCompound.getInteger("z");
|
||||||
|
String id = incomingCompound.getString("id");
|
||||||
|
|
||||||
|
TileEntity tile = player.worldObj.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (tile == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!ITilePermission.doesIDMatch(tile.getClass(), id))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
boolean validatesPacket = tile instanceof ITilePermission;
|
||||||
|
if (!validatesPacket) {
|
||||||
|
LogWriter.error(String.format("%s tried to use TileEntitySavePacket on %s -- should this class implement ITileValidityChecker??", player.getCommandSenderName(), tile));
|
||||||
|
return false; // Assume packet is not meant for this entity from the get-go as there is no checking process.
|
||||||
|
}
|
||||||
|
|
||||||
|
ITilePermission validityChecker = (ITilePermission) tile;
|
||||||
|
CustomNpcsPermissions.Permission perm = validityChecker.getPermission();
|
||||||
|
|
||||||
|
return CustomNpcsPermissions.hasPermission(player, perm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package noppes.npcs.blocks.tiles;
|
||||||
|
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
|
|
||||||
|
public interface ITilePermission {
|
||||||
|
|
||||||
|
CustomNpcsPermissions.Permission getPermission();
|
||||||
|
|
||||||
|
static boolean doesIDMatch(Class<? extends TileEntity> tileClass, String givenID) {
|
||||||
|
if (givenID == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Object entry = TileEntity.classToNameMap.get(tileClass);
|
||||||
|
return givenID.equals(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,11 +12,12 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
import noppes.npcs.controllers.data.Availability;
|
import noppes.npcs.controllers.data.Availability;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileBorder extends TileEntity implements IEntitySelector {
|
public class TileBorder extends TileEntity implements IEntitySelector, ITilePermission {
|
||||||
public Availability availability = new Availability();
|
public Availability availability = new Availability();
|
||||||
public AxisAlignedBB boundingbox;
|
public AxisAlignedBB boundingbox;
|
||||||
public int rotation = 0;
|
public int rotation = 0;
|
||||||
@@ -109,4 +110,9 @@ public class TileBorder extends TileEntity implements IEntitySelector {
|
|||||||
public boolean isEntityApplicable(Entity var1) {
|
public boolean isEntityApplicable(Entity var1) {
|
||||||
return var1 instanceof EntityPlayerMP || var1 instanceof EntityEnderPearl;
|
return var1 instanceof EntityPlayerMP || var1 instanceof EntityEnderPearl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomNpcsPermissions.Permission getPermission() {
|
||||||
|
return CustomNpcsPermissions.EDIT_BLOCKS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import noppes.npcs.CustomNpcs;
|
import noppes.npcs.CustomNpcs;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
import noppes.npcs.blocks.BlockNpcRedstone;
|
import noppes.npcs.blocks.BlockNpcRedstone;
|
||||||
import noppes.npcs.controllers.data.Availability;
|
import noppes.npcs.controllers.data.Availability;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileRedstoneBlock extends TileEntity {
|
public class TileRedstoneBlock extends TileEntity implements ITilePermission {
|
||||||
public int onRange = 6;
|
public int onRange = 6;
|
||||||
public int offRange = 10;
|
public int offRange = 10;
|
||||||
|
|
||||||
@@ -138,4 +139,9 @@ public class TileRedstoneBlock extends TileEntity {
|
|||||||
public boolean canUpdate() {
|
public boolean canUpdate() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomNpcsPermissions.Permission getPermission() {
|
||||||
|
return CustomNpcsPermissions.EDIT_REDSTONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
import noppes.npcs.CustomNpcsPermissions;
|
||||||
import noppes.npcs.constants.EnumQuestType;
|
import noppes.npcs.constants.EnumQuestType;
|
||||||
import noppes.npcs.controllers.PartyController;
|
import noppes.npcs.controllers.PartyController;
|
||||||
import noppes.npcs.controllers.data.Party;
|
import noppes.npcs.controllers.data.Party;
|
||||||
@@ -18,7 +19,7 @@ import noppes.npcs.quests.QuestLocation;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileWaypoint extends TileEntity {
|
public class TileWaypoint extends TileEntity implements ITilePermission {
|
||||||
|
|
||||||
public String name = "";
|
public String name = "";
|
||||||
|
|
||||||
@@ -102,4 +103,9 @@ public class TileWaypoint extends TileEntity {
|
|||||||
compound.setString("LocationName", name);
|
compound.setString("LocationName", name);
|
||||||
compound.setInteger("LocationRange", range);
|
compound.setInteger("LocationRange", range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomNpcsPermissions.Permission getPermission() {
|
||||||
|
return CustomNpcsPermissions.EDIT_WAYPOINT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,9 +19,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
|||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.client.event.RenderLivingEvent;
|
import net.minecraftforge.client.event.RenderLivingEvent;
|
||||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
|
||||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||||
import net.minecraftforge.event.world.WorldEvent;
|
|
||||||
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
|
||||||
import noppes.npcs.client.gui.hud.ClientHudManager;
|
import noppes.npcs.client.gui.hud.ClientHudManager;
|
||||||
import noppes.npcs.client.gui.hud.CompassHudComponent;
|
import noppes.npcs.client.gui.hud.CompassHudComponent;
|
||||||
@@ -38,7 +36,6 @@ import noppes.npcs.controllers.data.FramePart;
|
|||||||
import noppes.npcs.controllers.data.MarkData;
|
import noppes.npcs.controllers.data.MarkData;
|
||||||
import noppes.npcs.controllers.data.PlayerData;
|
import noppes.npcs.controllers.data.PlayerData;
|
||||||
import noppes.npcs.entity.EntityNPCInterface;
|
import noppes.npcs.entity.EntityNPCInterface;
|
||||||
import somehussar.gui.guides.GuideController;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -82,12 +79,6 @@ public class ClientEventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void worldEventLoad(WorldEvent.Load event) {
|
|
||||||
GuideController.resetGlint();
|
|
||||||
GuideController.handleWorldJoin();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onItemTooltip(ItemTooltipEvent event) {
|
public void onItemTooltip(ItemTooltipEvent event) {
|
||||||
AuctionTooltipHandler.onItemTooltip(event);
|
AuctionTooltipHandler.onItemTooltip(event);
|
||||||
|
|||||||
@@ -254,13 +254,14 @@ import noppes.npcs.items.ItemNpcTool;
|
|||||||
import noppes.npcs.items.ItemScripted;
|
import noppes.npcs.items.ItemScripted;
|
||||||
import noppes.npcs.scripted.item.ScriptCustomItem;
|
import noppes.npcs.scripted.item.ScriptCustomItem;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
import tconstruct.client.tabs.*;
|
import tconstruct.client.tabs.InventoryTabCustomNpc;
|
||||||
|
import tconstruct.client.tabs.InventoryTabVanilla;
|
||||||
|
import tconstruct.client.tabs.TabRegistry;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
@@ -385,34 +386,14 @@ public class ClientProxy extends CommonProxy {
|
|||||||
MinecraftForge.EVENT_BUS.register(new LightningHandler());
|
MinecraftForge.EVENT_BUS.register(new LightningHandler());
|
||||||
|
|
||||||
if (ConfigClient.InventoryGuiEnabled) {
|
if (ConfigClient.InventoryGuiEnabled) {
|
||||||
setupTabs();
|
MinecraftForge.EVENT_BUS.register(new TabRegistry());
|
||||||
|
if (TabRegistry.getTabList().isEmpty()) {
|
||||||
|
TabRegistry.registerTab(new InventoryTabVanilla());
|
||||||
|
}
|
||||||
|
TabRegistry.registerTab(new InventoryTabCustomNpc());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTabs() {
|
|
||||||
MinecraftForge.EVENT_BUS.register(new TabRegistry());
|
|
||||||
|
|
||||||
ensureInventoryTabIsFirst();
|
|
||||||
|
|
||||||
TabRegistry.getTabList().add(1, new InventoryTabGuides());
|
|
||||||
TabRegistry.registerTab(new InventoryTabCustomNpc());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureInventoryTabIsFirst() {
|
|
||||||
List<AbstractTab> tabList = TabRegistry.getTabList();
|
|
||||||
|
|
||||||
// Find the first inventory tab or create one.
|
|
||||||
InventoryTabVanilla vanillaTab = tabList.stream()
|
|
||||||
.filter(InventoryTabVanilla.class::isInstance)
|
|
||||||
.map(InventoryTabVanilla.class::cast)
|
|
||||||
.findFirst()
|
|
||||||
.orElseGet(InventoryTabVanilla::new);
|
|
||||||
|
|
||||||
// Move the inventory tab to be the FIRST in the list no matter what.
|
|
||||||
tabList.remove(vanillaTab);
|
|
||||||
tabList.add(0, vanillaTab);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FakePlayer getCommandPlayer(IWorld world) {
|
public FakePlayer getCommandPlayer(IWorld world) {
|
||||||
return (FakePlayer) (new EntityCustomNpc(world.getMCWorld())).getFakePlayer();
|
return (FakePlayer) (new EntityCustomNpc(world.getMCWorld())).getFakePlayer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package somehussar.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||||
|
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||||
|
import somehussar.gui.annotationHandling.GuiFieldHandler;
|
||||||
|
import somehussar.gui.annotationHandling.field.EditableField;
|
||||||
|
|
||||||
|
public class AnnotatedGui<T> extends SubGuiInterface {
|
||||||
|
private final GuiFieldHandler.ClassMetadata metadata;
|
||||||
|
|
||||||
|
public AnnotatedGui(T object, String[] groups, GuiScreen parent) {
|
||||||
|
this(object, groups, parent, 256, 216);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnnotatedGui(T object, String[] groups, GuiScreen parent, int xSize, int ySize) {
|
||||||
|
if (object != null)
|
||||||
|
metadata = GuiFieldHandler.getMetadata(object.getClass());
|
||||||
|
else
|
||||||
|
metadata = null;
|
||||||
|
setBackground("menubg.png");
|
||||||
|
this.xSize = xSize;
|
||||||
|
this.ySize = ySize;
|
||||||
|
closeOnEsc = true;
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initGui() {
|
||||||
|
super.initGui();
|
||||||
|
if (metadata == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (EditableField field : metadata.getParent().getDeclaredFields()) {
|
||||||
|
addLabel(new GuiNpcLabel(i++, field.getName(), guiLeft + 8, guiTop + i * 15 + 5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package somehussar.gui;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||||
|
import somehussar.gui.annotationHandling.field.EditableField;
|
||||||
|
|
||||||
|
public class ImmediateTextField extends GuiNpcTextField {
|
||||||
|
private final EditableField editableField;
|
||||||
|
//
|
||||||
|
// private final GuiNpcTextField encapsulatedField;
|
||||||
|
|
||||||
|
public ImmediateTextField(int id, EditableField field, int xPos, int yPos) {
|
||||||
|
this(id, field, Minecraft.getMinecraft().fontRenderer, xPos, yPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImmediateTextField(int id, EditableField field, FontRenderer fontRenderer, int xPos, int yPos) {
|
||||||
|
super(id, null, fontRenderer, xPos, yPos, 0, 0, null);
|
||||||
|
|
||||||
|
this.editableField = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawTextBox(int mousX, int mousY) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(int xPos, int yPos, int k) {
|
||||||
|
xPos -= this.xPosition;
|
||||||
|
yPos -= this.yPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package somehussar.gui.annotationHandling;
|
||||||
|
|
||||||
|
public interface FieldConstraint {
|
||||||
|
void validate(Object value);
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package somehussar.gui.annotationHandling;
|
||||||
|
|
||||||
|
public final class FieldConstraints {
|
||||||
|
|
||||||
|
private static final FieldConstraints EMPTY =
|
||||||
|
new FieldConstraints(new FieldConstraint[0]);
|
||||||
|
|
||||||
|
private final FieldConstraint[] constraints;
|
||||||
|
|
||||||
|
public FieldConstraints(FieldConstraint[] constraints) {
|
||||||
|
this.constraints = constraints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FieldConstraints empty() {
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(Object value) {
|
||||||
|
for (FieldConstraint c : constraints) {
|
||||||
|
c.validate(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return constraints.length == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package somehussar.gui.annotationHandling;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface GuiEditable {
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@interface Field {
|
||||||
|
String value();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display order
|
||||||
|
* Higher value = higher priority.
|
||||||
|
*/
|
||||||
|
int order() default 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@interface Group {
|
||||||
|
String value();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@interface Size {
|
||||||
|
int labelWidth() default 60;
|
||||||
|
|
||||||
|
int fieldWidth() default 50;
|
||||||
|
|
||||||
|
GuiEditable.Size DEFAULT_SIZE = new GuiEditable.Size() {
|
||||||
|
@Override
|
||||||
|
public int labelWidth() {
|
||||||
|
return 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int fieldWidth() {
|
||||||
|
return 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends Annotation> annotationType() {
|
||||||
|
return GuiEditable.Size.class;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
package somehussar.gui.annotationHandling;
|
||||||
|
|
||||||
|
import somehussar.gui.annotationHandling.constraints.ConstraintFactory;
|
||||||
|
import somehussar.gui.annotationHandling.constraints.NumericConstraint;
|
||||||
|
import somehussar.gui.annotationHandling.constraints.NumericConstraintFactory;
|
||||||
|
import somehussar.gui.annotationHandling.field.EditableField;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public final class GuiFieldHandler {
|
||||||
|
|
||||||
|
private static final Map<Class<?>, ClassMetadata> CACHE = new HashMap<>();
|
||||||
|
private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
|
||||||
|
|
||||||
|
public static final Map<Class<? extends Annotation>, ConstraintFactory<?>> registry = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
registry.put(NumericConstraint.class, new NumericConstraintFactory());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private GuiFieldHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ClassMetadata getMetadata(Class<?> type) {
|
||||||
|
return CACHE.computeIfAbsent(type, GuiFieldHandler::scanClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"RawUseOfParameterized"})
|
||||||
|
private static ClassMetadata scanClass(Class<?> type) {
|
||||||
|
if (!type.isAnnotationPresent(GuiEditable.class)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClassMetadata parent = null;
|
||||||
|
|
||||||
|
Class<?> superCls = type.getSuperclass();
|
||||||
|
if (superCls != null && superCls != Object.class) {
|
||||||
|
parent = getMetadata(superCls);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<EditableField> list = new ArrayList<>();
|
||||||
|
for (Field field : type.getDeclaredFields()) {
|
||||||
|
EditableField editableField = createEditableField(field);
|
||||||
|
|
||||||
|
if (editableField != null) {
|
||||||
|
list.add(editableField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ClassMetadata(
|
||||||
|
type,
|
||||||
|
list.toArray(list.toArray(new EditableField[0])),
|
||||||
|
parent
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"RawUseOfParameterized", "unchecked"})
|
||||||
|
private static EditableField createEditableField(Field field) {
|
||||||
|
try {
|
||||||
|
GuiEditable.Field fieldConfig = field.getAnnotation(GuiEditable.Field.class);
|
||||||
|
if (fieldConfig == null) return null;
|
||||||
|
if (Modifier.isFinal(field.getModifiers())) return null;
|
||||||
|
|
||||||
|
GuiEditable.Size size = field.getAnnotation(GuiEditable.Size.class);
|
||||||
|
if (size == null) size = GuiEditable.Size.DEFAULT_SIZE;
|
||||||
|
;
|
||||||
|
|
||||||
|
field.setAccessible(true);
|
||||||
|
EditableField.Builder builder = new EditableField.Builder()
|
||||||
|
.name(fieldConfig.value())
|
||||||
|
.type(field.getType())
|
||||||
|
.getter(LOOKUP.unreflectGetter(field))
|
||||||
|
.setter(LOOKUP.unreflectSetter(field))
|
||||||
|
.constraints(buildConstraints(field))
|
||||||
|
.order(fieldConfig.order())
|
||||||
|
.size(size);
|
||||||
|
|
||||||
|
|
||||||
|
GuiEditable.Group group = field.getAnnotation(GuiEditable.Group.class);
|
||||||
|
if (group != null)
|
||||||
|
builder.group(group.value());
|
||||||
|
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Failed to bind field: " + field, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"RawUseOfParameterized", "unchecked"})
|
||||||
|
private static FieldConstraints buildConstraints(Field field) {
|
||||||
|
List<FieldConstraint> list = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Annotation ann : field.getAnnotations()) {
|
||||||
|
ConstraintFactory factory = registry.get(ann.annotationType());
|
||||||
|
if (factory != null) {
|
||||||
|
FieldConstraint c = factory.create(field, ann);
|
||||||
|
list.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (list.isEmpty()) return FieldConstraints.empty();
|
||||||
|
return new FieldConstraints(list.toArray(new FieldConstraint[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings({"RawUseOfParameterized"})
|
||||||
|
public static final class ClassMetadata {
|
||||||
|
final Class<?> type;
|
||||||
|
final EditableField[] fields; // only declared fields
|
||||||
|
final ClassMetadata parent; // superclass metadata (nullable)
|
||||||
|
|
||||||
|
ClassMetadata(Class<?> type, EditableField[] fields, ClassMetadata parent) {
|
||||||
|
this.type = type;
|
||||||
|
this.fields = fields;
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassMetadata getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EditableField[] getDeclaredFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<?> getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package somehussar.gui.annotationHandling.constraints;
|
||||||
|
|
||||||
|
import somehussar.gui.annotationHandling.FieldConstraint;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public interface ConstraintFactory<A extends Annotation> {
|
||||||
|
FieldConstraint create(Field field, A annotation);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package somehussar.gui.annotationHandling.constraints;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
public @interface NumericConstraint {
|
||||||
|
double min() default Double.NEGATIVE_INFINITY;
|
||||||
|
|
||||||
|
double max() default Double.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package somehussar.gui.annotationHandling.constraints;
|
||||||
|
|
||||||
|
import somehussar.gui.annotationHandling.FieldConstraint;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class NumericConstraintFactory implements ConstraintFactory<NumericConstraint> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FieldConstraint create(Field field, NumericConstraint ann) {
|
||||||
|
return new NumericRangeConstraint(ann.min(), ann.max());
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package somehussar.gui.annotationHandling.constraints;
|
||||||
|
|
||||||
|
import somehussar.gui.annotationHandling.FieldConstraint;
|
||||||
|
|
||||||
|
public final class NumericRangeConstraint implements FieldConstraint {
|
||||||
|
|
||||||
|
private final double min;
|
||||||
|
private final double max;
|
||||||
|
|
||||||
|
public NumericRangeConstraint(double min, double max) {
|
||||||
|
this.min = min;
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Object value) {
|
||||||
|
if (!(value instanceof Number)) {
|
||||||
|
throw new ConstraintViolationException("Expected number, got " + value);
|
||||||
|
}
|
||||||
|
|
||||||
|
double v = ((Number) value).doubleValue();
|
||||||
|
if (v < min || v > max) {
|
||||||
|
throw new ConstraintViolationException(
|
||||||
|
"Value " + v + " must be between " + min + " and " + max
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class ConstraintViolationException extends RuntimeException {
|
||||||
|
public ConstraintViolationException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package somehussar.gui.annotationHandling.field;
|
||||||
|
|
||||||
|
import somehussar.gui.annotationHandling.FieldConstraints;
|
||||||
|
import somehussar.gui.annotationHandling.GuiEditable;
|
||||||
|
|
||||||
|
import java.lang.invoke.MethodHandle;
|
||||||
|
|
||||||
|
public final class EditableField<T> {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final Class<T> type;
|
||||||
|
private final MethodHandle getter;
|
||||||
|
private final MethodHandle setter;
|
||||||
|
private final FieldConstraints constraints;
|
||||||
|
private final int order;
|
||||||
|
private final String group;
|
||||||
|
private final GuiEditable.Size size;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<?> getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked"})
|
||||||
|
public T read(T instance) {
|
||||||
|
try {
|
||||||
|
return (T) getter.invoke(instance);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new RuntimeException("Failed to read field " + name, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(T instance, T value) {
|
||||||
|
constraints.validate(value);
|
||||||
|
try {
|
||||||
|
setter.invoke(instance, value);
|
||||||
|
} catch (Throwable t) {
|
||||||
|
throw new RuntimeException("Failed to write field " + name, t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldConstraints getConstraints() {
|
||||||
|
return this.constraints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrder() {
|
||||||
|
return this.order;
|
||||||
|
}
|
||||||
|
|
||||||
|
EditableField(Builder<T> b) {
|
||||||
|
this.name = b.name;
|
||||||
|
this.type = b.type;
|
||||||
|
this.getter = b.getter;
|
||||||
|
this.setter = b.setter;
|
||||||
|
this.constraints = b.constraints;
|
||||||
|
this.order = b.order;
|
||||||
|
this.group = b.group;
|
||||||
|
this.size = b.size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder<T> {
|
||||||
|
private String name;
|
||||||
|
private Class<T> type;
|
||||||
|
private MethodHandle getter;
|
||||||
|
private MethodHandle setter;
|
||||||
|
private FieldConstraints constraints;
|
||||||
|
private int order;
|
||||||
|
private String group = null;
|
||||||
|
private GuiEditable.Size size;
|
||||||
|
|
||||||
|
public Builder<T> name(String v) {
|
||||||
|
this.name = v;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> type(Class<T> v) {
|
||||||
|
this.type = v;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> getter(MethodHandle v) {
|
||||||
|
this.getter = v;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> setter(MethodHandle v) {
|
||||||
|
this.setter = v;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> constraints(FieldConstraints v) {
|
||||||
|
this.constraints = v;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> order(int order) {
|
||||||
|
this.order = order;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> group(String value) {
|
||||||
|
this.group = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder<T> size(GuiEditable.Size size) {
|
||||||
|
this.size = size;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EditableField<T> build() {
|
||||||
|
return new EditableField<>(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package somehussar.gui.guides;
|
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.achievement.GuiAchievement;
|
|
||||||
import net.minecraft.stats.AchievementList;
|
|
||||||
|
|
||||||
// TODO: THIS IS JUST THE CLIENT SIDE CONTROLLER
|
|
||||||
// NEED SERVER SIDE
|
|
||||||
public class GuideController {
|
|
||||||
private static boolean glint = true;
|
|
||||||
private static boolean isGuideLoaded = true;
|
|
||||||
|
|
||||||
public static boolean isGuideLoaded() {
|
|
||||||
return isGuideLoaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setGuideLoaded(boolean isGuideLoaded) {
|
|
||||||
GuideController.isGuideLoaded = isGuideLoaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean glint() {
|
|
||||||
return glint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void handleWorldJoin() {
|
|
||||||
if (glint()){
|
|
||||||
GuiAchievement achievementGui = Minecraft.getMinecraft().guiAchievement;
|
|
||||||
achievementGui.func_146255_b(AchievementList.openInventory);
|
|
||||||
achievementGui.field_146265_j = "Check out guides in your inventory!";
|
|
||||||
achievementGui.field_146268_i = "CNPC Guides!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void disableGlint() {
|
|
||||||
glint = false;
|
|
||||||
final long time = Minecraft.getSystemTime();
|
|
||||||
GuiAchievement achievementGui = Minecraft.getMinecraft().guiAchievement;
|
|
||||||
achievementGui.field_146263_l = (achievementGui.field_146263_l <= time - 3000 && achievementGui.field_146262_n ? time : Minecraft.getSystemTime() - (long) (3000.0D * 0.5D));
|
|
||||||
achievementGui.field_146262_n = false;
|
|
||||||
achievementGui.field_146265_j = "Guides explored!";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void resetGlint() {
|
|
||||||
glint = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
package tconstruct.client.tabs;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
|
||||||
import net.minecraft.client.gui.achievement.GuiAchievement;
|
|
||||||
import net.minecraft.client.gui.inventory.GuiInventory;
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
|
||||||
import net.minecraft.stats.Achievement;
|
|
||||||
import net.minecraft.stats.AchievementList;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
import org.lwjgl.opengl.GL12;
|
|
||||||
import somehussar.gui.guides.GuideController;
|
|
||||||
|
|
||||||
import static tconstruct.client.tabs.TabRegistry.getPotionOffset;
|
|
||||||
|
|
||||||
public class InventoryTabGuides extends AbstractTab {
|
|
||||||
|
|
||||||
// TODO: Replace with a proper texture.
|
|
||||||
private static final ResourceLocation HELP_TEXTURE = new ResourceLocation("customnpcs", "textures/marks/question.png");
|
|
||||||
public InventoryTabGuides() {
|
|
||||||
super(0, 0, 0, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTabClicked() {
|
|
||||||
int xSize = 176;
|
|
||||||
int ySize = 166;
|
|
||||||
GuiScreen gui = Minecraft.getMinecraft().currentScreen;
|
|
||||||
|
|
||||||
GuideController.disableGlint();
|
|
||||||
if (!(gui instanceof GuiInventory))
|
|
||||||
return;
|
|
||||||
|
|
||||||
int guiLeft = (gui.width - xSize) / 2;
|
|
||||||
int guiTop = (gui.height - ySize) / 2;
|
|
||||||
guiLeft += getPotionOffset();
|
|
||||||
TabRegistry.updateTabValues(guiLeft, guiTop, InventoryTabGuides.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldAddToList() {
|
|
||||||
return GuideController.isGuideLoaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
|
||||||
if (this.visible) {
|
|
||||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
||||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
|
||||||
GL11.glDepthMask(true);
|
|
||||||
this.zLevel = 100.0F;
|
|
||||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
int yTexPos = this.enabled ? 3 : 32;
|
|
||||||
int ySize = this.enabled ? 25 : 32;
|
|
||||||
int xOffset = this.id == 2 ? 0 : 1;
|
|
||||||
int yPos = this.yPosition + (this.enabled ? 3 : 0);
|
|
||||||
mc.renderEngine.bindTexture(super.texture);
|
|
||||||
this.drawTexturedModalRect(this.xPosition, yPos, xOffset * 28,
|
|
||||||
yTexPos, 28, ySize);
|
|
||||||
|
|
||||||
this.zLevel = 100.0f;
|
|
||||||
mc.renderEngine.bindTexture(HELP_TEXTURE);
|
|
||||||
|
|
||||||
RenderHelper.enableGUIStandardItemLighting();
|
|
||||||
this.zLevel = 100.0F;
|
|
||||||
this.itemRenderer.zLevel = 100.0F;
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
drawTextured(this.xPosition + 6, this.yPosition + 8, 0, 0, 16, 16, 16, 16);
|
|
||||||
|
|
||||||
if (GuideController.glint()) {
|
|
||||||
GL11.glDepthFunc(GL11.GL_EQUAL);
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDepthMask(false);
|
|
||||||
mc.renderEngine.bindTexture(RenderItem.RES_ITEM_GLINT);
|
|
||||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
|
|
||||||
this.renderGlint(this.xPosition, yPos, 28, ySize);
|
|
||||||
GL11.glDepthMask(true);
|
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
|
||||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
|
||||||
}
|
|
||||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
|
||||||
this.zLevel = 0.0F;
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderGlint(int x, int y, int width, int height) {
|
|
||||||
OpenGlHelper.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE, 0, 0);
|
|
||||||
|
|
||||||
final float GLINT_TEX_SCALE = 0.00390625F; // 1 / 256
|
|
||||||
long now = Minecraft.getSystemTime();
|
|
||||||
double z = this.zLevel;
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
|
|
||||||
for (int pass = 0; pass < 2; ++pass) {
|
|
||||||
long cycleLengthMs = 3000 + pass * 1873;
|
|
||||||
float scrollU = (now % cycleLengthMs) / (float) cycleLengthMs * 256.0F;
|
|
||||||
float skew = (pass == 1) ? -1.0F : 4.0F;
|
|
||||||
|
|
||||||
float uLeft = scrollU * GLINT_TEX_SCALE;
|
|
||||||
float uRight = (scrollU + width) * GLINT_TEX_SCALE;
|
|
||||||
float uBottomSkew = (scrollU + height * skew) * GLINT_TEX_SCALE;
|
|
||||||
float uBottomRightSkew = (scrollU + width + height * skew) * GLINT_TEX_SCALE;
|
|
||||||
float vTop = 0.0F;
|
|
||||||
float vBottom = height * GLINT_TEX_SCALE;
|
|
||||||
|
|
||||||
tessellator.addVertexWithUV(x, y + height, z, uBottomSkew, vBottom);
|
|
||||||
tessellator.addVertexWithUV(x + width, y + height, z, uBottomRightSkew, vBottom);
|
|
||||||
tessellator.addVertexWithUV(x + width, y, z, uRight, vTop);
|
|
||||||
tessellator.addVertexWithUV(x, y, z, uLeft, vTop);
|
|
||||||
}
|
|
||||||
|
|
||||||
tessellator.draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawTextured(int x, int y, float u, float v, int width, int height, float textureWidth, float textureHeight)
|
|
||||||
{
|
|
||||||
float f4 = 1.0F / textureWidth;
|
|
||||||
float f5 = 1.0F / textureHeight;
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
tessellator.addVertexWithUV((double)x, (double)(y + height), this.zLevel, (double)(u * f4), (double)((v + (float)height) * f5));
|
|
||||||
tessellator.addVertexWithUV((double)(x + width), (double)(y + height), this.zLevel, (double)((u + (float)width) * f4), (double)((v + (float)height) * f5));
|
|
||||||
tessellator.addVertexWithUV((double)(x + width), (double)y, this.zLevel, (double)((u + (float)width) * f4), (double)(v * f5));
|
|
||||||
tessellator.addVertexWithUV((double)x, (double)y, this.zLevel, (double)(u * f4), (double)(v * f5));
|
|
||||||
tessellator.draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,11 +26,7 @@ public net.minecraft.client.Minecraft field_147126_aw # mcMusicTicker
|
|||||||
public net.minecraft.client.audio.MusicTicker field_147676_d # timeUntilNextMusic
|
public net.minecraft.client.audio.MusicTicker field_147676_d # timeUntilNextMusic
|
||||||
#GuiScreen
|
#GuiScreen
|
||||||
public net.minecraft.client.gui.GuiScreen field_146290_a # selectedButton
|
public net.minecraft.client.gui.GuiScreen field_146290_a # selectedButton
|
||||||
# ItemRenderer
|
|
||||||
public net.minecraft.client.renderer.entity.RenderItem field_110798_h # RES_ITEM_GLINT
|
|
||||||
|
|
||||||
public net.minecraft.client.gui.achievement.GuiAchievement field_146268_i # popupTitle
|
|
||||||
public net.minecraft.client.gui.achievement.GuiAchievement field_146265_j # description
|
# TileEntity
|
||||||
public net.minecraft.client.gui.achievement.GuiAchievement field_146263_l # startTime
|
public net.minecraft.tileentity.TileEntity field_145853_j
|
||||||
public net.minecraft.client.gui.achievement.GuiAchievement field_146266_k # achievementType
|
|
||||||
public net.minecraft.client.gui.achievement.GuiAchievement field_146262_n # showOnlyDescription / persistUntilCompletion. It does the job of both of these ;o
|
|
||||||
Reference in new issue
Block a user