roket333 Posted September 14, 2014 Share Posted September 14, 2014 I have recently been trying to make a black hole but I cannot find code for it ANYWHERE! I tried " double radius = 5; List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, ep.boundingBox.expand(32, 32, 32)); //The area to pull items from (change 32 to any number) for(EntityItem it : items){ double distX = ep.posX - it.posX; //Move those items! double distZ = ep.posZ - it.posZ; double distY = it.posY+1.5D - ep.posY; double dir = Math.atan2(distZ, distX); double speed = 1F / it.getDistanceToEntity(ep) * 15; //Adjust the speed here (change 15) if (distY<0) { it.motionY += speed; } it.motionX = Math.cos(dir) * speed; it.motionZ = Math.sin(dir) * speed; } }" but that just gives me a ton of errors saying it cant find distx,y and z. I really need some help! any kind is appreciated. Quote Link to comment Share on other sites More sharing options...
Whov Posted September 14, 2014 Share Posted September 14, 2014 What does "can't find" mean? Where? Outside that loop of course not. Still studying Java perhaps? Quote Check out my blog! http://www.whov.altervista.org Link to comment Share on other sites More sharing options...
roket333 Posted September 14, 2014 Author Share Posted September 14, 2014 do you think you could supply me with the code for the sucking entities and killing them thing? I would really appreciate it! If you want, I could give you a link to a custom model of Sonic the Hedgehog and Tails, all ready to be animated and put in-game in return of the code. Quote Link to comment Share on other sites More sharing options...
hugo_the_dwarf Posted September 15, 2014 Share Posted September 15, 2014 do you think you could supply me with the code for the sucking entities and killing them thing? I would really appreciate it! If you want, I could give you a link to a custom model of Sonic the Hedgehog and Tails, all ready to be animated and put in-game in return of the code. Not how it really works around here, would be nice, but if that was the case not many would learn. You can post the class in [code] {/code] Seems like you have a rough idea on how to do this, just some error troubles. Quote Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master Link to comment Share on other sites More sharing options...
Whov Posted September 18, 2014 Share Posted September 18, 2014 Sorry. I meant what does "saying it cant find distx,y and z." mean? Could you show the errors? Quote Check out my blog! http://www.whov.altervista.org Link to comment Share on other sites More sharing options...
EmperorZelos Posted September 19, 2014 Share Posted September 19, 2014 from my experience it is wise to avoid using sin/cos at all costs if possible as they are heavy on processing, you might wanna read up some on linear algebra to help you aswell Quote Link to comment Share on other sites More sharing options...
roket333 Posted February 16, 2016 Author Share Posted February 16, 2016 from my experience it is wise to avoid using sin/cos at all costs if possible as they are heavy on processing, you might wanna read up some on linear algebra to help you aswell I know this post is over a year old but to be honest, I tried to take that from the Vacuum Hopper in Open Blocks. I feel kind stupid but I really need this code for a Black Hole. I have all the textures ready as well as the custom model. Also, someone PLEASE supply me with the code. Of course, I'll give proper credit too. Quote Link to comment Share on other sites More sharing options...
Cerandior Posted February 16, 2016 Share Posted February 16, 2016 I have tried to create a blackhole myself some time ago. Even though the code i used to "suck" entities inside it worked i never got it's rendering to work properly. I can supply you with the code of my blackhole but you have to work through the rendering process yourself. Code: public class blackHoleTE extends TileEntity implements IUpdatePlayerListBox{ private int Mass; @Override public void update() { List<Entity> EntitiesAround = this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.fromBounds (this.getPos().getX() - 10 - Mass / 10, this.getPos().getY() - 10 - Mass / 10, this.getPos().getZ() - 10 - Mass / 10, this.getPos().getX() + 10 + Mass / 10 + 1, this.getPos().getY() + 10 + Mass / 10 + 1, this.getPos().getZ() + 10 + Mass / 10 + 1)); for(Entity e : EntitiesAround){ double motionX = this.getPos().getX() - (e.posX + 0.5); double motionY = this.getPos().getY() - (e.posY + 0.5); double motionZ = this.getPos().getZ() - (e.posZ + 0.5); e.motionX = motionX * 0.1F; e.motionY = motionY * 0.1F; e.motionZ = motionZ * 0.1F; } List<Entity> ToClose = this.worldObj.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.fromBounds (this.getPos().getX() - 1 , this.getPos().getY() - 1 , this.getPos().getZ() - 1, this.getPos().getX() + 2, this.getPos().getY() + 2, this.getPos().getZ() + 2)); for(Entity e : ToClose){ if(e instanceof EntityItem){ Mass++; e.attackEntityFrom(DamageSource.cactus, 7.5F); }else{ e.attackEntityFrom(DamageSource.cactus, 7.5F); } } if(Mass >= 500){ if(!worldObj.isRemote){ worldObj.destroyBlock(this.pos, false); worldObj.createExplosion(null, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 100F, true); } } } @Override public void writeToNBT(NBTTagCompound compound) { compound.setInteger("Mass", Mass); super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound) { compound.getInteger("Mass"); super.readFromNBT(compound); } } My blackhole is made so it adds an explosion after it takes up to much entities inside it. Remove the parts of code that do that. Quote Link to comment Share on other sites More sharing options...
Draco18s Posted February 16, 2016 Share Posted February 16, 2016 Alert: supplied code is 1.8ish. 1.7.10 does not require IUpdatePlayerListBox and all pos and Blockpos objects should be some variant of x , posx , or xCoord . Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
Failender Posted February 16, 2016 Share Posted February 16, 2016 yes because normal blocks cant tick Quote Link to comment Share on other sites More sharing options...
Cerandior Posted February 16, 2016 Share Posted February 16, 2016 Yeah i gave him a tile entity example, but an entity would be better in this case. He said that he wanted a block to suck items so... Quote Link to comment Share on other sites More sharing options...
Izzy Axel Posted February 16, 2016 Share Posted February 16, 2016 Fairly simple with a TileEntity. As for rendering, you can attach an ISimpleBlockRenderingHandler or TileEntitySpecialRenderer to it. There are plenty of tutorials for that out there, so here's how I did the block: Block TileEntity Quote Link to comment Share on other sites More sharing options...
roket333 Posted February 19, 2016 Author Share Posted February 19, 2016 Fairly simple with a TileEntity. As for rendering, you can attach an ISimpleBlockRenderingHandler or TileEntitySpecialRenderer to it. There are plenty of tutorials for that out there, so here's how I did the block: Block TileEntity Thanks! I'll test the code when I can and let you know how it goes Quote Link to comment Share on other sites More sharing options...
jeffryfisher Posted February 19, 2016 Share Posted February 19, 2016 How do xp orbs get drawn toward a player? Even if the movement is calculated by each orb itself, you should see useful examples of vector math and entity search there that you can adapt to your tile entity. Quote The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting. Link to comment Share on other sites More sharing options...
roket333 Posted February 21, 2016 Author Share Posted February 21, 2016 Also, someone PLEASE supply me with the code. Of course, I'll give proper credit too. As was already said above, this is not how this forum works. More requests like this will get you banned. I did not know that but thank you for letting me know Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.