Mudballs are throwable once again

This commit is contained in:
Adubbz 2013-12-28 16:57:03 +11:00
parent 390e989cf9
commit 27515b2d51
4 changed files with 70 additions and 9 deletions

View File

@ -5,6 +5,7 @@ import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityBreakingFX;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.entity.RenderSnowball;
import biomesoplenty.api.BOPItemHelper;
import biomesoplenty.client.render.blocks.BambooRenderer;
import biomesoplenty.client.render.blocks.FoliageRenderer;
@ -14,6 +15,7 @@ import biomesoplenty.client.render.blocks.RenderUtils;
import biomesoplenty.client.render.blocks.SmallBlockRenderer;
import biomesoplenty.client.render.entities.RenderDart;
import biomesoplenty.common.entities.projectiles.EntityDart;
import biomesoplenty.common.entities.projectiles.EntityMudball;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class ClientProxy extends CommonProxy
@ -37,6 +39,7 @@ public class ClientProxy extends CommonProxy
RenderUtils.bambooModel = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerEntityRenderingHandler(EntityDart.class, new RenderDart());
RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, new RenderSnowball(BOPItemHelper.get("mudball"), 0));
RenderingRegistry.registerBlockHandler(new FoliageRenderer());
RenderingRegistry.registerBlockHandler(new PlantsRenderer());
@ -52,11 +55,11 @@ public class ClientProxy extends CommonProxy
Random rand = new Random();
/*if (string == "mud")
if (string == "mud")
{
entityfx = new EntityBreakingFX(mc.theWorld, x, y, z, Items.mudball.get());
entityfx = new EntityBreakingFX(minecraft.theWorld, x, y, z, BOPItemHelper.get("mudball"));
}
else*/ if (string == "dart")
else if (string == "dart")
{
entityfx = new EntityBreakingFX(minecraft.theWorld, x, y, z, BOPItemHelper.get("dart"), 0);
}

View File

@ -3,6 +3,7 @@ package biomesoplenty.common.core;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.common.configuration.BOPConfigurationIDs;
import biomesoplenty.common.entities.projectiles.EntityDart;
import biomesoplenty.common.entities.projectiles.EntityMudball;
import cpw.mods.fml.common.registry.EntityRegistry;
public class BOPEntities
@ -15,5 +16,6 @@ public class BOPEntities
private static void registerEntities()
{
EntityRegistry.registerModEntity(EntityDart.class, "dart", BOPConfigurationIDs.entityDartID, BiomesOPlenty.instance, 80, 3, true);
EntityRegistry.registerModEntity(EntityMudball.class, "mudball", BOPConfigurationIDs.entityMudballID, BiomesOPlenty.instance, 80, 3, true);
}
}

View File

@ -0,0 +1,55 @@
package biomesoplenty.common.entities.projectiles;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.ClientProxy;
public class EntityMudball extends EntityThrowable
{
boolean isClient = BiomesOPlenty.proxy instanceof ClientProxy;
public EntityMudball(World world)
{
super(world);
}
public EntityMudball(World world, EntityLivingBase entityLivingBase)
{
super(world, entityLivingBase);
}
public EntityMudball(World world, double x, double y, double z)
{
super(world, x, y, z);
}
@Override
protected void onImpact(MovingObjectPosition movingObjectPosition)
{
if (movingObjectPosition.entityHit != null)
{
movingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0);
if (movingObjectPosition.entityHit instanceof EntityLivingBase)
{
((EntityLivingBase)movingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 400, 2));
}
}
for (int i = 0; i < 16; ++i)
{
BiomesOPlenty.proxy.spawnParticle("mud", posX, posY, posZ);
}
if (!worldObj.isRemote)
{
this.setDead();
}
}
}

View File

@ -6,12 +6,13 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.common.entities.projectiles.EntityMudball;
public class ItemBOPMudball extends Item
{
public ItemBOPMudball()
{
setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
this.setCreativeTab(BiomesOPlenty.tabBiomesOPlenty);
}
@Override
@ -21,18 +22,18 @@ public class ItemBOPMudball extends Item
}
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World par2World, EntityPlayer par3EntityPlayer)
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
if (!par3EntityPlayer.capabilities.isCreativeMode)
if (!player.capabilities.isCreativeMode)
{
--itemStack.stackSize;
}
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!par2World.isRemote)
if (!world.isRemote)
{
//TODO: FEATURE par2World.spawnEntityInWorld(new EntityMudball(par2World, par3EntityPlayer));
world.spawnEntityInWorld(new EntityMudball(world, player));
}
return itemStack;