Skip to content

Commit

Permalink
メイドの経路探索をconfigで設定できるように
Browse files Browse the repository at this point in the history
  • Loading branch information
iesika committed Aug 23, 2017
1 parent 04aef0e commit 02ba981
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/main/java/com/iesika/aem/common/AEMConfig.java
Expand Up @@ -7,19 +7,25 @@

public class AEMConfig {

private static final String CATEGORY_general = "General";
private static final String CATEGORY_ItemCarier = "item carrier mode";

//General
public static int maidPathFindingRange = 64;

//ItemCarrier
public static int workbookTier0NodeSize = 2;
public static int workbookTier1NodeSize = 4;
public static int workbookTier2NodeSize = 6;


public static void readConfig() {

Configuration cfg = AdditionalEntityMode.config;

try {
cfg.load();
initGeneralConfig(cfg);
initItemCarrierConfig(cfg);
} catch (Exception e1) {
Logger.error("failed loading config file...");
Expand All @@ -30,10 +36,15 @@ public static void readConfig() {
}
}

private static void initGeneralConfig(Configuration cfg) {
cfg.addCustomCategoryComment(CATEGORY_general, "general configuration");
maidPathFindingRange = cfg.getInt("maidPathFindingRange", CATEGORY_general, maidPathFindingRange, 20, 1000, "maid of path finding range, may cause rag with high value [20-1000] default : 64", null);
}

private static void initItemCarrierConfig(Configuration cfg) {
cfg.addCustomCategoryComment(CATEGORY_ItemCarier, "Item carrier mode configuration");
workbookTier0NodeSize = cfg.getInt("workbookTier0NodeSize", CATEGORY_ItemCarier, workbookTier0NodeSize, 2, 100, "The number of nodes that workbook tier0 can be recorded [2-100]default : 2", null);
workbookTier1NodeSize = cfg.getInt("workbookTier1NodeSize", CATEGORY_ItemCarier, workbookTier1NodeSize, 2, 100, "The number of nodes that workbook tier1 can be recorded [2-100]default : 4", null);
workbookTier2NodeSize = cfg.getInt("workbookTier2NodeSize", CATEGORY_ItemCarier, workbookTier2NodeSize, 2, 100, "The number of nodes that workbook tier2 can be recorded [2-100]default : 6", null);
workbookTier0NodeSize = cfg.getInt("workbookTier0NodeSize", CATEGORY_ItemCarier, workbookTier0NodeSize, 2, 100, "The number of nodes that workbook tier0 can be recorded [2-100] default : 2", null);
workbookTier1NodeSize = cfg.getInt("workbookTier1NodeSize", CATEGORY_ItemCarier, workbookTier1NodeSize, 2, 100, "The number of nodes that workbook tier1 can be recorded [2-100] default : 4", null);
workbookTier2NodeSize = cfg.getInt("workbookTier2NodeSize", CATEGORY_ItemCarier, workbookTier2NodeSize, 2, 100, "The number of nodes that workbook tier2 can be recorded [2-100] default : 6", null);
}
}
8 changes: 8 additions & 0 deletions src/main/java/com/iesika/aem/mode/EntityModeCarrier.java
@@ -1,5 +1,6 @@
package com.iesika.aem.mode;

import com.iesika.aem.common.AEMConfig;
import com.iesika.aem.common.AEMItems;
import com.iesika.aem.common.ai.EntityAIExport;
import com.iesika.aem.common.ai.EntityAIImport;
Expand All @@ -9,6 +10,7 @@
import net.blacklab.lmr.entity.EntityLittleMaid;
import net.blacklab.lmr.entity.mode.EntityModeBase;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.ai.EntityAIWatchClosest;
Expand Down Expand Up @@ -40,6 +42,12 @@ public boolean changeMode(EntityPlayer pentityplayer) {
ItemStack mainHand = owner.maidInventory.mainHandInventory[0];
if (mainHand != null){
if (shouldChangeToCarrierMode(mainHand)){
double pre = owner.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getBaseValue();
double now = (double)AEMConfig.maidPathFindingRange;
if (pre != now){
owner.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(now);
Logger.info("maid path finding range increased : " + pre + " -> " + now);
}
owner.setMaidMode(CarrierModeName);
Logger.info("maid mode -> Carrier (use main hand)");
return true;
Expand Down

0 comments on commit 02ba981

Please sign in to comment.