下面列出了net.minecraft.util.EntitySelectors#net.minecraft.init.SoundEvents 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
boolean flag = playerIn.capabilities.isCreativeMode;
if (flag || playerIn.getHeldItem(handIn).getItemDamage() <= playerIn.getHeldItem(handIn).getMaxDamage())
{
if (!worldIn.isRemote)
{
boolean isSpawnChunk = playerIn.dimension == TofuMain.TOFU_DIMENSION.getId() || EntityTofuSlime.isSpawnChunk(playerIn.world, playerIn.posX, playerIn.posZ);
if(isSpawnChunk) playerIn.sendMessage(new TextComponentTranslation("tofucraft.radar.result.success", new Object()));
else playerIn.sendMessage(new TextComponentTranslation("tofucraft.radar.result.failed", new Object()));
}
if (!playerIn.capabilities.isCreativeMode && playerIn.getHeldItem(handIn).isItemStackDamageable())
{
playerIn.getHeldItem(handIn).damageItem(1, playerIn);
}
playerIn.playSound(SoundEvents.UI_BUTTON_CLICK, 0.5F, 1.0F);
}
return super.onItemRightClick(worldIn, playerIn, handIn);
}
@Override
public void updateTask() {
super.updateTask();
this.tofunian.getLookHelper().setLookPosition((double) this.destinationBlock.getX() + 0.5D, (double) (this.destinationBlock.getY()), (double) this.destinationBlock.getZ() + 0.5D, 10.0F, (float) this.tofunian.getVerticalFaceSpeed());
if (this.getIsAboveDestination()) {
++tick;
if (tick % 10 == 0) {
this.tofunian.swingArm(EnumHand.MAIN_HAND);
}
if (tick == 60) {
this.findSoy().shrink(1);
this.tofunian.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.6F, 0.65F);
this.makeFood();
if (!this.tofunian.hasEnoughCraftedItem(2, 0) && !this.findSoy().isEmpty()) {
tick = 0;
}
}
}
}
public void explode(World world, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
if (!world.isRemote) {
if (((Boolean) state.getValue(EXPLODE)).booleanValue()) {
// EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldIn,
// (double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() +
// 0.5F), (double)((float)pos.getZ() + 0.5F), igniter);
// worldIn.spawnEntityInWorld(entitytntprimed);
// worldIn.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F,
// 1.0F);
EntityPrimedCharge entity = new EntityPrimedCharge(this, world, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
world.spawnEntity(entity);
world.playSound((EntityPlayer)null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1, 1);
world.updateEntity(entity);
}
}
}
private void signContract(ItemStack stack, EntityPlayer oldOwner, EntityLivingBase target)
{
NBTTagCompound nbt = NBTUtils.getCompoundTag(stack, null, true);
UUID uuidOwner = oldOwner.getUniqueID();
nbt.setLong("OwnerM", uuidOwner.getMostSignificantBits());
nbt.setLong("OwnerL", uuidOwner.getLeastSignificantBits());
UUID uuidTarget = target.getUniqueID();
nbt.setLong("OwnableM", uuidTarget.getMostSignificantBits());
nbt.setLong("OwnableL", uuidTarget.getLeastSignificantBits());
nbt.setFloat("Health", target.getHealth());
String str = EntityList.getEntityString(target);
if (str != null)
{
nbt.setString("EntityString", str);
}
if (target.hasCustomName())
{
nbt.setString("CustomName", target.getCustomNameTag());
}
oldOwner.getEntityWorld().playSound(null, oldOwner.getPosition(), SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 0.5f, 1f);
}
protected static void registerMaterial(String name, MetalMaterial m){
allMaterials.put(name, m);
String enumName = m.getEnumName();
String texName = m.getName();
int[] protection = m.getDamageReductionArray();
int durability = m.getArmorMaxDamageFactor();
ArmorMaterial am = EnumHelper.addArmorMaterial(enumName, texName, durability, protection, m.getEnchantability(), SoundEvents.ITEM_ARMOR_EQUIP_IRON, (m.hardness > 10 ? (int)(m.hardness / 5) : 0));
if(am == null){
// uh-oh
FMLLog.severe("Failed to create armor material enum for "+m);
}
armorMaterialMap.put(m, am);
FMLLog.info("Created armor material enum "+am);
ToolMaterial tm = EnumHelper.addToolMaterial(enumName, m.getToolHarvestLevel(), m.getToolDurability(), m.getToolEfficiency(), m.getBaseAttackDamage(), m.getEnchantability());
if(tm == null){
// uh-oh
FMLLog.severe("Failed to create tool material enum for "+m);
}
toolMaterialMap.put(m, tm);
FMLLog.info("Created tool material enum "+tm);
}
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
if (entityLiving instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)entityLiving;
entityplayer.getFoodStats().addStats(this, stack);
worldIn.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F);
this.onFoodEaten(stack, worldIn, entityplayer);
entityplayer.addStat(StatList.getObjectUseStats(this));
if (entityplayer instanceof EntityPlayerMP)
{
CriteriaTriggers.CONSUME_ITEM.trigger((EntityPlayerMP)entityplayer, stack);
}
}
return new ItemStack(Items.GLASS_BOTTLE);
}
protected void attackWithPotion(EntityLivingBase target) {
double targetY = target.posY + (double) target.getEyeHeight() - 1.100000023841858D;
double targetX = target.posX + target.motionX - this.posX;
double d2 = targetY - this.posY;
double targetZ = target.posZ + target.motionZ - this.posZ;
float f = MathHelper.sqrt(targetX * targetX + targetZ * targetZ);
PotionType potiontype = PotionTypes.HARMING;
if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS)) {
potiontype = PotionTypes.SLOWNESS;
} else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON)) {
potiontype = PotionTypes.POISON;
} else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F) {
potiontype = PotionTypes.WEAKNESS;
}
EntityPotion entitypotion = new EntityPotion(this.world, this,
PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
entitypotion.rotationPitch -= -20.0F;
entitypotion.shoot(targetX, d2 + (double) (f * 0.2F), targetZ, 0.75F, 8.0F);
this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F,
0.8F + this.rand.nextFloat() * 0.4F);
this.world.spawnEntity(entitypotion);
}
public void sheath_In(EntityPlayer player) {
ItemStack item_l = player.getHeldItemMainhand();
ItemStack item_r = player.getHeldItemOffhand();
if(item_r.getItem()==ItemLoader.KATANA){
player.playSound(SoundEvents.BLOCK_ANVIL_HIT, 1F, 1F);
player.setHeldItem(EnumHand.MAIN_HAND, ItemLoader.KATANA_SHEATH.setBlade(item_r));
player.setHeldItem(EnumHand.OFF_HAND, ItemStack.EMPTY);
}else if(item_r.getItem()==ItemLoader.SAKURAKATANA){
player.playSound(SoundEvents.BLOCK_ANVIL_HIT, 1F, 1F);
player.setHeldItem(EnumHand.MAIN_HAND, ItemLoader.SAKURAKATANA_SHEATH.setBlade(item_r));
player.setHeldItem(EnumHand.OFF_HAND, ItemStack.EMPTY);
}else if(item_l.getItem()==ItemLoader.KATANA){
player.playSound(SoundEvents.BLOCK_ANVIL_HIT, 1F, 1F);
player.setHeldItem(EnumHand.OFF_HAND, ItemLoader.KATANA_SHEATH.setBlade(item_l));
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
}else if(item_l.getItem()==ItemLoader.SAKURAKATANA){
player.playSound(SoundEvents.BLOCK_ANVIL_HIT, 1F, 1F);
player.setHeldItem(EnumHand.OFF_HAND, ItemLoader.SAKURAKATANA_SHEATH.setBlade(item_l));
player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY);
}
}
private boolean tryToggleLocked(ItemStack stack)
{
if (ItemEnderPart.itemMatches(stack, ItemPartType.STORAGE_KEY))
{
this.itemHandlerLockable.setTemplateStackInSlot(0, this.itemHandlerLockable.getStackInSlot(0));
this.itemHandlerLockable.toggleSlotLocked(0);
int[] ints = new int[] { this.itemHandlerLockable.isSlotLocked(0) ? 1 : 0 };
ItemStack[] stacks = new ItemStack[] { this.itemHandlerLockable.getTemplateStackInSlot(0) };
this.sendPacketToWatchers(new MessageSyncTileEntity(this.getPos(), ints, stacks));
this.getWorld().playSound(null, this.getPos(), SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, SoundCategory.BLOCKS, 0.7f, 1f);
return true;
}
return false;
}
@Listener
public void receivePacket(EventReceivePacket event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
if (event.getPacket() instanceof SPacketSoundEffect) {
final SPacketSoundEffect packet = (SPacketSoundEffect) event.getPacket();
if (packet.getCategory() == SoundCategory.BLOCKS && packet.getSound() == SoundEvents.ENTITY_GENERIC_EXPLODE) {
for (Entity e : Minecraft.getMinecraft().world.loadedEntityList) {
if (e != null && e instanceof EntityEnderCrystal) {
if (e.getDistance(packet.getX(), packet.getY(), packet.getZ()) <= 6.0f) {
e.setDead();
}
}
}
}
}
}
}
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos)
{
boolean powered = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(pos.up());
if (powered)
{
if(!state.getValue(POWERED))
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
worldIn.setBlockState(pos, state.withProperty(POWERED, true));
worldIn.playSound(null, pos, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.BLOCKS, 1F, 0.25F + worldIn.rand.nextFloat());
}
}
else
{
if(state.getValue(POWERED))
{
worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
worldIn.setBlockState(pos, state.withProperty(POWERED, false));
worldIn.playSound(null, pos, SoundEvents.BLOCK_NOTE_BASEDRUM, SoundCategory.BLOCKS, 1F, 0.25F + worldIn.rand.nextFloat());
}
}
}
/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/
@Override
public void onPlayerStoppedUsing(ItemStack itemStack, World world, EntityLivingBase player, int itemInUseCount) {
if (ElectricItem.manager.getCharge(itemStack) >= 100) {
int i = this.getMaxItemUseDuration(itemStack) - itemInUseCount;
float damge = (float) i / 20.0F;
damge = (damge * damge + damge * 2.0F) / 3.0F;
if ((double)damge < 0.1D) {
return;
}
if (damge > 1.0F) {
damge = 1.0F;
}
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT,
SoundCategory.PLAYERS, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + damge * 0.5F);
if (!(player instanceof EntityPlayer
&& ((EntityPlayer) player).capabilities.isCreativeMode)) {
ElectricItem.manager.discharge(itemStack, 100, this.tier, false, true, false);
}
if (!world.isRemote) {
world.spawnEntity(new EntityRay(world, player, damge * 2.0F));
}
}
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack heldStack = player.getHeldItem(hand);
if (!player.capabilities.isCreativeMode) heldStack.shrink(1);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_SKELETON_DEATH, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
if (!world.isRemote) {
WorldInfo worldinfo = world.getWorldInfo();
worldinfo.setCleanWeatherTime(0);
worldinfo.setRainTime(1200);
worldinfo.setThunderTime(1200);
worldinfo.setRaining(true);
worldinfo.setThundering(false);
} else player.sendMessage(new TextComponentString("Dark clouds start forming in the sky"));
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, heldStack);
}
@Override
protected void playStepSound(BlockPos pos, Block blockIn) {
if (!blockIn.getDefaultState().getMaterial().isLiquid()) {
SoundType soundtype = blockIn.getSoundType(blockIn.getDefaultState(), this.world, pos, this);
if (this.world.getBlockState(pos.up()).getBlock() == Blocks.SNOW_LAYER) {
soundtype = Blocks.SNOW_LAYER.getSoundType(Blocks.SNOW_LAYER.getDefaultState(), this.world, pos, this);
}
if (this.isBeingRidden()) {
++this.gallopTime;
if (this.gallopTime > 5 && this.gallopTime % 3 == 0) {
this.playGallopSound(soundtype);
} else if (this.gallopTime <= 5) {
this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
} else if (soundtype == SoundType.WOOD) {
this.playSound(SoundEvents.ENTITY_HORSE_STEP_WOOD, soundtype.getVolume() * 0.15F, soundtype.getPitch());
} else {
this.playSound(SoundEvents.ENTITY_HORSE_STEP, soundtype.getVolume() * 0.15F, soundtype.getPitch());
}
}
}
protected boolean teleportTo(double x, double y, double z)
{
EnderTeleportEvent event = new EnderTeleportEvent(this, x, y, z, 0);
if (MinecraftForge.EVENT_BUS.post(event))
{
return false;
}
boolean success = this.attemptTeleport(event.getTargetX(), event.getTargetY(), event.getTargetZ());
if (success)
{
this.getEntityWorld().playSound(null, this.prevPosX, this.prevPosY, this.prevPosZ,
SoundEvents.ENTITY_ENDERMEN_TELEPORT, this.getSoundCategory(), 1.0F, 1.0F);
}
return success;
}
protected void tryDoVenting() {
BlockPos machinePos = metaTileEntity.getPos();
EnumFacing ventingSide = getVentingSide();
BlockPos ventingBlockPos = machinePos.offset(ventingSide);
IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos);
if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) {
metaTileEntity.getWorld()
.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET)
.forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f));
WorldServer world = (WorldServer) metaTileEntity.getWorld();
double posX = machinePos.getX() + 0.5 + ventingSide.getFrontOffsetX() * 0.6;
double posY = machinePos.getY() + 0.5 + ventingSide.getFrontOffsetY() * 0.6;
double posZ = machinePos.getZ() + 0.5 + ventingSide.getFrontOffsetZ() * 0.6;
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ,
7 + world.rand.nextInt(3),
ventingSide.getFrontOffsetX() / 2.0,
ventingSide.getFrontOffsetY() / 2.0,
ventingSide.getFrontOffsetZ() / 2.0, 0.1);
world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
setNeedsVenting(false);
} else if (!ventingStuck) {
setVentingStuck(true);
}
}
private void generateSteam() {
if(currentTemperature >= 100) {
if (getTimer() % getBoilingCycleLength() == 0) {
int fillAmount = (int) (baseSteamOutput * (currentTemperature / (getMaxTemperate() * 1.0)));
boolean hasDrainedWater = waterFluidTank.drain(1, true) != null;
int filledSteam = 0;
if (hasDrainedWater) {
filledSteam = steamFluidTank.fill(ModHandler.getSteam(fillAmount), true);
}
if (this.hasNoWater && hasDrainedWater) {
getWorld().setBlockToAir(getPos());
getWorld().createExplosion(null,
getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
2.0f, true);
} else this.hasNoWater = !hasDrainedWater;
if (filledSteam == 0 && hasDrainedWater) {
getWorld().playSound(null, getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
steamFluidTank.drain(4000, true);
}
}
} else {
this.hasNoWater = false;
}
}
public boolean isConvertingToolItem() {
ItemStack inputStack = this.getStackInSlot(slotInput);
int level = GTHelperStack.getItemStackEnchantmentLevel(inputStack);
if (level > 0 && !this.isFull()) {
int generate = world.rand.nextInt(20000 * level);
ItemStack blankTool = inputStack.copy();
blankTool.getTagCompound().removeTag("ench");
if (!GTHelperStack.canMerge(blankTool, this.getStackInSlot(slotOutput))) {
return false;
}
this.addEnergy(generate);
this.setStackInSlot(slotOutput, StackUtil.copyWithSize(blankTool, this.getStackInSlot(slotOutput).getCount()
+ 1));
inputStack.shrink(1);
world.playSound((EntityPlayer) null, this.pos, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, 0.75F
+ world.rand.nextFloat());
return true;
}
return false;
}
public boolean isConvertingBookItem() {
ItemStack inputStack = this.getStackInSlot(slotInput);
int level = GTHelperStack.getBookEnchantmentLevel(inputStack);
if (level > 0 && !this.isFull()) {
int generate = world.rand.nextInt(20000 * level);
ItemStack blankBook = GTMaterialGen.get(Items.BOOK);
if (!GTHelperStack.canMerge(blankBook, this.getStackInSlot(slotOutput))) {
return false;
}
this.addEnergy(generate);
this.setStackInSlot(slotOutput, StackUtil.copyWithSize(blankBook, this.getStackInSlot(slotOutput).getCount()
+ 1));
inputStack.shrink(1);
world.playSound((EntityPlayer) null, this.pos, SoundEvents.BLOCK_PORTAL_AMBIENT, SoundCategory.BLOCKS, 0.5F, 0.75F
+ world.rand.nextFloat());
return true;
}
return false;
}
protected void handleDrinkingPotionUpdate() {
if (this.attackTimer-- <= 0) {
this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F,
0.8F + this.rand.nextFloat() * 0.4F);
this.setAggressive(false);
ItemStack itemstack = this.getHeldItemOffhand();
this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.EMPTY);
if (itemstack != null && itemstack.getItem() == Items.POTIONITEM) {
List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);
if (list != null) {
for (PotionEffect potioneffect : list) {
this.addPotionEffect(new PotionEffect(potioneffect));
}
}
}
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(MODIFIER);
}
}
@Override
public boolean onRightClickBlock(EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
ItemStack stack = player.getHeldItem(hand);
if (stack.isEmpty() == false && ItemEnderPart.itemMatches(stack, ItemPartType.CREATIVE_STORAGE_KEY))
{
this.setCreative(! this.isCreative());
this.markDirty();
this.notifyBlockUpdate(this.getPos());
this.getWorld().playSound(null, this.getPos(), SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, SoundCategory.BLOCKS, 0.7f, 1f);
return true;
}
return super.onRightClickBlock(player, hand, side, hitX, hitY, hitZ);
}
@SideOnly(Side.CLIENT)
@Override
public void randomTickDisplay(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
if (this.isActive) {
if (rand.nextInt(16) == 0) {
worldIn.playSound((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY()
+ 0.5F), (double) ((float) pos.getZ()
+ 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F
+ rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false);
}
for (int i = 0; i < 3; ++i) {
double d0 = (double) pos.getX() + rand.nextDouble();
double d1 = (double) pos.getY() + rand.nextDouble() * 0.5D + 0.5D;
double d2 = (double) pos.getZ() + rand.nextDouble();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
}
}
@Override
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand)
{
TileEntityEnderFurnace te = getTileEntitySafely(world, pos, TileEntityEnderFurnace.class);
if (te != null && te.isBurningLast)
{
Effects.spawnParticlesAround(world, EnumParticleTypes.PORTAL, pos, 2, rand);
if (rand.nextDouble() < 0.1D)
{
world.playSound((double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D,
SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
}
}
}
/**
* Called by a player entity when they collide with an entity
*/
public void onCollideWithPlayer(EntityPlayer par1EntityPlayer)
{
if (this.getEntityWorld().isRemote == false && this.isDead == false && this.inGround && this.arrowShake <= 0 && this.canBePickedUp != 0)
{
// Normal pick up to inventory
if (this.canBePickedUp == 1)
{
if (par1EntityPlayer.inventory.addItemStackToInventory(this.getArrowStack()))
{
this.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
par1EntityPlayer.onItemPickup(this, 1);
this.setDead();
}
}
// Creative mode fake pick up (no actual items given)
else if (this.canBePickedUp == 2)
{
this.playSound(SoundEvents.ENTITY_ITEM_PICKUP, 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
this.setDead();
}
}
}
@SubscribeEvent
public void handleSound(PlaySoundAtEntityEvent event)
{
Entity e = event.getEntity();
if (e instanceof EntityPlayer && event.getSound() == SoundEvents.ENTITY_PLAYER_HURT && e.worldObj.isRemote)
{
if (didFall.contains(e.getEntityId()))
{
int numLegs = 0;
if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 2)))
{
numLegs++;
}
if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 3)))
{
numLegs++;
}
if (numLegs > 0)
{
event.setSound(SoundEvents.ENTITY_IRONGOLEM_HURT);
event.setPitch(event.getPitch() + 1F);
didFall.remove((Integer) e.getEntityId());
}
}
}
}
/**
* Updates the task
*/
public void updateTask() {
EntityLivingBase entitylivingbase = this.theEntity.getAttackTarget();
this.theEntity.getNavigator().clearPath();
this.theEntity.getLookHelper().setLookPositionWithEntity(entitylivingbase, 90.0F, 90.0F);
if (!this.theEntity.canEntityBeSeen(entitylivingbase)) {
this.theEntity.setAttackTarget((EntityLivingBase) null);
} else {
++this.tickCounter;
if (this.tickCounter == 0) {
this.theEntity.setTargetedEntity(this.theEntity.getAttackTarget().getEntityId());
// this.theEntity.world.setEntityState(this.theEntity,
// (byte) 21);
} else if (this.tickCounter >= this.theEntity.getAttackDuration()) {
float damage = 3.0F;
if (this.theEntity.world.getDifficulty() == EnumDifficulty.HARD) {
damage += 3.0F;
}
DamageSource ds = DamageSource.causeIndirectMagicDamage(this.theEntity, this.theEntity);
entitylivingbase.attackEntityFrom(ds, damage);
entitylivingbase.attackEntityFrom(DamageSource.causeMobDamage(this.theEntity),
(float) this.theEntity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue());
theEntity.attackedTarget = theEntity.getAttackTarget();
theEntity.setAttackTarget((EntityLivingBase) null);
theEntity.world.setEntityState(theEntity, (byte) 15);
theEntity.playSound(SoundEvents.ENTITY_GENERIC_EXPLODE, 1.0F, 1.0F / (theEntity.getRNG().nextFloat() * 0.4F + 0.8F));
}
super.updateTask();
}
}
@Override
public Void call() throws Exception
{
Entity targetEntity = Minecraft.getMinecraft().theWorld.getEntityByID(entityId);
if (targetEntity != null)
{
for (int i = 0; i < 25; i++)
{
Random rand = targetEntity.worldObj.rand;
targetEntity.worldObj.spawnParticle(EnumParticleTypes.SPELL, targetEntity.posX, targetEntity.posY + rand.nextFloat() * targetEntity.height, targetEntity.posZ,
(rand.nextFloat() - .5F) * .2F,
0,
(rand.nextFloat() - .5F) * .2F,
new int[] {255, 255, 255});
}
targetEntity.playSound(SoundEvents.ENTITY_FIREWORK_SHOOT, 1F, 1F);
if (targetEntity == Minecraft.getMinecraft().thePlayer)
{
HudHandler.addNotification(new NotificationInstance(targetEntity.ticksExisted, new DodgeNotification()));
}
}
return null;
}
/**
* Called when a Block is right-clicked with this Item
*/
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
ItemStack itemstack = player.getHeldItem(hand);
if (!player.canPlayerEdit(pos.offset(facing), facing, itemstack))
{
return EnumActionResult.FAIL;
}
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (facing != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && ((worldIn.getBlockState(pos).getMaterial() == Material.GROUND||worldIn.getBlockState(pos).getMaterial() ==Material.GRASS) && !(block instanceof BlockFarmland||block instanceof BlockGrassPath)))
{
IBlockState iblockstate1 = Blocks.GRASS_PATH.getDefaultState();
worldIn.playSound(player, pos, SoundEvents.BLOCK_GRASS_STEP, SoundCategory.BLOCKS, 1.2F, 1.2F);
worldIn.playSound(player, pos, SoundEvents.BLOCK_GRASS_PLACE, SoundCategory.BLOCKS, 1.2F, 1.2F);
if (!worldIn.isRemote)
{
worldIn.setBlockState(pos, iblockstate1, 11);
itemstack.damageItem(1, player);
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
@Override
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) {
int i = this.getMaxItemUseDuration(stack) - timeLeft;
if (i < 0) return;
entityLiving.swingArm(entityLiving.getActiveHand());
float f = (float) entityLiving.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
f += EnchantmentHelper.getModifierForCreature(stack, entityLiving.getCreatureAttribute()) / 1.2F;
float f1 = i / 15F;
f1 = (f1 * f1 + f1 * 2.0F) / 2F;
if(f1>8F) f1=8f;
float f3 = f1 + EnchantmentHelper.getSweepingDamageRatio(entityLiving) * f ;
float sweepingRatio = EnchantmentHelper.getSweepingDamageRatio(entityLiving);
for (Entity entitylivingbase : worldIn.getEntitiesWithinAABB(Entity.class, entityLiving.getEntityBoundingBox().grow(1.6D + sweepingRatio * 1.2D, 0.5D + sweepingRatio * 0.15D, 1.6D + sweepingRatio * 1.2D))) {
if (entitylivingbase != entityLiving && !entityLiving.isOnSameTeam(entitylivingbase)) {
if (entitylivingbase instanceof EntityLivingBase) {
f1 = f1/10;
((EntityLivingBase) entitylivingbase).knockBack(entityLiving, 0.4F + 0.6F * f1 * EnchantmentHelper.getSweepingDamageRatio(entityLiving), MathHelper.sin(entityLiving.rotationYaw * 0.017453292F), (-MathHelper.cos(entityLiving.rotationYaw * 0.017453292F)));
entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) entityLiving), f3);
}
if (entitylivingbase instanceof MultiPartEntityPart) {
entitylivingbase.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) entityLiving), f3);
}
}
}
worldIn.playSound(null, entityLiving.posX, entityLiving.posY, entityLiving.posZ, SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, entityLiving.getSoundCategory(), 1.0F, 1.0F);
if (worldIn instanceof WorldServer) {
double d0 = (-MathHelper.sin(entityLiving.rotationYaw * 0.017453292F));
double d1 = MathHelper.cos(entityLiving.rotationYaw * 0.017453292F);
((WorldServer) worldIn).spawnParticle(EnumParticleTypes.SWEEP_ATTACK, entityLiving.posX + d0, entityLiving.posY + entityLiving.height * 0.5D, entityLiving.posZ + d1, 0, d0, 0.0D, d1, 0.0D);
}
stack.damageItem(2, entityLiving);
((EntityPlayer) entityLiving).getCooldownTracker().setCooldown(this, 25);
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
double d0 = pos.getX() + 0.5D;
double d2 = pos.getZ() + 0.5D;
double d4 = rand.nextDouble() * 0.4D - 0.2D;
if (this.isBurning) {
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D);
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0 + d4, pos.getY() + 0.2D, d2 + d4, 0.0D, 0.0D, 0.0D);
if (rand.nextDouble() < 0.15D) {
worldIn.playSound(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
}
}
}