@Override public float work() { if (WorkUtils.isDisabled(this.getBlockType())) return 0; List<BlockPos> blockPosList = BlockUtils.getBlockPosInAABB(getWorkingArea()); for (BlockPos pos : blockPosList) { if (this.world.isAirBlock(pos)) { ItemStack stack = getFirstStackHasBlock(); if (stack.isEmpty()) return 0; if (this.world.isAirBlock(pos)) { FakePlayer player = IndustrialForegoing.getFakePlayer(this.world); player.setHeldItem(EnumHand.MAIN_HAND, stack); EnumActionResult result = ForgeHooks.onPlaceItemIntoWorld(stack, player, world, pos, EnumFacing.UP, 0, 0, 0, EnumHand.MAIN_HAND); return result == EnumActionResult.SUCCESS ? 1 : 0; } } } return 0; }
@Override public float work() { if (WorkUtils.isDisabled(this.getBlockType())) return 0; AxisAlignedBB area = getWorkingArea(); List<EntityLiving> mobs = this.getWorld().getEntitiesWithinAABB(EntityLiving.class, area); if (mobs.size() == 0) return 0; FakePlayer player = IndustrialForegoing.getFakePlayer(world); AtomicBoolean hasWorked = new AtomicBoolean(false); mobs.stream().filter(entityLiving -> !hasAddon() || (!(entityLiving instanceof EntityAgeable) || !entityLiving.isChild())).forEach(entityLiving -> { entityLiving.attackEntityFrom(DamageSource.causePlayerDamage(player), Integer.MAX_VALUE); hasWorked.set(true); }); List<EntityItem> items = this.getWorld().getEntitiesWithinAABB(EntityItem.class, area); for (EntityItem item : items) { if (!item.getItem().isEmpty()) { ItemHandlerHelper.insertItem(outItems, item.getItem(), false); item.setDead(); } } return hasWorked.get() ? 1 : 0; }
@Override public float work() { if (WorkUtils.isDisabled(this.getBlockType())) return 0; List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea()); boolean needsToIncrease = true; if (pointer >= blockPos.size()) pointer = 0; if (pointer < blockPos.size()) { BlockPos pos = blockPos.get(pointer); if (!this.world.isAirBlock(pos)) { ItemStack stack = getFirstItem(); if (!stack.isEmpty()) { FakePlayer player = IndustrialForegoing.getFakePlayer(this.world); if (ItemDye.applyBonemeal(stack, this.world, pos, player, EnumHand.MAIN_HAND)) needsToIncrease = false; } } } else { pointer = 0; } if (needsToIncrease) ++pointer; return 1; }
public static BlockBreakEvent callBlockBreakEvent(net.minecraft.world.World world, int x, int y, int z, net.minecraft.block.Block block, int blockMetadata, net.minecraft.entity.player.EntityPlayerMP player) { org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(x, y, z); org.bukkit.event.block.BlockBreakEvent blockBreakEvent = new org.bukkit.event.block.BlockBreakEvent(bukkitBlock, ((EntityPlayerMP)player).getBukkitEntity()); EntityPlayerMP playermp = (EntityPlayerMP)player; if (!(playermp instanceof FakePlayer)) { if (!(playermp.theItemInWorldManager.getGameType().isAdventure() && !playermp.isCurrentToolAdventureModeExempt(x, y, z)) && !(playermp.theItemInWorldManager.getGameType().isCreative() && playermp.getHeldItem() != null && playermp.getHeldItem().getItem() instanceof ItemSword)) { int exp = 0; if (!(block == null || !player.canHarvestBlock(block) || // Handle empty block or player unable to break block scenario block.canSilkHarvest(world, player, x, y, z, blockMetadata) && EnchantmentHelper.getSilkTouchModifier(player))) // If the block is being silk harvested, the exp dropped is 0 { int meta = block.getDamageValue(world, x, y, z); int bonusLevel = EnchantmentHelper.getFortuneModifier(player); exp = block.getExpDrop(world, meta, bonusLevel); } blockBreakEvent.setExpToDrop(exp); } else blockBreakEvent.setCancelled(true); } world.getServer().getPluginManager().callEvent(blockBreakEvent); return blockBreakEvent; }
private boolean isFakePlayer(Entity entity) { if (!(entity instanceof EntityPlayer)) { return false; } if (entity instanceof FakePlayer) { return true; } // If this returns false it is still possible we have a fake player. Try to find the player in the list of online players PlayerList playerList = DimensionManager.getWorld(0).getMinecraftServer().getPlayerList(); EntityPlayerMP playerByUUID = playerList.getPlayerByUUID(((EntityPlayer) entity).getGameProfile().getId()); if (playerByUUID == null) { // The player isn't online. Then it can't be real return true; } // The player is in the list. But is it this player? return entity != playerByUUID; }
@SubscribeEvent public static void onLivingDropsEvent(LivingDropsEvent event) { if (ConfigHandler.dropMoney && !(event.getEntityLiving() instanceof EntityPlayer) && event.getEntityLiving() instanceof IMob && event.getEntityLiving().getEntityWorld().isRemote == false) { if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityPlayer && !(event.getSource().getTrueSource() instanceof FakePlayer)) { CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ); return; } if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityArrow) { EntityArrow arrow = (EntityArrow) event.getSource().getTrueSource(); if (arrow.shootingEntity instanceof EntityPlayer && !(arrow.shootingEntity instanceof FakePlayer)) { CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ); return; } } } }
@SubscribeEvent public static void registerCapability(AttachCapabilitiesEvent<Entity> event) { Entity obj = event.getObject(); if (obj instanceof EntityPlayer && !(obj instanceof FakePlayer)) { EntityPlayer player = (EntityPlayer) obj; AbstractPlayerDamageModel damageModel; if (player.world.isRemote) damageModel = FirstAid.activeDamageConfig == null ? PlayerDamageModel.createTemp() : PlayerDamageModel.create(); else { FirstAid.activeDamageConfig = FirstAidConfig.damageSystem; FirstAid.activeHealingConfig = FirstAidConfig.externalHealing; FirstAid.scaleMaxHealth = FirstAidConfig.scaleMaxHealth; damageModel = PlayerDamageModel.create(); } event.addCapability(CapProvider.IDENTIFIER, new CapProvider(player, damageModel)); //replace the data manager with our wrapper to grab absorption player.dataManager = new DataManagerWrapper(player, player.dataManager); } }
@SubscribeEvent public void entityHurtEvent(LivingHurtEvent event) { if (!EtFuturum.enableDmgIndicator) return; int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F); if (amount <= 0) return; // If the attacker is a player spawn the hearts aligned and facing it if (event.source instanceof EntityDamageSource) { EntityDamageSource src = (EntityDamageSource) event.source; Entity attacker = src.getSourceOfDamage(); if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) { EntityPlayer player = (EntityPlayer) attacker; Vec3 look = player.getLookVec(); look.rotateAroundY((float) Math.PI / 2); for (int i = 0; i < amount; i++) { double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord; double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05; double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord; EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64)); } } } }
@SubscribeEvent public void checkSetTarget(LivingSetAttackTargetEvent event) { if (event.getTarget() == null) return; if (!(event.getTarget() instanceof EntityPlayer) || event.getTarget() instanceof FakePlayer) return; if (!(event.getEntity() instanceof EntityLiving)) return; EntityPlayer player = (EntityPlayer)event.getTarget(); EntityLiving ent = (EntityLiving)event.getEntity(); boolean flag = player.inventory.armorInventory[2] != null && player.inventory.armorInventory[2].getItem() == UCItems.poncho && NBTUtils.getInt(player.inventory.armorInventory[2], ItemGeneric.TAG_UPGRADE, -1) == 10; if (flag && ent.isNonBoss() && !(ent instanceof EntityGuardian || ent instanceof EntityShulker)) { ent.setAttackTarget(null); ent.setRevengeTarget(null); } }
@Override public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { if (stack.getItemDamage() != 20) return; if (!(entity instanceof EntityPlayer) || (entity instanceof FakePlayer)) return; if (itemSlot < ((EntityPlayer)entity).inventory.getHotbarSize()) { List<EntityLiving> entities = entity.worldObj.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(entity.getPosition().add(-range, -range, -range), entity.getPosition().add(range, range, range))); for (EntityLiving ent : entities) { List<EntityAITaskEntry> entries = new ArrayList(ent.tasks.taskEntries); entries.addAll(new ArrayList(ent.targetTasks.taskEntries)); for (EntityAITaskEntry entry : entries) { if (entry.action instanceof EntityAIAttackRangedBow) { makeSkellyShootSlower((EntityAIAttackRangedBow)entry.action); } } if (ent instanceof EntityCreeper) ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper)ent, 60, this.FUSETIME); } } }
private void PlantSapling(World world, BlockPos blockPos, BlockPos originPos) { Set<ItemStack> leafDrop = new HashSet<>(); BlockPos plantPos1 = new BlockPos(originPos.getX() - 1, originPos.getY(), originPos.getZ() - 1); int counter = 0; while (leafDrop.isEmpty() && counter <= 100) { NonNullList<ItemStack> tmpList = NonNullList.create(); world.getBlockState(blockPos).getBlock().getDrops(tmpList, world, blockPos, world.getBlockState(blockPos), 3); leafDrop.addAll(tmpList); counter++; } if (leafDrop.isEmpty()) { return; } FakePlayer fakePlayer = FakePlayerFactory.getMinecraft((WorldServer) world); fakePlayer.setHeldItem(EnumHand.MAIN_HAND, leafDrop.iterator().next()); for (ItemStack itemStack : leafDrop) { itemStack.onItemUse(fakePlayer, world, plantPos1, EnumHand.MAIN_HAND, EnumFacing.NORTH, 0, 0, 0); } }
public boolean doPlayerLastHit(final World world, final Entity target, final TileEntity tile) { final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft((WorldServer)world); try { final ItemStack stack = this.swordStack.copy(); if (tile instanceof TileEntityEnchantedSpike) { stack.setTagCompound(((TileEntityEnchantedSpike)tile).getEnchantmentTagList()); } fakePlayer.setCurrentItemOrArmor(0, stack); boolean b = target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)fakePlayer), 400.0f); fakePlayer.setCurrentItemOrArmor(0, (ItemStack)null); b |= target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)fakePlayer), 400.0f); b |= target.attackEntityFrom(DamageSource.cactus, 400.0f); return b; } finally { fakePlayer.setCurrentItemOrArmor(0, (ItemStack)null); } }
public void addPlayerHeads(PlayerDropsEvent event){ EntityPlayer player = event.getEntityPlayer(); DamageSource source = event.getSource(); Entity attacker = source.getSourceOfDamage(); if(Config.playerHeadType == ItemDropType.NONE)return; if(player == null || player.getEntityWorld() == null)return; int rand = player.getEntityWorld().rand.nextInt(Math.max(Config.playerHeadDropChance / fixLooting(event.getLootingLevel()), 1)); if(Config.playerHeadDropChance < 0 || rand !=0) return; if(Config.playerHeadType == ItemDropType.KILLED){ if(attacker == null || !(attacker instanceof EntityPlayer) || attacker instanceof FakePlayer) return; } ItemStack skull = PlayerUtil.createPlayerHead(player); event.getDrops().add(ItemUtil.dropFromPlayer(player, skull, true)); }
@Override public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, boolean isSelected) { if (entity instanceof FakePlayer || entity.world.isRemote) { return; } if (entity.ticksExisted % TICK_PER_STAT > 0) { return; } NBTTagCompound tag = TagUtil.getExtraTag(tool); Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag); data.radius += random.nextFloat() * 0.5f; if (data.radius >= 1) { TagUtil.setEnchantEffect(tool, true); } data.write(tag); TagUtil.setExtraTag(tool, tag); }
@SubscribeEvent(priority = EventPriority.BOTTOM) public void onLivingAttackCallback(LivingAttackEvent event) { if (Always.isServer()) { EntityLivingBase living = event.getEntityLiving(), attacker = event.getSource().getTrueSource() instanceof EntityLivingBase ? (EntityLivingBase) event.getSource().getTrueSource() : null; if (isEquipmented(living) && !(living instanceof EntityPlayer && ((EntityPlayer) living).isCreative())) { living.getCombatTracker().lastDamageTime = living.ticksExisted; if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer)) AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(-1), (EntityPlayerMP) living); } if (attacker != null && isEquipmented(attacker)) { attacker.setLastAttackedEntity(living); if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer)) AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(living.getEntityId()), (EntityPlayerMP) attacker); } } }
@Override public void onWornTick(ItemStack item, EntityLivingBase living) { if (Always.isServer()) if (living.ticksExisted - living.getEntityData().getInteger(NBT_KEY_CD) > INTERVAL) { boolean flag = false; for (Iterator<PotionEffect> iterator = living.getActivePotionEffects().iterator(); iterator.hasNext();) if (iterator.next().getPotion().isBadEffect()) { flag = true; iterator.remove(); } if (flag) { List<Double6IntArrayPackage> d6iap = new LinkedList<Double6IntArrayPackage>(); for (int i = 0; i < 9; i++) d6iap.add(new Double6IntArrayPackage(living.posX - 1 + living.rand.nextDouble() * 2, living.posY + 1, living.posZ - 1 + living.rand.nextDouble() * 2, 0D, 0D, 0D)); AlchemyNetworkHandler.spawnParticle(EnumParticleTypes.WATER_SPLASH, AABBHelper.getAABBFromEntity(living, AlchemyNetworkHandler.getParticleRange()), living.world, d6iap); living.getEntityData().setInteger(NBT_KEY_CD, living.ticksExisted); if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer)) AlchemyNetworkHandler.network_wrapper.sendTo(new MessagePurifyCallback(), (EntityPlayerMP) living); } } living.setAir(MAX_AIR); }
@SubscribeEvent public void onEntityDrop(LivingDropsEvent event) { if(event.getSource().getEntity() == null || event.getSource().getEntity() instanceof FakePlayer || !(event.getSource().getEntity() instanceof EntityPlayer)) return; //This is bad remove at some point //set NBT to stack if(random.nextInt(10) == 1) { int type = random.nextInt(OpenLootBagsApi.INSTANCE.getBagManager().getBagTypes().size()); ItemStack stack = new ItemStack(OpenLootBags.lootbag, 1, type); ResourceLocation name = OpenLootBagsApi.INSTANCE.getBagManager().getBagTypes().get(type); ItemNBTHelper.setString(stack, "typeName", name.getResourcePath()); ItemNBTHelper.setString(stack, "typeDomain", name.getResourceDomain()); ItemNBTHelper.setInt(stack, "colour", OpenLootBagsApi.INSTANCE.getBagManager().getBagColorMap().get(name)); event.getEntityLiving().entityDropItem(stack, random.nextInt(2) + 1); } }
@SubscribeEvent(priority = EventPriority.LOWEST) // Act after any cancellations public void recordBlock(BlockEvent.PlaceEvent event) { IBlockState bs = event.placedBlock; Block block = bs.getBlock(); if (event.player == null) return; if (event.world.isRemote) return; if (event.player instanceof FakePlayer) return; if (block.getBlockHardness(event.world, event.pos) <= 0F) return; if (PlayerUtil.isPlayerCreative(event.player)) return; int idmd = hash(bs); final ItemStack theItem = toItem(block, event.world, event.pos, bs); final PlacedBlock at = new PlacedBlock(FzUtil.getWorldDimension(event.world), event.pos, idmd, theItem); markPlacement(event.player, at); if (event.player instanceof EntityPlayerMP) { send(event.player, at); } }
@Override protected void onFoodEaten(ItemStack stack, World wrold, EntityPlayer player) { if (player instanceof FakePlayer) { super.onFoodEaten(stack, wrold, player); return; } boolean spicy = stack.getItemDamage() > 0; int nomage = spicy ? 7 : 1; StatUtil.IFzStat stat = StatUtil.load(player, manwhichStatus); stat.set(nomage); stat.sync(); int saturationTime; if (spicy) { player.setFire(7); saturationTime = 20 * 60 * 5; } else { player.addPotionEffect(new PotionEffect(Potion.confusion.getId(), 50, 1, true, true)); saturationTime = 20 * 25; } player.addPotionEffect(new PotionEffect(Potion.saturation.getId(), saturationTime, 1, !Core.dev_environ, !Core.dev_environ)); super.onFoodEaten(stack, wrold, player); }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onPlayerDeath(LivingDeathEvent event) { if(!event.getEntityLiving().getEntityWorld().isRemote && event.getEntityLiving() instanceof EntityPlayer && !(event.getEntityLiving() instanceof FakePlayer)) { EntityPlayerMP player = (EntityPlayerMP)event.getEntityLiving(); if(player.interactionManager.getGameType() == GameType.CREATIVE || player.interactionManager.getGameType() == GameType.SPECTATOR) { return; } NBTTagCompound tag = EntityHelper.getPlayerPersistentData(player, "LimitedLivesSave"); int prevDeaths = tag.getInteger("deathCount"); int liveCount = tag.getInteger("maxLives"); if(liveCount == 0) { liveCount = LimitedLives.maxLives; } tag.setDouble("healthOffset", event.getEntityLiving().getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue() - (20D - (20D * prevDeaths / (double)liveCount))); tag.setInteger("deathCount", prevDeaths + 1); tag.setInteger("maxLives", LimitedLives.maxLives); } }
public static WeakReference<FakePlayer> initFakePlayer(WorldServer ws, UUID uname, String blockName) { GameProfile breakerProfile = new GameProfile(uname, Const.MODID + ".fake_player." + blockName); WeakReference<FakePlayer> fakePlayer; try { fakePlayer = new WeakReference<FakePlayer>(FakePlayerFactory.get(ws, breakerProfile)); } catch (Exception e) { ModCyclic.logger.error("Exception thrown trying to create fake player : " + e.getMessage()); fakePlayer = null; } if (fakePlayer == null || fakePlayer.get() == null) { fakePlayer = null; return null; // trying to get around https://github.com/PrinceOfAmber/Cyclic/issues/113 } fakePlayer.get().onGround = true; fakePlayer.get().connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer.get()) { @SuppressWarnings("rawtypes") @Override public void sendPacket(Packet packetIn) {} }; fakePlayer.get().setSilent(true); return fakePlayer; }
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (state.getValue(AGE) == 5) { if (worldIn.isRemote) return true; worldIn.setBlockState(pos, this.getDefaultState(), 2); EntityItem ei = new EntityItem(worldIn, playerIn.posX, playerIn.posY, playerIn.posZ, new ItemStack(this.item)); worldIn.spawnEntityInWorld(ei); if (playerIn instanceof FakePlayer) ei.onCollideWithPlayer(playerIn); return true; } return false; }
@Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { if (Platform.isClient()) { return; } if (entity instanceof EntityPlayer && !(entity instanceof FakePlayer)) { EntityPlayer player = (EntityPlayer) entity; if (world.getTileEntity(x, y, z) instanceof TileEntityPlayerInterface) { TileEntityPlayerInterface te = (TileEntityPlayerInterface) world.getTileEntity(x, y, z); te.bindPlayer(player.getUniqueID()); te.setPlayerOnline(); } } }
@Override public boolean onBlockActivated(World pWorld, int pX, int pY, int pZ, EntityPlayer pPlayer, int pSide, float pDx, float pDy, float pDz) { // Cannot be activated by a block activator, must be a player if(pPlayer == null || pPlayer instanceof FakePlayer) { return false; } TileEntityRotorBlock rotorEntity = (TileEntityRotorBlock)pWorld.getTileEntity(pX, pY, pZ); if(rotorEntity != null) { ForgeDirection rotorDir = Util.intToDirection(rotorEntity.getBlockMetadata() & 3).getOpposite(); int parentX = pX + rotorDir.offsetX; int parentY = pY + rotorDir.offsetY; int parentZ = pZ + rotorDir.offsetZ; TileEntityWindmillBlock windmillEntity = (TileEntityWindmillBlock)pWorld.getTileEntity(parentX, parentY, parentZ); if(windmillEntity != null) { windmillEntity.handcrank(); } } return true; }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onPlayerDeath(PlayerDropsEvent evt) { if (evt.getEntityPlayer() == null || evt.getEntityPlayer() instanceof FakePlayer || evt.isCanceled()) { return; } if(evt.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) { return; } ListIterator<EntityItem> iter = evt.getDrops().listIterator(); while (iter.hasNext()) { EntityItem ei = iter.next(); ItemStack item = ei.getEntityItem(); if(isSoulBound(item)) { if (addToPlayerInventory(evt.getEntityPlayer(), item)) { Bagginses.analytics.eventDesign("playerDied:Soulbound", Bagginses.analytics.userPrefix()); iter.remove(); } } } }
@Nullable private IBlockState getPlacementStateForPosition(int invPosition, World world, BlockPos pos, FakePlayer player) { if (this.blockInfoTaken[invPosition] != null) { return this.blockInfoTaken[invPosition].getState(); } ItemStack stack = this.itemHandlerDrawbridge.getStackInSlot(invPosition); if (stack.isEmpty() == false && stack.getItem() instanceof ItemBlock) { ItemBlock itemBlock = (ItemBlock) stack.getItem(); Block block = itemBlock.getBlock(); if (block != null) { int meta = itemBlock.getMetadata(stack.getMetadata()); player.rotationYaw = this.getFacing().getHorizontalAngle(); return block.getStateForPlacement(world, pos, EnumFacing.UP, 0.5f, 1f, 0.5f, meta, player, EnumHand.MAIN_HAND); } } return null; }
/** * Permission and activation checks. * * @param player * @return */ protected boolean activationCheck( final EntityPlayer player ) { // Ignore fake players if( player instanceof FakePlayer ) { return false; } // Is the monitor off? if( !this.isActive() ) { return false; } // Does the player have permission to interact with this device? if( !Platform.hasPermissions( this.getLocation(), player ) ) { return false; } return true; }
@Override public boolean canPlayerInteract( final EntityPlayer player ) { // Fake player? if( player instanceof FakePlayer ) { // Are golems allowed to interact? if( !this.allowGolemInteraction ) { // Golem interaction not allowed return false; } // Is the fake player a golem? if( !player.getGameProfile().getName().equalsIgnoreCase( "FakeThaumcraftGolem" ) ) { // Not a golem return false; } } return true; }
@SubscribeEvent public void onBucketFill(FillBucketEvent ev) { if(ev.entity.worldObj.isRemote || ev.isCanceled()) { return; } int x = (int) Math.floor(ev.target.blockX); int y = (int) Math.floor(ev.target.blockY); int z = (int) Math.floor(ev.target.blockZ); if(ev.entityPlayer instanceof FakePlayer) { if(!ProtectionManager.getFlagValueAtLocation(FlagType.FAKERS, ev.world.provider.dimensionId, x, y, z)) { ev.setCanceled(true); } } else { Resident res = MyTownUniverse.instance.getOrMakeResident(ev.entityPlayer); if(!ProtectionManager.hasPermission(res, FlagType.USAGE, ev.world.provider.dimensionId, x, y, z)) { ev.setCanceled(true); } } }
@SubscribeEvent(priority = EventPriority.HIGH) public void onPlayerDeath(LivingDeathEvent event) { if (Config.dumpStiffsStuff) { final Entity rottingMeat = event.getEntity(); if ((rottingMeat instanceof EntityPlayerMP) && !(rottingMeat instanceof FakePlayer)) { EntityPlayer player = (EntityPlayer)rottingMeat; final String playerName = player.getName(); try { File file = storePlayerInventory(player, "death"); Log.info("Storing post-mortem inventory into %s. It can be restored with command '/ob_inventory restore %s %s'", file.getAbsolutePath(), playerName, stripFilename(file.getName())); } catch (Exception e) { Log.severe(e, "Failed to store inventory for player %s", playerName); } } } }
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are) { if (world.isRemote) { return true; } else { if (world.getBlockMetadata(x, y, z) == 7) { world.setBlockMetadataWithNotify(x, y, z, 5, 2); EntityItem entityItemCrop = new EntityItem(world, player.posX, player.posY - 1.0D, player.posZ, new ItemStack(ModItems.grapes, 1)); EntityItem entityItemSeed = new EntityItem(world, player.posX, player.posY - 1.0D, player.posZ, new ItemStack(ModItems.grapeSeed, 1)); world.spawnEntityInWorld(entityItemCrop); world.spawnEntityInWorld(entityItemSeed); if (!(player instanceof FakePlayer)) { entityItemCrop.onCollideWithPlayer(player); entityItemSeed.onCollideWithPlayer(player); } return true; } else { return false; } } }