Jump to content

Recommended Posts

Posted

I would really like to try and simulate the effect of a black hole on minecraft. The way that i am going to do it is that the "black-hole" to suck inside it every Mob and Players aswell as the Item Entities (Items thrown on ground). I also want to give the "black-hole" a inventory so for each item that it sucks in, the "mass" inside the blackhole will be increased by one. The bigger the mass, the more power / range the "black-hole" has to suck items on it. When it reaches a certain amount of mass, it will either add a huge explosion to the world, or will be stabilized into a "Singularity" if you used a "Singularity Stabilizer" which will be a block. I would like to know how to make the dropped items, mobs and players be attracted by the "black-hole" and i also would like to know how to store these Entity Items into the "mass" variable that will be into the "black-hole" Tile Entity.

Thank you for your time.

Posted

I am definitely not an experienced modder. That said though, if I were you, I would start be creating an entity for your black hole. Have it collect certain entities that are nearby and change their motion towards the black hole and same with the item entities. Considering what black holes do in real life it should also damage the entities nearby too maybe. You can add a counter to the black hole maybe to see how much stuff it has collected and have that add to the power of it. The closest vanilla thing to this idea would be in the explosion class in the world folder. It might be worthwhile to look there too.

 

All this said, I'm not that experienced of a modder though. If someone else comes along that's more experienced, their advice would be worth way more than mine.

Posted

There is not much to say here. Black hole should most certainly be an Entity (not a TileEntity like you wrote). You want to use its onUpdate method to gather entities around it and pull them into singularity's coords.

 

To get entities you can use world.getEntitiesWithAABB (might not be exact name) or just grab world.entityList and check each against distance to black hole. Pulling is a matter of math, so "have fun" :D

As to storing data - If you need your singularity to suck stuff and make it retrievable (meaning - it is 100% saved and can be pulled out from BH), then you want to implement IInventory and save it to Entity's (BH's) NBT. If not - simply destroy all EntityItems and other stuff and just add some number to counter (which will be field in BH's class.

As to rendering and size - you need to make your own Renderer (extend it) and register it to entity. Then in renderer you can use you BH Entity's field (e.g: "magnitude" based on sucked stuff) to properly resize BH.

As to containing BH with your stabilizer - simply check adjacent blocks (in onUpdate method) for your stabilizer.

 

Do note that all onUpdate actions (especially checking blocks around) doesn't need to happen every tick, but in this case (since BH aren't exacly your common everyday thing), you can really use as much computation as you like.

There is not really much to say here. Outside some GL rendering and vector Math, there is jsut basic entity modding.

1.7.10 is no longer supported by forge, you are on your own.

Posted

Using

World#getEntitiesWithinAABB(Entity.class, AxisAlignedBB)

to get all entities in th specified range. Than use some math to calculate the motionX/Y/Z for each entity to go to to th black hole. You could also increase the speed of the items based on how close it is to the black hole, by increasing the motionX/Y/Z.

 

If the entities are in a range of, lets say, 0.5 blocks, kill the Entity and add it's drops to the inventory of the black hole. You can calculate the 'force' of the black hole based on the amount of items in the inventory of the black hole.

 

Thaumcraft 4 has an aura node modifier that makes it suck in everything, so you could at the Thaumcraft 4 source code to get some inspiration.

 

You could, as americanman said, also damage entities, e.g. players,  if they are to close to the black hole.

 

Edit: I see Ernio was faster :D

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

@americanman I appreciate the fact you took your time to comment and try to help me, the rest doesn't matter.

 

@Ernio I am very very (very) bad at GL Rendering. I had a post some time ago and requested a OpenGL tutorial, coolAlias and diesiebien07 helped me out. However GLProgramming was very intense. I only have finished 2 chapters, and to be honest i still haven't tried anything on minecraft yet. I am not sure how would i render a black "circle" on the game =_=

 

EDIT: @lasgerrits, Is Thaumcraft 4 Open-Source? Hungry-Nodes Code and their custom renderer would help me out a lot, but i can't seem to find it on github. I can only find Thaumcraft 4 API.

Posted

EDIT: @lasgerrits, Is Thaumcraft 4 Open-Source? Hungry-Nodes Code and their custom renderer would help me out a lot, but i can't seem to find it on github. I can only find Thaumcraft 4 API.

 

Every version of Thaumcraft is closed-source.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

This is the code that i used:

 

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);
}

}

 

Everything except for the explosion is working. But this is a tile-entity. I will have to create an entity and hopefully find a way to render a god damn circle.

Posted

