@Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { Player player = (Player) src; PlayerGymInfoData playerGymInfoData = player.get(PlayerGymInfoData.class).get(); List<ItemStackSnapshot> itemStackSnapshots = playerGymInfoData.badgeItems().get(); InventoryBasic inventoryBasic = new InventoryBasic("Badges", true, 54); for (int i = 0; i < itemStackSnapshots.size(); i++) { if (i < inventoryBasic.getSizeInventory()) { ItemStackSnapshot snapshot = itemStackSnapshots.get(i); ItemStack stack = snapshot.createStack(); inventoryBasic.setInventorySlotContents(i, (net.minecraft.item.ItemStack) stack); } } ((EntityPlayerMP) player).displayGUIChest(inventoryBasic); /* try { GameProfile gameProfile = Sponge.getServer().getGameProfileManager().get("clienthax").get(); // <-- why the hell doesnt this return a optional.. -.- System.out.println(gameProfile.getUniqueId()); } catch (Exception e) { e.printStackTrace(); }*/ return CommandResult.success(); }
/** * @author Aaron1011 - February 6th, 2015 * @reason This needs to handle for both cases where a fish and/or an entity is being caught. * There's no real good way to do this with an injection. */ @Overwrite public int handleHookRetraction() { if (this.worldObj.isRemote) { return 0; } // Sponge start byte b0 = 0; net.minecraft.item.ItemStack itemStack = null; int exp = 0; if (this.ticksCatchable > 0) { itemStack = this.getFishingResult(); exp = this.rand.nextInt(6) + 1; } EntitySnapshot fishHookSnapshot = this.createSnapshot(); Transaction<ItemStackSnapshot> transaction = null; if (itemStack != null) { ItemStackSnapshot original = ((ItemStack) itemStack).createSnapshot(); ItemStackSnapshot replacement = ((ItemStack) itemStack).createSnapshot(); transaction = new Transaction<>(original, replacement); } else { transaction = new Transaction<>(ItemStackSnapshot.NONE, ItemStackSnapshot.NONE); } FishingEvent.Stop event = SpongeEventFactory.createFishingEventStop( Cause.of(NamedCause.source(this.angler)), exp, exp, fishHookSnapshot, this, transaction, (Player) this.angler); if (!SpongeImpl.postEvent(event)) { // Sponge end if (this.caughtEntity != null) { double d0 = this.angler.posX - this.posX; double d2 = this.angler.posY - this.posY; double d4 = this.angler.posZ - this.posZ; double d6 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2 + d4 * d4); double d8 = 0.1D; this.caughtEntity.motionX += d0 * d8; this.caughtEntity.motionY += d2 * d8 + (double) MathHelper.sqrt_double(d6) * 0.08D; this.caughtEntity.motionZ += d4 * d8; b0 = 3; } // Sponge Start if (!event.getItemStackTransaction().getFinal().getType().equals(ItemTypes.NONE)) { ItemStackSnapshot itemSnapshot = event.getItemStackTransaction().getFinal(); EntityItem entityitem1 = new EntityItem( this.worldObj, this.posX, this.posY, this.posZ, (net.minecraft.item.ItemStack) itemSnapshot.createStack()); double d1 = this.angler.posX - this.posX; double d3 = this.angler.posY - this.posY; double d5 = this.angler.posZ - this.posZ; double d7 = MathHelper.sqrt_double(d1 * d1 + d3 * d3 + d5 * d5); double d9 = 0.1D; entityitem1.motionX = d1 * d9; entityitem1.motionY = d3 * d9 + MathHelper.sqrt_double(d7) * 0.08D; entityitem1.motionZ = d5 * d9; this.worldObj.spawnEntityInWorld(entityitem1); this.angler.worldObj.spawnEntityInWorld( new EntityXPOrb( this.angler.worldObj, this.angler.posX, this.angler.posY + 0.5D, this.angler.posZ + 0.5D, event.getExperience())); // Sponge End b0 = 1; } if (this.inGround) { b0 = 2; } this.setDead(); this.angler.fishEntity = null; // Sponge Start if (this.fishingRod != null) { this.fishingRod.damageItem(b0, this.angler); this.angler.swingItem(); this.fishingRod = null; } // Sponge End } return b0; }