Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Copyright (C) 2016 Andrew Morin
- //Licensed under GNU GPL v3; see license.txt for complete license terms + conditions etc.
- package theishiopian.gunmod.entity;
- import net.minecraft.client.multiplayer.WorldClient;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.projectile.EntityThrowable;
- import net.minecraft.init.Blocks;
- import net.minecraft.init.SoundEvents;
- import net.minecraft.util.DamageSource;
- import net.minecraft.util.EnumParticleTypes;
- import net.minecraft.util.SoundCategory;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.util.math.RayTraceResult;
- import net.minecraft.util.math.RayTraceResult.Type;
- import net.minecraft.world.World;
- import net.minecraft.world.WorldServer;
- import java.util.Random;
- public class EntityBullet extends EntityThrowable
- {
- public EntityBullet(World world)
- {
- super(world);
- }
- public EntityBullet(World world, EntityLivingBase entity)
- {
- super(world, entity);
- this.ignoreEntity = entity;
- }
- public EntityBullet(World world, double x, double y, double z)
- {
- super(world, x, y, z);
- }
- @Override
- protected void onImpact(RayTraceResult result)
- {
- if(result.typeOfHit == Type.BLOCK)
- {
- if(!world.isRemote&&world.getBlockState(result.getBlockPos()).getBlockHardness(world, result.getBlockPos())>1)
- {
- ((WorldServer)world).spawnParticle(EnumParticleTypes.LAVA, true, posX, posY, posZ, 1, 0, 0, 0, 1, new int[0]);
- this.world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_ANVIL_FALL, SoundCategory.HOSTILE, 1, 1);
- }
- if(world.getBlockState(result.getBlockPos()).getCollisionBoundingBox(world, result.getBlockPos()) != null)setDead();
- }
- else if(result.entityHit != null)
- {
- result.entityHit.attackEntityFrom(DamageSource.GENERIC, 3);
- result.entityHit.hurtResistantTime = 0;
- setDead();
- }
- }
- @Override
- public void onUpdate()
- {
- super.onUpdate();
- if(this.ticksExisted>100)setDead();
- this.world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, new int[0]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement