├── .gitignore ├── TODO.txt ├── readme.txt ├── src └── main │ ├── resources │ ├── assets │ │ └── mmm │ │ │ ├── lang │ │ │ ├── ja_JP.lang │ │ │ └── en_US.lang │ │ │ └── textures │ │ │ └── gui │ │ │ └── container │ │ │ ├── littlemaidinventory.png │ │ │ └── littlemaidtrigger.png │ ├── readme.txt │ └── mcmod.info │ └── java │ └── mmm │ └── littleMaidMob │ ├── sound │ ├── SoundEntry.java │ ├── ILMMSound.java │ ├── SoundListName.java │ ├── SoundListColor.java │ ├── SoundManager.java │ └── EnumSound.java │ ├── mode │ ├── ModeManager.java │ ├── ModeController.java │ └── EntityModeBase.java │ ├── ProxyClient.java │ ├── entity │ ├── EntityLittleMaidAvatar.java │ └── EntityLittleMaidBase.java │ ├── ai │ └── EntityAIWait.java │ ├── inventory │ ├── SlotArmor.java │ ├── ContainerInventory.java │ └── InventoryLittleMaid.java │ ├── gui │ ├── GuiButtonNextPage.java │ ├── GuiHandler.java │ ├── GuiLittleMaidInventory.java │ └── GuiEffectRenderer.java │ ├── TileContainer.java │ ├── RenderLittleMaid.java │ ├── Statics.java │ ├── littleMaidMob.java │ └── SwingStatus.java ├── old ├── readme.txt ├── readme-faq.txt ├── readme-src.txt ├── readme_en.txt └── readme-sound.txt └── soundcheck.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | *.class 3 | /bin 4 | /build 5 | /eclipse 6 | .* 7 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/TODO.txt -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/readme.txt -------------------------------------------------------------------------------- /src/main/resources/assets/mmm/lang/ja_JP.lang: -------------------------------------------------------------------------------- 1 | entity.littleMaidMob.name=リトルメイド 2 | -------------------------------------------------------------------------------- /old/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/old/readme.txt -------------------------------------------------------------------------------- /soundcheck.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/soundcheck.txt -------------------------------------------------------------------------------- /old/readme-faq.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/old/readme-faq.txt -------------------------------------------------------------------------------- /old/readme-src.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/old/readme-src.txt -------------------------------------------------------------------------------- /old/readme_en.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/old/readme_en.txt -------------------------------------------------------------------------------- /src/main/resources/assets/mmm/lang/en_US.lang: -------------------------------------------------------------------------------- 1 | entity.littleMaidMob.name=littleMaidMob 2 | -------------------------------------------------------------------------------- /old/readme-sound.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/old/readme-sound.txt -------------------------------------------------------------------------------- /src/main/resources/readme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/src/main/resources/readme.txt -------------------------------------------------------------------------------- /src/main/resources/assets/mmm/textures/gui/container/littlemaidinventory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/src/main/resources/assets/mmm/textures/gui/container/littlemaidinventory.png -------------------------------------------------------------------------------- /src/main/resources/assets/mmm/textures/gui/container/littlemaidtrigger.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MMM666/littleMaidMob/HEAD/src/main/resources/assets/mmm/textures/gui/container/littlemaidtrigger.png -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/sound/SoundEntry.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.sound; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class SoundEntry { 7 | 8 | String name; 9 | float volume; 10 | float pitch; 11 | List locations = new ArrayList(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/sound/ILMMSound.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.sound; 2 | 3 | import net.minecraft.client.audio.ISound; 4 | 5 | public interface ILMMSound { 6 | 7 | public ISound getLastSound(); 8 | public void setLastSound(ISound pSound); 9 | 10 | public String getTextureName(); 11 | public int getColor(); 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/mode/ModeManager.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.mode; 2 | 3 | /** 4 | * 動作モードの登録、管理 5 | * 6 | */ 7 | public class ModeManager { 8 | 9 | public void init() { 10 | 11 | 12 | } 13 | 14 | public void loadModes() { 15 | 16 | } 17 | 18 | public ModeController getModeControler() { 19 | return null; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "MMMLib", 4 | "name": "MMMLib", 5 | "description": "MMM's Library. ", 6 | "version": "${version}", 7 | "mcversion": "${mcversion}", 8 | "url": "", 9 | "updateUrl": "", 10 | "authors": ["MMM"], 11 | "credits": "created by MMM", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [] 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/sound/SoundListName.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.sound; 2 | 3 | 4 | 5 | public class SoundListName { 6 | 7 | public SoundListColor value; 8 | public SoundListColor[] colors = new SoundListColor[16]; 9 | 10 | public SoundListName() { 11 | value = new SoundListColor(); 12 | for (int li = 0; li < colors.length; li++) { 13 | colors[li] = value; 14 | } 15 | } 16 | 17 | public void load() { 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/ProxyClient.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob; 2 | 3 | import mmm.lib.ProxyCommon; 4 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 5 | import cpw.mods.fml.client.registry.RenderingRegistry; 6 | 7 | public class ProxyClient extends ProxyCommon { 8 | 9 | @Override 10 | public void init() { 11 | // レンダラの登録 12 | RenderingRegistry.registerEntityRenderingHandler(EntityLittleMaidBase.class, new RenderLittleMaid(0.5F)); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/entity/EntityLittleMaidAvatar.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.entity; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | 5 | import net.minecraft.world.WorldServer; 6 | import net.minecraftforge.common.util.FakePlayer; 7 | 8 | public class EntityLittleMaidAvatar extends FakePlayer { 9 | 10 | public EntityLittleMaidAvatar(WorldServer world, GameProfile name) { 11 | super(world, name); 12 | // TODO Auto-generated constructor stub 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/sound/SoundListColor.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.sound; 2 | 3 | import java.util.Map; 4 | 5 | public class SoundListColor { 6 | 7 | public boolean canUseDefault; 8 | public Map defaultSounds; 9 | public Map sounds; 10 | 11 | public SoundEntry getSound(EnumSound pSound) { 12 | if (sounds.containsKey(pSound)) { 13 | return sounds.get(pSound); 14 | } else if (canUseDefault && defaultSounds.containsKey(pSound)) { 15 | return defaultSounds.get(pSound); 16 | } 17 | return null; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/ai/EntityAIWait.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.ai; 2 | 3 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 4 | import net.minecraft.entity.ai.EntityAISit; 5 | 6 | public class EntityAIWait extends EntityAISit { 7 | 8 | protected EntityLittleMaidBase maid; 9 | 10 | 11 | public EntityAIWait(EntityLittleMaidBase pMaid) { 12 | super(pMaid); 13 | 14 | setMutexBits(5); 15 | maid = pMaid; 16 | } 17 | 18 | @Override 19 | public boolean shouldExecute() { 20 | return maid.isMaidWaitEx() || (!maid.isFreedom() && maid.mstatMasterEntity == null); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/inventory/SlotArmor.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.inventory; 2 | 3 | import cpw.mods.fml.relauncher.Side; 4 | import cpw.mods.fml.relauncher.SideOnly; 5 | import net.minecraft.entity.Entity; 6 | import net.minecraft.inventory.IInventory; 7 | import net.minecraft.inventory.Slot; 8 | import net.minecraft.item.ItemArmor; 9 | import net.minecraft.item.ItemStack; 10 | import net.minecraft.util.IIcon; 11 | 12 | public class SlotArmor extends Slot { 13 | 14 | protected final int type; 15 | protected final Entity owner; 16 | 17 | public SlotArmor(IInventory par1iInventory, int par2, int par3, int par4, int pType, Entity pOwner) { 18 | super(par1iInventory, par2, par3, par4); 19 | type = pType; 20 | owner = pOwner; 21 | } 22 | 23 | @Override 24 | public int getSlotStackLimit() { 25 | return 1; 26 | } 27 | 28 | @Override 29 | public boolean isItemValid(ItemStack par1ItemStack) { 30 | if (par1ItemStack == null) return false; 31 | return par1ItemStack.getItem().isValidArmor(par1ItemStack, type, owner); 32 | } 33 | 34 | @Override 35 | @SideOnly(Side.CLIENT) 36 | public IIcon getBackgroundIconIndex() { 37 | return ItemArmor.func_94602_b(type); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/gui/GuiButtonNextPage.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.gui; 2 | 3 | import net.minecraft.client.Minecraft; 4 | import net.minecraft.client.gui.GuiButton; 5 | import net.minecraft.util.ResourceLocation; 6 | 7 | import org.lwjgl.opengl.GL11; 8 | 9 | /** 10 | * NextButtonの丸パクリ 11 | * 12 | */ 13 | public class GuiButtonNextPage extends GuiButton { 14 | 15 | private static final ResourceLocation bookGuiTextures = new ResourceLocation("textures/gui/book.png"); 16 | private final boolean direction; 17 | 18 | 19 | public GuiButtonNextPage(int par1, int par2, int par3, boolean par4) { 20 | super(par1, par2, par3, 23, 13, ""); 21 | this.direction = par4; 22 | } 23 | 24 | @Override 25 | public void drawButton(Minecraft p_146112_1_, int p_146112_2_, int p_146112_3_) { 26 | if (visible) { 27 | boolean flag = p_146112_2_ >= xPosition 28 | && p_146112_3_ >= yPosition 29 | && p_146112_2_ < xPosition + width 30 | && p_146112_3_ < yPosition + height; 31 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 32 | p_146112_1_.getTextureManager().bindTexture(bookGuiTextures); 33 | int k = 0; 34 | int l = 192; 35 | 36 | if (flag) { 37 | k += 23; 38 | } 39 | 40 | if (!direction) { 41 | l += 13; 42 | } 43 | 44 | drawTexturedModalRect(xPosition, yPosition, k, l, 23, 13); 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/gui/GuiHandler.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.gui; 2 | 3 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 4 | import mmm.littleMaidMob.inventory.ContainerInventory; 5 | import net.minecraft.entity.Entity; 6 | import net.minecraft.entity.player.EntityPlayer; 7 | import net.minecraft.entity.player.EntityPlayerMP; 8 | import net.minecraft.world.World; 9 | import cpw.mods.fml.common.network.IGuiHandler; 10 | 11 | public class GuiHandler implements IGuiHandler { 12 | 13 | @Override 14 | public Object getServerGuiElement(int ID, EntityPlayer player, 15 | World world, int x, int y, int z) { 16 | if (ID == 0) { 17 | Entity lentity = world.getEntityByID(x); 18 | if (lentity instanceof EntityLittleMaidBase) { 19 | ContainerInventory lci = new ContainerInventory((EntityLittleMaidBase)lentity, player); 20 | lci.player = (EntityPlayerMP)player; 21 | return lci; 22 | } 23 | } 24 | return null; 25 | } 26 | 27 | @Override 28 | public Object getClientGuiElement(int ID, EntityPlayer player, 29 | World world, int x, int y, int z) { 30 | if (ID == 0) { 31 | Entity lentity = world.getEntityByID(x); 32 | if (lentity instanceof EntityLittleMaidBase) { 33 | return new GuiLittleMaidInventory((EntityLittleMaidBase)lentity, player); 34 | } 35 | } 36 | return null; 37 | // return new GuiLittleMaidInventory(player.inventory, world, x, y, z); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/mode/ModeController.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.mode; 2 | 3 | import java.util.Map; 4 | 5 | import mmm.littleMaidMob.littleMaidMob; 6 | import net.minecraft.entity.ai.EntityAIBase; 7 | 8 | /** 9 | * モード管理用クラス 10 | * 11 | */ 12 | public class ModeController { 13 | 14 | // default AIs 15 | public EntityAIBase aiSit; 16 | // AI 17 | /* 18 | public EntityAITempt aiTempt; 19 | public LMM_EntityAIBeg aiBeg; 20 | public LMM_EntityAIBegMove aiBegMove; 21 | public EntityAIOpenDoor aiOpenDoor; 22 | public EntityAIRestrictOpenDoor aiCloseDoor; 23 | public LMM_EntityAIAvoidPlayer aiAvoidPlayer; 24 | public LMM_EntityAIFollowOwner aiFollow; 25 | public LMM_EntityAIAttackOnCollide aiAttack; 26 | public LMM_EntityAIAttackArrow aiShooting; 27 | public LMM_EntityAICollectItem aiCollectItem; 28 | public LMM_EntityAIRestrictRain aiRestrictRain; 29 | public LMM_EntityAIFleeRain aiFreeRain; 30 | public LMM_EntityAIWander aiWander; 31 | public LMM_EntityAIJumpToMaster aiJumpTo; 32 | public LMM_EntityAIFindBlock aiFindBlock; 33 | public LMM_EntityAITracerMove aiTracer; 34 | public EntityAISwimming aiSwiming; 35 | public EntityAIPanic aiPanic; 36 | */ 37 | 38 | public Map modeList; 39 | /** 現在実行中のモード */ 40 | public EntityModeBase activeMode; 41 | 42 | 43 | public void addMode(EntityModeBase pMode) { 44 | if (pMode.getName() != null) { 45 | modeList.put(pMode.getName(), pMode); 46 | } else { 47 | littleMaidMob.Debug("ModeClass is NoName: %s", pMode.toString()); 48 | } 49 | } 50 | 51 | public void getMode(String pName) { 52 | 53 | } 54 | 55 | public void setMode(String pName) { 56 | 57 | } 58 | 59 | public void setLastMode() { 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/TileContainer.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import net.minecraft.world.World; 7 | 8 | /** 9 | * ターゲットにしているタイルのコンテナ 10 | * 11 | */ 12 | public class TileContainer { 13 | 14 | public List tiles; 15 | 16 | 17 | public TileContainer() { 18 | tiles = new ArrayList(); 19 | } 20 | 21 | /** 22 | * ブロックの登録 23 | * @param pPosX 24 | * @param pPosY 25 | * @param pPosZ 26 | * @return 27 | */ 28 | public int[] addTile(int pPosX, int pPosY, int pPosZ) { 29 | int[] lib = new int[] {pPosX, pPosY, pPosZ}; 30 | tiles.add(lib); 31 | return lib; 32 | } 33 | public int[] addTile(int[] pPos) { 34 | return addTile(pPos[0], pPos[1], pPos[2]); 35 | } 36 | 37 | public int[] remove(int pPosX, int pPosY, int pPosZ) { 38 | int li = indexOf(pPosX, pPosY, pPosZ); 39 | return tiles.remove(li); 40 | } 41 | 42 | public boolean contain(int pPosX, int pPosY, int pPosZ) { 43 | for (int[] li : tiles) { 44 | if (li[0] == pPosX && li[1] == pPosY && li[2] == pPosZ) { 45 | return true; 46 | } 47 | } 48 | return false; 49 | } 50 | public boolean contain(int[] pPos) { 51 | return contain(pPos[0], pPos[1], pPos[2]); 52 | } 53 | 54 | public int indexOf(int pPosX, int pPosY, int pPosZ) { 55 | for (int[] li : tiles) { 56 | if (li[0] == pPosX && li[1] == pPosY && li[2] == pPosZ) { 57 | return tiles.indexOf(li); 58 | } 59 | } 60 | return -1; 61 | } 62 | 63 | public int[] get(int pIndex) { 64 | return tiles.get(pIndex); 65 | } 66 | 67 | public void clear() { 68 | tiles.clear(); 69 | } 70 | 71 | public int size() { 72 | return tiles.size(); 73 | } 74 | 75 | public void onUpdate(World pWorld) { 76 | // TIleEntityの生存チェック 77 | for (int[] li : tiles) { 78 | if (pWorld.getTileEntity(li[0], li[1], li[2]).isInvalid()) { 79 | // 対象は破壊されたので削除 80 | // TODO これいけるのか? 81 | tiles.remove(li); 82 | } 83 | } 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/gui/GuiLittleMaidInventory.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.gui; 2 | 3 | import org.lwjgl.opengl.GL11; 4 | 5 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 6 | import mmm.littleMaidMob.inventory.ContainerInventory; 7 | import net.minecraft.client.gui.GuiButton; 8 | import net.minecraft.entity.player.EntityPlayer; 9 | import net.minecraft.util.ResourceLocation; 10 | 11 | public class GuiLittleMaidInventory extends GuiEffectRenderer { 12 | 13 | protected static ResourceLocation defGuiTex = new ResourceLocation("mmm", "textures/gui/container/littlemaidinventory.png"); 14 | 15 | public EntityLittleMaidBase maid; 16 | public GuiButtonNextPage txbutton[] = new GuiButtonNextPage[4]; 17 | public GuiButton selectbutton; 18 | 19 | 20 | public GuiLittleMaidInventory(EntityLittleMaidBase pMaid, EntityPlayer pPlayer) { 21 | super(new ContainerInventory(pMaid, pPlayer), pMaid); 22 | maid = pMaid; 23 | ySize = 207; 24 | } 25 | 26 | @SuppressWarnings("unchecked") 27 | @Override 28 | public void initGui() { 29 | super.initGui(); 30 | buttonList.add(txbutton[0] = new GuiButtonNextPage(100, guiLeft + 25, guiTop + 7, false)); 31 | buttonList.add(txbutton[1] = new GuiButtonNextPage(101, guiLeft + 55, guiTop + 7, true)); 32 | buttonList.add(txbutton[2] = new GuiButtonNextPage(110, guiLeft + 25, guiTop + 47, false)); 33 | buttonList.add(txbutton[3] = new GuiButtonNextPage(111, guiLeft + 55, guiTop + 47, true)); 34 | buttonList.add(selectbutton = new GuiButton(200, guiLeft + 25, guiTop + 25, 53, 17, "select")); 35 | } 36 | 37 | @Override 38 | protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { 39 | // 背景 40 | // ResourceLocation lrl = maid.textureData.getGUITexture(); 41 | ResourceLocation lrl = null; 42 | if (lrl == null) { 43 | lrl = defGuiTex; 44 | } 45 | mc.getTextureManager().bindTexture(lrl); 46 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 47 | int lx = guiLeft; 48 | int ly = guiTop; 49 | drawTexturedModalRect(lx, ly, 0, 0, xSize, ySize); 50 | 51 | // LP/AP 52 | // drawHeathArmor(0, 0); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/RenderLittleMaid.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob; 2 | 3 | import mmm.lib.multiModel.RenderMultiModel; 4 | import mmm.lib.multiModel.model.mc162.ModelMultiBase; 5 | import mmm.lib.multiModel.texture.MultiModelContainer; 6 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 7 | import net.minecraft.entity.Entity; 8 | import net.minecraft.entity.EntityLiving; 9 | import net.minecraft.util.ResourceLocation; 10 | 11 | public class RenderLittleMaid extends RenderMultiModel { 12 | 13 | public MultiModelContainer modelContainer; 14 | 15 | 16 | public RenderLittleMaid(float pShadowSize) { 17 | super(pShadowSize); 18 | 19 | modelMain.textures = new ResourceLocation[0]; 20 | // modelMain.textures = new ResourceLocation[] { textures }; 21 | /* 22 | modelMain.model = new ModelLittleMaid_Aug(); 23 | try { 24 | ClassLoader lcl = getClass().getClassLoader(); 25 | Class lc = lcl.loadClass("ModelLittleMaid_Kelo"); 26 | Constructor lcc = lc.getConstructor(); 27 | modelMain.model = lcc.newInstance(); 28 | } catch (Exception e) { 29 | e.printStackTrace(); 30 | } 31 | */ 32 | } 33 | 34 | @Override 35 | public void doRender(EntityLiving par1EntityLiving, double par2, 36 | double par4, double par6, float par8, float par9) { 37 | doRender((EntityLittleMaidBase)par1EntityLiving, par2, par4, par6, par8, par9); 38 | } 39 | 40 | public void doRender(EntityLittleMaidBase pEntity, double pX, double pY, double pZ, float par8, float par9) { 41 | modelMain.isRendering = true; 42 | // modelMain.model = pEntity.getModel(); 43 | // modelContainer = MultiModelManager.instance.getMultiModel("MMM_Aug"); 44 | modelContainer = pEntity.multiModel.model; 45 | modelMain.model = (ModelMultiBase)modelContainer.getModelClass()[0]; 46 | 47 | super.doRender(pEntity, pX, pY, pZ, par8, par9); 48 | } 49 | 50 | @Override 51 | protected ResourceLocation getEntityTexture(Entity var1) { 52 | // TODO Auto-generated method stub 53 | // return ((EntityLittleMaidMob)var1).getTexture(); 54 | // return textures; 55 | return modelContainer.getTexture(((EntityLittleMaidBase)var1).multiModel.getColor()); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/sound/SoundManager.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.sound; 2 | 3 | import mmm.lib.destroyAll.DestroyAllManager; 4 | import mmm.littleMaidMob.littleMaidMob; 5 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 6 | import net.minecraft.client.audio.PositionedSoundRecord; 7 | import net.minecraft.entity.Entity; 8 | import net.minecraft.util.ResourceLocation; 9 | import cpw.mods.fml.client.FMLClientHandler; 10 | import cpw.mods.fml.common.eventhandler.SubscribeEvent; 11 | import cpw.mods.fml.common.network.FMLEventChannel; 12 | import cpw.mods.fml.common.network.FMLNetworkEvent; 13 | import cpw.mods.fml.common.network.NetworkRegistry; 14 | 15 | public class SoundManager { 16 | 17 | public static DestroyAllManager instance; 18 | public static String packetChannel = "LMM|SND"; 19 | public static FMLEventChannel serverEventChannel; 20 | 21 | 22 | public static void Debug(String pText, Object... pData) { 23 | // デバッグメッセージ 24 | if (littleMaidMob.isDebugMessage) { 25 | System.out.println(String.format("LMM|Sound-" + pText, pData)); 26 | } 27 | } 28 | 29 | public static void init() { 30 | if (instance instanceof DestroyAllManager) return; 31 | 32 | // ネットワークのハンドラを登録 33 | instance = new DestroyAllManager(); 34 | serverEventChannel = NetworkRegistry.INSTANCE.newEventDrivenChannel(packetChannel); 35 | serverEventChannel.register(instance); 36 | } 37 | 38 | public void sendSoundPacket() { 39 | // サーバーからクライアントへ 40 | 41 | } 42 | 43 | @SubscribeEvent 44 | public void receiveSoundPacket(FMLNetworkEvent.ClientCustomPacketEvent pEvent) { 45 | // クライアントでパケット受信 46 | if (pEvent.packet.channel().contentEquals(packetChannel)) { 47 | Debug("get playSOund Packet from Server."); 48 | Entity lentity = FMLClientHandler.instance().getWorldClient().getEntityByID(0); 49 | int lsoundIndex = 0; 50 | EnumSound lsound = EnumSound.getEnumSound(lsoundIndex); 51 | float lvolume = 0.0F; 52 | float lpitch = 0.0F; 53 | 54 | PositionedSoundRecord positionedsoundrecord = 55 | new PositionedSoundRecord(getSoundResource(lentity, lsound), lvolume, lpitch, 56 | (float)lentity.posX, (float)lentity.posY, (float)lentity.posZ); 57 | FMLClientHandler.instance().getClient().getSoundHandler().playSound(positionedsoundrecord); 58 | } 59 | } 60 | 61 | 62 | public void playSound(EntityLittleMaidBase pEntity, EnumSound pSound, 63 | float pVolume, float pPitch, boolean pCanOverwrite) { 64 | 65 | } 66 | 67 | public ResourceLocation getSoundResource(Entity pEntity, EnumSound pSound) { 68 | return null; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/gui/GuiEffectRenderer.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.gui; 2 | 3 | import java.util.Collection; 4 | import java.util.Iterator; 5 | 6 | import org.lwjgl.opengl.GL11; 7 | 8 | import net.minecraft.client.gui.inventory.GuiContainer; 9 | import net.minecraft.client.resources.I18n; 10 | import net.minecraft.entity.EntityLivingBase; 11 | import net.minecraft.inventory.Container; 12 | import net.minecraft.potion.Potion; 13 | import net.minecraft.potion.PotionEffect; 14 | 15 | /** 16 | * InventoryEffectRendererの丸パクリ
17 | * プレーヤー以外のエフェクトも対象にする 18 | */ 19 | public abstract class GuiEffectRenderer extends GuiContainer { 20 | 21 | protected EntityLivingBase target; 22 | protected boolean isEffect; 23 | 24 | 25 | public GuiEffectRenderer(Container par1Container, EntityLivingBase pTarget) { 26 | super(par1Container); 27 | target = pTarget; 28 | } 29 | 30 | @Override 31 | public void initGui() { 32 | super.initGui(); 33 | 34 | if (!target.getActivePotionEffects().isEmpty()) { 35 | guiLeft = 160 + (width - xSize - 200) / 2; 36 | isEffect = true; 37 | } 38 | } 39 | 40 | @Override 41 | public void drawScreen(int par1, int par2, float par3) { 42 | super.drawScreen(par1, par2, par3); 43 | 44 | if (isEffect) { 45 | drawEffects(); 46 | } 47 | } 48 | 49 | /** 50 | * ポーションエフェクトを描画する 51 | */ 52 | protected void drawEffects() { 53 | int i = guiLeft - 124; 54 | int j = guiTop; 55 | 56 | Collection collection = target.getActivePotionEffects(); 57 | 58 | if (!collection.isEmpty()) { 59 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 60 | GL11.glDisable(GL11.GL_LIGHTING); 61 | GL11.glEnable(GL11.GL_BLEND); 62 | int k = 33; 63 | 64 | if (collection.size() > 5) { 65 | k = 132 / (collection.size() - 1); 66 | } 67 | 68 | for (Iterator iterator = target.getActivePotionEffects().iterator(); 69 | iterator.hasNext(); j += k) { 70 | PotionEffect potioneffect = (PotionEffect) iterator.next(); 71 | Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; 72 | GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 73 | mc.getTextureManager().bindTexture(field_147001_a); 74 | drawTexturedModalRect(i, j, 0, 166, 140, 32); 75 | 76 | if (potion.hasStatusIcon()) { 77 | int l = potion.getStatusIconIndex(); 78 | drawTexturedModalRect(i + 6, j + 7, 0 + l % 8 * 18, 79 | 198 + l / 8 * 18, 18, 18); 80 | } 81 | 82 | String s1 = I18n.format(potion.getName(), new Object[0]); 83 | 84 | if (potioneffect.getAmplifier() == 1) { 85 | s1 = s1 + " II"; 86 | } else if (potioneffect.getAmplifier() == 2) { 87 | s1 = s1 + " III"; 88 | } else if (potioneffect.getAmplifier() == 3) { 89 | s1 = s1 + " IV"; 90 | } 91 | 92 | fontRendererObj.drawStringWithShadow( 93 | s1, i + 10 + 18, j + 6, 0xffffff); 94 | String s = Potion.getDurationString(potioneffect); 95 | fontRendererObj.drawStringWithShadow( 96 | s, i + 10 + 18, j + 6 + 10, 0x7f7f7f); 97 | } 98 | } 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/inventory/ContainerInventory.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.inventory; 2 | 3 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 4 | import net.minecraft.entity.player.EntityPlayer; 5 | import net.minecraft.inventory.Container; 6 | import net.minecraft.inventory.Slot; 7 | import net.minecraft.item.ItemStack; 8 | 9 | public class ContainerInventory extends Container { 10 | 11 | public EntityLittleMaidBase maid; 12 | public EntityPlayer player; 13 | protected int numRows; 14 | 15 | 16 | public ContainerInventory(EntityLittleMaidBase pMaid, EntityPlayer pPlayer) { 17 | maid = pMaid; 18 | player = pPlayer; 19 | 20 | // Slotの構築 21 | maid.inventory.openInventory(); 22 | 23 | numRows = maid.inventory.getSizeInventory() / 9; 24 | for (int ly = 0; ly < numRows; ly++) { 25 | for (int lx = 0; lx < 9; lx++) { 26 | addSlotToContainer(new Slot(maid.inventory, lx + ly * 9, 8 + lx * 18, 76 + ly * 18)); 27 | } 28 | } 29 | 30 | int lyoffset = (numRows - 4) * 18 + 59; 31 | for (int ly = 0; ly < 3; ly++) { 32 | for (int lx = 0; lx < 9; lx++) { 33 | addSlotToContainer(new Slot(player.inventory, lx + ly * 9 + 9, 8 + lx * 18, 103 + ly * 18 + lyoffset)); 34 | } 35 | } 36 | 37 | for (int lx = 0; lx < 9; lx++) { 38 | addSlotToContainer(new Slot(player.inventory, lx, 8 + lx * 18, 161 + lyoffset)); 39 | } 40 | 41 | for (int j = 0; j < 3; j++) { 42 | addSlotToContainer(new SlotArmor(maid.inventory, maid.inventory.getSizeInventory() - 2 - j, 8, 8 + j * 18, j + 1, maid)); 43 | } 44 | 45 | } 46 | 47 | @Override 48 | public boolean canInteractWith(EntityPlayer var1) { 49 | // 開けるかどうかの判定 50 | if(maid.isDead) { 51 | // if(maid.isDead || maid.isOpenInventory()) { 52 | return false; 53 | } 54 | return maid.getDistanceSqToEntity(var1) <= 64D; 55 | } 56 | 57 | @Override 58 | public void onContainerClosed(EntityPlayer par1EntityPlayer) { 59 | // 閉じた時の処理 60 | super.onContainerClosed(par1EntityPlayer); 61 | maid.inventory.closeInventory(); 62 | } 63 | 64 | @Override 65 | public ItemStack slotClick(int par1, int par2, int par3, 66 | EntityPlayer par4EntityPlayer) { 67 | // TODO Auto-generated method stub 68 | return super.slotClick(par1, par2, par3, par4EntityPlayer); 69 | } 70 | 71 | @Override 72 | public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int pIndex) { 73 | ItemStack litemstack = null; 74 | Slot slot = (Slot)inventorySlots.get(pIndex); 75 | if (slot != null && slot.getHasStack()) { 76 | ItemStack itemstack1 = slot.getStack(); 77 | litemstack = itemstack1.copy(); 78 | int lline = numRows * 9; 79 | if (pIndex < lline) { 80 | if (!this.mergeItemStack(itemstack1, lline, lline + 36, true)) { 81 | return null; 82 | } 83 | } else if (pIndex >= lline && pIndex < lline + 36) { 84 | if (!this.mergeItemStack(itemstack1, 0, lline, false)) { 85 | return null; 86 | } 87 | } else { 88 | if (!this.mergeItemStack(itemstack1, 0, lline + 36, false)) { 89 | return null; 90 | } 91 | } 92 | if (itemstack1.stackSize == 0) { 93 | slot.putStack(null); 94 | } else { 95 | slot.onSlotChanged(); 96 | } 97 | } 98 | return litemstack; 99 | } 100 | 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/sound/EnumSound.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.sound; 2 | 3 | public enum EnumSound { 4 | 5 | death(0x100, "Deid Voice. Null is no Voice", "mob.ghast.death", null), 6 | attack(0x110, "Attack Voice. Null is no Voice", "mob.ghast.charge", null), 7 | attack_bloodsuck(0x111, "Attack Bloodsucker Voice. Null is no Voice", "^", attack), 8 | laughter(0x120, "Laughter Voice. Null is no Voice", "", null), 9 | shoot(0x130, "shoot Voice. Null is no Voice", "mob.ghast.charge", attack), 10 | shoot_burst(0x131, "burst shoot Voice. Null is no Voice", "mob.ghast.charge", attack), 11 | sighting(0x140, "Adopt a fire Voice. Null is no Voice", "", null), 12 | healing(0x150, "Healing Voice. Null is no Voice", "", null), 13 | healing_potion(0x151, "Healing with potion Voice. Null is no Voice", "", healing), 14 | TNT_D(0x160, "Enable TNT-D Voice. Null is no Voice", "", null), 15 | // eatGunpowder(0x161, "Eat Gunpowder Voice. Null is no Voice", "^"), 16 | 17 | eatSugar(0x200, "Eat Sugar Voice. Null is no Voice", "", null), 18 | eatSugar_MaxPower(0x201, "Eat Sugar to MAX healing Voice. Null is no Voice", "", null), 19 | getCake(0x210, "Get Cake Voice. Null is no Voice", "", null), 20 | Recontract(0x211, "Recontract Voice. Null is no Voice", "", getCake), 21 | addFuel(0x220, "Add Fuel Voice. Null is no Voice", "", null), 22 | cookingStart(0x221, "Cooking Start Voice. Null is no Voice", "", null), 23 | cookingOver(0x222, "Cooking Over Voice. Null is no Voice", "", null), 24 | installation(0x230, "Installation Voice. Null is no Voice", "", null), 25 | collect_snow(0x240, "Collecting snow Voice. Null is no Voice", "", null), 26 | 27 | hurt(0x300, "Dameged Voice. Null is no Voice", "mob.ghast.scream", null), 28 | hurt_snow(0x301, "Dameged Voice from snowball. Null is no Voice", "", hurt), 29 | hurt_fire(0x302, "Dameged Voice from fire. Null is no Voice", "", hurt), 30 | hurt_guard(0x303, "Dameged Voice on Guard. Null is no Voice", "mob.blaze.hit", hurt), 31 | hurt_fall(0x304, "Dameged Voice from Fall. Null is no Voice", "", hurt), 32 | hurt_nodamege(0x309, "No Dameged Voice. Null is no Voice", "mob.blaze.hit", hurt), 33 | 34 | findTarget_N(0x400, "Find target Normal Voice. Null is no Voice", "", null), 35 | findTarget_B(0x401, "Find target Bloodsuck Voice. Null is no Voice", "", findTarget_N), 36 | findTarget_I(0x402, "Find target Item Voice. Null is no Voice", "", null), 37 | findTarget_D(0x403, "Find target Darkness Voice. Null is no Voice", "", null), 38 | 39 | living_daytime(0x500, "Living Voice(Default) in Daytime. Null is no Voice", "mob.ghast.moan", null), 40 | living_morning(0x501, "Living Voice in Mornig. Null is no Voice", "^", living_daytime), 41 | living_night(0x502, "Living Voice in Night. Null is no Voice", "^", living_daytime), 42 | living_whine(0x503, "Living Voice at Whine. Null is no Voice", "^", living_daytime), 43 | living_rain(0x504, "Living Voice at Rain. Null is no Voice", "^", living_daytime), 44 | living_snow(0x505, "Living Voice at Snow. Null is no Voice", "^", living_daytime), 45 | living_cold(0x506, "Living Voice at Cold. Null is no Voice", "^", living_daytime), 46 | living_hot(0x507, "Living Voice at Hot. Null is no Voice", "^", living_daytime), 47 | goodmorning(0x551, "Goodmorning Voice. Null is no Voice", "mob.wolf.bark", null), 48 | goodnight(0x561, "Goodnight Voice. Null is no Voice", "mob.ghast.affectionate scream", null), 49 | 50 | Null(0, "", null, null); 51 | 52 | 53 | public final int index; 54 | public final String info; 55 | public final String DefaultValue; 56 | public final EnumSound alterValue; 57 | 58 | 59 | 60 | private EnumSound(int pIndex, String pInfo, String pDefault, EnumSound pAlter) { 61 | index = pIndex; 62 | info = pInfo; 63 | DefaultValue = pDefault; 64 | alterValue = pAlter; 65 | } 66 | 67 | public static EnumSound getEnumSound(int pindex) { 68 | for (EnumSound le : EnumSound.values()) { 69 | if (le.index == pindex) { 70 | return le; 71 | } 72 | } 73 | return Null; 74 | } 75 | 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/Statics.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob; 2 | 3 | public class Statics { 4 | 5 | /** Absoption効果をクライアント側へ転送するのに使う */ 6 | public static final int dataWatch_Absoption = 18; 7 | 8 | /** メイドカラー(byte) */ 9 | public static final int dataWatch_Color = 19; 10 | /** 11 | * MSB|0x0000 0000|LSB
12 | * | |本体のテクスチャインデックス
13 | * |アーマーのテクスチャインデックス
14 | */ 15 | public static final int dataWatch_Texture = 20; 16 | /** モデルパーツの表示フラグ(Integer) */ 17 | public static final int dataWatch_Parts = 21; 18 | /** 19 | * 各種フラグを一纏めにしたもの。 20 | */ 21 | public static final int dataWatch_Flags = 22; 22 | public static final int dataWatch_Flags_looksWithInterest = 0x00000001; 23 | public static final int dataWatch_Flags_looksWithInterestAXIS = 0x00000002; 24 | public static final int dataWatch_Flags_Aimebow = 0x00000004; 25 | public static final int dataWatch_Flags_Freedom = 0x00000008; 26 | public static final int dataWatch_Flags_Tracer = 0x00000010; 27 | public static final int dataWatch_Flags_remainsContract = 0x00000020; 28 | public static final int dataWatch_Flags_PlayingMode = 0x00000040; 29 | public static final int dataWatch_Flags_Working = 0x00000080; 30 | public static final int dataWatch_Flags_Wait = 0x00000100; 31 | public static final int dataWatch_Flags_WaitEx = 0x00000200; 32 | public static final int dataWatch_Flags_LooksSugar = 0x00000400; 33 | public static final int dataWatch_Flags_Bloodsuck = 0x00000800; 34 | public static final int dataWatch_Flags_OverDrive = 0x00001000; 35 | /** 紐の持ち主のEntityID。 */ 36 | public static final int dataWatch_Gotcha = 23; 37 | 38 | /** メイドモード(Short) */ 39 | public static final int dataWatch_Mode = 24; 40 | /** 利き腕(Byte) */ 41 | public static final int dataWatch_DominamtArm = 25; 42 | /** アイテムの使用判定、腕毎(Integer) */ 43 | public static final int dataWatch_ItemUse = 26; 44 | /** 保持経験値、実のところクライアント側では必要ないので要らない(Integer) */ 45 | public static final int dataWatch_ExpValue = 27; 46 | 47 | 48 | 49 | /** 50 | * 自由設定値。 51 | */ 52 | public static final int dataWatch_Free = 31; 53 | 54 | public static final int dataFlags_ForceUpdateInventory = 0x80000000; 55 | 56 | // NetWork 57 | 58 | /* 59 | * 動作用定数、8bit目を立てるとEntity要求 60 | */ 61 | 62 | /* 63 | * LMMPacetのフォーマット 64 | * (Byte) 65 | * 0 : 識別(1byte) 66 | * 1 - 4: EntityID(4Byte)場合に寄っては省略 67 | * 5 - : Data 68 | * 69 | */ 70 | /** 71 | * サーバー側へ対象のインベントリを送信するように指示する。 72 | * スポーン時点ではインベントリ情報が無いため。 73 | * [0] : 0x00; 74 | * [1..4] : EntityID(int); 75 | */ 76 | public static final byte LMN_Server_UpdateSlots = (byte)0x80; 77 | /** 78 | * クライアント側へ腕振りを指示する。 79 | * 振った時の再生音声も指定する。 80 | * [0] : 0x81; 81 | * [1..4] : EntityID(int); 82 | * [5] : ArmIndex(byte); 83 | * [6..9] : SoundIndex(int); 84 | */ 85 | public static final byte LMN_Client_SwingArm = (byte)0x81; 86 | /** 87 | * サーバー側へ染料の使用を通知する。 88 | * GUISelect用。 89 | * [0] : 0x02; 90 | * [1] : color(byte); 91 | */ 92 | public static final byte LMN_Server_DecDyePowder = (byte)0x02; 93 | /** 94 | * サーバーへIFFの設定値が変更されたことを通知する。 95 | * [0] : 0x04; 96 | * [1] : IFFValue(byte); 97 | * [2..5] : Index(int); 98 | * [6..] : TargetName(str); 99 | */ 100 | public static final byte LMN_Server_SetIFFValue = (byte)0x04; 101 | /** 102 | * クライアントへIFFの設定値を通知する。 103 | * [0] : 0x04; 104 | * [1] : IFFValue(byte); 105 | * [2..5] : Index(int); 106 | */ 107 | public static final byte LMN_Client_SetIFFValue = (byte)0x04; 108 | /** 109 | * サーバーへ現在のIFFの設定値を要求する。 110 | * 要求時は一意な識別番号を付与すること。 111 | * [0] : 0x05; 112 | * [1..4] : Index(int); 113 | * [5..] : TargetName(str); 114 | */ 115 | public static final byte LMN_Server_GetIFFValue = (byte)0x05; 116 | /** 117 | * サーバーへIFFの設定値を保存するように指示する。 118 | * [0] : 0x06; 119 | */ 120 | public static final byte LMN_Server_SaveIFF = (byte)0x06; 121 | /** 122 | * クライアント側へ音声を発生させるように指示する。 123 | * 音声の自体はクライアント側の登録音声を使用するため標準の再生手順だと音がでないため。 124 | * [0] : 0x07; 125 | * [1..4] : EntityID(int); 126 | * [5..8] : SoundIndex(int); 127 | */ 128 | public static final byte LMN_Client_PlaySound = (byte)0x89; 129 | 130 | 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/littleMaidMob.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob; 2 | 3 | import java.io.File; 4 | 5 | import mmm.lib.ProxyCommon; 6 | import mmm.lib.multiModel.MultiModelHandler; 7 | import mmm.lib.multiModel.texture.MultiModelData; 8 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 9 | import mmm.littleMaidMob.gui.GuiHandler; 10 | import net.minecraft.entity.EnumCreatureType; 11 | import net.minecraft.init.Items; 12 | import net.minecraft.item.ItemStack; 13 | import net.minecraft.world.biome.BiomeGenBase; 14 | import net.minecraftforge.common.BiomeDictionary; 15 | import net.minecraftforge.common.config.Configuration; 16 | import cpw.mods.fml.common.Mod; 17 | import cpw.mods.fml.common.Mod.Instance; 18 | import cpw.mods.fml.common.SidedProxy; 19 | import cpw.mods.fml.common.event.FMLInitializationEvent; 20 | import cpw.mods.fml.common.event.FMLPostInitializationEvent; 21 | import cpw.mods.fml.common.event.FMLPreInitializationEvent; 22 | import cpw.mods.fml.common.network.NetworkRegistry; 23 | import cpw.mods.fml.common.registry.EntityRegistry; 24 | import cpw.mods.fml.common.registry.GameRegistry; 25 | 26 | @Mod( 27 | modid = "littleMaidMob", 28 | name = "LittleMaidMob" 29 | ) 30 | public class littleMaidMob { 31 | 32 | @SidedProxy(clientSide = "mmm.littleMaidMob.ProxyClient", serverSide = "mmm.lib.ProxyCommon") 33 | public static ProxyCommon proxy; 34 | @Instance("littleMaidMob") 35 | public static littleMaidMob instance; 36 | 37 | public static boolean isDebugMessage = true; 38 | 39 | public static int spawnWeight = 5; 40 | public static int spawnMin = 1; 41 | public static int spawnMax = 3; 42 | public static String[] spawnBiomes; 43 | public static boolean canDespawn = false; 44 | public static boolean addSpawnEggRecipe = false; 45 | public static boolean isNetherLand = false; 46 | 47 | private static int gueid = 0; 48 | 49 | 50 | public static void Debug(String pText, Object... pData) { 51 | // デバッグメッセージ 52 | if (isDebugMessage) { 53 | System.out.println(String.format("littleMaidMob-" + pText, pData)); 54 | } 55 | } 56 | 57 | @Mod.EventHandler 58 | public void preInit(FMLPreInitializationEvent pEvent) { 59 | // コンフィグの解析・設定 60 | String ls = "littleMaidMob"; 61 | File configFile = pEvent.getSuggestedConfigurationFile(); 62 | Configuration lconf = new Configuration(configFile); 63 | lconf.load(); 64 | isDebugMessage = lconf.get(ls, "isDebugMessage", false).getBoolean(false); 65 | 66 | spawnWeight = lconf.get(ls, "spawnWeight", 5).getInt(); 67 | spawnMin = lconf.get(ls, "spawnMin", 1).getInt(); 68 | spawnMax = lconf.get(ls, "spawnMax", 3).getInt(); 69 | spawnBiomes = lconf.get(ls, "spawnBiomes", new String[] { 70 | "FOREST", 71 | "PLAINS", 72 | "MOUNTAIN", 73 | "HILLS", 74 | "SWAMP", 75 | "WATER", 76 | "DESERT", 77 | "FROZEN", 78 | "JUNGLE", 79 | "WASTELAND", 80 | "BEACH", 81 | // "NETHER", 82 | // "END", 83 | "MUSHROOM", 84 | "MAGICAL" 85 | }).getStringList(); 86 | canDespawn = lconf.get(ls, "canDespawn", false).getBoolean(false); 87 | addSpawnEggRecipe = lconf.get(ls, "addSpawnEggRecipe", false).getBoolean(false); 88 | lconf.save(); 89 | 90 | gueid = EntityRegistry.findGlobalUniqueEntityId(); 91 | EntityRegistry.registerGlobalEntityID(EntityLittleMaidBase.class, ls, gueid, 0xefffef, 0x9f5f5f); 92 | EntityRegistry.registerModEntity(EntityLittleMaidBase.class, ls, gueid, this, 80, 3, true); 93 | 94 | } 95 | 96 | @Mod.EventHandler 97 | public void init(FMLInitializationEvent pEvent) { 98 | // レンダラの登録 99 | proxy.init(); 100 | 101 | // GUIハンドラ 102 | NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); 103 | 104 | // スポーンエッグのレシピを追加 105 | if (addSpawnEggRecipe) { 106 | GameRegistry.addRecipe(new ItemStack(Items.spawn_egg, 1, gueid), new Object[] { 107 | "scs", 108 | "sbs", 109 | " e ", 110 | Character.valueOf('s'), Items.sugar, 111 | Character.valueOf('c'), new ItemStack(Items.dye, 1, 3), 112 | Character.valueOf('b'), Items.slime_ball, 113 | Character.valueOf('e'), Items.egg, 114 | }); 115 | } 116 | 117 | MultiModelHandler.init(); 118 | MultiModelHandler.instance.registerEntityClass(EntityLittleMaidBase.class, MultiModelData.class, "default"); 119 | } 120 | 121 | @Mod.EventHandler 122 | public void loaded(FMLPostInitializationEvent pEvent) { 123 | 124 | addSpawns(); 125 | } 126 | 127 | private void addSpawns() { 128 | // スポーン領域の登録 129 | if (spawnWeight > 0) { 130 | BiomeGenBase[] lbiome; 131 | for (String ls : spawnBiomes) { 132 | BiomeDictionary.Type ltype = BiomeDictionary.Type.valueOf(ls); 133 | if (ltype != null) { 134 | lbiome = BiomeDictionary.getBiomesForType(ltype); 135 | EntityRegistry.addSpawn(EntityLittleMaidBase.class, 136 | spawnWeight, spawnMin, spawnMax, 137 | EnumCreatureType.creature, lbiome); 138 | Debug("addSpawn:%s", lbiome.toString()); 139 | } 140 | } 141 | if (isNetherLand) { 142 | lbiome = BiomeDictionary.getBiomesForType(BiomeDictionary.Type.NETHER); 143 | EntityRegistry.addSpawn(EntityLittleMaidBase.class, 144 | spawnWeight, spawnMin, spawnMax, 145 | EnumCreatureType.creature, lbiome); 146 | Debug("addSpawn:%s", lbiome.toString()); 147 | } 148 | } 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/inventory/InventoryLittleMaid.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.inventory; 2 | 3 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 4 | import net.minecraft.block.Block; 5 | import net.minecraft.block.BlockTNT; 6 | import net.minecraft.block.material.Material; 7 | import net.minecraft.entity.player.EntityPlayer; 8 | import net.minecraft.entity.player.InventoryPlayer; 9 | import net.minecraft.item.ItemArmor; 10 | import net.minecraft.item.ItemStack; 11 | import net.minecraft.item.crafting.FurnaceRecipes; 12 | import net.minecraft.nbt.NBTTagList; 13 | import net.minecraft.tileentity.TileEntityFurnace; 14 | import net.minecraft.util.MathHelper; 15 | import net.minecraft.world.Explosion; 16 | 17 | public class InventoryLittleMaid extends InventoryPlayer { 18 | 19 | public EntityLittleMaidBase maid; 20 | public boolean isOpen; 21 | 22 | 23 | public InventoryLittleMaid(EntityLittleMaidBase pMaid) { 24 | super(pMaid.avatar); 25 | mainInventory = new ItemStack[getInitInvSize()]; 26 | maid = pMaid; 27 | isOpen = false; 28 | } 29 | 30 | /** 31 | * 初期化時のインベントリサイズ 32 | * @return 33 | */ 34 | protected int getInitInvSize() { 35 | // メイドインベントリはプレーヤの半分 36 | return 18; 37 | } 38 | 39 | public static int getHotbarSize() { 40 | return 18; 41 | } 42 | 43 | /** 44 | * インベントリのどこでもカレントアイテムに成り得る 45 | */ 46 | @Override 47 | public ItemStack getCurrentItem() { 48 | if (currentItem >= 0 && currentItem < mainInventory.length) { 49 | return mainInventory[currentItem]; 50 | } else { 51 | return null; 52 | } 53 | } 54 | 55 | public void decrementAnimations() { 56 | // 落ちないようにtryで括る 57 | // アニメーション処理ってか毎時処理 58 | for (int i = 0; i < mainInventory.length; i++) { 59 | try { 60 | if (mainInventory[i] != null) 61 | mainInventory[i].updateAnimation(maid.worldObj, maid, i, currentItem == i); 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | } 65 | } 66 | // EntityPlayerにしか対応してねぇ・・・ 67 | for (int i = 0; i < armorInventory.length; i++) { 68 | try { 69 | if (armorInventory[i] != null) 70 | armorInventory[i].getItem().onArmorTick(maid.worldObj, player, armorInventory[i]); 71 | } catch (Exception e) { 72 | e.printStackTrace(); 73 | } 74 | } 75 | } 76 | 77 | public int getTotalArmorValue() { 78 | int i = 0; 79 | for (int j = 0; j < armorInventory.length; j++) 80 | if (armorInventory[j] != null 81 | && (armorInventory[j].getItem() instanceof ItemArmor)) { 82 | int k = ((ItemArmor) armorInventory[j].getItem()).damageReduceAmount; 83 | i += k; 84 | } 85 | 86 | return i; 87 | } 88 | 89 | @Override 90 | public void damageArmor(float par1) { 91 | // ダメージを装備で分散 92 | par1 /= 3F; 93 | // 最低ダメージ保証 94 | if (par1 < 1.0F) par1 = 1.0F; 95 | // 各部にダメージ 96 | for (int i = 0; i < armorInventory.length; i++) { 97 | if (i == 3) continue; 98 | if (armorInventory[i] == null 99 | || !(armorInventory[i].getItem() instanceof ItemArmor)) 100 | continue; 101 | armorInventory[i].damageItem((int) par1, maid); 102 | if (armorInventory[i].stackSize == 0) 103 | armorInventory[i] = null; 104 | } 105 | } 106 | 107 | /** 108 | * インベントリをブチマケロ! 109 | * @param detonator 110 | */ 111 | public void dropAllItems(boolean detonator) { 112 | Explosion lexp = null; 113 | if (detonator) { 114 | // Mobによる破壊の是非 115 | lexp = new Explosion(maid.worldObj, maid, 116 | maid.posX, maid.posY, maid.posZ, 3F); 117 | lexp.isFlaming = false; 118 | lexp.isSmoking = maid.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"); 119 | } 120 | 121 | armorInventory[3] = null; 122 | for (int i = 0; i < getSizeInventory(); i++) { 123 | ItemStack it = getStackInSlot(i); 124 | if (it != null) { 125 | if (detonator && isItemExplord(i)) { 126 | Block lblock = Block.getBlockFromItem(it.getItem()); 127 | if (lblock instanceof BlockTNT) { 128 | BlockTNT ltnt = (BlockTNT)lblock; 129 | for (int l = 0; l < it.stackSize; l++) { 130 | // 爆薬ぶちまけ 131 | ltnt.onBlockDestroyedByExplosion( 132 | maid.worldObj, 133 | MathHelper.floor_double(maid.posX) 134 | + maid.getRNG().nextInt(7) - 3, 135 | MathHelper.floor_double(maid.posY) 136 | + maid.getRNG().nextInt(7) - 3, 137 | MathHelper.floor_double(maid.posZ) 138 | + maid.getRNG().nextInt(7) - 3, 139 | lexp); 140 | } 141 | } 142 | } else { 143 | maid.entityDropItem(it, 0F); 144 | } 145 | } 146 | setInventorySlotContents(i, null); 147 | } 148 | if (detonator) { 149 | lexp.doExplosionA(); 150 | lexp.doExplosionB(true); 151 | } 152 | } 153 | 154 | @Override 155 | public void dropAllItems() { 156 | dropAllItems(false); 157 | } 158 | 159 | @Override 160 | public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) { 161 | return maid.isDead ? false : par1EntityPlayer.getDistanceSqToEntity(maid) <= 64D; 162 | } 163 | 164 | // ロード 165 | @Override 166 | public void readFromNBT(NBTTagList par1nbtTagList) { 167 | super.readFromNBT(par1nbtTagList); 168 | // インベントリのサイズを変更する 169 | ItemStack[] lmi = new ItemStack[getInitInvSize()]; 170 | for (int li = 0; li < lmi.length; li++) { 171 | lmi[li] = mainInventory[li]; 172 | } 173 | mainInventory = lmi; 174 | } 175 | 176 | @Override 177 | public String getInventoryName() { 178 | return "container.insideSkirt"; 179 | } 180 | 181 | 182 | // アイテムの状態識別 183 | 184 | /** 185 | * 燃えるアイテムか? 186 | * @param index スロット 187 | * @return 188 | */ 189 | public boolean isItemBurned(int index) { 190 | return index > -1 && isItemBurned(getStackInSlot(index)); 191 | } 192 | public static boolean isItemBurned(ItemStack pItemstack) { 193 | return (pItemstack != null && 194 | TileEntityFurnace.getItemBurnTime(pItemstack) > 0); 195 | } 196 | 197 | /** 198 | * 精錬アイテムか? 199 | * @param index スロット 200 | * @return 201 | */ 202 | public boolean isItemSmelting(int index) { 203 | return isItemSmelting(getStackInSlot(index)); 204 | } 205 | public static boolean isItemSmelting(ItemStack pItemstack) { 206 | return (pItemstack != null && 207 | FurnaceRecipes.smelting().getSmeltingResult(pItemstack) != null); 208 | } 209 | 210 | /** 211 | * 爆発物? 212 | * @param index スロット 213 | * @return 214 | */ 215 | public boolean isItemExplord(int index) { 216 | return (index >= 0) && isItemExplord(getStackInSlot(index)); 217 | } 218 | public static boolean isItemExplord(ItemStack pItemstack) { 219 | if (pItemstack == null) return false; 220 | Block lblock = Block.getBlockFromItem(pItemstack.getItem()); 221 | return (pItemstack != null && lblock != null && 222 | lblock.getMaterial() == Material.tnt); 223 | } 224 | 225 | @Override 226 | public void openInventory() { 227 | super.openInventory(); 228 | isOpen = true; 229 | maid.onGuiOpened(); 230 | } 231 | 232 | @Override 233 | public void closeInventory() { 234 | super.closeInventory(); 235 | isOpen = false; 236 | maid.onGuiClosed(); 237 | } 238 | 239 | } 240 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/SwingStatus.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob; 2 | 3 | import java.lang.reflect.Method; 4 | 5 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 6 | import net.minecraft.entity.Entity; 7 | import net.minecraft.entity.EntityLivingBase; 8 | import net.minecraft.entity.player.EntityPlayer; 9 | import net.minecraft.item.EnumAction; 10 | import net.minecraft.item.Item; 11 | import net.minecraft.item.ItemStack; 12 | import net.minecraft.util.Vec3; 13 | import cpw.mods.fml.relauncher.ReflectionHelper; 14 | 15 | public class SwingStatus { 16 | 17 | /** 使用中のアイテムスロット */ 18 | public int index; 19 | public int lastIndex; 20 | /* 腕振り関連変数 */ 21 | public boolean isSwingInProgress; 22 | public float swingProgress; 23 | public float prevSwingProgress; 24 | public int swingProgressInt; 25 | public float onGround; 26 | /** クールタイム */ 27 | public int attackTime; 28 | // public int usingCount; 29 | public int itemInUseCount; 30 | protected ItemStack itemInUse; 31 | 32 | 33 | 34 | public SwingStatus() { 35 | index = lastIndex = -1; 36 | isSwingInProgress = false; 37 | swingProgress = prevSwingProgress = 0.0F; 38 | onGround = 0F; 39 | attackTime = 0; 40 | itemInUseCount = 0; 41 | itemInUse = null; 42 | } 43 | 44 | /** 45 | * TODO:数値の更新用、onEntityUpdate内で呼ぶ事:いらんか? 46 | */ 47 | public void onEntityUpdate(EntityLittleMaidBase pEntity) { 48 | prevSwingProgress = swingProgress; 49 | } 50 | 51 | /** 52 | * 数値の更新用、onUpdate内で呼ぶ事 53 | */ 54 | public void onUpdate(EntityLittleMaidBase pEntity) { 55 | prevSwingProgress = swingProgress; 56 | if (attackTime > 0) { 57 | attackTime--; 58 | } 59 | 60 | // 腕振り 61 | // int li = pEntity.getSwingSpeedModifier(); 62 | // int li = pEntity.getArmSwingAnimationEnd(); 63 | int li = 0; 64 | try { 65 | Method lmethod = ReflectionHelper.findMethod(EntityLivingBase.class, pEntity, new String[] {"getArmSwingAnimationEnd"}); 66 | li = (Integer)lmethod.invoke(pEntity); 67 | } catch (Exception e) { 68 | e.printStackTrace(); 69 | } 70 | if (isSwingInProgress) { 71 | swingProgressInt++; 72 | if(swingProgressInt >= li) { 73 | swingProgressInt = 0; 74 | isSwingInProgress = false; 75 | } 76 | } else { 77 | swingProgressInt = 0; 78 | } 79 | swingProgress = (float)swingProgressInt / (float)li; 80 | 81 | if (isUsingItem()) { 82 | ItemStack itemstack = pEntity.inventory.getStackInSlot(index); 83 | Entity lrentity = pEntity.worldObj.isRemote ? null : pEntity; 84 | 85 | if (itemstack != itemInUse) { 86 | clearItemInUse(lrentity); 87 | } else { 88 | if (itemInUseCount <= 25 && itemInUseCount % 4 == 0) { 89 | // 食べかすとか 90 | updateItemUse(pEntity, 5); 91 | } 92 | if (--itemInUseCount <= 0 && lrentity != null) { 93 | onItemUseFinish(pEntity.avatar); 94 | } 95 | } 96 | } 97 | } 98 | 99 | /** 100 | * 選択中のスロット番号を設定 101 | */ 102 | public void setSlotIndex(int pIndex) { 103 | index = pIndex; 104 | lastIndex = -2; 105 | } 106 | 107 | /** 108 | * 選択中のインベントリ内アイテムスタックを返す 109 | */ 110 | public ItemStack getItemStack(EntityLittleMaidBase pEntity) { 111 | if (index > -1) { 112 | return pEntity.inventory.getStackInSlot(index); 113 | } else { 114 | return null; 115 | } 116 | } 117 | 118 | public boolean canAttack() { 119 | return attackTime <= 0; 120 | } 121 | 122 | 123 | 124 | // 腕振り関係 125 | 126 | 127 | public float getSwingProgress(float ltime) { 128 | float lf = swingProgress - prevSwingProgress; 129 | 130 | if (lf < 0.0F) { 131 | ++lf; 132 | } 133 | 134 | return onGround = prevSwingProgress + lf * ltime; 135 | } 136 | 137 | public boolean setSwinging() { 138 | if (!isSwingInProgress || swingProgressInt < 0) { 139 | swingProgressInt = -1; 140 | isSwingInProgress = true; 141 | return true; 142 | } 143 | return false; 144 | } 145 | 146 | 147 | /** 148 | * 変更があるかどうかを返し、フラグをクリアする。 149 | */ 150 | public boolean checkChanged() { 151 | boolean lflag = index != lastIndex; 152 | lastIndex = index; 153 | return lflag; 154 | } 155 | 156 | // アイテムの使用に関わる関数群 157 | 158 | public ItemStack getItemInUse() { 159 | return itemInUse; 160 | } 161 | 162 | public int getItemInUseCount() { 163 | return itemInUseCount; 164 | } 165 | 166 | public boolean isUsingItem() { 167 | return itemInUse != null; 168 | } 169 | 170 | public int getItemInUseDuration() { 171 | return isUsingItem() ? itemInUse.getMaxItemUseDuration() - itemInUseCount : 0; 172 | } 173 | 174 | /** 175 | * 176 | * @param pEntity 177 | * サーバーの時はEntityを設定する。 178 | */ 179 | public void stopUsingItem(Entity pEntity) { 180 | if (itemInUse != null && pEntity instanceof EntityPlayer) { 181 | itemInUse.onPlayerStoppedUsing(pEntity.worldObj, (EntityPlayer)pEntity, itemInUseCount); 182 | } 183 | 184 | clearItemInUse(pEntity); 185 | } 186 | 187 | /** 188 | * 189 | * @param pEntity 190 | * サーバーの時はEntityを設定する。 191 | */ 192 | public void clearItemInUse(Entity pEntity) { 193 | itemInUse = null; 194 | itemInUseCount = 0; 195 | 196 | if (pEntity != null) { 197 | pEntity.setEating(false); 198 | } 199 | } 200 | 201 | public boolean isBlocking() { 202 | return isUsingItem() && itemInUse.getItem().getItemUseAction(itemInUse) == EnumAction.block; 203 | } 204 | 205 | /** 206 | * 207 | * @param par1ItemStack 208 | * @param par2 209 | * @param pEntity 210 | * サーバーの時はEntityを設定する。 211 | */ 212 | public void setItemInUse(ItemStack par1ItemStack, int par2, Entity pEntity) { 213 | if (par1ItemStack != itemInUse) { 214 | itemInUse = par1ItemStack; 215 | itemInUseCount = par2; 216 | 217 | if (pEntity != null) { 218 | pEntity.setEating(true); 219 | } 220 | } 221 | } 222 | 223 | /** 224 | * アイテムの使用中処理 225 | * @param pEntity 226 | * @param par2 227 | */ 228 | protected void updateItemUse(EntityLivingBase pEntity, int par2) { 229 | // EntityPlayerの丸パクリ 230 | if (itemInUse.getItemUseAction() == EnumAction.drink) { 231 | pEntity.playSound("random.drink", 0.5F, pEntity.worldObj.rand.nextFloat() * 0.1F + 0.9F); 232 | } 233 | 234 | if (itemInUse.getItemUseAction() == EnumAction.eat) { 235 | for (int j = 0; j < par2; ++j) { 236 | Vec3 vec3 = pEntity.worldObj.getWorldVec3Pool().getVecFromPool( 237 | ((double) pEntity.getRNG().nextFloat() - 0.5D) * 0.1D, 238 | Math.random() * 0.1D + 0.1D, 0.0D); 239 | vec3.rotateAroundX(-pEntity.rotationPitch * (float) Math.PI / 180.0F); 240 | vec3.rotateAroundY(-pEntity.rotationYaw * (float) Math.PI / 180.0F); 241 | Vec3 vec31 = pEntity.worldObj.getWorldVec3Pool().getVecFromPool( 242 | ((double) pEntity.getRNG().nextFloat() - 0.5D) * 0.3D, 243 | (double) (-pEntity.getRNG().nextFloat()) * 0.6D - 0.3D, 0.6D); 244 | vec31.rotateAroundX(-pEntity.rotationPitch * (float) Math.PI / 180.0F); 245 | vec31.rotateAroundY(-pEntity.rotationYaw * (float) Math.PI / 180.0F); 246 | vec31 = vec31.addVector(pEntity.posX, 247 | pEntity.posY + (double) pEntity.getEyeHeight(), pEntity.posZ); 248 | String s = "iconcrack_" + Item.getIdFromItem(itemInUse.getItem()); 249 | 250 | if (itemInUse.getHasSubtypes()) { 251 | s = s + "_" + itemInUse.getItemDamage(); 252 | } 253 | 254 | pEntity.worldObj.spawnParticle(s, 255 | vec31.xCoord, vec31.yCoord, vec31.zCoord, 256 | vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord); 257 | } 258 | 259 | pEntity.playSound( 260 | "random.eat", 261 | 0.5F + 0.5F * (float) pEntity.getRNG().nextInt(2), 262 | (pEntity.getRNG().nextFloat() - pEntity.getRNG().nextFloat()) * 0.2F + 1.0F); 263 | } 264 | 265 | } 266 | 267 | protected void onItemUseFinish(EntityPlayer pEntityPlayer) { 268 | if (this.itemInUse != null) { 269 | this.updateItemUse(pEntityPlayer, 16); 270 | int var1 = this.itemInUse.stackSize; 271 | ItemStack var2 = itemInUse.onFoodEaten(pEntityPlayer.worldObj, pEntityPlayer); 272 | 273 | if (var2 != this.itemInUse || var2 != null && var2.stackSize != var1) { 274 | if (var2.stackSize == 0) { 275 | pEntityPlayer.inventory.setInventorySlotContents(index, null); 276 | } else { 277 | pEntityPlayer.inventory.setInventorySlotContents(index, var2); 278 | } 279 | } 280 | 281 | clearItemInUse(pEntityPlayer); 282 | } 283 | } 284 | 285 | } 286 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/mode/EntityModeBase.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.mode; 2 | 3 | import java.util.List; 4 | 5 | import mmm.littleMaidMob.RenderLittleMaid; 6 | import mmm.littleMaidMob.littleMaidMob; 7 | import mmm.littleMaidMob.entity.EntityLittleMaidBase; 8 | import net.minecraft.block.Block; 9 | import net.minecraft.entity.Entity; 10 | import net.minecraft.entity.ai.EntityAITasks; 11 | import net.minecraft.entity.player.EntityPlayer; 12 | import net.minecraft.init.Blocks; 13 | import net.minecraft.item.ItemStack; 14 | import net.minecraft.nbt.NBTTagCompound; 15 | import net.minecraft.tileentity.TileEntity; 16 | import net.minecraft.util.DamageSource; 17 | import net.minecraft.util.MovingObjectPosition; 18 | import net.minecraft.util.MovingObjectPosition.MovingObjectType; 19 | import net.minecraft.util.Vec3; 20 | import net.minecraft.world.World; 21 | 22 | /** 23 | * LMM用独自AI処理に使用。 24 | * この継承クラスをAI処理として渡すことができる。 25 | * また、AI処理選択中は特定の関数を除いて選択中のクラスのみが処理される。 26 | * インスタンス化する事によりローカル変数を保持。 27 | */ 28 | public abstract class EntityModeBase { 29 | 30 | public final EntityLittleMaidBase owner; 31 | 32 | 33 | public String getName() { 34 | return null; 35 | } 36 | 37 | /** 38 | * 初期化 39 | */ 40 | public EntityModeBase(EntityLittleMaidBase pEntity) { 41 | owner = pEntity; 42 | } 43 | 44 | public int fpriority; 45 | /** 46 | * 優先順位。 47 | * 番号が若いほうが先に処理される。 48 | * 下二桁が00のものはシステム予約。 49 | */ 50 | public abstract int priority(); 51 | 52 | /** 53 | * 起動時の初期化。 54 | */ 55 | public void init() { 56 | } 57 | 58 | /** 59 | * Entity初期化時の実行部 60 | */ 61 | public void initEntity() { 62 | } 63 | 64 | /** 65 | * モードの追加。 66 | */ 67 | public abstract void addEntityMode(EntityAITasks pDefaultMove, EntityAITasks pDefaultTargeting); 68 | 69 | /** 70 | * 独自データ保存用。 71 | */ 72 | public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { 73 | } 74 | /** 75 | * 独自データ読込用。 76 | */ 77 | public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { 78 | } 79 | 80 | /** 81 | * renderSpecialの追加実装用。 82 | */ 83 | public void showSpecial(RenderLittleMaid prenderlittlemaid, double px, double py, double pz) { 84 | } 85 | 86 | /** 87 | * サーバー側のみの毎時処理。 88 | * AI処理の後の方に呼ばれる。 89 | */ 90 | public void updateAITick(int pMode) { 91 | } 92 | 93 | /** 94 | * 毎時処理。 95 | * 他の処理の前に呼ばれる 96 | */ 97 | public void onUpdate(int pMode) { 98 | } 99 | 100 | /** 101 | * このへんの処理は若干時間かかっても良し。 102 | * 他のアイテムを使用したい時。 103 | * 補完処理に先んじて実行される、その代わり判定も全部自分持ち。 104 | */ 105 | public boolean preInteract(EntityPlayer pentityplayer, ItemStack pitemstack) { 106 | return false; 107 | } 108 | /** 109 | * このへんの処理は若干時間かかっても良し。 110 | * 他のアイテムを使用したい時。 111 | */ 112 | public boolean interact(EntityPlayer pentityplayer, ItemStack pitemstack) { 113 | return false; 114 | } 115 | 116 | /** 117 | * 砂糖でモードチェンジした時。 118 | */ 119 | public boolean changeMode(EntityPlayer pentityplayer) { 120 | return false; 121 | } 122 | 123 | /** 124 | * モードチェンジ時の設定処理の本体。 125 | * こっちに処理を書かないとロード時におかしくなるかも? 126 | */ 127 | public boolean setMode(int pMode) { 128 | return false; 129 | } 130 | 131 | /** 132 | * 使用アイテムの選択。 133 | * 戻り値はスロット番号 134 | */ 135 | public int getNextEquipItem(int pMode) { 136 | // 未選択 137 | return -1; 138 | } 139 | 140 | /** 141 | * アイテム回収可否の判定式。 142 | * 拾いに行くアイテムの判定。 143 | */ 144 | public boolean checkItemStack(ItemStack pItemStack) { 145 | // 回収対象アイテムの設定なし 146 | return false; 147 | } 148 | 149 | /** 150 | * 攻撃判定処理。 151 | * 特殊な攻撃動作はここで実装。 152 | */ 153 | public boolean attackEntityAsMob(int pMode, Entity pEntity) { 154 | // 特殊攻撃の設定なし 155 | return false; 156 | } 157 | 158 | /** 159 | * ブロックのチェック判定をするかどうか。 160 | * 判定式のどちらを使うかをこれで選択。 161 | */ 162 | public boolean isSearchBlock() { 163 | return false; 164 | } 165 | 166 | /** 167 | * isSearchBlock=falseのときに判定される。 168 | */ 169 | public boolean shouldBlock(int pMode) { 170 | return false; 171 | } 172 | 173 | /** 174 | * 探し求めたブロックであるか。 175 | * trueを返すと検索終了。 176 | */ 177 | public boolean checkBlock(int pMode, int px, int py, int pz) { 178 | return false; 179 | } 180 | 181 | /** 182 | * 検索範囲に索敵対象がなかった。 183 | */ 184 | public boolean overlooksBlock(int pMode) { 185 | return false; 186 | } 187 | // @Deprecated 188 | // public TileEntity overlooksBlock(int pMode) { 189 | // return null; 190 | // } 191 | 192 | /** 193 | * 限界距離を超えた時の処理 194 | */ 195 | public void farrangeBlock() { 196 | owner.getNavigator().clearPathEntity(); 197 | } 198 | 199 | /** 200 | * 有効射程距離を超えた時の処理 201 | */ 202 | public boolean outrangeBlock(int pMode, int pX, int pY, int pZ) { 203 | return owner.getNavigator().tryMoveToXYZ(pX, pY, pZ, 1.0F); 204 | } 205 | public boolean outrangeBlock(int pMode) { 206 | if (owner.tiles.size() > 0) { 207 | int[] li = owner.tiles.get(0); 208 | return outrangeBlock(pMode, li[0], li[1], li[2]); 209 | } 210 | return false; 211 | } 212 | 213 | /** 214 | * 射程距離に入ったら実行される。 215 | * 戻り値がtrueの時は終了せずに動作継続 216 | */ 217 | public boolean executeBlock(int pMode, int px, int py, int pz) { 218 | return false; 219 | } 220 | public boolean executeBlock(int pMode) { 221 | if (owner.tiles.size() > 0) { 222 | int[] li = owner.tiles.get(0); 223 | return executeBlock(pMode, li[0], li[1], li[2]); 224 | } 225 | return false; 226 | } 227 | 228 | /** 229 | * AI実行時に呼ばれる。 230 | */ 231 | public void startBlock(int pMode) { 232 | } 233 | 234 | /** 235 | * AI終了時に呼ばれる。 236 | */ 237 | public void resetBlock(int pMode) { 238 | } 239 | 240 | /** 241 | * 継続判定を行う時に呼ばれる。 242 | */ 243 | public void updateBlock() { 244 | } 245 | 246 | 247 | /** 248 | * 独自索敵処理の使用有無 249 | */ 250 | public boolean isSearchEntity() { 251 | return false; 252 | } 253 | 254 | /** 255 | * 独自索敵処理 256 | */ 257 | public boolean checkEntity(int pMode, Entity pEntity) { 258 | return false; 259 | } 260 | 261 | /** 262 | * 発光処理用 263 | */ 264 | public int colorMultiplier(float pLight, float pPartialTicks) { 265 | return 0; 266 | } 267 | 268 | /** 269 | * 被ダメ時の処理1。 270 | * 0以上を返すと処理を乗っ取る。 271 | * 1:falseで元の処理を終了する。 272 | * 2:trueで元の処理を終了する。 273 | */ 274 | public float attackEntityFrom(DamageSource par1DamageSource, float par2) { 275 | return 0; 276 | } 277 | /** 278 | * 被ダメ時の処理2。 279 | * trueを返すと処理を乗っ取る。 280 | */ 281 | public boolean damageEntity(int pMode, DamageSource par1DamageSource, float par2) { 282 | return false; 283 | } 284 | 285 | /** 286 | * 自分が使っているTileならTrueを返す。 287 | */ 288 | public boolean isUsingTile(TileEntity pTile) { 289 | return false; 290 | } 291 | 292 | /** 293 | * 持ってるTileを返す。 294 | */ 295 | public List getTiles() { 296 | return null; 297 | } 298 | 299 | /** 300 | * do1:当たり判定のチェック 301 | * do2:常時ブロク判定、透過判定も当たり判定も無視。 302 | */ 303 | protected boolean canBlockBeSeen(int pX, int pY, int pZ, boolean toTop, boolean do1, boolean do2) { 304 | // ブロックの可視判定 305 | World worldObj = owner.worldObj; 306 | Block lblock = worldObj.getBlock(pX, pY, pZ); 307 | if (lblock == Blocks.air) { 308 | littleMaidMob.Debug("block-null: %d, %d, %d", pX, pY, pZ); 309 | return false; 310 | } 311 | lblock.setBlockBoundsBasedOnState(worldObj, pX, pY, pZ); 312 | 313 | Vec3 vec3do = Vec3.createVectorHelper(owner.posX, owner.posY + owner.getEyeHeight(), owner.posZ); 314 | Vec3 vec3dt = Vec3.createVectorHelper( 315 | (double)pX + ((lblock.getBlockBoundsMinX() + lblock.getBlockBoundsMaxX()) * 0.5D), 316 | (double)pY + ((lblock.getBlockBoundsMinY() + lblock.getBlockBoundsMaxY()) * (toTop ? 0.9D : 0.5D)), 317 | (double)pZ + ((lblock.getBlockBoundsMinZ() + lblock.getBlockBoundsMaxZ()) * 0.5D)); 318 | MovingObjectPosition movingobjectposition = worldObj.func_147447_a(vec3do, vec3dt, do1, do2, true); 319 | 320 | if (movingobjectposition != null && movingobjectposition.typeOfHit == MovingObjectType.BLOCK) { 321 | // 接触ブロックが指定したものならば 322 | if (movingobjectposition.blockX == pX && 323 | movingobjectposition.blockY == pY && 324 | movingobjectposition.blockZ == pZ) { 325 | return true; 326 | } 327 | } 328 | return false; 329 | } 330 | 331 | /** 332 | * 主との距離感。 333 | * @param pIndex 334 | * 0:minRange; 335 | * 1:maxRange; 336 | * @return 337 | */ 338 | public double getRangeToMaster(int pIndex) { 339 | return pIndex == 0 ? 36D : pIndex == 1 ? 25D : 0D; 340 | } 341 | 342 | /** 343 | * 攻撃後にターゲットを再設定させるかの指定。 344 | * @param pTarget 345 | * @return 346 | */ 347 | public boolean isChangeTartget(Entity pTarget) { 348 | return !owner.isBloodsuck(); 349 | } 350 | 351 | public int getWaitDelayTime() { 352 | int li = 0;//owner.maidMode & 0x0080; 353 | return (li == 0) ? 50 : 0; 354 | } 355 | 356 | } 357 | -------------------------------------------------------------------------------- /src/main/java/mmm/littleMaidMob/entity/EntityLittleMaidBase.java: -------------------------------------------------------------------------------- 1 | package mmm.littleMaidMob.entity; 2 | 3 | import static mmm.littleMaidMob.Statics.dataWatch_Absoption; 4 | import static mmm.littleMaidMob.Statics.dataWatch_Color; 5 | import static mmm.littleMaidMob.Statics.dataWatch_DominamtArm; 6 | import static mmm.littleMaidMob.Statics.dataWatch_ExpValue; 7 | import static mmm.littleMaidMob.Statics.dataWatch_Flags; 8 | import static mmm.littleMaidMob.Statics.dataWatch_Flags_Freedom; 9 | import static mmm.littleMaidMob.Statics.dataWatch_Flags_Wait; 10 | import static mmm.littleMaidMob.Statics.dataWatch_Flags_remainsContract; 11 | import static mmm.littleMaidMob.Statics.dataWatch_Free; 12 | import static mmm.littleMaidMob.Statics.dataWatch_Gotcha; 13 | import static mmm.littleMaidMob.Statics.dataWatch_ItemUse; 14 | import static mmm.littleMaidMob.Statics.dataWatch_Mode; 15 | import static mmm.littleMaidMob.Statics.dataWatch_Parts; 16 | import static mmm.littleMaidMob.Statics.dataWatch_Texture; 17 | 18 | import java.util.UUID; 19 | 20 | import mmm.lib.Client; 21 | import mmm.lib.multiModel.MultiModelManager; 22 | import mmm.lib.multiModel.model.AbstractModelBase; 23 | import mmm.lib.multiModel.model.IModelCaps; 24 | import mmm.lib.multiModel.texture.IMultiModelEntity; 25 | import mmm.lib.multiModel.texture.MultiModelData; 26 | import mmm.littleMaidMob.TileContainer; 27 | import mmm.littleMaidMob.littleMaidMob; 28 | import mmm.littleMaidMob.inventory.InventoryLittleMaid; 29 | import mmm.littleMaidMob.mode.ModeController; 30 | import net.minecraft.entity.EntityAgeable; 31 | import net.minecraft.entity.EntityLivingBase; 32 | import net.minecraft.entity.IEntityLivingData; 33 | import net.minecraft.entity.ai.attributes.AttributeModifier; 34 | import net.minecraft.entity.passive.EntityTameable; 35 | import net.minecraft.entity.player.EntityPlayer; 36 | import net.minecraft.entity.player.EntityPlayerMP; 37 | import net.minecraft.init.Items; 38 | import net.minecraft.item.Item; 39 | import net.minecraft.item.ItemStack; 40 | import net.minecraft.nbt.NBTTagCompound; 41 | import net.minecraft.network.Packet; 42 | import net.minecraft.network.play.server.S1DPacketEntityEffect; 43 | import net.minecraft.network.play.server.S1EPacketRemoveEntityEffect; 44 | import net.minecraft.potion.PotionEffect; 45 | import net.minecraft.server.MinecraftServer; 46 | import net.minecraft.util.MathHelper; 47 | import net.minecraft.world.World; 48 | import net.minecraft.world.WorldServer; 49 | 50 | import com.mojang.authlib.GameProfile; 51 | 52 | import cpw.mods.fml.common.FMLCommonHandler; 53 | import cpw.mods.fml.relauncher.Side; 54 | import cpw.mods.fml.relauncher.SideOnly; 55 | 56 | //public class EntityLittleMaidMob extends EntityCreature implements IAnimals, IEntityOwnable { 57 | public class EntityLittleMaidBase extends EntityTameable implements IMultiModelEntity { 58 | 59 | // protected static final UUID maidUUID = UUID.nameUUIDFromBytes("net.minecraft.src.littleMaidMob".getBytes()); 60 | protected static final UUID maidUUID = UUID.fromString("e2361272-644a-3028-8416-8536667f0efb"); 61 | // protected static final UUID maidUUIDSneak = UUID.nameUUIDFromBytes("net.minecraft.src.littleMaidMob.sneak".getBytes()); 62 | protected static final UUID maidUUIDSneak = UUID.fromString("5649cf91-29bb-3a0c-8c31-b170a1045560"); 63 | protected static AttributeModifier attCombatSpeed = (new AttributeModifier(maidUUID, "Combat speed boost", 0.07D, 0)).setSaved(false); 64 | protected static AttributeModifier attAxeAmp = (new AttributeModifier(maidUUID, "Axe Attack boost", 0.5D, 1)).setSaved(false); 65 | protected static AttributeModifier attSneakingSpeed = (new AttributeModifier(maidUUIDSneak, "Sneking speed ampd", -0.4D, 2)).setSaved(false); 66 | 67 | public EntityLittleMaidAvatar avatar; 68 | public InventoryLittleMaid inventory; 69 | // public MultiModelContainer multiModel; 70 | // public int color; 71 | public MultiModelData multiModel; 72 | 73 | /** 契約限界時間 */ 74 | public int maidContractLimit; 75 | /** 主の識別 */ 76 | public EntityPlayer mstatMasterEntity; 77 | /** 上司の識別 */ 78 | public EntityLivingBase keeperEntity; 79 | /** 待機状態 */ 80 | protected boolean maidWait; 81 | protected int mstatWaitCount; 82 | /** 動作状態 */ 83 | protected short maidMode; 84 | /** 待機判定 */ 85 | protected boolean maidFreedom; 86 | 87 | /** 文字しているモードの管理用クラス */ 88 | public ModeController modeController; 89 | public IModelCaps modelCaps; 90 | 91 | /** 処理対象となるブロック群 */ 92 | public TileContainer tiles; 93 | 94 | 95 | public EntityLittleMaidBase(World par1World) { 96 | super(par1World); 97 | this.setSize(0.6F, 2.8F); 98 | 99 | if (par1World instanceof WorldServer) { 100 | avatar = new EntityLittleMaidAvatar((WorldServer)par1World, new GameProfile("10", "maid")); 101 | } 102 | inventory = new InventoryLittleMaid(this); 103 | 104 | // multiModel = MultiModelManager.instance.getMultiModel("MMM_SR2"); 105 | // setModel("MMM_Aug"); 106 | 107 | initMultiModel(); 108 | // TODO 付けないと無限落下する・・・意味解らん 109 | // setSize(width, height); 110 | // setScale(1.0F); // ダメ 111 | // moveEntity(posX, posY, posZ); // ダメ 112 | } 113 | 114 | 115 | // 初期化関数群 116 | 117 | @Override 118 | protected void entityInit() { 119 | super.entityInit(); 120 | /* 121 | * DataWatcherはクライアントからサーバーへは値を渡さない、渡せない。 122 | */ 123 | 124 | // 使用中リスト 125 | // 0:Flags 126 | // 1:Air 127 | // 2, 3, 4, 5, 128 | // 6: HP 129 | // 7, 8:PotionMap 130 | // 9: ArrowCount 131 | // 10: 固有名称 132 | // 11: 名付判定 133 | // 12: GrowingAge 134 | // 16: Tame(4), Sit(1) 135 | // 17: ownerName 136 | 137 | // maidAvater用EntityPlayer互換変数 138 | // 17 -> 18 139 | // 18 : Absoption効果をクライアント側へ転送するのに使う(拡張HP) 140 | dataWatcher.addObject(dataWatch_Absoption, Float.valueOf(0.0F)); 141 | 142 | // 独自分 143 | // 19:maidColor 144 | dataWatcher.addObject(dataWatch_Color, Byte.valueOf((byte)0)); 145 | // 20:選択テクスチャインデックス 146 | dataWatcher.addObject(dataWatch_Texture, Integer.valueOf(0)); 147 | // 21:モデルパーツの表示フラグ 148 | dataWatcher.addObject(dataWatch_Parts, Integer.valueOf(0)); 149 | // 22:状態遷移フラグ群(32Bit)、詳細はStatics参照 150 | dataWatcher.addObject(dataWatch_Flags, Integer.valueOf(0)); 151 | // 23:GotchaID 152 | dataWatcher.addObject(dataWatch_Gotcha, Integer.valueOf(0)); 153 | // 24:メイドモード 154 | dataWatcher.addObject(dataWatch_Mode, Short.valueOf((short)0)); 155 | // 25:利き腕 156 | dataWatcher.addObject(dataWatch_DominamtArm, Byte.valueOf((byte)0)); 157 | // 26:アイテムの使用判定 158 | dataWatcher.addObject(dataWatch_ItemUse, Integer.valueOf(0)); 159 | // 27:保持経験値 160 | dataWatcher.addObject(dataWatch_ExpValue, Integer.valueOf(0)); 161 | 162 | // TODO:test 163 | // 31:自由変数、EntityMode等で使用可能な変数。 164 | dataWatcher.addObject(dataWatch_Free, new Integer(0)); 165 | } 166 | 167 | @Override 168 | public IEntityLivingData onSpawnWithEgg(IEntityLivingData par1EntityLivingData) { 169 | // 別に通常のスポーンでも呼ばれる。 170 | // 個体値は持たせないのでsuperしない。 171 | // multiModel = MultiModelManager.instance.getMultiModel("MMM_SR2"); 172 | multiModel.setColor(0x08); 173 | setModel("MMM_Aug"); 174 | // multiModel.forceChanged(true); 175 | return par1EntityLivingData; 176 | } 177 | 178 | // 固有値関数群 179 | 180 | @Override 181 | protected Item getDropItem() { 182 | // ドロップは砂糖 183 | return Items.sugar; 184 | } 185 | 186 | @Override 187 | public boolean getCanSpawnHere() { 188 | // TODO Auto-generated method stub 189 | return super.getCanSpawnHere(); 190 | } 191 | 192 | @Override 193 | public EntityAgeable createChild(EntityAgeable var1) { 194 | // TODO Auto-generated method stub 195 | return null; 196 | } 197 | 198 | // 形態形成場 199 | 200 | public boolean setModel(String pName) { 201 | multiModel.setModelFromName(pName); 202 | // AbstractModelBase lamb = multiModel.model.getModelClass(multiModel.getColor())[0]; 203 | // setScale(0.1F); 204 | // setSize(lamb.getWidth(modelCaps), lamb.getHeight(modelCaps)); 205 | // setScale(1.0F); 206 | // littleMaidMob.Debug("setSize:%f, %f - %s", width, height, isClientWorld() ? "server" : "client"); 207 | return MultiModelManager.instance.isMultiModel(pName); 208 | } 209 | 210 | @Override 211 | public ItemStack getHeldItem() { 212 | // TODO Auto-generated method stub 213 | return null; 214 | } 215 | 216 | @Override 217 | public ItemStack getEquipmentInSlot(int var1) { 218 | // TODO Auto-generated method stub 219 | return null; 220 | } 221 | 222 | @Override 223 | public void setCurrentItemOrArmor(int var1, ItemStack var2) { 224 | // TODO Auto-generated method stub 225 | 226 | } 227 | 228 | @Override 229 | public ItemStack[] getLastActiveItems() { 230 | // 被ダメ時に此処を参照するのでNULL以外を返すこと。 231 | return new ItemStack[0]; 232 | } 233 | 234 | // 契約関係 235 | 236 | @Override 237 | public String getOwnerName() { 238 | // TODO Auto-generated method stub 239 | return null; 240 | } 241 | 242 | @Override 243 | public boolean isTamed() { 244 | return isContract(); 245 | } 246 | /** 247 | * 契約済みか? 248 | * @return 249 | */ 250 | public boolean isContract() { 251 | return super.isTamed(); 252 | } 253 | public boolean isContractEX() { 254 | return isContract() && isRemainsContract(); 255 | } 256 | 257 | @Override 258 | public void setTamed(boolean par1) { 259 | setContract(par1); 260 | } 261 | // @Override 262 | public void setContract(boolean flag) { 263 | super.setTamed(flag); 264 | } 265 | 266 | /** 267 | * 契約期間の残りがあるかを確認 268 | */ 269 | protected void updateRemainsContract() { 270 | boolean lflag = false; 271 | if (maidContractLimit > 0) { 272 | maidContractLimit--; 273 | lflag = true; 274 | } 275 | if (getMaidFlags(dataWatch_Flags_remainsContract) != lflag) { 276 | setMaidFlags(lflag, dataWatch_Flags_remainsContract); 277 | } 278 | } 279 | /** 280 | * ストライキに入っていないか判定 281 | * @return 282 | */ 283 | public boolean isRemainsContract() { 284 | return getMaidFlags(dataWatch_Flags_remainsContract); 285 | } 286 | 287 | public float getContractLimitDays() { 288 | return maidContractLimit > 0 ? ((float)maidContractLimit / 24000F) : -1F; 289 | } 290 | 291 | public boolean updateMaidContract() { 292 | // TODO 同一性のチェック 293 | // boolean lf = isContract(); 294 | // if (textureData.isContract() != lf) { 295 | // textureData.setContract(lf); 296 | // return true; 297 | // } 298 | return false; 299 | } 300 | 301 | @Override 302 | public EntityLivingBase getOwner() { 303 | return getMaidMasterEntity(); 304 | } 305 | public String getMaidMaster() { 306 | return getOwnerName(); 307 | } 308 | 309 | public EntityPlayer getMaidMasterEntity() { 310 | // 主を獲得 311 | if (isContract()) { 312 | EntityPlayer entityplayer = mstatMasterEntity; 313 | if (mstatMasterEntity == null || mstatMasterEntity.isDead) { 314 | String lname; 315 | // インターナルサーバーならオーナ判定しない、オフライン対策 316 | if (!Client.isIntegratedServerRunning()) { 317 | lname = getMaidMaster(); 318 | } else { 319 | lname = ((EntityPlayer)worldObj.playerEntities.get(0)).getCommandSenderName(); 320 | } 321 | entityplayer = worldObj.getPlayerEntityByName(lname); 322 | 323 | // クリエイティブモードの状態を主とあわせる 324 | if (entityplayer != null && avatar != null) { 325 | avatar.capabilities.isCreativeMode = entityplayer.capabilities.isCreativeMode; 326 | } 327 | } 328 | return entityplayer; 329 | } else { 330 | return null; 331 | } 332 | } 333 | 334 | public boolean isMaidContractOwner(String pname) { 335 | return pname.equalsIgnoreCase(getMaidMaster()); 336 | } 337 | 338 | public boolean isMaidContractOwner(EntityPlayer pentity) { 339 | return pentity == getMaidMasterEntity(); 340 | 341 | // return pentity == mstatMasterEntity; 342 | } 343 | 344 | 345 | // AI関連 346 | 347 | @Override 348 | protected boolean isAIEnabled() { 349 | // TODO 設定変えること 350 | return false; 351 | } 352 | 353 | @Override 354 | public boolean interact(EntityPlayer par1EntityPlayer) { 355 | if (true) { 356 | ItemStack lis = par1EntityPlayer.getCurrentEquippedItem(); 357 | if (isContractEX()) { 358 | if (lis.getItem() == Items.cake) { 359 | 360 | } else { 361 | // インベントリの表示 362 | displayGUIInventry(par1EntityPlayer); 363 | return true; 364 | } 365 | } else { 366 | if (lis.getItem() == Items.cake) { 367 | // 契約 368 | setOwner(""); 369 | setContract(true); 370 | } 371 | } 372 | } 373 | 374 | return super.interact(par1EntityPlayer); 375 | } 376 | 377 | // 状態識別変数郡 378 | 379 | /** 380 | * 血に飢えているか? 381 | * @return 382 | */ 383 | public boolean isBloodsuck() { 384 | return false; 385 | } 386 | 387 | /** 388 | * 待機状態であるか? 389 | * @return 390 | */ 391 | public boolean isWait() { 392 | return false; 393 | } 394 | 395 | // GUI関連 396 | 397 | /** 398 | * インベントリの表示 399 | * @param pPlayer 400 | */ 401 | @SideOnly(Side.CLIENT) 402 | public void displayGUIInventry(EntityPlayer pPlayer) { 403 | pPlayer.openGui(littleMaidMob.instance, 0, worldObj, getEntityId(), 0, 0); 404 | // FMLClientHandler.instance().displayGuiScreen(pPlayer, new GuiLittleMaidInventory(this, pPlayer)); 405 | } 406 | 407 | /** 408 | * IFF設定の表示 409 | * @param pPlayer 410 | */ 411 | @SideOnly(Side.CLIENT) 412 | public void displayGUIIFF(EntityPlayer pPlayer) { 413 | pPlayer.openGui(littleMaidMob.instance, 1, worldObj, getEntityId(), 0, 0); 414 | // FMLClientHandler.instance().displayGuiScreen(pPlayer, new GuiLittleMaidInventory(this, pPlayer)); 415 | } 416 | 417 | 418 | // イベント関連 419 | 420 | 421 | /** 422 | * 周囲のプレーヤーにパケットを送信する 423 | * @param pRange 射程距離 424 | * @param pPacket 425 | */ 426 | public void sendToAllNear(double pRange, Packet pPacket) { 427 | MinecraftServer lms = FMLCommonHandler.instance().getMinecraftServerInstance(); 428 | lms.getConfigurationManager().sendToAllNear(posX, posY, posZ, pRange, dimension, pPacket); 429 | } 430 | 431 | public void sendToMaster(Packet pPacket) { 432 | if (mstatMasterEntity instanceof EntityPlayerMP) { 433 | ((EntityPlayerMP)mstatMasterEntity).playerNetServerHandler.sendPacket(pPacket); 434 | } 435 | } 436 | 437 | // ポーションエフェクト 438 | 439 | @Override 440 | protected void onNewPotionEffect(PotionEffect par1PotionEffect) { 441 | super.onNewPotionEffect(par1PotionEffect); 442 | // if (isContract()) { 443 | sendToAllNear(64D, new S1DPacketEntityEffect(getEntityId(), par1PotionEffect)); 444 | // } 445 | } 446 | 447 | @Override 448 | protected void onChangedPotionEffect(PotionEffect par1PotionEffect, boolean par2) { 449 | super.onChangedPotionEffect(par1PotionEffect, par2); 450 | // なんかエンドレスで再設定されるので更新なし。 451 | // if (isContract()) { 452 | // sendToAllNear(64D, new S1DPacketEntityEffect(getEntityId(), par1PotionEffect)); 453 | // } 454 | } 455 | 456 | @Override 457 | protected void onFinishedPotionEffect(PotionEffect par1PotionEffect) { 458 | super.onFinishedPotionEffect(par1PotionEffect); 459 | // if (isContract()) { 460 | sendToAllNear(64D, new S1EPacketRemoveEntityEffect(getEntityId(), par1PotionEffect)); 461 | // } 462 | } 463 | 464 | /** 465 | * フラグ群に値をセット。 466 | * @param pCheck: 対象値。 467 | * @param pFlags: 対象フラグ。 468 | */ 469 | public void setMaidFlags(boolean pFlag, int pFlagvalue) { 470 | int li = dataWatcher.getWatchableObjectInt(dataWatch_Flags); 471 | li = pFlag ? (li | pFlagvalue) : (li & ~pFlagvalue); 472 | dataWatcher.updateObject(dataWatch_Flags, Integer.valueOf(li)); 473 | } 474 | 475 | /** 476 | * 指定されたフラグを獲得 477 | */ 478 | public boolean getMaidFlags(int pFlagvalue) { 479 | return (dataWatcher.getWatchableObjectInt(dataWatch_Flags) & pFlagvalue) > 0; 480 | } 481 | 482 | // メイドの待機設定 483 | public boolean isMaidWait() { 484 | return maidWait; 485 | } 486 | 487 | public boolean isMaidWaitEx() { 488 | return isMaidWait() | (mstatWaitCount > 0) | isOpenInventory(); 489 | } 490 | 491 | public void setMaidWait(boolean pflag) { 492 | // 待機常態の設定、 isMaidWait系でtrueを返すならAIが勝手に移動を停止させる。 493 | maidWait = pflag; 494 | setMaidFlags(pflag, dataWatch_Flags_Wait); 495 | 496 | aiSit.setSitting(pflag); 497 | maidWait = pflag; 498 | isJumping = false; 499 | setAttackTarget(null); 500 | setRevengeTarget(null); 501 | setPathToEntity(null); 502 | getNavigator().clearPathEntity(); 503 | velocityChanged = true; 504 | } 505 | 506 | public void setMaidWaitCount(int count) { 507 | mstatWaitCount = count; 508 | } 509 | 510 | // インベントリの表示関係 511 | // まさぐれるのは一人だけ 512 | public boolean isOpenInventory() { 513 | return inventory.isOpen; 514 | } 515 | 516 | /** 517 | * GUIを開いた時にサーバー側で呼ばれる。 518 | */ 519 | public void onGuiOpened() { 520 | } 521 | 522 | /** 523 | * GUIを閉めた時にサーバー側で呼ばれる。 524 | */ 525 | public void onGuiClosed() { 526 | setMaidWaitCount(modeController.activeMode.getWaitDelayTime()); 527 | } 528 | 529 | // 自由行動 530 | public void setFreedom(boolean pFlag) { 531 | // AI関連のリセットもここで。 532 | maidFreedom = pFlag; 533 | // aiRestrictRain.setEnable(pFlag); 534 | // aiFreeRain.setEnable(pFlag); 535 | // aiWander.setEnable(pFlag); 536 | // aiJumpTo.setEnable(!pFlag); 537 | // aiAvoidPlayer.setEnable(!pFlag); 538 | // aiFollow.setEnable(!pFlag); 539 | // aiTracer.setEnable(false); 540 | // setAIMoveSpeed(pFlag ? moveSpeed_Nomal : moveSpeed_Max); 541 | // setMoveForward(0.0F); 542 | 543 | if (maidFreedom && isContract()) { 544 | // func_110171_b( 545 | setHomeArea( 546 | MathHelper.floor_double(posX), 547 | MathHelper.floor_double(posY), 548 | MathHelper.floor_double(posZ), 16); 549 | } else { 550 | // func_110177_bN(); 551 | detachHome(); 552 | // setPlayingRole(0); 553 | } 554 | 555 | setMaidFlags(maidFreedom, dataWatch_Flags_Freedom); 556 | } 557 | 558 | public boolean isFreedom() { 559 | return maidFreedom; 560 | } 561 | 562 | public void setAbsorptionAmount(float par1) { 563 | if (par1 < 0.0F) { 564 | par1 = 0.0F; 565 | } 566 | 567 | dataWatcher.updateObject(dataWatch_Absoption, Float.valueOf(par1)); 568 | } 569 | 570 | public float getAbsorptionAmount() { 571 | return dataWatcher.getWatchableObjectFloat(dataWatch_Absoption); 572 | } 573 | 574 | @Override 575 | public void readEntityFromNBT(NBTTagCompound par1nbtTagCompound) { 576 | // TODO Auto-generated method stub 577 | super.readEntityFromNBT(par1nbtTagCompound); 578 | multiModel.setChange(); 579 | } 580 | 581 | @Override 582 | public void writeEntityToNBT(NBTTagCompound par1nbtTagCompound) { 583 | // TODO Auto-generated method stub 584 | super.writeEntityToNBT(par1nbtTagCompound); 585 | } 586 | 587 | 588 | // MultiModel関連 589 | 590 | @Override 591 | public MultiModelData getMultiModel() { 592 | return multiModel; 593 | } 594 | 595 | @Override 596 | public void setMultiModelData(MultiModelData pMultiModelData) { 597 | multiModel = pMultiModelData; 598 | } 599 | 600 | @Override 601 | public void initMultiModel() { 602 | // 値の初期化 603 | multiModel.setColor(0x0c); 604 | setModel("MMM_Aug"); 605 | // multiModel.setModelFromName("MMM_Aug"); 606 | multiModel.forceChanged(false); 607 | } 608 | 609 | @Override 610 | public void onMultiModelChange() { 611 | // TODO Auto-generated method stub 612 | 613 | } 614 | 615 | } 616 | --------------------------------------------------------------------------------