Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.