use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class ItemEvents method onItemTossEvent.
@SubscribeEvent
public void onItemTossEvent(ItemTossEvent event) {
if (!event.getPlayer().world.isRemote)
if (event.getPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getInDrive() && !event.getPlayer().getCapability(ModCapabilities.DRIVE_STATE, null).getActiveDriveName().equals(Strings.Form_Anti)) {
event.setCanceled(true);
return;
}
if (event.getEntityItem().getItem().getItem() instanceof ItemKeyblade && (event.getEntityItem().getItem().getItem() != ModItems.WoodenKeyblade && event.getEntityItem().getItem().getItem() != ModItems.WoodenStick && event.getEntityItem().getItem().getItem() != ModItems.DreamSword && event.getEntityItem().getItem().getItem() != ModItems.DreamStaff)) {
event.getEntityItem().isDead = true;
event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).setIsKeybladeSummoned(EnumHand.MAIN_HAND, false);
if (!ItemStack.areItemStacksEqual(event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null).getInventoryKeychain().getStackInSlot(0), ItemStack.EMPTY))
PacketDispatcher.sendTo(new SyncKeybladeData(event.getPlayer().getCapability(ModCapabilities.SUMMON_KEYBLADE, null)), (EntityPlayerMP) event.getPlayer());
} else if (event.getEntityItem().getItem().getItem() instanceof ItemMunny) {
event.setCanceled(true);
if (!event.getPlayer().world.isRemote) {
PacketDispatcher.sendTo(new ShowOverlayPacket("munny", event.getEntityItem().getItem().getTagCompound().getInteger("amount")), (EntityPlayerMP) event.getPlayer());
event.getPlayer().getCapability(ModCapabilities.MUNNY, null).addMunny(event.getEntityItem().getItem().getTagCompound().getInteger("amount"));
}
}
if (event.getEntityItem().getItem().getItem() == event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null).currentWeapon()) {
event.getEntityItem().isDead = true;
event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null).setWeaponSummoned(EnumHand.MAIN_HAND, false);
PacketDispatcher.sendTo(new SyncOrgXIIIData(event.getPlayer().getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) event.getPlayer());
}
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class OrgWeaponUnlock method process.
@Override
public void process(EntityPlayer player, Side side) {
OrganizationXIIICapability.IOrganizationXIII org = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null);
org.addUnlockedWeapon(unlock);
org.removePoints(points);
PacketDispatcher.sendTo(new SyncOrgXIIIData(org), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class DeSummonOrgWeapon method process.
@Override
public void process(EntityPlayer player, Side side) {
if (hand == EnumHand.MAIN_HAND)
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
else
player.inventory.offHandInventory.set(0, ItemStack.EMPTY);
player.world.playSound((EntityPlayer) null, player.getPosition(), ModSounds.unsummon, SoundCategory.MASTER, 1.0f, 1.0f);
player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).setWeaponSummoned(hand, false);
PacketDispatcher.sendTo(new SyncOrgXIIIData(player.getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) player);
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class BlockOrgPortal method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
byte index = -1;
if (player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getMember() != Utils.OrgMember.NONE) {
if (world.getTileEntity(pos) instanceof TileEntityOrgPortal) {
TileEntityOrgPortal te = (TileEntityOrgPortal) world.getTileEntity(pos);
if (te.getOwner() == null) {
te.setOwner(player);
te.markDirty();
for (byte i = 0; i < 3; i++) {
PortalCoords coords = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getPortalCoords(i);
// System.out.println(i+" "+coords.getX());
if (coords.getX() == 0.0D && coords.getY() == 0.0D && coords.getZ() == 0.0D) {
index = i;
break;
}
}
// System.out.println("A: "+index);
if (index != -1) {
player.sendMessage(new TextComponentString(TextFormatting.GREEN + "This is now " + player.getDisplayNameString() + "'s portal " + (index + 1)));
player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).setPortalCoords((byte) index, new PortalCoords((byte) index, pos.getX(), pos.getY(), pos.getZ(), player.dimension));
System.out.println(index + " " + player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getPortalCoords(index).getDimID());
PacketDispatcher.sendTo(new SyncOrgXIIIData(player.getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) player);
} else {
player.sendMessage(new TextComponentString(TextFormatting.RED + "You have no empty slots for portals"));
}
return true;
} else if (te.getOwner().equals(player.getDisplayNameString())) {
player.sendMessage(new TextComponentString(TextFormatting.YELLOW + "This is your portal " + index));
} else {
player.sendMessage(new TextComponentString(TextFormatting.RED + "This portal belongs to " + te.getOwner()));
return false;
}
}
}
}
return false;
}
use of uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class BlockOrgPortal method breakBlock.
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
if (!world.isRemote) {
if (world.getTileEntity(pos) instanceof TileEntityOrgPortal) {
TileEntityOrgPortal te = (TileEntityOrgPortal) world.getTileEntity(pos);
if (te.getOwner() != null) {
EntityPlayer player = world.getPlayerEntityByName(te.getOwner());
byte index = -1;
for (byte i = 0; i < 3; i++) {
PortalCoords coords = player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).getPortalCoords(i);
if (coords.getX() == pos.getX() && coords.getY() == pos.getY() && coords.getZ() == pos.getZ()) {
index = i;
break;
}
}
System.out.println("R: " + index);
if (index != -1) {
player.sendMessage(new TextComponentString(TextFormatting.RED + "Portal destination disappeared"));
player.getCapability(ModCapabilities.ORGANIZATION_XIII, null).setPortalCoords((byte) index, new PortalCoords((byte) index, 0, 0, 0, 0));
} else {
player.sendMessage(new TextComponentString(TextFormatting.RED + "You have no empty slots for portals"));
}
PacketDispatcher.sendTo(new SyncOrgXIIIData(player.getCapability(ModCapabilities.ORGANIZATION_XIII, null)), (EntityPlayerMP) player);
}
}
}
super.breakBlock(world, pos, state);
}
Aggregations