-
Posts
53 -
Joined
-
Last visited
Everything posted by navybofus
-
I knew that it was ticking on both sides but when The tile entity called the item storage method I received a stack overflow. I thought this was caused by my method recycling the extra items from an item stack that was too large. I've got everything working but I still get the error if the items inherent max stack size is 16 (eggs). About the @SideOnly, through tutorials I was taught to use this for graphics. Is this no longer the case? I do understand that I was confusing side only and isRemote checks when I wrote this post.
-
[1.7.2] The best way to add items to an inventory
navybofus replied to navybofus's topic in Modder Support
Wow. I should have thought of that. Been staring at this code too long. Need to take a break lol. Thanks. -
[1.7.2] The best way to add items to an inventory
navybofus replied to navybofus's topic in Modder Support
Sorry, I meant to say that this works. I was wondering if there is some nifty forge way that does all of this work via IInventory or something. -
I've got a few automation blocks that add items to nearby chests. Until I started picking up EntityItems, everything worked fine. Now that I'm getting the ItemStack from the EntityItem and adding them, I'm having troubles. Here's the code that I use to add the items to chests. /*** * Takes an int[] with the x, y, z and slot of a nearby inventory * with either a matching item or empty slot. Also takes the stack to add. */ private void placeItemsInChest(int[] loc, ItemStack stack){ TileEntityChest te = (TileEntityChest) worldObj.getTileEntity(loc[0], loc[1], loc[2]); if(te.getStackInSlot(loc[3]) != null){ ItemStack chestStack = te.getStackInSlot(loc[3]); if(chestStack.getItem() == stack.getItem()){ if(chestStack.getItemDamage() == stack.getItemDamage()){ Item passedItem = stack.getItem(); int size = 0; size = chestStack.stackSize; size += stack.stackSize; if(size <= chestStack.getMaxStackSize()){ te.setInventorySlotContents(loc[3], new ItemStack(passedItem, size)); } else { int sizeRemain = size - chestStack.getMaxStackSize(); te.setInventorySlotContents(loc[3], new ItemStack(passedItem, size-sizeRemain)); ItemStack remainingStack = new ItemStack(passedItem, sizeRemain); if(findChestWithRoom(remainingStack) != null){ //Run this method again with the remaining stack. int[] tmpLoc = findChestWithRoom(remainingStack).clone(); placeItemsInChest(tmpLoc, remainingStack); } else { spawnItems(remainingStack); //Spawns EntityItems into the world if no valid inventory found } } } else { te.setInventorySlotContents(loc[3], stack); } } else { te.setInventorySlotContents(loc[3], stack); } } }
-
I've been writing new code for the LittleHelpers mod for a few weeks, but just recently I've added another new block with a TileEntity (like all the others). BUT, every time I try to run any method, it's running twice. I used System.out.println(); and every message appears twice. I added the delay variable that I've set and it displays two different values (the delay is random) so I believe that each method within my tile entity is running twice. This is really messing with the functionality of my blocks. What am I doing different? Should I be using @SideOnly? I haven't had to use it so far and all other blocks work just fine. Just updated to 1082, but I only did that because the problem was happening in 1060. HALP!
-
I'm trying to "highlight" (add a wire frame) to some nearby chests when the player looks at a certain block, but I can't seem to get the tessellator to draw the wire frame. I followed the tutorial here on tessellation, but it's mainly for drawing faces of a custom block. I just want to draw a "phantom" wire frame with the faces shaded a color with a low alpha. Currently I just have the code for one face to get started but I stopped there because I was just getting a glitchy black face that was invisible from most angles and glitchy from others. I guess I'm using the wrong methods to draw lines. Sorry, but I just can't find a lot of good info about this. Tessellator t = Tessellator.instance; GL11.glPushMatrix(); GL11.glColor4d(1.0D, 0.0D, 0.0D, 1.0D); GL11.glTranslated(x, y+1, z); GL11.glLineWidth(3.0F); //t.startDrawingQuads(); // EDIT: Was using this. Now using next line. t.startDrawing(GL11.GL_LINE_STRIP); // This is showing the wireframe, but not all the time. t.addVertex(0, 0, 0); t.addVertex(0, 1, 0); t.addVertex(1, 1, 0); t.addVertex(1, 0, 0); t.draw(); GL11.glPopMatrix(); Any help or a point toward a similar tutorial would be greatly appreciated.
-
Like coolboy, I'm not exactly sure, but I can help you search. You need to add the mod to your workspace somehow so you can reference the item via the mod's code. Also you need to add the original mod to the dependency list or add a default item that the block will drop in case the mod isn't loaded. Coolboy was also right about the method to use to see if the mod is loaded. Add this to your @Mod annotation dependencies = "required-after:halogunmod" And this will be in your PreInit if(Loader.isModLoaded("halogunmod")){ halomodLoaded = true; } Then you can use that boolean in the block's class to determine what the block drops. However, there's always a better way to do things that I normally do, so search the web and I hope you find what you need. **Since i'm unsure of the mod's ID, I just used halogunmod
-
Currently my LittleHelpers mod does well with vanilla blocks/items, but when it interacts with other mod's items, it goes a bit haywire. I just want to put a check in that will discriminate against other mod items. I was trying to add the mod's jar as a Referenced Library so I can say, "If this is a block from this mod, then skip this block." But I'm crashing on debug. I know there's a way to add other mods to the workspace, but I can't remember or find documentation on how to do so. Any help is greatly appreciated! Thanks!
-
Hello again Minecraft Forge guru's! I've decided to add a small bit of flare to my newest mod (mostly for practice). I'd like to have an item hover over my block and slowly rotate. I'm going to change this item based on the inventory, but I can do that after I find out how to render any item. So far, I've tried using the tesselator to draw ANYTHING above my block, but I can't even figure out if my Renderer is being registered correctly. I've placed a few log notes and none of them show up. Here's some of my code that I believe is the culprit. EDIT: I've made sure that my renderer is being registered and got something on the screen. I forgot to add proxy.registerRenderers(); to my FMLInitilizationEvent public class CommonProxy { public void registerRenderers(){} } public class ClientProxy extends CommonProxy{ public void registerRenderers(){ ClientRegistry.bindTileEntitySpecialRenderer(TEMetalExtractor.class, new RendererMetalExtractor()); } } public class RendererMetalExtractor extends TileEntitySpecialRenderer{ public RendererMetalExtractor(){} private static final ResourceLocation texture = new ResourceLocation(ModInfo.MODID, "textures/blocks/magnet.png"); @Override @SideOnly(Side.CLIENT) public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) { bindTexture(texture); Tessellator t = Tessellator.instance; GL11.glPushMatrix(); GL11.glColor3ub((byte)255, (byte)0, (byte)0); GL11.glTranslated(x, y+1, z); GL11.glLineWidth(10.0F); t.startDrawingQuads(); t.addVertexWithUV(0, 0, 0, 0, 0); t.addVertexWithUV(0, 1, 0, 0, 1); t.addVertexWithUV(1, 1, 0, 1, 1); t.addVertexWithUV(1, 0, 0, 1, 0); t.draw(); GL11.glPopMatrix(); } } All of this TESR code is the product of several tutorials that don't do what I wanted, but I thought I could figure it out if I got something to show up. I'm going to continue working towards a solution. If anyone can provide some help I'd really appreciate it.
-
[1.6.4][Gradle] doForgePatchesPatching Failed
navybofus replied to navybofus's topic in Modder Support
Yeah I thought a clean install would work too, but the problem persists. I think I'll just leave 1.6.4 alone. I'm not that worried about porting my mods to previous versions. But thanks anyway -
First thing I'd do is check out the vanilla diamond and redstone blocks. They do what you're asking already, if I understand you correctly.
-
I've been looking for an answer to this for a little while and thought maybe someone would recognize the error and send me in the right direction. I'm going to port some of my 1.7.2 mods to 1.6.4 by request and got the forge-1.6.4-9.11.1.964-src.zip file and extracted it, and ran (through gradlew) setupDevWorkspace, and then eclipse, and then I tried to run setupDecompWorkspace and received a failed build error. The log that contains the build info is in the spoiler below. [spoiler=Gradle.log] **************************** Powered By MCP: http://mcp.ocean-labs.de/ Searge, ProfMobius, Fesh0r, R4wk, ZeuX, IngisKahn MCP Data version : unknown **************************** :downloadMcpTools UP-TO-DATE :extractUserDev :genSrgs UP-TO-DATE :downloadClient SKIPPED :downloadServer SKIPPED :mergeJars SKIPPED :deobfuscateJar UP-TO-DATE :decompile SKIPPED :doFmlPatches SKIPPED :addFmlSources UP-TO-DATE :remapJar SKIPPED :doForgePatchesPatching failed: net/minecraft/client/gui/achievement/GuiAchievements.java Cannot find hunk target Hunk 7 failed! Cannot find hunk target Hunk 8 failed! Cannot find hunk target Patching failed: net/minecraft/client/renderer/RenderBlocks.java Cannot find hunk target Hunk 6 failed! Cannot find hunk target Hunk 10 failed! Cannot find hunk target Patching failed: net/minecraft/client/renderer/entity/RenderItem.java Cannot find hunk target Hunk 6 failed! Cannot find hunk target Hunk 11 failed! Cannot find hunk target Hunk 12 failed! Cannot find hunk target Patching failed: net/minecraft/world/gen/feature/WorldGenTaiga2.java Cannot find hunk target Hunk 4 failed! Cannot find hunk target Hunk 5 failed! Cannot find hunk target FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':doForgePatches'. > Could not call EditJarTask.doTask() on task ':doForgePatches' * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 24.103 secs As always, any help is greatly appreciated. Thank you.
-
EDIT: I figured it out, I wasn't getting the AABB correctly and I wasn't positioning it correctly either. Here's a sample for others that may need this in the future. AxisAlignedBB axisalignedbb = AxisAlignedBB.getAABBPool().getAABB((double)this.xCoord, (double)this.yCoord, (double)this.zCoord, (double)(this.xCoord + 1), (double)(this.yCoord + 1), (double)(this.zCoord + 1)) You can also use .expand to change this size of your box. Original Message: I'm trying to retrieve a list of entities within a specified area. I've been trying to use a custom AABB with worldObj.getEntitiesWithinAABB(), but I can't seem to get my list to display anything when I send it to the log. I've never used AABB so that's probably my problem. I am attempting to use the following code because of the EntityAILookAtVillager script that makes the Iron Golem look at villagers. It's also repeated in other "AILookAt" scripts. Here's the code I'm tinkering with atm. It's in one of my TileEntity scripts. //Returns list of entities within AABB private List<EntityLiving> getEntityInRange(){ AxisAlignedBB detectionBB = AxisAlignedBB.getBoundingBox(5.0D, 2.0D, 5.0D, 5.0D, 2.0D, 5.0D); detectionBB.offset(xCoord, yCoord, zCoord); List entitylist = worldObj.getEntitiesWithinAABB(EntityLiving.class, detectionBB); if(!entitylist.isEmpty()){ System.out.println("Found entity(ies): " + Arrays.toString(entitylist.toArray())); return entitylist; } System.out.println("NOTHING DETECTED"); return null; } Any help is much appreciated. --Thanks, Navybofus
-
I want to add an in-game mod manual to the player's inventory when they player crafts one of my mod items. Just like Tinkerer's Construct. So, instead of decompiling mDiyo's mod and copying code, I'd like to do it my own way. Basically when I craft an item, I'd like a prewritten book to be added to the player's inventory (or spawn at the player's feet if inv is full). I was going to have another book that was given to the player when a new world is loaded that had all of the recipes too, but I'm not sure exactly how to do it. What I know: I'd like to use the vanilla book to do this. I know I need to add an onCrafting Event I'd don't necessarily need to add the book on world load. In summary, I am trying to dynamically write a book during an oncrafting event to add to the player's inventory to give descriptions of my mod items/blocks. Also, if someone has time to direct me, I'd like to have another book given to the player in new worlds. If there is a tutorial or some information on this topic, a link will suffice. Thank you Forge Community.
-
Thanks, I'm trying to get my Gui button's to talk to my blocks/tileentities. VSWE's lectures say that I need one. I'll check out that tutorial. Thanks!
-
I've been going through the VSWE lectures video by video and every now and then errors occur that I can find the updated versions of, but I'm to the packethandler stuff and I'm not sure what took the place of IPacketHandler. I've seen a lot of mentions of the netty packets but I'm not sure if that's what I want. I've looked at the tutorials here at forge and only found 1.6 stuff. A point to a newer tutorial or some light on the subject is greatly appreciated. Thanks.
-
I'm not quite sure about the config button yet, but I know that you can add a tag in your @Mod to enable the disable feature. I think this may only be useful for mods that don't add custom content but only change vanilla features. Because if you load a world without the custom content of a mod there will be hell to pay, or errors... whichever.
-
There it is! Thanks! Well everything is without error at least.
-
Right now I'm using MinecraftForge.EVENT_BUS.register(.class) in hopes of getting my class that implements INetHandler to register. But putting a System.out in there shows nothing in the console. I'm sure this is my lack of java knowledge that's making this difficult. But in 1.6.4 we just registered a tick handler and looked through the event stuff with no avail.
-
I'm upgrading from 1.6 to 1.7 and haven't found it yet.