Jump to content

epicsquare

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by epicsquare

  1. How about something like this: Every solar panel has its own tile entity. Each tile entity has a List (lets call it otherPanels) that will contain a list of all other solar panels in the structure. When placed, the tile checks adjacent blocks for solar panel tiles, and if it finds one, it requests from it its otherPanels list, sets it as its own. It then notifies every tile in that list that it is now also part of the list (enumerate through the list and call .addToOtherPanels(this) or something for each element). You can also now call some method for every other panel to notify them that the storage capacity has increased. When any panel loses energy, it enumerates through that list and tells all the other panels to decrease their internal buffers by the appropriate amount. So basically every panel keeps track of the total capacity and current energy level for the whole structure, and they are all synced when any of those changes by whatever panel caused the change. I feel like there's a way you can do this recursively, but I haven't thought it through enough for that. I don't know if this is the best approach, but it's all I could come up with off the top of my head at 2am. Let me know what you think
  2. Well, I seem to have found an extremely sketchy, but somewhat effective fix. Basically when creating the structure, I put a single custom block with a tile entity. Each second (20 ticks) the tile entity checks for players within 100 blocks, and if one is found it updates all the lights in a 50 block radius around it, then replaces itself with a grass block. I know this is very inefficient and somewhat lag inducing, but the performance impact has been tolerable (as far as I can tell, its just a single 500 - 600 millisecond stutter when approaching the structure), and it does solve the problem. Here is the code for the tile entity: If anyone has a better suggestion, please post!
  3. Thanks for the suggestion, I don't know why I did not think of stepping into updateLightByType lol Turns out this check (the first check in the method) fails : if (this.doChunksNearChunkExist(par2, par3, par4, 17)) { Which makes sense because the structure is being generated with the chunks. TECHNICALLY, I'm generating it on onPopulateChunkPost(PopulateChunkEvent.Post event) because I read that for large structures generating them on that event (rather than registering an IWoldGenerator) prevents them from getting cut off. None the less, that event is called after the IWoldGenerator would have been so the problem remains. If I can't update my lights here, where can I (so that all the chunks would already be generated)? EDIT: I tried force generating all the nearby chunks before updating lights - did not help (.doChunksNearChunkExist is true and the update lights code runs, but dark blocks remain). Not only can I not debug the blocks that are dark (I don't know which ones hey are until I see them in-game, and update lights gets run on every solid block I generate), but this.computeLightValue(par2, par3, par4, par1EnumSkyBlock); seems to return 0, and I don't know whether it it supposed to or not (is that block naturally unlit or is it the bug). The link did prove quite interesting, thank you, but I'm still unsure as to the specific cause in my case.
  4. Hi everyone, I'll get right to the point: I'm generating a structure and it has the weird blacked out areas lighting bug: I don't know what causes it, and for the life of me I can't get rid of it. The black bits are all over the place and are really annoying to look at. I've tried running world.markBlockForUpdate(x, y, z); world.updateAllLightTypes(x, y, z); on every block inside the structure (both air and solid) after generating the structure, and it still happens. Also, when generating the structure, I'm passing 3 as a flag to set block - world.setBlock(x, y, z, id, meta, 3); Any advice?
  5. I need to get the ingredients. IRecipe does not seem to offer that.
  6. So every recipe except the ones you mentioned are stored in CraftingManager.getInstance().getRecipeList();? Right now I'm checking each IRecipe in that list if it is an instance of ShapedRecipes or ShapelessRecipes. Should I be checking for others? For example swords and other tools don't seem to be shaped or shapeless so what are they?
  7. Is there really no easy way to do this?
  8. Hi all, I have a very simple issue, but I haven't been able to find a simple answer to it. All I want to do, is get the recipe of an item or block. More specifically, I want to get the recipe of every item or block in the game (Including items added by mods). I think NEI does this, and I do believe they have an API but I have yet to find proper documentation on it. I've tried @EventHandler public void postInit(FMLPostInitializationEvent event) { List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList(); } However this does not include many recipes for vanilla items such as tools. Am I running it too early?
  9. Where would I find the PreRenderPlayer/PostRenderPlayer events? I don't see them in the Event reference (http://www.minecraftforge.net/wiki/Event_Reference). As you said I realized that returning EnumAction.bow for GetItemUseAction puts the player in a bow stance and if I setItemInUse every update that it is held, (and give a long item max use duration) it appears to be held the way I want it, and even for some reason does not slow down the player (I guess minecraft does that only while mouse is down). This solution works, however it makes it so that OnItemRightClick, and OnPlayerStoppedUsing are never called so i have to call them manually from the client's update (when mouse is up/down) and send packets about it to the server. It's a very hacky solution, so i'd like to hook the player renderer as you said if I can, as that seems much more proper. Also I'd also like to avoid ASM if possible. EDIT: So I created my own class MyPlayerRenderer extends RenderPlayer and registered it with RenderingRegistry.registerEntityRenderingHandler(EntityPlayer.class, new MyPlayerRenderer()); Now to render the bow stance I overrode renderLivingAt With @Override protected void renderLivingAt( AbstractClientPlayer par1AbstractClientPlayer, double par2, double par4, double par6) { ItemStack currItem = par1AbstractClientPlayer.getCurrentEquippedItem(); if (currItem.getItem() instanceof BaseItem) { if (((BaseItem)currItem.getItem()).type == 0 || currItem.stackTagCompound.getBoolean("mouseDown")) { this.modelBipedMain.aimedBow = true; } } super.renderLivingAt(par1AbstractClientPlayer, par2, par4, par6); } This works perfectly for third person view but how do I get it to render the arm also in first person with the item held like an aimed bow?
  10. Hi all, My question is - I want to force the player into a drawn bow stance at all times while HOLDING my Item (My Item does not extend ItemBow, and I don't think I can do that for my own reasons). Preferably I want the player to not slow down in movement while doing this as well. Any way to do this? Thanks for any help!
  11. I'm having the exact same issue. My sound is Wave format PCM signed 16bit stereo. I saved 4 very similar sounds using the same program, same format, 2 of them work 2 get that error and for the life of me I can't figure out why. Can anyone help? EDIT: So I figured it out. Its got nothing to do with format, eclipse did not include my sounds in the project. To fix I just right clicked on the assets "package" in eclipse and hit refresh. Hope this helps someone
  12. Thanks! That works so long as the player doesn't fall or get launched a large distance somehow. I wonder if there is a way to make it actually follow the player.
  13. Hi all, I have a sound that I'm playing with par2World.playSoundAtEntity(entPlayer,.... but that just plays it at the player's current location, and if he is running at the moment, it just fades off into the distance. The sound is about 5 seconds long, and I was wondering if there's any way to make it play at the same volume no matter where the player goes after it begins playing. Essentially make the player actively emit the sound. Any help is very appreciated!
  14. It seems like my problem is now in this part: if (!par2World.isRemote && par2World.getGameRules().getGameRuleBooleanValue("doTileDrops")) { float f = 0.7F; double d0 = (double)(par2World.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; double d1 = (double)(par2World.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; double d2 = (double)(par2World.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; EntityItem entityitem = new EntityItem(par2World, (double)x + d0, (double)y + d1, (double)z + d2, iss); entityitem.delayBeforeCanPickup = 10; par2World.spawnEntityInWorld(entityitem); dropModified = true; } Its not actually spawning anything even though the code is run just fine. It spawns something once then stops
  15. im serious btw, this might be a huge problem As I said my class is extending ItemPickaxe. OnBlockDestroyed is part of ItemTool ItemPickaxe extends ItemTool Yes, that is how I overrode it.
  16. im serious btw, this might be a huge problem As I said my class is extending ItemPickaxe. OnBlockDestroyed is part of ItemTool
  17. The whole statement? Then the block will drop the smelted contents and the original contents too won't it? I need the pickaxe should only smelt things SOMETIMES as in there's a chance it will drop regularly. I didnt put that part into the code I posted but it shouldn't affect it. My issue is that FurnaceRecipes returns null even though it shouldn't.
  18. Hi all, I'm trying to make a custom picaxe that will smelt the block you mine. However, when I try to get the smelt result of a block, it always returns null, EXCEPT for the first time for each new block. The first stone I mined, smelted into stone, however after that it returned null every time. The first iron ore I mined dropped an iron ingot, after that FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(Block.blocksList[par3])) always returned null for iron ore (I have checked to make sure that new ItemStack(Block.blocksList[par3]) is of the correct type). Can anyone help me? Here is my onBlockDestroyed code @Override public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int x, int y, int z, EntityLiving par7EntityLiving) { boolean dropModified = false; if (!par2World.isRemote) { ItemStack res = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(Block.blocksList[par3])); if (res != null) { float f = 0.7F; double d0 = (double)(par2World.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; double d1 = (double)(par2World.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; double d2 = (double)(par2World.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; EntityItem entityitem = new EntityItem(par2World, (double)x + d0, (double)y + d1, (double)z + d2, res); entityitem.delayBeforeCanPickup = 10; par2World.spawnEntityInWorld(entityitem); dropModified = true; } } if (!dropModified) super.onBlockDestroyed(par1ItemStack, par2World, par3, x, y, z, par7EntityLiving); else par2World.destroyBlock(x, y, z, false); return true; }
  19. I have this exact same problem. Except for me it does it even if I damage my item just on use not even continuously.
  20. I modified the vanilla one and set var21 (which was set to the player's reach distance) to 50, and yet still doesn't work, even if I am right beside the mobs.
  21. I am trying to get the mob the player is currently aiming at (from a distance). I then want to change some properties of it (damage it, and possibly put potion effect). I can't use item interaction because I don't think that works from a distance. Also I would like to be able to do this even if the player did not right click (i.e. during update) or after player stopped using (onPlayerStoppedUsing or whatever it was called). Thanks for all the help guys
  22. Thanks for the reply, but that does not seem to work. I have this code: EntityLiving target = null; MovingObjectPosition pos = getMovingObjectPositionFromPlayer(world, player, false);//tried true there as well if (pos != null && pos.entityHit != null && pos.entityHit instanceof EntityLiving) target = (EntityLiving) pos.entityHit; target never changes from null.
  23. For now I have this which seems to work but I don't think its very efficient especially if you are surrounded by mobs. public static EntityLiving GetTargetEntityLiving(World world, EntityPlayer player, int scanRadius) { double targetDistance = Math.pow(scanRadius,2); EntityLiving target = null; //int tryCount = 0; List lst = world.getEntitiesWithinAABBExcludingEntity(player, AxisAlignedBB.getBoundingBox(player.posX-scanRadius, player.posY-scanRadius, player.posZ-scanRadius, player.posX+scanRadius, player.posY+scanRadius, player.posZ+scanRadius)); for (int i = 0; i < lst.size(); i ++) { Entity ent = (Entity) lst.get(i); if (ent instanceof EntityLiving && ent!=null && ent.boundingBox != null) { //tryCount++; float distance = player.getDistanceToEntity(ent) + 0.1f; float angle = player.rotationYawHead; float pitch = player.rotationPitch; Vec3 look = player.getLookVec(); Vec3 targetVec = Vec3.createVectorHelper(player.posX + look.xCoord * distance, player.getEyeHeight() + player.posY + look.yCoord * distance, player.posZ + look.zCoord * distance); //world.spawnParticle("smoke", targetVec.xCoord, targetVec.yCoord, targetVec.zCoord, 0, 0.5, 0); // System.out.println("Bounds: min: x=" + ent.boundingBox.minX + " y=" + ent.boundingBox.minY + " z=" + ent.boundingBox.minZ); // System.out.println("Bounds: max: x=" + ent.boundingBox.maxX + " y=" + ent.boundingBox.maxY + " z=" + ent.boundingBox.maxZ); // System.out.println("Target: x=" + targetVec.xCoord + " y=" + targetVec.yCoord + " z=" + targetVec.zCoord); if (ent.boundingBox.isVecInside(targetVec)) { if (distance < targetDistance && distance > 0) { targetDistance = distance; target = (EntityLiving) ent; } } } } return target; } If anyone has a better idea, PLEASE let me know. Thanks!
×
×
  • Create New...

Important Information

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