/** * ■対象Entityに傷を指定数つける * * @param dwIn * @param countHit */ public void setHitCount(DataWatcher dwIn, int countHit) { // ■確認用 getHitCount(dwIn); // ■設定 dwIn.updateObject(Hizume.getDWID(), MathHelper.clamp_int(countHit, 0, Integer.MAX_VALUE - 1)); }
/** * Called when the player Left Clicks (attacks) an entity. Processed before damage is done, if * return value is true further processing is canceled and the entity is not attacked. * ■左クリックでEntityを殴ると呼ばれる。 (return : 相手にダメージを [true = 与えない : false = 与える]) * * @param stack The Item being used * @param player The player that is attacking * @param entity The entity being attacked * @return True to cancel the rest of the interaction. */ @Override public boolean onLeftClickEntity(ItemStack stackIn, EntityPlayer player, Entity entity) { // ■相手に傷をつける(DataWatcherに情報を刻む) if (entity instanceof EntityDragonPart) { // ■DragonPartからDragonを取得 entity = (Entity) ((EntityDragonPart) entity).entityDragonObj; } DataWatcher dw = entity.getDataWatcher(); int countHit = getHitCount(dw); // ■情報を刻む dw.updateObject(Hizume.getDWID(), ++countHit); // TODO if (!player.worldObj.isRemote) { // System.out.println("Entity = " + entity.getName() + " : Scars!"); } return false; }