The Meaning of Life, the Universe, and Everything.
Location:
Sydney
Join Date:
7/11/2012
Posts:
49
Location:
Sydney, Australia
Minecraft:
Lydio_RLRPG
PSN:
Sonic_Agent
Member Details
Hi all!
I would like to be able to have a block that I have made only be active if on fire, which I assume means I need to check for if there is a fire block directly above my block? How would I go about doing this? I am quite new to modding, and I'm sure this knowledge will help tremendously in the future.
Also, once my block has fire on top of it, I would like all zombies to stop spawning within 50 blocks from my block. Again, how would I go about this?
Any and all help is appreciated
Thanks, Lydio
Rollback Post to RevisionRollBack
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
The Meaning of Life, the Universe, and Everything.
Location:
Sydney
Join Date:
7/11/2012
Posts:
49
Location:
Sydney, Australia
Minecraft:
Lydio_RLRPG
PSN:
Sonic_Agent
Member Details
Ok thanks
Just another query, how would I set it to tick randomly, and after that how would I go about checking if there are zombies within a 50 block radius?
Sorry, as I said I'm quite new to this.
Thanks again
EDIT: isBurning() doesn't seem to work that way :/. isBurning() seems to be if it should be set on fire and deal fire damage to entities coming into contact with it. It doesn't actually check if the block itself is on fire :/
I was also trying to do something similar to this. I managed to get the block to burn with a flint & steel, but then it burned up completely.
I couldn't figure out how to make it just have fire on it. My next stop was to look at how the netherrack blocks work, as they seem to burn for a long time and don't burn up, but I never got around to looking at those.
There are functions to find all nearby entities. Goes something like:
List entities = World#getEntitiesWithinAABBExcludingEntity(player, targetBox);
So you would find the x,y,z of the block, you set the bound box to be a square area around it, then call the function to find entities. You then go through the list checking them all for Zombies. You can move them away with another function.
So like I show above, the getBoundingBox requires x,y,z for the upper left corner and x,y,z for the lower right. So say if you have a box at 100, 64, 100, you would subtract 50 from x & z for the first set and add 50 for the 2nd. For the y, you might want to do 32, so like:
For the getEntities ... method, you need a reference to the player for the first parameter, the 2nd is just the return value of the above function, for which I used the targetBox variable.
So it returns all the entities in the list found in the box described by the above function.
The Meaning of Life, the Universe, and Everything.
Location:
Sydney
Join Date:
7/11/2012
Posts:
49
Location:
Sydney, Australia
Minecraft:
Lydio_RLRPG
PSN:
Sonic_Agent
Member Details
So.... one problem. For the List entities = World.getEntitiesWithinAABBExcludingEntity (player, targetBox); method, it says it can't make a static reference to a non-static method. Any ideas? Also, how would I make it find only zombies then kill them as soon as it found them? Thanks
Rollback Post to RevisionRollBack
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
But again, the 'World.getEntitiesWithinAABBExcludingEntity (player, targetBox);' method throws an error for making a static reference to a non-static method. This method is non-static, but I'm not sure how to make a non-static reference.
Yes, so I don't see where you declare "this.entities", but that needs to be a list, it contains a list of entities, so you cant go entities.setDead(), as that isn't referencing a single entity.
You need to do a bit more here. Now if you want to get fancy, you could sort the list by the closest and kill those first, but since you want to kill them all, just try something like:
for (int i = 0; i < entities.size(); i++) {
if (entities.get(i) instanceof EntityZombie)
entities.get(i).setDead(); // Cast this to the (EntityZombie)
Hi all!
I would like to be able to have a block that I have made only be active if on fire, which I assume means I need to check for if there is a fire block directly above my block? How would I go about doing this? I am quite new to modding, and I'm sure this knowledge will help tremendously in the future.
Also, once my block has fire on top of it, I would like all zombies to stop spawning within 50 blocks from my block. Again, how would I go about this?
Any and all help is appreciated
Thanks, Lydio
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
I think you could set the block to tick randomly and during the method that handles the tick you could just check for whatever you want.
To check for burning I think the block itself has method called isBurning() that says whether it is currently oh fire.
I think you could set the block to tick randomly and during the method that handles the tick you could just check for whatever you want.
To check for burning I think the block itself has method called isBurning() that says whether it is currently on fire.
Ok thanks
Just another query, how would I set it to tick randomly, and after that how would I go about checking if there are zombies within a 50 block radius?
Sorry, as I said I'm quite new to this.
Thanks again
EDIT: isBurning() doesn't seem to work that way :/. isBurning() seems to be if it should be set on fire and deal fire damage to entities coming into contact with it. It doesn't actually check if the block itself is on fire :/
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
I was also trying to do something similar to this. I managed to get the block to burn with a flint & steel, but then it burned up completely.
I couldn't figure out how to make it just have fire on it. My next stop was to look at how the netherrack blocks work, as they seem to burn for a long time and don't burn up, but I never got around to looking at those.
There are functions to find all nearby entities. Goes something like:
AxisAlignedBB targetBox = AxisAlignedBB.getBoundingBox(
message.x-0.5D,
message.y-0.0D,
message.z-0.5D,
message.x+0.5D,
message.y+1.5D,
message.z+0.5D
List entities = World#getEntitiesWithinAABBExcludingEntity(player, targetBox);
So you would find the x,y,z of the block, you set the bound box to be a square area around it, then call the function to find entities. You then go through the list checking them all for Zombies. You can move them away with another function.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
Ok thanks. What are the parameters for these functions that I plug into the method?
(also, if you would like to set the block to burn infinitely, simply override the isFireSource() method. :3)
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
So like I show above, the getBoundingBox requires x,y,z for the upper left corner and x,y,z for the lower right. So say if you have a box at 100, 64, 100, you would subtract 50 from x & z for the first set and add 50 for the 2nd. For the y, you might want to do 32, so like:
AxisAlignedBB.getBoundingBox(50,32,50, 150,96,150)
For the getEntities ... method, you need a reference to the player for the first parameter, the 2nd is just the return value of the above function, for which I used the targetBox variable.
So it returns all the entities in the list found in the box described by the above function.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
So would this be okay?
EntityPlayer player;
AxisAlignedBB targetBox = AxisAlignedBB.fromBounds(
this.minX-50D,
this.minY-32D,
this.minZ-50D,
this.maxX+50D,
this.maxY+32D,
this.maxZ+50D);
List entities = World.getEntitiesWithinAABBExcludingEntity (player, targetBox);
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
So I would just replace fromBounds() to getBoundingBox()?
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
Hmm. It seems that the getBoundingBox method isn't in the AxisAlignedBB class :/
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
Ok thanks :3
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
So.... one problem. For the List entities = World.getEntitiesWithinAABBExcludingEntity (player, targetBox); method, it says it can't make a static reference to a non-static method. Any ideas? Also, how would I make it find only zombies then kill them as soon as it found them? Thanks
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
So in theory, this should work:
public void findZombies(EntityPlayer player){
AxisAlignedBB targetBox = AxisAlignedBB.fromBounds(
this.minX-50D,
this.minY-32D,
this.minZ-50D,
this.maxX+50D,
this.maxY+32D,
this.maxZ+50D);
this.entities = World.getEntitiesWithinAABBExcludingEntity (player, targetBox);
if (entities instanceof EntityZombie){
((EntityZombie) entities).setDead();
}
}
But again, the 'World.getEntitiesWithinAABBExcludingEntity (player, targetBox);' method throws an error for making a static reference to a non-static method. This method is non-static, but I'm not sure how to make a non-static reference.
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
Change this line from:
this.entities = World.getEntitiesWithinAABBExcludingEntity (player, targetBox);
To:
this.entities = player.worldObj.getEntitiesWithinAABBExcludingEntity (player, targetBox);
The World was a static variable, you needed a non-static one like above.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
It doesn't work :/ The zombies don't die even if they are right next to the block :/
Here's my code again:
AxisAlignedBB targetBox = AxisAlignedBB.fromBounds(
this.minX-50D,
this.minY-32D,
this.minZ-50D,
this.maxX+50D,
this.maxY+32D,
this.maxZ+50D);
this.entities = player.worldObj.getEntitiesWithinAABBExcludingEntity (player, targetBox);
if (entities instanceof EntityZombie){
((EntityZombie) entities).setDead();
}
}
Any ideas? :/
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
Yes, so I don't see where you declare "this.entities", but that needs to be a list, it contains a list of entities, so you cant go entities.setDead(), as that isn't referencing a single entity.
You need to do a bit more here. Now if you want to get fancy, you could sort the list by the closest and kill those first, but since you want to kill them all, just try something like:
for (int i = 0; i < entities.size(); i++) {
if (entities.get(i) instanceof EntityZombie)
entities.get(i).setDead(); // Cast this to the (EntityZombie)
}
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
I did declare public static List entities; furthur up in the class, I just forgot to put it in the spoiler sorry. I'll try this out thanks.
It still isn't working :/ This time I'll give the full class for the block just incase I'm doing something wrong further up in the code.
package lydio.mobeffigies.mod.blocks;
import java.util.List;
import scala.reflect.internal.Trees.This;
import lydio.mobeffigies.mod.MobEffigiesBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class ZombieEffigy extends Block{
public int spawnradius = 0;
public static List entities;
public ZombieEffigy(Material materialIn) {
super(materialIn);
this.blockHardness = 7F;
this.setTickRandomly(true);
}
public boolean isOpaqueCube()
{
return false;
}
public boolean isFullCube()
{
return true;
}
public Block setTickRandomly(boolean shouldTick)
{
this.needsRandomTick = shouldTick;
return this;
}
@Override
public boolean isFireSource(World world, BlockPos pos, EnumFacing side)
{
if (this == MobEffigiesBlocks.zombie_effigy && side == EnumFacing.UP)
{
return true;
}
if ((world.provider instanceof net.minecraft.world.WorldProviderEnd) && this == net.minecraft.init.Blocks.bedrock && side == EnumFacing.UP)
{
return true;
}
return false;
}
public void findZombies(EntityPlayer player){
AxisAlignedBB targetBox = AxisAlignedBB.fromBounds(
this.minX-50D,
this.minY-32D,
this.minZ-50D,
this.maxX+50D,
this.maxY+32D,
this.maxZ+50D);
this.entities = player.worldObj.getEntitiesWithinAABBExcludingEntity (player, targetBox);
for (int i = 0; i < entities.size(); i++) {
if (entities.get(i) instanceof EntityZombie)
((EntityZombie) entities.get(i)).setDead();
}
}
}
Thanks so much for your help so far guys. I really appreciate it.
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
Where are you calling the findZombies method from?
It needs to get called for it to do anything
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
I made it up... Is there a method in another class that finds entities? If not, how else would I call it? (Sorry, I am a huge newbie)
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.
What you are doing is fine, the problem is that you never call findZombies().
Please don't PM me asking for help, I will just redirect you to the appropriate forum, where there are others who are far more skilled than me.
This is not the signature you are looking for.
Banners and such things
Again, I'm not quite sure what you mean by 'call' :/ Sorry I'm still quite new to Java, so a quick explanation will do
Thanks
GENERATION 1: The first time you see this, copy it into your signature on any forum and subtract 1 from the generation. Social experiment.
Lol. Lolol. LoloLOL. LOLOLOLOLOLOLOLOLOLOLO- *clears throat*.