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.

z3r0_null

Members
  • Joined

  • Last visited

Everything posted by z3r0_null

  1. I thought of that, but it would be really convoluted to call it 12 times and replace the redstone for each of the redstone dusts used; i was wondering if there's a more elegant way, before using that method?
  2. I've written an item that requires an amount of redstone to be in the player's inventory, but I can't work out how to make it require and consume x redstone. What I want is: [*]Player uses item [*]Item checks if Player has 12 redstone or more in their inventory [*]If they do, remove 12 redstone form their inventory This is the code I'm using at the moment as a placeholder: if (entityplayer.capabilities.isCreativeMode || entityplayer.inventory.hasItem(Item.redstone.itemID)) { entityplayer.inventory.consumeInventoryItem(Item.redstone.itemID); }
  3. So do I instantiate the above class, or is it instantiated somewhere else in the game code?
  4. Thanks now to take a well-earned sleep, I've been hammering away at this mod for about 7 hours solid...
  5. Ah ok, that makes things a bit simpler! Could you provide a little snippet of example code for the rendering?
  6. I'm writing a mod in which the player can pick up blocks (turning them into EntityFallingSand) and fling them about. I've run into the problem that for some reason I can't seem to override the fact that EntityFallingSand always falls downward, regardless of what I write into my custom class to counteract it. Here is the item that I'm using to pick up blocks: package arcanepower.items; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntitySmallFireball; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; import arcanepower.ArcanePower; import arcanepower.entities.EarthBolt; import arcanepower.lib.ModInfo; import arcanepower.lib.Names; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class EarthWand extends WoodWand { private int targetBlock = -1; private MovingObjectPosition hitEnt; private int ix; private int iy; private int iz; private EarthBolt bolt; public EarthWand(int id) { super(id); setCreativeTab(ArcanePower.tabArcanePower); setUnlocalizedName(Names.earthWand_unlocalizedName); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister icon) { itemIcon = icon.registerIcon(ModInfo.ID.toLowerCase() + ":" + Names.earthWand_unlocalizedName); } public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { if (!world.isRemote) { if (targetBlock == -1) { if (world.getBlockMaterial(x, y, z) == Material.ground || world.getBlockMaterial(x, y, z) == Material.sand || world.getBlockMaterial(x, y, z) == Material.rock || world.getBlockMaterial(x, y, z) == Material.grass) { if (world.getBlockMaterial(x, y, z) == Material.grass) { targetBlock = Block.dirt.blockID; } ix = x; iy = y; iz = z; world.destroyBlock(x, y, z, false); bolt = new EarthBolt(world); bolt.blockID = targetBlock; bolt.metadata = world.getBlockMetadata(x, y, z); bolt.setTar(x + 0.5, y + 4, z + 0.5); bolt.setPosition(x + 0.5, y + 1, z + 0.5); world.spawnEntityInWorld(bolt); } else { System.out.println("Bad block type!"); } } else { float f = 1.0F; float f1 = entityplayer.prevRotationPitch + (entityplayer.rotationPitch - entityplayer.prevRotationPitch) * f; float f2 = entityplayer.prevRotationYaw + (entityplayer.rotationYaw - entityplayer.prevRotationYaw) * f; double d0 = entityplayer.prevPosX + (entityplayer.posX - entityplayer.prevPosX) * (double) f; double d1 = entityplayer.prevPosY + (entityplayer.posY - entityplayer.prevPosY) * (double) f + 1.62D - (double) entityplayer.yOffset; double d2 = entityplayer.prevPosZ + (entityplayer.posZ - entityplayer.prevPosZ) * (double) f; Vec3 vec3 = world.getWorldVec3Pool().getVecFromPool(d0, d1, d2); float f3 = MathHelper.cos(-f2 * 0.017453292F - (float) Math.PI); float f4 = MathHelper.sin(-f2 * 0.017453292F - (float) Math.PI); float f5 = -MathHelper.cos(-f1 * 0.017453292F); float f6 = MathHelper.sin(-f1 * 0.017453292F); float f7 = f4 * f5; float f8 = f3 * f5; double d3 = 60.0D; Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); hitEnt = world.rayTraceBlocks_do_do(vec3, vec31, false, true); } } return true; } public void onUpdate(ItemStack itemstack, World world, Entity entityplayer, int par4, boolean par5) { if (targetBlock != -1) { if (entityplayer.getDistance(ix, iy, iz) > 10) { System.out.println("Moved out of range, deselecting block."); bolt.setTar(ix, iy, iz); targetBlock = -1; } } } public void throwBolt(EarthBolt bolt, EntityPlayer entityplayer) { float f = 0.4F; bolt.motionX = (double) (-MathHelper.sin(entityplayer.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(entityplayer.rotationPitch / 180.0F * (float) Math.PI) * f); bolt.motionZ = (double) (MathHelper.cos(entityplayer.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(entityplayer.rotationPitch / 180.0F * (float) Math.PI) * f); bolt.motionY = (double) (-MathHelper.sin((entityplayer.rotationPitch) / 180.0F * (float) Math.PI) * f); } } Here is my custom Entity: package arcanepower.entities; import java.util.Random; import net.minecraft.entity.item.EntityFallingSand; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; public class EarthBolt extends EntityFallingSand { private EntityPlayer thrower; private float deltaPitch; private float deltaYaw; private double tarX; private double tarY; private double tarZ; private double deltaX; private double deltaY; private double deltaZ; public float speedMul = 10.0F; public EarthBolt(World world) { super(world); Random rand = new Random(); deltaPitch = -1 + rand.nextFloat() * 2; deltaYaw = -1 + rand.nextFloat() * 2; this.shouldDropItem = true; } @Override public void onUpdate() { Random rand = new Random(); worldObj.spawnParticle("smoke", this.posX - 0.5 + rand.nextDouble(), this.posY - 0.5 + rand.nextDouble(), this.posZ - 0.5 + rand.nextDouble(), 0, 0, 0); this.rotationPitch += deltaPitch; this.rotationYaw += deltaYaw; deltaX = (this.posX - tarX) * speedMul; deltaY = (this.posY - tarY) * speedMul; deltaZ = (this.posZ - tarZ) * speedMul; this.posX += deltaX; this.posY += deltaY; this.posZ += deltaZ; } public void setTar(double x, double y, double z) { tarX = x; tarY = y; tarZ = z; } } Many thanks in advance, I'm totally stumped at this.

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.