Jump to content

Errors in EntityThrowable Child


Raebit

Recommended Posts

I'm using a tutorial to make a gun in 1.8, but I think some of the calls are from an older version. What should I use instead for lines 38 and 49?

 

Line 38: "getBlock(int, int, int) is undefined for Type World", "getBlockMetadata(int, int, int) is undefined for Type World", "SetBlocktoAir(Blockpos) is not applicable to the arguments (int, int, int)",  "The Method SetBlock is undefined by the Type World".

 

Line 49: spawnParticle is apparently not applicable to the arguments it lists.

 

 

package raebit.tutorial.inherited;

import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneDiode;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class EntityEMP extends EntityThrowable 
{
public static final float explosionPower = 0.75F;
public static final int empRadius = 4;

public EntityEMP(World world)
{
super(world);
}

public EntityEMP(World world, EntityLivingBase entity)
{
super(world, entity);
}

private void explode()
{	
int bx = (int)posX;
int by = (int)posY;
int bz = (int)posZ;
worldObj.createExplosion(this, posX, posY, posZ, (float) 0.75, true);

for (int x = bx - empRadius; x <= empRadius; x++)
{
for (int y = by - empRadius; y <= by + empRadius; y++)
{
for (int z = bz - empRadius; z <= bz + empRadius; z++) { Block block = worldObj.getBlock(x, y, z); if (block == Blocks.redstone_wire || block instanceof BlockRedstoneDiode) { block.dropBlockAsItem(worldObj, x, y, z, worldObj.getBlockMetadata(x, y, z), 0); worldObj.setBlockToAir(x, y, z); } if (block == Blocks.redstone_block) { worldObj.setBlock(x, y, z, Blocks.stone); } } } } setDead(); } @Override public void onUpdate() { super.onUpdate(); if (ticksExisted > 20)
{
explode();
}

for (int i = 0; i < 10; i++)
{
super.onUpdate();
double x = (double)(rand.nextInt(10) - 5) / 8.0D;
double y = (double)(rand.nextInt(10) - 5) / 8.0D;
double z = (double)(rand.nextInt(10) - 5) / 8.0D;
worldObj.spawnParticle("fireworksSpark", posX, posY, posZ, x, y, z);
}
}	

@Override
protected float getGravityVelocity()
{
return 0.005F;
}

@Override
public void onImpact(MovingObjectPosition movingObjectPosition)
{
explode();
}
}

Link to comment
Share on other sites

In 1.8 x/y/z are wrapped into BlockPos - you can just make new BlockPos(x, y, z).

Seriously - just look at literally any part of vanilla code, it's everywhere.

Same goes for particles - look at e.g TNT primed.

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

Link to comment
Share on other sites

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.