Search in sources :

Example 1 with SyncOrgXIIIData

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());
    }
}
Also used : ShowOverlayPacket(uk.co.wehavecookies56.kk.common.network.packet.client.ShowOverlayPacket) SyncKeybladeData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncKeybladeData) SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData) ItemKeyblade(uk.co.wehavecookies56.kk.common.item.base.ItemKeyblade) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemMunny(uk.co.wehavecookies56.kk.common.item.ItemMunny) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with SyncOrgXIIIData

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);
}
Also used : SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData) OrganizationXIIICapability(uk.co.wehavecookies56.kk.common.capability.OrganizationXIIICapability)

Example 3 with SyncOrgXIIIData

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);
}
Also used : SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData)

Example 4 with SyncOrgXIIIData

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;
}
Also used : PortalCoords(uk.co.wehavecookies56.kk.common.util.PortalCoords) SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData) TileEntityOrgPortal(uk.co.wehavecookies56.kk.common.block.tile.TileEntityOrgPortal) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 5 with SyncOrgXIIIData

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);
}
Also used : PortalCoords(uk.co.wehavecookies56.kk.common.util.PortalCoords) SyncOrgXIIIData(uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntityOrgPortal(uk.co.wehavecookies56.kk.common.block.tile.TileEntityOrgPortal) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

SyncOrgXIIIData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncOrgXIIIData)10 TextComponentString (net.minecraft.util.text.TextComponentString)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 OrganizationXIIICapability (uk.co.wehavecookies56.kk.common.capability.OrganizationXIIICapability)3 SyncKeybladeData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncKeybladeData)3 TileEntityOrgPortal (uk.co.wehavecookies56.kk.common.block.tile.TileEntityOrgPortal)2 IOrganizationXIII (uk.co.wehavecookies56.kk.common.capability.OrganizationXIIICapability.IOrganizationXIII)2 SyncDriveData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncDriveData)2 SyncLevelData (uk.co.wehavecookies56.kk.common.network.packet.client.SyncLevelData)2 PortalCoords (uk.co.wehavecookies56.kk.common.util.PortalCoords)2 GameProfile (com.mojang.authlib.GameProfile)1 UUID (java.util.UUID)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 EntityWither (net.minecraft.entity.boss.EntityWither)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 ItemStack (net.minecraft.item.ItemStack)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1 ItemStackHandler (net.minecraftforge.items.ItemStackHandler)1