EDIT: @lasgerrits, Is Thaumcraft 4 Open-Source? Hungry-Nodes Code and their custom renderer would help me out a lot, but i can't seem to find it on github. I can only find Thaumcraft 4 API.

 

Every version of Thaumcraft is closed-source.

 

There is also this thing called JD-GUI or Fernflower. ("Fernflower"?)

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.

Posted

You made a mistake here:

worldObj.createExplosion(null, this.getPos().getX(), this.getPos().getY(), 
				this.getPos().getZ(), 100F, true);

 

The first param is YOUR entity, if it is null it will not work. If it is in your Entity class put "this" instead of "null". If it is not, get an instance of your Entity class to pass in it. :P

 

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

One more thing that i want to ask. Which uses up more resources:

Checking each tick for blocks around my black hole

Or checking each tick for entities around my block.

 

EDIT: @HappyKiller101 derping everywhere  :D, thanks for letting me know, probably saved me some time

Posted

Both use the same. They both check the same amount of ticks, so they both use the same amount of processing power. Unless of course, you're talking about which one would find less items?

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Both use the same. They both check the same amount of ticks, so they both use the same amount of processing power. Unless of course, you're talking about which one would find less items?

Yeah, that's what i meant

Posted

Well, you would honestly have to check for both. Solid blocks would have to be turned into entities before moving. And, everything besides a solid block IS an entity. So, if you want which one takes up less power; it would be the block checker. But, no matter what, you'll need both. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

I already finished the sucking part. Still haven't gotten into the rendering. But now i want to give my black hole another abillity. I want my black hole to suck the blocks around it aswell. Now for something to exist in world it should either be a block or an entity. Now, you can't give blocks any motion. At least i am not aware of a way to give a block a motion. So what i was wondering is that i should add a timer to the blackhole so each 4-8 seconds destroys about 40 blocks around it at random. By destroying them, the blocks will drop their EntityItem. I can give motion to that. But it would be more "cool-looking" if these EntityItems would have a size of a block. Can you resize/scale an existing entity? Or there is another way to achieve what i want.

Posted

Sand blocks spawn an EntityFallingSand when they fall. You can set the block to air at the original position, and spawn a new EntityFallingSand(World,X,Y,Z,Block,metadata) with motion in the world.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Sand blocks spawn an EntityFallingSand when they fall. You can set the block to air at the original position, and spawn a new EntityFallingSand(World,X,Y,Z,Block,metadata) with motion in the world.

 

That's very smart thinking. I am guessing you can do the same with gravel. Thank you for the idea  ;)

Posted

There is no EntityFallingGravel. It uses the same EntityFallingSand.

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.

Posted

There is no EntityFallingSand on my IDE. The only thing that my IDE can find about "Falling" is EntityFallingBlock. Is that the same? I am working on forge-1.8-11.14.3.1450.

Posted

There is no EntityFallingSand on my IDE. The only thing that my IDE can find about "Falling" is EntityFallingBlock. Is that the same? I am working on forge-1.8-11.14.3.1450.

 

That's the one. It isn't called "sand" anymore because it now handles any and every block.

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.

Posted

Just jumped into the rendering bits, and troubles already.

First of things, i couldn't render a sphere with the knowledge that i currently have so i looked up jabelar's tutorial on how to render a sphere on minecraft. So props to him for the code. However i can't seem to find passSpecialRender method on my custom Render Class. I am working on 1.8 and i don't know which version of forge jabelar used on his tutorial at his blogspot so maybe there is no such method in 1.8

Any method that is equivalent to passSpecialRender ? I have mentioned before, i am not good at rendering, hence i am not aware of a lot of methods of rendering.

Posted

Do you really need a sphere? A billboarded circle will probably work quite well

 

Won't be able to generate a code for a circle on my own aswell. I am pretty sure of that. It is not about the shape. If i knew the "basics" or have an overall knowledge over the rendering i would be able to do this on my own. It's like knowing how a loop works so you can use that loop again in different situations.

Posted

A texture with a circle drawn on it and rendered so that it always faces the player doesn't require much know how, just a little trig

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.

Posted

A texture with a circle drawn on it and rendered so that it always faces the player doesn't require much know how, just a little trig

 

I don't know if i come up like an idiot if i say this, but i seriously have no idea :S

Really, i don't even know where to start. Trigonometry is fine for me. Just a pen and paper is enough to find out the perfect numbers. I just have no idea how to start the rendering process of something, anything. The only thing that i know about OpenGL is that it uses some primitives ( Lines, Points, Quads, Polygons ... ) to draw complex (in case of minecraft, very simple) objects. I don't know, however, how OpenGL does this.

Posted

Go look at the nametag code.

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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