
Raebit
Members-
Posts
7 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
Personal Text
I am new!
Raebit's Achievements

Tree Puncher (2/8)
0
Reputation
-
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(); } }
-
I'm working on reverse engineering minecraft's code for EntityThrowable to make a basic gun I can learn from, but there is a problem with my indexing. How should I prepare this code to properly inherit from it's parent in eclipse? package raebit.tutorial.inherited; public class PlasmaGun extends EntityThrowable { import java.util.List; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public abstract class EntityThrowable extends Entity implements IProjectile { private int xTile = -1; private int yTile = -1; private int zTile = -1; private Block inTile; protected boolean inGround; public int throwableShake; /** The entity that threw this throwable item. */ private EntityLivingBase thrower; private String throwerName; private int ticksInGround; private int ticksInAir; private static final String __OBFID = "CL_00001723"; public EntityThrowable(World worldIn) { super(worldIn); this.setSize(0.25F, 0.25F); } protected void entityInit() {} /** * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge * length * 64 * renderDistanceWeight Args: distance */ @SideOnly(Side.CLIENT) public boolean isInRangeToRenderDist(double distance) { double d1 = this.getEntityBoundingBox().getAverageEdgeLength() * 4.0D; d1 *= 64.0D; return distance < d1 * d1; } public EntityThrowable(World worldIn, EntityLivingBase throwerIn) { super(worldIn); this.thrower = throwerIn; this.setSize(0.25F, 0.25F); this.setLocationAndAngles(throwerIn.posX, throwerIn.posY + (double)throwerIn.getEyeHeight(), throwerIn.posZ, throwerIn.rotationYaw, throwerIn.rotationPitch); this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); this.posY -= 0.10000000149011612D; this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); this.setPosition(this.posX, this.posY, this.posZ); float f = 0.4F; this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.getInaccuracy()) / 180.0F * (float)Math.PI) * f); this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.getVelocity(), 1.0F); } public EntityThrowable(World worldIn, double x, double y, double p_i1778_6_) { super(worldIn); this.ticksInGround = 0; this.setSize(0.25F, 0.25F); this.setPosition(x, y, p_i1778_6_); } protected float getVelocity() { return 1.5F; } protected float getInaccuracy() { return 0.0F; } /** * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. * * @param inaccuracy Higher means more error. */ public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { float f2 = MathHelper.sqrt_double(x * x + y * y + z * z); x /= (double)f2; y /= (double)f2; z /= (double)f2; x += this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy; y += this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy; z += this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy; x *= (double)velocity; y *= (double)velocity; z *= (double)velocity; this.motionX = x; this.motionY = y; this.motionZ = z; float f3 = MathHelper.sqrt_double(x * x + z * z); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI); this.ticksInGround = 0; } /** * Sets the velocity to the args. Args: x, y, z */ @SideOnly(Side.CLIENT) public void setVelocity(double x, double y, double z) { this.motionX = x; this.motionY = y; this.motionZ = z; if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(x * x + z * z); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f) * 180.0D / Math.PI); } } /** * Called to update the entity's position/logic. */ public void onUpdate() { this.lastTickPosX = this.posX; this.lastTickPosY = this.posY; this.lastTickPosZ = this.posZ; super.onUpdate(); if (this.throwableShake > 0) { --this.throwableShake; } if (this.inGround) { if (this.worldObj.getBlockState(new BlockPos(this.xTile, this.yTile, this.zTile)).getBlock() == this.inTile) { ++this.ticksInGround; if (this.ticksInGround == 1200) { this.setDead(); } return; } this.inGround = false; this.motionX *= (double)(this.rand.nextFloat() * 0.2F); this.motionY *= (double)(this.rand.nextFloat() * 0.2F); this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } else { ++this.ticksInAir; } Vec3 vec3 = new Vec3(this.posX, this.posY, this.posZ); Vec3 vec31 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec3, vec31); vec3 = new Vec3(this.posX, this.posY, this.posZ); vec31 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingobjectposition != null) { vec31 = new Vec3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } if (!this.worldObj.isRemote) { Entity entity = null; List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; EntityLivingBase entitylivingbase = this.getThrower(); for (int j = 0; j < list.size(); ++j) { Entity entity1 = (Entity)list.get(j); if (entity1.canBeCollidedWith() && (entity1 != entitylivingbase || this.ticksInAir >= 5)) { float f = 0.3F; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand((double)f, (double)f, (double)f); MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31); if (movingobjectposition1 != null) { double d1 = vec3.distanceTo(movingobjectposition1.hitVec); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } } if (movingobjectposition != null) { if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlockState(movingobjectposition.getBlockPos()).getBlock() == Blocks.portal) { this.setInPortal(); } else { this.onImpact(movingobjectposition); } } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; float f1 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f1) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { ; } while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; float f2 = 0.99F; float f3 = this.getGravityVelocity(); if (this.isInWater()) { for (int i = 0; i < 4; ++i) { float f4 = 0.25F; this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ, new int[0]); } f2 = 0.8F; } this.motionX *= (double)f2; this.motionY *= (double)f2; this.motionZ *= (double)f2; this.motionY -= (double)f3; this.setPosition(this.posX, this.posY, this.posZ); } /** * Gets the amount of gravity to apply to the thrown entity with each tick. */ protected float getGravityVelocity() { return 0.03F; } /** * Called when this EntityThrowable hits a block or entity. */ protected abstract void onImpact(MovingObjectPosition p_70184_1_); /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound tagCompound) { tagCompound.setShort("xTile", (short)this.xTile); tagCompound.setShort("yTile", (short)this.yTile); tagCompound.setShort("zTile", (short)this.zTile); ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(this.inTile); tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString()); tagCompound.setByte("shake", (byte)this.throwableShake); tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); if ((this.throwerName == null || this.throwerName.length() == 0) && this.thrower instanceof EntityPlayer) { this.throwerName = this.thrower.getName(); } tagCompound.setString("ownerName", this.throwerName == null ? "" : this.throwerName); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { this.xTile = tagCompund.getShort("xTile"); this.yTile = tagCompund.getShort("yTile"); this.zTile = tagCompund.getShort("zTile"); if (tagCompund.hasKey("inTile", ) { this.inTile = Block.getBlockFromName(tagCompund.getString("inTile")); } else { this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255); } this.throwableShake = tagCompund.getByte("shake") & 255; this.inGround = tagCompund.getByte("inGround") == 1; this.throwerName = tagCompund.getString("ownerName"); if (this.throwerName != null && this.throwerName.length() == 0) { this.throwerName = null; } } public EntityLivingBase getThrower() { if (this.thrower == null && this.throwerName != null && this.throwerName.length() > 0) { this.thrower = this.worldObj.getPlayerEntityByName(this.throwerName); } return this.thrower; } }
-
So I'm digging through the libraries and pulling out the code for the snowball to use as a base for a "learning by doing" test gun. I know that in 1.8 we need to make .json files for our textures and models. I've done that before. Aside from that, is there anything else I should consider in regards to coding the gun in 1.8? Also, am I forgetting any classes? So far I've pulled out the item class and the entity for the snowball. Will I also need to make my own utility classes like damage sources and object positions or will the minecraft classes work fine for a custom gun? I suppose that might be upto how in depth I want to go into making this gun. I don't want depth right now. I just want to make something very basic that will help me learn how the projectiles work and how the animations work. Not asking for code, just parameters and setup. Thanks in advance.
-
Thanks, both of you. I am studying Java and it is similar to other coding languages that I work with. The major thing for me now is just learning the calls and vocab. Could you please offer me the proper setup for the base mod in the newest version? I am having difficulty locating it.
-
So I'm trying to setup my base mod file in Eclipse using this tutorial http://www.minecraftforge.net/wiki/Tutorials/Making_the_base_mod_file. The problem I'm having is that certain parameters or functions are not being recognized as types. package gilgamesh.tutorialmod.common; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @Mod(modid = "tutorial", name = "Tutorial Mod", version = "1.0.0") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class mod_tutorial { @Instance("tutorial") public static mod_tutorial instance; @PreInit public void preInit(FMLPreInitializationEvent event) { } @Init public void init(FMLInitializationEvent event) { } @PostInit public static void postInit(FMLPostInitializationEvent event) { } } NetworkMod, PreInit, Init, and PostInit all "cannot be resolved to a type". Totally new to JAVA. I know I've done something wrong here.
-
So I am putting together a classic Doom (ID Developed FPS) map for a multiplayer server my brother and I are hosting. I am going to create a mod specifically for this server. I have worked with modding other games in the past and know other coding languages, but I have not touched JAVA yet. The first thing I would like to do with this mod is import and code the actual two dimensional monsters from the original Doom and Doom 2 games. Is this even possible? Can you code enemies and mobs that are sprites in mine craft? If yes, where should I start? Can you point me to a tutorial that will help me start on the track toward making this a reality? I am studying basic JAVA at the moment. I understand that I need this to even begin this undertaking. What is there, specifically, that can help me in achieving this? Thank you in advance for your time and help!