Exemplo n.º 1
0
 @SubscribeEvent
 public void onPlayerTick(TickEvent.PlayerTickEvent event) {
   if (event.player == player) {
     for (EntityPlayer player1 : player.worldObj.playerEntities) {
       boolean pokemob;
       PokeInfo info = proxy.getMap().get(player.getUniqueID());
       if (info == null) {
         proxy.getPokemob(player);
         info = proxy.getMap().get(player.getUniqueID());
         pokemob = info != null;
         pokemob = pokemob && player.getEntityData().getBoolean("isPokemob");
       } else {
         pokemob = player.getEntityData().getBoolean("isPokemob");
       }
       PacketBuffer buffer = new PacketBuffer(Unpooled.buffer(6));
       MessageClient message = new MessageClient(buffer);
       buffer.writeByte(MessageClient.SETPOKE);
       buffer.writeInt(player1.getEntityId());
       buffer.writeBoolean(pokemob);
       if (pokemob) {
         buffer.writeFloat(info.originalHeight);
         buffer.writeFloat(info.originalWidth);
         buffer.writeNBTTagCompoundToBuffer(player1.getEntityData().getCompoundTag("Pokemob"));
       }
       PokecubeMod.packetPipeline.sendTo(message, (EntityPlayerMP) player);
       MinecraftForge.EVENT_BUS.unregister(this);
     }
   }
 }
Exemplo n.º 2
0
 @SubscribeEvent
 public void PlayerDeath(LivingDeathEvent evt) {
   if (evt.entityLiving instanceof EntityPlayer) {
     IPokemob pokemob = proxy.getPokemob((EntityPlayer) evt.entityLiving);
     if (pokemob != null) {
       ((EntityLivingBase) pokemob).setHealth(10);
       ((IHungrymob) pokemob).setHungerTime(0);
     }
   }
 }
Exemplo n.º 3
0
 @SubscribeEvent
 public void pokemobAttack(AttackEvent evt) {
   if (evt.moveInfo.attacked instanceof EntityPlayer) {
     EntityPlayer player = (EntityPlayer) evt.moveInfo.attacked;
     IPokemob pokemob = proxy.getPokemob(player);
     if (pokemob != null) {
       evt.moveInfo.attacked = (Entity) pokemob;
     }
   }
 }
Exemplo n.º 4
0
 @SubscribeEvent
 public void interactEvent(PlayerInteractEvent event) {
   IPokemob pokemob = proxy.getPokemob(event.entityPlayer);
   if (pokemob == null) return;
   EntityPlayer player = event.entityPlayer;
   if (event.entityPlayer.getHeldItem() != null
       && event.entityPlayer.isSneaking()
       && event.entityPlayer.getHeldItem().getItem() instanceof ItemPokedex) {
     pokemob.getPokemobInventory().func_110134_a((IInvBasic) pokemob);
     if (!event.world.isRemote) {
       event.setCanceled(true);
       event.entityPlayer.openGui(
           PokePlayer.INSTANCE, Proxy.POKEMOBGUI, event.entityPlayer.worldObj, 0, 0, 0);
     }
   } else if (event.action == Action.RIGHT_CLICK_AIR && event.entityPlayer.getHeldItem() != null) {
     ((Entity) pokemob).interactFirst(player);
     proxy.getMap().get(event.entityPlayer.getUniqueID()).save(player);
   }
 }