Jump to content

hugo_the_dwarf

Members
  • Posts

    334
  • Joined

  • Last visited

Everything posted by hugo_the_dwarf

  1. I believe that is this? @CapabilityInject(CapAttributeData.class) public static Capability<CapAttributeData> CAPABILITY = null; public static void register() { CapabilityManager.INSTANCE.register(CapAttributeData.class, new StorageHelper(), new DefaultInstanceFactory()); } that's located in the "CapAttribute" class. If you wish to see all the code I have a link in my sig to the repo that I'm updating the code to for now. It's supposed to be public so hopefully it allows access. I use straight forward package names so hopefully easy to navigate through. EDIT: Yeah looks somewhere I have it set up incorrectly. I put some "test" code back in that I used when it was only on the player. Killing things now show that their stats are the players stats. Which is 100% incorrect. Which is strange as when I had only two vars (two test ints) killing a mob would return 0, where my player version (killing added 1 to that var) increased normally and correctly. Leaving mobs to 0 as nothing increased their variable. But now it's all messed up once I add in the roll stats option? EDIT2: Tried to revert the code back, now it seems using the old way is the same issue, updating player attrs, kill something, reads players attrs back from the death event. It should have been all 0's for the bat
  2. Possibly the only thing that bugs me is: final CapAttributeData INSTANCE = new CapAttributeData(); inside the CapAttributeProvider.class so perhaps following someone elses code made me create a singleton?
  3. It's very possible they would be on the same Y However the roll logic is always 0-12 + (height bonus calculated via Y level being under or above the base Depth and Height) then that value is multiplied by the MobLevel (Difficulty) which can be 1 to 25 (clamped) / 4 then the baseBonus is added onto it (so if it's higher level mob it will have something always greater than 0) I added in my code to roll on attachment (so when the provider gives it out) and on the update results is I get alot of "everything is nothing" then a rare "stats rolled" but those stats are applied to everything. I may have broken it that or capabilities are shared with "all" entities (one instance to serve them all) if that's the case I want my IEEP back, at least I could have each entity own it's own unique values EDIT to your Y question I hope I was on the same page, even if they were on the same Y there should still be some randomness to their stats
  4. The packet only sends the stats from the server to a client, which I have limited to only the player (or a player) currently as it's only for when I setup the GUI again so players can view their own stats. Also with some changes this is roughly my output It generates and sets the values for just one mob in this case a chicken, then all of a sudden everyone has the same values (recorded by their death event)
  5. ah so you mean my current attachement: @SubscribeEvent public void onAddCapabilities(AttachCapabilitiesEvent.Entity e) { if (e.getEntity() instanceof EntityLivingBase) { EntityLivingBase ent = (EntityLivingBase)e.getEntity(); if (canHaveAttributes(ent)) { e.addCapability(CapAttributeProvider.KEY, new CapAttributeProvider(ent)); } } } I should include a "entity.hasCapability(mine,null);" I only find it strange that my Console.out().Prints seem to output the exact same value for every mob including the player (on death)
  6. updateAttributes is also inside the CapAttributeData Class public void updateAttributes(int[] attributes) { int[] pulledAttributes = attributes; for(int index = 0; index < this.attributes.length;index++) { pulledAttributes[index] = pulledAttributes[index] > STAT_MAX_LIMIT ? STAT_MAX_LIMIT : pulledAttributes[index]; pulledAttributes[index] = pulledAttributes[index] < (STAT_MAX_LIMIT * -1) ? (STAT_MAX_LIMIT * -1) : pulledAttributes[index]; } this.attributes = pulledAttributes; dataChanged(); } public void dataChanged() { if (entity != null && !entity.worldObj.isRemote && entity instanceof EntityPlayer) { PacketManager.INSTANCE.sendTo(new CapAttributePacket(attributes), (EntityPlayerMP) entity); } } also included the dataChanged method the updated method is in "EventAddCapability" class for now as i'm just trying to get something working: @SubscribeEvent public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) { if(!event.getEntityLiving().worldObj.isRemote && !(event.getEntityLiving() instanceof EntityPlayer)) { if (event.getEntityLiving().hasCapability(CapAttribute.CAPABILITY, null)) { if (event.getEntityLiving().getCapability(CapAttribute.CAPABILITY, null).attributes[0] == 0) event.getEntityLiving().getCapability(CapAttribute.CAPABILITY, null).rollStats(event.getEntityLiving()); } } }
  7. This Method is inside the CapAttributeData class public void rollStats(EntityLivingBase entity) { int[] attrs = new int[attributes.length]; int baseDepth = 62; int baseHeight = 100; int yHeight = (int) entity.posY; int heightBonus = yHeight < 62 ? yHeight - baseDepth : yHeight > baseHeight ? yHeight - baseHeight : 0; heightBonus = heightBonus < 0 ? heightBonus * -1 : heightBonus; int mobDifficulty = MathHelper.clamp_int(yHeight/10, 1, 25); int baseBonus = mobDifficulty * (mobDifficulty / 5); Console.out().println("Mob Stat Rolling: " +entity.getName()+ " Mob Depth: " + yHeight + " Mob Height Bonus: " + heightBonus + " Base Bonus: " + baseBonus); Random rand = new Random(); for (int index = 0; index < attrs.length; index++) { attrs[index] = (int) ((rand.nextInt(12 + heightBonus) * (mobDifficulty / 4))+baseBonus); Console.out().println("Stat "+attributeTags[index]+ ": "+attrs[index] + "-------------"); } Console.out().println("-------------------------------"); updateAttributes(attrs); }
  8. Ok I got a simple system constructed, with a packet from server to player to update their attributes, however Since player attributes are composed of "Item given Bonuses" and "Class Base Values (berserker, wizard,etc)" it works fine as I can just design a "stats changed, update player" however. Mobs get their stats when they are created, and this is causing me some grief. As I base their standard difficulty on: Their current constructed Y value (if under sea level deeper means stronger, if higher than 100(currently) higher means stronger) Using their given "depth" bonus some rand int bounds are given a range, and a baseBonus is given by how deep/high they are. I have that math down right, but Mobs don't really need to send their stats to the clients (can remain server-side as no one can look at their stats) I tried adding the rolling of stats in the Capabilities Data Constructor (used by the Provider) and reading up someone had this same issue as the attachment of capabilities is done before the entity is fully constructed (just was I gathered correct if wrong) So I tried the EntityEvent.EntityConstructing and checked some values before calling the rollStats, not much luck as I'm guessing events go: EntityConstructing AttachCapability so I don't believe I can use that, so I tried the LivingEvent.LivingUpdateEvent, checking to see if the entity is not a player, and that a certain value is at the default 0, rollStats. Issue now is that all mobs get the same stats, it's like a one time deal. EDIT I have upaded the Repo/Source https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
  9. Depending on what you mean by "the itemstack needs to tick all the time" is it something like: Item auto repairs? Item Generates some sort of value overtime? I believe there is a "PlayerOpenContainerEvent" if you're ok with designing your system of where every player tick the item gets updated, but have a "last updated" value on the itemstack, you can then use this during "update calls" including when the container is opened (event) and do some math differences to make it "appear" that it was updating the whole time, even tho it just calculated from "last update" and "current time" If they need to be constantly ticking, you could add in the tooltip that it must always be on a player?
  10. Awesome that is greatly more helpful (not that the other suggestions were not helpful, I was just struggling to grasp the concepts) I just need to implement the packet usage to update the remote of any changes from the server. And figure out how to get it to work correctly with the clone event (as some stats like what class, profession, etc. should persist through death)
  11. Ah very nice, Thought I still had to use the FMLCommonHandler for those type of events. But if Jonnyb170 wishes to continue with 1.8.9 he'll have to use the outdated advice.
  12. try using FMLCommonHandler.instance().bus().register(new FMLEventPlayerTick()); to register that event, it's a FML event some more context would be: public static void registerEvents() { FMLCommonHandler.instance().bus().register(new FMLEventPlayerTick()); MinecraftForge.EVENT_BUS.register(new EventEntityConstruction()); //MinecraftForge.EVENT_BUS.register(new EventEntityLivingUpdate()); } the above method is being called in the postInit (in my case) not sure if it would do better being in the preInit but seems to still work. oh the FML event I have there is: @SubscribeEvent public void playerTickEvent(TickEvent.PlayerTickEvent event)
  13. Makes sense, really only players benefit from items with stats, but once i figure out this Capability business I will have to convert that code too. https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src/59a4ef4abd8ff735f885c7378fc7c33097be0e82/htd/rot/?at=master I've made this a public Repo so hopefully it works. I've just run into an issue of trying to look at the Capability in the FMLPlayerTick event just to see if I can pull data from it. So far class wise the project is just capabilities so far, so hopefully if anyone wants to have a look and see what I'm doing wrong should be easy to navigate EDIT: the Storage Classes save isn't complete, because I might rewrite the data and methods in the interface since I more or less copy pasted from the Extended Prop to the DefaultCapabilityAttribute but I feel like I will scrap it and redesign it when my mind isn't on "Lets get a capability working, and understand it for other capabilities"
  14. Thanks Choonster, I tried to follow your code, however you've integrated it with a design pattern of your choosing/making and it made it a bit difficult for me to follow, at least to get the basic idea of how it should flow however your comments of where to register and what events to use is helpful. Thanks Ferrettomato, looking at the Wizardry code I believe is helping me, it's taking me a bit as my extended prop had a great deal of methods and variables so I'm slowly trying to mimic the Wizardry setup, which appears to be the very basic of how to use a capability, it's very helpful. I have a side Question while I'm plugging away at trying to get a test run of my conversion going. For ItemStacks is it better to use a Capability for storing extra data or can we still use the NBT? since my mod is Diablo and other dungeon crawl types heavy, I attach stats to items (min - max dmg, 5 base stat boosts, sockets, etc) currently my old code for ramming that data into itemstacks hasn't yelled at me yet, but I haven't gotten the old code to compile yet (starting over and moving code pieces slowly into a new project) Should I also setup a Capability for ItemStack values or keep using my NBT data code?
  15. Unfortunately I'm not understanding how to get it to work. I'll have to rework my mod completely now, as without being able to store mana, stamina, gold, and other vital attribute stats on players and entities. Without a good reference it's impossible for me to grasp this, from the documentation all it looks like is this just handles storing items (bags, chests, etc) that is not what i'm looking for I just need to store, update, and save custom values that are unique to each player and mob so I can use them during damage and other events.
  16. I have read it, it was actually the first part I looked at, actually it was: https://mcforge.readthedocs.io/en/latest/datastorage/extendedentityproperties/ but thanks to the warning at the top I went to where you had linked. Read it from top to bottom and saw the migration part. However it still is very vague I'm still reading it over, hoping that some of it will sink in. I know with IEEP it was the @SubscribeEvent public void onEntityConstructing(EntityConstructing event) { // Players if ((event.getEntity() instanceof EntityPlayer) && (ExtendPlayer .get((EntityPlayer) event.getEntity()) == null)) { ExtendPlayer.register((EntityPlayer) event.getEntity()); } } but the quoted part confuses me as now I register it somewhere else, but somehow also attach it with a new event?
  17. Hey all, I just got back into modding from a long hiatus. And with a new PC and all that all my old modding setups were wiped, so I figured I'd just bring my mod up to 1.10.2 only to find so many errors. I've cleaned up quite a few but now i'm stuck on my extended props, which I had used very heavily. I've been reading up on capabilities (forge document) not much help on the actual layout and implementation other than some vague "convert this, use this datatype" and anything I find on this forum or in example code is TileEntites or an attempt at an Entity. My IEEPs were mainly for Entities (Max Health bonus, stamina, mana, stats, skills, class, profession, etc.), but I also had a lot of code touching ItemStacks NBTs (weapon level, bonus stats, socketed items, etc) If anyone can explain the process needed: -Create a class of ICapabilityProvider? -Setup Event? or Register capability? -Etc I'd greatly appreciate it or if someone can supply a working example of a Entity and a Itemstack getting capabilities assigned I think I would be able to follow along all those given classes and update my own/created missing, sending packets to update the client(s) is easy enough it doesn't appear packets have changed much from the 1.8 version I was on to 1.10.2 Edit: If needed I could supply my code, however all of my IEEP classes and even the Item classes are rather large due to the amount of custom stats, getters, and setters and helper methods created for complex(not really that complex) calculations.
  18. Events might be your best bet https://dl.dropboxusercontent.com/s/h777x7ugherqs0w/forgeevents.html Preferably the livingUpdateEvent might handle what you need.
  19. Thanks for the Pointers, I will dig into those and if I still have trouble I shall be back. EDIT: Well managed to get it to work, didn't think the line of code would be this long conga-line "Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(new ItemStack(block)).getTexture()" just so I can use the GUIs draw textured rec. Thanks guys.
  20. Hey before IIcon and the like was tossed out [1.7.x] I had my GUI draw the 16x16 texture in my GUI, I upgraded to [1.8] and seems like this is no longer an option to just get the regular texture to render. How can I get the face or flat 2D display image of an Item or a Block. Blocks more preferred, here is my old code. The new code is just using GL to draw flat color squares which is not what I want. [spoiler=GuiButton] package ca.grm.rot.gui;import net.minecraft.client.Minecraft;import net.minecraft.client.gui.FontRenderer;import net.minecraft.client.gui.GuiButton;import net.minecraft.client.renderer.OpenGlHelper;import net.minecraft.client.renderer.texture.TextureManager;import net.minecraft.util.IIcon;import org.lwjgl.opengl.GL11;/*** Just a GuiButton with an extra variable, really wanted this in the normal* button**/public class GuiBaseNodeButton extends GuiButton {public int x, y, z;public IIcon tex;public float brightness = 1.0f;public GuiBaseNodeButton(int par1, int par2, int par3, int par4, int par5, String par6Str) { super(par1, par2, par3, par4, par5, par6Str);}@Overridepublic void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) { if (this.visible) { TextureManager manager = Minecraft.getMinecraft().renderEngine; manager.bindTexture(manager.getResourceLocation(0)); // RENDER ITEMS FontRenderer fontrenderer = p_146112_1_.fontRenderer; GL11.glColor4f(this.brightness, this.brightness, this.brightness, 1.0F); this.field_146123_n = (p_146112_2_ >= this.xPosition) && (p_146112_3_ >= this.yPosition) && (p_146112_2_ < (this.xPosition + this.width)) && (p_146112_3_ < (this.yPosition + this.height)); int k = this.getHoverState(this.field_146123_n); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (this.tex != null) { drawTexturedModelRectFromIcon(this.xPosition, this.yPosition, this.tex, 16, 16); } this.mouseDragged(p_146112_1_, p_146112_2_, p_146112_3_); int l = 14737632; if (this.packedFGColour != 0) { l = this.packedFGColour; } else if (!this.enabled) { l = 10526880; } else if (this.field_146123_n) { l = 16777120; } this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + (this.width / 2), this.yPosition + ((this.height - / 2), l); }}} [spoiler=Gui] package ca.grm.rot.gui;import java.util.ArrayList;import javax.vecmath.Vector3f;import net.minecraft.block.Block;import net.minecraft.client.Minecraft;import net.minecraft.client.gui.GuiButton;import net.minecraft.client.gui.inventory.GuiContainer;import net.minecraft.entity.player.EntityPlayer;import net.minecraft.init.Blocks;import net.minecraft.util.IIcon;import net.minecraft.util.MathHelper;import net.minecraft.util.ResourceLocation;import org.lwjgl.input.Keyboard;import org.lwjgl.opengl.GL11;import ca.grm.rot.Rot;import ca.grm.rot.blocks.RotBlocks;import ca.grm.rot.blocks.TileEntityBaseNode;import ca.grm.rot.comms.BaseNodeRequestPacket;import ca.grm.rot.libs.UtilityBlockLocationType;public class GuiBaseNode extends GuiContainer {public static final ResourceLocation texture = new ResourceLocation( Rot.MODID .toLowerCase(), "textures/gui/largeBase.png");private EntityPlayer player;private TileEntityBaseNode te;private int cw = 16; // control // Widthprivate int ch = 16; // control // Height// Grid Valuesprivate int gridSize = 0;private int gS = 5;private int gridSizeOffset = 0;private int xOffset = 0;private int yOffset1 = 0, yOffset2 = 0;private int zOffset = 0;// Block Placement Valuesprivate int currentBlock = 0;private int currentMeta = 0;private int blockColor = RotBlocks.blockTypeColors[this.currentBlock];// Selection and List Valuesprivate ArrayList locations = new ArrayList<UtilityBlockLocationType>();private Boolean listGotten = false;private int defaultColor = 0x444444;private int selectionMode = 0;private String[] selectionTitle = { "Single", "Rectangle A - B" };private Vector3f[] AB = new Vector3f[2];// Misc.private GuiBaseNodeButton[] coordButtons1;private GuiBaseNodeButton[] coordButtons2;private int INDEX_START = 17;private int indexCounter = this.INDEX_START;private int startLeft = this.cw * 2, startTop = this.ch * 2;public GuiBaseNode(TileEntityBaseNode tileEntity, EntityPlayer player) { super(new ContainerNull()); this.player = player; this.te = tileEntity; this.locations = this.te.locations; this.xSize = 227; this.ySize = 226;}/** Button Clicks **/@Overrideprotected void actionPerformed(GuiButton button) { // Anything below the generated buttons for grid clicking if (button.id < this.indexCounter) { switch (button.id) { case 0 : // Start Building Rot.net.sendToServer(new BaseNodeRequestPacket(2, this.te.xCoord, this.te.yCoord, this.te.zCoord, 0, 0, 0, 0)); break; case 1 : // Send List if (!this.locations.isEmpty()) { UtilityBlockLocationType ublt; for (int l = 0; l < this.locations.size(); l++) { ublt = (UtilityBlockLocationType) this.locations.get(l); Rot.net.sendToServer(new BaseNodeRequestPacket(0, this.te.xCoord, this.te.yCoord, this.te.zCoord, ublt.x, ublt.y, ublt.z, Block .getIdFromBlock(ublt.block))); } } this.locations.clear(); break; case 2 : // -X left/west Rot.net.sendToServer(new BaseNodeRequestPacket(1, this.te.xCoord, this.te.yCoord, this.te.zCoord, 0, 0, 0, 0)); this.locations.clear(); break; case 3 : // +X right/east if (this.currentBlock == 0) { this.currentBlock = RotBlocks.blockTypeObjects.length - 1; } else { this.currentBlock--; } this.blockColor = RotBlocks.blockTypeColors[this.currentBlock]; break; case 4 : // -Z forward/north if (this.currentBlock == (RotBlocks.blockTypeObjects.length - 1)) { this.currentBlock = 0; } else { this.currentBlock++; } this.blockColor = RotBlocks.blockTypeColors[this.currentBlock]; break; case 5 : // +Z backwards/south this.gridSizeOffset++; break; case 6 : // +Y up this.gridSizeOffset--; break; case 7 : // -Y down this.selectionMode = this.selectionMode == 0 ? 1 : 0; if (this.selectionMode == 0) { this.AB = new Vector3f[2]; } break; case 8 : // Clear, clears tileEntity list and this gui's List this.xOffset--; break; case 9 : // < moves block array left this.xOffset++; break; case 10 : // > moves block array right this.zOffset--; break; case 11 : // Increase grid width this.zOffset++; break; case 12 : // Decrease if ((this.yOffset1 + this.te.yCoord) == 255) { break; } else { this.yOffset1++; } break; case 13 : if ((this.yOffset1 + this.te.yCoord) == 0) { break; } else { this.yOffset1--; } break; case 14 : if ((this.yOffset2 + this.te.yCoord) == 255) { break; } else { this.yOffset2++; } break; case 15 : if ((this.yOffset2 + this.te.yCoord) == 0) { break; } else { this.yOffset2--; } break; case 16 : Rot.net.sendToServer(new BaseNodeRequestPacket(3, this.te.xCoord, this.te.yCoord, this.te.zCoord, 0, 0, 0, 0)); break; } } // Start code for generated buttons else { int xB = ((GuiBaseNodeButton) button).x, yB = ((GuiBaseNodeButton) button).y, zB = ((GuiBaseNodeButton) button).z; if (this.selectionMode == 1)// Range Mode { if (this.AB[0] == null) { this.AB[0] = new Vector3f(xB, yB, zB); } else if (this.AB[1] == null) { if (new Vector3f(xB, yB, zB) != this.AB[0]) { this.AB[1] = new Vector3f(xB, yB, zB); } } if ((this.AB[0] != null) && (this.AB[1] != null)) { int xh = (this.AB[0].x > this.AB[1].x ? (int) this.AB[0].x : (int) this.AB[1].x); int xl = (this.AB[0].x < this.AB[1].x ? (int) this.AB[0].x : (int) this.AB[1].x); int yh = (this.AB[0].y > this.AB[1].y ? (int) this.AB[0].y : (int) this.AB[1].y); int yl = (this.AB[0].y < this.AB[1].y ? (int) this.AB[0].y : (int) this.AB[1].y); int zh = (this.AB[0].z > this.AB[1].z ? (int) this.AB[0].z : (int) this.AB[1].z); int zl = (this.AB[0].z < this.AB[1].z ? (int) this.AB[0].z : (int) this.AB[1].z); for (int xs = xh; xs >= xl; xs--) { for (int zs = zh; zs >= zl; zs--) { for (int ys = yh; ys >= yl; ys--) { addLocation(xs + this.te.xCoord, ys + this.te.yCoord, zs + this.te.zCoord); } } } this.AB = new Vector3f[2]; } } else// single select { addLocation(xB + this.te.xCoord, yB + this.te.yCoord, zB + this.te.zCoord); } } updateButtons(); this.updateScreen();}@Overrideprotected void drawGuiContainerBackgroundLayer(float f, int i, int j) { this.gridSize = this.gS + this.gridSizeOffset; if (this.locations.isEmpty()) { this.locations = this.te.locations; } if (this.coordButtons1 == null) { updateButtons(); } GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); int gx1 = this.startLeft - 3, gx2 = (this.startLeft + (this.gridSize * this.cw)) + (this.gridSize * this.cw) + this.cw + 3, gy1 = this.startTop - 3, gy2 = gy1 + (this.gridSize * this.ch) + (this.gridSize * this.ch) + this.ch + 6; int gw = ((this.gridSize * 2) * this.cw) + (this.cw + 6), gh = ((this.gridSize * 2) * this.ch) + (this.ch + 6); // Drawing Map boarders // Map 1 drawTexturedModalRect(gx1, gy1, 0, 0, gw / 2, gh / 2);// upper left drawTexturedModalRect(gx1 + (gw / 2), gy1, 227 - (gw / 2), 0, gw / 2, gh / 2);// upper // right drawTexturedModalRect(gx1, gy1 + (gh / 2), 0, 226 - (gh / 2), gw / 2, gh / 2);// lower // left drawTexturedModalRect(gx1 + (gw / 2), gy1 + (gh / 2), 227 - (gw / 2), 226 - (gh / 2), gw / 2, gh / 2);// lower right // Map 2 drawTexturedModalRect(gx2, gy1, 0, 0, gw / 2, gh / 2);// upper left drawTexturedModalRect(gx2 + (gw / 2), gy1, 227 - (gw / 2), 0, gw / 2, gh / 2);// upper // right drawTexturedModalRect(gx2, gy1 + (gh / 2), 0, 226 - (gh / 2), gw / 2, gh / 2);// lower // left drawTexturedModalRect(gx2 + (gw / 2), gy1 + (gh / 2), 227 - (gw / 2), 226 - (gh / 2), gw / 2, gh / 2);// lower right this.buttonList.clear(); // Start with main control buttons this.buttonList.add(new GuiButton(0, gx1, gy2, 75, this.ch, "Start Building")); // right // now // does // nothing, // as // it // was // hit // and // miss this.buttonList.add(new GuiButton(1, gx1 + 75, gy2, 75, this.ch, "Send List")); // Adds // the // location // based // on // x,y,z this.buttonList.add(new GuiButton(2, gx1 + (75 * 2), gy2, 75, this.ch, "Clear")); // Clears // all // the // locations this.buttonList.add(new GuiButton(3, gx1, gy2 + this.ch, 60, this.ch, "< Block"));// prev // block this.buttonList.add(new GuiButton(4, gx1 + 60, gy2 + this.ch, 60, this.ch, "Block >"));// next block this.buttonList.add(new GuiButton(5, gx1 + (75 * 3), gy2, 60, this.ch, "Grid +"));// prev // block this.buttonList.add(new GuiButton(6, gx1 + (75 * 3) + 60, gy2, 60, this.ch, "Grid -"));// next block this.buttonList.add(new GuiButton(7, gx1 + (60 * 2), gy2 + this.ch, 90, this.ch, this.selectionTitle[this.selectionMode]));// selection mode this.buttonList.add(new GuiButton(16, gx1 + (60 * 2) + 90, gy2 + this.ch, 75, this.ch, "Get List"));// selection mode this.buttonList.add(new GuiButton(8, (gx1 + gx2 + gw) / 2, gy1 - this.ch, this.cw, this.ch, "<"));// X left this.buttonList.add(new GuiButton(9, ((gx1 + gx2 + gw) / 2) + (this.cw * 3), gy1 - this.ch, this.cw, this.ch, ">"));// X right this.buttonList.add(new GuiButton(10, ((gx1 + gx2 + gw) / 2) + this.cw, gy1 - this.ch, this.cw, this.ch, "^"));// Z 'forward' this.buttonList.add(new GuiButton(11, ((gx1 + gx2 + gw) / 2) + (this.cw * 2), gy1 - this.ch, this.cw, this.ch, "v"));// Z 'back' this.buttonList.add(new GuiButton(12, gx1 - this.cw, (this.startTop + (this.gridSize * this.ch)) - (this.ch / 2), this.cw, this.ch, "Y1+"));// Y1 up this.buttonList.add(new GuiButton(13, gx1 - this.cw, (this.startTop + (this.gridSize * this.ch)) + (this.ch / 2), this.cw, this.ch, "Y1-"));// Y1 down this.buttonList.add(new GuiButton(14, gx2 + gw, (this.startTop + (this.gridSize * this.ch)) - (this.ch / 2), this.cw, this.ch, "Y2+"));// Y2 up this.buttonList.add(new GuiButton(15, gx2 + gw, (this.startTop + (this.gridSize * this.ch)) + (this.ch / 2), this.cw, this.ch, "Y2-"));// Y2 down // Visual information on location /* * this.drawString(fontRendererObj, "OffSet: "+xOffset, (startLeft + * ((gridSize * 2) * cw)) + cw * 6, (startTop + (gridSize * ch) + 4) - * ch, 0xFFFFFF); * this.drawString(fontRendererObj, "OffSet: "+yOffset1, (startLeft + * ((gridSize * 2) * cw)) + cw * 6, (startTop + (gridSize * ch) + 4), * 0xFFFFFF); * this.drawString(fontRendererObj, "OffSet: "+yOffset2, (startLeft + * ((gridSize * 2) * cw)) + cw * 11, (startTop + (gridSize * ch) + 4), * 0xFFFFFF); * this.drawString(fontRendererObj, "OffSet: "+zOffset, (startLeft + * ((gridSize * 2) * cw)) + cw * 6, (startTop + (gridSize * ch) + 4) + * ch, 0xFFFFFF); * this.drawString(fontRendererObj, (AB == null ? "single Mode":(AB[0] * == null ? "Point A not selected" : AB[0])).toString(), * (startLeft + ((gridSize * 2) * cw)) + cw * 8, (startTop + ((gridSize * * 2) * ch)) - ch * 3, blockColor); // What block is selected */ this.drawString(this.fontRendererObj, RotBlocks.blockTypeObjects[this.currentBlock].getLocalizedName(), gx1, gy2 + (this.ch * 2), this.blockColor); // What block is selected for (GuiBaseNodeButton element : this.coordButtons1) { this.buttonList.add(element); } for (GuiBaseNodeButton element : this.coordButtons2) { this.buttonList.add(element); }}@Overrideprotected void keyTyped(char par1, int par2) { if (par1 == 'a') { this.xOffset--; updateButtons(); } else if (par1 == 'd') { this.xOffset++; updateButtons(); } else if (par1 == 'w') { this.zOffset--; updateButtons(); } else if (par1 == 's') { this.zOffset++; updateButtons(); } else if (par2 == this.mc.gameSettings.keyBindJump.getKeyCode()) { if ((this.yOffset1 + this.te.yCoord) == 255) { return; } else { this.yOffset1++; } updateButtons(); } else if (par2 == Keyboard.KEY_DOWN) { if ((this.yOffset2 + this.te.yCoord) == 0) { return; } else { this.yOffset2--; } updateButtons(); } else if (par2 == Keyboard.KEY_UP) { if ((this.yOffset2 + this.te.yCoord) == 255) { return; } else { this.yOffset2++; } updateButtons(); } else if (par2 == this.mc.gameSettings.keyBindSneak.getKeyCode()) { if ((this.yOffset1 + this.te.yCoord) == 0) { return; } else { this.yOffset1--; } updateButtons(); } if ((par2 == 1) || (par2 == this.mc.gameSettings.keyBindInventory.getKeyCode())) { this.mc.thePlayer.closeScreen(); }}private void addLocation(int x, int y, int z) { if (this.locations.isEmpty()) { this.locations.add(new UtilityBlockLocationType(x, y, z, RotBlocks.blockTypeObjects[this.currentBlock])); } else { boolean dupeObject = false; for (int l = 0; l < this.locations.size(); l++) { UtilityBlockLocationType ublt = (UtilityBlockLocationType) this.locations .get(l); if ((ublt.x == x) && (ublt.y == y) && (ublt.z == z)) { ublt.block = RotBlocks.blockTypeObjects[this.currentBlock]; this.locations.set(l, ublt); dupeObject = true; } } // If the coordinate is fresh add it in if (!dupeObject) { this.locations.add(new UtilityBlockLocationType(x, y, z, RotBlocks.blockTypeObjects[this.currentBlock])); } }}// Updates the buttons ...startLeft + ((gridSizeX * 2) * cw)) + cwprivate void updateButtons() { if ((this.coordButtons1 == null) || (this.coordButtons1.length != (((this.gridSize * 2) + 1) * ((this.gridSize * 2) + 1)))) { this.coordButtons1 = new GuiBaseNodeButton[((this.gridSize * 2) + 1) * ((this.gridSize * 2) + 1)]; } if ((this.coordButtons2 == null) || (this.coordButtons2.length != (((this.gridSize * 2) + 1) * ((this.gridSize * 2) + 1)))) { this.coordButtons2 = new GuiBaseNodeButton[((this.gridSize * 2) + 1) * ((this.gridSize * 2) + 1)]; } int buttonArrayIndex = 0; UtilityBlockLocationType ublt; for (int x = this.gridSize; x >= -this.gridSize; x--) { for (int z = this.gridSize; z >= -this.gridSize; z--) { IIcon t1 = null; IIcon t2 = null; int c1 = this.defaultColor; int c2 = this.defaultColor; String s1 = "x"; String s2 = "x"; Block worldBlock1 = this.te.getWorldObj() .getBlock(x + this.te.xCoord + this.xOffset, this.yOffset1 + this.te.yCoord, z + this.te.zCoord + this.zOffset); Block worldBlock2 = this.te.getWorldObj() .getBlock(x + this.te.xCoord + this.xOffset, this.yOffset2 + this.te.yCoord, z + this.te.zCoord + this.zOffset); if (this.selectionMode == 1) { if ((this.AB != null) && (this.AB[0] != null) && ((x + this.xOffset) == (int) this.AB[0].x) && ((z + this.zOffset) == (int) this.AB[0].z)) { s1 = "X"; s2 = "X"; } else { s1 = worldBlock1.equals(Blocks.air) ? "." : "+"; s2 = worldBlock2.equals(Blocks.air) ? "." : "+"; } } else { s1 = worldBlock1.equals(Blocks.air) ? "." : "+"; s2 = worldBlock2.equals(Blocks.air) ? "." : "+"; } if (!this.locations.isEmpty()) { UtilityBlockLocationType ubltS; // Look through every Item of the list for (int ubltl = 0; ubltl < this.locations.size(); ubltl++) { ubltS = (UtilityBlockLocationType) this.locations.get(ubltl); if (ubltS.y == (this.yOffset1 + this.te.yCoord)) { if ((ubltS.x == (x + this.xOffset + this.te.xCoord)) && (ubltS.z == (z + this.zOffset + this.te.zCoord))) { s1 = "*"; c1 = ubltS.block.getMapColor(0).colorValue; t1 = ubltS.block.getIcon(1, 0); break; } } } for (int ubltl = 0; ubltl < this.locations.size(); ubltl++) { ubltS = (UtilityBlockLocationType) this.locations.get(ubltl); if (ubltS.y == (this.yOffset2 + this.te.yCoord)) { if ((ubltS.x == (x + this.xOffset + this.te.xCoord)) && (ubltS.z == (z + this.zOffset + this.te.zCoord))) { s2 = "*"; c2 = ubltS.block.getMapColor(0).colorValue; t2 = ubltS.block.getIcon(1, 0); break; } } } } this.coordButtons1[buttonArrayIndex] = new GuiBaseNodeButton( this.indexCounter++, (this.startLeft + (this.gridSize * this.cw)) + ((this.cw * x)), (this.startTop + (this.gridSize * this.ch)) + ((this.ch * z)), this.cw, this.ch, s1); this.coordButtons2[buttonArrayIndex] = new GuiBaseNodeButton( this.indexCounter++, ((this.startLeft + (this.gridSize * this.cw)) + ((this.gridSize * this.cw) * 2) + this.cw + 6) + ((this.cw * x)), (this.startTop + (this.gridSize * this.ch)) + ((this.ch * z)), this.cw, this.ch, s2); if (((x + this.xOffset) == 0) && (this.yOffset1 == 0) && ((z + this.zOffset) == 0)) { this.coordButtons1[buttonArrayIndex].packedFGColour = 0x0000FF; } else { this.coordButtons1[buttonArrayIndex].packedFGColour = c1 == this.defaultColor ? (worldBlock1.equals(Blocks.air) ? 0x00CCFF : worldBlock1 .getMapColor(0).colorValue) : c1; } if (((x + this.xOffset) == 0) && (this.yOffset2 == 0) && ((z + this.zOffset) == 0)) { this.coordButtons2[buttonArrayIndex].packedFGColour = 0x0000FF; } else { this.coordButtons2[buttonArrayIndex].packedFGColour = c2 == this.defaultColor ? (worldBlock2.equals(Blocks.air) ? 0x00CCFF : worldBlock2 .getMapColor(0).colorValue) : c2; } float b1 = 1.0f, b2 = 1.0f; int depth1 = 0, depth2 = 0; while (t1 == null) { t1 = this.te .getWorldObj() .getBlock(x + this.te.xCoord + this.xOffset, (this.yOffset1 + this.te.yCoord) - depth1, z + this.te.zCoord + this.zOffset).getIcon(1, 0); if (t1 == null) { if (!this.locations.isEmpty()) { // Look through every Item of the list for (int ubltl = 0; ubltl < this.locations.size(); ubltl++) { ublt = (UtilityBlockLocationType) this.locations .get(ubltl); if (ublt.y == ((this.yOffset1 + this.te.yCoord) - depth1)) { if ((ublt.x == (x + this.xOffset + this.te.xCoord)) && (ublt.z == (z + this.zOffset + this.te.zCoord))) { t1 = ublt.block.getIcon(1, 0); break; } } } } MathHelper.clamp_float(b1 -= 0.2f, 0, 1f); depth1++; } } while (t2 == null) { t2 = this.te .getWorldObj() .getBlock(x + this.te.xCoord + this.xOffset, (this.yOffset2 + this.te.yCoord) - depth2, z + this.te.zCoord + this.zOffset).getIcon(1, 0); if (t2 == null) { if (!this.locations.isEmpty()) { // Look through every Item of the list for (int ubltl = 0; ubltl < this.locations.size(); ubltl++) { ublt = (UtilityBlockLocationType) this.locations .get(ubltl); if (ublt.y == ((this.yOffset2 + this.te.yCoord) - depth2)) { if ((ublt.x == (x + this.xOffset + this.te.xCoord)) && (ublt.z == (z + this.zOffset + this.te.zCoord))) { t2 = ublt.block.getIcon(1, 0); break; } } } } MathHelper.clamp_float(b2 -= 0.2f, 0, 1f); depth2++; } } this.coordButtons1[buttonArrayIndex].tex = t1; this.coordButtons1[buttonArrayIndex].x = x + this.xOffset; this.coordButtons1[buttonArrayIndex].y = this.yOffset1; this.coordButtons1[buttonArrayIndex].z = z + this.zOffset; this.coordButtons1[buttonArrayIndex].brightness = b1; this.coordButtons2[buttonArrayIndex].tex = t2; this.coordButtons2[buttonArrayIndex].x = x + this.xOffset; this.coordButtons2[buttonArrayIndex].y = this.yOffset2; this.coordButtons2[buttonArrayIndex].z = z + this.zOffset; this.coordButtons2[buttonArrayIndex].brightness = b2; buttonArrayIndex++; } } this.indexCounter = this.INDEX_START; this.updateScreen();}} This is all the old code before I had to butcher it and comment sections out just to get it to work at all. Any help to get the new [1.8] stuff to work would be great, as I want this gui to be given a list of blocks and let the player pick what one they want to draw with to build a blueprint, but to be able to use anything from even other mods. Right now it is a fixed static list of blocks (which I do not want, just used as I was making this to get started quicker)
  21. did you override the getDamage method in the item that you are using? does it have a maxDamage? What comes first the chicken or the egg? By my last statement you are saying you changed to a reference class, is this reference class or item defined and loaded before the creative tab? With out the code of what you mentioned (CreativeTab, ReferenceClass, Item) it's difficult to help with a null pointer error, because something somewhere is not passing an item in that stack, and better yet if it is, that item is not passing anything out as a damage value.
  22. I figured since you said a normal "one way" cable route worked fine (at least no freeze ups) That it would be your back trace code and or your search code. I find it a bit odd, you want to seach all 6 forge directions yet your output log shows the first leap going 0, 1, 2 found it, starting from cable, then 0, 1 ,2 recursing from cable. once again 0, 1, 2 recursing from cable. But then, from the looks of it you hit your junction 0, 1, 2, 3 Found Something, 4 Got something again recursing from cable. now you see the problem I have (unless you cut the log short) is that you have the foreach loop for all forge directions, yet I only see output for the 1st or 2nd found tileEntity when in reality I should see: 0,1,2,3,4,5 (all six) And now for the next question, why a back track? you run a recursive call on each cable anyways (understandable) so why the need to make a back trace, just trace all the way until there are no more cables. I figure you get a hang up because that backtrace junction literately gets stuck at that "T" and not only that checks down the 1st line forever, example would be: Cable scan finds junction, saves it (this is that "T") continue down the right path (I am guessing this is direction 4) reach the end, found nothing important back trace. Return to Junction "T" rescan down path 4, and look at path 3 (left?) well the 1st point down that junction is gonna stop and scan down path 4 (right, which is heading back not down the path) which scans the "T" junction and then goes down path 4(right) again, all the while creating another recursive path until you have game freeze from so many recursive loops generating until the end of time. So what you need to do, is check if that cable has been scanned already in that time frame, or have the cable focus one a direction "locateNodes(true, x1, x2, x3, ForgeDirection)" this way it should scan that way 1st before going 0,1,2,3,4,5. so Look over your scanning code, and see why it's not stopping and already scanned cables and checking for new ones.
  23. the problem is "armorItemInSlot(0)" returns an ItemStack, you can't compare ItemStacks with Items you will always get a false. You want armorItemInSlot(0).getItem() .equals(item) or == item, or instanceof item also you already have the itemstack from this line: ItemStack armorslot = player.inventory.armorItemInSlot(0); so just use if (armorslot.getItem() == ItemLoader.ArmorTeslaBoots) { //do stuff }
  24. This gentleman has gotten the same issue that you have using .expand, so he switched to something a bit different http://www.minecraftforge.net/forum/index.php/topic,23916.msg121467.html#msg121467 Hope this helps.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.