use of stevekung.mods.moreplanets.utils.tileentity.TileEntityTreasureChestMP in project MorePlanets by SteveKunG.
the class EntityInfectedPurloniteSlimeBoss method onDeathUpdate.
@Override
protected void onDeathUpdate() {
++this.deathTicks;
if (this.deathTicks >= 180 && this.deathTicks <= 200) {
float f = (this.rand.nextFloat() - 0.5F) * 1.5F;
float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F;
float f2 = (this.rand.nextFloat() - 0.5F) * 1.5F;
this.world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + f, this.posY + 2.0D + f1, this.posZ + f2, 0.0D, 0.0D, 0.0D);
}
int i;
int j;
if (!this.world.isRemote) {
if (this.deathTicks >= 180 && this.deathTicks % 5 == 0) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_EXPLODE, GCCoreUtil.getDimensionID(this.world), new Object[] {}), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
}
if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
i = 120;
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
}
}
if (this.deathTicks == 40) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_BOSS_DEATH, GCCoreUtil.getDimensionID(this.world), new Object[] { this.getSoundPitch() - 0.1F }), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
}
}
if (this.deathTicks == 200 && !this.world.isRemote) {
i = 120;
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
}
TileEntityTreasureChestMP chest = null;
if (this.spawner != null && this.spawner.getChestPos() != null) {
TileEntity chestTest = this.world.getTileEntity(this.spawner.getChestPos());
if (chestTest != null && chestTest instanceof TileEntityTreasureChestMP) {
chest = (TileEntityTreasureChestMP) chestTest;
}
}
if (chest == null) {
chest = TileEntityTreasureChestMP.findClosest(this, MPItems.DIONA_DUNGEON_KEY);
} else {
double dist = this.getDistanceSq(chest.getPos().getX() + 0.5, chest.getPos().getY() + 0.5, chest.getPos().getZ() + 0.5);
if (dist < 1000 * 1000) {
if (!chest.locked) {
chest.locked = true;
}
int slot = this.rand.nextInt(chest.getSizeInventory());
chest.setLootTable(MPLootTables.COMMON_SPACE_DUNGEON, this.rand.nextLong());
chest.setInventorySlotContents(slot, MPLootTables.getTieredKey(this.rand, 4));
}
}
this.entityDropItem(new ItemStack(MPItems.DIONA_DUNGEON_KEY, 1, 0), 0.5F);
this.setDead();
if (this.spawner != null) {
this.spawner.isBossDefeated = true;
this.spawner.boss = null;
this.spawner.spawned = false;
}
}
}
use of stevekung.mods.moreplanets.utils.tileentity.TileEntityTreasureChestMP in project MorePlanets by SteveKunG.
the class EntityCheeseCubeEyeBoss method onDeathUpdate.
@Override
protected void onDeathUpdate() {
++this.deathTicks;
if (this.deathTicks >= 180 && this.deathTicks <= 200) {
float f = (this.rand.nextFloat() - 0.5F) * 1.5F;
float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F;
float f2 = (this.rand.nextFloat() - 0.5F) * 1.5F;
this.world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + f, this.posY + 2.0D + f1, this.posZ + f2, 0.0D, 0.0D, 0.0D);
}
int i;
int j;
if (!this.world.isRemote) {
if (this.deathTicks >= 180 && this.deathTicks % 5 == 0) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_EXPLODE, GCCoreUtil.getDimensionID(this.world), new Object[] {}), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
}
if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
i = 150;
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
}
}
if (this.deathTicks == 40) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_BOSS_DEATH, GCCoreUtil.getDimensionID(this.world), new Object[] { this.getSoundPitch() - 0.1F }), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
}
}
this.move(MoverType.SELF, 0.0D, -0.10000000149011612D, 0.0D);
if (this.deathTicks == 200 && !this.world.isRemote) {
i = 150;
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
}
TileEntityTreasureChestMP chest = null;
if (this.spawner != null && this.spawner.getChestPos() != null) {
TileEntity chestTest = this.world.getTileEntity(this.spawner.getChestPos());
if (chestTest != null && chestTest instanceof TileEntityTreasureChestMP) {
chest = (TileEntityTreasureChestMP) chestTest;
}
}
if (chest == null) {
chest = TileEntityTreasureChestMP.findClosest(this, MPItems.CHALOS_DUNGEON_KEY);
}
if (chest != null) {
double dist = this.getDistanceSq(chest.getPos().getX() + 0.5, chest.getPos().getY() + 0.5, chest.getPos().getZ() + 0.5);
if (dist < 1000 * 1000) {
if (!chest.locked) {
chest.locked = true;
}
int slot = this.rand.nextInt(chest.getSizeInventory());
chest.setLootTable(MPLootTables.COMMON_SPACE_DUNGEON, this.rand.nextLong());
chest.setInventorySlotContents(slot, MPLootTables.getTieredKey(this.rand, 4));
}
}
this.entityDropItem(new ItemStack(MPItems.CHALOS_DUNGEON_KEY, 1, 0), 0.5F);
super.setDead();
if (this.spawner != null) {
this.spawner.isBossDefeated = true;
this.spawner.boss = null;
this.spawner.spawned = false;
}
}
}
use of stevekung.mods.moreplanets.utils.tileentity.TileEntityTreasureChestMP in project MorePlanets by SteveKunG.
the class GeneralEventHandler method onRightClickBlock.
@SubscribeEvent
public void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
EntityPlayer player = event.getEntityPlayer();
World world = event.getWorld();
BlockPos pos = event.getPos();
ItemStack heldItem = event.getItemStack();
// Skip events triggered from Thaumcraft Golems and other non-players
if (player == null || pos == null || world == null) {
return;
}
if (!heldItem.isEmpty() && (heldItem.getItem() instanceof ItemSpade || heldItem.getItem().getToolClasses(heldItem) == Collections.singleton("shovel"))) {
if (event.getFace() != EnumFacing.DOWN && world.getBlockState(pos.up()).getMaterial() == Material.AIR) {
if (world.getBlockState(pos).getBlock() == MPBlocks.INFECTED_GRASS_BLOCK) {
if (!world.isRemote) {
world.playSound(null, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, MPBlocks.INFECTED_GRASS_PATH.getDefaultState(), 11);
heldItem.damageItem(1, player);
}
player.swingArm(event.getHand());
} else if (world.getBlockState(pos).getBlock() == MPBlocks.GREEN_VEIN_GRASS_BLOCK) {
if (!world.isRemote) {
world.playSound(null, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, MPBlocks.GREEN_VEIN_GRASS_PATH.getDefaultState(), 11);
heldItem.damageItem(1, player);
}
player.swingArm(event.getHand());
}
}
}
TileEntity tile = world.getTileEntity(pos);
if (tile != null && tile instanceof TileEntityTreasureChestMP && tile instanceof IDungeonKeyable) {
TileEntityTreasureChestMP chest = (TileEntityTreasureChestMP) tile;
IDungeonKeyable keyable = (IDungeonKeyable) tile;
if (chest.locked) {
if (!heldItem.isEmpty()) {
if (heldItem.getItem() instanceof IDungeonKey) {
event.setCanceled(keyable.onActivated(player, keyable.getDungeonKey(), true));
} else if (!player.isSneaking()) {
event.setCanceled(keyable.onActivated(player, keyable.getDungeonKey(), false));
}
} else {
event.setCanceled(keyable.onActivated(player, keyable.getDungeonKey(), false));
}
}
}
}
use of stevekung.mods.moreplanets.utils.tileentity.TileEntityTreasureChestMP in project MorePlanets by SteveKunG.
the class EntityMiniVeinFloater method onDeathUpdate.
@Override
protected void onDeathUpdate() {
++this.deathTicks;
if (this.deathTicks >= 180 && this.deathTicks <= 200) {
float f = (this.rand.nextFloat() - 0.5F) * 5.5F;
float f1 = (this.rand.nextFloat() - 0.5F) * 28.0F;
float f2 = (this.rand.nextFloat() - 0.5F) * 5.5F;
this.world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + f, this.posY + 2.0D + f1, this.posZ + f2, 0.0D, 0.0D, 0.0D);
}
int i;
int j;
if (!this.world.isRemote) {
if (this.deathTicks >= 180 && this.deathTicks % 5 == 0) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_EXPLODE, GCCoreUtil.getDimensionID(this.world), new Object[] {}), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
}
if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
i = 200;
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
}
}
if (this.deathTicks == 40) {
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_PLAY_SOUND_BOSS_DEATH, GCCoreUtil.getDimensionID(this.world), new Object[] { this.getSoundPitch() - 0.1F }), new TargetPoint(GCCoreUtil.getDimensionID(this.world), this.posX, this.posY, this.posZ, 40.0D));
}
}
if (this.deathTicks == 200 && !this.world.isRemote) {
i = 200;
while (i > 0) {
j = EntityXPOrb.getXPSplit(i);
i -= j;
this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
}
TileEntityTreasureChestMP chest = null;
if (this.spawner != null && this.spawner.getChestPos() != null) {
TileEntity chestTest = this.world.getTileEntity(this.spawner.getChestPos());
if (chestTest != null && chestTest instanceof TileEntityTreasureChestMP) {
chest = (TileEntityTreasureChestMP) chestTest;
}
}
if (chest == null) {
chest = TileEntityTreasureChestMP.findClosest(this, MPItems.NIBIRU_DUNGEON_KEY);
}
if (chest != null) {
double dist = this.getDistanceSq(chest.getPos().getX() + 0.5, chest.getPos().getY() + 0.5, chest.getPos().getZ() + 0.5);
if (dist < 1000 * 1000) {
if (!chest.locked) {
chest.locked = true;
}
int slot = this.rand.nextInt(chest.getSizeInventory());
chest.setLootTable(MPLootTables.COMMON_SPACE_DUNGEON, this.rand.nextLong());
chest.setInventorySlotContents(slot, MPLootTables.getTieredKey(this.rand, 4));
}
}
this.entityDropItem(new ItemStack(MPItems.NIBIRU_DUNGEON_KEY_BOW), 0.5F);
this.setDead();
if (this.spawner != null) {
this.spawner.isBossDefeated = true;
this.spawner.boss = null;
this.spawner.spawned = false;
}
}
}
Aggregations