Proper Reformating

This commit is contained in:
Kam committed 2025-03-13 17:14:45 -04:00
1 parent ce75880aba
commit 180d257024
1179 files changed
+59847 -61583

No files matched your search

@@ -133,7 +133,7 @@ public class AnimationMixinFunctions {
}
private static EnumAnimationPart pivotEqualPart(ModelRenderer renderer) {
if(renderer.baseModel instanceof ModelBiped){
if (renderer.baseModel instanceof ModelBiped) {
ModelRenderer head = ((ModelBiped) renderer.baseModel).bipedHead;
ModelRenderer body = ((ModelBiped) renderer.baseModel).bipedBody;
ModelRenderer larm = ((ModelBiped) renderer.baseModel).bipedLeftArm;
@@ -141,22 +141,22 @@ public class AnimationMixinFunctions {
ModelRenderer lleg = ((ModelBiped) renderer.baseModel).bipedLeftLeg;
ModelRenderer rleg = ((ModelBiped) renderer.baseModel).bipedRightLeg;
if (pivotsEqual(renderer,head)) {
if (pivotsEqual(renderer, head)) {
return EnumAnimationPart.HEAD;
}
if (pivotsEqual(renderer,body)) {
if (pivotsEqual(renderer, body)) {
return EnumAnimationPart.BODY;
}
if (pivotsEqual(renderer,rarm)) {
if (pivotsEqual(renderer, rarm)) {
return EnumAnimationPart.RIGHT_ARM;
}
if (pivotsEqual(renderer,larm)) {
if (pivotsEqual(renderer, larm)) {
return EnumAnimationPart.LEFT_ARM;
}
if (pivotsEqual(renderer,rleg)) {
if (pivotsEqual(renderer, rleg)) {
return EnumAnimationPart.RIGHT_LEG;
}
if (pivotsEqual(renderer,lleg)) {
if (pivotsEqual(renderer, lleg)) {
return EnumAnimationPart.LEFT_LEG;
}
}
@@ -179,7 +179,7 @@ public class AnimationMixinFunctions {
declared = ClientEventHandler.declaredFieldCache.get(RenderClass);
} else {
declared = RenderClass.getDeclaredFields();
ClientEventHandler.declaredFieldCache.put(RenderClass,declared);
ClientEventHandler.declaredFieldCache.put(RenderClass, declared);
}
for (Field f : declared) {
f.setAccessible(true);
@@ -190,7 +190,8 @@ public class AnimationMixinFunctions {
if (partName.equals(f.getName()) && renderer == f.get(model)) {
return entry.getKey();
}
} catch (IllegalAccessException ignored) {}
} catch (IllegalAccessException ignored) {
}
}
}
}
@@ -268,7 +269,7 @@ public class AnimationMixinFunctions {
int i = Minecraft.getMinecraft().theWorld.getLightBrightnessForSkyBlocks(MathHelper.floor_double(entityclientplayermp.posX), MathHelper.floor_double(entityclientplayermp.posY), MathHelper.floor_double(entityclientplayermp.posZ), 0);
int j = i % 65536;
int k = i / 65536;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)j, (float)k);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k);
float f3 = entityclientplayermp.prevRenderArmPitch + (entityclientplayermp.renderArmPitch - entityclientplayermp.prevRenderArmPitch) * partialRenderTick;
float f4 = entityclientplayermp.prevRenderArmYaw + (entityclientplayermp.renderArmYaw - entityclientplayermp.prevRenderArmYaw) * partialRenderTick;
@@ -285,13 +286,11 @@ public class AnimationMixinFunctions {
ItemRenderer itemRenderer = Minecraft.getMinecraft().entityRenderer.itemRenderer;
ItemStack itemstack = itemRenderer.itemToRender;
if (frame.frameParts.containsKey(EnumAnimationPart.RIGHT_ARM) && itemstack != null)
{
if (frame.frameParts.containsKey(EnumAnimationPart.RIGHT_ARM) && itemstack != null) {
float f11, f12;
GL11.glPushMatrix();
if (player.fishEntity != null)
{
if (player.fishEntity != null) {
itemstack = new ItemStack(Items.stick);
}
@@ -310,27 +309,23 @@ public class AnimationMixinFunctions {
GL11.glRotatef(45, 1, 0, 0);
GL11.glRotatef(80, 0, 0, 1);
float f6 = 1/1.5F;
float f6 = 1 / 1.5F;
GL11.glScalef(f6, f6, f6);
if (itemstack.getItem().requiresMultipleRenderPasses())
{
for (k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k)
{
if (itemstack.getItem().requiresMultipleRenderPasses()) {
for (k = 0; k < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++k) {
i = itemstack.getItem().getColorFromItemStack(itemstack, k);
f12 = (float)(i >> 16 & 255) / 255.0F;
f3 = (float)(i >> 8 & 255) / 255.0F;
f4 = (float)(i & 255) / 255.0F;
f12 = (float) (i >> 16 & 255) / 255.0F;
f3 = (float) (i >> 8 & 255) / 255.0F;
f4 = (float) (i & 255) / 255.0F;
GL11.glColor4f(f12, f3, f4, 1.0F);
mixin_renderItem(player, itemstack, k, EQUIPPED_FIRST_PERSON, renderBlocksIr, resItemGlint);
}
}
else
{
} else {
k = itemstack.getItem().getColorFromItemStack(itemstack, 0);
f11 = (float)(k >> 16 & 255) / 255.0F;
f12 = (float)(k >> 8 & 255) / 255.0F;
f3 = (float)(k & 255) / 255.0F;
f11 = (float) (k >> 16 & 255) / 255.0F;
f12 = (float) (k >> 8 & 255) / 255.0F;
f3 = (float) (k & 255) / 255.0F;
GL11.glColor4f(f11, f12, f3, 1.0F);
mixin_renderItem(player, itemstack, 0, EQUIPPED_FIRST_PERSON, renderBlocksIr, resItemGlint);
}
@@ -469,7 +464,7 @@ public class AnimationMixinFunctions {
boolean instantTransmission = blocking == 2;
int id = blocking != 0 ? (instantTransmission ? 6 : 0) : (animKiShoot != 0 ? an[animKiShoot - 1] + 2 : -1);
if (!(boolean)JGConfigClientSettings.getField("CLIENT_DA4").get(null)) {
if (!(boolean) JGConfigClientSettings.getField("CLIENT_DA4").get(null)) {
id = -1;
}
@@ -478,12 +473,12 @@ public class AnimationMixinFunctions {
int jx;
int j;
if (dbcBool) {
String[] s = ((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null,acp.getCommandSenderName(), 1, "0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0")).split(";");
String[] s = ((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, acp.getCommandSenderName(), 1, "0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0;0")).split(";");
tailCol = Integer.parseInt(s[2]);
if (tailCol == 1) {
String[] PlyrSkills = (String[]) JRMCoreH.getMethod("PlyrSkills", EntityPlayer.class).invoke(null, acp);
jx = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null,12, PlyrSkills);
j = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null,15, PlyrSkills);
jx = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null, 12, PlyrSkills);
j = (int) JRMCoreH.getMethod("SklLvl", int.class, String[].class).invoke(null, 15, PlyrSkills);
String ss = s[17];
boolean v = dbcBool && !ss.equals("-1");
GL11.glPushMatrix();
@@ -676,10 +671,10 @@ public class AnimationMixinFunctions {
if (State == 14) {
tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype;
tailCol = (boolean)JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol;
tailCol = (boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol;
tailCol = skintype == 1 ? bodyc1 : tailCol;
if ((boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && tailCol == 6498048 && State == 14) {
if ((boolean)JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) {
if ((boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) {
tailCol = 13292516;
} else {
tailCol = 14292268;
@@ -703,8 +698,8 @@ public class AnimationMixinFunctions {
GL11.glDepthMask(false);
tailCol = Integer.parseInt((String) JRMCoreH.getMethod("data", String.class, int.class, String.class
).invoke(null, par1EntityPlayer.getCommandSenderName(), 8, "200"));
float one = (float)tailCol / 100.0F;
j = (int)((float)tailCol / one);
float one = (float) tailCol / 100.0F;
j = (int) ((float) tailCol / one);
if (j < 70) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises1.png"));
@@ -744,7 +739,7 @@ public class AnimationMixinFunctions {
if (itemstack != null) {
item = itemstack.getItem();
if (item instanceof ItemArmor) {
itemarmor = (ItemArmor)item;
itemarmor = (ItemArmor) item;
GL11.glPushMatrix();
dbcarmor = itemarmor.getArmorTexture(itemstack, par1EntityPlayer, 2, null);
mcarmor = RenderBiped.getArmorResource(par1EntityPlayer, itemstack, 1, null);
@@ -875,10 +870,10 @@ public class AnimationMixinFunctions {
if (State == 14) {
tailCol = race != 2 && bodytype == 0 ? 6498048 : bodytype;
tailCol = (boolean)JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol;
tailCol = (boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null) ? 13292516 : tailCol;
jx = skintype == 1 ? bodyc1 : tailCol;
if ((boolean) JRMCoreH.getMethod("rSai", int.class).invoke(null, race) && jx == 6498048 && State == 14) {
if ((boolean)JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) {
if ((boolean) JRMCoreH.getMethod("isAprilFoolsModeOn").invoke(null)) {
jx = 13292516;
} else {
jx = 14292268;
@@ -907,8 +902,8 @@ public class AnimationMixinFunctions {
((int[]) JRMCoreH.getField("PlyrAttrbts").get(null))[2], race,
(byte) JRMCoreH.getField("Class").get(null), 0.0F);
jx = Integer.parseInt((String) JRMCoreH.getMethod("data", String.class, int.class, String.class).invoke(null, par1EntityPlayer.getCommandSenderName(), 8, "200"));
float one = (float)tailCol / 100.0F;
int perc = (int)((float)jx / one);
float one = (float) tailCol / 100.0F;
int perc = (int) ((float) jx / one);
if (perc < 70) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(new ResourceLocation("jinryuumodscore:cc/bruises1.png"));
@@ -942,7 +937,7 @@ public class AnimationMixinFunctions {
if (itemstack != null) {
item = itemstack.getItem();
if (item instanceof ItemArmor) {
itemarmor = (ItemArmor)item;
itemarmor = (ItemArmor) item;
GL11.glPushMatrix();
dbcarmor = itemarmor.getArmorTexture(itemstack, par1EntityPlayer, 2, null);
mcarmor = RenderBiped.getArmorResource(par1EntityPlayer, itemstack, 1, null);
@@ -1020,9 +1015,9 @@ public class AnimationMixinFunctions {
}
private static void glColor3f(int c) throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, IllegalAccessException {
float h2 = (float)(c >> 16 & 255) / 255.0F;
float h3 = (float)(c >> 8 & 255) / 255.0F;
float h4 = (float)(c & 255) / 255.0F;
float h2 = (float) (c >> 16 & 255) / 255.0F;
float h3 = (float) (c >> 8 & 255) / 255.0F;
float h4 = (float) (c & 255) / 255.0F;
float h1 = 1.0F;
float r = h1 * h2;
float g = h1 * h3;
@@ -1048,7 +1043,7 @@ public class AnimationMixinFunctions {
} else if (p_78443_2_.getItemSpriteNumber() == 0 && item instanceof ItemBlock && RenderBlocks.renderItemIn3d(block.getRenderType())) {
texturemanager.bindTexture(texturemanager.getResourceLocation(0));
GL11.glTranslatef(0.0F, 0.2F,-0.2F);
GL11.glTranslatef(0.0F, 0.2F, -0.2F);
if (p_78443_2_ != null && block != null && block.getRenderBlockPass() != 0) {
GL11.glDepthMask(false);
renderBlocksIr.renderBlockAsItem(block, p_78443_2_.getItemDamage(), 1.0F);
+99 -96
View File
@@ -20,160 +20,163 @@ import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityNPCInterface;
public class CommonProxy implements IGuiHandler {
public boolean newVersionAvailable = false;
public int revision = 1;
public boolean newVersionAvailable = false;
public int revision = 1;
public void load() {
}
public void load() {
}
public PlayerData getPlayerData(EntityPlayer player) {
return null;
}
public PlayerData getPlayerData(EntityPlayer player) {
return null;
}
public AnimationData getClientAnimationData(Entity entity) {
return null;
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if(ID > EnumGuiType.values().length)
return null;
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
EnumGuiType gui = EnumGuiType.values()[ID];
return getContainer(gui, player, x, y, z, npc);
}
public Container getContainer(EnumGuiType gui,EntityPlayer player, int x, int y, int z,EntityNPCInterface npc){
if(gui == EnumGuiType.CustomGui)
return new ContainerCustomGui(new InventoryBasic("", false, x));
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
if (ID > EnumGuiType.values().length)
return null;
EntityNPCInterface npc = NoppesUtilServer.getEditingNpc(player);
EnumGuiType gui = EnumGuiType.values()[ID];
return getContainer(gui, player, x, y, z, npc);
}
if(gui == EnumGuiType.MainMenuInv)
return new ContainerNPCInv(npc, player);
public Container getContainer(EnumGuiType gui, EntityPlayer player, int x, int y, int z, EntityNPCInterface npc) {
if (gui == EnumGuiType.CustomGui)
return new ContainerCustomGui(new InventoryBasic("", false, x));
if(gui == EnumGuiType.PlayerBankSmall)
return new ContainerNPCBankSmall(player, x , y);
if (gui == EnumGuiType.MainMenuInv)
return new ContainerNPCInv(npc, player);
if(gui == EnumGuiType.PlayerBankUnlock)
return new ContainerNPCBankUnlock(player, x , y);
if (gui == EnumGuiType.PlayerBankSmall)
return new ContainerNPCBankSmall(player, x, y);
if(gui == EnumGuiType.PlayerBankUprade)
return new ContainerNPCBankUpgrade(player, x , y);
if (gui == EnumGuiType.PlayerBankUnlock)
return new ContainerNPCBankUnlock(player, x, y);
if(gui == EnumGuiType.PlayerBankLarge)
return new ContainerNPCBankLarge(player, x , y);
if (gui == EnumGuiType.PlayerBankUprade)
return new ContainerNPCBankUpgrade(player, x, y);
if(gui == EnumGuiType.PlayerFollowerHire)
return new ContainerNPCFollowerHire(npc, player);
if (gui == EnumGuiType.PlayerBankLarge)
return new ContainerNPCBankLarge(player, x, y);
if(gui == EnumGuiType.PlayerFollower)
return new ContainerNPCFollower(npc, player);
if (gui == EnumGuiType.PlayerFollowerHire)
return new ContainerNPCFollowerHire(npc, player);
if(gui == EnumGuiType.PlayerTrader)
return new ContainerNPCTrader(npc, player);
if (gui == EnumGuiType.PlayerFollower)
return new ContainerNPCFollower(npc, player);
if(gui == EnumGuiType.PlayerCarpentryBench)
return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z);
if (gui == EnumGuiType.PlayerTrader)
return new ContainerNPCTrader(npc, player);
if(gui == EnumGuiType.PlayerAnvil)
if (gui == EnumGuiType.PlayerCarpentryBench)
return new ContainerCarpentryBench(player.inventory, player.worldObj, x, y, z);
if (gui == EnumGuiType.PlayerAnvil)
return new ContainerAnvilRepair(player.inventory, player.worldObj, x, y, z);
if(gui == EnumGuiType.SetupItemGiver)
return new ContainerNpcItemGiver(npc, player);
if (gui == EnumGuiType.SetupItemGiver)
return new ContainerNpcItemGiver(npc, player);
if(gui == EnumGuiType.SetupTrader)
return new ContainerNPCTraderSetup(npc, player);
if (gui == EnumGuiType.SetupTrader)
return new ContainerNPCTraderSetup(npc, player);
if(gui == EnumGuiType.SetupFollower)
return new ContainerNPCFollowerSetup(npc, player);
if (gui == EnumGuiType.SetupFollower)
return new ContainerNPCFollowerSetup(npc, player);
if(gui == EnumGuiType.QuestReward)
return new ContainerNpcQuestReward(player);
if (gui == EnumGuiType.QuestReward)
return new ContainerNpcQuestReward(player);
if(gui == EnumGuiType.QuestItem)
return new ContainerNpcQuestTypeItem(player);
if (gui == EnumGuiType.QuestItem)
return new ContainerNpcQuestTypeItem(player);
if(gui == EnumGuiType.ManageRecipes)
return new ContainerManageRecipes(player,x);
if (gui == EnumGuiType.ManageRecipes)
return new ContainerManageRecipes(player, x);
if(gui == EnumGuiType.ManageBanks)
return new ContainerManageBanks(player);
if (gui == EnumGuiType.ManageBanks)
return new ContainerManageBanks(player);
if(gui == EnumGuiType.MerchantAdd)
return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj);
if (gui == EnumGuiType.MerchantAdd)
return new ContainerMerchantAdd(player, ServerEventsHandler.Merchant, player.worldObj);
if(gui == EnumGuiType.Crate)
return new ContainerCrate(player.inventory, (TileNpcContainer)player.worldObj.getTileEntity(x, y, z));
if (gui == EnumGuiType.Crate)
return new ContainerCrate(player.inventory, (TileNpcContainer) player.worldObj.getTileEntity(x, y, z));
if(gui == EnumGuiType.PlayerMailman)
return new ContainerMail(player, x == 1, y == 1);
if (gui == EnumGuiType.PlayerMailman)
return new ContainerMail(player, x == 1, y == 1);
if(gui == EnumGuiType.CompanionInv)
return new ContainerNPCCompanion(npc, player);
if (gui == EnumGuiType.CompanionInv)
return new ContainerNPCCompanion(npc, player);
return null;
}
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
return null;
}
public void openGui(EntityNPCInterface npc, EnumGuiType gui) {
public void openGui(EntityNPCInterface npc, EnumGuiType gui) {
}
}
public void openGui(EntityNPCInterface npc, EnumGuiType gui, int x, int y, int z) {
public void openGui(EntityNPCInterface npc, EnumGuiType gui, int x, int y, int z) {
}
}
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
public void openGui(int i, int j, int k, EnumGuiType gui, EntityPlayer player) {
}
}
public void openGui(EntityPlayer player, Object guiscreen) {
public void openGui(EntityPlayer player, Object guiscreen) {
}
}
public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
}
}
public FakePlayer getCommandPlayer(IWorld world) { return null; }
public FakePlayer getCommandPlayer(IWorld world) {
return null;
}
public boolean hasClient() {
return false;
}
public boolean hasClient() {
return false;
}
public EntityPlayer getPlayer() {
return null;
}
public EntityPlayer getPlayer() {
return null;
}
public void registerItem(Item item) {
public void registerItem(Item item) {
}
}
public ModelBiped getSkirtModel() {
return null;
}
public ModelBiped getSkirtModel() {
return null;
}
public void spawnParticle(String particle, double x, double y, double z,
double motionX, double motionY, double motionZ, float scale) {
public void spawnParticle(String particle, double x, double y, double z,
double motionX, double motionY, double motionZ, float scale) {
}
}
public void generateBigSmokeParticles(World world, int x, int y, int z, boolean signalFire){
public void generateBigSmokeParticles(World world, int x, int y, int z, boolean signalFire) {
}
public String getAchievementDesc(Achievement achievement) {
return "";
}
return "";
}
public boolean isGUIOpen(){
return false;
}
public boolean isGUIOpen() {
return false;
}
}
+13 -13
View File
@@ -4,21 +4,21 @@ import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
public class CreativeTabNpcs extends CreativeTabs{
public Item item = Items.bowl;
public int meta = 0;
public class CreativeTabNpcs extends CreativeTabs {
public Item item = Items.bowl;
public int meta = 0;
public CreativeTabNpcs(String label) {
super(label);
}
public CreativeTabNpcs(String label) {
super(label);
}
@Override
public Item getTabIconItem() {
return item;
}
@Override
public int func_151243_f(){
@Override
public Item getTabIconItem() {
return item;
}
@Override
public int func_151243_f() {
return meta;
}
}
File diff suppressed because it is too large. Load diff
+10 -10
View File
@@ -12,6 +12,7 @@ import foxz.command.CommandNoppes;
import kamkeel.npcs.addon.AddonManager;
import kamkeel.npcs.command.CommandKamkeel;
import kamkeel.npcs.command.profile.CommandProfile;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.data.profile.CNPCData;
import kamkeel.npcs.developer.Developer;
@@ -27,7 +28,6 @@ import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.MinecraftForge;
import nikedemos.markovnames.generators.*;
import kamkeel.npcs.controllers.AttributeController;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.config.LoadConfiguration;
@@ -100,10 +100,10 @@ public class CustomNpcs {
legacyPath = ev.getModConfigurationDirectory() + "/CustomNpcs.cfg";
File configDir = new File(configPath);
if(!configDir.exists()){
if (!configDir.exists()) {
// Convert Legacy Config to New Config if NO Config Folder Exists
File legacyFile = new File(legacyPath);
if(legacyFile.exists()){
if (legacyFile.exists()) {
System.out.println("Loading Legacy Config");
legacyExist = true;
legacyConfig = new LegacyConfig();
@@ -228,15 +228,15 @@ public class CustomNpcs {
PlayerDataController.Instance.clearCache();
Set<String> names = Block.blockRegistry.getKeys();
for(String name : names){
for (String name : names) {
Block block = (Block) Block.blockRegistry.getObject(name);
if(block instanceof BlockLeavesBase){
if (block instanceof BlockLeavesBase) {
block.setTickRandomly(ConfigMain.LeavesDecayEnabled);
}
if(block instanceof BlockVine){
if (block instanceof BlockVine) {
block.setTickRandomly(ConfigMain.VineGrowthEnabled);
}
if(block instanceof BlockIce){
if (block instanceof BlockIce) {
block.setTickRandomly(ConfigMain.IceMeltsEnabled);
}
}
@@ -256,7 +256,7 @@ public class CustomNpcs {
@EventHandler
public void stopped(FMLServerStoppedEvent event){
public void stopped(FMLServerStoppedEvent event) {
ServerCloneController.Instance = null;
GlobalDataController.Instance.saveData();
ScriptController.Instance.saveForgeScripts();
@@ -268,7 +268,7 @@ public class CustomNpcs {
public void serverstart(FMLServerStartingEvent event) {
event.registerServerCommand(new CommandNoppes());
event.registerServerCommand(new CommandKamkeel());
if(ConfigMain.ProfilesEnabled)
if (ConfigMain.ProfilesEnabled)
event.registerServerCommand(new CommandProfile());
}
@@ -323,7 +323,7 @@ public class CustomNpcs {
}
}
public static MinecraftServer getServer(){
public static MinecraftServer getServer() {
return MinecraftServer.getServer();
}
@@ -14,7 +14,7 @@ import java.util.Collections;
import java.util.List;
public class CustomNpcsPermissions{
public class CustomNpcsPermissions {
// Open GUI
public static final Permission NPC_GUI = new Permission("customnpcs.npc.gui");
public static final Permission PAINTBRUSH_GUI = new Permission("customnpcs.npc.paintbrush");
@@ -24,7 +24,7 @@ public class CustomNpcsPermissions{
// Modify NPC
public static final Permission NPC_DELETE = new Permission("customnpcs.npc.delete");
public static final Permission NPC_CREATE = new Permission("customnpcs.npc.create");
public static final Permission NPC_CREATE = new Permission("customnpcs.npc.create");
public static final Permission NPC_RESET = new Permission("customnpcs.npc.reset");
// Extra NPCs
@@ -32,43 +32,43 @@ public class CustomNpcsPermissions{
public static final Permission NPC_TELEPORT = new Permission("customnpcs.npc.teleport");
// Save NPC
public static final Permission NPC_AI = new Permission("customnpcs.npc.ai");
public static final Permission NPC_ADVANCED = new Permission("customnpcs.npc.advanced");
public static final Permission NPC_DISPLAY = new Permission("customnpcs.npc.display");
public static final Permission NPC_INVENTORY = new Permission("customnpcs.npc.inventory");
public static final Permission NPC_STATS = new Permission("customnpcs.npc.stats");
public static final Permission NPC_CLONE = new Permission("customnpcs.npc.clone");
public static final Permission NPC_AI = new Permission("customnpcs.npc.ai");
public static final Permission NPC_ADVANCED = new Permission("customnpcs.npc.advanced");
public static final Permission NPC_DISPLAY = new Permission("customnpcs.npc.display");
public static final Permission NPC_INVENTORY = new Permission("customnpcs.npc.inventory");
public static final Permission NPC_STATS = new Permission("customnpcs.npc.stats");
public static final Permission NPC_CLONE = new Permission("customnpcs.npc.clone");
public static final Permission GLOBAL_REMOTE = new Permission("customnpcs.global.remote");
// Save Globel Preferences
public static final Permission GLOBAL_LINKED = new Permission("customnpcs.global.linked");
public static final Permission GLOBAL_PLAYERDATA = new Permission("customnpcs.global.playerdata");
public static final Permission GLOBAL_BANK = new Permission("customnpcs.global.bank");
public static final Permission GLOBAL_DIALOG = new Permission("customnpcs.global.dialog");
public static final Permission GLOBAL_QUEST = new Permission("customnpcs.global.quest");
public static final Permission GLOBAL_FACTION = new Permission("customnpcs.global.faction");
public static final Permission GLOBAL_TRANSPORT = new Permission("customnpcs.global.transport");
public static final Permission GLOBAL_RECIPE = new Permission("customnpcs.global.recipe");
public static final Permission GLOBAL_NATURALSPAWN = new Permission("customnpcs.global.naturalspawn");
public static final Permission GLOBAL_TAG = new Permission("customnpcs.global.tag");
public static final Permission GLOBAL_PLAYERDATA = new Permission("customnpcs.global.playerdata");
public static final Permission GLOBAL_BANK = new Permission("customnpcs.global.bank");
public static final Permission GLOBAL_DIALOG = new Permission("customnpcs.global.dialog");
public static final Permission GLOBAL_QUEST = new Permission("customnpcs.global.quest");
public static final Permission GLOBAL_FACTION = new Permission("customnpcs.global.faction");
public static final Permission GLOBAL_TRANSPORT = new Permission("customnpcs.global.transport");
public static final Permission GLOBAL_RECIPE = new Permission("customnpcs.global.recipe");
public static final Permission GLOBAL_NATURALSPAWN = new Permission("customnpcs.global.naturalspawn");
public static final Permission GLOBAL_TAG = new Permission("customnpcs.global.tag");
public static final Permission GLOBAL_ANIMATION = new Permission("customnpcs.global.animation");
public static final Permission GLOBAL_MAGIC = new Permission("customnpcs.global.magic");
public static final Permission GLOBAL_EFFECT = new Permission("customnpcs.global.effect");
public static final Permission SPAWNER_MOB = new Permission("customnpcs.spawner.mob");
public static final Permission SPAWNER_CREATE = new Permission("customnpcs.spawner.create");
public static final Permission SPAWNER_CREATE = new Permission("customnpcs.spawner.create");
// Open / Use Wands
public static final Permission TOOL_MOUNTER = new Permission("customnpcs.tool.mounter");
public static final Permission TOOL_PATHER = new Permission("customnpcs.tool.pather");
public static final Permission TOOL_SCRIPTER = new Permission("customnpcs.tool.scripter");
public static final Permission TOOL_MOUNTER = new Permission("customnpcs.tool.mounter");
public static final Permission TOOL_PATHER = new Permission("customnpcs.tool.pather");
public static final Permission TOOL_SCRIPTER = new Permission("customnpcs.tool.scripter");
public static final Permission TOOL_CLONER = new Permission("customnpcs.tool.cloner");
public static final Permission TOOL_SCRIPTED_ITEM = new Permission("customnpcs.tool.scripteditem");
public static final Permission TOOL_TELEPORTER = new Permission("customnpcs.tool.teleporter");
// Edit Villager
public static final Permission EDIT_VILLAGER = new Permission("customnpcs.edit.villager");
public static final Permission EDIT_VILLAGER = new Permission("customnpcs.edit.villager");
public static final Permission EDIT_BLOCKS = new Permission("customnpcs.edit.blocks");
public static final Permission EDIT_REDSTONE = new Permission("customnpcs.edit.redstone");
@@ -97,87 +97,90 @@ public class CustomNpcsPermissions{
public static final Permission PROFILE_REGION_BYPASS = new Permission("customnpcs.profile.region-bypass");
public static final Permission PROFILE_MAX = new Permission("customnpcs.profile.max.*");
public static CustomNpcsPermissions Instance;
private Class<?> bukkit;
private Method getPlayer;
private Method hasPermission;
public static CustomNpcsPermissions Instance;
private Class<?> bukkit;
private Method getPlayer;
private Method hasPermission;
public CustomNpcsPermissions(){
Instance = this;
try {
bukkit = Class.forName("org.bukkit.Bukkit");
getPlayer = bukkit.getMethod("getPlayer", String.class);
hasPermission = Class.forName("org.bukkit.entity.Player").getMethod("hasPermission", String.class);
LogManager.getLogger(CustomNpcs.class).info("Bukkit permissions enabled");
LogManager.getLogger(CustomNpcs.class).info("Permissions available:");
Collections.sort(Permission.permissions, String.CASE_INSENSITIVE_ORDER);
for(String p : Permission.permissions){
LogManager.getLogger(CustomNpcs.class).info(p);
}
} catch (ClassNotFoundException e) {
// bukkit/mcpc+ is not loaded
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
}
}
public CustomNpcsPermissions() {
Instance = this;
try {
bukkit = Class.forName("org.bukkit.Bukkit");
getPlayer = bukkit.getMethod("getPlayer", String.class);
hasPermission = Class.forName("org.bukkit.entity.Player").getMethod("hasPermission", String.class);
LogManager.getLogger(CustomNpcs.class).info("Bukkit permissions enabled");
LogManager.getLogger(CustomNpcs.class).info("Permissions available:");
Collections.sort(Permission.permissions, String.CASE_INSENSITIVE_ORDER);
for (String p : Permission.permissions) {
LogManager.getLogger(CustomNpcs.class).info(p);
}
} catch (ClassNotFoundException e) {
// bukkit/mcpc+ is not loaded
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
}
}
public static boolean hasPermission(EntityPlayer player, Permission permission){
if(player != null){
if(FMLCommonHandler.instance().getSide() == Side.SERVER && NoppesUtilServer.isOp(player))
public static boolean hasPermission(EntityPlayer player, Permission permission) {
if (player != null) {
if (FMLCommonHandler.instance().getSide() == Side.SERVER && NoppesUtilServer.isOp(player))
return true;
if(Developer.Instance.hasUniversal(player.getUniqueID()))
return true;
if(permission != null){
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
}
}
}
return true;
}
if (Developer.Instance.hasUniversal(player.getUniqueID()))
return true;
if (permission != null) {
if (Instance.bukkit != null) {
return Instance.bukkitPermission(player.getCommandSenderName(), permission.name);
}
}
}
return true;
}
public static boolean hasCustomPermission(EntityPlayer player, String permission){
if(Developer.Instance.hasUniversal(player.getUniqueID())){
return true;
}
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission);
}
return false;
}
public static boolean hasCustomPermission(EntityPlayer player, String permission) {
if (Developer.Instance.hasUniversal(player.getUniqueID())) {
return true;
}
if (Instance.bukkit != null) {
return Instance.bukkitPermission(player.getCommandSenderName(), permission);
}
return false;
}
private boolean bukkitPermission(String username, String permission) {
try {
Object player = getPlayer.invoke(null, username);
return (Boolean) hasPermission.invoke(player, permission);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return false;
}
public static class Permission{
private static final List<String> permissions = new ArrayList<String>();
public String name;
public Permission(String name){
this.name = name;
if(!permissions.contains(name))
permissions.add(name);
}
}
public static boolean hasPermissionString(EntityPlayerMP player, String permission) {
if(Instance.bukkit != null){
return Instance.bukkitPermission(player.getCommandSenderName(), permission);
}
return true;
}
private boolean bukkitPermission(String username, String permission) {
try {
Object player = getPlayer.invoke(null, username);
return (Boolean) hasPermission.invoke(player, permission);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return false;
}
public static boolean enabled() {
return Instance.bukkit != null;
}
public static class Permission {
private static final List<String> permissions = new ArrayList<String>();
public String name;
public Permission(String name) {
this.name = name;
if (!permissions.contains(name))
permissions.add(name);
}
}
public static boolean hasPermissionString(EntityPlayerMP player, String permission) {
if (Instance.bukkit != null) {
return Instance.bukkitPermission(player.getCommandSenderName(), permission);
}
return true;
}
public static boolean enabled() {
return Instance.bukkit != null;
}
}
@@ -4,15 +4,14 @@ import net.minecraft.entity.Entity;
import net.minecraft.world.Teleporter;
import net.minecraft.world.WorldServer;
public class CustomTeleporter extends Teleporter{
public CustomTeleporter(WorldServer par1WorldServer) {
super(par1WorldServer);
}
public class CustomTeleporter extends Teleporter {
public CustomTeleporter(WorldServer par1WorldServer) {
super(par1WorldServer);
}
@Override
public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) {
@Override
public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8)
{
}
}
+210 -216
View File
@@ -12,255 +12,249 @@ import java.util.List;
public class DataAI {
private EntityNPCInterface npc;
public int onAttack = 0; //0:fight 1:panic 2:retreat 3:nothing
public int doorInteract = 2;
public int findShelter = 2;
public int distanceToMelee = 4;
public int canFireIndirect = 0;
public boolean canSwim = true;
public boolean reactsToFire = false;
public boolean avoidsWater = false;
public boolean avoidsSun = false;
public boolean returnToStart = true;
public boolean directLOS = true;
public int leapType = 0;
public boolean canSprint = false;
public boolean stopAndInteract = true;
public EnumNavType tacticalVariant = EnumNavType.Default;
public EnumCombatPolicy combatPolicy = EnumCombatPolicy.Flip;
public int useRangeMelee = 0;
public int tacticalRadius = 8;
public int tacticalChance = 5;
public int onAttack = 0; //0:fight 1:panic 2:retreat 3:nothing
public int doorInteract = 2;
public int findShelter = 2;
public int distanceToMelee = 4;
public int canFireIndirect = 0;
public boolean canSwim = true;
public boolean reactsToFire = false;
public boolean avoidsWater = false;
public boolean avoidsSun = false;
public boolean returnToStart = true;
public boolean directLOS = true;
public int leapType = 0;
public boolean canSprint = false;
public boolean stopAndInteract = true;
public EnumNavType tacticalVariant = EnumNavType.Default;
public EnumCombatPolicy combatPolicy = EnumCombatPolicy.Flip;
public int useRangeMelee = 0;
public int tacticalRadius = 8;
public int tacticalChance = 5;
public int movementType = 0; // 0 - Ground , 1 - Flying
public double flySpeed = 1.0D;
public double flyGravity = 0.0D;
public boolean hasFlyLimit = true;
public int flyHeightLimit = 2;
public int movementType = 0; // 0 - Ground , 1 - Flying
public double flySpeed = 1.0D;
public double flyGravity = 0.0D;
public boolean hasFlyLimit = true;
public int flyHeightLimit = 2;
public EnumAnimation animationType = EnumAnimation.NONE;
public EnumStandingType standingType = EnumStandingType.RotateBody;
public EnumMovingType movingType = EnumMovingType.Standing;
public boolean npcInteracting = true;
public EnumAnimation animationType = EnumAnimation.NONE;
public EnumStandingType standingType = EnumStandingType.RotateBody;
public EnumMovingType movingType = EnumMovingType.Standing;
public boolean npcInteracting = true;
public int orientation = 0;
public float bodyOffsetX = 5, bodyOffsetY = 5, bodyOffsetZ = 5;
public int walkingRange = 10;
private int moveSpeed = 5;
public int orientation = 0;
public float bodyOffsetX = 5, bodyOffsetY = 5, bodyOffsetZ = 5;
public int walkingRange = 10;
private int moveSpeed = 5;
private List<int[]> movingPath = new ArrayList<int[]>();
public int[] startPos;
public int movingPos = 0;
public int movingPattern = 0; // 0:Looping 1:Backtracking
private List<int[]> movingPath = new ArrayList<int[]>();
public int[] startPos;
public int movingPos = 0;
public int movingPattern = 0; // 0:Looping 1:Backtracking
public boolean movingPause = true;
public boolean movingPause = true;
public DataAI(EntityNPCInterface npc){
this.npc = npc;
}
public DataAI(EntityNPCInterface npc) {
this.npc = npc;
}
public void readToNBT(NBTTagCompound compound) {
canSwim = compound.getBoolean("CanSwim");
reactsToFire = compound.getBoolean("ReactsToFire");
avoidsWater = compound.getBoolean("AvoidsWater");
avoidsSun = compound.getBoolean("AvoidsSun");
returnToStart = compound.getBoolean("ReturnToStart");
onAttack = compound.getInteger("OnAttack");
doorInteract = compound.getInteger("DoorInteract");
findShelter = compound.getInteger("FindShelter");
directLOS = compound.getBoolean("DirectLOS");
leapType = compound.getInteger("LeapType");
canSprint = compound.getBoolean("CanSprint");
canFireIndirect = compound.getInteger("FireIndirect");
useRangeMelee = compound.getInteger("RangeAndMelee");
distanceToMelee = compound.getInteger("DistanceToMelee");
tacticalRadius = compound.getInteger("TacticalRadius");
tacticalChance = compound.getInteger("TacticalChance");
movingPause = compound.getBoolean("MovingPause");
npcInteracting = compound.getBoolean("npcInteracting");
stopAndInteract = compound.getBoolean("stopAndInteract");
public void readToNBT(NBTTagCompound compound) {
canSwim = compound.getBoolean("CanSwim");
reactsToFire = compound.getBoolean("ReactsToFire");
avoidsWater = compound.getBoolean("AvoidsWater");
avoidsSun = compound.getBoolean("AvoidsSun");
returnToStart = compound.getBoolean("ReturnToStart");
onAttack = compound.getInteger("OnAttack");
doorInteract = compound.getInteger("DoorInteract");
findShelter = compound.getInteger("FindShelter");
directLOS = compound.getBoolean("DirectLOS");
leapType = compound.getInteger("LeapType");
canSprint = compound.getBoolean("CanSprint");
canFireIndirect = compound.getInteger("FireIndirect");
useRangeMelee = compound.getInteger("RangeAndMelee");
distanceToMelee = compound.getInteger("DistanceToMelee");
tacticalRadius = compound.getInteger("TacticalRadius");
tacticalChance = compound.getInteger("TacticalChance");
movingPause = compound.getBoolean("MovingPause");
npcInteracting = compound.getBoolean("npcInteracting");
stopAndInteract = compound.getBoolean("stopAndInteract");
animationType = EnumAnimation.values()[compound.getInteger("MoveState") % EnumAnimation.values().length];
standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length];
movingType = EnumMovingType.values()[compound.getInteger("MovingState") % EnumMovingType.values().length];
tacticalVariant = EnumNavType.values()[compound.getInteger("TacticalVariant") % EnumNavType.values().length];
combatPolicy = EnumCombatPolicy.values()[compound.getInteger("CombatPolicy") % EnumCombatPolicy.values().length];
animationType = EnumAnimation.values()[compound.getInteger("MoveState") % EnumAnimation.values().length];
standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length];
movingType = EnumMovingType.values()[compound.getInteger("MovingState") % EnumMovingType.values().length];
tacticalVariant = EnumNavType.values()[compound.getInteger("TacticalVariant") % EnumNavType.values().length];
combatPolicy = EnumCombatPolicy.values()[compound.getInteger("CombatPolicy") % EnumCombatPolicy.values().length];
orientation = compound.getInteger("Orientation");
bodyOffsetY = compound.getFloat("PositionOffsetY");
bodyOffsetZ = compound.getFloat("PositionOffsetZ");
bodyOffsetX = compound.getFloat("PositionOffsetX");
walkingRange = compound.getInteger("WalkingRange");
setWalkingSpeed(compound.getInteger("MoveSpeed"));
orientation = compound.getInteger("Orientation");
bodyOffsetY = compound.getFloat("PositionOffsetY");
bodyOffsetZ = compound.getFloat("PositionOffsetZ");
bodyOffsetX = compound.getFloat("PositionOffsetX");
walkingRange = compound.getInteger("WalkingRange");
setWalkingSpeed(compound.getInteger("MoveSpeed"));
setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew",10)));
movingPos = compound.getInteger("MovingPos");
movingPattern = compound.getInteger("MovingPatern");
setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew", 10)));
movingPos = compound.getInteger("MovingPos");
movingPattern = compound.getInteger("MovingPatern");
movementType = compound.getInteger("MovingType");
if(!compound.hasKey("FlySpeed"))
flySpeed = 1.0D;
else
flySpeed = compound.getDouble("FlySpeed");
movementType = compound.getInteger("MovingType");
if (!compound.hasKey("FlySpeed"))
flySpeed = 1.0D;
else
flySpeed = compound.getDouble("FlySpeed");
if(!compound.hasKey("FlyGravity"))
flyGravity = 0.0D;
else
flyGravity = compound.getDouble("FlyGravity");
if (!compound.hasKey("FlyGravity"))
flyGravity = 0.0D;
else
flyGravity = compound.getDouble("FlyGravity");
if(!compound.hasKey("HasFlyLimit"))
hasFlyLimit = false;
else
hasFlyLimit = compound.getBoolean("HasFlyLimit");
if (!compound.hasKey("HasFlyLimit"))
hasFlyLimit = false;
else
hasFlyLimit = compound.getBoolean("HasFlyLimit");
if(!compound.hasKey("FlyHeightLimit"))
flyHeightLimit = 5;
else
flyHeightLimit = compound.getInteger("FlyHeightLimit");
if (!compound.hasKey("FlyHeightLimit"))
flyHeightLimit = 5;
else
flyHeightLimit = compound.getInteger("FlyHeightLimit");
startPos = compound.getIntArray("StartPosNew");
if (startPos == null || startPos.length != 3){
startPos = new int[] {
MathHelper.floor_double(npc.posX),
MathHelper.floor_double(npc.posY),
MathHelper.floor_double(npc.posZ) };
}
}
startPos = compound.getIntArray("StartPosNew");
if (startPos == null || startPos.length != 3) {
startPos = new int[]{
MathHelper.floor_double(npc.posX),
MathHelper.floor_double(npc.posY),
MathHelper.floor_double(npc.posZ)};
}
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setBoolean("CanSwim", canSwim);
compound.setBoolean("ReactsToFire", reactsToFire);
compound.setBoolean("AvoidsWater", avoidsWater );
compound.setBoolean("AvoidsSun", avoidsSun);
compound.setBoolean("ReturnToStart", returnToStart);
compound.setInteger("OnAttack", onAttack);
compound.setInteger("DoorInteract", doorInteract);
compound.setInteger("FindShelter", findShelter);
compound.setBoolean("DirectLOS", directLOS);
compound.setInteger("LeapType", leapType);
compound.setBoolean("CanSprint", canSprint);
compound.setInteger("FireIndirect", canFireIndirect);
compound.setInteger("RangeAndMelee", useRangeMelee);
compound.setInteger("DistanceToMelee", distanceToMelee);
compound.setInteger("TacticalRadius", tacticalRadius);
compound.setInteger("TacticalChance", tacticalChance);
compound.setBoolean("MovingPause", movingPause);
compound.setBoolean("npcInteracting", npcInteracting);
compound.setBoolean("stopAndInteract", stopAndInteract);
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setBoolean("CanSwim", canSwim);
compound.setBoolean("ReactsToFire", reactsToFire);
compound.setBoolean("AvoidsWater", avoidsWater);
compound.setBoolean("AvoidsSun", avoidsSun);
compound.setBoolean("ReturnToStart", returnToStart);
compound.setInteger("OnAttack", onAttack);
compound.setInteger("DoorInteract", doorInteract);
compound.setInteger("FindShelter", findShelter);
compound.setBoolean("DirectLOS", directLOS);
compound.setInteger("LeapType", leapType);
compound.setBoolean("CanSprint", canSprint);
compound.setInteger("FireIndirect", canFireIndirect);
compound.setInteger("RangeAndMelee", useRangeMelee);
compound.setInteger("DistanceToMelee", distanceToMelee);
compound.setInteger("TacticalRadius", tacticalRadius);
compound.setInteger("TacticalChance", tacticalChance);
compound.setBoolean("MovingPause", movingPause);
compound.setBoolean("npcInteracting", npcInteracting);
compound.setBoolean("stopAndInteract", stopAndInteract);
compound.setInteger("MoveState", animationType.ordinal());
compound.setInteger("StandingState", standingType.ordinal());
compound.setInteger("MovingState", movingType.ordinal());
compound.setInteger("TacticalVariant", tacticalVariant.ordinal());
compound.setInteger("CombatPolicy", combatPolicy.ordinal());
compound.setInteger("MoveState", animationType.ordinal());
compound.setInteger("StandingState", standingType.ordinal());
compound.setInteger("MovingState", movingType.ordinal());
compound.setInteger("TacticalVariant", tacticalVariant.ordinal());
compound.setInteger("CombatPolicy", combatPolicy.ordinal());
compound.setInteger("Orientation", orientation);
compound.setFloat("PositionOffsetX", bodyOffsetX);
compound.setFloat("PositionOffsetY", bodyOffsetY);
compound.setFloat("PositionOffsetZ", bodyOffsetZ);
compound.setInteger("WalkingRange", walkingRange);
compound.setInteger("MoveSpeed", moveSpeed);
compound.setInteger("Orientation", orientation);
compound.setFloat("PositionOffsetX", bodyOffsetX);
compound.setFloat("PositionOffsetY", bodyOffsetY);
compound.setFloat("PositionOffsetZ", bodyOffsetZ);
compound.setInteger("WalkingRange", walkingRange);
compound.setInteger("MoveSpeed", moveSpeed);
compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath));
compound.setInteger("MovingPos", movingPos);
compound.setInteger("MovingPatern", movingPattern);
compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath));
compound.setInteger("MovingPos", movingPos);
compound.setInteger("MovingPatern", movingPattern);
compound.setInteger("MovingType", movementType);
compound.setDouble("FlySpeed",flySpeed);
compound.setDouble("FlyGravity",flyGravity);
compound.setBoolean("HasFlyLimit",hasFlyLimit);
compound.setInteger("FlyHeightLimit", flyHeightLimit);
compound.setInteger("MovingType", movementType);
compound.setDouble("FlySpeed", flySpeed);
compound.setDouble("FlyGravity", flyGravity);
compound.setBoolean("HasFlyLimit", hasFlyLimit);
compound.setInteger("FlyHeightLimit", flyHeightLimit);
npc.setAvoidWater(avoidsWater);
npc.setAvoidWater(avoidsWater);
compound.setIntArray("StartPosNew", npc.getStartPos());
compound.setIntArray("StartPosNew", npc.getStartPos());
return compound;
}
return compound;
}
public List<int[]> getMovingPath() {
if(movingPath.isEmpty() && startPos != null)
movingPath.add(startPos);
return movingPath;
}
public List<int[]> getMovingPath() {
if (movingPath.isEmpty() && startPos != null)
movingPath.add(startPos);
return movingPath;
}
public void setMovingPath(List<int[]> list) {
movingPath = list;
if(!movingPath.isEmpty())
startPos = movingPath.get(0);
}
public void setMovingPath(List<int[]> list) {
movingPath = list;
if (!movingPath.isEmpty())
startPos = movingPath.get(0);
}
public int[] getCurrentMovingPath(){
List<int[]> list = getMovingPath();
if(list.size() == 1){
movingPos = 0;
}
else if(movingPos >= list.size()){
if(movingPattern == 0)
movingPos = 0;
else{
int size = list.size() * 2 - 2;
if(movingPos >= size){
movingPos = 0;
}
else if(movingPos >= list.size()){
return list.get(list.size() - (movingPos % list.size()) - 2);
}
}
}
public int[] getCurrentMovingPath() {
List<int[]> list = getMovingPath();
if (list.size() == 1) {
movingPos = 0;
} else if (movingPos >= list.size()) {
if (movingPattern == 0)
movingPos = 0;
else {
int size = list.size() * 2 - 2;
if (movingPos >= size) {
movingPos = 0;
} else if (movingPos >= list.size()) {
return list.get(list.size() - (movingPos % list.size()) - 2);
}
}
}
return list.get(movingPos);
}
return list.get(movingPos);
}
public void incrementMovingPath(){
List<int[]> list = getMovingPath();
if(list.size() == 1){
movingPos = 0;
}
else if(movingPattern == 0){
movingPos++;
movingPos = movingPos % list.size();
}
else if(movingPattern == 1){
movingPos++;
int size = list.size() * 2 - 2;
movingPos = movingPos % size;
}
}
public void incrementMovingPath() {
List<int[]> list = getMovingPath();
if (list.size() == 1) {
movingPos = 0;
} else if (movingPattern == 0) {
movingPos++;
movingPos = movingPos % list.size();
} else if (movingPattern == 1) {
movingPos++;
int size = list.size() * 2 - 2;
movingPos = movingPos % size;
}
}
public void decreaseMovingPath() {
List<int[]> list = getMovingPath();
if(list.size() == 1){
movingPos = 0;
}
else if(movingPattern == 0){
movingPos--;
if(movingPos < 0)
movingPos += list.size();
}
else if(movingPattern == 1){
movingPos--;
if(movingPos < 0){
int size = list.size() * 2 - 2;
movingPos += size;
}
}
}
public void decreaseMovingPath() {
List<int[]> list = getMovingPath();
if (list.size() == 1) {
movingPos = 0;
} else if (movingPattern == 0) {
movingPos--;
if (movingPos < 0)
movingPos += list.size();
} else if (movingPattern == 1) {
movingPos--;
if (movingPos < 0) {
int size = list.size() * 2 - 2;
movingPos += size;
}
}
}
public double getDistanceSqToPathPoint() {
int[] pos = getCurrentMovingPath();
return npc.getDistanceSq(pos[0] + 0.5, pos[1], pos[2] + 0.5);
}
public double getDistanceSqToPathPoint() {
int[] pos = getCurrentMovingPath();
return npc.getDistanceSq(pos[0] + 0.5, pos[1], pos[2] + 0.5);
}
public void setWalkingSpeed(double speed){
this.moveSpeed = (int)speed;
npc.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(npc.getSpeed());
}
public void setWalkingSpeed(double speed) {
this.moveSpeed = (int) speed;
npc.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(npc.getSpeed());
}
public int getWalkingSpeed(){
return this.moveSpeed;
}
public int getWalkingSpeed() {
return this.moveSpeed;
}
}
+47 -47
View File
@@ -41,12 +41,12 @@ public class DataAdvanced {
public boolean attackOtherFactions = false;
public boolean defendFaction = false;
public boolean disablePitch = false;
public boolean disablePitch = false;
public String soulStonePlayerName = "";
public boolean refuseSoulStone = false;
public boolean soulStoneInit = false;
public int minFactionPointsToSoulStone = -1;
public String soulStonePlayerName = "";
public boolean refuseSoulStone = false;
public boolean soulStoneInit = false;
public int minFactionPointsToSoulStone = -1;
public DataAdvanced(EntityNPCInterface npc) {
this.npc = npc;
@@ -76,13 +76,13 @@ public class DataAdvanced {
compound.setInteger("NpcJob", job.ordinal());
compound.setTag("FactionPoints", factions.writeToNBT(new NBTTagCompound()));
compound.setTag("NPCDialogOptions", nbtDialogs(npc.dialogs));
compound.setTag("NPCDialogOptions", nbtDialogs(npc.dialogs));
compound.setBoolean("RefuseSoulStone", refuseSoulStone);
compound.setString("SoulStonePlayerName", soulStonePlayerName);
compound.setInteger("MinFactionPointsToSoulStone", minFactionPointsToSoulStone);
compound.setBoolean("RefuseSoulStone", refuseSoulStone);
compound.setString("SoulStonePlayerName", soulStonePlayerName);
compound.setInteger("MinFactionPointsToSoulStone", minFactionPointsToSoulStone);
if(!tagUUIDs.isEmpty()){
if (!tagUUIDs.isEmpty()) {
NBTTagList nbtTagList = new NBTTagList();
for (UUID uuid : tagUUIDs) {
nbtTagList.appendTag(new NBTTagString(uuid.toString()));
@@ -119,45 +119,45 @@ public class DataAdvanced {
factions.readFromNBT(compound.getCompoundTag("FactionPoints"));
npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10));
npc.dialogs = getDialogs(compound.getTagList("NPCDialogOptions", 10));
refuseSoulStone = compound.getBoolean("RefuseSoulStone");
soulStonePlayerName = compound.getString("SoulStonePlayerName");
minFactionPointsToSoulStone = compound.getInteger("MinFactionPointsToSoulStone");
refuseSoulStone = compound.getBoolean("RefuseSoulStone");
soulStonePlayerName = compound.getString("SoulStonePlayerName");
minFactionPointsToSoulStone = compound.getInteger("MinFactionPointsToSoulStone");
if(compound.hasKey("TagUUIDs")){
NBTTagList nbtTagList = compound.getTagList("TagUUIDs",8);
if (compound.hasKey("TagUUIDs")) {
NBTTagList nbtTagList = compound.getTagList("TagUUIDs", 8);
for (int i = 0; i < nbtTagList.tagCount(); i++) {
tagUUIDs.add(UUID.fromString(nbtTagList.getStringTagAt(i)));
}
}
}
private HashMap<Integer, DialogOption> getDialogs(NBTTagList tagList) {
HashMap<Integer, DialogOption> map = new HashMap<Integer, DialogOption>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
int slot = nbttagcompound.getInteger("DialogSlot");
DialogOption option = new DialogOption();
option.readNBT(nbttagcompound.getCompoundTag("NPCDialog"));
map.put(slot, option);
private HashMap<Integer, DialogOption> getDialogs(NBTTagList tagList) {
HashMap<Integer, DialogOption> map = new HashMap<Integer, DialogOption>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
int slot = nbttagcompound.getInteger("DialogSlot");
DialogOption option = new DialogOption();
option.readNBT(nbttagcompound.getCompoundTag("NPCDialog"));
map.put(slot, option);
}
return map;
}
}
return map;
}
private NBTTagList nbtDialogs(HashMap<Integer, DialogOption> dialogs2) {
NBTTagList nbttaglist = new NBTTagList();
for (int slot : dialogs2.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("DialogSlot", slot);
nbttagcompound.setTag("NPCDialog", dialogs2.get(slot)
.writeNBT());
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
private NBTTagList nbtDialogs(HashMap<Integer, DialogOption> dialogs2) {
NBTTagList nbttaglist = new NBTTagList();
for (int slot : dialogs2.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("DialogSlot", slot);
nbttagcompound.setTag("NPCDialog", dialogs2.get(slot)
.writeNBT());
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public Line getInteractLine() {
return (Line) interactLines.getLine(!orderedLines);
@@ -184,25 +184,25 @@ public class DataAdvanced {
i -= 2;
}
role = EnumRoleType.values()[i];
if(role == EnumRoleType.None)
if (role == EnumRoleType.None)
npc.roleInterface = null;
else if(role == EnumRoleType.Bank && !(npc.roleInterface instanceof RoleBank))
else if (role == EnumRoleType.Bank && !(npc.roleInterface instanceof RoleBank))
npc.roleInterface = new RoleBank(npc);
else if(role == EnumRoleType.Follower && !(npc.roleInterface instanceof RoleFollower))
else if (role == EnumRoleType.Follower && !(npc.roleInterface instanceof RoleFollower))
npc.roleInterface = new RoleFollower(npc);
else if(role == EnumRoleType.Postman && !(npc.roleInterface instanceof RolePostman))
else if (role == EnumRoleType.Postman && !(npc.roleInterface instanceof RolePostman))
npc.roleInterface = new RolePostman(npc);
else if(role == EnumRoleType.Trader && !(npc.roleInterface instanceof RoleTrader))
else if (role == EnumRoleType.Trader && !(npc.roleInterface instanceof RoleTrader))
npc.roleInterface = new RoleTrader(npc);
else if(role == EnumRoleType.Transporter && !(npc.roleInterface instanceof RoleTransporter))
else if (role == EnumRoleType.Transporter && !(npc.roleInterface instanceof RoleTransporter))
npc.roleInterface = new RoleTransporter(npc);
else if(role == EnumRoleType.Companion && !(npc.roleInterface instanceof RoleCompanion))
else if (role == EnumRoleType.Companion && !(npc.roleInterface instanceof RoleCompanion))
npc.roleInterface = new RoleCompanion(npc);
}
public void setJob(int i) {
if(npc.jobInterface != null && !npc.worldObj.isRemote)
npc.jobInterface.reset();
if (npc.jobInterface != null && !npc.worldObj.isRemote)
npc.jobInterface.reset();
job = EnumJobType.values()[i % EnumJobType.values().length];
if (job == EnumJobType.None)
+40 -42
View File
@@ -36,7 +36,7 @@ public class DataDisplay {
private int markovGeneratorId = 8; //roman,japanese,slavic,welsh,sami,oldnorse,ancientgreek,aztec,classic,spanish (0 - 9 inclusively)
private int markovGender = 0; //0:random, 1:male, 2:female
public byte skinType = 0; //0:normal, 1:player, 2:url, 3:url64
public byte skinType = 0; //0:normal, 1:player, 2:url, 3:url64
public String url = "";
@@ -53,7 +53,7 @@ public class DataDisplay {
public String glowTexture = "";
public int visible = 0; //0:visible 1:Invisible 2:semi-invisible
public int visible = 0; //0:visible 1:Invisible 2:semi-invisible
public int modelSize = 5;
public int showName = 0;
public int modelType = 0;
@@ -68,9 +68,9 @@ public class DataDisplay {
@SideOnly(Side.CLIENT)
public HashSet<Integer> tempInvisIds;
public DataDisplay(EntityNPCInterface npc){
public DataDisplay(EntityNPCInterface npc) {
this.npc = npc;
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length-1);
markovGeneratorId = new Random().nextInt(CustomNpcs.MARKOV_GENERATOR.length - 1);
skinOverlayData = new DataSkinOverlays(npc);
name = getRandomName();
animationData = new AnimationData(this);
@@ -100,8 +100,7 @@ public class DataDisplay {
nbttagcompound = hitboxData.writeToNBT(nbttagcompound);
nbttagcompound = tintData.writeToNBT(nbttagcompound);
if (this.playerProfile != null)
{
if (this.playerProfile != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
NBTUtil.func_152460_a(nbttagcompound1, this.playerProfile);
nbttagcompound.setTag("SkinUsername", nbttagcompound1);
@@ -120,16 +119,16 @@ public class DataDisplay {
ArrayList<Integer> nonPersistedIDs = new ArrayList<>();
NBTTagList list = new NBTTagList();
for(UUID uuid : invisibleToList){
if(saveNonPersistendIDs){
for (UUID uuid : invisibleToList) {
if (saveNonPersistendIDs) {
EntityPlayer p = NoppesUtilServer.getPlayer(uuid);
if(p != null)
if (p != null)
nonPersistedIDs.add(p.getEntityId());
}
list.appendTag(new NBTTagString(uuid.toString()));
}
if(!nonPersistedIDs.isEmpty()) {
if (!nonPersistedIDs.isEmpty()) {
int[] tempIDArr = nonPersistedIDs.stream().filter(Objects::nonNull).mapToInt(i -> i).toArray();
nbttagcompound.setIntArray("InvisibleToNonPersistentID", tempIDArr);
}
@@ -137,6 +136,7 @@ public class DataDisplay {
nbttagcompound.setTag("InvisibleToList", list);
return nbttagcompound;
}
public void readToNBT(NBTTagCompound nbttagcompound) {
setName(nbttagcompound.getString("Name"));
setMarkovGeneratorId(nbttagcompound.getInteger("MarkovGeneratorId"));
@@ -151,11 +151,10 @@ public class DataDisplay {
skinType = nbttagcompound.getByte("UsingSkinUrl");
this.playerProfile = null;
if(skinType == 1){
if (nbttagcompound.hasKey("SkinUsername", 10)){
if (skinType == 1) {
if (nbttagcompound.hasKey("SkinUsername", 10)) {
this.playerProfile = NBTUtil.func_152459_a(nbttagcompound.getCompoundTag("SkinUsername"));
}
else if (nbttagcompound.hasKey("SkinUsername", 8) && !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkinUsername"))){
} else if (nbttagcompound.hasKey("SkinUsername", 8) && !StringUtils.isNullOrEmpty(nbttagcompound.getString("SkinUsername"))) {
this.playerProfile = new GameProfile(null, nbttagcompound.getString("SkinUsername"));
}
this.loadProfile();
@@ -190,7 +189,7 @@ public class DataDisplay {
tintData.readFromNBT(nbttagcompound);
modelSize = ValueUtil.clamp(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
if(modelSize > ConfigMain.NpcSizeLimit)
if (modelSize > ConfigMain.NpcSizeLimit)
modelSize = ConfigMain.NpcSizeLimit;
modelType = nbttagcompound.getInteger("modelType");
@@ -201,21 +200,20 @@ public class DataDisplay {
disableLivingAnimation = nbttagcompound.getBoolean("NoLivingAnimation");
showBossBar = nbttagcompound.getByte("BossBar");
NBTTagList tagList = (NBTTagList)nbttagcompound.getTag("InvisibleToList");
if(tagList != null) {
NBTTagList tagList = (NBTTagList) nbttagcompound.getTag("InvisibleToList");
if (tagList != null) {
invisibleToList.clear();
for (int i = 0; i < tagList.tagCount(); i++) {
String nbtTagString = tagList.getStringTagAt(i);
invisibleToList.add(UUID.fromString(nbtTagString));
}
}
else {
} else {
invisibleToList = new ArrayList<>();
}
if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT){
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
if(tempInvisIds == null){
if (tempInvisIds == null) {
tempInvisIds = new HashSet<>();
} else {
tempInvisIds.clear();
@@ -223,28 +221,28 @@ public class DataDisplay {
int[] tempEntityIDList = nbttagcompound.getIntArray("InvisibleToNonPersistentID");
final int playerID = Minecraft.getMinecraft().thePlayer.getEntityId();
for(int i : tempEntityIDList){
if(i == playerID){
for (int i : tempEntityIDList) {
if (i == playerID) {
isInvisibleToMe = true;
}
tempInvisIds.add(i);
}
}
if(prevSkinType != skinType || !texture.equals(prevTexture)|| !url.equals(prevUrl))
if (prevSkinType != skinType || !texture.equals(prevTexture) || !url.equals(prevUrl))
npc.textureLocation = null;
npc.updateHitbox();
}
public void loadProfile(){
if (this.playerProfile != null && !StringUtils.isNullOrEmpty(this.playerProfile.getName()) && MinecraftServer.getServer() != null){
if (!this.playerProfile.isComplete() || !this.playerProfile.getProperties().containsKey("textures")){
public void loadProfile() {
if (this.playerProfile != null && !StringUtils.isNullOrEmpty(this.playerProfile.getName()) && MinecraftServer.getServer() != null) {
if (!this.playerProfile.isComplete() || !this.playerProfile.getProperties().containsKey("textures")) {
GameProfile gameprofile = MinecraftServer.getServer().func_152358_ax().func_152655_a(this.playerProfile.getName());
if (gameprofile != null){
Property property = (Property)Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object)null);
if (gameprofile != null) {
Property property = (Property) Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object) null);
if (property == null){
if (property == null) {
gameprofile = MinecraftServer.getServer().func_147130_as().fillProfileProperties(gameprofile, false);
}
@@ -255,17 +253,17 @@ public class DataDisplay {
}
public boolean showName() {
if(npc.isKilled())
if (npc.isKilled())
return false;
return showName == 0 || (showName == 2 && npc.isAttacking());
}
public String getSkinTexture(){
public String getSkinTexture() {
return texture;
}
public void setSkinTexture(String texture){
if(this.texture.equals(texture))
public void setSkinTexture(String texture) {
if (this.texture.equals(texture))
return;
this.texture = texture;
npc.textureLocation = null;
@@ -273,35 +271,35 @@ public class DataDisplay {
npc.updateClient = true;
}
public String getName(){
public String getName() {
return name;
}
public void setName(String name){
if(this.name.equals(name))
public void setName(String name) {
if (this.name.equals(name))
return;
this.name = name;
npc.updateClient = true;
}
public int getMarkovGender(){
public int getMarkovGender() {
return markovGender;
}
public void setMarkovGender(int gender) {
if(markovGender == gender)
if (markovGender == gender)
return;
this.markovGender = ValueUtil.clamp(gender, 0, 2);
}
public int getMarkovGeneratorId(){
public int getMarkovGeneratorId() {
return markovGeneratorId;
}
public void setMarkovGeneratorId(int id) {
if(markovGeneratorId == id)
if (markovGeneratorId == id)
return;
this.markovGeneratorId = ValueUtil.clamp(id, 0, CustomNpcs.MARKOV_GENERATOR.length-1);
this.markovGeneratorId = ValueUtil.clamp(id, 0, CustomNpcs.MARKOV_GENERATOR.length - 1);
}
@SideOnly(Side.CLIENT)
+305 -302
View File
@@ -18,354 +18,357 @@ import java.util.HashMap;
import java.util.Random;
public class DataInventory implements IInventory {
public static Random random = new Random();
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>();
public HashMap<Integer,Double> dropchance = new HashMap<Integer,Double>();
public HashMap<Integer,ItemStack> weapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer,ItemStack> prevWeapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer,ItemStack> armor = new HashMap<Integer, ItemStack>();
public static Random random = new Random();
public HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
public HashMap<Integer, Double> dropchance = new HashMap<Integer, Double>();
public HashMap<Integer, ItemStack> weapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer, ItemStack> prevWeapons = new HashMap<Integer, ItemStack>();
public HashMap<Integer, ItemStack> armor = new HashMap<Integer, ItemStack>();
public int minExp = 0;
public int maxExp = 0;
public int minExp = 0;
public int maxExp = 0;
public int lootMode = 0;
public int lootMode = 0;
private EntityNPCInterface npc;
private EntityNPCInterface npc;
public DataInventory(EntityNPCInterface npc){
this.npc = npc;
}
public NBTTagCompound writeEntityToNBT(NBTTagCompound nbttagcompound){
nbttagcompound.setInteger("MinExp", minExp);
nbttagcompound.setInteger("MaxExp", maxExp);
nbttagcompound.setTag("NpcInv", NBTTags.nbtItemStackList(items));
nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor()));
nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons()));
nbttagcompound.setTag("DoubleDropChance", NBTTags.nbtIntegerDoubleMap(dropchance));
nbttagcompound.setInteger("LootMode", lootMode);
public DataInventory(EntityNPCInterface npc) {
this.npc = npc;
}
return nbttagcompound;
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound){
minExp = nbttagcompound.getInteger("MinExp");
maxExp = nbttagcompound.getInteger("MaxExp");
items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10));
setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10)));
setWeapons(NBTTags.getItemStackList(nbttagcompound.getTagList("Weapons", 10)));
public NBTTagCompound writeEntityToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("MinExp", minExp);
nbttagcompound.setInteger("MaxExp", maxExp);
nbttagcompound.setTag("NpcInv", NBTTags.nbtItemStackList(items));
nbttagcompound.setTag("Armor", NBTTags.nbtItemStackList(getArmor()));
nbttagcompound.setTag("Weapons", NBTTags.nbtItemStackList(getWeapons()));
nbttagcompound.setTag("DoubleDropChance", NBTTags.nbtIntegerDoubleMap(dropchance));
nbttagcompound.setInteger("LootMode", lootMode);
if(!nbttagcompound.hasKey("DoubleDropChance")) {
dropchance.clear();
HashMap<Integer, Integer> oldDropChance = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("DropChance", 10));
for(int i = 0; i < oldDropChance.entrySet().size(); i++){
dropchance.put(i, Double.valueOf(oldDropChance.get(i)));
}
} else {
dropchance = NBTTags.getIntegerDoubleMap(nbttagcompound.getTagList("DoubleDropChance", 10));
}
return nbttagcompound;
}
lootMode = nbttagcompound.getInteger("LootMode");
}
public HashMap<Integer, ItemStack> getWeapons() {
return weapons;
}
public void setWeapons(HashMap<Integer, ItemStack> list) {
weapons = list;
}
public HashMap<Integer, ItemStack> getArmor() {
return armor;
}
public void setArmor(HashMap<Integer, ItemStack> list) {
armor = list;
}
public ItemStack getWeapon(){
return weapons.get(0);
}
public void setWeapon(ItemStack item){
weapons.put(0, item);
}
public ItemStack getProjectile(){
return weapons.get(1);
}
public void setProjectile(ItemStack item){
weapons.put(1, item);
}
public ItemStack getOffHand(){
return weapons.get(2);
}
public void setOffHand(ItemStack item){
weapons.put(2, item);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound) {
minExp = nbttagcompound.getInteger("MinExp");
maxExp = nbttagcompound.getInteger("MaxExp");
items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcInv", 10));
setArmor(NBTTags.getItemStackList(nbttagcompound.getTagList("Armor", 10)));
setWeapons(NBTTags.getItemStackList(nbttagcompound.getTagList("Weapons", 10)));
public ArrayList<ItemStack> getDroppedItems(DamageSource damagesource) {
ArrayList<ItemStack> drops = new ArrayList<>();
ArrayList<EntityItem> list = new ArrayList<EntityItem>();
for (int i : items.keySet()) {
ItemStack item = items.get(i);
if(item == null)
continue;
double dchance = 100;
double chance = random.nextDouble() * 100;
if(dropchance.containsKey(i))
dchance = dropchance.get(i);
// double chance = Math.random()*100 + dchance;
if(chance < dchance){
EntityItem e = getEntityItem(item.copy());
if(e != null)
list.add(e);
}
}
for (EntityItem e : list) {
drops.add(e.getEntityItem());
}
int enchant = 0;
if (damagesource.getEntity() instanceof EntityPlayer){
enchant = EnchantmentHelper.getLootingModifier((EntityLivingBase)damagesource.getEntity());
}
if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(npc, damagesource, list, enchant, true, 0)){
return drops;
} else {
return new ArrayList<>();
}
}
public int getDroppedXp() {
int droppedXp = minExp;
if (maxExp - minExp > 0)
droppedXp += npc.worldObj.rand.nextInt(maxExp - minExp);
return droppedXp;
}
public void dropXp(Entity entity, int droppedXp) {
while (droppedXp > 0){
int var2 = EntityXPOrb.getXPSplit(droppedXp);
droppedXp -= var2;
if(lootMode == 1 && entity instanceof EntityPlayer){
npc.worldObj.spawnEntityInWorld(new EntityXPOrb(entity.worldObj, entity.posX, entity.posY, entity.posZ, var2));
}
else{
npc.worldObj.spawnEntityInWorld(new EntityXPOrb(npc.worldObj, npc.posX, npc.posY, npc.posZ, var2));
}
}
}
public void dropItems(Entity entity, ArrayList<ItemStack> itemList) {
ArrayList<EntityItem> list = new ArrayList<EntityItem>();
for (ItemStack item : itemList) {
if(item == null)
continue;
EntityItem e = getEntityItem(item.copy());
if(e != null)
list.add(e);
}
for (EntityItem item : list){
if(lootMode == 1 && entity instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)entity;
item.delayBeforeCanPickup = 2;
npc.worldObj.spawnEntityInWorld(item);
ItemStack stack = item.getEntityItem();
int i = stack.stackSize;
if (player.inventory.addItemStackToInventory(stack)) {
npc.worldObj.playSoundAtEntity(item,
"random.pop",
0.2F,
((npc.getRNG().nextFloat() - npc.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F);
player.onItemPickup(item, i);
if (stack.stackSize <= 0) {
item.setDead();
}
}
}
else
npc.worldObj.spawnEntityInWorld(item);
}
}
public EntityItem getEntityItem(ItemStack itemstack) {
if (itemstack == null) {
return null;
}
EntityItem entityitem = new EntityItem(npc.worldObj, npc.posX,
(npc.posY - 0.30000001192092896D) + (double) npc.getEyeHeight(), npc.posZ,
itemstack);
entityitem.delayBeforeCanPickup = 40;
float f2 = npc.getRNG().nextFloat() * 0.5F;
float f4 = npc.getRNG().nextFloat() * 3.141593F * 2.0F;
entityitem.motionX = -MathHelper.sin(f4) * f2;
entityitem.motionZ = MathHelper.cos(f4) * f2;
entityitem.motionY = 0.20000000298023224D;
return entityitem;
}
public ItemStack armorItemInSlot(int i) {
return getArmor().get(i);
}
@Override
public int getSizeInventory() {
return 15;
}
@Override
public ItemStack getStackInSlot(int i) {
if(i < 4)
return armorItemInSlot(i);
else if(i < 7)
return getWeapons().get(i-4);
else
return items.get(i-7);
}
@Override
public ItemStack decrStackSize(int par1, int par2) {
int i =0;
HashMap<Integer,ItemStack> var3;
if (par1 >= 7)
{
var3 = items;
par1 -= 7;
if (!nbttagcompound.hasKey("DoubleDropChance")) {
dropchance.clear();
HashMap<Integer, Integer> oldDropChance = NBTTags.getIntegerIntegerMap(nbttagcompound.getTagList("DropChance", 10));
for (int i = 0; i < oldDropChance.entrySet().size(); i++) {
dropchance.put(i, Double.valueOf(oldDropChance.get(i)));
}
} else {
dropchance = NBTTags.getIntegerDoubleMap(nbttagcompound.getTagList("DoubleDropChance", 10));
}
else if (par1 >= 4)
{
var3 = getWeapons();
lootMode = nbttagcompound.getInteger("LootMode");
}
public HashMap<Integer, ItemStack> getWeapons() {
return weapons;
}
public void setWeapons(HashMap<Integer, ItemStack> list) {
weapons = list;
}
public HashMap<Integer, ItemStack> getArmor() {
return armor;
}
public void setArmor(HashMap<Integer, ItemStack> list) {
armor = list;
}
public ItemStack getWeapon() {
return weapons.get(0);
}
public void setWeapon(ItemStack item) {
weapons.put(0, item);
}
public ItemStack getProjectile() {
return weapons.get(1);
}
public void setProjectile(ItemStack item) {
weapons.put(1, item);
}
public ItemStack getOffHand() {
return weapons.get(2);
}
public void setOffHand(ItemStack item) {
weapons.put(2, item);
}
public ArrayList<ItemStack> getDroppedItems(DamageSource damagesource) {
ArrayList<ItemStack> drops = new ArrayList<>();
ArrayList<EntityItem> list = new ArrayList<EntityItem>();
for (int i : items.keySet()) {
ItemStack item = items.get(i);
if (item == null)
continue;
double dchance = 100;
double chance = random.nextDouble() * 100;
if (dropchance.containsKey(i))
dchance = dropchance.get(i);
// double chance = Math.random()*100 + dchance;
if (chance < dchance) {
EntityItem e = getEntityItem(item.copy());
if (e != null)
list.add(e);
}
}
for (EntityItem e : list) {
drops.add(e.getEntityItem());
}
int enchant = 0;
if (damagesource.getEntity() instanceof EntityPlayer) {
enchant = EnchantmentHelper.getLootingModifier((EntityLivingBase) damagesource.getEntity());
}
if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(npc, damagesource, list, enchant, true, 0)) {
return drops;
} else {
return new ArrayList<>();
}
}
public int getDroppedXp() {
int droppedXp = minExp;
if (maxExp - minExp > 0)
droppedXp += npc.worldObj.rand.nextInt(maxExp - minExp);
return droppedXp;
}
public void dropXp(Entity entity, int droppedXp) {
while (droppedXp > 0) {
int var2 = EntityXPOrb.getXPSplit(droppedXp);
droppedXp -= var2;
if (lootMode == 1 && entity instanceof EntityPlayer) {
npc.worldObj.spawnEntityInWorld(new EntityXPOrb(entity.worldObj, entity.posX, entity.posY, entity.posZ, var2));
} else {
npc.worldObj.spawnEntityInWorld(new EntityXPOrb(npc.worldObj, npc.posX, npc.posY, npc.posZ, var2));
}
}
}
public void dropItems(Entity entity, ArrayList<ItemStack> itemList) {
ArrayList<EntityItem> list = new ArrayList<EntityItem>();
for (ItemStack item : itemList) {
if (item == null)
continue;
EntityItem e = getEntityItem(item.copy());
if (e != null)
list.add(e);
}
for (EntityItem item : list) {
if (lootMode == 1 && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
item.delayBeforeCanPickup = 2;
npc.worldObj.spawnEntityInWorld(item);
ItemStack stack = item.getEntityItem();
int i = stack.stackSize;
if (player.inventory.addItemStackToInventory(stack)) {
npc.worldObj.playSoundAtEntity(item,
"random.pop",
0.2F,
((npc.getRNG().nextFloat() - npc.getRNG().nextFloat()) * 0.7F + 1.0F) * 2.0F);
player.onItemPickup(item, i);
if (stack.stackSize <= 0) {
item.setDead();
}
}
} else
npc.worldObj.spawnEntityInWorld(item);
}
}
public EntityItem getEntityItem(ItemStack itemstack) {
if (itemstack == null) {
return null;
}
EntityItem entityitem = new EntityItem(npc.worldObj, npc.posX,
(npc.posY - 0.30000001192092896D) + (double) npc.getEyeHeight(), npc.posZ,
itemstack);
entityitem.delayBeforeCanPickup = 40;
float f2 = npc.getRNG().nextFloat() * 0.5F;
float f4 = npc.getRNG().nextFloat() * 3.141593F * 2.0F;
entityitem.motionX = -MathHelper.sin(f4) * f2;
entityitem.motionZ = MathHelper.cos(f4) * f2;
entityitem.motionY = 0.20000000298023224D;
return entityitem;
}
public ItemStack armorItemInSlot(int i) {
return getArmor().get(i);
}
@Override
public int getSizeInventory() {
return 15;
}
@Override
public ItemStack getStackInSlot(int i) {
if (i < 4)
return armorItemInSlot(i);
else if (i < 7)
return getWeapons().get(i - 4);
else
return items.get(i - 7);
}
@Override
public ItemStack decrStackSize(int par1, int par2) {
int i = 0;
HashMap<Integer, ItemStack> var3;
if (par1 >= 7) {
var3 = items;
par1 -= 7;
} else if (par1 >= 4) {
var3 = getWeapons();
par1 -= 4;
i = 1;
}
else{
var3 = getArmor();
} else {
var3 = getArmor();
i = 2;
}
ItemStack var4 = null;
if (var3.get(par1) != null)
{
if (var3.get(par1) != null) {
if (var3.get(par1).stackSize <= par2)
{
if (var3.get(par1).stackSize <= par2) {
var4 = var3.get(par1);
var3.put(par1,null);
}
else
{
var3.put(par1, null);
} else {
var4 = var3.get(par1).splitStack(par2);
if (var3.get(par1).stackSize == 0)
{
var3.put(par1,null);
if (var3.get(par1).stackSize == 0) {
var3.put(par1, null);
}
}
}
if(i == 1)
setWeapons(var3);
if(i == 2)
setArmor(var3);
if (i == 1)
setWeapons(var3);
if (i == 2)
setArmor(var3);
return var4;
}
@Override
public ItemStack getStackInSlotOnClosing(int par1) {
int i = 0;
HashMap<Integer,ItemStack> var2;;
}
if (par1 >= 7)
{
var2 = items;
@Override
public ItemStack getStackInSlotOnClosing(int par1) {
int i = 0;
HashMap<Integer, ItemStack> var2;
;
if (par1 >= 7) {
var2 = items;
par1 -= 7;
}
else if (par1 >= 4)
{
var2 = getWeapons();
} else if (par1 >= 4) {
var2 = getWeapons();
par1 -= 4;
i = 1;
}
else{
var2 = getArmor();
} else {
var2 = getArmor();
i = 2;
}
if (var2.get(par1) != null)
{
if (var2.get(par1) != null) {
ItemStack var3 = var2.get(par1);
var2.put(par1,null);
if(i == 1)
setWeapons(var2);
if(i == 2)
setArmor(var2);
var2.put(par1, null);
if (i == 1)
setWeapons(var2);
if (i == 2)
setArmor(var2);
return var3;
}
else
{
} else {
return null;
}
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
int i = 0;
HashMap<Integer,ItemStack> var3;
}
if (par1 >= 7)
{
var3 = items;
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {
int i = 0;
HashMap<Integer, ItemStack> var3;
if (par1 >= 7) {
var3 = items;
par1 -= 7;
}
else if (par1 >= 4)
{
var3 = getWeapons();
} else if (par1 >= 4) {
var3 = getWeapons();
par1 -= 4;
i = 1;
}
else{
var3 = getArmor();
} else {
var3 = getArmor();
i = 2;
}
var3.put(par1,par2ItemStack);
if(i == 1)
setWeapons(var3);
if(i == 2)
setArmor(var3);
var3.put(par1, par2ItemStack);
if (i == 1)
setWeapons(var3);
if (i == 2)
setArmor(var3);
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
return true;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
}
@Override
public String getInventoryName() {
return "NPC Inventory";
}
@Override
public boolean hasCustomInventoryName() {
return true;
}
@Override
public void markDirty() {
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
return true;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
}
@Override
public String getInventoryName() {
return "NPC Inventory";
}
@Override
public boolean hasCustomInventoryName() {
return true;
}
@Override
public void markDirty() {
}
@Override
public void openInventory() {
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public void closeInventory() {
}
}
}
+103 -105
View File
@@ -2,134 +2,131 @@ package noppes.npcs;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.nbt.*;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.constants.EnumParticleType;
import noppes.npcs.constants.EnumPotionType;
import noppes.npcs.controllers.data.MagicData;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.util.ValueUtil;
import java.util.HashSet;
import java.util.UUID;
public class DataStats {
private float attackStrength = 5;
public int attackSpeed = 20, swingWarmUp = 0, attackRange = 2, knockback = 0;
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
public int aggroRange = 16;
private float attackStrength = 5;
public int attackSpeed = 20, swingWarmUp = 0, attackRange = 2, knockback = 0;
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
public int aggroRange = 16;
public EnumPotionType potionType = EnumPotionType.None;
public int potionDuration = 5; //20 = 1 second
public int potionAmp = 0;
public EnumPotionType potionType = EnumPotionType.None;
public int potionDuration = 5; //20 = 1 second
public int potionAmp = 0;
public double maxHealth = 20;
public int respawnTime = 20;
public int spawnCycle = 0;
public boolean hideKilledBody = false;
public boolean canDespawn = false;
public boolean playerSetCanDespawn = false;
public double maxHealth = 20;
public int respawnTime = 20;
public int spawnCycle = 0;
public boolean hideKilledBody = false;
public boolean canDespawn = false;
public boolean playerSetCanDespawn = false;
public Resistances resistances = new Resistances();
public Resistances resistances = new Resistances();
public MagicData magicData = new MagicData();
public boolean ignoreCobweb = false;
public boolean immuneToFire = false;
public boolean potionImmune = false;
public int drowningType = 1; // 0 - Never, 1 - Water, 2 - Air
public boolean burnInSun = false;
public boolean noFallDamage = false;
public float healthRegen = 1;
public float combatRegen = 0;
public boolean ignoreCobweb = false;
public boolean immuneToFire = false;
public boolean potionImmune = false;
public int drowningType = 1; // 0 - Never, 1 - Water, 2 - Air
public boolean burnInSun = false;
public boolean noFallDamage = false;
public float healthRegen = 1;
public float combatRegen = 0;
public float pDamage = 4;
public int pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
public float pDamage = 4;
public int pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false;
public boolean pRender3D = false, pSpin = false, pStick = false;
public EnumPotionType pEffect = EnumPotionType.None;
public EnumParticleType pTrail = EnumParticleType.None;
public int pEffAmp = 0;
public String fireSound = "random.bow";
public boolean aimWhileShooting = false;
public boolean projectilesKeepTerrain = false;
public boolean aimWhileShooting = false;
public boolean projectilesKeepTerrain = false;
public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED;
public EnumCreatureAttribute creatureType = EnumCreatureAttribute.UNDEFINED;
private EntityNPCInterface npc;
public boolean attackInvisible = false;
private EntityNPCInterface npc;
public boolean attackInvisible = false;
// 0 - Yes, 1 - No, 2 - Only NPCs, 3 - Only Players, 4 - NPCs and Players
public int collidesWith = 1;
public DataStats(EntityNPCInterface npc){
this.npc = npc;
}
public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
compound.setTag("Resistances", resistances.writeToNBT());
compound.setDouble("MaxHealth", maxHealth);
compound.setInteger("AggroRange", aggroRange);
compound.setBoolean("HideBodyWhenKilled", hideKilledBody);
compound.setInteger("RespawnTime", respawnTime);
compound.setInteger("SpawnCycle", spawnCycle);
compound.setInteger("CreatureType", creatureType.ordinal());
compound.setBoolean("IgnoreCobweb", ignoreCobweb);
compound.setFloat("HealthRegen", healthRegen);
compound.setFloat("CombatRegen", combatRegen);
public DataStats(EntityNPCInterface npc) {
this.npc = npc;
}
compound.setFloat("AttackStrenght", attackStrength);
compound.setInteger("AttackRange", attackRange);
compound.setInteger("AttackSpeed", attackSpeed);
compound.setInteger("SwingWarmup", swingWarmUp);
compound.setInteger("KnockBack", knockback);
compound.setInteger("PotionEffect", potionType.ordinal());
compound.setInteger("PotionDuration", potionDuration);
compound.setInteger("PotionAmp", potionAmp);
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setTag("Resistances", resistances.writeToNBT());
compound.setDouble("MaxHealth", maxHealth);
compound.setInteger("AggroRange", aggroRange);
compound.setBoolean("HideBodyWhenKilled", hideKilledBody);
compound.setInteger("RespawnTime", respawnTime);
compound.setInteger("SpawnCycle", spawnCycle);
compound.setInteger("CreatureType", creatureType.ordinal());
compound.setBoolean("IgnoreCobweb", ignoreCobweb);
compound.setFloat("HealthRegen", healthRegen);
compound.setFloat("CombatRegen", combatRegen);
compound.setInteger("MaxFiringRange", rangedRange);
compound.setInteger("FireRate", fireRate);
compound.setInteger("minDelay", minDelay);
compound.setInteger("maxDelay", maxDelay);
compound.setInteger("BurstCount", burstCount);
compound.setInteger("ShotCount", shotCount);
compound.setInteger("Accuracy", accuracy);
compound.setFloat("AttackStrenght", attackStrength);
compound.setInteger("AttackRange", attackRange);
compound.setInteger("AttackSpeed", attackSpeed);
compound.setInteger("SwingWarmup", swingWarmUp);
compound.setInteger("KnockBack", knockback);
compound.setInteger("PotionEffect", potionType.ordinal());
compound.setInteger("PotionDuration", potionDuration);
compound.setInteger("PotionAmp", potionAmp);
compound.setFloat("pDamage", pDamage);
compound.setInteger("pImpact", pImpact);
compound.setInteger("pSize", pSize);
compound.setInteger("pSpeed", pSpeed);
compound.setInteger("pArea", pArea);
compound.setInteger("pDur", pDur);
compound.setBoolean("pPhysics", pPhysics);
compound.setBoolean("pXlr8", pXlr8);
compound.setBoolean("pGlows", pGlows);
compound.setBoolean("pExplode", pExplode);
compound.setBoolean("pRender3D", pRender3D);
compound.setBoolean("pSpin", pSpin);
compound.setBoolean("pStick", pStick);
compound.setInteger("pEffect", pEffect.ordinal());
compound.setInteger("pTrail", pTrail.ordinal());
compound.setInteger("pEffAmp", pEffAmp);
compound.setString("FiringSound", fireSound);
compound.setBoolean("AimWhileShooting", aimWhileShooting);
compound.setBoolean("ProjectilesKeepTerrain", projectilesKeepTerrain);
compound.setInteger("MaxFiringRange", rangedRange);
compound.setInteger("FireRate", fireRate);
compound.setInteger("minDelay", minDelay);
compound.setInteger("maxDelay", maxDelay);
compound.setInteger("BurstCount", burstCount);
compound.setInteger("ShotCount", shotCount);
compound.setInteger("Accuracy", accuracy);
compound.setBoolean("ImmuneToFire", immuneToFire);
compound.setBoolean("PotionImmune", potionImmune);
compound.setInteger("DrowningType", drowningType);
compound.setBoolean("BurnInSun", burnInSun);
compound.setBoolean("NoFallDamage", noFallDamage);
compound.setBoolean("AttackInvisible", attackInvisible);
compound.setBoolean("CanDespawn", canDespawn);
compound.setBoolean("PlayerSetCanDespawn", playerSetCanDespawn);
compound.setInteger("CollidesWith",collidesWith);
compound.setFloat("pDamage", pDamage);
compound.setInteger("pImpact", pImpact);
compound.setInteger("pSize", pSize);
compound.setInteger("pSpeed", pSpeed);
compound.setInteger("pArea", pArea);
compound.setInteger("pDur", pDur);
compound.setBoolean("pPhysics", pPhysics);
compound.setBoolean("pXlr8", pXlr8);
compound.setBoolean("pGlows", pGlows);
compound.setBoolean("pExplode", pExplode);
compound.setBoolean("pRender3D", pRender3D);
compound.setBoolean("pSpin", pSpin);
compound.setBoolean("pStick", pStick);
compound.setInteger("pEffect", pEffect.ordinal());
compound.setInteger("pTrail", pTrail.ordinal());
compound.setInteger("pEffAmp", pEffAmp);
compound.setString("FiringSound", fireSound);
compound.setBoolean("AimWhileShooting", aimWhileShooting);
compound.setBoolean("ProjectilesKeepTerrain", projectilesKeepTerrain);
compound.setBoolean("ImmuneToFire", immuneToFire);
compound.setBoolean("PotionImmune", potionImmune);
compound.setInteger("DrowningType", drowningType);
compound.setBoolean("BurnInSun", burnInSun);
compound.setBoolean("NoFallDamage", noFallDamage);
compound.setBoolean("AttackInvisible", attackInvisible);
compound.setBoolean("CanDespawn", canDespawn);
compound.setBoolean("PlayerSetCanDespawn", playerSetCanDespawn);
compound.setInteger("CollidesWith", collidesWith);
magicData.writeToNBT(compound);
return compound;
}
return compound;
}
public void readToNBT(NBTTagCompound compound) {
public void readToNBT(NBTTagCompound compound) {
resistances.readToNBT(compound.getCompoundTag("Resistances"));
setMaxHealth(compound.getDouble("MaxHealth"));
hideKilledBody = compound.getBoolean("HideBodyWhenKilled");
@@ -198,16 +195,17 @@ public class DataStats {
}
public float getAttackStrength(){
return attackStrength;
}
public void setAttackStrength(double strength){
attackStrength = (float)(Math.floor(strength));
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
}
public float getAttackStrength() {
return attackStrength;
}
public void setMaxHealth(double maxHealth) {
this.maxHealth = Math.floor(maxHealth);
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
}
public void setAttackStrength(double strength) {
attackStrength = (float) (Math.floor(strength));
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
}
public void setMaxHealth(double maxHealth) {
this.maxHealth = Math.floor(maxHealth);
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
}
}
+83 -82
View File
@@ -17,7 +17,6 @@ import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.api.IWorld;
import noppes.npcs.api.entity.*;
import noppes.npcs.api.event.IAnimationEvent;
import noppes.npcs.api.event.IPlayerEvent;
import noppes.npcs.api.gui.ICustomGui;
import noppes.npcs.api.gui.IItemSlot;
import noppes.npcs.api.handler.data.IAnimation;
@@ -64,7 +63,7 @@ public class EventHooks {
public static boolean onScriptItemTossed(IItemCustomizable item, EntityPlayer player, EntityItem entity) {
INpcScriptHandler handler = (INpcScriptHandler) item.getScriptHandler();
ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(item, (IPlayer)NpcAPI.Instance().getIEntity(player), NpcAPI.Instance().getIEntity(entity));
ItemEvent.TossedEvent event = new ItemEvent.TossedEvent(item, (IPlayer) NpcAPI.Instance().getIEntity(player), NpcAPI.Instance().getIEntity(entity));
if (handler != null) {
handler.callScript(EnumScriptType.TOSSED, event);
}
@@ -73,7 +72,7 @@ public class EventHooks {
public static boolean onScriptItemPickedUp(IItemCustomizable item, EntityPlayer player) {
INpcScriptHandler handler = (INpcScriptHandler) item.getScriptHandler();
ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(item, (IPlayer)NpcAPI.Instance().getIEntity(player));
ItemEvent.PickedUpEvent event = new ItemEvent.PickedUpEvent(item, (IPlayer) NpcAPI.Instance().getIEntity(player));
if (handler != null) {
handler.callScript(EnumScriptType.PICKEDUP, event);
}
@@ -186,7 +185,7 @@ public class EventHooks {
}
public static void onNPCInit(EntityNPCInterface npc) {
if(npc == null || npc.wrappedNPC == null)
if (npc == null || npc.wrappedNPC == null)
return;
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
@@ -197,7 +196,7 @@ public class EventHooks {
}
public static void onNPCUpdate(EntityNPCInterface npc) {
if(npc == null || npc.wrappedNPC == null)
if (npc == null || npc.wrappedNPC == null)
return;
noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC);
@@ -207,7 +206,7 @@ public class EventHooks {
}
public static boolean onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
if(npc == null || npc.wrappedNPC == null)
if (npc == null || npc.wrappedNPC == null)
return false;
NpcEvent.DialogEvent event = new NpcEvent.DialogEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
@@ -218,7 +217,7 @@ public class EventHooks {
}
public static void onNPCDialogClosed(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
if(npc == null || npc.wrappedNPC == null)
if (npc == null || npc.wrappedNPC == null)
return;
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
@@ -229,37 +228,37 @@ public class EventHooks {
}
public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) {
if(npc == null || npc.wrappedNPC == null)
if (npc == null || npc.wrappedNPC == null)
return false;
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC,player);
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC, player);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INTERACT, event);
boolean result = npc.script.callScript(EnumScriptType.INTERACT, event, "player", player);
NpcAPI.EVENT_BUS.post(event);
return result;
}
public static boolean onNPCMeleeAttack(EntityNPCInterface npc, NpcEvent.MeleeAttackEvent event){
if(npc == null || npc.wrappedNPC == null)
public static boolean onNPCMeleeAttack(EntityNPCInterface npc, NpcEvent.MeleeAttackEvent event) {
if (npc == null || npc.wrappedNPC == null)
return false;
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
npc.script.callScript(EnumScriptType.ATTACK_MELEE, event, "target", event.target);
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
npc.script.callScript(EnumScriptType.ATTACK_MELEE, event, "target", event.target);
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCMeleeSwing(EntityNPCInterface npc, NpcEvent.SwingEvent event){
if(npc == null || npc.wrappedNPC == null)
public static boolean onNPCMeleeSwing(EntityNPCInterface npc, NpcEvent.SwingEvent event) {
if (npc == null || npc.wrappedNPC == null)
return false;
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_SWING, event);
npc.script.callScript(EnumScriptType.ATTACK_SWING, event);
npc.script.callScript(EnumScriptType.ATTACK_SWING, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCRangedAttack(EntityNPCInterface npc, NpcEvent.RangedLaunchedEvent event){
if(npc == null || npc.wrappedNPC == null)
public static boolean onNPCRangedAttack(EntityNPCInterface npc, NpcEvent.RangedLaunchedEvent event) {
if (npc == null || npc.wrappedNPC == null)
return false;
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
@@ -268,18 +267,18 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity){
if(npc == null || npc.wrappedNPC == null)
public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity) {
if (npc == null || npc.wrappedNPC == null)
return;
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC,entity);
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC, entity);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLS, event);
npc.script.callScript(EnumScriptType.KILLS, event, "target", entity);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCTarget(EntityNPCInterface npc, NpcEvent.TargetEvent event){
if(npc == null || npc.wrappedNPC == null)
public static boolean onNPCTarget(EntityNPCInterface npc, NpcEvent.TargetEvent event) {
if (npc == null || npc.wrappedNPC == null)
return false;
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET, event);
@@ -288,7 +287,7 @@ public class EventHooks {
}
public static boolean onNPCTargetLost(EntityNPCInterface npc, EntityLivingBase prevtarget, EntityLivingBase newTarget) {
if(npc.script.isClient())
if (npc.script.isClient())
return false;
NpcEvent.TargetLostEvent event = new NpcEvent.TargetLostEvent(npc.wrappedNPC, prevtarget, newTarget);
@@ -297,18 +296,18 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCCollide(EntityNPCInterface npc, Entity entity){
if(npc == null || npc.wrappedNPC == null)
public static void onNPCCollide(EntityNPCInterface npc, Entity entity) {
if (npc == null || npc.wrappedNPC == null)
return;
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC,entity);
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC, entity);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.COLLIDE, event);
npc.script.callScript(EnumScriptType.COLLIDE, event, "entity", entity);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCDamaged(EntityNPCInterface npc, NpcEvent.DamagedEvent event){
if(npc == null || npc.wrappedNPC == null)
public static boolean onNPCDamaged(EntityNPCInterface npc, NpcEvent.DamagedEvent event) {
if (npc == null || npc.wrappedNPC == null)
return false;
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DAMAGED, event);
@@ -316,8 +315,8 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCKilled(EntityNPCInterface npc, NpcEvent.DiedEvent event){
if(npc == null || npc.wrappedNPC == null)
public static boolean onNPCKilled(EntityNPCInterface npc, NpcEvent.DiedEvent event) {
if (npc == null || npc.wrappedNPC == null)
return false;
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLED, event);
@@ -326,7 +325,7 @@ public class EventHooks {
}
public static void onNPCTimer(EntityNPCInterface npc, int id) {
if(npc == null || npc.wrappedNPC == null)
if (npc == null || npc.wrappedNPC == null)
return;
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
@@ -338,15 +337,15 @@ public class EventHooks {
public static void onProjectileTick(EntityProjectile projectile) {
ProjectileEvent.UpdateEvent event = new ProjectileEvent.UpdateEvent((IProjectile) NpcAPI.Instance().getIEntity(projectile));
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.PROJECTILE_TICK, event);
for(ScriptContainer script : projectile.scripts) {
if(script.isValid()) {
for (ScriptContainer script : projectile.scripts) {
if (script.isValid()) {
script.run(EnumScriptType.PROJECTILE_TICK, event);
}
}
EntityLivingBase thrower = projectile.getThrower();
if(thrower != null){
if(thrower instanceof EntityNPCInterface){
if (thrower != null) {
if (thrower instanceof EntityNPCInterface) {
((EntityNPCInterface) thrower).script.callScript(EnumScriptType.PROJECTILE_TICK, event);
}
}
@@ -356,15 +355,15 @@ public class EventHooks {
public static void onProjectileImpact(EntityProjectile projectile, ProjectileEvent.ImpactEvent event) {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.PROJECTILE_IMPACT, event);
for(ScriptContainer script : projectile.scripts) {
if(script.isValid()) {
for (ScriptContainer script : projectile.scripts) {
if (script.isValid()) {
script.run(EnumScriptType.PROJECTILE_IMPACT, event);
}
}
EntityLivingBase thrower = projectile.getThrower();
if(thrower != null){
if(thrower instanceof EntityNPCInterface){
if (thrower != null) {
if (thrower instanceof EntityNPCInterface) {
((EntityNPCInterface) thrower).script.callScript(EnumScriptType.PROJECTILE_IMPACT, event);
}
}
@@ -407,25 +406,25 @@ public class EventHooks {
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStartUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
public static boolean onStartUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item) {
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration);
handler.callScript(EnumScriptType.START_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
public static boolean onUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item) {
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration);
handler.callScript(EnumScriptType.USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onStopUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
public static boolean onStopUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item) {
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration);
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onFinishUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item){
public static void onFinishUsingItem(PlayerDataScript handler, IPlayer player, int duration, ItemStack item) {
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration);
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
NpcAPI.EVENT_BUS.post(event);
@@ -433,7 +432,9 @@ public class EventHooks {
public static boolean onPlayerDropItems(PlayerDataScript handler, IPlayer player, ArrayList<EntityItem> entityItems) {
IItemStack[] items = new IItemStack[entityItems.size()];
for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); }
for (int i = 0; i < entityItems.size(); i++) {
items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem());
}
DropEvent event = new DropEvent(player, items);
handler.callScript(EnumScriptType.DROP, event);
@@ -517,7 +518,7 @@ public class EventHooks {
}
public static boolean onPlayerFall(PlayerDataScript handler, IPlayer player, float distance) {
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance);
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player, distance);
handler.callScript(EnumScriptType.FALL, event);
return NpcAPI.EVENT_BUS.post(event);
}
@@ -597,21 +598,21 @@ public class EventHooks {
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, int[] heldKeys) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, heldKeys);
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((IPlayer) NpcAPI.Instance().getIEntity(player), button, mouseWheel, buttonDown, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, heldKeys);
handler.callScript(EnumScriptType.MOUSE_CLICKED, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown, int[] heldKeys) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
KeyPressedEvent event = new KeyPressedEvent((IPlayer)NpcAPI.Instance().getIEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys);
KeyPressedEvent event = new KeyPressedEvent((IPlayer) NpcAPI.Instance().getIEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown, heldKeys);
handler.callScript(EnumScriptType.KEY_PRESSED, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerTimer(PlayerData data, int id) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((IPlayer)NpcAPI.Instance().getIEntity(data.player), id);
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((IPlayer) NpcAPI.Instance().getIEntity(data.player), id);
handler.callScript(EnumScriptType.TIMER, event);
NpcAPI.EVENT_BUS.post(event);
}
@@ -627,8 +628,8 @@ public class EventHooks {
}
public static void onForgeWorldEvent(WorldEvent event) {
if(ScriptController.Instance.forgeScripts.isEnabled()) {
IWorld e = NpcAPI.Instance().getIWorld((WorldServer)event.world);
if (ScriptController.Instance.forgeScripts.isEnabled()) {
IWorld e = NpcAPI.Instance().getIWorld((WorldServer) event.world);
onForgeEvent(new noppes.npcs.scripted.event.ForgeEvent.WorldEvent(event, e), event);
}
}
@@ -641,17 +642,17 @@ public class EventHooks {
public static void onForgeEvent(ForgeEvent ev, Event event) {
ForgeDataScript handler = ScriptController.Instance.forgeScripts;
if(handler.isEnabled()) {
if (handler.isEnabled()) {
String eventName = event.getClass().getName();
int i = eventName.lastIndexOf(".");
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
if(event.isCancelable()) {
if (event.isCancelable()) {
ev.setCanceled(event.isCanceled());
}
handler.callScript(eventName, event);
NpcAPI.EVENT_BUS.post(ev);
if(event.isCancelable()) {
if (event.isCancelable()) {
event.setCanceled(ev.isCanceled());
}
@@ -702,52 +703,52 @@ public class EventHooks {
CustomGuiController.onClose(event);
}
public static void onQuestFinished(EntityPlayer player, Quest quest){
public static void onQuestFinished(EntityPlayer player, Quest quest) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
QuestEvent.QuestCompletedEvent event = new QuestEvent.QuestCompletedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest);
handler.callScript(EnumScriptType.QUEST_COMPLETED, event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onQuestStarted(EntityPlayer player, Quest quest){
public static boolean onQuestStarted(EntityPlayer player, Quest quest) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
QuestEvent.QuestStartEvent event = new QuestEvent.QuestStartEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayerMP) player), quest);
handler.callScript(EnumScriptType.QUEST_START, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event){
public static void onQuestTurnedIn(QuestEvent.QuestTurnedInEvent event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.QUEST_TURNIN, event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onFactionPoints(FactionEvent.FactionPoints event){
public static boolean onFactionPoints(FactionEvent.FactionPoints event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.FACTION_POINTS, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onDialogOpen(DialogEvent.DialogOpen event){
public static boolean onDialogOpen(DialogEvent.DialogOpen event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.DIALOG_OPEN, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onDialogOption(DialogEvent.DialogOption event){
public static boolean onDialogOption(DialogEvent.DialogOption event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.DIALOG_OPTION, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onDialogClosed(DialogEvent.DialogClosed event){
public static void onDialogClosed(DialogEvent.DialogClosed event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.DIALOG_CLOSE, event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onScriptBlockInteract(IScriptBlockHandler handler, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if(handler.isClient())
if (handler.isClient())
return false;
BlockEvent.InteractEvent event = new BlockEvent.InteractEvent(handler.getBlock(), player, side, hitX, hitY, hitZ);
handler.callScript(EnumScriptType.INTERACT, event);
@@ -755,7 +756,7 @@ public class EventHooks {
}
public static void onScriptBlockCollide(IScriptBlockHandler handler, Entity entityIn) {
if(handler.isClient())
if (handler.isClient())
return;
BlockEvent.CollidedEvent event = new BlockEvent.CollidedEvent(handler.getBlock(), entityIn);
handler.callScript(EnumScriptType.COLLIDE, event);
@@ -763,7 +764,7 @@ public class EventHooks {
}
public static void onScriptBlockRainFill(IScriptBlockHandler handler) {
if(handler.isClient())
if (handler.isClient())
return;
BlockEvent.RainFillEvent event = new BlockEvent.RainFillEvent(handler.getBlock());
handler.callScript(EnumScriptType.RAIN_FILLED, event);
@@ -771,17 +772,17 @@ public class EventHooks {
}
public static float onScriptBlockFallenUpon(IScriptBlockHandler handler, Entity entity, float distance) {
if(handler.isClient())
if (handler.isClient())
return distance;
BlockEvent.EntityFallenUponEvent event = new BlockEvent.EntityFallenUponEvent(handler.getBlock(), entity, distance);
handler.callScript(EnumScriptType.FALLEN_UPON, event);
if(NpcAPI.EVENT_BUS.post(event))
if (NpcAPI.EVENT_BUS.post(event))
return 0;
return event.distanceFallen;
}
public static void onScriptBlockClicked(IScriptBlockHandler handler, EntityPlayer player) {
if(handler.isClient())
if (handler.isClient())
return;
BlockEvent.ClickedEvent event = new BlockEvent.ClickedEvent(handler.getBlock(), player);
handler.callScript(EnumScriptType.CLICKED, event);
@@ -789,7 +790,7 @@ public class EventHooks {
}
public static void onScriptBlockBreak(IScriptBlockHandler handler) {
if(handler.isClient())
if (handler.isClient())
return;
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(handler.getBlock());
handler.callScript(EnumScriptType.BROKEN, event);
@@ -797,7 +798,7 @@ public class EventHooks {
}
public static boolean onScriptBlockHarvest(IScriptBlockHandler handler, EntityPlayer player) {
if(handler.isClient())
if (handler.isClient())
return false;
BlockEvent.HarvestedEvent event = new BlockEvent.HarvestedEvent(handler.getBlock(), player);
handler.callScript(EnumScriptType.HARVESTED, event);
@@ -805,7 +806,7 @@ public class EventHooks {
}
public static boolean onScriptBlockExploded(IScriptBlockHandler handler) {
if(handler.isClient())
if (handler.isClient())
return false;
BlockEvent.ExplodedEvent event = new BlockEvent.ExplodedEvent(handler.getBlock());
handler.callScript(EnumScriptType.EXPLODED, event);
@@ -813,15 +814,15 @@ public class EventHooks {
}
public static void onScriptBlockNeighborChanged(IScriptBlockHandler handler, int x, int y, int z) {
if(handler.isClient())
if (handler.isClient())
return;
BlockEvent.NeighborChangedEvent event = new BlockEvent.NeighborChangedEvent(handler.getBlock(), NpcAPI.Instance().getIPos(x,y,z));
BlockEvent.NeighborChangedEvent event = new BlockEvent.NeighborChangedEvent(handler.getBlock(), NpcAPI.Instance().getIPos(x, y, z));
handler.callScript(EnumScriptType.NEIGHBOR_CHANGED, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onScriptBlockRedstonePower(IScriptBlockHandler handler, int prevPower, int power) {
if(handler.isClient())
if (handler.isClient())
return;
BlockEvent.RedstoneEvent event = new BlockEvent.RedstoneEvent(handler.getBlock(), prevPower, power);
handler.callScript(EnumScriptType.REDSTONE, event);
@@ -829,7 +830,7 @@ public class EventHooks {
}
public static void onScriptBlockInit(IScriptBlockHandler handler) {
if(handler.isClient())
if (handler.isClient())
return;
BlockEvent.InitEvent event = new BlockEvent.InitEvent(handler.getBlock());
handler.callScript(EnumScriptType.INIT, event);
@@ -837,7 +838,7 @@ public class EventHooks {
}
public static void onScriptBlockUpdate(IScriptBlockHandler handler) {
if(handler.isClient())
if (handler.isClient())
return;
BlockEvent.UpdateEvent event = new BlockEvent.UpdateEvent(handler.getBlock());
handler.callScript(EnumScriptType.TICK, event);
@@ -850,44 +851,44 @@ public class EventHooks {
NpcAPI.EVENT_BUS.post(event);
}
public static void onPartyFinished(Party party, Quest quest){
public static void onPartyFinished(Party party, Quest quest) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
PartyEvent.PartyQuestCompletedEvent event = new PartyEvent.PartyQuestCompletedEvent(party, quest);
handler.callScript(EnumScriptType.PARTY_QUEST_COMPLETED, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPartyQuestSet(PartyEvent.PartyQuestSetEvent event){
public static void onPartyQuestSet(PartyEvent.PartyQuestSetEvent event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.PARTY_QUEST_SET, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPartyTurnIn(PartyEvent.PartyQuestTurnedInEvent event){
public static void onPartyTurnIn(PartyEvent.PartyQuestTurnedInEvent event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.PARTY_QUEST_TURNED_IN, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPartyInvite(PartyEvent.PartyInviteEvent event){
public static void onPartyInvite(PartyEvent.PartyInviteEvent event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.PARTY_INVITE, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPartyKick(PartyEvent.PartyKickEvent event){
public static void onPartyKick(PartyEvent.PartyKickEvent event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.PARTY_KICK, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPartyLeave(PartyEvent.PartyLeaveEvent event){
public static void onPartyLeave(PartyEvent.PartyLeaveEvent event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.PARTY_LEAVE, event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onPartyDisband(PartyEvent.PartyDisbandEvent event){
public static void onPartyDisband(PartyEvent.PartyDisbandEvent event) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
handler.callScript(EnumScriptType.PARTY_DISBAND, event);
NpcAPI.EVENT_BUS.post(event);
+3 -2
View File
@@ -4,7 +4,8 @@ import noppes.npcs.entity.EntityNPCInterface;
public interface IChatMessages {
public void addMessage(String message, EntityNPCInterface npc);
public void renderMessages(double par3, double par5, double par7, float scale, boolean inRange);
public void addMessage(String message, EntityNPCInterface npc);
public void renderMessages(double par3, double par5, double par7, float scale, boolean inRange);
}
+5 -3
View File
@@ -3,7 +3,9 @@ package noppes.npcs;
import net.minecraft.nbt.NBTTagCompound;
public interface ICompatibilty {
public int getVersion();
public void setVersion(int version);
public NBTTagCompound writeToNBT(NBTTagCompound compound);
public int getVersion();
public void setVersion(int version);
public NBTTagCompound writeToNBT(NBTTagCompound compound);
}
+193 -194
View File
@@ -12,215 +12,214 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.*;
public class LogWriter {
private final static String name = "CustomNPCs";
private final static Logger logger = Logger.getLogger(name);
private final static String name = "CustomNPCs";
private final static Logger logger = Logger.getLogger(name);
private final static WeakHashMap<UUID, NPCStamp> InitCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> TickCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> InteractCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> DialogCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> DamagedCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> KilledCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> AttackCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> TargetCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> CollideCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> KillsCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> DialogCloseCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> TimerCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> InitCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> TickCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> InteractCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> DialogCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> DamagedCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> KilledCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> AttackCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> TargetCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> CollideCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> KillsCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> DialogCloseCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static WeakHashMap<UUID, NPCStamp> TimerCacheMap = new WeakHashMap<UUID, NPCStamp>();
private final static SimpleDateFormat dateformat = new SimpleDateFormat("HH:mm:ss");
private static Handler handler;
static {
try {
File dir = new File("logs");
if(!dir.exists())
dir.mkdir();
File file = new File(dir, name + "-latest.log");
File lock = new File(dir, name + "-latest.log.lck");
File file1 = new File(dir, name + "-1.log");
File file2 = new File(dir, name + "-2.log");
File file3 = new File(dir, name + "-3.log");
private final static SimpleDateFormat dateformat = new SimpleDateFormat("HH:mm:ss");
private static Handler handler;
if(lock.exists())
lock.delete();
static {
try {
File dir = new File("logs");
if (!dir.exists())
dir.mkdir();
File file = new File(dir, name + "-latest.log");
File lock = new File(dir, name + "-latest.log.lck");
File file1 = new File(dir, name + "-1.log");
File file2 = new File(dir, name + "-2.log");
File file3 = new File(dir, name + "-3.log");
if(file3.exists())
file3.delete();
if(file2.exists())
file2.renameTo(file3);
if(file1.exists())
file1.renameTo(file2);
if(file.exists())
file.renameTo(file1);
if (lock.exists())
lock.delete();
handler = new StreamHandler(new FileOutputStream(file), new Formatter() {
@Override
public String format(LogRecord record) {
String line = "";
if (record.getLevel() != NPCLogLevel.CNPCLog){
StackTraceElement element = Thread.currentThread().getStackTrace()[8];
line = "[" + element.getClassName() + ":" + element.getLineNumber() + "] ";
}
String time = "[" + dateformat.format(new Date(record.getMillis())) + "][" + record.getLevel() + "]" + line;
if(record.getThrown() != null){
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
record.getThrown().printStackTrace(pw);
return time + sw.toString();
}
return time + record.getMessage() + System.getProperty("line.separator");
}
});
handler.setLevel(Level.ALL);
logger.addHandler(handler);
logger.setUseParentHandlers(false);
Handler consoleHandler = new ConsoleHandler();
consoleHandler.setFormatter(handler.getFormatter());
consoleHandler.setLevel(Level.FINEST);
logger.addHandler(consoleHandler);
logger.setLevel(Level.ALL);
info(new Date().toString());
} catch (SecurityException e) {
if (file3.exists())
file3.delete();
if (file2.exists())
file2.renameTo(file3);
if (file1.exists())
file1.renameTo(file2);
if (file.exists())
file.renameTo(file1);
e.printStackTrace();
} catch (IOException e) {
handler = new StreamHandler(new FileOutputStream(file), new Formatter() {
@Override
public String format(LogRecord record) {
String line = "";
if (record.getLevel() != NPCLogLevel.CNPCLog) {
StackTraceElement element = Thread.currentThread().getStackTrace()[8];
line = "[" + element.getClassName() + ":" + element.getLineNumber() + "] ";
}
String time = "[" + dateformat.format(new Date(record.getMillis())) + "][" + record.getLevel() + "]" + line;
if (record.getThrown() != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
record.getThrown().printStackTrace(pw);
return time + sw.toString();
}
return time + record.getMessage() + System.getProperty("line.separator");
}
});
handler.setLevel(Level.ALL);
logger.addHandler(handler);
logger.setUseParentHandlers(false);
Handler consoleHandler = new ConsoleHandler();
consoleHandler.setFormatter(handler.getFormatter());
consoleHandler.setLevel(Level.FINEST);
logger.addHandler(consoleHandler);
logger.setLevel(Level.ALL);
info(new Date().toString());
} catch (SecurityException e) {
e.printStackTrace();
}
}
e.printStackTrace();
} catch (IOException e) {
public static void postScriptLog(UUID npcUUID, EnumScriptType type, String message) {
switch (type){
case INIT:
if(!CustomNpcs.InitIgnore){
scriptLogCalculator(InitCacheMap, npcUUID, message);
}
break;
case TICK:
if(!CustomNpcs.TickIgnore){
scriptLogCalculator(TickCacheMap, npcUUID, message);
}
break;
case INTERACT:
if(!CustomNpcs.InteractIgnore){
scriptLogCalculator(InteractCacheMap, npcUUID, message);
}
break;
case DIALOG:
if(!CustomNpcs.DialogIgnore){
scriptLogCalculator(DialogCacheMap, npcUUID, message);
}
break;
case DAMAGED:
if(!CustomNpcs.DamagedIgnore){
scriptLogCalculator(DamagedCacheMap, npcUUID, message);
}
break;
case KILLED:
if(!CustomNpcs.KilledIgnore){
scriptLogCalculator(KilledCacheMap, npcUUID, message);
}
break;
case ATTACK:
if(!CustomNpcs.AttackIgnore){
scriptLogCalculator(AttackCacheMap, npcUUID, message);
}
break;
case TARGET:
if(!CustomNpcs.TargetIgnore){
scriptLogCalculator(TargetCacheMap, npcUUID, message);
}
break;
case COLLIDE:
if(!CustomNpcs.CollideIgnore){
scriptLogCalculator(CollideCacheMap, npcUUID, message);
}
break;
case KILLS:
if(!CustomNpcs.KillsIgnore){
scriptLogCalculator(KillsCacheMap, npcUUID, message);
}
case DIALOG_CLOSE:
if(!CustomNpcs.DialogCloseIgnore){
scriptLogCalculator(DialogCloseCacheMap, npcUUID, message);
}
break;
case TIMER:
if(!CustomNpcs.TimerIgnore){
scriptLogCalculator(TimerCacheMap, npcUUID, message);
}
break;
default:
break;
}
}
e.printStackTrace();
}
}
public static void scriptLogCalculator(WeakHashMap<UUID, NPCStamp> map, UUID npcUUID, String message) {
if(map.containsKey(npcUUID)){
NPCStamp stamp = map.get(npcUUID);
long secondsSinceFirst = TimeUnit.MILLISECONDS.toSeconds(new Date().getTime() - stamp.makeDate.getTime());
long millisecSinceLast = TimeUnit.MILLISECONDS.toMillis(stamp.recentDate.getTime() - stamp.makeDate.getTime());
public static void postScriptLog(UUID npcUUID, EnumScriptType type, String message) {
switch (type) {
case INIT:
if (!CustomNpcs.InitIgnore) {
scriptLogCalculator(InitCacheMap, npcUUID, message);
}
break;
case TICK:
if (!CustomNpcs.TickIgnore) {
scriptLogCalculator(TickCacheMap, npcUUID, message);
}
break;
case INTERACT:
if (!CustomNpcs.InteractIgnore) {
scriptLogCalculator(InteractCacheMap, npcUUID, message);
}
break;
case DIALOG:
if (!CustomNpcs.DialogIgnore) {
scriptLogCalculator(DialogCacheMap, npcUUID, message);
}
break;
case DAMAGED:
if (!CustomNpcs.DamagedIgnore) {
scriptLogCalculator(DamagedCacheMap, npcUUID, message);
}
break;
case KILLED:
if (!CustomNpcs.KilledIgnore) {
scriptLogCalculator(KilledCacheMap, npcUUID, message);
}
break;
case ATTACK:
if (!CustomNpcs.AttackIgnore) {
scriptLogCalculator(AttackCacheMap, npcUUID, message);
}
break;
case TARGET:
if (!CustomNpcs.TargetIgnore) {
scriptLogCalculator(TargetCacheMap, npcUUID, message);
}
break;
case COLLIDE:
if (!CustomNpcs.CollideIgnore) {
scriptLogCalculator(CollideCacheMap, npcUUID, message);
}
break;
case KILLS:
if (!CustomNpcs.KillsIgnore) {
scriptLogCalculator(KillsCacheMap, npcUUID, message);
}
case DIALOG_CLOSE:
if (!CustomNpcs.DialogCloseIgnore) {
scriptLogCalculator(DialogCloseCacheMap, npcUUID, message);
}
break;
case TIMER:
if (!CustomNpcs.TimerIgnore) {
scriptLogCalculator(TimerCacheMap, npcUUID, message);
}
break;
default:
break;
}
}
double frequency = (float) ConfigDebug.ScriptFrequency / 60;
// Reset Log if 2 Minutes Pass
if (secondsSinceFirst > 120) {
LogWriter.script(message);
stamp.counter = 1;
stamp.makeDate = new Date();
stamp.recentDate = new Date();
}
// ALWAYS Log the First 3 of Event
else if(secondsSinceFirst < 10 && stamp.counter < 3) {
LogWriter.script(message);
stamp.recentDate = new Date();
}
// IF event occurs to QUICKLY Ignore.
else if (millisecSinceLast < ConfigDebug.ScriptIgnoreTime){
stamp.recentDate = new Date();
}
else if(secondsSinceFirst > 10 && (double)stamp.counter / secondsSinceFirst > frequency){
// WARN
LogWriter.script("[SPAM]:" + message);
stamp.counter = 0;
stamp.recentDate = new Date();
}
stamp.counter++;
} else {
map.put(npcUUID, new NPCStamp());
LogWriter.script(message);
}
}
public static void scriptLogCalculator(WeakHashMap<UUID, NPCStamp> map, UUID npcUUID, String message) {
if (map.containsKey(npcUUID)) {
NPCStamp stamp = map.get(npcUUID);
long secondsSinceFirst = TimeUnit.MILLISECONDS.toSeconds(new Date().getTime() - stamp.makeDate.getTime());
long millisecSinceLast = TimeUnit.MILLISECONDS.toMillis(stamp.recentDate.getTime() - stamp.makeDate.getTime());
public static void script(Object msg) {
logger.log(NPCLogLevel.CNPCLog, msg.toString());
handler.flush();
}
double frequency = (float) ConfigDebug.ScriptFrequency / 60;
// Reset Log if 2 Minutes Pass
if (secondsSinceFirst > 120) {
LogWriter.script(message);
stamp.counter = 1;
stamp.makeDate = new Date();
stamp.recentDate = new Date();
}
// ALWAYS Log the First 3 of Event
else if (secondsSinceFirst < 10 && stamp.counter < 3) {
LogWriter.script(message);
stamp.recentDate = new Date();
}
// IF event occurs to QUICKLY Ignore.
else if (millisecSinceLast < ConfigDebug.ScriptIgnoreTime) {
stamp.recentDate = new Date();
} else if (secondsSinceFirst > 10 && (double) stamp.counter / secondsSinceFirst > frequency) {
// WARN
LogWriter.script("[SPAM]:" + message);
stamp.counter = 0;
stamp.recentDate = new Date();
}
stamp.counter++;
} else {
map.put(npcUUID, new NPCStamp());
LogWriter.script(message);
}
}
public static void info(Object msg) {
logger.log(Level.INFO, msg.toString());
handler.flush();
}
public static void script(Object msg) {
logger.log(NPCLogLevel.CNPCLog, msg.toString());
handler.flush();
}
public static void error(Object msg) {
logger.log(Level.SEVERE, msg.toString());
handler.flush();
}
public static void info(Object msg) {
logger.log(Level.INFO, msg.toString());
handler.flush();
}
public static void error(Object msg, Exception e) {
logger.log(Level.SEVERE, msg.toString());
logger.log(Level.SEVERE, e.getMessage(), e);
handler.flush();
}
public static void error(Object msg) {
logger.log(Level.SEVERE, msg.toString());
handler.flush();
}
public static void except(Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
handler.flush();
}
public static void error(Object msg, Exception e) {
logger.log(Level.SEVERE, msg.toString());
logger.log(Level.SEVERE, e.getMessage(), e);
handler.flush();
}
public static void except(Exception e) {
logger.log(Level.SEVERE, e.getMessage(), e);
handler.flush();
}
}
class NPCStamp
{
public Date makeDate = new Date();
public Date recentDate = new Date();
public int counter = 1;
class NPCStamp {
public Date makeDate = new Date();
public Date recentDate = new Date();
public int counter = 1;
};
+336 -367
View File
@@ -22,112 +22,101 @@ public class NBTTags {
public static int TAG_Compound = 10;
public static int TAG_Int_Array = 11;
public static HashMap<Integer, ItemStack> getItemStackList(
NBTTagList tagList) {
HashMap<Integer, ItemStack> list = new HashMap<Integer, ItemStack>();
for(int i = 0; i < tagList.tagCount(); i++)
{
public static HashMap<Integer, ItemStack> getItemStackList(
NBTTagList tagList) {
HashMap<Integer, ItemStack> list = new HashMap<Integer, ItemStack>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
try{
list.put(nbttagcompound.getByte("Slot") & 0xff, NoppesUtilServer.readItem(nbttagcompound));
}
catch(ClassCastException e){
list.put(nbttagcompound.getInteger("Slot"), NoppesUtilServer.readItem(nbttagcompound));
try {
list.put(nbttagcompound.getByte("Slot") & 0xff, NoppesUtilServer.readItem(nbttagcompound));
} catch (ClassCastException e) {
list.put(nbttagcompound.getInteger("Slot"), NoppesUtilServer.readItem(nbttagcompound));
}
}
return list;
}
return list;
}
public static ItemStack[] getItemStackArray(
NBTTagList tagList) {
ItemStack[] list = new ItemStack[tagList.tagCount()];
for(int i = 0; i < tagList.tagCount(); i++)
{
public static ItemStack[] getItemStackArray(
NBTTagList tagList) {
ItemStack[] list = new ItemStack[tagList.tagCount()];
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list[nbttagcompound.getByte("Slot") & 0xff] = NoppesUtilServer.readItem(nbttagcompound);
list[nbttagcompound.getByte("Slot") & 0xff] = NoppesUtilServer.readItem(nbttagcompound);
}
return list;
}
return list;
}
public static ArrayList<int[]> getIntegerArraySet(NBTTagList tagList) {
ArrayList<int[]> set = new ArrayList<int[]>();
for(int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound compound = tagList.getCompoundTagAt(i);
set.add(compound.getIntArray("Array"));
public static ArrayList<int[]> getIntegerArraySet(NBTTagList tagList) {
ArrayList<int[]> set = new ArrayList<int[]>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound compound = tagList.getCompoundTagAt(i);
set.add(compound.getIntArray("Array"));
}
return set;
}
return set;
}
public static HashMap<Integer, Boolean> getBooleanList(NBTTagList tagList) {
HashMap<Integer, Boolean> list = new HashMap<Integer, Boolean>();
for(int i = 0; i < tagList.tagCount(); i++)
{
public static HashMap<Integer, Boolean> getBooleanList(NBTTagList tagList) {
HashMap<Integer, Boolean> list = new HashMap<Integer, Boolean>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getBoolean("Boolean"));
}
return list;
}
return list;
}
public static HashMap<Integer, Integer> getIntegerIntegerMap(
NBTTagList tagList) {
HashMap<Integer, Integer> list = new HashMap<Integer, Integer>();
for(int i = 0; i < tagList.tagCount(); i++)
{
public static HashMap<Integer, Integer> getIntegerIntegerMap(
NBTTagList tagList) {
HashMap<Integer, Integer> list = new HashMap<Integer, Integer>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getInteger("Integer"));
}
return list;
}
return list;
}
public static HashMap<Integer, Float> getIntegerFloatMap(
NBTTagList tagList) {
HashMap<Integer, Float> list = new HashMap<Integer, Float>();
for(int i = 0; i < tagList.tagCount(); i++)
{
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getFloat("Float"));
}
return list;
}
public static HashMap<Integer, Double> getIntegerDoubleMap(
NBTTagList tagList) {
HashMap<Integer, Double> list = new HashMap<Integer, Double>();
for(int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getDouble("Double"));
}
return list;
}
public static HashMap<Integer, Double> getIntegerDoubleMap(
NBTTagList tagList) {
HashMap<Integer, Double> list = new HashMap<Integer, Double>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getDouble("Double"));
}
return list;
}
public static HashMap<Integer, Long> getIntegerLongMap(
NBTTagList tagList) {
HashMap<Integer, Long> list = new HashMap<Integer, Long>();
for(int i = 0; i < tagList.tagCount(); i++)
{
public static HashMap<Integer, Long> getIntegerLongMap(
NBTTagList tagList) {
HashMap<Integer, Long> list = new HashMap<Integer, Long>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getLong("Long"));
}
return list;
}
return list;
}
public static HashSet<String> getStringSet(NBTTagList tagList) {
HashSet<String> list = new HashSet<>();
for(int i = 0; i < tagList.tagCount(); i++)
{
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.add(nbttagcompound.getString("String"));
}
return list;
}
public static HashSet<String> getStringSet(NBTTagList tagList) {
HashSet<String> list = new HashSet<>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.add(nbttagcompound.getString("String"));
}
return list;
}
public static HashMap<Integer, Byte> getIntegerByteMap(
NBTTagList tagList) {
HashMap<Integer, Byte> list = new HashMap<Integer, Byte>();
for(int i = 0; i < tagList.tagCount(); i++)
{
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getByte("Byte"));
}
@@ -136,7 +125,7 @@ public class NBTTags {
public static NBTTagList nbtIntegerByteMap(Map<Integer, Byte> lines) {
NBTTagList nbttaglist = new NBTTagList();
if(lines == null)
if (lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -147,194 +136,182 @@ public class NBTTags {
return nbttaglist;
}
public static NBTTagList nbtStringSet(HashSet<String> collection) {
NBTTagList nbttaglist = new NBTTagList();
if(collection == null)
return nbttaglist;
for (String slot : collection) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("String", slot);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtStringSet(HashSet<String> collection) {
NBTTagList nbttaglist = new NBTTagList();
if (collection == null)
return nbttaglist;
for (String slot : collection) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("String", slot);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static HashSet<Integer> getIntegerSet(NBTTagList tagList) {
HashSet<Integer> list = new HashSet<Integer>();
for(int i = 0; i < tagList.tagCount(); i++)
{
public static HashSet<Integer> getIntegerSet(NBTTagList tagList) {
HashSet<Integer> list = new HashSet<Integer>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.add(nbttagcompound.getInteger("Integer"));
}
return list;
}
return list;
}
public static NBTTagList nbtIntegerSet(HashSet<Integer> set) {
NBTTagList nbttaglist = new NBTTagList();
if(set == null)
return nbttaglist;
for (int slot : set) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Integer", slot);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtIntegerSet(HashSet<Integer> set) {
NBTTagList nbttaglist = new NBTTagList();
if (set == null)
return nbttaglist;
for (int slot : set) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Integer", slot);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static HashMap<String, String> getStringStringMap(NBTTagList tagList) {
HashMap<String, String> list = new HashMap<String, String>();
for(int i = 0; i < tagList.tagCount(); i++)
{
public static HashMap<String, String> getStringStringMap(NBTTagList tagList) {
HashMap<String, String> list = new HashMap<String, String>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getString("Slot"), nbttagcompound.getString("Value"));
}
return list;
}
return list;
}
public static HashMap<Integer, String> getIntegerStringMap(NBTTagList tagList) {
HashMap<Integer, String> list = new HashMap<Integer, String>();
for(int i = 0; i < tagList.tagCount(); i++)
{
public static HashMap<Integer, String> getIntegerStringMap(NBTTagList tagList) {
HashMap<Integer, String> list = new HashMap<Integer, String>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getInteger("Slot"), nbttagcompound.getString("Value"));
}
return list;
}
return list;
}
public static HashMap<String, Integer> getStringIntegerMap(NBTTagList tagList) {
HashMap<String, Integer> list = new HashMap<String, Integer>();
for(int i = 0; i < tagList.tagCount(); i++)
{
public static HashMap<String, Integer> getStringIntegerMap(NBTTagList tagList) {
HashMap<String, Integer> list = new HashMap<String, Integer>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getString("Slot"), nbttagcompound.getInteger("Value"));
}
return list;
}
return list;
}
public static HashMap<String, int[]> getStringIntegerArrayMap(NBTTagList tagList) {
HashMap<String, int[]> list = new HashMap<String, int[]>();
for(int i = 0; i < tagList.tagCount(); i++)
{
public static HashMap<String, int[]> getStringIntegerArrayMap(NBTTagList tagList) {
HashMap<String, int[]> list = new HashMap<String, int[]>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(nbttagcompound.getString("Slot"), nbttagcompound.getIntArray("Value"));
}
return list;
}
return list;
}
/**
* @param tagList
* @param arrayLength if an int array is not this length a new int array with this length is made
* @return
*/
public static HashMap<String, int[]> getStringIntegerArrayMap(NBTTagList tagList, int arrayLength) {
HashMap<String, int[]> list = new HashMap<String, int[]>();
for(int i = 0; i < tagList.tagCount(); i++)
{
/**
* @param tagList
* @param arrayLength if an int array is not this length a new int array with this length is made
* @return
*/
public static HashMap<String, int[]> getStringIntegerArrayMap(NBTTagList tagList, int arrayLength) {
HashMap<String, int[]> list = new HashMap<String, int[]>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
int[] a = nbttagcompound.getIntArray("Value");
if (a.length != arrayLength) a = new int[arrayLength];
list.put(nbttagcompound.getString("Slot"), a);
}
return list;
}
return list;
}
public static HashMap<String, Vector<String>> getVectorMap(NBTTagList tagList) {
HashMap<String, Vector<String>> map = new HashMap<String, Vector<String>>();
for(int i = 0; i < tagList.tagCount(); i++)
{
Vector<String> values = new Vector<String>();
public static HashMap<String, Vector<String>> getVectorMap(NBTTagList tagList) {
HashMap<String, Vector<String>> map = new HashMap<String, Vector<String>>();
for (int i = 0; i < tagList.tagCount(); i++) {
Vector<String> values = new Vector<String>();
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
NBTTagList list = nbttagcompound.getTagList("Values", 10);
for(int j = 0; j < list.tagCount(); j++)
{
for (int j = 0; j < list.tagCount(); j++) {
NBTTagCompound value = list.getCompoundTagAt(j);
values.add(value.getString("Value"));
}
map.put(nbttagcompound.getString("Key"), values);
}
return map;
}
return map;
}
public static List<String> getStringList(NBTTagList tagList) {
List<String> list = new ArrayList<String>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
String line = nbttagcompound.getString("Line");
list.add(line);
}
return list;
}
public static List<String> getStringList(NBTTagList tagList) {
List<String> list = new ArrayList<String>();
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
String line = nbttagcompound.getString("Line");
list.add(line);
}
return list;
}
public static String[] getStringArray(NBTTagList tagList, int size) {
String[] arr = new String[size];
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
String line = nbttagcompound.getString("Value");
int slot = nbttagcompound.getInteger("Slot");
arr[slot] = line;
}
return arr;
}
public static String[] getStringArray(NBTTagList tagList, int size) {
String[] arr = new String[size];
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
String line = nbttagcompound.getString("Value");
int slot = nbttagcompound.getInteger("Slot");
arr[slot] = line;
}
return arr;
}
public static NBTTagList nbtIntegerArraySet(List<int[]> set) {
NBTTagList nbttaglist = new NBTTagList();
if(set == null)
return nbttaglist;
for(int[] arr : set)
{
if (set == null)
return nbttaglist;
for (int[] arr : set) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setIntArray("Array", arr);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static NBTTagList nbtItemStackList(HashMap<Integer,ItemStack>inventory) {
public static NBTTagList nbtItemStackList(HashMap<Integer, ItemStack> inventory) {
NBTTagList nbttaglist = new NBTTagList();
if(inventory == null)
return nbttaglist;
for(int slot : inventory.keySet())
{
ItemStack item = inventory.get(slot);
if(item == null)
continue;
if (inventory == null)
return nbttaglist;
for (int slot : inventory.keySet()) {
ItemStack item = inventory.get(slot);
if (item == null)
continue;
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)slot);
nbttagcompound.setByte("Slot", (byte) slot);
NoppesUtilServer.writeItem(item, nbttagcompound);
NoppesUtilServer.writeItem(item, nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static NBTTagList nbtItemStackArray(ItemStack[] inventory) {
NBTTagList nbttaglist = new NBTTagList();
if(inventory == null)
return nbttaglist;
for(int slot = 0 ; slot < inventory.length; slot++)
{
ItemStack item = inventory[slot];
if (inventory == null)
return nbttaglist;
for (int slot = 0; slot < inventory.length; slot++) {
ItemStack item = inventory[slot];
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)slot);
nbttagcompound.setByte("Slot", (byte) slot);
if(item != null)
NoppesUtilServer.writeItem(item, nbttagcompound);
if (item != null)
NoppesUtilServer.writeItem(item, nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static NBTTagList nbtBooleanList(HashMap<Integer, Boolean> updatedSlots) {
public static NBTTagList nbtBooleanList(HashMap<Integer, Boolean> updatedSlots) {
NBTTagList nbttaglist = new NBTTagList();
if(updatedSlots == null)
return nbttaglist;
HashMap<Integer,Boolean> inventory2 = updatedSlots;
for(Integer slot : inventory2.keySet())
{
if (updatedSlots == null)
return nbttaglist;
HashMap<Integer, Boolean> inventory2 = updatedSlots;
for (Integer slot : inventory2.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setBoolean("Boolean", inventory2.get(slot));
@@ -342,24 +319,24 @@ public class NBTTags {
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static NBTTagList nbtIntegerIntegerMap(Map<Integer, Integer> lines) {
NBTTagList nbttaglist = new NBTTagList();
if(lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
public static NBTTagList nbtIntegerIntegerMap(Map<Integer, Integer> lines) {
NBTTagList nbttaglist = new NBTTagList();
if (lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setInteger("Integer", lines.get(slot));
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtIntegerFloatMap(Map<Integer, Float> lines) {
NBTTagList nbttaglist = new NBTTagList();
if(lines == null)
if (lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
@@ -370,57 +347,56 @@ public class NBTTags {
return nbttaglist;
}
public static NBTTagList nbtIntegerDoubleMap(Map<Integer, Double> lines) {
NBTTagList nbttaglist = new NBTTagList();
if(lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setDouble("Double", lines.get(slot));
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtIntegerDoubleMap(Map<Integer, Double> lines) {
NBTTagList nbttaglist = new NBTTagList();
if (lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setDouble("Double", lines.get(slot));
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtIntegerLongMap(Map<Integer, Long> lines) {
NBTTagList nbttaglist = new NBTTagList();
if(lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
public static NBTTagList nbtIntegerLongMap(Map<Integer, Long> lines) {
NBTTagList nbttaglist = new NBTTagList();
if (lines == null)
return nbttaglist;
for (int slot : lines.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setLong("Long", lines.get(slot));
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtVectorMap(Map<String, Vector<String>> map) {
NBTTagList list = new NBTTagList();
if(map == null)
return list;
for(String key : map.keySet()){
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Key", key);
NBTTagList values = new NBTTagList();
for(String value : map.get(key)){
NBTTagCompound comp = new NBTTagCompound();
comp.setString("Value", value);
values.appendTag(comp);
}
compound.setTag("Values", values);
list.appendTag(compound);
nbttaglist.appendTag(nbttagcompound);
}
return list;
}
return nbttaglist;
}
public static NBTTagList nbtStringStringMap(Map<String, String> map) {
public static NBTTagList nbtVectorMap(Map<String, Vector<String>> map) {
NBTTagList list = new NBTTagList();
if (map == null)
return list;
for (String key : map.keySet()) {
NBTTagCompound compound = new NBTTagCompound();
compound.setString("Key", key);
NBTTagList values = new NBTTagList();
for (String value : map.get(key)) {
NBTTagCompound comp = new NBTTagCompound();
comp.setString("Value", value);
values.appendTag(comp);
}
compound.setTag("Values", values);
list.appendTag(compound);
}
return list;
}
public static NBTTagList nbtStringStringMap(Map<String, String> map) {
NBTTagList nbttaglist = new NBTTagList();
if(map == null)
return nbttaglist;
for(String slot : map.keySet())
{
if (map == null)
return nbttaglist;
for (String slot : map.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Slot", slot);
nbttagcompound.setString("Value", map.get(slot));
@@ -428,14 +404,13 @@ public class NBTTags {
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static NBTTagList nbtStringIntegerMap(Map<String, Integer> map) {
public static NBTTagList nbtStringIntegerMap(Map<String, Integer> map) {
NBTTagList nbttaglist = new NBTTagList();
if(map == null)
return nbttaglist;
for(String slot : map.keySet())
{
if (map == null)
return nbttaglist;
for (String slot : map.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Slot", slot);
nbttagcompound.setInteger("Value", map.get(slot));
@@ -443,14 +418,13 @@ public class NBTTags {
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static NBTTagList nbtStringIntegerArrayMap(Map<String, int[]> map) {
NBTTagList nbttaglist = new NBTTagList();
if(map == null)
return nbttaglist;
for(String slot : map.keySet())
{
public static NBTTagList nbtStringIntegerArrayMap(Map<String, int[]> map) {
NBTTagList nbttaglist = new NBTTagList();
if (map == null)
return nbttaglist;
for (String slot : map.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Slot", slot);
nbttagcompound.setIntArray("Value", map.get(slot));
@@ -458,14 +432,13 @@ public class NBTTags {
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static NBTBase nbtIntegerStringMap(HashMap<Integer, String> map) {
public static NBTBase nbtIntegerStringMap(HashMap<Integer, String> map) {
NBTTagList nbttaglist = new NBTTagList();
if(map == null)
return nbttaglist;
for(int slot : map.keySet())
{
if (map == null)
return nbttaglist;
for (int slot : map.keySet()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setInteger("Slot", slot);
nbttagcompound.setString("Value", map.get(slot));
@@ -473,40 +446,39 @@ public class NBTTags {
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static NBTTagList nbtStringArray(String[] list) {
public static NBTTagList nbtStringArray(String[] list) {
NBTTagList nbttaglist = new NBTTagList();
if(list == null)
return nbttaglist;
for(int i = 0; i < list.length; i++){
if(list[i] == null)
continue;
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Value", list[i]);
nbttagcompound.setInteger("Slot", i);
nbttaglist.appendTag(nbttagcompound);
if (list == null)
return nbttaglist;
for (int i = 0; i < list.length; i++) {
if (list[i] == null)
continue;
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Value", list[i]);
nbttagcompound.setInteger("Slot", i);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
public static NBTTagList nbtStringList(List<String> list) {
NBTTagList nbttaglist = new NBTTagList();
for (String s : list) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Line", s);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtStringList(List<String> list) {
NBTTagList nbttaglist = new NBTTagList();
for (String s : list) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Line", s);
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
public static NBTTagList nbtDoubleList(double ... par1ArrayOfDouble){
public static NBTTagList nbtDoubleList(double... par1ArrayOfDouble) {
NBTTagList nbttaglist = new NBTTagList();
double[] adouble = par1ArrayOfDouble;
int i = par1ArrayOfDouble.length;
for (int j = 0; j < i; ++j)
{
for (int j = 0; j < i; ++j) {
double d1 = adouble[j];
nbttaglist.appendTag(new NBTTagDouble(d1));
}
@@ -514,97 +486,94 @@ public class NBTTags {
return nbttaglist;
}
public static NBTTagCompound NBTMerge(NBTTagCompound data, NBTTagCompound merge) {
NBTTagCompound compound = (NBTTagCompound) data.copy();
Set<String> names = merge.func_150296_c();
for(String name : names){
NBTBase base = merge.getTag(name);
if(base.getId() == 10)
base = NBTMerge(compound.getCompoundTag(name), (NBTTagCompound) base);
compound.setTag(name, base);
}
return compound;
}
public static NBTTagCompound NBTMerge(NBTTagCompound data, NBTTagCompound merge) {
NBTTagCompound compound = (NBTTagCompound) data.copy();
Set<String> names = merge.func_150296_c();
for (String name : names) {
NBTBase base = merge.getTag(name);
if (base.getId() == 10)
base = NBTMerge(compound.getCompoundTag(name), (NBTTagCompound) base);
compound.setTag(name, base);
}
return compound;
}
public static TreeMap<Long, String> GetLongStringMap(NBTTagList tagList) {
TreeMap list = new TreeMap();
public static TreeMap<Long, String> GetLongStringMap(NBTTagList tagList) {
TreeMap list = new TreeMap();
for(int i = 0; i < tagList.tagCount(); ++i) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(Long.valueOf(nbttagcompound.getLong("Long")), nbttagcompound.getString("String"));
}
for (int i = 0; i < tagList.tagCount(); ++i) {
NBTTagCompound nbttagcompound = tagList.getCompoundTagAt(i);
list.put(Long.valueOf(nbttagcompound.getLong("Long")), nbttagcompound.getString("String"));
}
return list;
}
return list;
}
public static NBTTagList NBTLongStringMap(Map<Long, String> map) {
NBTTagList nbttaglist = new NBTTagList();
if(map == null) {
return nbttaglist;
} else {
Iterator var2 = map.keySet().iterator();
public static NBTTagList NBTLongStringMap(Map<Long, String> map) {
NBTTagList nbttaglist = new NBTTagList();
if (map == null) {
return nbttaglist;
} else {
Iterator var2 = map.keySet().iterator();
while(var2.hasNext()) {
long slot = ((Long)var2.next()).longValue();
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setLong("Long", slot);
nbttagcompound.setString("String", (String) map.get(Long.valueOf(slot)));
nbttaglist.appendTag(nbttagcompound);
}
while (var2.hasNext()) {
long slot = ((Long) var2.next()).longValue();
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setLong("Long", slot);
nbttagcompound.setString("String", (String) map.get(Long.valueOf(slot)));
nbttaglist.appendTag(nbttagcompound);
}
return nbttaglist;
}
}
return nbttaglist;
}
}
public static List<ScriptContainer> GetScriptOld(NBTTagList list, IScriptHandler handler) {
ArrayList scripts = new ArrayList();
public static List<ScriptContainer> GetScriptOld(NBTTagList list, IScriptHandler handler) {
ArrayList scripts = new ArrayList();
for(int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound compoundd = list.getCompoundTagAt(i);
ScriptContainer script = new ScriptContainer(handler);
script.readFromNBT(compoundd);
scripts.add(script);
}
for (int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound compoundd = list.getCompoundTagAt(i);
ScriptContainer script = new ScriptContainer(handler);
script.readFromNBT(compoundd);
scripts.add(script);
}
return scripts;
}
return scripts;
}
public static List<ScriptContainer> GetScript(NBTTagCompound compound, IScriptHandler handler) {
ArrayList<ScriptContainer> scripts = new ArrayList<>();
public static List<ScriptContainer> GetScript(NBTTagCompound compound, IScriptHandler handler) {
ArrayList<ScriptContainer> scripts = new ArrayList<>();
for(int i = 0; i < compound.getInteger("TotalScripts"); ++i) {
NBTTagCompound containerCompound = compound.getCompoundTag("Tab"+i);
ScriptContainer script = new ScriptContainer(handler);
script.readFromNBT(containerCompound);
scripts.add(script);
}
for (int i = 0; i < compound.getInteger("TotalScripts"); ++i) {
NBTTagCompound containerCompound = compound.getCompoundTag("Tab" + i);
ScriptContainer script = new ScriptContainer(handler);
script.readFromNBT(containerCompound);
scripts.add(script);
}
return scripts;
}
return scripts;
}
public static NBTTagList NBTScript(List<ScriptContainer> scripts) {
NBTTagList list = new NBTTagList();
Iterator var2 = scripts.iterator();
public static NBTTagList NBTScript(List<ScriptContainer> scripts) {
NBTTagList list = new NBTTagList();
Iterator var2 = scripts.iterator();
while(var2.hasNext()) {
ScriptContainer script = (ScriptContainer)var2.next();
NBTTagCompound compound = new NBTTagCompound();
script.writeToNBT(compound);
list.appendTag(compound);
}
while (var2.hasNext()) {
ScriptContainer script = (ScriptContainer) var2.next();
NBTTagCompound compound = new NBTTagCompound();
script.writeToNBT(compound);
list.appendTag(compound);
}
return list;
}
return list;
}
public static int getIntAt(NBTTagList tagList, int index)
{
if (index >= 0 && index < tagList.tagCount())
{
public static int getIntAt(NBTTagList tagList, int index) {
if (index >= 0 && index < tagList.tagCount()) {
NBTBase nbtbase = tagList.getCompoundTagAt(index);
if (nbtbase.getId() == 3)
{
return ((NBTTagInt)nbtbase).func_150287_d();
if (nbtbase.getId() == 3) {
return ((NBTTagInt) nbtbase).func_150287_d();
}
}
+5 -5
View File
@@ -3,9 +3,9 @@ package noppes.npcs;
import java.util.logging.Level;
class NPCLogLevel extends Level {
public static final Level CNPCLog = new NPCLogLevel("CNPC", 0);
public static final Level CNPCLog = new NPCLogLevel("CNPC", 0);
public NPCLogLevel(String name, int value) {
super(name, value);
}
}
public NPCLogLevel(String name, int value) {
super(name, value);
}
}
+52 -55
View File
@@ -29,40 +29,40 @@ import noppes.npcs.scripted.event.CustomNPCsEvent;
import java.util.*;
public class NPCSpawning {
private static Set<ChunkCoordIntPair> eligibleChunksForSpawning = Sets.newHashSet();
private static Set<ChunkCoordIntPair> eligibleChunksForSpawning = Sets.newHashSet();
private static boolean animalSpawn;
private static boolean monsterSpawn;
private static boolean airSpawn;
private static boolean liquidSpawn;
public static void findChunksForSpawning(WorldServer world){
if(SpawnController.Instance.data.isEmpty() || world.getWorldInfo().getWorldTotalTime() % 400L != 0L)
return;
eligibleChunksForSpawning.clear();
for (int i = 0; i < world.playerEntities.size(); ++i){
EntityPlayer entityplayer = (EntityPlayer)world.playerEntities.get(i);
public static void findChunksForSpawning(WorldServer world) {
if (SpawnController.Instance.data.isEmpty() || world.getWorldInfo().getWorldTotalTime() % 400L != 0L)
return;
eligibleChunksForSpawning.clear();
for (int i = 0; i < world.playerEntities.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) world.playerEntities.get(i);
int j = MathHelper.floor_double(entityplayer.posX / 16.0D);
int k = MathHelper.floor_double(entityplayer.posZ / 16.0D);
byte size = 7;
for (int x = -size; x <= size; ++x){
for (int z = -size; z <= size; ++z){
for (int x = -size; x <= size; ++x) {
for (int z = -size; z <= size; ++z) {
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(x + j, z + k);
if (!eligibleChunksForSpawning.contains(chunkcoordintpair)){
if (!eligibleChunksForSpawning.contains(chunkcoordintpair)) {
eligibleChunksForSpawning.add(chunkcoordintpair);
}
}
}
}
if (countNPCs(world) > eligibleChunksForSpawning.size()){
return;
if (countNPCs(world) > eligibleChunksForSpawning.size()) {
return;
}
ArrayList<ChunkCoordIntPair> tmp = new ArrayList(eligibleChunksForSpawning);
Collections.shuffle(tmp);
Iterator<ChunkCoordIntPair> iterator = tmp.iterator();
while (iterator.hasNext()){
while (iterator.hasNext()) {
ChunkCoordIntPair chunkcoordintpair1 = iterator.next();
ChunkPosition chunkposition = getChunk(world, chunkcoordintpair1.chunkXPos, chunkcoordintpair1.chunkZPos);
@@ -70,7 +70,7 @@ public class NPCSpawning {
int y = chunkposition.chunkPosY;
int l1 = chunkposition.chunkPosZ;
for(int i = 0; i < 3; i++){
for (int i = 0; i < 3; i++) {
int x = j1;
int z = l1;
byte b1 = 6;
@@ -78,28 +78,28 @@ public class NPCSpawning {
x += world.rand.nextInt(b1) - world.rand.nextInt(b1);
z += world.rand.nextInt(b1) - world.rand.nextInt(b1);
String name = world.getBiomeGenForCoords(x, z).biomeName;
SpawnData data = SpawnController.Instance.getRandomSpawnData(name, world.provider.dimensionId);
String name = world.getBiomeGenForCoords(x, z).biomeName;
SpawnData data = SpawnController.Instance.getRandomSpawnData(name, world.provider.dimensionId);
if (data == null || !canCreatureTypeSpawnAtLocation(data, world, x, y, z) || world.getClosestPlayer(x, y, z, 24.0D) != null)
continue;
continue;
spawnData(data, world, x, y, z);
}
}
}
public static int countNPCs(World world){
public static int countNPCs(World world) {
int count = 0;
List<Entity> list = world.loadedEntityList;
for (Entity entity : list){
if (entity instanceof EntityNPCInterface){
for (Entity entity : list) {
if (entity instanceof EntityNPCInterface) {
count++;
}
}
return count;
}
protected static ChunkPosition getChunk(World world, int x, int z){
protected static ChunkPosition getChunk(World world, int x, int z) {
Chunk chunk = world.getChunkFromChunkCoords(x, z);
int k = x * 16 + world.rand.nextInt(16);
int l = z * 16 + world.rand.nextInt(16);
@@ -107,21 +107,21 @@ public class NPCSpawning {
return new ChunkPosition(k, i1, l);
}
public static void performWorldGenSpawning(World world, int x, int z, Random rand){
public static void performWorldGenSpawning(World world, int x, int z, Random rand) {
BiomeGenBase biome = world.getBiomeGenForCoords(x + 8, z + 8);
while (rand.nextFloat() < biome.getSpawningChance()){
SpawnData data = SpawnController.Instance.getRandomSpawnData(biome.biomeName, world.provider.dimensionId);
if(data == null)
continue;
while (rand.nextFloat() < biome.getSpawningChance()) {
SpawnData data = SpawnController.Instance.getRandomSpawnData(biome.biomeName, world.provider.dimensionId);
if (data == null)
continue;
int size = 16;
int size = 16;
int j1 = x + rand.nextInt(size);
int k1 = z + rand.nextInt(size);
int l1 = j1;
int i2 = k1;
for (int k2 = 0; k2 < 4; ++k2){
for (int k2 = 0; k2 < 4; ++k2) {
int l2 = world.getTopSolidOrLiquidBlock(j1, k1);
if (l2 > data.spawnHeightMax || l2 < data.spawnHeightMin) {
continue;
@@ -129,31 +129,29 @@ public class NPCSpawning {
l2 = l2 + (int) ((data.spawnHeightMax - l2) * Math.random());
}
if (!canCreatureTypeSpawnAtLocation(data, world, j1, l2, k1)){
if (!canCreatureTypeSpawnAtLocation(data, world, j1, l2, k1)) {
j1 += rand.nextInt(5) - rand.nextInt(5);
for (k1 += rand.nextInt(5) - rand.nextInt(5); j1 < x || j1 >= x + size || k1 < z || k1 >= z + size; k1 = i2 + rand.nextInt(5) - rand.nextInt(5))
{
for (k1 += rand.nextInt(5) - rand.nextInt(5); j1 < x || j1 >= x + size || k1 < z || k1 >= z + size; k1 = i2 + rand.nextInt(5) - rand.nextInt(5)) {
j1 = l1 + rand.nextInt(5) - rand.nextInt(5);
}
}
else if(spawnData(data, world, j1, l2, k1))
break;
} else if (spawnData(data, world, j1, l2, k1))
break;
}
}
}
private static boolean spawnData(SpawnData data, World world, int x, int y, int z){
private static boolean spawnData(SpawnData data, World world, int x, int y, int z) {
EntityLiving entityliving;
try{
try {
NBTTagCompound[] allCompoundList = data.spawnCompounds.values().toArray(new NBTTagCompound[0]);
ArrayList<Entity> entities = new ArrayList<>();
for (NBTTagCompound compound : allCompoundList) {
Entity entity;
try {
Class<?> oclass = (Class<?>)EntityList.stringToClassMapping.get(compound.getString("id"));
Class<?> oclass = (Class<?>) EntityList.stringToClassMapping.get(compound.getString("id"));
if (oclass == null) {
continue;
}
@@ -170,43 +168,42 @@ public class NPCSpawning {
return false;
}
Entity spawnEntity = entities.get((int)Math.floor(Math.random()*entities.size()));
Entity spawnEntity = entities.get((int) Math.floor(Math.random() * entities.size()));
if (!(spawnEntity instanceof EntityLiving)) {
if (!(spawnEntity instanceof EntityLiving)) {
return false;
}
entityliving = (EntityLiving) spawnEntity;
entityliving = (EntityLiving) spawnEntity;
if(spawnEntity instanceof EntityCustomNpc){
EntityCustomNpc npc = (EntityCustomNpc) spawnEntity;
npc.stats.spawnCycle = 3;
npc.ais.returnToStart = false;
npc.ais.startPos = new int[]{x,y, z};
if (spawnEntity instanceof EntityCustomNpc) {
EntityCustomNpc npc = (EntityCustomNpc) spawnEntity;
npc.stats.spawnCycle = 3;
npc.ais.returnToStart = false;
npc.ais.startPos = new int[]{x, y, z};
npc.updateAI = true;
npc.updateClient = true;
npc.getNavigator().clearPathEntity();
}
spawnEntity.setLocationAndAngles(x + 0.5, y, z + 0.5, world.rand.nextFloat() * 360.0F, 0.0F);
}
catch (Exception exception){
}
spawnEntity.setLocationAndAngles(x + 0.5, y, z + 0.5, world.rand.nextFloat() * 360.0F, 0.0F);
} catch (Exception exception) {
exception.printStackTrace();
return false;
}
Result canSpawn = ForgeEventFactory.canEntitySpawn(entityliving, world, x + 0.5f, y, z + 0.5f);
if (canSpawn == Result.DENY || (canSpawn == Result.DEFAULT && !canEntitySpawn(data,entityliving)))
return false;
if (canSpawn == Result.DENY || (canSpawn == Result.DEFAULT && !canEntitySpawn(data, entityliving)))
return false;
CustomNPCsEvent.CNPCNaturalSpawnEvent event = new CustomNPCsEvent.CNPCNaturalSpawnEvent(entityliving, data, NpcAPI.Instance().getIPos(new BlockPos(x,y,z)), NPCSpawning.animalSpawn, NPCSpawning.monsterSpawn, NPCSpawning.liquidSpawn, NPCSpawning.airSpawn);
CustomNPCsEvent.CNPCNaturalSpawnEvent event = new CustomNPCsEvent.CNPCNaturalSpawnEvent(entityliving, data, NpcAPI.Instance().getIPos(new BlockPos(x, y, z)), NPCSpawning.animalSpawn, NPCSpawning.monsterSpawn, NPCSpawning.liquidSpawn, NPCSpawning.airSpawn);
if (EventHooks.onCNPCNaturalSpawn(event)) {
return false;
}
entityliving.setPosition(event.attemptPosition.getX(),event.attemptPosition.getY(),event.attemptPosition.getZ());
entityliving.setPosition(event.attemptPosition.getX(), event.attemptPosition.getY(), event.attemptPosition.getZ());
world.spawnEntityInWorld(entityliving);
return true;
return true;
}
public static boolean canEntitySpawn(SpawnData data, EntityLiving entityLiving) {
@@ -217,7 +214,7 @@ public class NPCSpawning {
}
}
public static boolean canCreatureTypeSpawnAtLocation(SpawnData data, World world, int x, int y, int z){
public static boolean canCreatureTypeSpawnAtLocation(SpawnData data, World world, int x, int y, int z) {
Block block = world.getBlock(x, y - 1, z);
boolean hasSolidSurface = World.doesBlockHaveSolidTopSurface(world, x, y - 1, z);
@@ -11,72 +11,73 @@ import java.util.Arrays;
public class NoppesStringUtils {
final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47};
static {
Arrays.sort(illegalChars);
}
public static String cleanFileName(String badFileName) {
StringBuilder cleanName = new StringBuilder();
for (int i = 0; i < badFileName.length(); i++) {
int c = (int)badFileName.charAt(i);
if (Arrays.binarySearch(illegalChars, c) < 0) {
cleanName.append((char)c);
}
}
return cleanName.toString();
}
public static String formatText(String text, Object... obs) {
for(Object ob : obs){
if(ob instanceof EntityPlayer){
String username = ((EntityPlayer)ob).getDisplayName();
text = text.replace("{player}", username);
text = text.replace("@p", username);
}
else if(ob instanceof EntityNPCInterface)
text = text.replace("@npc", ((EntityNPCInterface)ob).getCommandSenderName());
}
text = text.replace("&", Character.toChars(167)[0] + "");
text = text.replace("%","%%");
return text;
}
final static int[] illegalChars = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47};
public static void setClipboardContents(String aString) {
StringSelection stringSelection = new StringSelection(aString);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, new ClipboardOwner() {
@Override
public void lostOwnership(Clipboard arg0, Transferable arg1) {
static {
Arrays.sort(illegalChars);
}
}
});
}
public static String cleanFileName(String badFileName) {
StringBuilder cleanName = new StringBuilder();
for (int i = 0; i < badFileName.length(); i++) {
int c = (int) badFileName.charAt(i);
if (Arrays.binarySearch(illegalChars, c) < 0) {
cleanName.append((char) c);
}
}
return cleanName.toString();
}
public static String getClipboardContents() {
String result = "";
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable contents = clipboard.getContents(null);
boolean hasTransferableText = contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
if (hasTransferableText) {
try {
result = (String) contents.getTransferData(DataFlavor.stringFlavor);
} catch (UnsupportedFlavorException ex) {
System.err.println(ex);
ex.printStackTrace();
} catch (IOException ex) {
System.err.println(ex);
ex.printStackTrace();
}
}
return result;
}
public static String formatText(String text, Object... obs) {
for (Object ob : obs) {
if (ob instanceof EntityPlayer) {
String username = ((EntityPlayer) ob).getDisplayName();
text = text.replace("{player}", username);
text = text.replace("@p", username);
} else if (ob instanceof EntityNPCInterface)
text = text.replace("@npc", ((EntityNPCInterface) ob).getCommandSenderName());
public static String translate(Object... arr) {
String s = "";
for(Object str : arr){
s += StatCollector.translateToLocal(str.toString());
}
return s;
}
}
text = text.replace("&", Character.toChars(167)[0] + "");
text = text.replace("%", "%%");
return text;
}
public static void setClipboardContents(String aString) {
StringSelection stringSelection = new StringSelection(aString);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(stringSelection, new ClipboardOwner() {
@Override
public void lostOwnership(Clipboard arg0, Transferable arg1) {
}
});
}
public static String getClipboardContents() {
String result = "";
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable contents = clipboard.getContents(null);
boolean hasTransferableText = contents != null && contents.isDataFlavorSupported(DataFlavor.stringFlavor);
if (hasTransferableText) {
try {
result = (String) contents.getTransferData(DataFlavor.stringFlavor);
} catch (UnsupportedFlavorException ex) {
System.err.println(ex);
ex.printStackTrace();
} catch (IOException ex) {
System.err.println(ex);
ex.printStackTrace();
}
}
return result;
}
public static String translate(Object... arr) {
String s = "";
for (Object str : arr) {
s += StatCollector.translateToLocal(str.toString());
}
return s;
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -3,15 +3,14 @@ package noppes.npcs;
import net.minecraft.entity.Entity;
import net.minecraft.util.EntityDamageSource;
public class NpcDamageSource extends EntityDamageSource{
public class NpcDamageSource extends EntityDamageSource {
public NpcDamageSource(String par1Str, Entity par2Entity) {
super(par1Str, par2Entity);
}
public NpcDamageSource(String par1Str, Entity par2Entity) {
super(par1Str, par2Entity);
}
@Override
public boolean isDifficultyScaled()
{
return false;
@Override
public boolean isDifficultyScaled() {
return false;
}
}
@@ -3,15 +3,14 @@ package noppes.npcs;
import net.minecraft.entity.Entity;
import net.minecraft.util.EntityDamageSourceIndirect;
public class NpcDamageSourceInderect extends EntityDamageSourceIndirect{
public class NpcDamageSourceInderect extends EntityDamageSourceIndirect {
public NpcDamageSourceInderect(String par1Str, Entity par2Entity, Entity par3Entity) {
super(par1Str, par2Entity, par3Entity);
}
public NpcDamageSourceInderect(String par1Str, Entity par2Entity, Entity par3Entity) {
super(par1Str, par2Entity, par3Entity);
}
@Override
public boolean isDifficultyScaled()
{
return false;
@Override
public boolean isDifficultyScaled() {
return false;
}
}
+144 -141
View File
@@ -8,167 +8,170 @@ import net.minecraft.nbt.NBTTagCompound;
import java.util.HashMap;
public class NpcMiscInventory implements IInventory {
public HashMap<Integer,ItemStack> items = new HashMap<Integer,ItemStack>();
public int stackLimit = 64;
public HashMap<Integer, ItemStack> items = new HashMap<Integer, ItemStack>();
public int stackLimit = 64;
private int size;
public NpcMiscInventory(int size){
this.size = size;
}
public NBTTagCompound getToNBT(){
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setTag("NpcMiscInv", NBTTags.nbtItemStackList(items));
return nbttagcompound;
}
public void setFromNBT(NBTTagCompound nbttagcompound){
items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcMiscInv", 10));
}
@Override
public int getSizeInventory() {
return size;
}
private int size;
@Override
public ItemStack getStackInSlot(int var1) {
return items.get(var1);
}
public NpcMiscInventory(int size) {
this.size = size;
}
@Override
public ItemStack decrStackSize(int par1, int par2) {
public NBTTagCompound getToNBT() {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setTag("NpcMiscInv", NBTTags.nbtItemStackList(items));
return nbttagcompound;
}
public void setFromNBT(NBTTagCompound nbttagcompound) {
items = NBTTags.getItemStackList(nbttagcompound.getTagList("NpcMiscInv", 10));
}
@Override
public int getSizeInventory() {
return size;
}
@Override
public ItemStack getStackInSlot(int var1) {
return items.get(var1);
}
@Override
public ItemStack decrStackSize(int par1, int par2) {
if (items.get(par1) == null)
return null;
return null;
ItemStack var4 = null;
if (items.get(par1).stackSize <= par2){
if (items.get(par1).stackSize <= par2) {
var4 = items.get(par1);
items.put(par1,null);
}
else{
items.put(par1, null);
} else {
var4 = items.get(par1).splitStack(par2);
if (items.get(par1).stackSize == 0){
items.put(par1,null);
if (items.get(par1).stackSize == 0) {
items.put(par1, null);
}
}
return var4;
}
return var4;
}
public boolean decrStackSize(ItemStack eating, int decrease) {
for(int slot : items.keySet()){
ItemStack item = items.get(slot);
if(items != null && eating == item && item.stackSize >= decrease){
item.splitStack(decrease);
if(item.stackSize <= 0)
items.put(slot, null);
return true;
}
}
return false;
}
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
if (items.get(var1) != null)
{
public boolean decrStackSize(ItemStack eating, int decrease) {
for (int slot : items.keySet()) {
ItemStack item = items.get(slot);
if (items != null && eating == item && item.stackSize >= decrease) {
item.splitStack(decrease);
if (item.stackSize <= 0)
items.put(slot, null);
return true;
}
}
return false;
}
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
if (items.get(var1) != null) {
ItemStack var3 = items.get(var1);
items.put(var1,null);
items.put(var1, null);
return var3;
}
return null;
}
}
@Override
public void setInventorySlotContents(int var1, ItemStack var2) {
if(var1 >= getSizeInventory())
return;
items.put(var1,var2);
}
@Override
public void setInventorySlotContents(int var1, ItemStack var2) {
if (var1 >= getSizeInventory())
return;
items.put(var1, var2);
}
@Override
public int getInventoryStackLimit() {
return stackLimit;
}
@Override
public int getInventoryStackLimit() {
return stackLimit;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
return true;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
return true;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
}
@Override
public String getInventoryName() {
return "Npc Misc Inventory";
}
@Override
public boolean hasCustomInventoryName() {
return true;
}
@Override
public void markDirty() {
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
public boolean addItemStack(ItemStack item) {
ItemStack mergable;
boolean merged = false;
while((mergable = getMergableItem(item)) != null && mergable.stackSize > 0){
int size = mergable.getMaxStackSize() - mergable.stackSize;
if(size > item.stackSize){
mergable.stackSize = mergable.getMaxStackSize();
item.stackSize -= size;
merged = true;
}
else{
mergable.stackSize += item.stackSize;
item.stackSize = 0;
}
}
if(item.stackSize <= 0)
return true;
int slot = firstFreeSlot();
if(slot >= 0){
items.put(slot, item.copy());
item.stackSize = 0;
return true;
}
return merged;
}
public ItemStack getMergableItem(ItemStack item){
for(ItemStack is : items.values()){
if(NoppesUtilPlayer.compareItems(item, is, false, false) && is.stackSize < is.getMaxStackSize()){
return is;
}
}
return null;
}
public int firstFreeSlot(){
for(int i = 0; i < getSizeInventory(); i++){
if(items.get(i) == null)
return i;
}
return -1;
}
public void setSize(int i) {
size = i;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
}
@Override
public String getInventoryName() {
return "Npc Misc Inventory";
}
@Override
public boolean hasCustomInventoryName() {
return true;
}
@Override
public void markDirty() {
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
public boolean addItemStack(ItemStack item) {
ItemStack mergable;
boolean merged = false;
while ((mergable = getMergableItem(item)) != null && mergable.stackSize > 0) {
int size = mergable.getMaxStackSize() - mergable.stackSize;
if (size > item.stackSize) {
mergable.stackSize = mergable.getMaxStackSize();
item.stackSize -= size;
merged = true;
} else {
mergable.stackSize += item.stackSize;
item.stackSize = 0;
}
}
if (item.stackSize <= 0)
return true;
int slot = firstFreeSlot();
if (slot >= 0) {
items.put(slot, item.copy());
item.stackSize = 0;
return true;
}
return merged;
}
public ItemStack getMergableItem(ItemStack item) {
for (ItemStack is : items.values()) {
if (NoppesUtilPlayer.compareItems(item, is, false, false) && is.stackSize < is.getMaxStackSize()) {
return is;
}
}
return null;
}
public int firstFreeSlot() {
for (int i = 0; i < getSizeInventory(); i++) {
if (items.get(i) == null)
return i;
}
return -1;
}
public void setSize(int i) {
size = i;
}
}
+77 -79
View File
@@ -14,133 +14,131 @@ import java.util.HashMap;
import java.util.Vector;
public class QuestLogData {
public String trackedQuestKey = "";
public HashMap<String,Vector<String>> categories = new HashMap<String,Vector<String>>();
public String selectedQuest = "";
public String selectedCategory = "";
public HashMap<String,String> questText = new HashMap<>();
public HashMap<String,String> questAlerts = new HashMap<>();
public HashMap<String,Vector<String>> questStatus = new HashMap<>();
public HashMap<String,String> finish = new HashMap<>();
public HashMap<String, Integer> partyQuests = new HashMap<>();
public HashMap<String,Vector<String>> partyOptions = new HashMap<>();
public String trackedQuestKey = "";
public HashMap<String, Vector<String>> categories = new HashMap<String, Vector<String>>();
public String selectedQuest = "";
public String selectedCategory = "";
public HashMap<String, String> questText = new HashMap<>();
public HashMap<String, String> questAlerts = new HashMap<>();
public HashMap<String, Vector<String>> questStatus = new HashMap<>();
public HashMap<String, String> finish = new HashMap<>();
public HashMap<String, Integer> partyQuests = new HashMap<>();
public HashMap<String, Vector<String>> partyOptions = new HashMap<>();
public NBTTagCompound writeNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Categories", NBTTags.nbtVectorMap(categories));
compound.setTag("Logs", NBTTags.nbtStringStringMap(questText));
compound.setTag("Alerts", NBTTags.nbtStringStringMap(questAlerts));
compound.setTag("Status", NBTTags.nbtVectorMap(questStatus));
compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish));
compound.setString("TrackedQuestID", trackedQuestKey);
compound.setTag("PartyQuests", NBTTags.nbtStringIntegerMap(partyQuests));
public NBTTagCompound writeNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Categories", NBTTags.nbtVectorMap(categories));
compound.setTag("Logs", NBTTags.nbtStringStringMap(questText));
compound.setTag("Alerts", NBTTags.nbtStringStringMap(questAlerts));
compound.setTag("Status", NBTTags.nbtVectorMap(questStatus));
compound.setTag("QuestFinisher", NBTTags.nbtStringStringMap(finish));
compound.setString("TrackedQuestID", trackedQuestKey);
compound.setTag("PartyQuests", NBTTags.nbtStringIntegerMap(partyQuests));
compound.setTag("PartyOptions", NBTTags.nbtVectorMap(partyOptions));
return compound;
}
return compound;
}
public void readNBT(NBTTagCompound compound){
categories = NBTTags.getVectorMap(compound.getTagList("Categories", 10));
questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10));
questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10));
finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10));
trackedQuestKey = compound.getString("TrackedQuestID");
partyQuests = NBTTags.getStringIntegerMap(compound.getTagList("PartyQuests", 10));
public void readNBT(NBTTagCompound compound) {
categories = NBTTags.getVectorMap(compound.getTagList("Categories", 10));
questText = NBTTags.getStringStringMap(compound.getTagList("Logs", 10));
questAlerts = NBTTags.getStringStringMap(compound.getTagList("Alerts", 10));
questStatus = NBTTags.getVectorMap(compound.getTagList("Status", 10));
finish = NBTTags.getStringStringMap(compound.getTagList("QuestFinisher", 10));
trackedQuestKey = compound.getString("TrackedQuestID");
partyQuests = NBTTags.getStringIntegerMap(compound.getTagList("PartyQuests", 10));
partyOptions = NBTTags.getVectorMap(compound.getTagList("PartyOptions", 10));
}
}
public NBTTagCompound writeTrackedQuest(){
public NBTTagCompound writeTrackedQuest() {
NBTTagCompound compound = new NBTTagCompound();
compound.setString("TrackedQuestID", trackedQuestKey);
return compound;
}
public void readTrackedQuest(NBTTagCompound compound){
public void readTrackedQuest(NBTTagCompound compound) {
trackedQuestKey = compound.getString("TrackedQuestID");
}
public void setData(EntityPlayer player){
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
public void setData(EntityPlayer player) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
for(Quest quest : PlayerQuestController.getActiveQuests(player))
{
String category = quest.category.title;
if(!categories.containsKey(category))
categories.put(category, new Vector<String>());
Vector<String> list = categories.get(category);
list.add(quest.title);
for (Quest quest : PlayerQuestController.getActiveQuests(player)) {
String category = quest.category.title;
if (!categories.containsKey(category))
categories.put(category, new Vector<String>());
Vector<String> list = categories.get(category);
list.add(quest.title);
String key = category + ":" + quest.title;
questText.put(key, quest.logText);
questAlerts.put(key, String.valueOf(playerData.questData.activeQuests.get(quest.id).sendAlerts));
questStatus.put(key, quest.questInterface.getQuestLogStatus(player));
if(quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
finish.put(key, quest.completerNpc);
questText.put(key, quest.logText);
questAlerts.put(key, String.valueOf(playerData.questData.activeQuests.get(quest.id).sendAlerts));
questStatus.put(key, quest.questInterface.getQuestLogStatus(player));
if (quest.completion == EnumQuestCompletion.Npc && quest.questInterface.isCompleted(playerData))
finish.put(key, quest.completerNpc);
if (playerData.questData.getTrackedQuest() != null) {
if (quest.id == playerData.questData.getTrackedQuest().getId()) {
trackedQuestKey = key;
}
}
if (playerData.questData.getTrackedQuest() != null) {
if (quest.id == playerData.questData.getTrackedQuest().getId()) {
trackedQuestKey = key;
}
}
if (quest.partyOptions.allowParty) {
partyQuests.put(key, quest.id);
if (quest.partyOptions.allowParty) {
partyQuests.put(key, quest.id);
partyOptions.put(key, quest.partyOptions.getPartyOptionsList());
}
}
}
Party party = playerData.getPlayerParty();
if(party != null && party.getQuest() != null){
if (party != null && party.getQuest() != null) {
if (playerData.questData.getTrackedQuest() != null) {
if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) {
trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName();
}
}
}
}
}
public void setTrackedQuestKey(EntityPlayer player){
public void setTrackedQuestKey(EntityPlayer player) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
Party party = playerData.getPlayerParty();
if(party != null && party.getQuest() != null){
if (party != null && party.getQuest() != null) {
if (playerData.questData.getTrackedQuest() != null) {
if (party.getQuest().getId() == playerData.questData.getTrackedQuest().getId()) {
trackedQuestKey = "P" + ":" + party.getQuest().getCategory().getName() + ":" + party.getQuest().getName();
}
}
} else if(playerData.questData != null && playerData.questData.getTrackedQuest() != null){
} else if (playerData.questData != null && playerData.questData.getTrackedQuest() != null) {
IQuest quest = playerData.questData.getTrackedQuest();
trackedQuestKey = quest.getCategory().getName() + ":" + quest.getName();
}
else {
} else {
trackedQuestKey = "";
}
}
public boolean hasSelectedQuest() {
return !selectedQuest.isEmpty();
}
public boolean hasSelectedQuest() {
return !selectedQuest.isEmpty();
}
public String getQuestText() {
return questText.get(selectedCategory + ":" + selectedQuest);
}
public String getQuestText() {
return questText.get(selectedCategory + ":" + selectedQuest);
}
public Boolean getQuestAlerts() {
return Boolean.valueOf(questAlerts.get(selectedCategory+":"+selectedQuest));
}
public Boolean getQuestAlerts() {
return Boolean.valueOf(questAlerts.get(selectedCategory + ":" + selectedQuest));
}
public void toggleQuestAlerts() {
questAlerts.put(selectedCategory+":"+selectedQuest,String.valueOf(!getQuestAlerts()));
}
public void toggleQuestAlerts() {
questAlerts.put(selectedCategory + ":" + selectedQuest, String.valueOf(!getQuestAlerts()));
}
public Vector<String> getQuestStatus() {
return questStatus.get(selectedCategory + ":" + selectedQuest);
}
public Vector<String> getQuestStatus() {
return questStatus.get(selectedCategory + ":" + selectedQuest);
}
public String getComplete() {
return finish.get(selectedCategory + ":" + selectedQuest);
}
public String getComplete() {
return finish.get(selectedCategory + ":" + selectedQuest);
}
public Vector<String> getPartyOptions() {
return partyOptions.get(selectedCategory + ":" + selectedQuest);
+36 -38
View File
@@ -5,47 +5,45 @@ import net.minecraft.util.DamageSource;
public class Resistances {
public float knockback = 1f;
public float arrow = 1f;
public float playermelee = 1f;
public float explosion = 1f;
public float knockback = 1f;
public float arrow = 1f;
public float playermelee = 1f;
public float explosion = 1f;
public boolean disableDamage = false;
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setFloat("Knockback", knockback);
compound.setFloat("Arrow", arrow);
compound.setFloat("Melee", playermelee);
compound.setFloat("Explosion", explosion);
compound.setBoolean("disableDamage", disableDamage);
return compound;
}
public boolean disableDamage = false;
public void readToNBT(NBTTagCompound compound) {
knockback = compound.getFloat("Knockback");
arrow = compound.getFloat("Arrow");
playermelee = compound.getFloat("Melee");
explosion = compound.getFloat("Explosion");
disableDamage = compound.getBoolean("disableDamage");
}
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setFloat("Knockback", knockback);
compound.setFloat("Arrow", arrow);
compound.setFloat("Melee", playermelee);
compound.setFloat("Explosion", explosion);
compound.setBoolean("disableDamage", disableDamage);
return compound;
}
public float applyResistance(DamageSource source, float damage) {
if(disableDamage){
return 0;
}
public void readToNBT(NBTTagCompound compound) {
knockback = compound.getFloat("Knockback");
arrow = compound.getFloat("Arrow");
playermelee = compound.getFloat("Melee");
explosion = compound.getFloat("Explosion");
disableDamage = compound.getBoolean("disableDamage");
}
if(source.damageType.equals("arrow") || source.damageType.equals("thrown")){
damage *= (2 - arrow);
}
else if(source.damageType.equals("player") || source.damageType.equals("mob")){
damage *= (2 - playermelee);
}
else if(source.damageType.equals("explosion") || source.damageType.equals("explosion.player")){
damage *= (2 - explosion);
}
return damage;
}
public float applyResistance(DamageSource source, float damage) {
if (disableDamage) {
return 0;
}
if (source.damageType.equals("arrow") || source.damageType.equals("thrown")) {
damage *= (2 - arrow);
} else if (source.damageType.equals("player") || source.damageType.equals("mob")) {
damage *= (2 - playermelee);
} else if (source.damageType.equals("explosion") || source.damageType.equals("explosion.player")) {
damage *= (2 - explosion);
}
return damage;
}
}
@@ -35,22 +35,22 @@ public class ScriptForgeEventHandler {
@SubscribeEvent
public void forgeEntity(Event event) {
if(CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
if(event instanceof TickEvent && !(((TickEvent)event).side == Side.SERVER && ((TickEvent)event).phase == TickEvent.Phase.START)) {
if (CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
if (event instanceof TickEvent && !(((TickEvent) event).side == Side.SERVER && ((TickEvent) event).phase == TickEvent.Phase.START)) {
return;
}
if(event instanceof EntityEvent) {
EntityEvent ev2 = (EntityEvent)event;
if(ev2.entity != null && ev2.entity.worldObj instanceof WorldServer) {
if (event instanceof EntityEvent) {
EntityEvent ev2 = (EntityEvent) event;
if (ev2.entity != null && ev2.entity.worldObj instanceof WorldServer) {
EventHooks.onForgeEntityEvent(ev2);
}
} else if(event instanceof WorldEvent) {
WorldEvent ev1 = (WorldEvent)event;
if(ev1.world instanceof WorldServer) {
} else if (event instanceof WorldEvent) {
WorldEvent ev1 = (WorldEvent) event;
if (ev1.world instanceof WorldServer) {
EventHooks.onForgeWorldEvent(ev1);
}
} else if(!(event instanceof TickEvent) || ((TickEvent)event).side != Side.CLIENT) {
} else if (!(event instanceof TickEvent) || ((TickEvent) event).side != Side.CLIENT) {
if (event instanceof PlayerEvent) {
PlayerEvent ev = (PlayerEvent) event;
if (ev.player == null || !(ev.player.worldObj instanceof WorldServer)) {
@@ -74,21 +74,21 @@ public class ScriptForgeEventHandler {
list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen"));
Iterator e1 = list.iterator();
while(true) {
while (true) {
ClassPath.ClassInfo classLoader;
String classes;
do {
if(!e1.hasNext()) {
if(PixelmonHelper.Enabled) {
if (!e1.hasNext()) {
if (PixelmonHelper.Enabled) {
try {
Field e2 = ClassLoader.class.getDeclaredField("classes");
e2.setAccessible(true);
ClassLoader classLoader1 = Thread.currentThread().getContextClassLoader();
ArrayList classes1 = new ArrayList((Vector)e2.get(classLoader1));
ArrayList classes1 = new ArrayList((Vector) e2.get(classLoader1));
Iterator infoClass1 = classes1.iterator();
while(infoClass1.hasNext()) {
Class c2 = (Class)infoClass1.next();
while (infoClass1.hasNext()) {
Class c2 = (Class) infoClass1.next();
}
} catch (Exception var12) {
var12.printStackTrace();
@@ -100,20 +100,20 @@ public class ScriptForgeEventHandler {
return this;
}
classLoader = (ClassPath.ClassInfo)e1.next();
classLoader = (ClassPath.ClassInfo) e1.next();
classes = classLoader.getName();
} while(classes.startsWith("net.minecraftforge.event.terraingen"));
} while (classes.startsWith("net.minecraftforge.event.terraingen"));
Class infoClass = classLoader.load();
ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses()));
if(c.isEmpty()) {
if (c.isEmpty()) {
c.add(infoClass);
}
Iterator var10 = c.iterator();
while(var10.hasNext()) {
Class c1 = (Class)var10.next();
if(!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) {
while (var10.hasNext()) {
Class c1 = (Class) var10.next();
if (!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) {
register.invoke(FMLCommonHandler.instance().bus(), new Object[]{c1, this, e, Loader.instance().activeModContainer()});
}
}
@@ -123,4 +123,4 @@ public class ScriptForgeEventHandler {
return this;
}
}
}
}
@@ -23,11 +23,12 @@ import noppes.npcs.scripted.event.ItemEvent;
import java.util.HashMap;
public class ScriptItemEventHandler {
public ScriptItemEventHandler() {}
public ScriptItemEventHandler() {
}
@SubscribeEvent
public void invoke(LivingEvent.LivingUpdateEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null || event.entityLiving instanceof EntityPlayer || event.entityLiving.ticksExisted%10 != 0)
if (event.entityLiving == null || event.entityLiving.worldObj == null || event.entityLiving instanceof EntityPlayer || event.entityLiving.ticksExisted % 10 != 0)
return;
if (event.entityLiving instanceof EntityCustomNpc) {
@@ -43,7 +44,7 @@ public class ScriptItemEventHandler {
}
}
}
} else if(event.entityLiving.getHeldItem() != null && NoppesUtilServer.isScriptableItem(event.entityLiving.getHeldItem().getItem()) && !event.isCanceled()) {
} else if (event.entityLiving.getHeldItem() != null && NoppesUtilServer.isScriptableItem(event.entityLiving.getHeldItem().getItem()) && !event.isCanceled()) {
IItemStack itemStack = NpcAPI.Instance().getIItemStack(event.entityLiving.getHeldItem());
EventHooks.onScriptItemUpdate((IItemCustomizable) itemStack, event.entityLiving);
}
@@ -51,177 +52,186 @@ public class ScriptItemEventHandler {
@SubscribeEvent
public void invoke(ItemTossEvent event) {
if(event.player == null || event.player.worldObj == null)
if (event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
if (event.player.worldObj instanceof WorldServer) {
try {
if (NoppesUtilServer.isScriptableItem(event.entityItem.getEntityItem().getItem()) && !event.isCanceled()) {
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityItem.getEntityItem());
if(isw instanceof IItemCustomizable)
if (isw instanceof IItemCustomizable)
event.setCanceled(EventHooks.onScriptItemTossed((IItemCustomizable) isw, event.player, event.entityItem));
}
} catch (Exception e) {}
} catch (Exception e) {
}
}
}
@SubscribeEvent
public void invoke(PlayerEvent.ItemPickupEvent event) {
if(event.player == null || event.player.worldObj == null)
if (event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
if (event.player.worldObj instanceof WorldServer) {
try {
if (NoppesUtilServer.isScriptableItem(event.player.getHeldItem().getItem()) && !event.isCanceled()) {
IItemStack isw = NpcAPI.Instance().getIItemStack(event.player.getHeldItem());
if(isw instanceof IItemCustomizable)
if (isw instanceof IItemCustomizable)
EventHooks.onScriptItemPickedUp((IItemCustomizable) isw, event.player);
}
} catch(Exception e) {}
} catch (Exception e) {
}
}
}
@SubscribeEvent
public void invoke(EntityJoinWorldEvent event) {
if (!event.world.isRemote && event.entity instanceof EntityItem) {
EntityItem entity = (EntityItem)event.entity;
EntityItem entity = (EntityItem) event.entity;
ItemStack stack = entity.getEntityItem();
try {
if (stack.stackSize > 0 && NoppesUtilServer.isScriptableItem(stack.getItem())) {
if (stack.stackSize > 0 && NoppesUtilServer.isScriptableItem(stack.getItem())) {
IItemStack isw = NpcAPI.Instance().getIItemStack(stack);
if(isw instanceof IItemCustomizable){
if(EventHooks.onScriptItemSpawn((IItemCustomizable) isw, entity)){
if (isw instanceof IItemCustomizable) {
if (EventHooks.onScriptItemSpawn((IItemCustomizable) isw, entity)) {
event.setCanceled(true);
}
}
}
} catch(Exception e) {}
} catch (Exception e) {
}
}
}
@SubscribeEvent
public void invoke(EntityInteractEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
try {
if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) {
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem());
if(isw instanceof IItemCustomizable){
if (isw instanceof IItemCustomizable) {
ItemEvent.InteractEvent eve = new ItemEvent.InteractEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIEntity(event.target));
event.setCanceled(EventHooks.onScriptItemInteract((IItemCustomizable) isw, eve));
ItemEvent.RightClickEvent rightClickEvent = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 1, NpcAPI.Instance().getIEntity(event.target));
ItemEvent.RightClickEvent rightClickEvent = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 1, NpcAPI.Instance().getIEntity(event.target));
event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustomizable) isw, rightClickEvent));
}
}
} catch(Exception e) {}
} catch (Exception e) {
}
}
}
@SubscribeEvent
public void invoke(PlayerInteractEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null || event.action == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null || event.action == null)
return;
if(event.entityPlayer.worldObj.isRemote || !(event.entityPlayer.worldObj instanceof WorldServer))
if (event.entityPlayer.worldObj.isRemote || !(event.entityPlayer.worldObj instanceof WorldServer))
return;
if (PlayerDataController.Instance != null) {
if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR){
if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) {
PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
if(handler == null)
if (handler == null)
return;
if(handler.hadInteract) {
if (handler.hadInteract) {
handler.hadInteract = false;
return;
}
try {
if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) {
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem());
if(isw instanceof IItemCustomizable){
if (isw instanceof IItemCustomizable) {
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 0, null);
event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustomizable) isw, eve));
}
}
} catch(Exception e) {}
}
else if(event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK){
} catch (Exception e) {
}
} else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
PlayerData handler = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
if(handler == null)
if (handler == null)
return;
handler.hadInteract = true;
try {
if (NoppesUtilServer.isScriptableItem(event.entityPlayer.getHeldItem().getItem()) && !event.isCanceled()) {
IItemStack isw = NpcAPI.Instance().getIItemStack(event.entityPlayer.getHeldItem());
if(isw instanceof IItemCustomizable){
if (isw instanceof IItemCustomizable) {
ItemEvent.RightClickEvent eve = new ItemEvent.RightClickEvent((IItemCustomizable) isw, (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer), 2, NpcAPI.Instance().getIBlock((IWorld) NpcAPI.Instance().getIWorld(event.world), event.x, event.y, event.z));
event.setCanceled(EventHooks.onScriptItemRightClick((IItemCustomizable) isw, eve));
}
}
} catch(Exception e) {}
} catch (Exception e) {
}
}
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Start event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
if(isw instanceof IItemCustomizable){
if (isw instanceof IItemCustomizable) {
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStartUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration));
}
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Tick event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
if (event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
if(isw instanceof IItemCustomizable){
if (isw instanceof IItemCustomizable) {
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration));
}
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Stop event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
if (event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
if(isw instanceof IItemCustomizable){
if (isw instanceof IItemCustomizable) {
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStopUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration));
}
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Finish event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
if (event.entityPlayer.worldObj instanceof WorldServer && NoppesUtilServer.isScriptableItem(event.item.getItem())) {
IItemStack isw = NpcAPI.Instance().getIItemStack(event.item);
if(isw instanceof IItemCustomizable){
if (isw instanceof IItemCustomizable) {
IPlayer IPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onFinishUsingCustomItem((IItemCustomizable) isw, IPlayer, event.duration);
}
}
}
@SubscribeEvent
public void invoke(AnvilRepairEvent repairEvent) {
IItemStack output = NpcAPI.Instance().getIItemStack(repairEvent.output);
@@ -5,7 +5,9 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.relauncher.Side;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.SyncController;
import kamkeel.npcs.util.AttributeAttackUtil;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -23,8 +25,6 @@ import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.world.BlockEvent;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.item.IItemCustomizable;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.util.AttributeAttackUtil;
import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.CustomEffectController;
@@ -42,6 +42,7 @@ import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
public class ScriptPlayerEventHandler {
public ScriptPlayerEventHandler() {
}
@SubscribeEvent
public void onServerTick(TickEvent.PlayerTickEvent event) {
if (event.player == null || event.player.worldObj == null)
@@ -55,23 +56,23 @@ public class ScriptPlayerEventHandler {
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player);
EventHooks.onPlayerTick(handler, scriptPlayer);
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack item = player.inventory.getStackInSlot(i);
if(item != null && NoppesUtilServer.isScriptableItem(item.getItem())){
if (item != null && NoppesUtilServer.isScriptableItem(item.getItem())) {
IItemCustomizable isw = (IItemCustomizable) NpcAPI.Instance().getIItemStack(item);
EventHooks.onScriptItemUpdate(isw, player);
}
}
if(ConfigMain.AttributesEnabled)
if (ConfigMain.AttributesEnabled)
AttributeController.getTracker(player).updateIfChanged(player);
}
if (PlayerDataController.Instance != null) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(player);
if(playerData.updateClient) {
SyncController.syncPlayerData((EntityPlayerMP)player, true);
if (playerData.updateClient) {
SyncController.syncPlayerData((EntityPlayerMP) player, true);
playerData.updateClient = false;
}
@@ -79,7 +80,7 @@ public class ScriptPlayerEventHandler {
playerData.timers.update();
}
if(player.ticksExisted % 10 == 0)
if (player.ticksExisted % 10 == 0)
SyncController.syncEffects((EntityPlayerMP) player);
if (player.ticksExisted % 10 == 0)
@@ -100,12 +101,11 @@ public class ScriptPlayerEventHandler {
if (player.ticksExisted % (TrackedQuestUpdateFrequency * 20) == 0) {
PlayerQuestData questData = playerData.questData;
if(questData != null){
if (questData != null) {
if (questData.getTrackedQuest() != null && ((Quest) questData.getTrackedQuest()).type == EnumQuestType.Item) {
if(trackingPartyQuest){
if (trackingPartyQuest) {
NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) event.player, party);
}
else {
} else {
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
}
}
@@ -117,10 +117,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(EntityInteractEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target));
@@ -130,10 +130,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(ArrowNockEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer);
@@ -143,10 +143,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(ArrowLooseEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
if (!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge);
@@ -156,18 +156,18 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(BlockEvent.BreakEvent event) {
if(event.getPlayer() == null || event.getPlayer().worldObj == null)
if (event.getPlayer() == null || event.getPlayer().worldObj == null)
return;
if(event.getPlayer().getHeldItem() != null && event.getPlayer().getHeldItem().getItem() instanceof ItemNpcTool){
if (event.getPlayer().getHeldItem() != null && event.getPlayer().getHeldItem().getItem() instanceof ItemNpcTool) {
event.setCanceled(true);
return;
}
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
if (!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.getPlayer());
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(NpcAPI.Instance().getIWorld(event.world), NpcAPI.Instance().getIPos(event.x,event.y,event.z)), event.getExpToDrop());
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(NpcAPI.Instance().getIWorld(event.world), NpcAPI.Instance().getIPos(event.x, event.y, event.z)), event.getExpToDrop());
event.setCanceled(EventHooks.onPlayerBreak(handler, ev));
event.setExpToDrop(ev.exp);
}
@@ -175,43 +175,46 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Start event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Tick event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Stop event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Finish event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item);
@@ -220,10 +223,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerDropsEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops));
@@ -232,10 +235,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerPickupXpEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb);
@@ -244,10 +247,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) {
if(event.player == null || event.player.worldObj == null)
if (event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
if (event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim);
@@ -256,16 +259,16 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerEvent.ItemPickupEvent event) {
if(event.player == null || event.player.worldObj == null)
if (event.player == null || event.player.worldObj == null)
return;
if(!event.player.worldObj.isRemote && !(event.player instanceof FakePlayer)){
if (!event.player.worldObj.isRemote && !(event.player instanceof FakePlayer)) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
PlayerQuestData questData = playerData.questData;
QuestItem.pickedUp = event.pickedUp.getEntityItem();
Party playerParty = playerData.getPlayerParty();
if(playerParty != null){
if (playerParty != null) {
QuestItem.pickedUpParty = event.pickedUp.getEntityItem();
QuestItem.pickedUpPlayer = event.player;
PartyController.Instance().checkQuestCompletion(playerParty, EnumQuestType.Item);
@@ -274,7 +277,7 @@ public class ScriptPlayerEventHandler {
questData.checkQuestCompletion(playerData, EnumQuestType.Item);
}
if(event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayer) {
if (event.player.worldObj instanceof WorldServer && event.player instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp);
@@ -283,10 +286,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerOpenContainerEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) {
if (event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer);
@@ -295,10 +298,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(UseHoeEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z);
@@ -307,10 +310,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerSleepInBedEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z);
@@ -319,10 +322,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerWakeUpEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn);
@@ -331,10 +334,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(FillBucketEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result);
@@ -343,10 +346,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(BonemealEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world);
@@ -355,10 +358,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(AchievementEvent event) {
if(event.entityPlayer == null || event.entityPlayer.worldObj == null)
if (event.entityPlayer == null || event.entityPlayer.worldObj == null)
return;
if(event.entityPlayer.worldObj instanceof WorldServer) {
if (event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityPlayer);
EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement));
@@ -367,10 +370,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(ItemTossEvent event) {
if(event.player == null || event.player.worldObj == null)
if (event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
if (event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
event.setCanceled(EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem));
@@ -379,10 +382,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(LivingFallEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
if (event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
@@ -393,10 +396,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(LivingEvent.LivingJumpEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
if (event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
@@ -407,10 +410,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(EntityStruckByLightningEvent event) {
if(event.entity == null || event.entity.worldObj == null)
if (event.entity == null || event.entity.worldObj == null)
return;
if(event.entity.worldObj instanceof WorldServer) {
if (event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity);
@@ -421,38 +424,39 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlaySoundAtEntityEvent event) {
if(event.entity == null || event.entity.worldObj == null)
if (event.entity == null || event.entity.worldObj == null)
return;
if(event.entity.worldObj instanceof WorldServer) {
if (event.entity.worldObj instanceof WorldServer) {
if (event.entity instanceof EntityPlayer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entity);
EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume);
EventHooks.onPlayerSound(handler, scriptPlayer, event.name, event.pitch, event.volume);
}
}
}
@SubscribeEvent
public void invoke(LivingDeathEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
if (event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving.worldObj instanceof WorldServer) {
Entity source = NoppesUtilServer.GetDamageSource(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
if (event.entityLiving instanceof EntityPlayer) {
try {
CustomEffectController.getInstance().killEffects((EntityPlayer) event.entityLiving);
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.entityLiving);
EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source);
} catch (Exception ignored) {}
EventHooks.onPlayerDeath(handler, scriptPlayer, event.source, source);
} catch (Exception ignored) {
}
}
if(event.source.getEntity() instanceof EntityPlayer) {
if (event.source.getEntity() instanceof EntityPlayer) {
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.source.getEntity());
EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving);
EventHooks.onPlayerKills(handler, scriptPlayer, event.entityLiving);
}
}
@@ -460,24 +464,24 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(LivingAttackEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
if (event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving.worldObj instanceof WorldServer) {
boolean cancel = event.isCanceled();
Entity source = NoppesUtilServer.GetDamageSource(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.AttackedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.AttackedEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
if (event.entityLiving instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.AttackedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.AttackedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayer) event.entityLiving), source, event.ammount, event.source);
cancel = EventHooks.onPlayerAttacked(handler, pevent);
}
if(event.source.getEntity() instanceof EntityPlayer) {
if (event.source.getEntity() instanceof EntityPlayer) {
float attackAmount = event.ammount;
if(ConfigMain.AttributesEnabled)
if (ConfigMain.AttributesEnabled)
attackAmount = AttributeAttackUtil.calculateOutgoing((EntityPlayer) event.source.getEntity(), attackAmount);
noppes.npcs.scripted.event.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.AttackEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, attackAmount, event.source);
noppes.npcs.scripted.event.PlayerEvent.AttackEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.AttackEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayer) event.source.getEntity()), event.entityLiving, attackAmount, event.source);
cancel = cancel || EventHooks.onPlayerAttack(handler, pevent1);
}
event.setCanceled(cancel);
@@ -486,31 +490,31 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(LivingHurtEvent event) {
if(event.entityLiving == null || event.entityLiving.worldObj == null)
if (event.entityLiving == null || event.entityLiving.worldObj == null)
return;
if(event.entityLiving.worldObj instanceof WorldServer) {
if (event.entityLiving.worldObj instanceof WorldServer) {
boolean cancel = event.isCanceled();
Entity source = NoppesUtilServer.GetDamageSource(event.source);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
// Player to Player Interaction
if(ConfigMain.AttributesEnabled){
if(event.entityLiving instanceof EntityPlayer && source instanceof EntityPlayer){
if (ConfigMain.AttributesEnabled) {
if (event.entityLiving instanceof EntityPlayer && source instanceof EntityPlayer) {
event.ammount = AttributeAttackUtil.calculateDamagePlayerToPlayer((EntityPlayer) event.entityLiving, (EntityPlayer) source, event.ammount);
} else if (!(event.entityLiving instanceof EntityNPCInterface) && source instanceof EntityPlayer){
} else if (!(event.entityLiving instanceof EntityNPCInterface) && source instanceof EntityPlayer) {
event.ammount = AttributeAttackUtil.calculateOutgoing((EntityPlayer) source, event.ammount);
}
}
if(event.entityLiving instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((IPlayer)NpcAPI.Instance().getIEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
if (event.entityLiving instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((IPlayer) NpcAPI.Instance().getIEntity((EntityPlayer) event.entityLiving), source, event.ammount, event.source);
cancel = EventHooks.onPlayerDamaged(handler, pevent);
event.ammount = pevent.damage;
}
if(source instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer)NpcAPI.Instance().getIEntity(source), event.entityLiving, event.ammount, event.source);
if (source instanceof EntityPlayer) {
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((IPlayer) NpcAPI.Instance().getIEntity(source), event.entityLiving, event.ammount, event.source);
cancel = cancel || EventHooks.onPlayerDamagedEntity(handler, pevent1);
event.ammount = pevent1.damage;
}
@@ -521,10 +525,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerEvent.PlayerRespawnEvent event) {
if(event.player == null || event.player.worldObj == null)
if (event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
if (event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerRespawn(handler, scriptPlayer);
@@ -533,22 +537,21 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerEvent.PlayerLoggedInEvent event) {
if(event.player == null || event.player.worldObj == null)
if (event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
if (event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerLogin(handler, scriptPlayer);
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
Quest quest = (Quest) playerData.questData.getTrackedQuest();
if (quest != null) {
Party party = playerData.getPlayerParty();
if(party != null && party.getQuest() != null && party.getQuest().getId() == quest.getId()){
if (party != null && party.getQuest() != null && party.getQuest().getId() == quest.getId()) {
NoppesUtilPlayer.sendPartyTrackedQuestData((EntityPlayerMP) event.player, party);
}
else {
} else {
NoppesUtilPlayer.sendTrackedQuestData((EntityPlayerMP) event.player);
}
}
@@ -559,10 +562,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerEvent.PlayerLoggedOutEvent event) {
if(event.player == null || event.player.worldObj == null)
if (event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer) {
if (event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
EventHooks.onPlayerLogout(handler, scriptPlayer);
@@ -570,20 +573,20 @@ public class ScriptPlayerEventHandler {
}
@SubscribeEvent(
priority = EventPriority.HIGHEST
priority = EventPriority.HIGHEST
)
public void invoke(net.minecraftforge.event.ServerChatEvent event) {
if(event.player == null || event.player.worldObj == null)
if (event.player == null || event.player.worldObj == null)
return;
if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
if (event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(event.player);
String message = event.message;
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message);
EventHooks.onPlayerChat(handler, ev);
event.setCanceled(ev.isCanceled());
if(!message.equals(ev.message)) {
if (!message.equals(ev.message)) {
ChatComponentTranslation chat = new ChatComponentTranslation("", new Object[0]);
chat.appendSibling(ForgeHooks.newChatWithLinks(ev.message));
event.component = chat;
+42 -45
View File
@@ -12,57 +12,54 @@ import java.util.List;
import java.util.Map;
public class Server {
public static boolean fillBuffer(ByteBuf buffer, Enum enu, Object... obs) throws IOException{
buffer.writeInt(enu.ordinal());
for(Object ob : obs){
if(ob == null)
continue;
if(ob instanceof Map){
Map<String,Integer> map = (Map<String, Integer>) ob;
public static boolean fillBuffer(ByteBuf buffer, Enum enu, Object... obs) throws IOException {
buffer.writeInt(enu.ordinal());
for (Object ob : obs) {
if (ob == null)
continue;
if (ob instanceof Map) {
Map<String, Integer> map = (Map<String, Integer>) ob;
buffer.writeInt(map.size());
for(String key : map.keySet()){
int value = map.get(key);
buffer.writeInt(value);
ByteBufUtils.writeString(buffer, key);
}
}
else if(ob instanceof MerchantRecipeList)
((MerchantRecipeList)ob).func_151391_a(new PacketBuffer(buffer));
else if(ob instanceof List){
List<String> list = (List<String>) ob;
buffer.writeInt(list.size());
for(String s : list)
ByteBufUtils.writeString(buffer, s);
}
else if(ob instanceof Enum)
buffer.writeInt(((Enum<?>) ob).ordinal());
else if(ob instanceof Integer)
buffer.writeInt((Integer) ob);
else if(ob instanceof Boolean)
buffer.writeBoolean((Boolean) ob);
else if(ob instanceof String)
ByteBufUtils.writeString(buffer, (String) ob);
else if(ob instanceof Float)
buffer.writeFloat((Float) ob);
else if(ob instanceof Long)
buffer.writeLong((Long) ob);
else if(ob instanceof Double)
buffer.writeDouble((Double) ob);
buffer.writeInt(map.size());
for (String key : map.keySet()) {
int value = map.get(key);
buffer.writeInt(value);
ByteBufUtils.writeString(buffer, key);
}
} else if (ob instanceof MerchantRecipeList)
((MerchantRecipeList) ob).func_151391_a(new PacketBuffer(buffer));
else if (ob instanceof List) {
List<String> list = (List<String>) ob;
buffer.writeInt(list.size());
for (String s : list)
ByteBufUtils.writeString(buffer, s);
} else if (ob instanceof Enum)
buffer.writeInt(((Enum<?>) ob).ordinal());
else if (ob instanceof Integer)
buffer.writeInt((Integer) ob);
else if (ob instanceof Boolean)
buffer.writeBoolean((Boolean) ob);
else if (ob instanceof String)
ByteBufUtils.writeString(buffer, (String) ob);
else if (ob instanceof Float)
buffer.writeFloat((Float) ob);
else if (ob instanceof Long)
buffer.writeLong((Long) ob);
else if (ob instanceof Double)
buffer.writeDouble((Double) ob);
else if (ob instanceof byte[]) {
// Write byte array length followed by bytes
byte[] byteArray = (byte[]) ob;
buffer.writeShort((short) byteArray.length);
buffer.writeBytes(byteArray);
}
else if(ob instanceof NBTTagCompound)
ByteBufUtils.writeNBT(buffer, (NBTTagCompound) ob);
}
if(buffer.array().length >= 32767){
LogWriter.error("Packet " + enu + " was too big to be send");
LogWriter.script( "Issue occurred with the following Packet - " + enu + ":\n" + Arrays.toString(obs));
} else if (ob instanceof NBTTagCompound)
ByteBufUtils.writeNBT(buffer, (NBTTagCompound) ob);
}
if (buffer.array().length >= 32767) {
LogWriter.error("Packet " + enu + " was too big to be send");
LogWriter.script("Issue occurred with the following Packet - " + enu + ":\n" + Arrays.toString(obs));
return false;
}
}
return true;
}
}
}
+255 -261
View File
@@ -63,247 +63,242 @@ import java.util.List;
public class ServerEventsHandler {
public static EntityVillager Merchant;
public static Entity mounted;
public static EntityVillager Merchant;
public static Entity mounted;
@SubscribeEvent
public void invoke(EntityInteractEvent event) {
ItemStack item = event.entityPlayer.getCurrentEquippedItem();
if(item == null)
return;
boolean isRemote = event.entityPlayer.worldObj.isRemote;
boolean npcInteracted = event.target instanceof EntityNPCInterface;
@SubscribeEvent
public void invoke(EntityInteractEvent event) {
ItemStack item = event.entityPlayer.getCurrentEquippedItem();
if (item == null)
return;
boolean isRemote = event.entityPlayer.worldObj.isRemote;
boolean npcInteracted = event.target instanceof EntityNPCInterface;
if(!isRemote && ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(event.entityPlayer.getGameProfile())){
return;
}
if (!isRemote && ConfigMain.OpsOnly && !MinecraftServer.getServer().getConfigurationManager().func_152596_g(event.entityPlayer.getGameProfile())) {
return;
}
if(!isRemote && item.getItem() == CustomItems.soulstoneEmpty) {
if(event.target instanceof EntityLivingBase){
((ItemSoulstoneEmpty)item.getItem()).store((EntityLivingBase)event.target, item, event.entityPlayer);
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
if (!isRemote && item.getItem() == CustomItems.soulstoneEmpty) {
if (event.target instanceof EntityLivingBase) {
((ItemSoulstoneEmpty) item.getItem()).store((EntityLivingBase) event.target, item, event.entityPlayer);
if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
LogWriter.script(String.format("[%s] (Player) %s PICKED ENTITY %s", "SOULSTONE", event.entityPlayer.getCommandSenderName(), event.target));
}
}
}
}
if(item.getItem() == CustomItems.wand && npcInteracted && !isRemote){
if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI)){
return;
}
event.setCanceled(true);
NoppesUtilServer.sendOpenGui(event.entityPlayer, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) event.target);
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
}
}
else if(item.getItem() == CustomItems.cloner && !isRemote && !(event.target instanceof EntityPlayer)){
if(!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_CLONER))
if (item.getItem() == CustomItems.wand && npcInteracted && !isRemote) {
if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.NPC_GUI)) {
return;
NBTTagCompound compound = new NBTTagCompound();
if(!event.target.writeToNBTOptional(compound))
return;
PlayerData data = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
ServerCloneController.Instance.cleanTags(compound);
PacketHandler.Instance.sendToPlayer(new ClonerPacket(compound), (EntityPlayerMP)event.entityPlayer);
data.cloned = compound;
if (event.target instanceof EntityNPCInterface) {
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target);
}
event.setCanceled(true);
}
else if(item.getItem() == CustomItems.scripter && !isRemote && npcInteracted){
if(!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_SCRIPTER))
return;
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface)event.target);
event.setCanceled(true);
GuiOpenPacket.openGUI((EntityPlayerMP)event.entityPlayer, EnumGuiType.Script, 0, 0, 0);
if(ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "SCRIPTER", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface)(event.target)).display.getName(), (int)(event.target).posX, (int)(event.target).posY, (int)(event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
}
}
else if(item.getItem() == CustomItems.mount){
if(!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER))
return;
event.setCanceled(true);
mounted = event.target;
if(isRemote)
CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer);
}
else if(item.getItem() == CustomItems.wand && !isRemote && event.target instanceof EntityVillager){
if(!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER))
return;
event.setCanceled(true);
Merchant = (EntityVillager)event.target;
}
event.setCanceled(true);
NoppesUtilServer.sendOpenGui(event.entityPlayer, EnumGuiType.MainMenuDisplay, (EntityNPCInterface) event.target);
if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "WAND", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface) (event.target)).display.getName(), (int) (event.target).posX, (int) (event.target).posY, (int) (event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
}
} else if (item.getItem() == CustomItems.cloner && !isRemote && !(event.target instanceof EntityPlayer)) {
if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_CLONER))
return;
NBTTagCompound compound = new NBTTagCompound();
if (!event.target.writeToNBTOptional(compound))
return;
PlayerData data = PlayerDataController.Instance.getPlayerData(event.entityPlayer);
ServerCloneController.Instance.cleanTags(compound);
PacketHandler.Instance.sendToPlayer(new ClonerPacket(compound), (EntityPlayerMP) event.entityPlayer);
data.cloned = compound;
if (event.target instanceof EntityNPCInterface) {
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target);
}
event.setCanceled(true);
} else if (item.getItem() == CustomItems.scripter && !isRemote && npcInteracted) {
if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_SCRIPTER))
return;
NoppesUtilServer.setEditingNpc(event.entityPlayer, (EntityNPCInterface) event.target);
event.setCanceled(true);
GuiOpenPacket.openGUI((EntityPlayerMP) event.entityPlayer, EnumGuiType.Script, 0, 0, 0);
if (ConfigDebug.PlayerLogging && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
LogWriter.script(String.format("[%s] (Player) %s OPEN NPC %s (%s, %s, %s) [%s]", "SCRIPTER", event.entityPlayer.getCommandSenderName(), ((EntityNPCInterface) (event.target)).display.getName(), (int) (event.target).posX, (int) (event.target).posY, (int) (event.target).posZ, (event.target).worldObj.getWorldInfo().getWorldName()));
}
} else if (item.getItem() == CustomItems.mount) {
if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.TOOL_MOUNTER))
return;
event.setCanceled(true);
mounted = event.target;
if (isRemote)
CustomNpcs.proxy.openGui(MathHelper.floor_double(mounted.posX), MathHelper.floor_double(mounted.posY), MathHelper.floor_double(mounted.posZ), EnumGuiType.MobSpawnerMounter, event.entityPlayer);
} else if (item.getItem() == CustomItems.wand && !isRemote && event.target instanceof EntityVillager) {
if (!CustomNpcsPermissions.hasPermission(event.entityPlayer, CustomNpcsPermissions.EDIT_VILLAGER))
return;
event.setCanceled(true);
Merchant = (EntityVillager) event.target;
if(!isRemote){
EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0);
MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player);
if (!isRemote) {
EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
player.openGui(CustomNpcs.instance, EnumGuiType.MerchantAdd.ordinal(), player.worldObj, 0, 0, 0);
MerchantRecipeList merchantrecipelist = Merchant.getRecipes(player);
if (merchantrecipelist != null)
{
if (merchantrecipelist != null) {
PacketHandler.Instance.sendToPlayer(new VillagerListPacket(merchantrecipelist), player);
}
}
}
}
}
}
}
}
@SubscribeEvent
public void partyDamagedEvent(LivingAttackEvent event) {
if(!(event.source != null && event.source.getEntity() instanceof EntityPlayer) || !(event.entityLiving instanceof EntityPlayer) || FMLCommonHandler.instance().getEffectiveSide().isClient())
return;
@SubscribeEvent
public void partyDamagedEvent(LivingAttackEvent event) {
if (!(event.source != null && event.source.getEntity() instanceof EntityPlayer) || !(event.entityLiving instanceof EntityPlayer) || FMLCommonHandler.instance().getEffectiveSide().isClient())
return;
// Check for Friendly Fire
if(ConfigMain.PartyFriendlyFireEnabled){
if (ConfigMain.PartyFriendlyFireEnabled) {
EntityPlayer sourcePlayer = (EntityPlayer) event.source.getEntity();
PlayerData playerData = PlayerDataController.Instance.getPlayerData(sourcePlayer);
PlayerData targetData = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entityLiving);
if (playerData.partyUUID != null && playerData.partyUUID.equals(targetData.partyUUID)) {
Party party = PartyController.Instance().getParty(playerData.partyUUID);
if(party != null && !party.friendlyFire())
if (party != null && !party.friendlyFire())
event.setCanceled(true);
}
}
}
}
@SubscribeEvent
public void invoke(LivingHurtEvent event) {
if(!(event.entityLiving instanceof EntityPlayer))
return;
@SubscribeEvent
public void invoke(LivingHurtEvent event) {
if (!(event.entityLiving instanceof EntityPlayer))
return;
EntityPlayer player = (EntityPlayer) event.entityLiving;
if(event.source.isUnblockable() || event.source.isFireDamage())
return;
if(!player.isBlocking())
return;
ItemStack item = player.getCurrentEquippedItem();
if(item == null || !(item.getItem() instanceof ItemShield))
return;
if(((ItemShield)item.getItem()).material.getDamageVsEntity() < player.getRNG().nextInt(9))
return;
float damage = item.getItemDamage() + event.ammount;
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (event.source.isUnblockable() || event.source.isFireDamage())
return;
if (!player.isBlocking())
return;
ItemStack item = player.getCurrentEquippedItem();
if (item == null || !(item.getItem() instanceof ItemShield))
return;
if (((ItemShield) item.getItem()).material.getDamageVsEntity() < player.getRNG().nextInt(9))
return;
float damage = item.getItemDamage() + event.ammount;
item.damageItem((int) event.ammount, player);
item.damageItem((int) event.ammount, player);
if(damage > item.getMaxDamage())
event.ammount = damage - item.getMaxDamage();
else{
event.ammount = 0;
event.setCanceled(true);
}
}
if (damage > item.getMaxDamage())
event.ammount = damage - item.getMaxDamage();
else {
event.ammount = 0;
event.setCanceled(true);
}
}
@SubscribeEvent
public void invoke(PlayerInteractEvent event) {
EntityPlayer player = event.entityPlayer;
Block block = player.worldObj.getBlock(event.x, event.y, event.z);
if(event.action == Action.LEFT_CLICK_BLOCK && player.getHeldItem() != null && player.getHeldItem().getItem() == CustomItems.teleporter){
event.setCanceled(true);
}
@SubscribeEvent
public void invoke(PlayerInteractEvent event) {
EntityPlayer player = event.entityPlayer;
Block block = player.worldObj.getBlock(event.x, event.y, event.z);
if (event.action == Action.LEFT_CLICK_BLOCK && player.getHeldItem() != null && player.getHeldItem().getItem() == CustomItems.teleporter) {
event.setCanceled(true);
}
if(block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
if (block == Blocks.crafting_table && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote) {
PacketHandler.Instance.sendToPlayer(new SyncPacket(
EnumSyncType.WORKBENCH_RECIPES,
EnumSyncAction.RELOAD,
-1,
SyncController.workbenchNBT()
), (EntityPlayerMP) player);
}
if(block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote){
}
if (block == CustomItems.carpentyBench && event.action == Action.RIGHT_CLICK_BLOCK && !player.worldObj.isRemote) {
PacketHandler.Instance.sendToPlayer(new SyncPacket(
EnumSyncType.CARPENTRY_RECIPES,
EnumSyncAction.RELOAD,
-1,
SyncController.carpentryNBT()
), (EntityPlayerMP) player);
}
if((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK){
ItemStack item = player.inventory.getCurrentItem();
if(item == null || item.getItem() == null)
return;
int y = event.y;
int meta = player.worldObj.getBlockMetadata(event.x, event.y, event.z);
if(meta >= 7)
y--;
ITileIcon tile = (ITileIcon)player.worldObj.getTileEntity(event.x, y, event.z);
if(!tile.canEdit()){
if(item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)){
tile.setTime(System.currentTimeMillis());
if(player.worldObj.isRemote)
player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
}
return;
}
}
if ((block == CustomItems.banner || block == CustomItems.wallBanner || block == CustomItems.sign) && event.action == Action.RIGHT_CLICK_BLOCK) {
ItemStack item = player.inventory.getCurrentItem();
if (item == null || item.getItem() == null)
return;
int y = event.y;
int meta = player.worldObj.getBlockMetadata(event.x, event.y, event.z);
if (meta >= 7)
y--;
ITileIcon tile = (ITileIcon) player.worldObj.getTileEntity(event.x, y, event.z);
if (!tile.canEdit()) {
if (item.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BLOCKS)) {
tile.setTime(System.currentTimeMillis());
if (player.worldObj.isRemote)
player.addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
}
return;
}
if(!player.worldObj.isRemote){
tile.setIcon(item.copy());
player.worldObj.markBlockForUpdate(event.x, y, event.z);
event.setCanceled(true);
}
}
}
if (!player.worldObj.isRemote) {
tile.setIcon(item.copy());
player.worldObj.markBlockForUpdate(event.x, y, event.z);
event.setCanceled(true);
}
}
}
@SubscribeEvent
public void invoke(LivingDeathEvent event) {
if(event.entityLiving.worldObj.isRemote)
return;
if(event.source.getEntity() != null){
if(event.source.getEntity() instanceof EntityPlayer){
doExcalibur((EntityPlayer) event.source.getEntity(),event.entityLiving);
}
@SubscribeEvent
public void invoke(LivingDeathEvent event) {
if (event.entityLiving.worldObj.isRemote)
return;
if (event.source.getEntity() != null) {
if (event.source.getEntity() instanceof EntityPlayer) {
doExcalibur((EntityPlayer) event.source.getEntity(), event.entityLiving);
}
if(event.source.getEntity() instanceof EntityNPCInterface){
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
Line line = npc.advanced.getKillLine();
if(line != null)
npc.saySurrounding(line.formatTarget(event.entityLiving));
if (event.source.getEntity() instanceof EntityNPCInterface) {
EntityNPCInterface npc = (EntityNPCInterface) event.source.getEntity();
Line line = npc.advanced.getKillLine();
if (line != null)
npc.saySurrounding(line.formatTarget(event.entityLiving));
EventHooks.onNPCKilledEntity(npc,event.entityLiving);
}
EventHooks.onNPCKilledEntity(npc, event.entityLiving);
}
EntityPlayer player = null;
if(event.source.getEntity() instanceof EntityPlayer)
player = (EntityPlayer) event.source.getEntity();
else if(event.source.getEntity() instanceof EntityNPCInterface && ((EntityNPCInterface)event.source.getEntity()).advanced.role == EnumRoleType.Follower)
player = ((RoleFollower)((EntityNPCInterface)event.source.getEntity()).roleInterface).owner;
if(player != null){
doQuest(player, event.entityLiving, true);
EntityPlayer player = null;
if (event.source.getEntity() instanceof EntityPlayer)
player = (EntityPlayer) event.source.getEntity();
else if (event.source.getEntity() instanceof EntityNPCInterface && ((EntityNPCInterface) event.source.getEntity()).advanced.role == EnumRoleType.Follower)
player = ((RoleFollower) ((EntityNPCInterface) event.source.getEntity()).roleInterface).owner;
if (player != null) {
doQuest(player, event.entityLiving, true);
if(event.entityLiving instanceof EntityNPCInterface)
doFactionPoints(player, (EntityNPCInterface)event.entityLiving);
}
}
if(event.entityLiving instanceof EntityPlayer){
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer)event.entityLiving);
data.save();
}
}
if (event.entityLiving instanceof EntityNPCInterface)
doFactionPoints(player, (EntityNPCInterface) event.entityLiving);
}
}
if (event.entityLiving instanceof EntityPlayer) {
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entityLiving);
data.save();
}
}
@SubscribeEvent
public void onPlayerClone(PlayerEvent.Clone event) {
if (event.entity.worldObj.isRemote)
return;
@SubscribeEvent
public void onPlayerClone(PlayerEvent.Clone event) {
if (event.entity.worldObj.isRemote)
return;
NBTTagCompound storedData = event.original.getEntityData().getCompoundTag("CNPCStoredData");
if (!storedData.hasNoTags()) {
event.entityPlayer.getEntityData().setTag("CNPCStoredData", storedData);
}
}
NBTTagCompound storedData = event.original.getEntityData().getCompoundTag("CNPCStoredData");
if (!storedData.hasNoTags()) {
event.entityPlayer.getEntityData().setTag("CNPCStoredData", storedData);
}
}
private void doExcalibur(EntityPlayer player, EntityLivingBase entity) {
ItemStack item = player.getCurrentEquippedItem();
if(item == null || item.getItem() != CustomItems.excalibur)
return;
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_MUSIC, "customnpcs:songs.excalibur"), (EntityPlayerMP)player);
player.addChatMessage(new ChatComponentTranslation("<" + StatCollector.translateToLocal(item.getItem().getUnlocalizedName() + ".name") + "> " + ItemExcalibur.quotes[player.getRNG().nextInt(ItemExcalibur.quotes.length)]));
}
private void doExcalibur(EntityPlayer player, EntityLivingBase entity) {
ItemStack item = player.getCurrentEquippedItem();
if (item == null || item.getItem() != CustomItems.excalibur)
return;
PacketHandler.Instance.sendToPlayer(new SoundManagementPacket(EnumSoundOperation.PLAY_MUSIC, "customnpcs:songs.excalibur"), (EntityPlayerMP) player);
player.addChatMessage(new ChatComponentTranslation("<" + StatCollector.translateToLocal(item.getItem().getUnlocalizedName() + ".name") + "> " + ItemExcalibur.quotes[player.getRNG().nextInt(ItemExcalibur.quotes.length)]));
}
private void doFactionPoints(EntityPlayer player, EntityNPCInterface npc) {
npc.advanced.factions.addPoints(player);
}
private void doFactionPoints(EntityPlayer player, EntityNPCInterface npc) {
npc.advanced.factions.addPoints(player);
}
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) {
private void doQuest(EntityPlayer player, EntityLivingBase entity, boolean all) {
PlayerData playerData = PlayerData.get(player);
if (playerData == null) {
return;
@@ -315,15 +310,15 @@ public class ServerEventsHandler {
}
boolean checkCompletion = false;
String entityName = EntityList.getEntityString(entity);
if(entity instanceof EntityPlayer)
if (entity instanceof EntityPlayer)
entityName = "Player";
Party party = playerData.getPlayerParty();
Quest partyQuest = null;
if(party != null){
if(party.getQuestData() != null){
if (party != null) {
if (party.getQuestData() != null) {
partyQuest = party.getQuestData().quest;
if(partyQuest != null && (partyQuest.type == EnumQuestType.Kill || partyQuest.type == EnumQuestType.AreaKill ))
if (partyQuest != null && (partyQuest.type == EnumQuestType.Kill || partyQuest.type == EnumQuestType.AreaKill))
doPartyQuest(player, party, entity);
else
partyQuest = null;
@@ -331,41 +326,41 @@ public class ServerEventsHandler {
}
ArrayList<QuestData> activeQuestValues = new ArrayList<>(questData.activeQuests.values());
for(QuestData data : activeQuestValues){
for (QuestData data : activeQuestValues) {
if (data.quest == null) {
continue;
}
if (data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
continue;
if(partyQuest != null && partyQuest.getId() == data.quest.getId())
if (data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
continue;
if(data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty)
if (partyQuest != null && partyQuest.getId() == data.quest.getId())
continue;
if(data.quest.type == EnumQuestType.AreaKill && all){
if (data.quest.partyOptions.allowParty && data.quest.partyOptions.onlyParty)
continue;
if (data.quest.type == EnumQuestType.AreaKill && all) {
List<EntityPlayer> list = player.worldObj.getEntitiesWithinAABB(EntityPlayer.class, entity.boundingBox.expand(10, 10, 10));
for(EntityPlayer pl : list)
if(pl != player)
for (EntityPlayer pl : list)
if (pl != player)
doQuest(pl, entity, false);
}
String name = entityName;
QuestKill quest = (QuestKill) data.quest.questInterface;
Class entityType = EntityNPCInterface.class;
if (quest.targetType == 2) {
try {
entityType = Class.forName(quest.customTargetType);
} catch (ClassNotFoundException notFoundException) {
continue;
}
}
QuestKill quest = (QuestKill) data.quest.questInterface;
Class entityType = EntityNPCInterface.class;
if (quest.targetType == 2) {
try {
entityType = Class.forName(quest.customTargetType);
} catch (ClassNotFoundException notFoundException) {
continue;
}
}
if (quest.targetType > 0 && !(entityType.isInstance(entity)))
continue;
if (quest.targetType > 0 && !(entityType.isInstance(entity)))
continue;
if (entity.getCommandSenderName() != null && quest.targets != null && quest.targets.containsKey(entity.getCommandSenderName())) {
name = entity.getCommandSenderName();
@@ -373,31 +368,31 @@ public class ServerEventsHandler {
continue;
}
checkCompletion = true;
checkCompletion = true;
HashMap<String, Integer> killed = quest.getKilled(data);
if (!killed.containsKey(name)) {
killed.put(name, 1);
} else if(killed.get(name) < quest.targets.get(name)) {
int amount = killed.get(name);
killed.put(name, amount + 1);
}
quest.setKilled(data, killed);
if (!killed.containsKey(name)) {
killed.put(name, 1);
} else if (killed.get(name) < quest.targets.get(name)) {
int amount = killed.get(name);
killed.put(name, amount + 1);
}
quest.setKilled(data, killed);
playerData.updateClient = true;
}
if(!checkCompletion)
return;
questData.checkQuestCompletion(playerData,EnumQuestType.Kill);
}
private void doPartyQuest(EntityPlayer player, Party party, EntityLivingBase entity){
PlayerData pdata = PlayerData.get(player);
QuestData data = party.getQuestData();
if(data == null)
}
if (!checkCompletion)
return;
if(pdata == null)
questData.checkQuestCompletion(playerData, EnumQuestType.Kill);
}
private void doPartyQuest(EntityPlayer player, Party party, EntityLivingBase entity) {
PlayerData pdata = PlayerData.get(player);
QuestData data = party.getQuestData();
if (data == null)
return;
if (pdata == null)
return;
if (data.quest.type != EnumQuestType.Kill && data.quest.type != EnumQuestType.AreaKill)
@@ -405,7 +400,7 @@ public class ServerEventsHandler {
String name = EntityList.getEntityString(entity);
QuestKill quest = (QuestKill) data.quest.questInterface;
if(data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(player.getUniqueID()))
if (data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.Leader && !party.getLeaderUUID().equals(player.getUniqueID()))
return;
Class entityType = EntityNPCInterface.class;
@@ -425,21 +420,20 @@ public class ServerEventsHandler {
else if (!quest.targets.containsKey(name))
return;
if(data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All){
if (data.quest.partyOptions.objectiveRequirement == EnumPartyObjectives.All) {
HashMap<String, Integer> killed = quest.getPlayerKilled(data, player.getCommandSenderName());
if (!killed.containsKey(name)) {
killed.put(name, 1);
} else if(killed.get(name) < quest.targets.get(name)) {
} else if (killed.get(name) < quest.targets.get(name)) {
int amount = killed.get(name);
killed.put(name, amount + 1);
}
quest.setPlayerKilled(data, killed, player.getCommandSenderName());
}
else {
} else {
HashMap<String, Integer> killed = quest.getKilled(data);
if (!killed.containsKey(name)) {
killed.put(name, 1);
} else if(killed.get(name) < quest.targets.get(name)) {
} else if (killed.get(name) < quest.targets.get(name)) {
int amount = killed.get(name);
killed.put(name, amount + 1);
}
@@ -451,28 +445,28 @@ public class ServerEventsHandler {
PartyController.Instance().checkQuestCompletion(party, EnumQuestType.Kill);
}
@SubscribeEvent
public void world(PlayerEvent.SaveToFile event){
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity);
data.save();
}
@SubscribeEvent
public void world(EntityJoinWorldEvent event){
if(event.world.isRemote || !(event.entity instanceof EntityPlayer))
return;
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity);
data.updateCompanion(event.world);
}
@SubscribeEvent
public void populateChunk(PopulateChunkEvent.Post event){
NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand);
}
@SubscribeEvent
public void world(PlayerEvent.SaveToFile event) {
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity);
data.save();
}
@SubscribeEvent
public void playerTracking(PlayerEvent.StartTracking event){
if(!(event.target instanceof EntityPlayerMP || event.target instanceof EntityNPCInterface) || event.target.worldObj.isRemote)
public void world(EntityJoinWorldEvent event) {
if (event.world.isRemote || !(event.entity instanceof EntityPlayer))
return;
PlayerData data = PlayerDataController.Instance.getPlayerData((EntityPlayer) event.entity);
data.updateCompanion(event.world);
}
@SubscribeEvent
public void populateChunk(PopulateChunkEvent.Post event) {
NPCSpawning.performWorldGenSpawning(event.world, event.chunkX, event.chunkZ, event.rand);
}
@SubscribeEvent
public void playerTracking(PlayerEvent.StartTracking event) {
if (!(event.target instanceof EntityPlayerMP || event.target instanceof EntityNPCInterface) || event.target.worldObj.isRemote)
return;
AnimationData animationData = AnimationData.getData(event.target);
@@ -490,7 +484,7 @@ public class ServerEventsHandler {
MarkData data = MarkData.get((EntityNPCInterface) event.target);
if (data.marks.isEmpty())
return;
PacketHandler.Instance.sendToPlayer(new MarkDataPacket(event.target.getEntityId(), data.getNBT()), (EntityPlayerMP)event.entityPlayer);
PacketHandler.Instance.sendToPlayer(new MarkDataPacket(event.target.getEntityId(), data.getNBT()), (EntityPlayerMP) event.entityPlayer);
}
}
@@ -17,51 +17,51 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
public class ServerTickHandler {
@SubscribeEvent
public void onServerTick(TickEvent.WorldTickEvent event){
if(event.phase == Phase.START){
NPCSpawning.findChunksForSpawning((WorldServer) event.world);
}
}
@SubscribeEvent
public void onServerTick(TickEvent.WorldTickEvent event) {
if (event.phase == Phase.START) {
NPCSpawning.findChunksForSpawning((WorldServer) event.world);
}
}
private String serverName = null;
private String serverName = null;
@SubscribeEvent
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event){
@SubscribeEvent
public void playerLogin(PlayerEvent.PlayerLoggedInEvent event) {
EntityPlayerMP player = (EntityPlayerMP) event.player;
if(serverName == null){
String e = "local";
MinecraftServer server = MinecraftServer.getServer();
if(server.isDedicatedServer()){
try {
e = InetAddress.getByName(server.getServerHostname()).getCanonicalHostName();
} catch (UnknownHostException e1) {
e = MinecraftServer.getServer().getServerHostname();
}
if(server.getPort() != 25565)
e += ":" + server.getPort();
}
if(e == null || e.startsWith("192.168") || e.contains("127.0.0.1") || e.startsWith("localhost"))
e = "local";
serverName = e;
}
AnalyticsTracking.sendData(event.player, "join", serverName);
if (serverName == null) {
String e = "local";
MinecraftServer server = MinecraftServer.getServer();
if (server.isDedicatedServer()) {
try {
e = InetAddress.getByName(server.getServerHostname()).getCanonicalHostName();
} catch (UnknownHostException e1) {
e = MinecraftServer.getServer().getServerHostname();
}
if (server.getPort() != 25565)
e += ":" + server.getPort();
}
if (e == null || e.startsWith("192.168") || e.contains("127.0.0.1") || e.startsWith("localhost"))
e = "local";
serverName = e;
}
AnalyticsTracking.sendData(event.player, "join", serverName);
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
if (playerData != null) {
playerData.onLogin();
}
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
if (playerData != null) {
playerData.onLogin();
}
SyncController.syncPlayer(player);
SyncController.syncEffects(player);
ProfileController.Instance.login(player);
}
}
@SubscribeEvent
public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
if (playerData != null) {
playerData.onLogout();
}
}
@SubscribeEvent
public void playerLogout(PlayerEvent.PlayerLoggedOutEvent event) {
PlayerData playerData = PlayerDataController.Instance.getPlayerData(event.player);
if (playerData != null) {
playerData.onLogout();
}
}
}
+1 -1
View File
@@ -6,5 +6,5 @@ import java.util.ArrayList;
import java.util.List;
public class TextBlock {
public List<IChatComponent> lines = new ArrayList<IChatComponent>();
public List<IChatComponent> lines = new ArrayList<IChatComponent>();
}
@@ -13,207 +13,207 @@ import java.util.Collection;
import java.util.List;
public class VersionCompatibility {
public static int ModRev = 22;
public static int ModRev = 22;
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
if(npc.npcVersion == ModRev)
return;
if(npc.npcVersion < 22) {
if (compound.hasKey("CanLeap")) {
boolean canLeap = compound.getBoolean("CanLeap");
compound.setInteger("LeapType", !canLeap ? 0 : 1);
}
}
if(npc.npcVersion < 19) {
if (compound.hasKey("CanDrown")) {
compound.setInteger("DrowningType", (compound.getBoolean("CanDrown") ? 1 : 0));
compound.removeTag("CanDrown");
}
}
if(npc.npcVersion < 18){
// Fix CloakTexture (Reorganization)
String cloakTexture = compound.getString("CloakTexture");
cloakTexture = cloakTexture.replace("/cloak/Daybreak/", "/cloak/Guilds/Daybreak/");
cloakTexture = cloakTexture.replace("/cloak/Created/", "/cloak/Extras/");
cloakTexture = cloakTexture.replace("/cloak/Color Capes/", "/cloak/Color/");
compound.setString("CloakTexture", cloakTexture);
}
if(npc.npcVersion < 17){
// Fix DialogDarkenScreen
if(compound.hasKey("DialogDarkenScreen")){
compound.removeTag("DialogDarkenScreen");
}
}
if(npc.npcVersion < 12){
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.ais.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.stats.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.display.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.inventory.writeEntityToNBT(new NBTTagCompound()));
}
if(npc.npcVersion < 5){
String texture = compound.getString("Texture");
texture = texture.replace("/mob/customnpcs/", "customnpcs:textures/entity/");
texture = texture.replace("/mob/", "customnpcs:textures/entity/");
compound.setString("Texture", texture);
}
if(npc.npcVersion < 6 && compound.getTag("NpcInteractLines") instanceof NBTTagList){
List<String> interactLines = NBTTags.getStringList(compound.getTagList("NpcInteractLines", 10));
Lines lines = new Lines();
for(int i = 0; i < interactLines.size(); i++){
Line line = new Line();
line.text = (String) interactLines.toArray()[i];
lines.lines.put(i, line);
}
compound.setTag("NpcInteractLines", lines.writeToNBT());
public static void CheckNpcCompatibility(EntityNPCInterface npc, NBTTagCompound compound) {
if (npc.npcVersion == ModRev)
return;
if (npc.npcVersion < 22) {
if (compound.hasKey("CanLeap")) {
boolean canLeap = compound.getBoolean("CanLeap");
compound.setInteger("LeapType", !canLeap ? 0 : 1);
}
}
if (npc.npcVersion < 19) {
if (compound.hasKey("CanDrown")) {
compound.setInteger("DrowningType", (compound.getBoolean("CanDrown") ? 1 : 0));
compound.removeTag("CanDrown");
}
}
if (npc.npcVersion < 18) {
// Fix CloakTexture (Reorganization)
String cloakTexture = compound.getString("CloakTexture");
cloakTexture = cloakTexture.replace("/cloak/Daybreak/", "/cloak/Guilds/Daybreak/");
cloakTexture = cloakTexture.replace("/cloak/Created/", "/cloak/Extras/");
cloakTexture = cloakTexture.replace("/cloak/Color Capes/", "/cloak/Color/");
compound.setString("CloakTexture", cloakTexture);
}
if (npc.npcVersion < 17) {
// Fix DialogDarkenScreen
if (compound.hasKey("DialogDarkenScreen")) {
compound.removeTag("DialogDarkenScreen");
}
}
if (npc.npcVersion < 12) {
CompatabilityFix(compound, npc.advanced.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.ais.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.stats.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.display.writeToNBT(new NBTTagCompound()));
CompatabilityFix(compound, npc.inventory.writeEntityToNBT(new NBTTagCompound()));
}
if (npc.npcVersion < 5) {
String texture = compound.getString("Texture");
texture = texture.replace("/mob/customnpcs/", "customnpcs:textures/entity/");
texture = texture.replace("/mob/", "customnpcs:textures/entity/");
compound.setString("Texture", texture);
}
if (npc.npcVersion < 6 && compound.getTag("NpcInteractLines") instanceof NBTTagList) {
List<String> interactLines = NBTTags.getStringList(compound.getTagList("NpcInteractLines", 10));
Lines lines = new Lines();
for (int i = 0; i < interactLines.size(); i++) {
Line line = new Line();
line.text = (String) interactLines.toArray()[i];
lines.lines.put(i, line);
}
compound.setTag("NpcInteractLines", lines.writeToNBT());
List<String> worldLines = NBTTags.getStringList(compound.getTagList("NpcLines", 10));
lines = new Lines();
for(int i = 0; i < worldLines.size(); i++){
Line line = new Line();
line.text = (String) worldLines.toArray()[i];
lines.lines.put(i, line);
}
compound.setTag("NpcLines", lines.writeToNBT());
List<String> worldLines = NBTTags.getStringList(compound.getTagList("NpcLines", 10));
lines = new Lines();
for (int i = 0; i < worldLines.size(); i++) {
Line line = new Line();
line.text = (String) worldLines.toArray()[i];
lines.lines.put(i, line);
}
compound.setTag("NpcLines", lines.writeToNBT());
List<String> attackLines = NBTTags.getStringList(compound.getTagList("NpcAttackLines", 10));
lines = new Lines();
for(int i = 0; i < attackLines.size(); i++){
Line line = new Line();
line.text = (String) attackLines.toArray()[i];
lines.lines.put(i, line);
}
compound.setTag("NpcAttackLines", lines.writeToNBT());
List<String> attackLines = NBTTags.getStringList(compound.getTagList("NpcAttackLines", 10));
lines = new Lines();
for (int i = 0; i < attackLines.size(); i++) {
Line line = new Line();
line.text = (String) attackLines.toArray()[i];
lines.lines.put(i, line);
}
compound.setTag("NpcAttackLines", lines.writeToNBT());
List<String> killedLines = NBTTags.getStringList(compound.getTagList("NpcKilledLines", 10));
lines = new Lines();
for(int i = 0; i < killedLines.size(); i++){
Line line = new Line();
line.text = (String) killedLines.toArray()[i];
lines.lines.put(i, line);
}
compound.setTag("NpcKilledLines", lines.writeToNBT());
List<String> killedLines = NBTTags.getStringList(compound.getTagList("NpcKilledLines", 10));
lines = new Lines();
for (int i = 0; i < killedLines.size(); i++) {
Line line = new Line();
line.text = (String) killedLines.toArray()[i];
lines.lines.put(i, line);
}
compound.setTag("NpcKilledLines", lines.writeToNBT());
}
if(npc.npcVersion == 12){
NBTTagList list = compound.getTagList("StartPos", 3);
if(list.tagCount() == 3){
int z = ((NBTTagInt) list.removeTag(2)).func_150287_d();
int y = ((NBTTagInt) list.removeTag(1)).func_150287_d();
int x = ((NBTTagInt) list.removeTag(0)).func_150287_d();
}
if (npc.npcVersion == 12) {
NBTTagList list = compound.getTagList("StartPos", 3);
if (list.tagCount() == 3) {
int z = ((NBTTagInt) list.removeTag(2)).func_150287_d();
int y = ((NBTTagInt) list.removeTag(1)).func_150287_d();
int x = ((NBTTagInt) list.removeTag(0)).func_150287_d();
compound.setIntArray("StartPosNew", new int[]{x,y,z});
}
}
if(npc.npcVersion == 13){
boolean bo = compound.getBoolean("HealthRegen");
compound.setInteger("HealthRegen", bo?1:0);
NBTTagCompound comp = compound.getCompoundTag("TransformStats");
bo = comp.getBoolean("HealthRegen");
comp.setInteger("HealthRegen", bo?1:0);
compound.setTag("TransformStats", comp);
compound.setIntArray("StartPosNew", new int[]{x, y, z});
}
}
if (npc.npcVersion == 13) {
boolean bo = compound.getBoolean("HealthRegen");
compound.setInteger("HealthRegen", bo ? 1 : 0);
NBTTagCompound comp = compound.getCompoundTag("TransformStats");
bo = comp.getBoolean("HealthRegen");
comp.setInteger("HealthRegen", bo ? 1 : 0);
compound.setTag("TransformStats", comp);
}
npc.npcVersion = ModRev;
}
}
npc.npcVersion = ModRev;
}
public static void CheckModelCompatibility(EntityNPCInterface npc, NBTTagCompound compound){
if(npc.npcVersion == ModRev)
return;
NBTTagCompound modelData = compound.getCompoundTag("NpcModelData");
if(npc.npcVersion < 20){
// Convert Puppet Job
if (compound.hasKey("NpcJob")) {
if(compound.getInteger("NpcJob") == 9){
// Remove Job
compound.setInteger("NpcJob", 0);
public static void CheckModelCompatibility(EntityNPCInterface npc, NBTTagCompound compound) {
if (npc.npcVersion == ModRev)
return;
NBTTagCompound modelData = compound.getCompoundTag("NpcModelData");
if (npc.npcVersion < 20) {
// Convert Puppet Job
if (compound.hasKey("NpcJob")) {
if (compound.getInteger("NpcJob") == 9) {
// Remove Job
compound.setInteger("NpcJob", 0);
// Get Puppet Data
boolean moving = compound.getBoolean("PuppetMoving");
boolean attacking = compound.getBoolean("PuppetAttacking");
boolean standing = compound.getBoolean("PuppetStanding");
NBTTagCompound head = compound.getCompoundTag("PuppetHead");
NBTTagCompound body = compound.getCompoundTag("PuppetBody");
NBTTagCompound larm = compound.getCompoundTag("PuppetLArm");
NBTTagCompound rarm = compound.getCompoundTag("PuppetRArm");
NBTTagCompound lleg = compound.getCompoundTag("PuppetLLeg");
NBTTagCompound rleg = compound.getCompoundTag("PuppetRLeg");
// Get Puppet Data
boolean moving = compound.getBoolean("PuppetMoving");
boolean attacking = compound.getBoolean("PuppetAttacking");
boolean standing = compound.getBoolean("PuppetStanding");
NBTTagCompound head = compound.getCompoundTag("PuppetHead");
NBTTagCompound body = compound.getCompoundTag("PuppetBody");
NBTTagCompound larm = compound.getCompoundTag("PuppetLArm");
NBTTagCompound rarm = compound.getCompoundTag("PuppetRArm");
NBTTagCompound lleg = compound.getCompoundTag("PuppetLLeg");
NBTTagCompound rleg = compound.getCompoundTag("PuppetRLeg");
// Enable Rotations
modelData.setBoolean("EnableRotation", true);
// Make New Rotation and Write It
ModelRotate newRotation = new ModelRotate();
newRotation.whileMoving = moving;
newRotation.whileAttacking = attacking;
newRotation.whileStanding = standing;
NBTTagCompound rotation = newRotation.writeToNBT();
rotation.setTag("PuppetHead", head);
rotation.setTag("PuppetBody", body);
rotation.setTag("PuppetLArm", larm);
rotation.setTag("PuppetRArm", rarm);
rotation.setTag("PuppetLLeg", lleg);
rotation.setTag("PuppetRLeg", rleg);
modelData.setTag("ModelRotation", rotation);
// Enable Rotations
modelData.setBoolean("EnableRotation", true);
// Make New Rotation and Write It
ModelRotate newRotation = new ModelRotate();
newRotation.whileMoving = moving;
newRotation.whileAttacking = attacking;
newRotation.whileStanding = standing;
NBTTagCompound rotation = newRotation.writeToNBT();
rotation.setTag("PuppetHead", head);
rotation.setTag("PuppetBody", body);
rotation.setTag("PuppetLArm", larm);
rotation.setTag("PuppetRArm", rarm);
rotation.setTag("PuppetLLeg", lleg);
rotation.setTag("PuppetRLeg", rleg);
modelData.setTag("ModelRotation", rotation);
// Remove All Old Tags
compound.removeTag("PuppetMoving");
compound.removeTag("PuppetAttacking");
compound.removeTag("PuppetStanding");
compound.removeTag("PuppetHead");
compound.removeTag("PuppetBody");
compound.removeTag("PuppetLArm");
compound.removeTag("PuppetRArm");
compound.removeTag("PuppetLLeg");
compound.removeTag("PuppetRLeg");
}
}
}
if(npc.npcVersion < 19) {
// Fix Leg MPM Dependency
if(modelData.hasKey("LegParts")){
NBTTagCompound legParts = modelData.getCompoundTag("LegParts");
if(legParts.hasKey("Texture")){
legParts.setString("Texture", legParts.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts"));
}
modelData.setTag("LegParts", legParts);
}
// Remove All Old Tags
compound.removeTag("PuppetMoving");
compound.removeTag("PuppetAttacking");
compound.removeTag("PuppetStanding");
compound.removeTag("PuppetHead");
compound.removeTag("PuppetBody");
compound.removeTag("PuppetLArm");
compound.removeTag("PuppetRArm");
compound.removeTag("PuppetLLeg");
compound.removeTag("PuppetRLeg");
}
}
}
if (npc.npcVersion < 19) {
// Fix Leg MPM Dependency
if (modelData.hasKey("LegParts")) {
NBTTagCompound legParts = modelData.getCompoundTag("LegParts");
if (legParts.hasKey("Texture")) {
legParts.setString("Texture", legParts.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts"));
}
modelData.setTag("LegParts", legParts);
}
// Fix Part MPM Dependency
if(modelData.hasKey("Parts")){
NBTTagList list = modelData.getTagList("Parts", 10);
// Fix Part MPM Dependency
if (modelData.hasKey("Parts")) {
NBTTagList list = modelData.getTagList("Parts", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
if(item.hasKey("Texture")){
item.setString("Texture", item.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts"));
}
list.func_150304_a(i, item);
}
modelData.setTag("Parts", list);
}
}
compound.setTag("NpcModelData", modelData);
}
if (item.hasKey("Texture")) {
item.setString("Texture", item.getString("Texture").replace("moreplayermodels:textures", "customnpcs:textures/parts"));
}
list.func_150304_a(i, item);
}
modelData.setTag("Parts", list);
}
}
compound.setTag("NpcModelData", modelData);
}
public static void CheckAvailabilityCompatibility(ICompatibilty compatibilty, NBTTagCompound compound){
if(compatibilty.getVersion() == ModRev)
return;
CompatabilityFix(compound, compatibilty.writeToNBT(new NBTTagCompound()));
public static void CheckAvailabilityCompatibility(ICompatibilty compatibilty, NBTTagCompound compound) {
if (compatibilty.getVersion() == ModRev)
return;
CompatabilityFix(compound, compatibilty.writeToNBT(new NBTTagCompound()));
compatibilty.setVersion(ModRev);
}
private static void CompatabilityFix(NBTTagCompound compound,
NBTTagCompound check) {
Collection<String> tags = check.func_150296_c();
for(String name : tags){
NBTBase nbt = check.getTag(name);
if(!compound.hasKey(name)){
compound.setTag(name, nbt);
}
else if(nbt instanceof NBTTagCompound && compound.getTag(name) instanceof NBTTagCompound){
CompatabilityFix(compound.getCompoundTag(name), (NBTTagCompound)nbt);
}
}
}
compatibilty.setVersion(ModRev);
}
private static void CompatabilityFix(NBTTagCompound compound,
NBTTagCompound check) {
Collection<String> tags = check.func_150296_c();
for (String name : tags) {
NBTBase nbt = check.getTag(name);
if (!compound.hasKey(name)) {
compound.setTag(name, nbt);
} else if (nbt instanceof NBTTagCompound && compound.getTag(name) instanceof NBTTagCompound) {
CompatabilityFix(compound.getCompoundTag(name), (NBTTagCompound) nbt);
}
}
}
}
+112 -112
View File
@@ -14,138 +14,138 @@ import java.util.Map;
public class CombatHandler {
private Map<EntityLivingBase, Float> aggressors = new HashMap<EntityLivingBase, Float>();
private Map<EntityLivingBase, LinkedList<Float>> recentDamages = new HashMap<>();
private EntityNPCInterface npc;
private long startTime = 0;
private int combatResetTimer = 0;
public CombatHandler(EntityNPCInterface npc) {
this.npc = npc;
}
private Map<EntityLivingBase, Float> aggressors = new HashMap<EntityLivingBase, Float>();
private Map<EntityLivingBase, LinkedList<Float>> recentDamages = new HashMap<>();
private EntityNPCInterface npc;
private long startTime = 0;
private int combatResetTimer = 0;
public void update(){
if(npc.isKilled()){
if(npc.isAttacking()){
reset();
}
return;
}
if(npc.getAttackTarget() != null && !npc.isAttacking()){
start();
}
public CombatHandler(EntityNPCInterface npc) {
this.npc = npc;
}
if(!shouldCombatContinue()){
if(combatResetTimer++ > 40){
reset();
}
return;
}
combatResetTimer = 0;
}
public void update() {
if (npc.isKilled()) {
if (npc.isAttacking()) {
reset();
}
return;
}
if (npc.getAttackTarget() != null && !npc.isAttacking()) {
start();
}
if (!shouldCombatContinue()) {
if (combatResetTimer++ > 40) {
reset();
}
return;
}
combatResetTimer = 0;
}
private boolean shouldCombatContinue() {
if(npc.getAttackTarget() == null)
return false;
return isValidTarget(npc.getAttackTarget());
}
private boolean shouldCombatContinue() {
if (npc.getAttackTarget() == null)
return false;
return isValidTarget(npc.getAttackTarget());
}
public void damage(DamageSource source, float damageAmount) {
combatResetTimer = 0;
Entity e = NoppesUtilServer.GetDamageSource(source);
public void damage(DamageSource source, float damageAmount) {
combatResetTimer = 0;
Entity e = NoppesUtilServer.GetDamageSource(source);
if (e instanceof EntityLivingBase) {
EntityLivingBase el = (EntityLivingBase) e;
if (e instanceof EntityLivingBase) {
EntityLivingBase el = (EntityLivingBase) e;
// Update recent damages
LinkedList<Float> recentDamageList = recentDamages.computeIfAbsent(el, k -> new LinkedList<>());
recentDamageList.addLast(damageAmount);
if (recentDamageList.size() > 15) {
recentDamageList.removeFirst();
}
// Update recent damages
LinkedList<Float> recentDamageList = recentDamages.computeIfAbsent(el, k -> new LinkedList<>());
recentDamageList.addLast(damageAmount);
if (recentDamageList.size() > 15) {
recentDamageList.removeFirst();
}
// Update total aggressor damage
Float f = aggressors.get(el);
if (f == null) {
f = 0f;
}
aggressors.put(el, f + damageAmount);
}
}
// Update total aggressor damage
Float f = aggressors.get(el);
if (f == null) {
f = 0f;
}
aggressors.put(el, f + damageAmount);
}
}
public void start(){
combatResetTimer = 0;
startTime = npc.worldObj.getWorldInfo().getWorldTotalTime();
npc.setBoolFlag(true, 4);
}
public void start() {
combatResetTimer = 0;
startTime = npc.worldObj.getWorldInfo().getWorldTotalTime();
npc.setBoolFlag(true, 4);
}
public void reset(){
combatResetTimer = 0;
startTime = 0;
aggressors.clear();
recentDamages.clear();
npc.setBoolFlag(false, 4);
}
public void reset() {
combatResetTimer = 0;
startTime = 0;
aggressors.clear();
recentDamages.clear();
npc.setBoolFlag(false, 4);
}
public boolean checkTarget() {
if(aggressors.isEmpty() || npc.ticksExisted % 10 != 0)
return false;
EntityLivingBase target = npc.getAttackTarget();
Float current = 0f;
if(isValidTarget(target)){
current = aggressors.get(target);
if(current == null)
current = 0f;
}
else
target = null;
for (Map.Entry<EntityLivingBase, Float> entry : aggressors.entrySet()){
if(entry.getValue() > current && isValidTarget(entry.getKey())){
current = entry.getValue();
target = entry.getKey();
}
}
return target == null;
}
public boolean checkTarget() {
if (aggressors.isEmpty() || npc.ticksExisted % 10 != 0)
return false;
EntityLivingBase target = npc.getAttackTarget();
Float current = 0f;
if (isValidTarget(target)) {
current = aggressors.get(target);
if (current == null)
current = 0f;
} else
target = null;
for (Map.Entry<EntityLivingBase, Float> entry : aggressors.entrySet()) {
if (entry.getValue() > current && isValidTarget(entry.getKey())) {
current = entry.getValue();
target = entry.getKey();
}
}
return target == null;
}
public boolean isValidTarget(EntityLivingBase target){
if(target == null || !target.isEntityAlive())
return false;
public boolean isValidTarget(EntityLivingBase target) {
if (target == null || !target.isEntityAlive())
return false;
if(target instanceof EntityPlayer && (((EntityPlayer)target).capabilities.disableDamage || DBCAddon.instance.isKO(npc, (EntityPlayer) target)))
return false;
if (target instanceof EntityPlayer && (((EntityPlayer) target).capabilities.disableDamage || DBCAddon.instance.isKO(npc, (EntityPlayer) target)))
return false;
return npc.isInRange(target, npc.stats.aggroRange);
}
return npc.isInRange(target, npc.stats.aggroRange);
}
public float calculateThreatLevel(EntityLivingBase entity) {
float threatLevel = 0.0f;
LinkedList<Float> recentDamageList = recentDamages.get(entity);
public float calculateThreatLevel(EntityLivingBase entity) {
float threatLevel = 0.0f;
LinkedList<Float> recentDamageList = recentDamages.get(entity);
if (recentDamageList != null) {
long currentTime = npc.worldObj.getWorldInfo().getWorldTotalTime();
for (Float damage : recentDamageList) {
float decayFactor = Math.max(0, 1 - (float) startTime / currentTime);
if (recentDamageList != null) {
long currentTime = npc.worldObj.getWorldInfo().getWorldTotalTime();
for (Float damage : recentDamageList) {
float decayFactor = Math.max(0, 1 - (float) startTime / currentTime);
threatLevel += damage * decayFactor;
}
}
threatLevel += damage * decayFactor;
}
}
return threatLevel;
}
return threatLevel;
}
public boolean shouldChangeTarget(double chance) {
// Assuming randomNum is a random number between 0 and 100
double randomNum = Math.random() * 100; // Generates a random number between 0 and 100
return randomNum < chance;
}
public boolean shouldChangeTarget(double chance) {
// Assuming randomNum is a random number between 0 and 100
double randomNum = Math.random() * 100; // Generates a random number between 0 and 100
return randomNum < chance;
}
public boolean shouldSwitchTactically(EntityLivingBase originalTarget, EntityLivingBase newTarget, boolean reverse) {
float currentThreat = calculateThreatLevel(originalTarget);
float newThreat = calculateThreatLevel(newTarget);
if(reverse){
public boolean shouldSwitchTactically(EntityLivingBase originalTarget, EntityLivingBase newTarget, boolean reverse) {
float currentThreat = calculateThreatLevel(originalTarget);
float newThreat = calculateThreatLevel(newTarget);
if (reverse) {
return newThreat < currentThreat;
}
return newThreat > currentThreat;
}
return newThreat > currentThreat;
}
}
@@ -11,9 +11,8 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.Random;
public class EntityAIAmbushTarget extends EntityAIBase
{
private EntityNPCInterface theEntity;
public class EntityAIAmbushTarget extends EntityAIBase {
private EntityNPCInterface theEntity;
private EntityLivingBase targetEntity;
private double shelterX;
private double shelterY;
@@ -25,8 +24,7 @@ public class EntityAIAmbushTarget extends EntityAIBase
private int tick;
private boolean attackFromBehind;
public EntityAIAmbushTarget(EntityNPCInterface par1EntityCreature, double par2, double par3, boolean par4)
{
public EntityAIAmbushTarget(EntityNPCInterface par1EntityCreature, double par2, double par3, boolean par4) {
this.theEntity = par1EntityCreature;
this.movementSpeed = par2;
this.theWorld = par1EntityCreature.worldObj;
@@ -38,33 +36,22 @@ public class EntityAIAmbushTarget extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
this.targetEntity = this.theEntity.getAttackTarget();
public boolean shouldExecute() {
this.targetEntity = this.theEntity.getAttackTarget();
if (this.targetEntity == null)
{
if (this.targetEntity == null) {
return false;
}
else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance || !this.theEntity.canSee(targetEntity))
{
return false;
}
else if (delay > 0)
{
delay--;
return false;
}
else
{
Vec3 vec3 = this.findHidingSpot();
} else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance || !this.theEntity.canSee(targetEntity)) {
return false;
} else if (delay > 0) {
delay--;
return false;
} else {
Vec3 vec3 = this.findHidingSpot();
if (vec3 == null)
{
if (vec3 == null) {
return false;
}
else
{
} else {
this.shelterX = vec3.xCoord;
this.shelterY = vec3.yCoord;
this.shelterZ = vec3.zCoord;
@@ -76,83 +63,68 @@ public class EntityAIAmbushTarget extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
boolean shouldHide = this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance;
boolean isSeen = this.theEntity.canSee(targetEntity);
return (!this.theEntity.getNavigator().noPath() && shouldHide) || (!isSeen && (shouldHide || this.theEntity.ais.directLOS));
public boolean continueExecuting() {
boolean shouldHide = this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance;
boolean isSeen = this.theEntity.canSee(targetEntity);
return (!this.theEntity.getNavigator().noPath() && shouldHide) || (!isSeen && (shouldHide || this.theEntity.ais.directLOS));
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.theEntity.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, this.movementSpeed);
}
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
this.theEntity.getNavigator().clearPathEntity();
if (this.theEntity.getAttackTarget() == null && this.targetEntity != null)
{
this.theEntity.setAttackTarget(targetEntity);
if (this.theEntity.getAttackTarget() == null && this.targetEntity != null) {
this.theEntity.setAttackTarget(targetEntity);
}
if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance)
{
this.delay = 60;
if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < this.distance) {
this.delay = 60;
}
}
/**
* Updates the task
*/
public void updateTask()
{
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
public void updateTask() {
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
}
private Vec3 findHidingSpot()
{
Random random = this.theEntity.getRNG();
Vec3 idealPos = null;
private Vec3 findHidingSpot() {
Random random = this.theEntity.getRNG();
Vec3 idealPos = null;
for (int i = 1; i <= 8; i++)
{
for (int y = -2; y <= 2; y++)
{
for (int x = -i; x <= i; x++)
{
for (int z = -i; z <= i; z++)
{
double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D;
double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y);
double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D;
for (int i = 1; i <= 8; i++) {
for (int y = -2; y <= 2; y++) {
for (int x = -i; x <= i; x++) {
for (int z = -i; z <= i; z++) {
double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D;
double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y);
double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D;
if (this.theWorld.getBlock((int)j, (int)k, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 1, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 2, (int)l).isOpaqueCube())
{
Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double)this.targetEntity.getEyeHeight(), this.targetEntity.posZ);
Vec3 vec2 = Vec3.createVectorHelper(j, k + (double)this.theEntity.getEyeHeight(), l);
MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2);
if (movingobjectposition != null)
{
if (this.shelterX != j && this.shelterY != k && this.shelterZ != l)
{
idealPos = Vec3.createVectorHelper(j, k, l);
}
}
}
}
}
}
if (this.theWorld.getBlock((int) j, (int) k, (int) l).isOpaqueCube() && !this.theWorld.getBlock((int) j, (int) k + 1, (int) l).isOpaqueCube() && !this.theWorld.getBlock((int) j, (int) k + 2, (int) l).isOpaqueCube()) {
Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double) this.targetEntity.getEyeHeight(), this.targetEntity.posZ);
Vec3 vec2 = Vec3.createVectorHelper(j, k + (double) this.theEntity.getEyeHeight(), l);
MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2);
if (movingobjectposition != null) {
if (this.shelterX != j && this.shelterY != k && this.shelterZ != l) {
idealPos = Vec3.createVectorHelper(j, k, l);
}
}
}
}
}
}
if (idealPos != null)
{
return idealPos;
}
if (idealPos != null) {
return idealPos;
}
}
delay = 60;
return null;
@@ -5,8 +5,7 @@ import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumMovingType;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIAnimation extends EntityAIBase
{
public class EntityAIAnimation extends EntityAIBase {
private EntityNPCInterface npc;
private boolean isAttacking = false;
@@ -15,53 +14,53 @@ public class EntityAIAnimation extends EntityAIBase
private boolean hasPath = false;
private int tick = 4;
public EntityAIAnimation(EntityNPCInterface npc){
public EntityAIAnimation(EntityNPCInterface npc) {
this.npc = npc;
}
@Override
public boolean shouldExecute(){
isDead = !npc.isEntityAlive();
if(isDead)
return npc.currentAnimation != EnumAnimation.LYING;
public boolean shouldExecute() {
isDead = !npc.isEntityAlive();
if (isDead)
return npc.currentAnimation != EnumAnimation.LYING;
if(npc.stats.aimWhileShooting && npc.isAttacking())
return npc.currentAnimation != EnumAnimation.AIMING;
if(npc.ais.animationType == EnumAnimation.NONE)
return npc.currentAnimation != EnumAnimation.NONE;
isAttacking = npc.isAttacking();
if(npc.ais.returnToStart)
isAtStartpoint = npc.isVeryNearAssignedPlace();
hasPath = !npc.getNavigator().noPath();
if (npc.stats.aimWhileShooting && npc.isAttacking())
return npc.currentAnimation != EnumAnimation.AIMING;
if (npc.ais.animationType == EnumAnimation.NONE)
return npc.currentAnimation != EnumAnimation.NONE;
isAttacking = npc.isAttacking();
if (npc.ais.returnToStart)
isAtStartpoint = npc.isVeryNearAssignedPlace();
hasPath = !npc.getNavigator().noPath();
if(npc.ais.movingType == EnumMovingType.Standing && hasNavigation() && npc.currentAnimation.getWalkingAnimation() == 0){
return npc.currentAnimation != EnumAnimation.NONE;
}
if (npc.ais.movingType == EnumMovingType.Standing && hasNavigation() && npc.currentAnimation.getWalkingAnimation() == 0) {
return npc.currentAnimation != EnumAnimation.NONE;
}
return npc.currentAnimation != npc.ais.animationType;
return npc.currentAnimation != npc.ais.animationType;
}
@Override
public void updateTask(){
if(npc.stats.aimWhileShooting && npc.isAttacking()){
setAnimation(EnumAnimation.AIMING);
return;
}
EnumAnimation type = npc.ais.animationType;
if(isDead)
type = EnumAnimation.LYING;
else if(npc.ais.movingType == EnumMovingType.Standing && npc.ais.animationType.getWalkingAnimation() == 0 && hasNavigation())
type = EnumAnimation.NONE;
setAnimation(type);
public void updateTask() {
if (npc.stats.aimWhileShooting && npc.isAttacking()) {
setAnimation(EnumAnimation.AIMING);
return;
}
EnumAnimation type = npc.ais.animationType;
if (isDead)
type = EnumAnimation.LYING;
else if (npc.ais.movingType == EnumMovingType.Standing && npc.ais.animationType.getWalkingAnimation() == 0 && hasNavigation())
type = EnumAnimation.NONE;
setAnimation(type);
}
private void setAnimation(EnumAnimation animation){
npc.setCurrentAnimation(animation);
npc.updateHitbox();
npc.setPosition(npc.posX, npc.posY, npc.posZ);
private void setAnimation(EnumAnimation animation) {
npc.setCurrentAnimation(animation);
npc.updateHitbox();
npc.setPosition(npc.posX, npc.posY, npc.posZ);
}
private boolean hasNavigation() {
return (isAttacking || npc.ais.returnToStart && !isAtStartpoint && !npc.isFollower() || hasPath);
return (isAttacking || npc.ais.returnToStart && !isAtStartpoint && !npc.isFollower() || hasPath);
}
}
@@ -12,8 +12,7 @@ import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIAttackTarget extends EntityAIBase
{
public class EntityAIAttackTarget extends EntityAIBase {
private World world;
private EntityNPCInterface npc;
private EntityLivingBase entityTarget;
@@ -23,42 +22,41 @@ public class EntityAIAttackTarget extends EntityAIBase
*/
private int attackTick;
/** The PathEntity of our entity. */
/**
* The PathEntity of our entity.
*/
private PathEntity entityPathEntity;
private int field_75445_i;
private boolean navOverride = false;
private boolean navOverride = false;
public EntityAIAttackTarget(EntityNPCInterface par1EntityLiving){
public EntityAIAttackTarget(EntityNPCInterface par1EntityLiving) {
this.attackTick = 0;
this.npc = par1EntityLiving;
this.world = par1EntityLiving.worldObj;
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
}
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute(){
EntityLivingBase entitylivingbase = this.npc.getAttackTarget();
public boolean shouldExecute() {
EntityLivingBase entitylivingbase = this.npc.getAttackTarget();
if (entitylivingbase == null){
if (entitylivingbase == null) {
return false;
}
else if (!entitylivingbase.isEntityAlive()){
} else if (!entitylivingbase.isEntityAlive()) {
return false;
} else if (this.npc.inventory.getProjectile() != null && this.npc.ais.useRangeMelee == 0) {
return false;
}
else if (this.npc.inventory.getProjectile() != null && this.npc.ais.useRangeMelee == 0){
return false;
}
double var2 = this.npc.getDistanceSq(entitylivingbase.posX, entitylivingbase.boundingBox.minY, entitylivingbase.posZ);
double var3 = this.npc.ais.distanceToMelee * this.npc.ais.distanceToMelee;
if (this.npc.ais.useRangeMelee == 1 && var2 > var3){
return false;
}
else{
this.entityTarget = entitylivingbase;
if (this.npc.ais.useRangeMelee == 1 && var2 > var3) {
return false;
} else {
this.entityTarget = entitylivingbase;
this.npc.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) this.npc).stats.aggroRange);
this.entityPathEntity = this.npc.getNavigator().getPathToEntityLiving(entitylivingbase);
this.npc.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(ConfigMain.NpcNavRange);
@@ -69,62 +67,56 @@ public class EntityAIAttackTarget extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
this.entityTarget = this.npc.getAttackTarget();
public boolean continueExecuting() {
this.entityTarget = this.npc.getAttackTarget();
if(entityTarget == null || !entityTarget.isEntityAlive())
return false;
if(entityTarget instanceof EntityPlayer && DBCAddon.instance.isKO(npc, (EntityPlayer) this.entityTarget))
if (entityTarget == null || !entityTarget.isEntityAlive())
return false;
if(npc.getDistanceToEntity(entityTarget) > npc.stats.aggroRange)
return false;
if (this.npc.ais.useRangeMelee == 1 && npc.getDistanceSqToEntity(entityTarget) > (this.npc.ais.distanceToMelee * this.npc.ais.distanceToMelee))
return false;
if (entityTarget instanceof EntityPlayer && DBCAddon.instance.isKO(npc, (EntityPlayer) this.entityTarget))
return false;
return this.npc.isWithinHomeDistance(MathHelper.floor_double(entityTarget.posX), MathHelper.floor_double(entityTarget.posY), MathHelper.floor_double(entityTarget.posZ));
if (npc.getDistanceToEntity(entityTarget) > npc.stats.aggroRange)
return false;
if (this.npc.ais.useRangeMelee == 1 && npc.getDistanceSqToEntity(entityTarget) > (this.npc.ais.distanceToMelee * this.npc.ais.distanceToMelee))
return false;
return this.npc.isWithinHomeDistance(MathHelper.floor_double(entityTarget.posX), MathHelper.floor_double(entityTarget.posY), MathHelper.floor_double(entityTarget.posZ));
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting(){
if(!navOverride)
this.npc.getNavigator().setPath(this.entityPathEntity, 1.3D);
public void startExecuting() {
if (!navOverride)
this.npc.getNavigator().setPath(this.entityPathEntity, 1.3D);
this.field_75445_i = 0;
if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2)
{
this.npc.getRangedTask().navOverride(true);
if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2) {
this.npc.getRangedTask().navOverride(true);
}
}
/**
* Resets the task
*/
public void resetTask()
{
this.entityPathEntity = null;
this.entityTarget = null;
this.npc.setAttackTarget(null);
public void resetTask() {
this.entityPathEntity = null;
this.entityTarget = null;
this.npc.setAttackTarget(null);
this.npc.getNavigator().clearPathEntity();
if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2)
{
this.npc.getRangedTask().navOverride(false);
if (this.npc.getRangedTask() != null && this.npc.ais.useRangeMelee == 2) {
this.npc.getRangedTask().navOverride(false);
}
}
/**
* Updates the task
*/
public void updateTask()
{
public void updateTask() {
this.npc.getLookHelper().setLookPositionWithEntity(this.entityTarget, 30.0F, 30.0F);
if (!navOverride && --this.field_75445_i <= 0)
{
if (!navOverride && --this.field_75445_i <= 0) {
this.field_75445_i = 4 + this.npc.getRNG().nextInt(7);
this.npc.getNavigator().tryMoveToEntityLiving(this.entityTarget, 1.3f);
}
@@ -133,13 +125,12 @@ public class EntityAIAttackTarget extends EntityAIBase
double distance = this.npc.getDistanceSq(this.entityTarget.posX, this.entityTarget.boundingBox.minY, this.entityTarget.posZ);
double range = npc.stats.attackRange * npc.stats.attackRange + entityTarget.width;
double minRange = this.npc.width * 2.0F * this.npc.width * 2.0F + entityTarget.width;
if(minRange > range)
range = minRange;
if (distance <= range && (npc.canSee(this.entityTarget) || distance < minRange))
{
if (minRange > range)
range = minRange;
if (distance <= range && (npc.canSee(this.entityTarget) || distance < minRange)) {
if (this.attackTick <= 0) {
this.attackTick = this.npc.stats.attackSpeed;
if(this.npc.stats.swingWarmUp == 0)
if (this.npc.stats.swingWarmUp == 0)
this.npc.attackEntityAsMob(this.entityTarget);
this.npc.swingItem();
} else if (this.npc.stats.swingWarmUp > 0 && this.attackTick == this.npc.stats.attackSpeed - this.npc.stats.swingWarmUp) {
@@ -149,8 +140,8 @@ public class EntityAIAttackTarget extends EntityAIBase
}
}
public void navOverride(boolean nav){
this.navOverride = nav;
public void navOverride(boolean nav) {
this.navOverride = nav;
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
}
}
@@ -13,26 +13,32 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
public class EntityAIAvoidTarget extends EntityAIBase
{
/** The entity we are attached to */
public class EntityAIAvoidTarget extends EntityAIBase {
/**
* The entity we are attached to
*/
private EntityNPCInterface theEntity;
private Entity closestLivingEntity;
private float distanceFromEntity;
private float health;
/** The PathEntity of our entity */
/**
* The PathEntity of our entity
*/
private PathEntity entityPathEntity;
/** The PathNavigate of our entity */
/**
* The PathNavigate of our entity
*/
private PathNavigate entityPathNavigate;
/** The class of the entity we should avoid */
/**
* The class of the entity we should avoid
*/
private Class targetEntityClass;
public EntityAIAvoidTarget(EntityNPCInterface par1EntityNPC)
{
public EntityAIAvoidTarget(EntityNPCInterface par1EntityNPC) {
this.theEntity = par1EntityNPC;
this.distanceFromEntity = this.theEntity.stats.aggroRange;
this.health = this.theEntity.getHealth();
@@ -43,64 +49,47 @@ public class EntityAIAvoidTarget extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
EntityLivingBase target = this.theEntity.getAttackTarget();
public boolean shouldExecute() {
EntityLivingBase target = this.theEntity.getAttackTarget();
if (target == null)
{
if (target == null) {
return false;
}
targetEntityClass = target.getClass();
targetEntityClass = target.getClass();
if (this.targetEntityClass == EntityPlayer.class)
{
this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, (double)this.distanceFromEntity);
if (this.targetEntityClass == EntityPlayer.class) {
this.closestLivingEntity = this.theEntity.worldObj.getClosestPlayerToEntity(this.theEntity, (double) this.distanceFromEntity);
if (this.closestLivingEntity == null)
{
if (this.closestLivingEntity == null) {
return false;
}
}
else
{
List var1 = this.theEntity.worldObj.getEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand((double)this.distanceFromEntity, 3.0D, (double)this.distanceFromEntity));
} else {
List var1 = this.theEntity.worldObj.getEntitiesWithinAABB(this.targetEntityClass, this.theEntity.boundingBox.expand((double) this.distanceFromEntity, 3.0D, (double) this.distanceFromEntity));
if (var1.isEmpty())
{
if (var1.isEmpty()) {
return false;
}
this.closestLivingEntity = (Entity)var1.get(0);
this.closestLivingEntity = (Entity) var1.get(0);
}
if (!this.theEntity.getEntitySenses().canSee(this.closestLivingEntity) && this.theEntity.ais.directLOS)
{
if (!this.theEntity.getEntitySenses().canSee(this.closestLivingEntity) && this.theEntity.ais.directLOS) {
return false;
}
else
{
} else {
Vec3 var2 = RandomPositionGeneratorAlt.findRandomTargetBlockAwayFrom(this.theEntity, 16, 7, Vec3.createVectorHelper(this.closestLivingEntity.posX, this.closestLivingEntity.posY, this.closestLivingEntity.posZ));
boolean var3 = this.theEntity.inventory.getProjectile() == null || this.theEntity.ais.useRangeMelee == 2;
boolean var4 = var3 ? this.health == this.theEntity.getHealth() : this.theEntity.getRangedTask() != null && !this.theEntity.getRangedTask().hasFired();
if (var2 == null)
{
if (var2 == null) {
return false;
}
else if (this.closestLivingEntity.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity))
{
} else if (this.closestLivingEntity.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord) < this.closestLivingEntity.getDistanceSqToEntity(this.theEntity)) {
return false;
}
else if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun && var4)
{
return false;
}
else
{
} else if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun && var4) {
return false;
} else {
this.entityPathEntity = this.entityPathNavigate.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord);
return this.entityPathEntity == null ? false : this.entityPathEntity.isDestinationSame(var2);
}
@@ -110,24 +99,21 @@ public class EntityAIAvoidTarget extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return !this.entityPathNavigate.noPath();
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.entityPathNavigate.setPath(this.entityPathEntity, 1.0D);
}
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
this.closestLivingEntity = null;
this.theEntity.setAttackTarget(null);
}
@@ -135,23 +121,17 @@ public class EntityAIAvoidTarget extends EntityAIBase
/**
* Updates the task
*/
public void updateTask()
{
if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D)
{
public void updateTask() {
if (this.theEntity.getDistanceSqToEntity(this.closestLivingEntity) < 49.0D) {
this.theEntity.getNavigator().setSpeed(1.2D);
}
else
{
} else {
this.theEntity.getNavigator().setSpeed(1.0D);
}
if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun)
{
float dist = this.theEntity.getDistanceToEntity(this.closestLivingEntity);
if (dist > this.distanceFromEntity || dist < this.theEntity.ais.tacticalRadius)
{
this.health = this.theEntity.getHealth();
}
if (this.theEntity.ais.tacticalVariant == EnumNavType.HitNRun) {
float dist = this.theEntity.getDistanceToEntity(this.closestLivingEntity);
if (dist > this.distanceFromEntity || dist < this.theEntity.ais.tacticalRadius) {
this.health = this.theEntity.getHealth();
}
}
}
}
@@ -5,28 +5,25 @@ import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityAIDoorInteract;
import net.minecraft.init.Blocks;
public class EntityAIBustDoor extends EntityAIDoorInteract
{
public class EntityAIBustDoor extends EntityAIDoorInteract {
private int breakingTime;
private int field_75358_j = -1;
public EntityAIBustDoor(EntityLiving par1EntityLiving){
public EntityAIBustDoor(EntityLiving par1EntityLiving) {
super(par1EntityLiving);
}
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
public boolean shouldExecute() {
return !super.shouldExecute() ? false : (!this.theEntity.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing") ? false : !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ));
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
super.startExecuting();
this.breakingTime = 0;
}
@@ -34,17 +31,15 @@ public class EntityAIBustDoor extends EntityAIDoorInteract
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
double var1 = this.theEntity.getDistanceSq((double)this.entityPosX, (double)this.entityPosY, (double)this.entityPosZ);
public boolean continueExecuting() {
double var1 = this.theEntity.getDistanceSq((double) this.entityPosX, (double) this.entityPosY, (double) this.entityPosZ);
return this.breakingTime <= 240 && !this.field_151504_e.func_150015_f(this.theEntity.worldObj, this.entityPosX, this.entityPosY, this.entityPosZ) && var1 < 4.0D;
}
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
super.resetTask();
this.theEntity.worldObj.destroyBlockInWorldPartially(this.theEntity.getEntityId(), this.entityPosX, this.entityPosY, this.entityPosZ, -1);
}
@@ -52,27 +47,23 @@ public class EntityAIBustDoor extends EntityAIDoorInteract
/**
* Updates the task
*/
public void updateTask()
{
public void updateTask() {
super.updateTask();
if (this.theEntity.getRNG().nextInt(20) == 0)
{
if (this.theEntity.getRNG().nextInt(20) == 0) {
this.theEntity.worldObj.playAuxSFX(1010, this.entityPosX, this.entityPosY, this.entityPosZ, 0);
this.theEntity.swingItem();
}
++this.breakingTime;
int var1 = (int)((float)this.breakingTime / 240.0F * 10.0F);
int var1 = (int) ((float) this.breakingTime / 240.0F * 10.0F);
if (var1 != this.field_75358_j)
{
if (var1 != this.field_75358_j) {
this.theEntity.worldObj.destroyBlockInWorldPartially(this.theEntity.getEntityId(), this.entityPosX, this.entityPosY, this.entityPosZ, var1);
this.field_75358_j = var1;
}
if (this.breakingTime == 240)
{
if (this.breakingTime == 240) {
this.theEntity.worldObj.setBlock(this.entityPosX, this.entityPosY, this.entityPosZ, Blocks.air);
this.theEntity.worldObj.playAuxSFX(1012, this.entityPosX, this.entityPosY, this.entityPosZ, 0);
this.theEntity.worldObj.playAuxSFX(2001, this.entityPosX, this.entityPosY, this.entityPosZ, Block.getIdFromBlock(this.field_151504_e));
@@ -6,15 +6,13 @@ import net.minecraft.util.Vec3;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIDodgeShoot extends EntityAIBase
{
public class EntityAIDodgeShoot extends EntityAIBase {
private EntityNPCInterface entity;
private double xPosition;
private double yPosition;
private double zPosition;
public EntityAIDodgeShoot(EntityNPCInterface par1EntityNPCInterface)
{
public EntityAIDodgeShoot(EntityNPCInterface par1EntityNPCInterface) {
this.entity = par1EntityNPCInterface;
this.setMutexBits(AiMutex.PASSIVE);
}
@@ -22,33 +20,23 @@ public class EntityAIDodgeShoot extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
EntityLivingBase var1 = this.entity.getAttackTarget();
public boolean shouldExecute() {
EntityLivingBase var1 = this.entity.getAttackTarget();
if (var1 == null || !var1.isEntityAlive())
{
if (var1 == null || !var1.isEntityAlive()) {
return false;
}
if (this.entity.inventory.getProjectile() == null)
{
return false;
}
else if (this.entity.getRangedTask() == null)
{
return false;
}
else
{
if (this.entity.inventory.getProjectile() == null) {
return false;
} else if (this.entity.getRangedTask() == null) {
return false;
} else {
Vec3 vec = this.entity.getRangedTask().hasFired() ? RandomPositionGeneratorAlt.findRandomTarget(this.entity, 4, 1) : null;
Vec3 vec = this.entity.getRangedTask().hasFired() ? RandomPositionGeneratorAlt.findRandomTarget(this.entity, 4, 1) : null;
if (vec == null)
{
if (vec == null) {
return false;
}
else
{
} else {
this.xPosition = vec.xCoord;
this.yPosition = vec.yCoord;
this.zPosition = vec.zCoord;
@@ -60,25 +48,22 @@ public class EntityAIDodgeShoot extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return !this.entity.getNavigator().noPath();
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, 1.2D);
}
/**
* Updates the task
*/
public void updateTask()
{
if (this.entity.getAttackTarget() != null)
this.entity.getLookHelper().setLookPositionWithEntity(this.entity.getAttackTarget(), 30.0F, 30.0F);
public void updateTask() {
if (this.entity.getAttackTarget() != null)
this.entity.getLookHelper().setLookPositionWithEntity(this.entity.getAttackTarget(), 30.0F, 30.0F);
}
}
@@ -9,16 +9,14 @@ import noppes.npcs.constants.AiMutex;
import java.util.Random;
public class EntityAIFindShade extends EntityAIBase
{
public class EntityAIFindShade extends EntityAIBase {
private EntityCreature theCreature;
private double shelterX;
private double shelterY;
private double shelterZ;
private World theWorld;
public EntityAIFindShade(EntityCreature par1EntityCreature)
{
public EntityAIFindShade(EntityCreature par1EntityCreature) {
this.theCreature = par1EntityCreature;
this.theWorld = par1EntityCreature.worldObj;
this.setMutexBits(AiMutex.PASSIVE);
@@ -27,26 +25,17 @@ public class EntityAIFindShade extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (!this.theWorld.isDaytime())
{
public boolean shouldExecute() {
if (!this.theWorld.isDaytime()) {
return false;
}
else if (!this.theWorld.canBlockSeeTheSky(MathHelper.floor_double(this.theCreature.posX), (int)this.theCreature.boundingBox.minY, MathHelper.floor_double(this.theCreature.posZ)))
{
} else if (!this.theWorld.canBlockSeeTheSky(MathHelper.floor_double(this.theCreature.posX), (int) this.theCreature.boundingBox.minY, MathHelper.floor_double(this.theCreature.posZ))) {
return false;
}
else
{
} else {
Vec3 var1 = this.findPossibleShelter();
if (var1 == null)
{
if (var1 == null) {
return false;
}
else
{
} else {
this.shelterX = var1.xCoord;
this.shelterY = var1.yCoord;
this.shelterZ = var1.zCoord;
@@ -58,33 +47,28 @@ public class EntityAIFindShade extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return !this.theCreature.getNavigator().noPath();
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.theCreature.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, 1.0D);
}
private Vec3 findPossibleShelter()
{
private Vec3 findPossibleShelter() {
Random var1 = this.theCreature.getRNG();
for (int var2 = 0; var2 < 10; ++var2)
{
int var3 = MathHelper.floor_double(this.theCreature.posX + (double)var1.nextInt(20) - 10.0D);
int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double)var1.nextInt(6) - 3.0D);
int var5 = MathHelper.floor_double(this.theCreature.posZ + (double)var1.nextInt(20) - 10.0D);
for (int var2 = 0; var2 < 10; ++var2) {
int var3 = MathHelper.floor_double(this.theCreature.posX + (double) var1.nextInt(20) - 10.0D);
int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double) var1.nextInt(6) - 3.0D);
int var5 = MathHelper.floor_double(this.theCreature.posZ + (double) var1.nextInt(20) - 10.0D);
float light = this.theWorld.getLightBrightness(var3, var4, var5) - 0.5F;
if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && light < 0.0F)
{
return Vec3.createVectorHelper((double)var3, (double)var4, (double)var5);
if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && light < 0.0F) {
return Vec3.createVectorHelper((double) var3, (double) var4, (double) var5);
}
}
@@ -8,72 +8,69 @@ import noppes.npcs.constants.AiMutex;
import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIFollow extends EntityAIBase
{
public class EntityAIFollow extends EntityAIBase {
private EntityNPCInterface npc;
private EntityLivingBase owner;
private double distance;
public int updateTick = 0;
public int updateTick = 0;
public EntityAIFollow(EntityNPCInterface npc){
public EntityAIFollow(EntityNPCInterface npc) {
this.npc = npc;
this.setMutexBits(AiMutex.PASSIVE + AiMutex.LOOK);
}
@Override
public boolean shouldExecute(){
if(!excute())
return false;
return distance > npc.followRange();
public boolean shouldExecute() {
if (!excute())
return false;
return distance > npc.followRange();
}
public boolean excute(){
if(!npc.isEntityAlive() || !npc.isFollower() || npc.isAttacking() || (owner = npc.getOwner()) == null || npc.ais.animationType == EnumAnimation.SITTING)
return false;
distance = npc.getDistanceSqToEntity(owner);
return true;
public boolean excute() {
if (!npc.isEntityAlive() || !npc.isFollower() || npc.isAttacking() || (owner = npc.getOwner()) == null || npc.ais.animationType == EnumAnimation.SITTING)
return false;
distance = npc.getDistanceSqToEntity(owner);
return true;
}
@Override
public void startExecuting(){
updateTick = 10;
public void startExecuting() {
updateTick = 10;
}
@Override
public boolean continueExecuting(){
public boolean continueExecuting() {
return !this.npc.getNavigator().noPath() && distance > 4 && excute();
}
@Override
public void resetTask(){
public void resetTask() {
this.owner = null;
this.npc.getNavigator().clearPathEntity();
}
@Override
public void updateTask(){
updateTick++;
if(updateTick < 10)
return;
updateTick = 0;
this.npc.getLookHelper().setLookPositionWithEntity(owner, 10.0F, (float)this.npc.getVerticalFaceSpeed());
public void updateTask() {
updateTick++;
if (updateTick < 10)
return;
updateTick = 0;
this.npc.getLookHelper().setLookPositionWithEntity(owner, 10.0F, (float) this.npc.getVerticalFaceSpeed());
double speed = 1 + distance / 150;
if(speed > 3)
speed = 3;
double speed = 1 + distance / 150;
if (speed > 3)
speed = 3;
if (this.npc.getNavigator().tryMoveToEntityLiving(owner, speed) || distance < 225.0D)
return;
return;
int i = MathHelper.floor_double(this.owner.posX) - 2;
int j = MathHelper.floor_double(this.owner.posZ) - 2;
int k = MathHelper.floor_double(this.owner.boundingBox.minY);
for (int l = 0; l <= 4; ++l)
{
for (int i1 = 0; i1 <= 4; ++i1)
{
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(npc.worldObj, i + l, k - 1, j + i1) && !npc.worldObj.getBlock(i + l, k, j + i1).isNormalCube() && !npc.worldObj.getBlock(i + l, k + 1, j + i1).isNormalCube())
{
this.npc.setLocationAndAngles((double)((float)(i + l) + 0.5F), (double)k, (double)((float)(j + i1) + 0.5F), this.npc.rotationYaw, this.npc.rotationPitch);
for (int l = 0; l <= 4; ++l) {
for (int i1 = 0; i1 <= 4; ++i1) {
if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) && World.doesBlockHaveSolidTopSurface(npc.worldObj, i + l, k - 1, j + i1) && !npc.worldObj.getBlock(i + l, k, j + i1).isNormalCube() && !npc.worldObj.getBlock(i + l, k + 1, j + i1).isNormalCube()) {
this.npc.setLocationAndAngles((double) ((float) (i + l) + 0.5F), (double) k, (double) ((float) (j + i1) + 0.5F), this.npc.rotationYaw, this.npc.rotationPitch);
this.npc.getNavigator().clearPathEntity();
return;
}
+26 -28
View File
@@ -5,38 +5,36 @@ import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIJob extends EntityAIBase {
private EntityNPCInterface npc;
public EntityAIJob(EntityNPCInterface npc){
this.npc = npc;
}
@Override
public boolean shouldExecute() {
if(npc.isKilled() || npc.jobInterface == null)
return false;
return npc.jobInterface.aiShouldExecute();
}
public void startExecuting()
{
npc.jobInterface.aiStartExecuting();
private EntityNPCInterface npc;
public EntityAIJob(EntityNPCInterface npc) {
this.npc = npc;
}
@Override
public boolean continueExecuting()
{
if(npc.isKilled() || npc.jobInterface == null)
return false;
return npc.jobInterface.aiContinueExecute();
@Override
public boolean shouldExecute() {
if (npc.isKilled() || npc.jobInterface == null)
return false;
return npc.jobInterface.aiShouldExecute();
}
public void updateTask()
{
npc.jobInterface.aiUpdateTask();
public void startExecuting() {
npc.jobInterface.aiStartExecuting();
}
@Override
public boolean continueExecuting() {
if (npc.isKilled() || npc.jobInterface == null)
return false;
return npc.jobInterface.aiContinueExecute();
}
public void updateTask() {
npc.jobInterface.aiUpdateTask();
}
public void resetTask() {
if(npc.jobInterface != null)
npc.jobInterface.resetTask();
if (npc.jobInterface != null)
npc.jobInterface.resetTask();
}
}
+50 -51
View File
@@ -9,14 +9,14 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.Iterator;
public class EntityAILook extends EntityAIBase{
public class EntityAILook extends EntityAIBase {
private final EntityNPCInterface npc;
private int idle = 0;
private double lookX;
private double lookZ;
boolean rotatebody;
public EntityAILook(EntityNPCInterface npc){
public EntityAILook(EntityNPCInterface npc) {
this.npc = npc;
this.setMutexBits(AiMutex.LOOK);
}
@@ -25,7 +25,7 @@ public class EntityAILook extends EntityAIBase{
* Returns whether the EntityAIBase should begin execution.
*/
@Override
public boolean shouldExecute(){
public boolean shouldExecute() {
return !npc.isAttacking() && npc.getNavigator().noPath() && !npc.isPlayerSleeping() && npc.isEntityAlive();
}
@@ -33,68 +33,67 @@ public class EntityAILook extends EntityAIBase{
* Execute a one shot task or start executing a continuous task
*/
@Override
public void startExecuting(){
rotatebody = npc.ais.standingType == EnumStandingType.RotateBody || npc.ais.standingType == EnumStandingType.HeadRotation;
public void startExecuting() {
rotatebody = npc.ais.standingType == EnumStandingType.RotateBody || npc.ais.standingType == EnumStandingType.HeadRotation;
}
/**
* Resets the task
*/
@Override
public void resetTask(){
rotatebody = false;
public void resetTask() {
rotatebody = false;
}
/**
* Updates the task
*/
@Override
public void updateTask(){
if(npc.ais.standingType == EnumStandingType.Stalking){
EntityPlayer player = npc.worldObj.getClosestPlayerToEntity(npc, 16);
if(player == null)
rotatebody = true;
else
npc.getLookHelper().setLookPositionWithEntity(player, 10F, npc.getVerticalFaceSpeed());
}
if(npc.isInteracting()){
Iterator<EntityLivingBase> ita = npc.interactingEntities.iterator();
EntityLivingBase closest = null;
double closestDistance = 12;
while(ita.hasNext()){
EntityLivingBase entity = ita.next();
double distance = entity.getDistanceSqToEntity(npc);
if(distance < closestDistance){
closestDistance = entity.getDistanceSqToEntity(npc);
closest = entity;
}
else if(distance > 12)
ita.remove();
}
if(closest != null){
npc.getLookHelper().setLookPositionWithEntity(closest, 10F, npc.getVerticalFaceSpeed());
return;
}
public void updateTask() {
if (npc.ais.standingType == EnumStandingType.Stalking) {
EntityPlayer player = npc.worldObj.getClosestPlayerToEntity(npc, 16);
if (player == null)
rotatebody = true;
else
npc.getLookHelper().setLookPositionWithEntity(player, 10F, npc.getVerticalFaceSpeed());
}
if (npc.isInteracting()) {
Iterator<EntityLivingBase> ita = npc.interactingEntities.iterator();
EntityLivingBase closest = null;
double closestDistance = 12;
while (ita.hasNext()) {
EntityLivingBase entity = ita.next();
double distance = entity.getDistanceSqToEntity(npc);
if (distance < closestDistance) {
closestDistance = entity.getDistanceSqToEntity(npc);
closest = entity;
} else if (distance > 12)
ita.remove();
}
if (closest != null) {
npc.getLookHelper().setLookPositionWithEntity(closest, 10F, npc.getVerticalFaceSpeed());
return;
}
}
}
if(rotatebody){
if(idle == 0 && npc.getRNG().nextFloat() < 0.02F){
double var1 = (Math.PI * 2D) * this.npc.getRNG().nextDouble();
if(npc.ais.standingType == EnumStandingType.HeadRotation)
var1 = Math.PI / 180 * npc.ais.orientation + Math.PI * 0.2 + Math.PI * 0.6 * this.npc.getRNG().nextDouble();
this.lookX = Math.cos(var1);
this.lookZ = Math.sin(var1);
this.idle = 20 + this.npc.getRNG().nextInt(20);
}
if(idle > 0){
idle--;
npc.getLookHelper().setLookPosition(npc.posX + lookX, npc.posY + npc.getEyeHeight(), npc.posZ + lookZ, 10F, npc.getVerticalFaceSpeed());
}
}
if (rotatebody) {
if (idle == 0 && npc.getRNG().nextFloat() < 0.02F) {
double var1 = (Math.PI * 2D) * this.npc.getRNG().nextDouble();
if (npc.ais.standingType == EnumStandingType.HeadRotation)
var1 = Math.PI / 180 * npc.ais.orientation + Math.PI * 0.2 + Math.PI * 0.6 * this.npc.getRNG().nextDouble();
this.lookX = Math.cos(var1);
this.lookZ = Math.sin(var1);
this.idle = 20 + this.npc.getRNG().nextInt(20);
}
if (idle > 0) {
idle--;
npc.getLookHelper().setLookPosition(npc.posX + lookX, npc.posY + npc.getEyeHeight(), npc.posZ + lookZ, 10F, npc.getVerticalFaceSpeed());
}
}
if(npc.ais.standingType == EnumStandingType.NoRotation){
npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ais.orientation;
}
if (npc.ais.standingType == EnumStandingType.NoRotation) {
npc.rotationYawHead = npc.rotationYaw = npc.renderYawOffset = npc.ais.orientation;
}
}
}
@@ -9,16 +9,14 @@ import noppes.npcs.constants.AiMutex;
import java.util.Random;
public class EntityAIMoveIndoors extends EntityAIBase
{
public class EntityAIMoveIndoors extends EntityAIBase {
private EntityCreature theCreature;
private double shelterX;
private double shelterY;
private double shelterZ;
private World theWorld;
public EntityAIMoveIndoors(EntityCreature par1EntityCreature)
{
public EntityAIMoveIndoors(EntityCreature par1EntityCreature) {
this.theCreature = par1EntityCreature;
this.theWorld = par1EntityCreature.worldObj;
this.setMutexBits(AiMutex.PASSIVE);
@@ -27,70 +25,55 @@ public class EntityAIMoveIndoors extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
int x = MathHelper.floor_double(this.theCreature.posX);
int y = (int)this.theCreature.boundingBox.minY;
int z = MathHelper.floor_double(this.theCreature.posZ);
if ((!this.theCreature.worldObj.isDaytime() || this.theCreature.worldObj.isRaining()) && !this.theCreature.worldObj.provider.hasNoSky)
{
if (!this.theWorld.canBlockSeeTheSky(x, y, z) && this.theWorld.getFullBlockLightValue(x, y, z) > 8)
{
public boolean shouldExecute() {
int x = MathHelper.floor_double(this.theCreature.posX);
int y = (int) this.theCreature.boundingBox.minY;
int z = MathHelper.floor_double(this.theCreature.posZ);
if ((!this.theCreature.worldObj.isDaytime() || this.theCreature.worldObj.isRaining()) && !this.theCreature.worldObj.provider.hasNoSky) {
if (!this.theWorld.canBlockSeeTheSky(x, y, z) && this.theWorld.getFullBlockLightValue(x, y, z) > 8) {
return false;
} else {
Vec3 var1 = this.findPossibleShelter();
if (var1 == null) {
return false;
} else {
this.shelterX = var1.xCoord;
this.shelterY = var1.yCoord;
this.shelterZ = var1.zCoord;
return true;
}
}
else
{
Vec3 var1 = this.findPossibleShelter();
if (var1 == null)
{
return false;
}
else
{
this.shelterX = var1.xCoord;
this.shelterY = var1.yCoord;
this.shelterZ = var1.zCoord;
return true;
}
}
} else {
return false;
}
else
{
return false;
}
}
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return !this.theCreature.getNavigator().noPath();
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.theCreature.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, 1.0D);
}
private Vec3 findPossibleShelter()
{
private Vec3 findPossibleShelter() {
Random var1 = this.theCreature.getRNG();
for (int var2 = 0; var2 < 10; ++var2)
{
int var3 = MathHelper.floor_double(this.theCreature.posX + (double)var1.nextInt(20) - 10.0D);
int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double)var1.nextInt(6) - 3.0D);
int var5 = MathHelper.floor_double(this.theCreature.posZ + (double)var1.nextInt(20) - 10.0D);
for (int var2 = 0; var2 < 10; ++var2) {
int var3 = MathHelper.floor_double(this.theCreature.posX + (double) var1.nextInt(20) - 10.0D);
int var4 = MathHelper.floor_double(this.theCreature.boundingBox.minY + (double) var1.nextInt(6) - 3.0D);
int var5 = MathHelper.floor_double(this.theCreature.posZ + (double) var1.nextInt(20) - 10.0D);
if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && this.theWorld.getFullBlockLightValue(var3, var4, var5) > 8)
{
return Vec3.createVectorHelper((double)var3, (double)var4, (double)var5);
if (!this.theWorld.canBlockSeeTheSky(var3, var4, var5) && this.theWorld.getFullBlockLightValue(var3, var4, var5) > 8) {
return Vec3.createVectorHelper((double) var3, (double) var4, (double) var5);
}
}
@@ -6,12 +6,11 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
public class EntityAIMovingPath extends EntityAIBase
{
public class EntityAIMovingPath extends EntityAIBase {
private EntityNPCInterface npc;
private int[] pos;
public EntityAIMovingPath(EntityNPCInterface par1EntityNPCInterface){
public EntityAIMovingPath(EntityNPCInterface par1EntityNPCInterface) {
this.npc = par1EntityNPCInterface;
this.setMutexBits(AiMutex.PASSIVE);
}
@@ -20,16 +19,16 @@ public class EntityAIMovingPath extends EntityAIBase
* Returns whether the EntityAIBase should begin execution.
*/
@Override
public boolean shouldExecute(){
public boolean shouldExecute() {
if (npc.isAttacking() || npc.isInteracting() || npc.getRNG().nextInt(40) != 0 && npc.ais.movingPause || !npc.getNavigator().noPath() || npc.isInteracting())
return false;
List<int[]> list = npc.ais.getMovingPath();
if(list.size() < 2)
return false;
if (list.size() < 2)
return false;
npc.ais.incrementMovingPath();
pos = npc.ais.getCurrentMovingPath();
pos = npc.ais.getCurrentMovingPath();
return true;
}
@@ -38,11 +37,11 @@ public class EntityAIMovingPath extends EntityAIBase
* Returns whether an in-progress EntityAIBase should continue executing
*/
@Override
public boolean continueExecuting(){
if(npc.isAttacking() || npc.isInteracting()){
npc.ais.decreaseMovingPath();
return false;
}
public boolean continueExecuting() {
if (npc.isAttacking() || npc.isInteracting()) {
npc.ais.decreaseMovingPath();
return false;
}
return !this.npc.getNavigator().noPath();
}
@@ -50,7 +49,7 @@ public class EntityAIMovingPath extends EntityAIBase
* Execute a one shot task or start executing a continuous task
*/
@Override
public void startExecuting(){
public void startExecuting() {
this.npc.getNavigator().tryMoveToXYZ(pos[0] + 0.5, pos[1], pos[2] + 0.5, 1.0D);
}
}
@@ -8,8 +8,7 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.Random;
public class EntityAIOrbitTarget extends EntityAIBase
{
public class EntityAIOrbitTarget extends EntityAIBase {
private EntityNPCInterface theEntity;
private EntityLivingBase targetEntity;
private double movePosX;
@@ -26,8 +25,7 @@ public class EntityAIOrbitTarget extends EntityAIBase
private float decayRate = 1.0F;
private int tick = 0;
public EntityAIOrbitTarget(EntityNPCInterface par1EntityCreature, double par2, float par4, boolean par5)
{
public EntityAIOrbitTarget(EntityNPCInterface par1EntityCreature, double par2, float par4, boolean par5) {
this.theEntity = par1EntityCreature;
this.speed = par2;
this.distance = par4;
@@ -38,90 +36,78 @@ public class EntityAIOrbitTarget extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (--delay > 0)
{
return false;
}
this.targetEntity = this.theEntity.getAttackTarget();
if (this.targetEntity == null)
{
public boolean shouldExecute() {
if (--delay > 0) {
return false;
}
else
{
double d0 = this.theEntity.getDistanceToEntity(this.targetEntity);
return d0 >= this.distance / 2.0F && (this.theEntity.inventory.getProjectile() == null ? d0 <= this.distance : true);
this.targetEntity = this.theEntity.getAttackTarget();
if (this.targetEntity == null) {
return false;
} else {
double d0 = this.theEntity.getDistanceToEntity(this.targetEntity);
return d0 >= this.distance / 2.0F && (this.theEntity.inventory.getProjectile() == null ? d0 <= this.distance : true);
}
}
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
double d0 = this.targetEntity.getDistanceToEntity(this.theEntity);
return this.targetEntity.isEntityAlive() && d0 >= this.distance / 2.0F && d0 <= this.distance * 1.5F && !this.theEntity.isInWater() && this.canNavigate;
public boolean continueExecuting() {
double d0 = this.targetEntity.getDistanceToEntity(this.theEntity);
return this.targetEntity.isEntityAlive() && d0 >= this.distance / 2.0F && d0 <= this.distance * 1.5F && !this.theEntity.isInWater() && this.canNavigate;
}
/**
* Resets the task
*/
public void resetTask()
{
this.theEntity.getNavigator().clearPathEntity();
this.delay = 60;
if (this.theEntity.getRangedTask() != null){
this.theEntity.getRangedTask().navOverride(false);
public void resetTask() {
this.theEntity.getNavigator().clearPathEntity();
this.delay = 60;
if (this.theEntity.getRangedTask() != null) {
this.theEntity.getRangedTask().navOverride(false);
}
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
this.canNavigate = true;
Random random = this.theEntity.getRNG();
this.direction = random.nextInt(10) > 5 ? 1 : -1;
this.decayRate = random.nextFloat() + (this.distance / 16.0F);
public void startExecuting() {
this.canNavigate = true;
Random random = this.theEntity.getRNG();
this.direction = random.nextInt(10) > 5 ? 1 : -1;
this.decayRate = random.nextFloat() + (this.distance / 16.0F);
this.targetDistance = this.theEntity.getDistanceToEntity(this.targetEntity);
double d0 = this.theEntity.posX - this.targetEntity.posX;
double d1 = this.theEntity.posZ - this.targetEntity.posZ;
this.angle = (float) (Math.atan2(d1, d0) * 180.0F / Math.PI);
if (this.theEntity.getRangedTask() != null){
this.theEntity.getRangedTask().navOverride(true);
if (this.theEntity.getRangedTask() != null) {
this.theEntity.getRangedTask().navOverride(true);
}
}
/**
* Updates the task
*/
public void updateTask()
{
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
if (this.theEntity.getNavigator().noPath() && this.tick >= 0)
{
if (this.theEntity.onGround && !this.theEntity.isInWater())
{
double d0 = this.targetDistance * (double)(MathHelper.cos(angle / 180.0F * (float)Math.PI));
double d1 = this.targetDistance * (double)(MathHelper.sin(angle / 180.0F * (float)Math.PI));
this.movePosX = this.targetEntity.posX + d0;
this.movePosY = this.targetEntity.boundingBox.maxY;
this.movePosZ = this.targetEntity.posZ + d1;
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed);
this.angle += 15.0F * this.direction;
this.tick = MathHelper.ceiling_double_int(this.theEntity.getDistance(this.movePosX, this.movePosY, this.movePosZ) / (this.theEntity.getSpeed() / 20.0F));
if (this.decay)
{
this.targetDistance -=decayRate;
}
}
}
if (this.tick >= 0) this.tick--;
public void updateTask() {
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
if (this.theEntity.getNavigator().noPath() && this.tick >= 0) {
if (this.theEntity.onGround && !this.theEntity.isInWater()) {
double d0 = this.targetDistance * (double) (MathHelper.cos(angle / 180.0F * (float) Math.PI));
double d1 = this.targetDistance * (double) (MathHelper.sin(angle / 180.0F * (float) Math.PI));
this.movePosX = this.targetEntity.posX + d0;
this.movePosY = this.targetEntity.boundingBox.maxY;
this.movePosZ = this.targetEntity.posZ + d1;
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed);
this.angle += 15.0F * this.direction;
this.tick = MathHelper.ceiling_double_int(this.theEntity.getDistance(this.movePosX, this.movePosY, this.movePosZ) / (this.theEntity.getSpeed() / 20.0F));
if (this.decay) {
this.targetDistance -= decayRate;
}
}
}
if (this.tick >= 0) this.tick--;
}
}
+12 -17
View File
@@ -5,16 +5,14 @@ import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.util.Vec3;
import noppes.npcs.constants.AiMutex;
public class EntityAIPanic extends EntityAIBase
{
public class EntityAIPanic extends EntityAIBase {
private EntityCreature theEntityCreature;
private float speed;
private double randPosX;
private double randPosY;
private double randPosZ;
public EntityAIPanic(EntityCreature par1EntityCreature, float par2)
{
public EntityAIPanic(EntityCreature par1EntityCreature, float par2) {
this.theEntityCreature = par1EntityCreature;
this.speed = par2;
this.setMutexBits(AiMutex.PASSIVE);
@@ -23,18 +21,15 @@ public class EntityAIPanic extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute(){
if (this.theEntityCreature.getAttackTarget() == null && !this.theEntityCreature.isBurning()){
public boolean shouldExecute() {
if (this.theEntityCreature.getAttackTarget() == null && !this.theEntityCreature.isBurning()) {
return false;
}
else
{
} else {
Vec3 var1 = RandomPositionGeneratorAlt.findRandomTarget(this.theEntityCreature, 5, 4);
if (var1 == null){
if (var1 == null) {
return false;
}
else{
} else {
this.randPosX = var1.xCoord;
this.randPosY = var1.yCoord;
this.randPosZ = var1.zCoord;
@@ -46,16 +41,16 @@ public class EntityAIPanic extends EntityAIBase
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting(){
public void startExecuting() {
this.theEntityCreature.getNavigator().tryMoveToXYZ(this.randPosX, this.randPosY, this.randPosZ, this.speed);
}
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting(){
if(this.theEntityCreature.getAttackTarget() == null)
return false;
public boolean continueExecuting() {
if (this.theEntityCreature.getAttackTarget() == null)
return false;
return !this.theEntityCreature.getNavigator().noPath();
}
}
}
@@ -6,58 +6,58 @@ import net.minecraft.util.MathHelper;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIPounceTarget extends EntityAIBase {
private EntityNPCInterface npc;
private EntityLivingBase leapTarget;
private float leapSpeed = 1.2F;
private EntityNPCInterface npc;
private EntityLivingBase leapTarget;
private float leapSpeed = 1.2F;
public EntityAIPounceTarget(EntityNPCInterface leapingEntity){
public EntityAIPounceTarget(EntityNPCInterface leapingEntity) {
this.npc = leapingEntity;
this.setMutexBits(4);
}
@Override
public boolean shouldExecute(){
if(!this.npc.onGround)
return false;
public boolean shouldExecute() {
if (!this.npc.onGround)
return false;
this.leapTarget = this.npc.getAttackTarget();
if (this.leapTarget == null || !this.npc.getEntitySenses().canSee(leapTarget))
return false;
if (this.leapTarget == null || !this.npc.getEntitySenses().canSee(leapTarget))
return false;
return !npc.isInRange(leapTarget, 4) && npc.isInRange(leapTarget, 8) && this.npc.getRNG().nextInt(5) == 0;
}
@Override
public boolean continueExecuting(){
public boolean continueExecuting() {
return !this.npc.onGround;
}
@Override
public void startExecuting(){
double varX = this.leapTarget.posX - this.npc.posX;
double varY = this.leapTarget.boundingBox.minY - this.npc.boundingBox.minY;
double varZ = this.leapTarget.posZ - this.npc.posZ;
float varF = MathHelper.sqrt_double(varX * varX + varZ * varZ);
float angle = this.getAngleForXYZ(varX, varY, varZ, varF);
float yaw = (float)(Math.atan2(varX, varZ) * 180.0D / Math.PI);
this.npc.motionX = (double)(MathHelper.sin(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(angle / 180.0F * (float)Math.PI));
this.npc.motionZ = (double)(MathHelper.cos(yaw / 180.0F * (float)Math.PI) * MathHelper.cos(angle / 180.0F * (float)Math.PI));
this.npc.motionY = (double)(MathHelper.sin((angle + 1.0F) / 180.0F * (float)Math.PI));
public void startExecuting() {
double varX = this.leapTarget.posX - this.npc.posX;
double varY = this.leapTarget.boundingBox.minY - this.npc.boundingBox.minY;
double varZ = this.leapTarget.posZ - this.npc.posZ;
float varF = MathHelper.sqrt_double(varX * varX + varZ * varZ);
float angle = this.getAngleForXYZ(varX, varY, varZ, varF);
float yaw = (float) (Math.atan2(varX, varZ) * 180.0D / Math.PI);
this.npc.motionX = (double) (MathHelper.sin(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(angle / 180.0F * (float) Math.PI));
this.npc.motionZ = (double) (MathHelper.cos(yaw / 180.0F * (float) Math.PI) * MathHelper.cos(angle / 180.0F * (float) Math.PI));
this.npc.motionY = (double) (MathHelper.sin((angle + 1.0F) / 180.0F * (float) Math.PI));
this.npc.motionX *= this.leapSpeed;
this.npc.motionZ *= this.leapSpeed;
this.npc.motionY *= this.leapSpeed;
}
public float getAngleForXYZ(double varX, double varY, double varZ, double horiDist) {
float g = 0.1F;
float var1 = this.leapSpeed * this.leapSpeed;
double var2 = (g * horiDist);
double var3 = ((g * horiDist * horiDist) + (2 * varY * var1));
double var4 = (var1 * var1) - (g * var3);
if (var4 < 0) return 90.0F;
float var6 = var1 - MathHelper.sqrt_double(var4);
float var7 = (float) (Math.atan2(var6 , var2) * 180.0D / Math.PI);
return var7;
float g = 0.1F;
float var1 = this.leapSpeed * this.leapSpeed;
double var2 = (g * horiDist);
double var3 = ((g * horiDist * horiDist) + (2 * varY * var1));
double var4 = (var1 * var1) - (g * var3);
if (var4 < 0) return 90.0F;
float var6 = var1 - MathHelper.sqrt_double(var4);
float var7 = (float) (Math.atan2(var6, var2) * 180.0D / Math.PI);
return var7;
}
}
}
@@ -9,9 +9,10 @@ import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumNavType;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIRangedAttack extends EntityAIBase
{
/** The entity the AI instance has been applied to */
public class EntityAIRangedAttack extends EntityAIBase {
/**
* The entity the AI instance has been applied to
*/
private final EntityNPCInterface entityHost;
/**
@@ -31,16 +32,12 @@ public class EntityAIRangedAttack extends EntityAIBase
private boolean hasFired = false;
private boolean navOverride = false;
public EntityAIRangedAttack(IRangedAttackMob par1IRangedAttackMob)
{
if (!(par1IRangedAttackMob instanceof EntityLivingBase))
{
public EntityAIRangedAttack(IRangedAttackMob par1IRangedAttackMob) {
if (!(par1IRangedAttackMob instanceof EntityLivingBase)) {
throw new IllegalArgumentException("ArrowAttackGoal requires Mob implements RangedAttackMob");
}
else
{
} else {
this.rangedAttackEntityHost = par1IRangedAttackMob;
this.entityHost = (EntityNPCInterface)par1IRangedAttackMob;
this.entityHost = (EntityNPCInterface) par1IRangedAttackMob;
this.rangedAttackTime = this.entityHost.stats.minDelay / 2;
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
}
@@ -49,23 +46,21 @@ public class EntityAIRangedAttack extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
EntityLivingBase var1 = this.entityHost.getAttackTarget();
public boolean shouldExecute() {
EntityLivingBase var1 = this.entityHost.getAttackTarget();
if (var1 == null || !var1.isEntityAlive()) return false;
if(entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange) return false;
if (entityHost.getDistanceToEntity(var1) > entityHost.stats.aggroRange) return false;
if (this.entityHost.inventory.getProjectile() == null) return false;
if (this.entityHost.inventory.getProjectile() == null) return false;
double var2 = this.entityHost.getDistanceSq(var1.posX, var1.boundingBox.minY, var1.posZ);
double var3 = this.entityHost.ais.distanceToMelee * this.entityHost.ais.distanceToMelee;
if (this.entityHost.ais.useRangeMelee >= 1 && var2 <= var3) return false;
else
{
else {
this.attackTarget = var1;
return true;
}
@@ -74,16 +69,14 @@ public class EntityAIRangedAttack extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return this.shouldExecute() || !this.entityHost.getNavigator().noPath();
}
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
this.attackTarget = null;
this.entityHost.setAttackTarget(null);
this.entityHost.getNavigator().clearPathEntity();
@@ -95,77 +88,63 @@ public class EntityAIRangedAttack extends EntityAIBase
/**
* Updates the task
*/
public void updateTask()
{
this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F);
public void updateTask() {
this.entityHost.getLookHelper().setLookPositionWithEntity(this.attackTarget, 30.0F, 30.0F);
double var1 = this.entityHost.getDistanceSq(this.attackTarget.posX, this.attackTarget.boundingBox.minY, this.attackTarget.posZ);
float field_82642_h = this.entityHost.stats.rangedRange * this.entityHost.stats.rangedRange;
float field_82642_h = this.entityHost.stats.rangedRange * this.entityHost.stats.rangedRange;
if (!navOverride && this.entityHost.ais.directLOS)
{
if (this.entityHost.getEntitySenses().canSee(this.attackTarget))
{
++this.field_75318_f;
}
else
{
this.field_75318_f = 0;
}
int v = this.entityHost.ais.tacticalVariant == EnumNavType.Default ? 20 : 5;
if (var1 <= (double)field_82642_h && this.field_75318_f >= v)
{
this.entityHost.getNavigator().clearPathEntity();
}
else
{
this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, 1.0D);
}
if (!navOverride && this.entityHost.ais.directLOS) {
if (this.entityHost.getEntitySenses().canSee(this.attackTarget)) {
++this.field_75318_f;
} else {
this.field_75318_f = 0;
}
int v = this.entityHost.ais.tacticalVariant == EnumNavType.Default ? 20 : 5;
if (var1 <= (double) field_82642_h && this.field_75318_f >= v) {
this.entityHost.getNavigator().clearPathEntity();
} else {
this.entityHost.getNavigator().tryMoveToEntityLiving(this.attackTarget, 1.0D);
}
}
this.rangedAttackTime = Math.max(this.rangedAttackTime - 1, 0);
if (this.rangedAttackTime <= 0)
{
if (var1 <= (double)field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2))
{
if (this.field_70846_g++ <= this.entityHost.stats.burstCount)
{
this.rangedAttackTime = this.entityHost.stats.fireRate;
}
else
{
this.field_70846_g = 0;
this.hasFired = true;
this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay)));
}
if (this.rangedAttackTime <= 0) {
if (var1 <= (double) field_82642_h && (this.entityHost.getEntitySenses().canSee(this.attackTarget) || this.entityHost.ais.canFireIndirect == 2)) {
if (this.field_70846_g++ <= this.entityHost.stats.burstCount) {
this.rangedAttackTime = this.entityHost.stats.fireRate;
} else {
this.field_70846_g = 0;
this.hasFired = true;
this.rangedAttackTime = (this.entityHost.stats.maxDelay - MathHelper.floor_float(this.entityHost.getRNG().nextFloat() * (this.entityHost.stats.maxDelay - this.entityHost.stats.minDelay)));
}
if (this.field_70846_g > 1)
{
boolean indirect = false;
if (this.field_70846_g > 1) {
boolean indirect = false;
switch(this.entityHost.ais.canFireIndirect)
{
case 1 : indirect = var1 > (double)field_82642_h / 2; break;
case 2 : indirect = !this.entityHost.getEntitySenses().canSee(this.attackTarget);
}
switch (this.entityHost.ais.canFireIndirect) {
case 1:
indirect = var1 > (double) field_82642_h / 2;
break;
case 2:
indirect = !this.entityHost.getEntitySenses().canSee(this.attackTarget);
}
this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, indirect ? 1 : 0);
if (this.entityHost.currentAnimation != EnumAnimation.AIMING)
{
this.entityHost.swingItem();
}
}
this.rangedAttackEntityHost.attackEntityWithRangedAttack(this.attackTarget, indirect ? 1 : 0);
if (this.entityHost.currentAnimation != EnumAnimation.AIMING) {
this.entityHost.swingItem();
}
}
}
}
}
public boolean hasFired()
{
return this.hasFired;
public boolean hasFired() {
return this.hasFired;
}
public void navOverride(boolean nav){
this.navOverride = nav;
public void navOverride(boolean nav) {
this.navOverride = nav;
this.setMutexBits(this.navOverride ? AiMutex.PATHING : AiMutex.LOOK + AiMutex.PASSIVE);
}
}
+102 -107
View File
@@ -6,9 +6,8 @@ import noppes.npcs.config.ConfigMain;
import noppes.npcs.constants.EnumMovingType;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIReturn extends EntityAIBase
{
public static final int MaxTotalTicks = 600;
public class EntityAIReturn extends EntityAIBase {
public static final int MaxTotalTicks = 600;
private final EntityNPCInterface npc;
private int stuckTicks = 0;
private int totalTicks = 0;
@@ -19,8 +18,7 @@ public class EntityAIReturn extends EntityAIBase
private double[] preAttackPos;
private int stuckCount = 0;
public EntityAIReturn(EntityNPCInterface npc)
{
public EntityAIReturn(EntityNPCInterface npc) {
this.npc = npc;
this.setMutexBits(1);
}
@@ -29,131 +27,128 @@ public class EntityAIReturn extends EntityAIBase
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute() {
if (!npc.ais.returnToStart){
return false;
}
if (!npc.ais.returnToStart) {
return false;
}
if(npc.hasOwner() || npc.isKilled() || npc.isInteracting()){
return false;
}
if (npc.hasOwner() || npc.isKilled() || npc.isInteracting()) {
return false;
}
if (npc.ais.findShelter == 0 && (!npc.worldObj.isDaytime() || npc.worldObj.isRaining()) && !npc.worldObj.provider.hasNoSky){
if (npc.worldObj.canBlockSeeTheSky((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos()) || npc.worldObj.getFullBlockLightValue((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos()) <= 8){
if (npc.ais.findShelter == 0 && (!npc.worldObj.isDaytime() || npc.worldObj.isRaining()) && !npc.worldObj.provider.hasNoSky) {
if (npc.worldObj.canBlockSeeTheSky((int) npc.getStartXPos(), (int) npc.getStartYPos(), (int) npc.getStartZPos()) || npc.worldObj.getFullBlockLightValue((int) npc.getStartXPos(), (int) npc.getStartYPos(), (int) npc.getStartZPos()) <= 8) {
return false;
}
} else if (npc.ais.findShelter == 1 && npc.worldObj.isDaytime()) {
if (npc.worldObj.canBlockSeeTheSky((int) npc.getStartXPos(), (int) npc.getStartYPos(), (int) npc.getStartZPos())) {
return false;
}
}
else if (npc.ais.findShelter == 1 && npc.worldObj.isDaytime()){
if (npc.worldObj.canBlockSeeTheSky((int)npc.getStartXPos(), (int)npc.getStartYPos(), (int)npc.getStartZPos())){
return false;
if (npc.isAttacking()) {
if (!wasAttacked) {
wasAttacked = true;
preAttackPos = new double[]{npc.posX, npc.posY, npc.posZ};
}
}
return false;
}
if(npc.isAttacking()){
if(!wasAttacked){
wasAttacked = true;
preAttackPos = new double[]{npc.posX, npc.posY, npc.posZ};
}
return false;
}
if (npc.ais.movingType == EnumMovingType.MovingPath && npc.ais.getDistanceSqToPathPoint() < ConfigMain.NpcNavRange * ConfigMain.NpcNavRange)
return false;
if(npc.ais.movingType == EnumMovingType.MovingPath && npc.ais.getDistanceSqToPathPoint() < ConfigMain.NpcNavRange * ConfigMain.NpcNavRange)
return false;
if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)) {
return true;
}
if (npc.getNavigator().noPath() || (!npc.isAttacking() && wasAttacked)) {
return true;
}
if (npc.ais.movingType == EnumMovingType.Wandering)
return this.npc.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()) > npc.ais.walkingRange * npc.ais.walkingRange;
if(npc.ais.movingType == EnumMovingType.Wandering)
return this.npc.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos()) > npc.ais.walkingRange * npc.ais.walkingRange;
if(npc.ais.movingType == EnumMovingType.Standing)
return !this.npc.isVeryNearAssignedPlace();
if (npc.ais.movingType == EnumMovingType.Standing)
return !this.npc.isVeryNearAssignedPlace();
return false;
}
public boolean continueExecuting(){
public boolean continueExecuting() {
return !npc.isFollower() && !npc.isKilled() && !npc.isAttacking() && !npc.isVeryNearAssignedPlace() && totalTicks <= MaxTotalTicks && !npc.isInteracting();
}
public void updateTask(){
totalTicks++;
if(totalTicks > MaxTotalTicks){
npc.setPosition(endPosX, endPosY, endPosZ);
npc.getNavigator().clearPathEntity();
return;
}
public void updateTask() {
totalTicks++;
if (totalTicks > MaxTotalTicks) {
npc.setPosition(endPosX, endPosY, endPosZ);
npc.getNavigator().clearPathEntity();
return;
}
if(stuckTicks > 0){
stuckTicks--;
}
else if(npc.getNavigator().noPath()){
stuckCount++;
stuckTicks = 10;
if(totalTicks > 30 && wasAttacked && isTooFar() || stuckCount > 5 ){
npc.setPosition(endPosX, endPosY, endPosZ);
npc.getNavigator().clearPathEntity();
}
else
navigate(stuckCount % 2 == 1);
}
else{
stuckCount = 0;
}
}
private boolean isTooFar(){
int allowedDistance = npc.stats.aggroRange * 2;
if(npc.ais.movingType == EnumMovingType.Wandering)
allowedDistance += npc.ais.walkingRange;
return npc.getDistanceSq(endPosX, endPosY, endPosZ) > allowedDistance * allowedDistance;
if (stuckTicks > 0) {
stuckTicks--;
} else if (npc.getNavigator().noPath()) {
stuckCount++;
stuckTicks = 10;
if (totalTicks > 30 && wasAttacked && isTooFar() || stuckCount > 5) {
npc.setPosition(endPosX, endPosY, endPosZ);
npc.getNavigator().clearPathEntity();
} else
navigate(stuckCount % 2 == 1);
} else {
stuckCount = 0;
}
}
public void startExecuting()
{
stuckTicks = 0;
totalTicks = 0;
stuckCount = 0;
navigate(false);
private boolean isTooFar() {
int allowedDistance = npc.stats.aggroRange * 2;
if (npc.ais.movingType == EnumMovingType.Wandering)
allowedDistance += npc.ais.walkingRange;
return npc.getDistanceSq(endPosX, endPosY, endPosZ) > allowedDistance * allowedDistance;
}
public void startExecuting() {
stuckTicks = 0;
totalTicks = 0;
stuckCount = 0;
navigate(false);
}
private void navigate(boolean towards) {
if(!wasAttacked){
endPosX = npc.getStartXPos();
endPosY = npc.getStartYPos();
endPosZ = npc.getStartZPos();
}
else{
endPosX = preAttackPos[0];
endPosY = preAttackPos[1];
endPosZ = preAttackPos[2];
}
double posX = endPosX;
double posY = endPosY;
double posZ = endPosZ;
double range = npc.getDistance(posX, posY, posZ);
if(range > ConfigMain.NpcNavRange || towards){
int distance = (int) range;
if(distance > ConfigMain.NpcNavRange)
distance = ConfigMain.NpcNavRange / 2;
else
distance /= 2;
if(distance > 2){
Vec3 start = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 pos = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(npc, distance, Math.min(distance / 2, 7), start);
if(pos != null){
posX = pos.xCoord;
posY = pos.yCoord;
posZ = pos.zCoord;
}
}
}
if (!wasAttacked) {
endPosX = npc.getStartXPos();
endPosY = npc.getStartYPos();
endPosZ = npc.getStartZPos();
} else {
endPosX = preAttackPos[0];
endPosY = preAttackPos[1];
endPosZ = preAttackPos[2];
}
double posX = endPosX;
double posY = endPosY;
double posZ = endPosZ;
double range = npc.getDistance(posX, posY, posZ);
if (range > ConfigMain.NpcNavRange || towards) {
int distance = (int) range;
if (distance > ConfigMain.NpcNavRange)
distance = ConfigMain.NpcNavRange / 2;
else
distance /= 2;
if (distance > 2) {
Vec3 start = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 pos = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(npc, distance, Math.min(distance / 2, 7), start);
if (pos != null) {
posX = pos.xCoord;
posY = pos.yCoord;
posZ = pos.zCoord;
}
}
}
if (range > 1.1f) {
npc.getNavigator().clearPathEntity();
npc.getNavigator().tryMoveToXYZ(posX, posY, posZ, 1);
}
}
if (range > 1.1f) {
npc.getNavigator().clearPathEntity();
npc.getNavigator().tryMoveToXYZ(posX, posY, posZ, 1);
}
}
public void resetTask(){
wasAttacked = false;
public void resetTask() {
wasAttacked = false;
this.npc.getNavigator().clearPathEntity();
}
}
+25 -26
View File
@@ -5,33 +5,32 @@ import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIRole extends EntityAIBase {
private EntityNPCInterface npc;
public EntityAIRole(EntityNPCInterface npc){
this.npc = npc;
}
@Override
public boolean shouldExecute() {
if(npc.isKilled() || npc.roleInterface == null)
return false;
return npc.roleInterface.aiShouldExecute();
}
public void startExecuting()
{
npc.roleInterface.aiStartExecuting();
private EntityNPCInterface npc;
public EntityAIRole(EntityNPCInterface npc) {
this.npc = npc;
}
@Override
public boolean continueExecuting()
{
if(npc.isKilled() || npc.roleInterface == null)
return false;
return npc.roleInterface.aiContinueExecute();
@Override
public boolean shouldExecute() {
if (npc.isKilled() || npc.roleInterface == null)
return false;
return npc.roleInterface.aiShouldExecute();
}
public void updateTask(){
if(npc.roleInterface != null)
npc.roleInterface.aiUpdateTask();
public void startExecuting() {
npc.roleInterface.aiStartExecuting();
}
@Override
public boolean continueExecuting() {
if (npc.isKilled() || npc.roleInterface == null)
return false;
return npc.roleInterface.aiContinueExecute();
}
public void updateTask() {
if (npc.roleInterface != null)
npc.roleInterface.aiUpdateTask();
}
}
@@ -5,27 +5,29 @@ import net.minecraft.entity.ai.EntityAIBase;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAISprintToTarget extends EntityAIBase
{
public class EntityAISprintToTarget extends EntityAIBase {
private EntityNPCInterface npc;
public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving){
public EntityAISprintToTarget(EntityNPCInterface par1EntityLiving) {
this.npc = par1EntityLiving;
this.setMutexBits(AiMutex.PASSIVE);
}
@Override
public boolean shouldExecute(){
public boolean shouldExecute() {
EntityLivingBase runTarget = this.npc.getAttackTarget();
if (runTarget == null || this.npc.getNavigator().noPath()){
if (runTarget == null || this.npc.getNavigator().noPath()) {
return false;
}
switch(this.npc.ais.onAttack){
case 0 : return !this.npc.isInRange(runTarget, 8)? (!this.npc.onGround ? false : true) : false;
case 2 : return this.npc.isInRange(runTarget, 7)? (!this.npc.onGround ? false : true) : false;
default : return false;
switch (this.npc.ais.onAttack) {
case 0:
return !this.npc.isInRange(runTarget, 8) ? (!this.npc.onGround ? false : true) : false;
case 2:
return this.npc.isInRange(runTarget, 7) ? (!this.npc.onGround ? false : true) : false;
default:
return false;
}
}
@@ -33,8 +35,7 @@ public class EntityAISprintToTarget extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
public boolean continueExecuting() {
return this.npc.isEntityAlive() && this.npc.onGround && this.npc.hurtTime <= 0 && (this.npc.motionX != 0.0D && this.npc.motionZ != 0.0D);
}
@@ -42,7 +43,7 @@ public class EntityAISprintToTarget extends EntityAIBase
* Execute a one shot task or start executing a continuous task
*/
@Override
public void startExecuting(){
public void startExecuting() {
this.npc.setSprinting(true);
}
@@ -50,7 +51,7 @@ public class EntityAISprintToTarget extends EntityAIBase
* Resets the task
*/
@Override
public void resetTask(){
public void resetTask() {
this.npc.setSprinting(false);
}
}
@@ -9,9 +9,8 @@ import net.minecraft.world.World;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIStalkTarget extends EntityAIBase
{
private EntityNPCInterface theEntity;
public class EntityAIStalkTarget extends EntityAIBase {
private EntityNPCInterface theEntity;
private EntityLivingBase targetEntity;
private Vec3 movePosition;
private double distance;
@@ -20,8 +19,7 @@ public class EntityAIStalkTarget extends EntityAIBase
private int delay;
private int tick = 0;
public EntityAIStalkTarget(EntityNPCInterface par1EntityCreature, double par2)
{
public EntityAIStalkTarget(EntityNPCInterface par1EntityCreature, double par2) {
this.theEntity = par1EntityCreature;
this.theWorld = par1EntityCreature.worldObj;
this.distance = par2 * par2;
@@ -33,176 +31,140 @@ public class EntityAIStalkTarget extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
this.targetEntity = this.theEntity.getAttackTarget();
public boolean shouldExecute() {
this.targetEntity = this.theEntity.getAttackTarget();
if (this.targetEntity == null)
{
if (this.targetEntity == null) {
return false;
}
else if (this.tick > 0)
{
this.tick--;
return false;
}
else
{
return this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance;
} else if (this.tick > 0) {
this.tick--;
return false;
} else {
return this.targetEntity.getDistanceSqToEntity(this.theEntity) > this.distance;
}
}
/**
* Resets the task
*/
public void resetTask()
{
public void resetTask() {
this.theEntity.getNavigator().clearPathEntity();
if (this.theEntity.getAttackTarget() == null && this.targetEntity != null)
{
this.theEntity.setAttackTarget(targetEntity);
if (this.theEntity.getAttackTarget() == null && this.targetEntity != null) {
this.theEntity.setAttackTarget(targetEntity);
}
if (this.theEntity.getRangedTask() != null)
{
this.theEntity.getRangedTask().navOverride(false);
if (this.theEntity.getRangedTask() != null) {
this.theEntity.getRangedTask().navOverride(false);
}
}
public void startExecuting()
{
if (this.theEntity.getRangedTask() != null)
{
this.theEntity.getRangedTask().navOverride(true);
public void startExecuting() {
if (this.theEntity.getRangedTask() != null) {
this.theEntity.getRangedTask().navOverride(true);
}
}
/**
* Updates the task
*/
public void updateTask()
{
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
if (this.theEntity.getNavigator().noPath() || this.overRide)
{
if (this.isLookingAway())
{
this.movePosition = this.stalkTarget();
if (this.movePosition != null)
{
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.0D);
this.overRide = false;
}
else
{
this.tick = 100;
}
}
else if (this.theEntity.canSee(targetEntity))
{
this.movePosition = this.hideFromTarget();
if (this.movePosition != null)
{
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.33D);
this.overRide = false;
}
else
{
this.tick = 100;
}
}
}
if (this.delay > 0) this.delay--;
if (!this.isLookingAway() && this.theEntity.canSee(targetEntity) && this.delay == 0)
{
this.overRide = true;
this.delay = 60;
}
public void updateTask() {
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
if (this.theEntity.getNavigator().noPath() || this.overRide) {
if (this.isLookingAway()) {
this.movePosition = this.stalkTarget();
if (this.movePosition != null) {
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.0D);
this.overRide = false;
} else {
this.tick = 100;
}
} else if (this.theEntity.canSee(targetEntity)) {
this.movePosition = this.hideFromTarget();
if (this.movePosition != null) {
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosition.xCoord, this.movePosition.yCoord, this.movePosition.zCoord, 1.33D);
this.overRide = false;
} else {
this.tick = 100;
}
}
}
if (this.delay > 0) this.delay--;
if (!this.isLookingAway() && this.theEntity.canSee(targetEntity) && this.delay == 0) {
this.overRide = true;
this.delay = 60;
}
}
private Vec3 hideFromTarget()
{
Vec3 vec;
for (int i = 1; i <= 8; i++)
{
vec = findSecludedXYZ(i, false);
if (vec != null) {
return vec;
}
}
return null;
private Vec3 hideFromTarget() {
Vec3 vec;
for (int i = 1; i <= 8; i++) {
vec = findSecludedXYZ(i, false);
if (vec != null) {
return vec;
}
}
return null;
}
private Vec3 stalkTarget()
{
Vec3 vec;
for (int i = 8; i >= 1; i--)
{
vec = findSecludedXYZ(i, true);
if (vec != null) {
return vec;
}
}
return null;
}
private Vec3 findSecludedXYZ(int radius, boolean nearest)
{
Vec3 idealPos = null;
boolean weight;
double dist = this.targetEntity.getDistanceSqToEntity(this.theEntity);
double u = 0, v = 0, w = 0;
if (this.movePosition != null)
{
u = this.movePosition.xCoord;
v = this.movePosition.yCoord;
w = this.movePosition.zCoord;
}
for (int y = -2; y <= 2; y++)
{
for (int x = -radius; x <= radius; x++)
{
for (int z = -radius; z <= radius; z++)
{
double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D;
double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y);
double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D;
if (this.theWorld.getBlock((int)j, (int)k, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 1, (int)l).isOpaqueCube() && !this.theWorld.getBlock((int)j, (int)k + 2, (int)l).isOpaqueCube())
{
Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double)this.targetEntity.getEyeHeight(), this.targetEntity.posZ);
Vec3 vec2 = Vec3.createVectorHelper(j, k + (double)this.theEntity.getEyeHeight(), l);
MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2);
if (movingobjectposition != null)
{
weight = nearest ? this.targetEntity.getDistanceSq(j, k, l) <= dist : true;
if (weight && (j != u || k != v || l != w))
{
idealPos = Vec3.createVectorHelper(j, k, l);
if (nearest) dist = this.targetEntity.getDistanceSq(j, k, l);
}
}
}
}
}
}
return idealPos;
private Vec3 stalkTarget() {
Vec3 vec;
for (int i = 8; i >= 1; i--) {
vec = findSecludedXYZ(i, true);
if (vec != null) {
return vec;
}
}
return null;
}
private boolean isLookingAway()
{
Vec3 vec3 = this.targetEntity.getLook(1.0F).normalize();
Vec3 vec31 = Vec3.createVectorHelper(this.theEntity.posX - this.targetEntity.posX, this.theEntity.boundingBox.minY + (double)(this.theEntity.height / 2.0F) - (this.targetEntity.posY + (double)this.targetEntity.getEyeHeight()), this.theEntity.posZ - this.targetEntity.posZ);
private Vec3 findSecludedXYZ(int radius, boolean nearest) {
Vec3 idealPos = null;
boolean weight;
double dist = this.targetEntity.getDistanceSqToEntity(this.theEntity);
double u = 0, v = 0, w = 0;
if (this.movePosition != null) {
u = this.movePosition.xCoord;
v = this.movePosition.yCoord;
w = this.movePosition.zCoord;
}
for (int y = -2; y <= 2; y++) {
for (int x = -radius; x <= radius; x++) {
for (int z = -radius; z <= radius; z++) {
double j = MathHelper.floor_double(this.theEntity.posX + x) + 0.5D;
double k = MathHelper.floor_double(this.theEntity.boundingBox.minY + y);
double l = MathHelper.floor_double(this.theEntity.posZ + z) + 0.5D;
if (this.theWorld.getBlock((int) j, (int) k, (int) l).isOpaqueCube() && !this.theWorld.getBlock((int) j, (int) k + 1, (int) l).isOpaqueCube() && !this.theWorld.getBlock((int) j, (int) k + 2, (int) l).isOpaqueCube()) {
Vec3 vec1 = Vec3.createVectorHelper(this.targetEntity.posX, this.targetEntity.posY + (double) this.targetEntity.getEyeHeight(), this.targetEntity.posZ);
Vec3 vec2 = Vec3.createVectorHelper(j, k + (double) this.theEntity.getEyeHeight(), l);
MovingObjectPosition movingobjectposition = this.theWorld.rayTraceBlocks(vec1, vec2);
if (movingobjectposition != null) {
weight = nearest ? this.targetEntity.getDistanceSq(j, k, l) <= dist : true;
if (weight && (j != u || k != v || l != w)) {
idealPos = Vec3.createVectorHelper(j, k, l);
if (nearest) dist = this.targetEntity.getDistanceSq(j, k, l);
}
}
}
}
}
}
return idealPos;
}
private boolean isLookingAway() {
Vec3 vec3 = this.targetEntity.getLook(1.0F).normalize();
Vec3 vec31 = Vec3.createVectorHelper(this.theEntity.posX - this.targetEntity.posX, this.theEntity.boundingBox.minY + (double) (this.theEntity.height / 2.0F) - (this.targetEntity.posY + (double) this.targetEntity.getEyeHeight()), this.theEntity.posZ - this.targetEntity.posZ);
double d0 = vec31.lengthVector();
vec31 = vec31.normalize();
double d1 = vec3.dotProduct(vec31);
return d1 < 0.6;
}
}
}
@@ -6,21 +6,22 @@ import noppes.npcs.entity.EntityNPCInterface;
public class EntityAITransform extends EntityAIBase {
private EntityNPCInterface npc;
public EntityAITransform(EntityNPCInterface npc){
this.npc = npc;
setMutexBits(AiMutex.PASSIVE);
}
@Override
public boolean shouldExecute() {
if(npc.isKilled() || npc.isAttacking() || npc.transform.editingModus)
return false;
private EntityNPCInterface npc;
return npc.worldObj.getWorldTime() % 24000 < 12000?npc.transform.isActive:!npc.transform.isActive;
}
public void startExecuting(){
npc.transform.transform(!npc.transform.isActive);
public EntityAITransform(EntityNPCInterface npc) {
this.npc = npc;
setMutexBits(AiMutex.PASSIVE);
}
@Override
public boolean shouldExecute() {
if (npc.isKilled() || npc.isAttacking() || npc.transform.editingModus)
return false;
return npc.worldObj.getWorldTime() % 24000 < 12000 ? npc.transform.isActive : !npc.transform.isActive;
}
public void startExecuting() {
npc.transform.transform(!npc.transform.isActive);
}
}
@@ -13,8 +13,7 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.Iterator;
import java.util.List;
public class EntityAIWander extends EntityAIBase
{
public class EntityAIWander extends EntityAIBase {
private EntityNPCInterface entity;
public final IEntitySelector selector;
private double xPosition;
@@ -22,36 +21,34 @@ public class EntityAIWander extends EntityAIBase
private double zPosition;
private EntityNPCInterface nearbyNPC;
public EntityAIWander(EntityNPCInterface npc){
public EntityAIWander(EntityNPCInterface npc) {
this.entity = npc;
this.setMutexBits(AiMutex.PASSIVE);
selector = new NPCInteractSelector(npc);
}
@Override
public boolean shouldExecute(){
if (this.entity.getAge() >= 100 || !entity.getNavigator().noPath() || entity.isInteracting() || this.entity.getRNG().nextInt(80) != 0){
public boolean shouldExecute() {
if (this.entity.getAge() >= 100 || !entity.getNavigator().noPath() || entity.isInteracting() || this.entity.getRNG().nextInt(80) != 0) {
return false;
}
if(entity.ais.npcInteracting && entity.getRNG().nextInt(4) == 1)
nearbyNPC = getNearbyNPC();
if (entity.ais.npcInteracting && entity.getRNG().nextInt(4) == 1)
nearbyNPC = getNearbyNPC();
if(nearbyNPC != null){
if (nearbyNPC != null) {
this.xPosition = MathHelper.floor_double(nearbyNPC.posX);
this.yPosition = MathHelper.floor_double(nearbyNPC.posY);
this.zPosition = MathHelper.floor_double(nearbyNPC.posZ);
nearbyNPC.addInteract(entity);
}
else{
Vec3 vec = getVec();
if (vec == null){
nearbyNPC.addInteract(entity);
} else {
Vec3 vec = getVec();
if (vec == null) {
return false;
}
else{
} else {
this.xPosition = vec.xCoord;
this.yPosition = vec.yCoord;
if(entity.canFly())
if (entity.canFly())
this.yPosition = entity.getStartYPos() + entity.getRNG().nextFloat() * 0.75 * entity.ais.walkingRange;
this.zPosition = vec.zCoord;
}
@@ -61,70 +58,70 @@ public class EntityAIWander extends EntityAIBase
@Override
public void updateTask() {
if(nearbyNPC != null){
nearbyNPC.getNavigator().clearPathEntity();
}
if (nearbyNPC != null) {
nearbyNPC.getNavigator().clearPathEntity();
}
}
private EntityNPCInterface getNearbyNPC() {
List<EntityNPCInterface> list = entity.worldObj.getEntitiesWithinAABBExcludingEntity(entity, entity.boundingBox.expand(entity.ais.walkingRange, entity.ais.walkingRange > 7?7:entity.ais.walkingRange, entity.ais.walkingRange), selector);
Iterator<EntityNPCInterface> ita = list.iterator();
while(ita.hasNext()){
EntityNPCInterface npc = ita.next();
if(!npc.ais.stopAndInteract || npc.isAttacking() || !npc.isEntityAlive() || entity.faction.isAggressiveToNpc(npc))
ita.remove();
}
List<EntityNPCInterface> list = entity.worldObj.getEntitiesWithinAABBExcludingEntity(entity, entity.boundingBox.expand(entity.ais.walkingRange, entity.ais.walkingRange > 7 ? 7 : entity.ais.walkingRange, entity.ais.walkingRange), selector);
Iterator<EntityNPCInterface> ita = list.iterator();
while (ita.hasNext()) {
EntityNPCInterface npc = ita.next();
if (!npc.ais.stopAndInteract || npc.isAttacking() || !npc.isEntityAlive() || entity.faction.isAggressiveToNpc(npc))
ita.remove();
}
if(list.isEmpty())
return null;
if (list.isEmpty())
return null;
return list.get(entity.getRNG().nextInt(list.size()));
}
return list.get(entity.getRNG().nextInt(list.size()));
}
private Vec3 getVec(){
if(entity.ais.walkingRange > 0){
private Vec3 getVec() {
if (entity.ais.walkingRange > 0) {
double distance = this.entity.getDistanceSq(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos());
int range = (int) MathHelper.sqrt_double(this.entity.ais.walkingRange * this.entity.ais.walkingRange - distance);
if(range > ConfigMain.NpcNavRange)
range = ConfigMain.NpcNavRange;
if(range < 3){
if (range > ConfigMain.NpcNavRange)
range = ConfigMain.NpcNavRange;
if (range < 3) {
range = this.entity.ais.walkingRange;
if(range > ConfigMain.NpcNavRange)
range = ConfigMain.NpcNavRange;
if (range > ConfigMain.NpcNavRange)
range = ConfigMain.NpcNavRange;
Vec3 start = Vec3.createVectorHelper(this.entity.getStartXPos(), this.entity.getStartYPos(), this.entity.getStartZPos());
return RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.entity, range / 2, range / 2 > 7?7:range / 2, start);
return RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.entity, range / 2, range / 2 > 7 ? 7 : range / 2, start);
} else {
return RandomPositionGeneratorAlt.findRandomTarget(this.entity, range, range / 2 > 7 ? 7 : range / 2);
}
else{
return RandomPositionGeneratorAlt.findRandomTarget(this.entity, range, range / 2 > 7?7:range / 2);
}
}
return RandomPositionGeneratorAlt.findRandomTarget(this.entity, ConfigMain.NpcNavRange, 7);
}
return RandomPositionGeneratorAlt.findRandomTarget(this.entity, ConfigMain.NpcNavRange, 7);
}
@Override
public boolean continueExecuting(){
if(nearbyNPC != null && (!selector.isEntityApplicable(nearbyNPC) || entity.getDistanceSqToEntity(nearbyNPC) < entity.width * 1.5))
return false;
public boolean continueExecuting() {
if (nearbyNPC != null && (!selector.isEntityApplicable(nearbyNPC) || entity.getDistanceSqToEntity(nearbyNPC) < entity.width * 1.5))
return false;
return !this.entity.getNavigator().noPath() && this.entity.isEntityAlive() && !entity.isInteracting();
}
@Override
public void startExecuting(){
public void startExecuting() {
this.entity.getNavigator().tryMoveToXYZ(this.xPosition, this.yPosition, this.zPosition, 1);
}
@Override
public void resetTask() {
if(nearbyNPC != null && entity.getDistanceSqToEntity(nearbyNPC) < 12){
Line line = new Line(".........");
line.hideText = true;
if(entity.getRNG().nextBoolean())
entity.saySurrounding(line);
else
nearbyNPC.saySurrounding(line);
if (nearbyNPC != null && entity.getDistanceSqToEntity(nearbyNPC) < 12) {
Line line = new Line(".........");
line.hideText = true;
if (entity.getRNG().nextBoolean())
entity.saySurrounding(line);
else
nearbyNPC.saySurrounding(line);
entity.addInteract(nearbyNPC);
nearbyNPC.addInteract(entity);
}
nearbyNPC = null;
entity.addInteract(nearbyNPC);
nearbyNPC.addInteract(entity);
}
nearbyNPC = null;
}
}
@@ -6,18 +6,19 @@ import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIWatchClosest extends EntityAIBase
{
public class EntityAIWatchClosest extends EntityAIBase {
private EntityNPCInterface theWatcher;
/** The closest entity which is being watched by this one. */
/**
* The closest entity which is being watched by this one.
*/
protected Entity closestEntity;
private float field_75333_c;
private int lookTime;
private float field_75331_e;
private Class watchedClass;
public EntityAIWatchClosest(EntityNPCInterface par1EntityLiving, Class par2Class, float par3){
public EntityAIWatchClosest(EntityNPCInterface par1EntityLiving, Class par2Class, float par3) {
this.theWatcher = par1EntityLiving;
this.watchedClass = par2Class;
this.field_75333_c = par3;
@@ -29,26 +30,20 @@ public class EntityAIWatchClosest extends EntityAIBase
* Returns whether the EntityAIBase should begin execution.
*/
@Override
public boolean shouldExecute(){
if (this.theWatcher.getRNG().nextFloat() >= this.field_75331_e || theWatcher.isInteracting()){
public boolean shouldExecute() {
if (this.theWatcher.getRNG().nextFloat() >= this.field_75331_e || theWatcher.isInteracting()) {
return false;
}
else{
if (this.theWatcher.getAttackTarget() != null)
{
} else {
if (this.theWatcher.getAttackTarget() != null) {
this.closestEntity = this.theWatcher.getAttackTarget();
}
if (this.watchedClass == EntityPlayer.class)
{
this.closestEntity = this.theWatcher.worldObj.getClosestPlayerToEntity(this.theWatcher, (double)this.field_75333_c);
}
else
{
this.closestEntity = this.theWatcher.worldObj.findNearestEntityWithinAABB(this.watchedClass, this.theWatcher.boundingBox.expand((double)this.field_75333_c, 3.0D, (double)this.field_75333_c), this.theWatcher);
if (this.closestEntity != null)
{
return this.theWatcher.canSee(this.closestEntity);
if (this.watchedClass == EntityPlayer.class) {
this.closestEntity = this.theWatcher.worldObj.getClosestPlayerToEntity(this.theWatcher, (double) this.field_75333_c);
} else {
this.closestEntity = this.theWatcher.worldObj.findNearestEntityWithinAABB(this.watchedClass, this.theWatcher.boundingBox.expand((double) this.field_75333_c, 3.0D, (double) this.field_75333_c), this.theWatcher);
if (this.closestEntity != null) {
return this.theWatcher.canSee(this.closestEntity);
}
}
@@ -60,18 +55,17 @@ public class EntityAIWatchClosest extends EntityAIBase
* Returns whether an in-progress EntityAIBase should continue executing
*/
@Override
public boolean continueExecuting()
{
if(theWatcher.isInteracting() || theWatcher.isAttacking() || !this.closestEntity.isEntityAlive() || !theWatcher.isEntityAlive())
return false;
return this.theWatcher.getDistanceSqToEntity(this.closestEntity) > (double)(this.field_75333_c * this.field_75333_c) ? false : this.lookTime > 0;
public boolean continueExecuting() {
if (theWatcher.isInteracting() || theWatcher.isAttacking() || !this.closestEntity.isEntityAlive() || !theWatcher.isEntityAlive())
return false;
return this.theWatcher.getDistanceSqToEntity(this.closestEntity) > (double) (this.field_75333_c * this.field_75333_c) ? false : this.lookTime > 0;
}
/**
* Execute a one shot task or start executing a continuous task
*/
@Override
public void startExecuting(){
public void startExecuting() {
this.lookTime = 60 + this.theWatcher.getRNG().nextInt(60);
}
@@ -79,7 +73,7 @@ public class EntityAIWatchClosest extends EntityAIBase
* Resets the task
*/
@Override
public void resetTask(){
public void resetTask() {
this.closestEntity = null;
}
@@ -87,9 +81,8 @@ public class EntityAIWatchClosest extends EntityAIBase
* Updates the task
*/
@Override
public void updateTask()
{
this.theWatcher.getLookHelper().setLookPosition(this.closestEntity.posX, this.closestEntity.posY + (double)this.closestEntity.getEyeHeight(), this.closestEntity.posZ, 10.0F, (float)this.theWatcher.getVerticalFaceSpeed());
public void updateTask() {
this.theWatcher.getLookHelper().setLookPosition(this.closestEntity.posX, this.closestEntity.posY + (double) this.closestEntity.getEyeHeight(), this.closestEntity.posZ, 10.0F, (float) this.theWatcher.getVerticalFaceSpeed());
--this.lookTime;
}
}
@@ -3,12 +3,10 @@ package noppes.npcs.ai;
import net.minecraft.entity.ai.EntityAIBase;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIWaterNav extends EntityAIBase
{
public class EntityAIWaterNav extends EntityAIBase {
private EntityNPCInterface theEntity;
public EntityAIWaterNav(EntityNPCInterface par1EntityNPCInterface)
{
public EntityAIWaterNav(EntityNPCInterface par1EntityNPCInterface) {
this.theEntity = par1EntityNPCInterface;
par1EntityNPCInterface.getNavigator().setCanSwim(true);
}
@@ -16,18 +14,13 @@ public class EntityAIWaterNav extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (this.theEntity.isInWater() || this.theEntity.handleLavaMovement())
{
if (this.theEntity.ais.canSwim)
{
return true;
}
else if (this.theEntity.isCollidedHorizontally)
{
return true;
}
public boolean shouldExecute() {
if (this.theEntity.isInWater() || this.theEntity.handleLavaMovement()) {
if (this.theEntity.ais.canSwim) {
return true;
} else if (this.theEntity.isCollidedHorizontally) {
return true;
}
}
return false;
@@ -36,10 +29,8 @@ public class EntityAIWaterNav extends EntityAIBase
/**
* Updates the task
*/
public void updateTask()
{
if (this.theEntity.getRNG().nextFloat() < 0.8F)
{
public void updateTask() {
if (this.theEntity.getRNG().nextFloat() < 0.8F) {
this.theEntity.getJumpHelper().setJumping();
}
}
@@ -9,20 +9,20 @@ public class EntityAIWorldLines extends EntityAIBase {
private EntityNPCInterface npc;
private int cooldown = 100;
public EntityAIWorldLines(EntityNPCInterface npc){
public EntityAIWorldLines(EntityNPCInterface npc) {
this.npc = npc;
this.setMutexBits(AiMutex.PASSIVE);
}
@Override
public boolean shouldExecute() {
if(cooldown > 0){
if (cooldown > 0) {
cooldown--;
}
return !npc.isAttacking() && !npc.isKilled() && npc.advanced.hasWorldLines() && npc.getRNG().nextInt(1800) == 1;
}
public void startExecuting(){
public void startExecuting() {
cooldown = 100;
npc.saySurrounding(npc.advanced.getWorldLine());
}
@@ -9,8 +9,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import noppes.npcs.constants.AiMutex;
public class EntityAIZigZagTarget extends EntityAIBase
{
public class EntityAIZigZagTarget extends EntityAIBase {
private EntityCreature theEntity;
private EntityLivingBase targetEntity;
private double movePosX;
@@ -22,8 +21,7 @@ public class EntityAIZigZagTarget extends EntityAIBase
private double speed;
private float tacticalRange;
public EntityAIZigZagTarget(EntityCreature par1EntityCreature, double par2, float par4)
{
public EntityAIZigZagTarget(EntityCreature par1EntityCreature, double par2, float par4) {
this.theEntity = par1EntityCreature;
this.speed = par2;
this.tacticalRange = par4;
@@ -33,44 +31,34 @@ public class EntityAIZigZagTarget extends EntityAIBase
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
public boolean shouldExecute() {
this.targetEntity = this.theEntity.getAttackTarget();
if (this.targetEntity == null)
{
if (this.targetEntity == null) {
return false;
}
else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < (double)(this.tacticalRange * this.tacticalRange))
{
} else if (this.targetEntity.getDistanceSqToEntity(this.theEntity) < (double) (this.tacticalRange * this.tacticalRange)) {
return false;
}
else
{
PathEntity pathentity = this.theEntity.getNavigator().getPathToEntityLiving(targetEntity);
} else {
PathEntity pathentity = this.theEntity.getNavigator().getPathToEntityLiving(targetEntity);
if (pathentity != null)
{
if (pathentity.getCurrentPathLength() >= this.tacticalRange)
{
PathPoint pathpoint = pathentity.getPathPointFromIndex(MathHelper.floor_double(this.tacticalRange / 2.0D));
this.entityPosX = pathpoint.xCoord;
this.entityPosY = pathpoint.yCoord;
this.entityPosZ = pathpoint.zCoord;
Vec3 vec3 = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.theEntity, (int) tacticalRange, 3, Vec3.createVectorHelper(this.entityPosX, this.entityPosY, this.entityPosZ));
if (vec3 != null)
{
if (this.targetEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.targetEntity.getDistanceSq(entityPosX, entityPosY, entityPosZ))
{
this.movePosX = vec3.xCoord;
this.movePosY = vec3.yCoord;
this.movePosZ = vec3.zCoord;
return true;
}
}
}
if (pathentity != null) {
if (pathentity.getCurrentPathLength() >= this.tacticalRange) {
PathPoint pathpoint = pathentity.getPathPointFromIndex(MathHelper.floor_double(this.tacticalRange / 2.0D));
this.entityPosX = pathpoint.xCoord;
this.entityPosY = pathpoint.yCoord;
this.entityPosZ = pathpoint.zCoord;
Vec3 vec3 = RandomPositionGeneratorAlt.findRandomTargetBlockTowards(this.theEntity, (int) tacticalRange, 3, Vec3.createVectorHelper(this.entityPosX, this.entityPosY, this.entityPosZ));
if (vec3 != null) {
if (this.targetEntity.getDistanceSq(vec3.xCoord, vec3.yCoord, vec3.zCoord) < this.targetEntity.getDistanceSq(entityPosX, entityPosY, entityPosZ)) {
this.movePosX = vec3.xCoord;
this.movePosY = vec3.yCoord;
this.movePosZ = vec3.zCoord;
return true;
}
}
}
}
}
return false;
@@ -79,24 +67,21 @@ public class EntityAIZigZagTarget extends EntityAIBase
/**
* Returns whether an in-progress EntityAIBase should continue executing
*/
public boolean continueExecuting()
{
return !this.theEntity.getNavigator().noPath() && this.targetEntity.isEntityAlive() && this.targetEntity.getDistanceSqToEntity(this.theEntity) > (double)(this.tacticalRange * this.tacticalRange);
public boolean continueExecuting() {
return !this.theEntity.getNavigator().noPath() && this.targetEntity.isEntityAlive() && this.targetEntity.getDistanceSqToEntity(this.theEntity) > (double) (this.tacticalRange * this.tacticalRange);
}
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.theEntity.getNavigator().tryMoveToXYZ(this.movePosX, this.movePosY, this.movePosZ, this.speed);
}
/**
* Updates the task
*/
public void updateTask()
{
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
public void updateTask() {
this.theEntity.getLookHelper().setLookPositionWithEntity(targetEntity, 30.0F, 30.0F);
}
}
@@ -6,8 +6,7 @@ import net.minecraft.util.Vec3;
import java.util.Random;
public class RandomPositionGeneratorAlt
{
public class RandomPositionGeneratorAlt {
/**
* used to store a driection when the user passes a point to move towards or away from. WARNING: NEVER THREAD SAFE.
* MULTIPLE findTowards and findAway calls, will share this var
@@ -17,20 +16,18 @@ public class RandomPositionGeneratorAlt
/**
* finds a random target within par1(x,z) and par2 (y) blocks
*/
public static Vec3 findRandomTarget(EntityCreature par0EntityCreature, int par1, int par2)
{
public static Vec3 findRandomTarget(EntityCreature par0EntityCreature, int par1, int par2) {
/**
* searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction
* of par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number
*/
return findRandomTargetBlock(par0EntityCreature, par1, par2, (Vec3)null);
return findRandomTargetBlock(par0EntityCreature, par1, par2, (Vec3) null);
}
/**
* finds a random target within par1(x,z) and par2 (y) blocks in the direction of the point par3
*/
public static Vec3 findRandomTargetBlockTowards(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3)
{
public static Vec3 findRandomTargetBlockTowards(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) {
staticVector.xCoord = par3Vec3.xCoord - par0EntityCreature.posX;
staticVector.yCoord = par3Vec3.yCoord - par0EntityCreature.posY;
staticVector.zCoord = par3Vec3.zCoord - par0EntityCreature.posZ;
@@ -44,8 +41,7 @@ public class RandomPositionGeneratorAlt
/**
* finds a random target within par1(x,z) and par2 (y) blocks in the reverse direction of the point par3
*/
public static Vec3 findRandomTargetBlockAwayFrom(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3)
{
public static Vec3 findRandomTargetBlockAwayFrom(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) {
staticVector.xCoord = par0EntityCreature.posX - par3Vec3.xCoord;
staticVector.yCoord = par0EntityCreature.posY - par3Vec3.yCoord;
staticVector.zCoord = par0EntityCreature.posZ - par3Vec3.zCoord;
@@ -60,12 +56,11 @@ public class RandomPositionGeneratorAlt
* searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction of
* par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number
*/
private static Vec3 findRandomTargetBlock(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3)
{
if(par1 <= 0)
par1 = 1;
if(par2 <= 0)
par2 = 1;
private static Vec3 findRandomTargetBlock(EntityCreature par0EntityCreature, int par1, int par2, Vec3 par3Vec3) {
if (par1 <= 0)
par1 = 1;
if (par2 <= 0)
par2 = 1;
Random random = par0EntityCreature.getRNG();
boolean flag = false;
int k = 0;
@@ -74,41 +69,33 @@ public class RandomPositionGeneratorAlt
float f = -99999.0F;
boolean flag1;
if (par0EntityCreature.hasHome())
{
double d0 = (double)(par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F);
double d1 = (double)(par0EntityCreature.func_110174_bM() + (float)par1);
if (par0EntityCreature.hasHome()) {
double d0 = (double) (par0EntityCreature.getHomePosition().getDistanceSquared(MathHelper.floor_double(par0EntityCreature.posX), MathHelper.floor_double(par0EntityCreature.posY), MathHelper.floor_double(par0EntityCreature.posZ)) + 4.0F);
double d1 = (double) (par0EntityCreature.func_110174_bM() + (float) par1);
flag1 = d0 < d1 * d1;
}
else
{
} else {
flag1 = false;
}
for (int l1 = 0; l1 < 10; ++l1)
{
for (int l1 = 0; l1 < 10; ++l1) {
int j1 = random.nextInt(2 * par1) - par1;
int i2 = random.nextInt(2 * par2) - par2;
int k1 = random.nextInt(2 * par1) - par1;
if (par3Vec3 == null || (double)j1 * par3Vec3.xCoord + (double)k1 * par3Vec3.zCoord >= 0.0D)
{
if(random.nextBoolean()){
j1 += MathHelper.floor_double(par0EntityCreature.posX);
i2 += MathHelper.floor_double(par0EntityCreature.posY);
k1 += MathHelper.floor_double(par0EntityCreature.posZ);
}
else{
j1 += MathHelper.ceiling_double_int(par0EntityCreature.posX);
i2 += MathHelper.ceiling_double_int(par0EntityCreature.posY);
k1 += MathHelper.ceiling_double_int(par0EntityCreature.posZ);
}
if (!flag1 || par0EntityCreature.isWithinHomeDistance(j1, i2, k1))
{
if (par3Vec3 == null || (double) j1 * par3Vec3.xCoord + (double) k1 * par3Vec3.zCoord >= 0.0D) {
if (random.nextBoolean()) {
j1 += MathHelper.floor_double(par0EntityCreature.posX);
i2 += MathHelper.floor_double(par0EntityCreature.posY);
k1 += MathHelper.floor_double(par0EntityCreature.posZ);
} else {
j1 += MathHelper.ceiling_double_int(par0EntityCreature.posX);
i2 += MathHelper.ceiling_double_int(par0EntityCreature.posY);
k1 += MathHelper.ceiling_double_int(par0EntityCreature.posZ);
}
if (!flag1 || par0EntityCreature.isWithinHomeDistance(j1, i2, k1)) {
float f1 = par0EntityCreature.getBlockPathWeight(j1, i2, k1);
if (f1 > f)
{
if (f1 > f) {
f = f1;
k = j1;
l = i2;
@@ -119,13 +106,10 @@ public class RandomPositionGeneratorAlt
}
}
if (flag)
{
return Vec3.createVectorHelper((double)k, (double)l, (double)i1);
}
else
{
if (flag) {
return Vec3.createVectorHelper((double) k, (double) l, (double) i1);
} else {
return null;
}
}
}
}
@@ -19,15 +19,22 @@ import java.util.EnumSet;
import java.util.Map;
import java.util.Set;
public class FlyPathFinder extends PathFinder
{
/** Used to find obstacles */
public class FlyPathFinder extends PathFinder {
/**
* Used to find obstacles
*/
private IBlockAccess worldMap;
/** The path being generated */
/**
* The path being generated
*/
private PathHeap path = new PathHeap();
/** The points in the path */
/**
* The points in the path
*/
protected final IntHashMap<NPCPathPoint> pointMap = new IntHashMap<NPCPathPoint>();
/** Selection of path points to add to the path */
/**
* Selection of path points to add to the path
*/
private NPCPathPoint[] pathOptions = new NPCPathPoint[32];
private Entity theEntity;
private final Map<PathNodeType, Float> mapPathPriority = Maps.newEnumMap(PathNodeType.class);
@@ -41,9 +48,8 @@ public class FlyPathFinder extends PathFinder
private int drowningType;
private boolean immuneToFire;
public FlyPathFinder(IBlockAccess _worldMap, boolean doorsAllowed, boolean closedDoors, boolean canPathWater, boolean canDrown, Entity entityIn)
{
super(_worldMap,doorsAllowed,closedDoors,canPathWater,canDrown);
public FlyPathFinder(IBlockAccess _worldMap, boolean doorsAllowed, boolean closedDoors, boolean canPathWater, boolean canDrown, Entity entityIn) {
super(_worldMap, doorsAllowed, closedDoors, canPathWater, canDrown);
this.theEntity = entityIn;
this.worldMap = _worldMap;
@@ -56,75 +62,64 @@ public class FlyPathFinder extends PathFinder
/**
* Creates a path from one entity to another within a minimum distance
*/
public NPCPath createEntityPathTo(Entity entityFrom, Entity entityTo, float distance)
{
public NPCPath createEntityPathTo(Entity entityFrom, Entity entityTo, float distance) {
return this.createEntityPathTo(entityFrom, entityTo.posX, entityTo.boundingBox.minY, entityTo.posZ, distance);
}
/**
* Creates a path from an entity to a specified location within a minimum distance
*/
public NPCPath createEntityPathTo(Entity entityFrom, int xTo, int yTo, int zTo, float distance)
{
return this.createEntityPathTo(entityFrom, (double)((float)xTo + 0.5F), (double)((float)yTo + 0.5F), (double)((float)zTo + 0.5F), distance);
public NPCPath createEntityPathTo(Entity entityFrom, int xTo, int yTo, int zTo, float distance) {
return this.createEntityPathTo(entityFrom, (double) ((float) xTo + 0.5F), (double) ((float) yTo + 0.5F), (double) ((float) zTo + 0.5F), distance);
}
/**
* Internal implementation of creating a path from an entity to a point
*/
private NPCPath createEntityPathTo(Entity entityIn, double x, double y, double z, float distance)
{
private NPCPath createEntityPathTo(Entity entityIn, double x, double y, double z, float distance) {
this.path.clearPath();
this.pointMap.clearMap();
this.drowningType = ((EntityNPCInterface)theEntity).stats.drowningType;
this.immuneToFire = ((EntityNPCInterface)theEntity).stats.immuneToFire;
this.drowningType = ((EntityNPCInterface) theEntity).stats.drowningType;
this.immuneToFire = ((EntityNPCInterface) theEntity).stats.immuneToFire;
NPCPathPoint pathpoint = this.getStart();
NPCPathPoint pathpoint1 = this.getPathPointToCoords(entityIn, x, y, z);
NPCPathPoint pathPoint2 = new NPCPathPoint((int)Math.ceil(entityIn.width),(int)Math.ceil(entityIn.height),(int)Math.ceil(entityIn.width));
NPCPathPoint pathPoint2 = new NPCPathPoint((int) Math.ceil(entityIn.width), (int) Math.ceil(entityIn.height), (int) Math.ceil(entityIn.width));
NPCPath pathentity = addToPath(entityIn, pathpoint, pathpoint1, pathPoint2, distance);
return pathentity;
}
public NPCPathPoint getStart()
{
public NPCPathPoint getStart() {
int i;
if (((EntityNPCInterface)theEntity).ais.canSwim && this.theEntity.isInWater())
{
i = (int)this.theEntity.boundingBox.minY;
if (((EntityNPCInterface) theEntity).ais.canSwim && this.theEntity.isInWater()) {
i = (int) this.theEntity.boundingBox.minY;
BlockPos.MutableBlockPos muteBlock = new BlockPos.MutableBlockPos(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
for (Block block = this.worldMap.getBlock(muteBlock.getX(), muteBlock.getY(), muteBlock.getZ()); block == Blocks.flowing_water || block == Blocks.water; block = this.worldMap.getBlock(muteBlock.getX(), muteBlock.getY(), muteBlock.getZ()))
{
for (Block block = this.worldMap.getBlock(muteBlock.getX(), muteBlock.getY(), muteBlock.getZ()); block == Blocks.flowing_water || block == Blocks.water; block = this.worldMap.getBlock(muteBlock.getX(), muteBlock.getY(), muteBlock.getZ())) {
++i;
muteBlock.setPos(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
}
}
else
{
} else {
i = MathHelper.floor_double(this.theEntity.boundingBox.minY + 0.5D);
}
BlockPos blockpos1 = new BlockPos(this.theEntity);
PathNodeType pathnodetype1 = this.getPathNodeType((EntityLiving) this.theEntity, blockpos1.getX(), i, blockpos1.getZ());
if (this.getPathPriority(pathnodetype1) < 0.0F)
{
if (this.getPathPriority(pathnodetype1) < 0.0F) {
Set<BlockPos> set = Sets.<BlockPos>newHashSet();
set.add(new BlockPos(this.theEntity.boundingBox.minX, (double)i, this.theEntity.boundingBox.minZ));
set.add(new BlockPos(this.theEntity.boundingBox.minX, (double)i, this.theEntity.boundingBox.maxZ));
set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double)i, this.theEntity.boundingBox.minZ));
set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double)i, this.theEntity.boundingBox.maxZ));
set.add(new BlockPos(this.theEntity.boundingBox.minX, (double) i, this.theEntity.boundingBox.minZ));
set.add(new BlockPos(this.theEntity.boundingBox.minX, (double) i, this.theEntity.boundingBox.maxZ));
set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double) i, this.theEntity.boundingBox.minZ));
set.add(new BlockPos(this.theEntity.boundingBox.maxX, (double) i, this.theEntity.boundingBox.maxZ));
for (BlockPos blockpos : set)
{
PathNodeType pathnodetype = this.getPathNodeType((EntityLiving)this.theEntity, blockpos);
for (BlockPos blockpos : set) {
PathNodeType pathnodetype = this.getPathNodeType((EntityLiving) this.theEntity, blockpos);
if (this.getPathPriority(pathnodetype) >= 0.0F)
{
if (this.getPathPriority(pathnodetype) >= 0.0F) {
return openPoint(blockpos.getX(), blockpos.getY(), blockpos.getZ());
}
}
@@ -134,14 +129,12 @@ public class FlyPathFinder extends PathFinder
}
public NPCPathPoint getPathPointToCoords(Entity entityIn, double x, double y, double z)
{
public NPCPathPoint getPathPointToCoords(Entity entityIn, double x, double y, double z) {
return openPoint(MathHelper.floor_double(x), MathHelper.floor_double(y), MathHelper.floor_double(z));
}
private NPCPath addToPath(Entity p_75861_1_, NPCPathPoint p_75861_2_, NPCPathPoint p_75861_3_, NPCPathPoint p_75861_4_, float p_75861_5_)
{
private NPCPath addToPath(Entity p_75861_1_, NPCPathPoint p_75861_2_, NPCPathPoint p_75861_3_, NPCPathPoint p_75861_4_, float p_75861_5_) {
p_75861_2_.totalPathDistance = 0.0F;
p_75861_2_.distanceToNext = p_75861_2_.distanceToSquared(p_75861_3_);
p_75861_2_.distanceToTarget = p_75861_2_.distanceToNext;
@@ -150,8 +143,7 @@ public class FlyPathFinder extends PathFinder
NPCPathPoint pathpoint3 = p_75861_2_;
int x = 0;
while (!this.path.isPathEmpty())
{
while (!this.path.isPathEmpty()) {
x++;
if (x >= 200) {
@@ -160,36 +152,29 @@ public class FlyPathFinder extends PathFinder
NPCPathPoint pathpoint4 = this.path.dequeue();
if (pathpoint4.equals(p_75861_3_))
{
if (pathpoint4.equals(p_75861_3_)) {
return this.createEntityPath(p_75861_2_, p_75861_3_);
}
if (pathpoint4.distanceToSquared(p_75861_3_) < pathpoint3.distanceToSquared(p_75861_3_))
{
if (pathpoint4.distanceToSquared(p_75861_3_) < pathpoint3.distanceToSquared(p_75861_3_)) {
pathpoint3 = pathpoint4;
}
pathpoint4.isFirst = true;
int i = this.findPathOptions(p_75861_1_, pathpoint4, p_75861_4_, p_75861_3_, p_75861_5_);
for (int j = 0; j < i; ++j)
{
for (int j = 0; j < i; ++j) {
NPCPathPoint pathpoint5 = this.pathOptions[j];
float f1 = pathpoint4.totalPathDistance + pathpoint4.distanceToSquared(pathpoint5);
if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance)
{
if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance) {
pathpoint5.previous = pathpoint4;
pathpoint5.totalPathDistance = f1;
pathpoint5.distanceToNext = pathpoint5.distanceToSquared(p_75861_3_);
if (pathpoint5.isAssigned())
{
if (pathpoint5.isAssigned()) {
this.path.changeDistance(pathpoint5, pathpoint5.totalPathDistance + pathpoint5.distanceToNext);
}
else
{
} else {
pathpoint5.distanceToTarget = pathpoint5.totalPathDistance + pathpoint5.distanceToNext;
this.path.addPoint(pathpoint5);
}
@@ -197,12 +182,9 @@ public class FlyPathFinder extends PathFinder
}
}
if (pathpoint3 == p_75861_2_)
{
if (pathpoint3 == p_75861_2_) {
return null;
}
else
{
} else {
return this.createEntityPath(p_75861_2_, pathpoint3);
}
}
@@ -211,13 +193,11 @@ public class FlyPathFinder extends PathFinder
* populates pathOptions with available points and returns the number of options found (args: unused1, currentPoint,
* unused2, targetPoint, maxDistance)
*/
private int findPathOptions(Entity entity, NPCPathPoint currentPoint, NPCPathPoint p_75860_3_, NPCPathPoint targetPoint, float maxDistance)
{
private int findPathOptions(Entity entity, NPCPathPoint currentPoint, NPCPathPoint p_75860_3_, NPCPathPoint targetPoint, float maxDistance) {
int i = 0;
byte b0 = 0;
if (this.getVerticalOffset(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_) == 1)
{
if (this.getVerticalOffset(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_) == 1) {
b0 = 1;
}
@@ -228,33 +208,27 @@ public class FlyPathFinder extends PathFinder
NPCPathPoint pathpoint4 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_, b0);
NPCPathPoint pathpoint5 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord - 1, currentPoint.zCoord, p_75860_3_, b0);
if (pathpoint0 != null && !pathpoint0.isFirst && pathpoint0.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint0 != null && !pathpoint0.isFirst && pathpoint0.distanceTo(targetPoint) < maxDistance) {
this.pathOptions[i++] = pathpoint0;
}
if (pathpoint1 != null && !pathpoint1.isFirst && pathpoint1.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint1 != null && !pathpoint1.isFirst && pathpoint1.distanceTo(targetPoint) < maxDistance) {
this.pathOptions[i++] = pathpoint1;
}
if (pathpoint2 != null && !pathpoint2.isFirst && pathpoint2.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint2 != null && !pathpoint2.isFirst && pathpoint2.distanceTo(targetPoint) < maxDistance) {
this.pathOptions[i++] = pathpoint2;
}
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(targetPoint) < maxDistance) {
this.pathOptions[i++] = pathpoint3;
}
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(targetPoint) < maxDistance) {
this.pathOptions[i++] = pathpoint4;
}
if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(targetPoint) < maxDistance) {
this.pathOptions[i++] = pathpoint5;
}
@@ -265,122 +239,98 @@ public class FlyPathFinder extends PathFinder
boolean flag4 = pathpoint4 != null && pathpoint4.costMalus != 1 && pathpoint4.costMalus != 2;
boolean flag5 = pathpoint5 != null && pathpoint5.costMalus != 1 && pathpoint5.costMalus != 2;
if (flag && flag3)
{
if (flag && flag3) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord - 1, currentPoint.yCoord, currentPoint.zCoord - 1, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag && flag2)
{
if (flag && flag2) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord + 1, currentPoint.yCoord, currentPoint.zCoord - 1, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag1 && flag3)
{
if (flag1 && flag3) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord - 1, currentPoint.yCoord, currentPoint.zCoord + 1, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag1 && flag2)
{
if (flag1 && flag2) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord + 1, currentPoint.yCoord, currentPoint.zCoord + 1, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag && flag4)
{
if (flag && flag4) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord - 1, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag1 && flag4)
{
if (flag1 && flag4) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord + 1, currentPoint.zCoord + 1, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag2 && flag4)
{
if (flag2 && flag4) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord + 1, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag3 && flag4)
{
if (flag3 && flag4) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord - 1, currentPoint.yCoord + 1, currentPoint.zCoord, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag && flag5)
{
if (flag && flag5) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord - 1, currentPoint.zCoord - 1, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag1 && flag5)
{
if (flag1 && flag5) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord, currentPoint.yCoord - 1, currentPoint.zCoord + 1, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag2 && flag5)
{
if (flag2 && flag5) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord + 1, currentPoint.yCoord - 1, currentPoint.zCoord, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
if (flag3 && flag5)
{
if (flag3 && flag5) {
NPCPathPoint pathpoint6 = this.getSafePoint(entity, currentPoint.xCoord - 1, currentPoint.yCoord - 1, currentPoint.zCoord, p_75860_3_, b0);
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance)
{
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(targetPoint) < maxDistance) {
pathOptions[i++] = pathpoint6;
}
}
@@ -388,75 +338,62 @@ public class FlyPathFinder extends PathFinder
return i;
}
private NPCPathPoint getSafePoint(Entity entity, int x, int y, int z, NPCPathPoint p_75858_5_, int p_75858_6_)
{
private NPCPathPoint getSafePoint(Entity entity, int x, int y, int z, NPCPathPoint p_75858_5_, int p_75858_6_) {
NPCPathPoint pathpoint1 = null;
PathNodeType pathNodeType1 = this.getPathNodeType(entity,x,y,z);
PathNodeType pathNodeType1 = this.getPathNodeType(entity, x, y, z);
int i1 = this.nodeTypeToOffset(pathNodeType1);
if (i1 == 2)
{
if (i1 == 2) {
pathpoint1 = this.openPoint(x, y, z);
pathpoint1.costMalus = i1;
pathpoint1.nodeType = pathNodeType1;
return pathpoint1;
}
else
{
if (i1 == 1)
{
} else {
if (i1 == 1) {
pathpoint1 = this.openPoint(x, y, z);
pathpoint1.costMalus = i1;
pathpoint1.nodeType = pathNodeType1;
}
PathNodeType pathNodeType2 = this.getPathNodeType(entity, x,y + p_75858_6_, z);
PathNodeType pathNodeType2 = this.getPathNodeType(entity, x, y + p_75858_6_, z);
int vertOffset2 = this.nodeTypeToOffset(pathNodeType2);
if (pathpoint1 == null && p_75858_6_ > 0 && i1 != -3 && i1 != -4 && vertOffset2 == 1)
{
if (pathpoint1 == null && p_75858_6_ > 0 && i1 != -3 && i1 != -4 && vertOffset2 == 1) {
pathpoint1 = this.openPoint(x, y + p_75858_6_, z);
pathpoint1.costMalus = vertOffset2;
pathpoint1.nodeType = pathNodeType2;
y += p_75858_6_;
}
if (pathpoint1 != null)
{
if (pathpoint1 != null) {
int j1 = 0;
int k1 = 0;
while (y > 0)
{
PathNodeType pathNodeType3 = this.getPathNodeType(entity,x, y - 1, z);
while (y > 0) {
PathNodeType pathNodeType3 = this.getPathNodeType(entity, x, y - 1, z);
k1 = this.nodeTypeToOffset(pathNodeType3);
if (this.isPathingInWater && k1 == -1)
{
if (this.isPathingInWater && k1 == -1) {
return null;
}
if (k1 != 1)
{
if (k1 != 1) {
break;
}
if (j1++ >= entity.getMaxSafePointTries())
{
if (j1++ >= entity.getMaxSafePointTries()) {
return null;
}
--y;
if (y > 0)
{
if (y > 0) {
pathpoint1 = this.openPoint(x, y, z);
pathpoint1.costMalus = k1;
pathpoint1.nodeType = pathNodeType3;
}
}
if (k1 == -2)
{
if (k1 == -2) {
return null;
}
}
@@ -464,9 +401,8 @@ public class FlyPathFinder extends PathFinder
}
}
private PathNodeType getPathNodeType(Entity entity, int x, int y, int z)
{
return this.getPathNodeType((EntityLiving) entity, new BlockPos(x,y,z));
private PathNodeType getPathNodeType(Entity entity, int x, int y, int z) {
return this.getPathNodeType((EntityLiving) entity, new BlockPos(x, y, z));
}
public int nodeTypeToOffset(PathNodeType nodeType) {
@@ -500,13 +436,11 @@ public class FlyPathFinder extends PathFinder
return 1;
}
protected NPCPathPoint openPoint(int x, int y, int z)
{
protected NPCPathPoint openPoint(int x, int y, int z) {
int i = NPCPathPoint.makeHash(x, y, z);
NPCPathPoint pathpoint = this.pointMap.lookup(i);
if (pathpoint == null)
{
if (pathpoint == null) {
pathpoint = new NPCPathPoint(x, y, z);
this.pointMap.addKey(i, pathpoint);
}
@@ -517,13 +451,11 @@ public class FlyPathFinder extends PathFinder
/**
* Returns a new FlyPathEntity for a given start and end point
*/
private NPCPath createEntityPath(NPCPathPoint pathFrom, NPCPathPoint pathTo)
{
private NPCPath createEntityPath(NPCPathPoint pathFrom, NPCPathPoint pathTo) {
int i = 1;
NPCPathPoint pathpoint2;
for (pathpoint2 = pathTo; pathpoint2.previous != null; pathpoint2 = pathpoint2.previous)
{
for (pathpoint2 = pathTo; pathpoint2.previous != null; pathpoint2 = pathpoint2.previous) {
++i;
}
@@ -531,8 +463,7 @@ public class FlyPathFinder extends PathFinder
pathpoint2 = pathTo;
--i;
for (apathpoint[i] = pathTo; pathpoint2.previous != null; apathpoint[i] = pathpoint2)
{
for (apathpoint[i] = pathTo; pathpoint2.previous != null; apathpoint[i] = pathpoint2) {
pathpoint2 = pathpoint2.previous;
--i;
}
@@ -541,67 +472,49 @@ public class FlyPathFinder extends PathFinder
}
public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z, EntityLiving entitylivingIn, int xSize, int ySize, int zSize, boolean canBreakDoorsIn, boolean canEnterDoorsIn)
{
public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z, EntityLiving entitylivingIn, int xSize, int ySize, int zSize, boolean canBreakDoorsIn, boolean canEnterDoorsIn) {
EnumSet<PathNodeType> enumset = EnumSet.<PathNodeType>noneOf(PathNodeType.class);
PathNodeType pathnodetype = PathNodeType.BLOCKED;
BlockPos blockpos = new BlockPos(entitylivingIn);
pathnodetype = this.getPathNodeType(blockaccessIn, x, y, z, xSize, ySize, zSize, canBreakDoorsIn, canEnterDoorsIn, enumset, pathnodetype, blockpos);
if (enumset.contains(PathNodeType.FENCE))
{
if (enumset.contains(PathNodeType.FENCE)) {
return PathNodeType.FENCE;
}
else
{
} else {
PathNodeType pathnodetype1 = PathNodeType.BLOCKED;
for (PathNodeType pathnodetype2 : enumset)
{
if (getPathPriority(pathnodetype2) < 0.0F)
{
for (PathNodeType pathnodetype2 : enumset) {
if (getPathPriority(pathnodetype2) < 0.0F) {
return pathnodetype2;
}
if (getPathPriority(pathnodetype2) >= getPathPriority(pathnodetype1))
{
if (getPathPriority(pathnodetype2) >= getPathPriority(pathnodetype1)) {
pathnodetype1 = pathnodetype2;
}
}
if (pathnodetype == PathNodeType.OPEN && getPathPriority(pathnodetype1) == 0.0F)
{
if (pathnodetype == PathNodeType.OPEN && getPathPriority(pathnodetype1) == 0.0F) {
return PathNodeType.OPEN;
}
else
{
} else {
return pathnodetype1;
}
}
}
public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z)
{
public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z) {
PathNodeType pathnodetype = this.getPathNodeTypeRaw(blockaccessIn, x, y, z);
if (pathnodetype == PathNodeType.OPEN && y >= 1)
{
if (pathnodetype == PathNodeType.OPEN && y >= 1) {
PathNodeType pathnodetype1 = this.getPathNodeTypeRaw(blockaccessIn, x, y - 1, z);
if (pathnodetype1 != PathNodeType.DAMAGE_FIRE && pathnodetype1 != PathNodeType.LAVA)
{
if (pathnodetype1 == PathNodeType.DAMAGE_CACTUS)
{
if (pathnodetype1 != PathNodeType.DAMAGE_FIRE && pathnodetype1 != PathNodeType.LAVA) {
if (pathnodetype1 == PathNodeType.DAMAGE_CACTUS) {
pathnodetype = PathNodeType.DAMAGE_CACTUS;
}
else if (pathnodetype1 == PathNodeType.DAMAGE_OTHER) pathnodetype = PathNodeType.DAMAGE_OTHER;
else
{
} else if (pathnodetype1 == PathNodeType.DAMAGE_OTHER) pathnodetype = PathNodeType.DAMAGE_OTHER;
else {
pathnodetype = pathnodetype1 != PathNodeType.WALKABLE && pathnodetype1 != PathNodeType.OPEN && pathnodetype1 != PathNodeType.WATER ? PathNodeType.WALKABLE : PathNodeType.OPEN;
}
}
else
{
} else {
pathnodetype = PathNodeType.DAMAGE_FIRE;
}
}
@@ -610,36 +523,28 @@ public class FlyPathFinder extends PathFinder
return pathnodetype;
}
public PathNodeType getPathNodeType(IBlockAccess blockAccess, int x, int y, int z, int xSize, int ySize, int zSize, boolean canOpenDoorsIn, boolean canEnterDoorsIn, EnumSet<PathNodeType> p_193577_10_, PathNodeType p_193577_11_, BlockPos p_193577_12_)
{
for (int i = 0; i < xSize; ++i)
{
for (int j = 0; j < ySize; ++j)
{
for (int k = 0; k < zSize; ++k)
{
public PathNodeType getPathNodeType(IBlockAccess blockAccess, int x, int y, int z, int xSize, int ySize, int zSize, boolean canOpenDoorsIn, boolean canEnterDoorsIn, EnumSet<PathNodeType> p_193577_10_, PathNodeType p_193577_11_, BlockPos p_193577_12_) {
for (int i = 0; i < xSize; ++i) {
for (int j = 0; j < ySize; ++j) {
for (int k = 0; k < zSize; ++k) {
int l = i + x;
int i1 = j + y;
int j1 = k + z;
PathNodeType pathnodetype = this.getPathNodeType(blockAccess, l, i1, j1);
if (pathnodetype == PathNodeType.DOOR_WOOD_CLOSED && canOpenDoorsIn && canEnterDoorsIn)
{
if (pathnodetype == PathNodeType.DOOR_WOOD_CLOSED && canOpenDoorsIn && canEnterDoorsIn) {
pathnodetype = PathNodeType.WALKABLE;
}
if (pathnodetype == PathNodeType.DOOR_OPEN && !canEnterDoorsIn)
{
if (pathnodetype == PathNodeType.DOOR_OPEN && !canEnterDoorsIn) {
pathnodetype = PathNodeType.BLOCKED;
}
if (pathnodetype == PathNodeType.RAIL && !(blockAccess.getBlock(p_193577_12_.getX(), p_193577_12_.getY(), p_193577_12_.getZ()) instanceof BlockRailBase) && !(blockAccess.getBlock(p_193577_12_.down().getX(), p_193577_12_.down().getY(), p_193577_12_.down().getZ()) instanceof BlockRailBase))
{
if (pathnodetype == PathNodeType.RAIL && !(blockAccess.getBlock(p_193577_12_.getX(), p_193577_12_.getY(), p_193577_12_.getZ()) instanceof BlockRailBase) && !(blockAccess.getBlock(p_193577_12_.down().getX(), p_193577_12_.down().getY(), p_193577_12_.down().getZ()) instanceof BlockRailBase)) {
pathnodetype = PathNodeType.FENCE;
}
if (i == 0 && j == 0 && k == 0)
{
if (i == 0 && j == 0 && k == 0) {
p_193577_11_ = pathnodetype;
}
@@ -651,39 +556,29 @@ public class FlyPathFinder extends PathFinder
return p_193577_11_;
}
private PathNodeType getPathNodeType(EntityLiving p_192559_1_, BlockPos p_192559_2_)
{
private PathNodeType getPathNodeType(EntityLiving p_192559_1_, BlockPos p_192559_2_) {
return this.getPathNodeType(p_192559_1_, p_192559_2_.getX(), p_192559_2_.getY(), p_192559_2_.getZ());
}
private PathNodeType getPathNodeType(EntityLiving p_192558_1_, int p_192558_2_, int p_192558_3_, int p_192558_4_)
{
private PathNodeType getPathNodeType(EntityLiving p_192558_1_, int p_192558_2_, int p_192558_3_, int p_192558_4_) {
int entitySizeX = MathHelper.floor_double(this.theEntity.width + 1.0F);
int entitySizeY = MathHelper.floor_double(this.theEntity.height + 1.0F);
int entitySizeZ = MathHelper.floor_double(this.theEntity.width + 1.0F);
return this.getPathNodeType(this.worldMap, p_192558_2_, p_192558_3_, p_192558_4_, p_192558_1_, entitySizeX, entitySizeY, entitySizeZ, ((EntityCustomNpc)this.theEntity).ais.doorInteract == 0, ((EntityCustomNpc)this.theEntity).ais.doorInteract == 1);
return this.getPathNodeType(this.worldMap, p_192558_2_, p_192558_3_, p_192558_4_, p_192558_1_, entitySizeX, entitySizeY, entitySizeZ, ((EntityCustomNpc) this.theEntity).ais.doorInteract == 0, ((EntityCustomNpc) this.theEntity).ais.doorInteract == 1);
}
public PathNodeType checkNeighborBlocks(IBlockAccess worldmap, int x, int y, int z, PathNodeType type)
{
public PathNodeType checkNeighborBlocks(IBlockAccess worldmap, int x, int y, int z, PathNodeType type) {
BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();
if (type == PathNodeType.WALKABLE)
{
for (int i = -1; i <= 1; ++i)
{
for (int j = -1; j <= 1; ++j)
{
if (i != 0 || j != 0)
{
if (type == PathNodeType.WALKABLE) {
for (int i = -1; i <= 1; ++i) {
for (int j = -1; j <= 1; ++j) {
if (i != 0 || j != 0) {
blockpos$pooledmutableblockpos.setPos(i + x, y, j + z);
Block block = worldmap.getBlock(blockpos$pooledmutableblockpos.getX(), blockpos$pooledmutableblockpos.getY(), blockpos$pooledmutableblockpos.getZ());
if (block == Blocks.cactus)
{
if (block == Blocks.cactus) {
type = PathNodeType.DANGER_CACTUS;
}
else if (block == Blocks.fire && !immuneToFire)
{
} else if (block == Blocks.fire && !immuneToFire) {
type = PathNodeType.DANGER_FIRE;
}
}
@@ -695,70 +590,43 @@ public class FlyPathFinder extends PathFinder
return type;
}
protected PathNodeType getPathNodeTypeRaw(IBlockAccess worldmap, int p_189553_2_, int p_189553_3_, int p_189553_4_)
{
protected PathNodeType getPathNodeTypeRaw(IBlockAccess worldmap, int p_189553_2_, int p_189553_3_, int p_189553_4_) {
BlockPos blockpos = new BlockPos(p_189553_2_, p_189553_3_, p_189553_4_);
Block block = worldmap.getBlock(blockpos.getX(), blockpos.getY(), blockpos.getZ());
Material material = block.getMaterial();
if (material == Material.air)
{
if (material == Material.air) {
return PathNodeType.OPEN;
}
else if (block != Blocks.trapdoor && block != Blocks.waterlily)
{
if (block == Blocks.fire)
{
} else if (block != Blocks.trapdoor && block != Blocks.waterlily) {
if (block == Blocks.fire) {
return immuneToFire ? PathNodeType.OPEN : PathNodeType.DAMAGE_FIRE;
}
else if (block == Blocks.cactus)
{
} else if (block == Blocks.cactus) {
return PathNodeType.DAMAGE_CACTUS;
}
else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor)block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_))
{
} else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor) block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) {
return PathNodeType.DOOR_WOOD_CLOSED;
}
else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor)block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_))
{
} else if (block instanceof BlockDoor && material == Material.wood && !((BlockDoor) block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) {
return PathNodeType.DOOR_IRON_CLOSED;
}
else if (block instanceof BlockDoor && ((BlockDoor)block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_))
{
} else if (block instanceof BlockDoor && ((BlockDoor) block).getBlocksMovement(this.worldMap, p_189553_2_, p_189553_3_, p_189553_4_)) {
return PathNodeType.DOOR_OPEN;
}
else if (block instanceof BlockRailBase)
{
} else if (block instanceof BlockRailBase) {
return PathNodeType.RAIL;
}
else if (!(block instanceof BlockFence) && !(block instanceof BlockWall) && (!(block instanceof BlockFenceGate)))
{
if (material == Material.water)
{
return ((EntityNPCInterface)this.theEntity).ais.canSwim ? PathNodeType.OPEN : PathNodeType.WATER;
}
else if (material == Material.lava)
{
} else if (!(block instanceof BlockFence) && !(block instanceof BlockWall) && (!(block instanceof BlockFenceGate))) {
if (material == Material.water) {
return ((EntityNPCInterface) this.theEntity).ais.canSwim ? PathNodeType.OPEN : PathNodeType.WATER;
} else if (material == Material.lava) {
return immuneToFire ? PathNodeType.OPEN : PathNodeType.LAVA;
}
else
{
} else {
return block.getBlocksMovement(worldmap, blockpos.getX(), blockpos.getY(), blockpos.getZ()) ? PathNodeType.OPEN : PathNodeType.BLOCKED;
}
}
else
{
} else {
return PathNodeType.FENCE;
}
}
else
{
} else {
return PathNodeType.TRAPDOOR;
}
}
public float getPathPriority(PathNodeType nodeType)
{
public float getPathPriority(PathNodeType nodeType) {
Float f = this.mapPathPriority.get(nodeType);
return f == null ? nodeType.getPriority() : f.floatValue();
}
@@ -6,7 +6,7 @@ import net.minecraft.util.MathHelper;
import noppes.npcs.entity.EntityNPCFlying;
import noppes.npcs.entity.EntityNPCInterface;
public class FlyingMoveHelper extends EntityMoveHelper{
public class FlyingMoveHelper extends EntityMoveHelper {
private final EntityNPCInterface entity;
private double posX;
@@ -15,7 +15,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{
private double speed;
public boolean update;
public FlyingMoveHelper(EntityNPCInterface entity){
public FlyingMoveHelper(EntityNPCInterface entity) {
super(entity);
this.entity = entity;
this.posX = entity.posX;
@@ -28,15 +28,15 @@ public class FlyingMoveHelper extends EntityMoveHelper{
this.update = false;
double speed = this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
double verticalSpeed = this.speed * this.entity.ais.flySpeed/8.0D;
this.entity.setAIMoveSpeed((float)speed);
double verticalSpeed = this.speed * this.entity.ais.flySpeed / 8.0D;
this.entity.setAIMoveSpeed((float) speed);
double d0 = this.posX - this.entity.posX;
double d1 = this.posY - this.entity.posY;
double d2 = this.posZ - this.entity.posZ;
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
double d5 = MathHelper.sqrt_double(d4);
speed = Math.min(d5/5.0D,speed);
speed = Math.min(d5 / 5.0D, speed);
// its here louis!
// This is the hurt time that stuns the NPC!!!!!!
@@ -45,7 +45,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{
this.entity.motionX += (speed * (d0 / d5) - this.entity.motionX) * speed;
this.entity.motionZ += (speed * (d2 / d5) - this.entity.motionZ) * speed;
if (((EntityNPCFlying)this.entity).flyLimitAllow || !this.entity.ais.hasFlyLimit) {
if (((EntityNPCFlying) this.entity).flyLimitAllow || !this.entity.ais.hasFlyLimit) {
this.entity.motionY = verticalSpeed * (d1 / d5);
if (this.entity.motionY > 0) {
this.entity.motionY += 0.1D;
@@ -53,33 +53,27 @@ public class FlyingMoveHelper extends EntityMoveHelper{
}
this.entity.velocityChanged = true;
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),20.0F);
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, (float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)), 20.0F);
}
}
}
private float limitAngle(float angleIn, float lower, float upper)
{
private float limitAngle(float angleIn, float lower, float upper) {
float f = MathHelper.wrapAngleTo180_float(lower - angleIn);
if (f > upper)
{
if (f > upper) {
f = upper;
}
if (f < -upper)
{
if (f < -upper) {
f = -upper;
}
float f1 = angleIn + f;
if (f1 < 0.0F)
{
if (f1 < 0.0F) {
f1 += 360.0F;
}
else if (f1 > 360.0F)
{
} else if (f1 > 360.0F) {
f1 -= 360.0F;
}
@@ -89,8 +83,7 @@ public class FlyingMoveHelper extends EntityMoveHelper{
/**
* Sets the speed and location to move to
*/
public void setMoveTo(double p_75642_1_, double p_75642_3_, double p_75642_5_, double p_75642_7_)
{
public void setMoveTo(double p_75642_1_, double p_75642_3_, double p_75642_5_, double p_75642_7_) {
this.posX = p_75642_1_;
this.posY = p_75642_3_;
this.posZ = p_75642_5_;
@@ -98,13 +91,11 @@ public class FlyingMoveHelper extends EntityMoveHelper{
this.update = true;
}
public boolean isUpdating()
{
public boolean isUpdating() {
return this.update;
}
public double getSpeed()
{
public double getSpeed() {
return this.speed;
}
}
@@ -4,15 +4,18 @@ import net.minecraft.entity.Entity;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.Vec3;
public class NPCPath extends PathEntity{
public class NPCPath extends PathEntity {
public final NPCPathPoint[] points;
/** PathEntity Array Index the Entity is currently targeting */
/**
* PathEntity Array Index the Entity is currently targeting
*/
public int currentPathIndex;
/** The total length of the path */
/**
* The total length of the path
*/
public int pathLength;
public NPCPath(NPCPathPoint[] pointsIn)
{
public NPCPath(NPCPathPoint[] pointsIn) {
super(pointsIn);
this.points = pointsIn;
this.pathLength = pointsIn.length;
@@ -21,100 +24,81 @@ public class NPCPath extends PathEntity{
/**
* Directs this path to the next point in its array
*/
public void incrementPathIndex()
{
public void incrementPathIndex() {
++this.currentPathIndex;
}
/**
* Returns true if this path has reached the end
*/
public boolean isFinished()
{
public boolean isFinished() {
return this.currentPathIndex >= this.pathLength;
}
/**
* returns the last PathPoint of the Array
*/
public NPCPathPoint getFinalPathPoint()
{
public NPCPathPoint getFinalPathPoint() {
return this.pathLength > 0 ? this.points[this.pathLength - 1] : null;
}
/**
* return the PathPoint located at the specified PathIndex, usually the current one
*/
public NPCPathPoint getPathPointFromIndex(int p_75877_1_)
{
public NPCPathPoint getPathPointFromIndex(int p_75877_1_) {
return this.points[p_75877_1_];
}
public int getCurrentPathLength()
{
public int getCurrentPathLength() {
return this.pathLength;
}
public void setCurrentPathLength(int p_75871_1_)
{
public void setCurrentPathLength(int p_75871_1_) {
this.pathLength = p_75871_1_;
}
public int getCurrentPathIndex()
{
public int getCurrentPathIndex() {
return this.currentPathIndex;
}
public void setCurrentPathIndex(int p_75872_1_)
{
public void setCurrentPathIndex(int p_75872_1_) {
this.currentPathIndex = p_75872_1_;
}
/**
* Gets the vector of the PathPoint associated with the given index.
*/
public Vec3 getVectorFromIndex(Entity entity, int index)
{
double d0 = (double)this.points[index].xCoord + (double)((int)(entity.width + 1.0F)) * 0.5D;
double d1 = (double)this.points[index].yCoord + 0.05D;
double d2 = (double)this.points[index].zCoord + (double)((int)(entity.width + 1.0F)) * 0.5D;
public Vec3 getVectorFromIndex(Entity entity, int index) {
double d0 = (double) this.points[index].xCoord + (double) ((int) (entity.width + 1.0F)) * 0.5D;
double d1 = (double) this.points[index].yCoord + 0.05D;
double d2 = (double) this.points[index].zCoord + (double) ((int) (entity.width + 1.0F)) * 0.5D;
return Vec3.createVectorHelper(d0, d1, d2);
}
/**
* returns the current PathEntity target node as Vec3D
*/
public Vec3 getPosition(Entity p_75878_1_)
{
public Vec3 getPosition(Entity p_75878_1_) {
return this.getVectorFromIndex(p_75878_1_, this.currentPathIndex);
}
public Vec3 getCurrentPos()
{
public Vec3 getCurrentPos() {
NPCPathPoint pathpoint = this.points[this.currentPathIndex];
return Vec3.createVectorHelper((double)pathpoint.xCoord, (double)pathpoint.yCoord, (double)pathpoint.zCoord);
return Vec3.createVectorHelper((double) pathpoint.xCoord, (double) pathpoint.yCoord, (double) pathpoint.zCoord);
}
/**
* Returns true if the EntityPath are the same. Non instance related equals.
*/
public boolean isSamePath(PathEntity pathEntity)
{
public boolean isSamePath(PathEntity pathEntity) {
NPCPath NPCPath = (NPCPath) pathEntity;
if (NPCPath == null)
{
if (NPCPath == null) {
return false;
}
else if (NPCPath.points.length != this.points.length)
{
} else if (NPCPath.points.length != this.points.length) {
return false;
}
else
{
for (int i = 0; i < this.points.length; ++i)
{
if (this.points[i].xCoord != NPCPath.points[i].xCoord || this.points[i].yCoord != NPCPath.points[i].yCoord || this.points[i].zCoord != NPCPath.points[i].zCoord)
{
} else {
for (int i = 0; i < this.points.length; ++i) {
if (this.points[i].xCoord != NPCPath.points[i].xCoord || this.points[i].yCoord != NPCPath.points[i].yCoord || this.points[i].zCoord != NPCPath.points[i].zCoord) {
return false;
}
}
@@ -126,9 +110,8 @@ public class NPCPath extends PathEntity{
/**
* Returns true if the final PathPoint in the PathEntity is equal to Vec3D coords.
*/
public boolean isDestinationSame(Vec3 vec3)
{
public boolean isDestinationSame(Vec3 vec3) {
NPCPathPoint pathpoint = this.getFinalPathPoint();
return pathpoint == null ? false : pathpoint.xCoord == (int)vec3.xCoord && pathpoint.zCoord == (int)vec3.zCoord;
return pathpoint == null ? false : pathpoint.xCoord == (int) vec3.xCoord && pathpoint.zCoord == (int) vec3.zCoord;
}
}
@@ -3,105 +3,112 @@ package noppes.npcs.ai.pathfinder;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
public class NPCPathPoint extends PathPoint
{
/** The x coordinate of this point */
public class NPCPathPoint extends PathPoint {
/**
* The x coordinate of this point
*/
public final int xCoord;
/** The y coordinate of this point */
/**
* The y coordinate of this point
*/
public final int yCoord;
/** The z coordinate of this point */
/**
* The z coordinate of this point
*/
public final int zCoord;
/** A hash of the coordinates used to identify this point */
/**
* A hash of the coordinates used to identify this point
*/
public final int hash;
/** The index of this point in its assigned path */
/**
* The index of this point in its assigned path
*/
public int index = -1;
/** The distance along the path to this point */
/**
* The distance along the path to this point
*/
public float totalPathDistance;
/** The linear distance to the next point */
/**
* The linear distance to the next point
*/
public float distanceToNext;
/** The distance to the target */
/**
* The distance to the target
*/
public float distanceToTarget;
/** The point preceding this in its assigned path */
/**
* The point preceding this in its assigned path
*/
public NPCPathPoint previous;
/** Indicates this is the origin */
/**
* Indicates this is the origin
*/
public boolean isFirst;
public float costMalus;
public float cost;
public float distanceFromOrigin;
public PathNodeType nodeType = PathNodeType.BLOCKED;
public NPCPathPoint(int xIn, int yIn, int zIn)
{
super(xIn,yIn,zIn);
public NPCPathPoint(int xIn, int yIn, int zIn) {
super(xIn, yIn, zIn);
this.xCoord = xIn;
this.yCoord = yIn;
this.zCoord = zIn;
this.hash = makeHash(xIn, yIn, zIn);
}
public static int makeHash(int xIn, int yIn, int zIn)
{
public static int makeHash(int xIn, int yIn, int zIn) {
return yIn & 255 | (xIn & 32767) << 8 | (zIn & 32767) << 24 | (xIn < 0 ? Integer.MIN_VALUE : 0) | (zIn < 0 ? 32768 : 0);
}
/**
* Returns the linear distance to another path point
*/
public float distanceTo(NPCPathPoint point)
{
float f = (float)(point.xCoord - this.xCoord);
float f1 = (float)(point.yCoord - this.yCoord);
float f2 = (float)(point.zCoord - this.zCoord);
public float distanceTo(NPCPathPoint point) {
float f = (float) (point.xCoord - this.xCoord);
float f1 = (float) (point.yCoord - this.yCoord);
float f2 = (float) (point.zCoord - this.zCoord);
return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
}
/**
* Returns the squared distance to another path point
*/
public float distanceToSquared(NPCPathPoint point)
{
float f = (float)(point.xCoord - this.xCoord);
float f1 = (float)(point.yCoord - this.yCoord);
float f2 = (float)(point.zCoord - this.zCoord);
public float distanceToSquared(NPCPathPoint point) {
float f = (float) (point.xCoord - this.xCoord);
float f1 = (float) (point.yCoord - this.yCoord);
float f2 = (float) (point.zCoord - this.zCoord);
return f * f + f1 * f1 + f2 * f2;
}
public float distanceManhattan(NPCPathPoint point)
{
float f = (float)Math.abs(point.xCoord - this.xCoord);
float f1 = (float)Math.abs(point.yCoord - this.yCoord);
float f2 = (float)Math.abs(point.zCoord - this.zCoord);
public float distanceManhattan(NPCPathPoint point) {
float f = (float) Math.abs(point.xCoord - this.xCoord);
float f1 = (float) Math.abs(point.yCoord - this.yCoord);
float f2 = (float) Math.abs(point.zCoord - this.zCoord);
return f + f1 + f2;
}
public boolean equals(Object point)
{
if (!(point instanceof NPCPathPoint))
{
public boolean equals(Object point) {
if (!(point instanceof NPCPathPoint)) {
return false;
}
else
{
NPCPathPoint pathpoint = (NPCPathPoint)point;
} else {
NPCPathPoint pathpoint = (NPCPathPoint) point;
return this.hash == pathpoint.hash && this.xCoord == pathpoint.xCoord && this.yCoord == pathpoint.yCoord && this.zCoord == pathpoint.zCoord;
}
}
public int hashCode()
{
public int hashCode() {
return this.hash;
}
/**
* Returns true if this point has already been assigned to a path
*/
public boolean isAssigned()
{
public boolean isAssigned() {
return this.index >= 0;
}
public String toString()
{
public String toString() {
return this.xCoord + ", " + this.yCoord + ", " + this.zCoord;
}
}
}
@@ -2,22 +2,19 @@ package noppes.npcs.ai.pathfinder;
public class PathHeap {
private NPCPathPoint[] pathPoints = new NPCPathPoint[128];
/** The number of points in this path */
/**
* The number of points in this path
*/
private int count;
/**
* Adds a point to the path
*/
public NPCPathPoint addPoint(NPCPathPoint pathPoint)
{
if (pathPoint.index >= 0)
{
public NPCPathPoint addPoint(NPCPathPoint pathPoint) {
if (pathPoint.index >= 0) {
throw new IllegalStateException("OW KNOWS!");
}
else
{
if (this.count == this.pathPoints.length)
{
} else {
if (this.count == this.pathPoints.length) {
NPCPathPoint[] apathpoint = new NPCPathPoint[this.count << 1];
System.arraycopy(this.pathPoints, 0, apathpoint, 0, this.count);
this.pathPoints = apathpoint;
@@ -33,22 +30,19 @@ public class PathHeap {
/**
* Clears the path
*/
public void clearPath()
{
public void clearPath() {
this.count = 0;
}
/**
* Returns and removes the first point in the path
*/
public NPCPathPoint dequeue()
{
public NPCPathPoint dequeue() {
NPCPathPoint pathpoint = this.pathPoints[0];
this.pathPoints[0] = this.pathPoints[--this.count];
this.pathPoints[this.count] = null;
if (this.count > 0)
{
if (this.count > 0) {
this.sortForward(0);
}
@@ -59,17 +53,13 @@ public class PathHeap {
/**
* Changes the provided point's distance to target
*/
public void changeDistance(NPCPathPoint point, float distance)
{
public void changeDistance(NPCPathPoint point, float distance) {
float f1 = point.distanceToTarget;
point.distanceToTarget = distance;
if (distance < f1)
{
if (distance < f1) {
this.sortBack(point.index);
}
else
{
} else {
this.sortForward(point.index);
}
}
@@ -77,18 +67,15 @@ public class PathHeap {
/**
* Sorts a point to the left
*/
private void sortBack(int index)
{
private void sortBack(int index) {
NPCPathPoint pathpoint = this.pathPoints[index];
int j;
for (float f = pathpoint.distanceToTarget; index > 0; index = j)
{
for (float f = pathpoint.distanceToTarget; index > 0; index = j) {
j = index - 1 >> 1;
NPCPathPoint pathpoint1 = this.pathPoints[j];
if (f >= pathpoint1.distanceToTarget)
{
if (f >= pathpoint1.distanceToTarget) {
break;
}
@@ -103,18 +90,15 @@ public class PathHeap {
/**
* Sorts a point to the right
*/
private void sortForward(int index)
{
private void sortForward(int index) {
NPCPathPoint pathpoint = this.pathPoints[index];
float f = pathpoint.distanceToTarget;
while (true)
{
while (true) {
int j = 1 + (index << 1);
int k = j + 1;
if (j >= this.count)
{
if (j >= this.count) {
break;
}
@@ -123,32 +107,24 @@ public class PathHeap {
NPCPathPoint pathpoint2;
float f2;
if (k >= this.count)
{
if (k >= this.count) {
pathpoint2 = null;
f2 = Float.POSITIVE_INFINITY;
}
else
{
} else {
pathpoint2 = this.pathPoints[k];
f2 = pathpoint2.distanceToTarget;
}
if (f1 < f2)
{
if (f1 >= f)
{
if (f1 < f2) {
if (f1 >= f) {
break;
}
this.pathPoints[index] = pathpoint1;
pathpoint1.index = index;
index = j;
}
else
{
if (f2 >= f)
{
} else {
if (f2 >= f) {
break;
}
@@ -165,5 +141,7 @@ public class PathHeap {
/**
* Returns true if this path contains no points
*/
public boolean isPathEmpty() { return this.count == 0; }
public boolean isPathEmpty() {
return this.count == 0;
}
}
@@ -24,28 +24,44 @@ public class PathNavigateFlying extends PathNavigate {
private EntityNPCInterface theEntity;
private World worldObj;
/** The PathEntity being followed. */
/**
* The PathEntity being followed.
*/
protected NPCPath currentPath;
private double speed;
/** The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space */
/**
* The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space
*/
private IAttributeInstance pathSearchRange;
protected float maxDistanceToWaypoint = 0.5F;
private boolean noSunPathfind;
/** Time, in number of ticks, following the current path */
/**
* Time, in number of ticks, following the current path
*/
private int totalTicks;
/** The time when the last position check was done (to detect successful movement) */
/**
* The time when the last position check was done (to detect successful movement)
*/
private int ticksAtLastPos;
/** Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck') */
/**
* Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck')
*/
private Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
private Vec3 timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
private long timeoutTimer;
private long lastTimeoutCheck;
private double timeoutLimit;
/** Specifically, if a wooden door block is even considered to be passable by the pathfinder */
/**
* Specifically, if a wooden door block is even considered to be passable by the pathfinder
*/
private boolean canPassOpenWoodenDoors = true;
/** If door blocks are considered passable even when closed */
/**
* If door blocks are considered passable even when closed
*/
private boolean canPassClosedWoodenDoors;
/** If water blocks are avoided (at least by the pathfinder) */
/**
* If water blocks are avoided (at least by the pathfinder)
*/
private boolean avoidsWater;
/**
* If the entity can swim. Swimming AI enables this and the pathfinder will also cause the entity to swim straight
@@ -61,139 +77,112 @@ public class PathNavigateFlying extends PathNavigate {
public PathNavigateFlying(EntityLiving entityIN, World worldIn) {
super(entityIN, worldIn);
this.theEntity = (EntityNPCInterface)entityIN;
this.theEntity = (EntityNPCInterface) entityIN;
this.worldObj = worldIn;
this.pathSearchRange = entityIN.getEntityAttribute(SharedMonsterAttributes.followRange);
}
public void updatePath()
{
if (this.worldObj.getTotalWorldTime() - this.lastTimeUpdated > 20L)
{
if (this.targetPos != null)
{
public void updatePath() {
if (this.worldObj.getTotalWorldTime() - this.lastTimeUpdated > 20L) {
if (this.targetPos != null) {
this.currentPath = null;
this.currentPath = this.getPathToXYZ(this.targetPos.getX(), this.targetPos.getY(), this.targetPos.getZ());
this.lastTimeUpdated = this.worldObj.getTotalWorldTime();
this.tryUpdatePath = false;
}
}
else
{
} else {
this.tryUpdatePath = true;
}
}
public void setAvoidsWater(boolean p_75491_1_)
{
public void setAvoidsWater(boolean p_75491_1_) {
this.avoidsWater = p_75491_1_;
}
public boolean getAvoidsWater()
{
public boolean getAvoidsWater() {
return this.avoidsWater;
}
public void setBreakDoors(boolean p_75498_1_)
{
public void setBreakDoors(boolean p_75498_1_) {
this.canPassClosedWoodenDoors = p_75498_1_;
}
/**
* Sets if the entity can enter open doors
*/
public void setEnterDoors(boolean p_75490_1_)
{
public void setEnterDoors(boolean p_75490_1_) {
this.canPassOpenWoodenDoors = p_75490_1_;
}
/**
* Returns true if the entity can break doors, false otherwise
*/
public boolean getCanBreakDoors()
{
public boolean getCanBreakDoors() {
return this.canPassClosedWoodenDoors;
}
/**
* Sets if the path should avoid sunlight
*/
public void setAvoidSun(boolean p_75504_1_)
{
public void setAvoidSun(boolean p_75504_1_) {
this.noSunPathfind = p_75504_1_;
}
/**
* Sets the speed
*/
public void setSpeed(double p_75489_1_)
{
public void setSpeed(double p_75489_1_) {
this.speed = p_75489_1_;
}
/**
* Sets if the entity can swim
*/
public void setCanSwim(boolean p_75495_1_)
{
public void setCanSwim(boolean p_75495_1_) {
this.canSwim = p_75495_1_;
}
/**
* Gets the maximum distance that the path finding will search in.
*/
public float getPathSearchRange()
{
return (float)this.pathSearchRange.getAttributeValue();
public float getPathSearchRange() {
return (float) this.pathSearchRange.getAttributeValue();
}
/**
* Returns the path to the given coordinates
*/
public NPCPath getPathToXYZ(double x, double y, double z)
{
public NPCPath getPathToXYZ(double x, double y, double z) {
BlockPos pos = new BlockPos(x, y, z);
if (!this.canNavigate())
{
if (!this.canNavigate()) {
return null;
}
else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.targetPos))
{
} else if (this.currentPath != null && !this.currentPath.isFinished() && pos.equals(this.targetPos)) {
return this.currentPath;
}
else {
} else {
this.targetPos = pos;
return this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(x), (int)y, MathHelper.floor_double(z), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
return this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(x), (int) y, MathHelper.floor_double(z), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
}
}
/**
* Try to find and set a path to XYZ. Returns true if successful.
*/
public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_)
{
NPCPath pathentity = this.getPathToXYZ((double)MathHelper.floor_double(p_75492_1_), (double)((int)p_75492_3_), (double)MathHelper.floor_double(p_75492_5_));
public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_) {
NPCPath pathentity = this.getPathToXYZ((double) MathHelper.floor_double(p_75492_1_), (double) ((int) p_75492_3_), (double) MathHelper.floor_double(p_75492_5_));
return this.setPath(pathentity, p_75492_7_);
}
/**
* Returns the path to the given EntityLiving
*/
public NPCPath getPathToEntityLiving(Entity entity)
{
if (!this.canNavigate())
{
public NPCPath getPathToEntityLiving(Entity entity) {
if (!this.canNavigate()) {
return null;
}
else
{
} else {
BlockPos blockpos = new BlockPos(entity);
if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos))
{
if (this.currentPath != null && !this.currentPath.isFinished() && blockpos.equals(this.targetPos)) {
return this.currentPath;
}
else
{
} else {
this.targetPos = blockpos;
return this.getPathEntityToEntity(this.theEntity, entity, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
}
@@ -203,8 +192,7 @@ public class PathNavigateFlying extends PathNavigate {
/**
* Try to find and set a path to EntityLiving. Returns true if successful.
*/
public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_)
{
public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_) {
NPCPath pathentity = this.getPathToEntityLiving(p_75497_1_);
return pathentity != null && this.setPath(pathentity, p_75497_2_);
}
@@ -213,32 +201,23 @@ public class PathNavigateFlying extends PathNavigate {
* sets the active path data if path is 100% unique compared to old path, checks to adjust path for sun avoiding
* ents and stores end coords
*/
public boolean setPath(@Nullable PathEntity pathEntity, double speed)
{
public boolean setPath(@Nullable PathEntity pathEntity, double speed) {
NPCPath NPCPath = (NPCPath) pathEntity;
if (NPCPath == null)
{
if (NPCPath == null) {
this.currentPath = null;
return false;
}
else
{
if (!NPCPath.isSamePath(this.currentPath))
{
} else {
if (!NPCPath.isSamePath(this.currentPath)) {
this.currentPath = NPCPath;
}
if (this.noSunPathfind)
{
if (this.noSunPathfind) {
this.removeSunnyPath();
}
if (this.currentPath.getCurrentPathLength() == 0)
{
if (this.currentPath.getCurrentPathLength() == 0) {
return false;
}
else
{
} else {
this.speed = speed;
Vec3 vec3 = this.getEntityPosition();
this.ticksAtLastPos = this.totalTicks;
@@ -251,97 +230,78 @@ public class PathNavigateFlying extends PathNavigate {
/**
* gets the actively used PathEntity
*/
public PathEntity getPath()
{
public PathEntity getPath() {
return this.currentPath;
}
private boolean isInLiquid()
{
private boolean isInLiquid() {
return this.theEntity.isInWater() || this.theEntity.handleLavaMovement();
}
private boolean canNavigate()
{
private boolean canNavigate() {
return !this.isInLiquid() || (this.canSwim && this.isInLiquid());
}
public void onUpdateNavigation()
{
public void onUpdateNavigation() {
++this.totalTicks;
if (this.tryUpdatePath)
{
if (this.tryUpdatePath) {
this.updatePath();
}
if (!this.noPath())
{
if (this.canNavigate())
{
if (((EntityNPCInterface)this.theEntity).display.modelSize >= 5)
if (!this.noPath()) {
if (this.canNavigate()) {
if (((EntityNPCInterface) this.theEntity).display.modelSize >= 5)
this.pathFollowBig();
else
this.pathFollowSmall();
}
else if (this.currentPath != null && this.currentPath.getCurrentPathIndex() < this.currentPath.getCurrentPathLength())
{
if (!this.noPath())
{
} else if (this.currentPath != null && this.currentPath.getCurrentPathIndex() < this.currentPath.getCurrentPathLength()) {
if (!this.noPath()) {
Vec3 vec3d = this.currentPath.getVectorFromIndex(this.theEntity, this.currentPath.getCurrentPathIndex());
Vec3 vec3 = this.currentPath.getPosition(this.theEntity);
if (MathHelper.floor_double(this.theEntity.posX) == MathHelper.floor_double(vec3d.xCoord) && MathHelper.floor_double(this.theEntity.posY) == MathHelper.floor_double(vec3d.yCoord) && MathHelper.floor_double(this.theEntity.posZ) == MathHelper.floor_double(vec3d.zCoord))
if (vec3 != null)
{
if (vec3 != null) {
this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1);
this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed);
}
}
}
if (!this.noPath())
{
if (!this.noPath()) {
Vec3 vec3 = this.currentPath.getPosition(this.theEntity);
if (vec3 != null)
{
if (vec3 != null) {
this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed);
}
}
}
}
private void pathFollowBig()
{
private void pathFollowBig() {
Vec3 vec3 = this.getEntityPosition();
int i = this.currentPath.getCurrentPathLength();
float f = this.theEntity.width * this.theEntity.width;
int k;
for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k)
{
if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double)f)
{
for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k) {
if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double) f) {
this.currentPath.setCurrentPathIndex(k + 1);
}
}
k = MathHelper.floor_double(this.theEntity.width + 1.0F);
int l = MathHelper.floor_double(this.theEntity.height + 1.0F);
this.trimPath(vec3,i,k,l);
this.trimPath(vec3, i, k, l);
this.checkForStuck(vec3);
}
private void pathFollowSmall()
{
private void pathFollowSmall() {
Vec3 vec3 = this.getEntityPosition();
int i = this.currentPath.getCurrentPathLength();
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
{
if ((double)this.currentPath.getPathPointFromIndex(j).yCoord != Math.floor(vec3.yCoord))
{
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j) {
if ((double) this.currentPath.getPathPointFromIndex(j).yCoord != Math.floor(vec3.yCoord)) {
i = j;
break;
}
@@ -350,27 +310,24 @@ public class PathNavigateFlying extends PathNavigate {
this.maxDistanceToWaypoint = this.theEntity.width > 0.75F ? this.theEntity.width / 2.0F : 0.75F - this.theEntity.width / 2.0F;
Vec3 vec3d1 = this.currentPath.getCurrentPos();
if (MathHelper.abs((float)(this.theEntity.posX - (vec3d1.xCoord + 0.5D))) < this.maxDistanceToWaypoint && MathHelper.abs((float)(this.theEntity.posZ - (vec3d1.zCoord + 0.5D))) < this.maxDistanceToWaypoint && Math.abs(this.theEntity.posY - vec3d1.yCoord) < 1.0D)
{
if (MathHelper.abs((float) (this.theEntity.posX - (vec3d1.xCoord + 0.5D))) < this.maxDistanceToWaypoint && MathHelper.abs((float) (this.theEntity.posZ - (vec3d1.zCoord + 0.5D))) < this.maxDistanceToWaypoint && Math.abs(this.theEntity.posY - vec3d1.yCoord) < 1.0D) {
this.currentPath.setCurrentPathIndex(this.currentPath.getCurrentPathIndex() + 1);
}
int k = MathHelper.ceiling_double_int(this.theEntity.width);
int l = MathHelper.ceiling_double_int(this.theEntity.height + 1.0F);
this.trimPath(vec3,i,k,l);
this.trimPath(vec3, i, k, l);
this.checkForStuck(vec3);
}
public void trimPath(Vec3 position, int pathLength, int width, int height) {
for (int j1 = pathLength - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1)
{
for (int j1 = pathLength - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1) {
Vec3 pathPoint = this.currentPath.getVectorFromIndex(this.theEntity, j1);
if (position.distanceTo(pathPoint) > 6)
continue;
if (this.isDirectPathBetweenPoints(position, pathPoint, width, height))
{
if (this.isDirectPathBetweenPoints(position, pathPoint, width, height)) {
this.currentPath.setCurrentPathIndex(j1);
break;
}
@@ -381,8 +338,7 @@ public class PathNavigateFlying extends PathNavigate {
/**
* If null path or reached the end
*/
public boolean noPath()
{
public boolean noPath() {
return this.currentPath == null || this.currentPath.isFinished();
}
@@ -390,37 +346,30 @@ public class PathNavigateFlying extends PathNavigate {
* sets active PathEntity to null
*/
@Override
public void clearPathEntity()
{
public void clearPathEntity() {
this.currentPath = null;
}
private Vec3 getEntityPosition()
{
private Vec3 getEntityPosition() {
return Vec3.createVectorHelper(this.theEntity.posX, this.getPathableYPos(), this.theEntity.posZ);
}
/**
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
*/
private double getPathableYPos()
{
private double getPathableYPos() {
return this.theEntity.boundingBox.minY + 0.05D;
}
/**
* Trims path data from the end to the first sun covered block
*/
private void removeSunnyPath()
{
if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ)))
{
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
{
private void removeSunnyPath() {
if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int) (this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ))) {
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i) {
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))
{
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord)) {
this.currentPath.setCurrentPathLength(i - 1);
return;
}
@@ -432,22 +381,18 @@ public class PathNavigateFlying extends PathNavigate {
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
* pos1, pos2, entityXSize, entityYSize, entityZSize
*/
private boolean isDirectPathBetweenPoints(Vec3 startPos, Vec3 endPos, int width, int height)
{
Vec3 pos17 = Vec3.createVectorHelper(startPos.xCoord,startPos.yCoord, startPos.zCoord);
Vec3 pos18 = Vec3.createVectorHelper(endPos.xCoord,endPos.yCoord, endPos.zCoord);
private boolean isDirectPathBetweenPoints(Vec3 startPos, Vec3 endPos, int width, int height) {
Vec3 pos17 = Vec3.createVectorHelper(startPos.xCoord, startPos.yCoord, startPos.zCoord);
Vec3 pos18 = Vec3.createVectorHelper(endPos.xCoord, endPos.yCoord, endPos.zCoord);
if (this.rayTraceBlocks(pos17, pos18, true, false, false, width, height))
return false;
return true;
}
public boolean rayTraceBlocks(Vec3 p_147447_1_, Vec3 p_147447_2_, boolean p_147447_3_, boolean p_147447_4_, boolean p_147447_5_, int width, int height)
{
if (!Double.isNaN(p_147447_1_.xCoord) && !Double.isNaN(p_147447_1_.yCoord) && !Double.isNaN(p_147447_1_.zCoord))
{
if (!Double.isNaN(p_147447_2_.xCoord) && !Double.isNaN(p_147447_2_.yCoord) && !Double.isNaN(p_147447_2_.zCoord))
{
public boolean rayTraceBlocks(Vec3 p_147447_1_, Vec3 p_147447_2_, boolean p_147447_3_, boolean p_147447_4_, boolean p_147447_5_, int width, int height) {
if (!Double.isNaN(p_147447_1_.xCoord) && !Double.isNaN(p_147447_1_.yCoord) && !Double.isNaN(p_147447_1_.zCoord)) {
if (!Double.isNaN(p_147447_2_.xCoord) && !Double.isNaN(p_147447_2_.yCoord) && !Double.isNaN(p_147447_2_.zCoord)) {
int i = MathHelper.floor_double(p_147447_2_.xCoord);
int j = MathHelper.floor_double(p_147447_2_.yCoord);
int k = MathHelper.floor_double(p_147447_2_.zCoord);
@@ -457,12 +402,10 @@ public class PathNavigateFlying extends PathNavigate {
Block block = this.worldObj.getBlock(l, i1, j1);
int k1 = this.worldObj.getBlockMetadata(l, i1, j1);
if ((!p_147447_4_ || block.getCollisionBoundingBoxFromPool(this.worldObj, l, i1, j1) != null) && block.canCollideCheck(k1, p_147447_3_))
{
if ((!p_147447_4_ || block.getCollisionBoundingBoxFromPool(this.worldObj, l, i1, j1) != null) && block.canCollideCheck(k1, p_147447_3_)) {
MovingObjectPosition movingobjectposition = block.collisionRayTrace(this.worldObj, l, i1, j1, p_147447_1_, p_147447_2_);
if (movingobjectposition != null && movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.MISS)
{
if (movingobjectposition != null && movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.MISS) {
return true;
}
}
@@ -470,15 +413,12 @@ public class PathNavigateFlying extends PathNavigate {
MovingObjectPosition movingobjectposition2 = null;
k1 = 200;
while (k1-- >= 0)
{
if (Double.isNaN(p_147447_1_.xCoord) || Double.isNaN(p_147447_1_.yCoord) || Double.isNaN(p_147447_1_.zCoord))
{
while (k1-- >= 0) {
if (Double.isNaN(p_147447_1_.xCoord) || Double.isNaN(p_147447_1_.yCoord) || Double.isNaN(p_147447_1_.zCoord)) {
return false;
}
if (l == i && i1 == j && j1 == k)
{
if (l == i && i1 == j && j1 == k) {
if (p_147447_5_) {
return movingobjectposition2 != null && movingobjectposition2.typeOfHit != MovingObjectPosition.MovingObjectType.MISS;
}
@@ -492,42 +432,27 @@ public class PathNavigateFlying extends PathNavigate {
double d1 = 999.0D;
double d2 = 999.0D;
if (i > l)
{
d0 = (double)l + 1.0D;
}
else if (i < l)
{
d0 = (double)l + 0.0D;
}
else
{
if (i > l) {
d0 = (double) l + 1.0D;
} else if (i < l) {
d0 = (double) l + 0.0D;
} else {
flag6 = false;
}
if (j > i1)
{
d1 = (double)i1 + 1.0D;
}
else if (j < i1)
{
d1 = (double)i1 + 0.0D;
}
else
{
if (j > i1) {
d1 = (double) i1 + 1.0D;
} else if (j < i1) {
d1 = (double) i1 + 0.0D;
} else {
flag3 = false;
}
if (k > j1)
{
d2 = (double)j1 + 1.0D;
}
else if (k < j1)
{
d2 = (double)j1 + 0.0D;
}
else
{
if (k > j1) {
d2 = (double) j1 + 1.0D;
} else if (k < j1) {
d2 = (double) j1 + 0.0D;
} else {
flag4 = false;
}
@@ -538,62 +463,45 @@ public class PathNavigateFlying extends PathNavigate {
double d7 = p_147447_2_.yCoord - p_147447_1_.yCoord;
double d8 = p_147447_2_.zCoord - p_147447_1_.zCoord;
if (flag6)
{
if (flag6) {
d3 = (d0 - p_147447_1_.xCoord) / d6;
}
if (flag3)
{
if (flag3) {
d4 = (d1 - p_147447_1_.yCoord) / d7;
}
if (flag4)
{
if (flag4) {
d5 = (d2 - p_147447_1_.zCoord) / d8;
}
boolean flag5 = false;
byte b0;
if (d3 < d4 && d3 < d5)
{
if (i > l)
{
if (d3 < d4 && d3 < d5) {
if (i > l) {
b0 = 4;
}
else
{
} else {
b0 = 5;
}
p_147447_1_.xCoord = d0;
p_147447_1_.yCoord += d7 * d3;
p_147447_1_.zCoord += d8 * d3;
}
else if (d4 < d5)
{
if (j > i1)
{
} else if (d4 < d5) {
if (j > i1) {
b0 = 0;
}
else
{
} else {
b0 = 1;
}
p_147447_1_.xCoord += d6 * d4;
p_147447_1_.yCoord = d1;
p_147447_1_.zCoord += d8 * d4;
}
else
{
if (k > j1)
{
} else {
if (k > j1) {
b0 = 2;
}
else
{
} else {
b0 = 3;
}
@@ -603,26 +511,23 @@ public class PathNavigateFlying extends PathNavigate {
}
Vec3 vec32 = Vec3.createVectorHelper(p_147447_1_.xCoord, p_147447_1_.yCoord, p_147447_1_.zCoord);
l = (int)(vec32.xCoord = (double)MathHelper.floor_double(p_147447_1_.xCoord));
l = (int) (vec32.xCoord = (double) MathHelper.floor_double(p_147447_1_.xCoord));
if (b0 == 5)
{
if (b0 == 5) {
--l;
++vec32.xCoord;
}
i1 = (int)(vec32.yCoord = (double)MathHelper.floor_double(p_147447_1_.yCoord));
i1 = (int) (vec32.yCoord = (double) MathHelper.floor_double(p_147447_1_.yCoord));
if (b0 == 1)
{
if (b0 == 1) {
--i1;
++vec32.yCoord;
}
j1 = (int)(vec32.zCoord = (double)MathHelper.floor_double(p_147447_1_.zCoord));
j1 = (int) (vec32.zCoord = (double) MathHelper.floor_double(p_147447_1_.zCoord));
if (b0 == 3)
{
if (b0 == 3) {
--j1;
++vec32.zCoord;
}
@@ -650,7 +555,7 @@ public class PathNavigateFlying extends PathNavigate {
boolean collideCheck = (!p_147447_4_ || block2.getCollisionBoundingBoxFromPool(this.worldObj, l, i1, j1) != null) && block2.canCollideCheck(meta2, p_147447_3_);
boolean noCollisionBlock = block2 == Blocks.air || block2.getMaterial() == Material.lava && this.theEntity.isImmuneToFire() ||
block2.getMaterial() == Material.water && this.theEntity.stats.drowningType == 2;
block2.getMaterial() == Material.water && this.theEntity.stats.drowningType == 2;
if (collideCheck && !noCollisionBlock) {
if (!block2.getBlocksMovement(this.worldObj, l, i1, j1)) {
@@ -688,24 +593,17 @@ public class PathNavigateFlying extends PathNavigate {
return movingobjectposition2 != null && movingobjectposition2.typeOfHit != MovingObjectPosition.MovingObjectType.MISS;
}
return false;
}
else
{
} else {
return false;
}
}
else
{
} else {
return false;
}
}
protected void checkForStuck(Vec3 positionVec3)
{
if (this.totalTicks - this.ticksAtLastPos > 100)
{
if (positionVec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
{
protected void checkForStuck(Vec3 positionVec3) {
if (this.totalTicks - this.ticksAtLastPos > 100) {
if (positionVec3.squareDistanceTo(this.lastPosCheck) < 2.25D) {
this.clearPathEntity();
}
@@ -713,24 +611,20 @@ public class PathNavigateFlying extends PathNavigate {
this.lastPosCheck = positionVec3;
}
if (this.currentPath != null && !this.currentPath.isFinished())
{
if (this.currentPath != null && !this.currentPath.isFinished()) {
Vec3 vec3d = this.currentPath.getCurrentPos();
if (vec3d.equals(this.timeoutCachedNode))
{
if (vec3d.equals(this.timeoutCachedNode)) {
this.timeoutTimer += System.currentTimeMillis() - this.lastTimeoutCheck;
}
else
{
} else {
this.timeoutCachedNode = vec3d;
double d0 = positionVec3.distanceTo(this.timeoutCachedNode);
this.timeoutLimit = this.theEntity.getAIMoveSpeed() > 0.0F ? d0 / (double)this.theEntity.getAIMoveSpeed() * 1000.0D : 0.0D;
this.timeoutLimit = this.theEntity.getAIMoveSpeed() > 0.0F ? d0 / (double) this.theEntity.getAIMoveSpeed() * 1000.0D : 0.0D;
}
if (this.timeoutLimit > 0.0D && (double)this.timeoutTimer > this.timeoutLimit * 3.0D)
{
this.timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);;
if (this.timeoutLimit > 0.0D && (double) this.timeoutTimer > this.timeoutLimit * 3.0D) {
this.timeoutCachedNode = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
;
this.timeoutTimer = 0L;
this.timeoutLimit = 0.0D;
this.clearPathEntity();
@@ -740,16 +634,15 @@ public class PathNavigateFlying extends PathNavigate {
}
}
public ChunkCache createChunkCache(World world, BlockPos blockFrom, BlockPos blockTo){
public ChunkCache createChunkCache(World world, BlockPos blockFrom, BlockPos blockTo) {
return new ChunkCache(world, blockFrom.getX(), blockFrom.getY(), blockFrom.getZ(), blockTo.getX(), blockTo.getY(), blockTo.getZ(), 0);
}
public NPCPath getPathEntityToEntity(Entity entityFrom, Entity entityTo, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim)
{
public NPCPath getPathEntityToEntity(Entity entityFrom, Entity entityTo, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim) {
float f = this.getPathSearchRange();
this.theEntity.worldObj.theProfiler.startSection("pathfind");
BlockPos blockpos1 = (new BlockPos(this.theEntity)).up();
int i = (int)(f + 16.0F);
int i = (int) (f + 16.0F);
ChunkCache chunkcache = createChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i));
this.pathFinder = new FlyPathFinder(chunkcache, openDoors, breakDoors, pathWater, canSwim, this.theEntity);
NPCPath pathentity = this.pathFinder.createEntityPathTo(entityFrom, entityTo, distance);
@@ -757,12 +650,11 @@ public class PathNavigateFlying extends PathNavigate {
return pathentity;
}
public NPCPath getEntityPathToXYZ(Entity entityFrom, int x, int y, int z, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim)
{
public NPCPath getEntityPathToXYZ(Entity entityFrom, int x, int y, int z, float distance, boolean openDoors, boolean breakDoors, boolean pathWater, boolean canSwim) {
float f = this.getPathSearchRange();
this.theEntity.worldObj.theProfiler.startSection("pathfind");
BlockPos blockpos1 = (new BlockPos(this.theEntity)).up();
int i = (int)(f + 16.0F);
int i = (int) (f + 16.0F);
ChunkCache chunkcache = createChunkCache(this.worldObj, blockpos1.add(-i, -i, -i), blockpos1.add(i, i, i));
this.pathFinder = new FlyPathFinder(chunkcache, openDoors, breakDoors, pathWater, canSwim, this.theEntity);
NPCPath pathentity = this.pathFinder.createEntityPathTo(entityFrom, this.targetPos.getX(), this.targetPos.getY(), this.targetPos.getZ(), f);
@@ -1,7 +1,6 @@
package noppes.npcs.ai.pathfinder;
public enum PathNodeType
{
public enum PathNodeType {
BLOCKED(-1.0F),
OPEN(0.0F),
WALKABLE(0.0F),
@@ -22,13 +21,11 @@ public enum PathNodeType
private final float priority;
private PathNodeType(float priorityIn)
{
private PathNodeType(float priorityIn) {
this.priority = priorityIn;
}
public float getPriority()
{
public float getPriority() {
return this.priority;
}
}
}
@@ -17,68 +17,68 @@ import noppes.npcs.roles.JobGuard;
import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.roles.companion.CompanionGuard;
public class NPCAttackSelector implements IEntitySelector
{
private EntityNPCInterface npc;
public class NPCAttackSelector implements IEntitySelector {
private EntityNPCInterface npc;
public NPCAttackSelector(EntityNPCInterface npc) {
this.npc = npc;
}
public NPCAttackSelector(EntityNPCInterface npc){
this.npc = npc;
}
/**
* Return whether the specified entity is applicable to this filter.
*/
@Override
public boolean isEntityApplicable(Entity entity){
if(!entity.isEntityAlive() || entity == npc || npc.getDistanceToEntity(entity) > npc.stats.aggroRange || !(entity instanceof EntityLivingBase) || ((EntityLivingBase)entity).getHealth() < 1)
return false;
@Override
public boolean isEntityApplicable(Entity entity) {
if (!entity.isEntityAlive() || entity == npc || npc.getDistanceToEntity(entity) > npc.stats.aggroRange || !(entity instanceof EntityLivingBase) || ((EntityLivingBase) entity).getHealth() < 1)
return false;
if (this.npc.ais.directLOS && !this.npc.getEntitySenses().canSee(entity))
return false;
return false;
if(!npc.stats.attackInvisible &&((EntityLivingBase)entity).isPotionActive(Potion.invisibility) && npc.getDistanceSqToEntity(entity) < 9)
return false;
if (!npc.stats.attackInvisible && ((EntityLivingBase) entity).isPotionActive(Potion.invisibility) && npc.getDistanceSqToEntity(entity) < 9)
return false;
//prevent the npc from going on an endless killing spree
if(!npc.isFollower() && npc.ais.returnToStart){
int allowedDistance = npc.stats.aggroRange * 2;
if(npc.ais.movingType == EnumMovingType.Wandering)
allowedDistance += npc.ais.walkingRange;
double distance = entity.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos());
if(npc.ais.movingType == EnumMovingType.MovingPath){
int[] arr = npc.ais.getCurrentMovingPath();
distance = entity.getDistanceSq(arr[0], arr[1], arr[2]);
}
//prevent the npc from going on an endless killing spree
if (!npc.isFollower() && npc.ais.returnToStart) {
int allowedDistance = npc.stats.aggroRange * 2;
if (npc.ais.movingType == EnumMovingType.Wandering)
allowedDistance += npc.ais.walkingRange;
double distance = entity.getDistanceSq(npc.getStartXPos(), npc.getStartYPos(), npc.getStartZPos());
if (npc.ais.movingType == EnumMovingType.MovingPath) {
int[] arr = npc.ais.getCurrentMovingPath();
distance = entity.getDistanceSq(arr[0], arr[1], arr[2]);
}
if(distance > allowedDistance * allowedDistance)
return false;
}
if (distance > allowedDistance * allowedDistance)
return false;
}
if(npc.advanced.job == EnumJobType.Guard && ((JobGuard)npc.jobInterface).isEntityApplicable(entity))
return true;
if (npc.advanced.job == EnumJobType.Guard && ((JobGuard) npc.jobInterface).isEntityApplicable(entity))
return true;
if(npc.advanced.role == EnumRoleType.Companion){
RoleCompanion role = (RoleCompanion)npc.roleInterface;
if(role.job == EnumCompanionJobs.GUARD && ((CompanionGuard)role.jobInterface).isEntityApplicable(entity))
return true;
}
if(entity instanceof EntityPlayerMP){
if(npc.faction.isAggressiveToPlayer((EntityPlayer) entity)){
if(PixelmonHelper.Enabled && npc.advanced.job == EnumJobType.Spawner)
return PixelmonHelper.canBattle((EntityPlayerMP)entity, npc);
if (npc.advanced.role == EnumRoleType.Companion) {
RoleCompanion role = (RoleCompanion) npc.roleInterface;
if (role.job == EnumCompanionJobs.GUARD && ((CompanionGuard) role.jobInterface).isEntityApplicable(entity))
return true;
}
if (entity instanceof EntityPlayerMP) {
if (npc.faction.isAggressiveToPlayer((EntityPlayer) entity)) {
if (PixelmonHelper.Enabled && npc.advanced.job == EnumJobType.Spawner)
return PixelmonHelper.canBattle((EntityPlayerMP) entity, npc);
if(DBCAddon.instance.isKO(npc, (EntityPlayer) entity))
if (DBCAddon.instance.isKO(npc, (EntityPlayer) entity))
return false;
return !((EntityPlayerMP)entity).capabilities.disableDamage;
}
return false;
}
return !((EntityPlayerMP) entity).capabilities.disableDamage;
}
return false;
}
if(entity instanceof EntityNPCInterface){
if(((EntityNPCInterface)entity).isKilled())
return false;
if(npc.advanced.attackOtherFactions)
return npc.faction.isAggressiveToNpc((EntityNPCInterface)entity);
}
if (entity instanceof EntityNPCInterface) {
if (((EntityNPCInterface) entity).isKilled())
return false;
if (npc.advanced.attackOtherFactions)
return npc.faction.isAggressiveToNpc((EntityNPCInterface) entity);
}
return false;
}
@@ -5,18 +5,20 @@ import net.minecraft.entity.Entity;
import noppes.npcs.entity.EntityNPCInterface;
public class NPCInteractSelector implements IEntitySelector {
private EntityNPCInterface npc;
public NPCInteractSelector(EntityNPCInterface npc){
this.npc = npc;
}
@Override
public boolean isEntityApplicable(Entity entity) {
if(entity == npc || !(entity instanceof EntityNPCInterface) || !npc.isEntityAlive())
return false;
EntityNPCInterface selected = (EntityNPCInterface) entity;
if(selected.isAttacking() || npc.getFaction().isAggressiveToNpc(selected) || !npc.ais.stopAndInteract)
return false;
return true;
}
private EntityNPCInterface npc;
public NPCInteractSelector(EntityNPCInterface npc) {
this.npc = npc;
}
@Override
public boolean isEntityApplicable(Entity entity) {
if (entity == npc || !(entity instanceof EntityNPCInterface) || !npc.isEntityAlive())
return false;
EntityNPCInterface selected = (EntityNPCInterface) entity;
if (selected.isAttacking() || npc.getFaction().isAggressiveToNpc(selected) || !npc.ais.stopAndInteract)
return false;
return true;
}
}
@@ -4,22 +4,22 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAITarget;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIClearTarget extends EntityAITarget
{
private EntityNPCInterface npc;
private EntityLivingBase target;
public EntityAIClearTarget(EntityNPCInterface npc){
super(npc, false);
this.npc = npc;
public class EntityAIClearTarget extends EntityAITarget {
private EntityNPCInterface npc;
private EntityLivingBase target;
public EntityAIClearTarget(EntityNPCInterface npc) {
super(npc, false);
this.npc = npc;
}
@Override
public boolean shouldExecute(){
public boolean shouldExecute() {
target = npc.getAttackTarget();
if (target == null)
return false;
if(npc.getOwner() != null && !npc.isInRange(npc.getOwner(), npc.stats.aggroRange * 2)){
if (npc.getOwner() != null && !npc.isInRange(npc.getOwner(), npc.stats.aggroRange * 2)) {
return true;
}
@@ -27,10 +27,10 @@ public class EntityAIClearTarget extends EntityAITarget
}
@Override
public void startExecuting(){
public void startExecuting() {
this.taskOwner.setAttackTarget(null);
if(target == taskOwner.getAITarget())
this.taskOwner.setRevengeTarget(null);
if (target == taskOwner.getAITarget())
this.taskOwner.setRevengeTarget(null);
super.startExecuting();
}
}
@@ -14,28 +14,26 @@ import noppes.npcs.entity.EntityNPCInterface;
import java.util.Collections;
import java.util.List;
public class EntityAIClosestTarget extends EntityAITarget
{
public class EntityAIClosestTarget extends EntityAITarget {
private final Class targetClass;
private final int targetChance;
/** Instance of EntityAINearestAttackableTargetSorter. */
/**
* Instance of EntityAINearestAttackableTargetSorter.
*/
private final EntityAINearestAttackableTarget.Sorter theNearestAttackableTargetSorter;
private final IEntitySelector field_82643_g;
private EntityLivingBase targetEntity;
public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4)
{
public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4) {
this(par1EntityCreature, par2Class, par3, par4, false);
}
public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5)
{
this(par1EntityCreature, par2Class, par3, par4, par5, (IEntitySelector)null);
public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5) {
this(par1EntityCreature, par2Class, par3, par4, par5, (IEntitySelector) null);
}
public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5, IEntitySelector par6IEntitySelector)
{
public EntityAIClosestTarget(EntityCreature par1EntityCreature, Class par2Class, int par3, boolean par4, boolean par5, IEntitySelector par6IEntitySelector) {
super(par1EntityCreature, par4, par5);
this.targetClass = par2Class;
this.targetChance = par3;
@@ -47,26 +45,19 @@ public class EntityAIClosestTarget extends EntityAITarget
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0)
{
public boolean shouldExecute() {
if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0) {
return false;
}
else
{
} else {
taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) taskOwner).stats.aggroRange);
double d0 = this.getTargetDistance();
List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g);
List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g);
Collections.sort(list, this.theNearestAttackableTargetSorter);
taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(ConfigMain.NpcNavRange);
if (list.isEmpty())
{
if (list.isEmpty()) {
return false;
}
else
{
this.targetEntity = (EntityLivingBase)list.get(0);
} else {
this.targetEntity = (EntityLivingBase) list.get(0);
return true;
}
}
@@ -75,16 +66,13 @@ public class EntityAIClosestTarget extends EntityAITarget
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.taskOwner.setAttackTarget(this.targetEntity);
if (this.targetEntity instanceof EntityMob)
{
if (((EntityMob) this.targetEntity).getAttackTarget() == null)
{
((EntityMob)this.targetEntity).setAttackTarget(this.taskOwner);
((EntityMob)this.targetEntity).setTarget(this.taskOwner);
}
if (this.targetEntity instanceof EntityMob) {
if (((EntityMob) this.targetEntity).getAttackTarget() == null) {
((EntityMob) this.targetEntity).setAttackTarget(this.taskOwner);
((EntityMob) this.targetEntity).setTarget(this.taskOwner);
}
}
super.startExecuting();
}
@@ -5,13 +5,12 @@ import net.minecraft.entity.ai.EntityAITarget;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIOwnerHurtByTarget extends EntityAITarget
{
public class EntityAIOwnerHurtByTarget extends EntityAITarget {
EntityNPCInterface npc;
EntityLivingBase theOwnerAttacker;
private int field_142051_e;
public EntityAIOwnerHurtByTarget(EntityNPCInterface npc){
public EntityAIOwnerHurtByTarget(EntityNPCInterface npc) {
super(npc, false);
this.npc = npc;
this.setMutexBits(AiMutex.PASSIVE);
@@ -20,17 +19,15 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute(){
if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner())){
public boolean shouldExecute() {
if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner())) {
return false;
}
else{
} else {
EntityLivingBase entitylivingbase = this.npc.getOwner();
if (entitylivingbase == null){
if (entitylivingbase == null) {
return false;
}
else{
} else {
this.theOwnerAttacker = entitylivingbase.getAITarget();
int i = entitylivingbase.func_142015_aE();
return i != this.field_142051_e && this.isSuitableTarget(this.theOwnerAttacker, false);
@@ -41,14 +38,14 @@ public class EntityAIOwnerHurtByTarget extends EntityAITarget
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting(){
public void startExecuting() {
this.taskOwner.setAttackTarget(this.theOwnerAttacker);
EntityLivingBase entitylivingbase = this.npc.getOwner();
if (entitylivingbase != null){
if (entitylivingbase != null) {
this.field_142051_e = entitylivingbase.func_142015_aE();
}
super.startExecuting();
}
}
}
@@ -5,14 +5,12 @@ import net.minecraft.entity.ai.EntityAITarget;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIOwnerHurtTarget extends EntityAITarget
{
public class EntityAIOwnerHurtTarget extends EntityAITarget {
EntityNPCInterface npc;
EntityLivingBase theTarget;
private int field_142050_e;
public EntityAIOwnerHurtTarget(EntityNPCInterface npc)
{
public EntityAIOwnerHurtTarget(EntityNPCInterface npc) {
super(npc, false);
this.npc = npc;
this.setMutexBits(AiMutex.PASSIVE);
@@ -21,22 +19,15 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget
/**
* Returns whether the EntityAIBase should begin execution.
*/
public boolean shouldExecute()
{
if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner()))
{
public boolean shouldExecute() {
if (!this.npc.isFollower() || !(npc.roleInterface != null && npc.roleInterface.defendOwner())) {
return false;
}
else
{
} else {
EntityLivingBase entitylivingbase = this.npc.getOwner();
if (entitylivingbase == null)
{
if (entitylivingbase == null) {
return false;
}
else
{
} else {
this.theTarget = entitylivingbase.getLastAttacker();
int i = entitylivingbase.getLastAttackerTime();
return i != this.field_142050_e && this.isSuitableTarget(this.theTarget, false);
@@ -47,16 +38,14 @@ public class EntityAIOwnerHurtTarget extends EntityAITarget
/**
* Execute a one shot task or start executing a continuous task
*/
public void startExecuting()
{
public void startExecuting() {
this.taskOwner.setAttackTarget(this.theTarget);
EntityLivingBase entitylivingbase = this.npc.getOwner();
if (entitylivingbase != null)
{
if (entitylivingbase != null) {
this.field_142050_e = entitylivingbase.getLastAttackerTime();
}
super.startExecuting();
}
}
}
@@ -30,42 +30,44 @@ import java.util.List;
import static kamkeel.npcs.util.ColorUtil.colorTableInts;
import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
public class BlockBanner extends BlockContainer{
public class BlockBanner extends BlockContainer {
public int renderId = -1;
public int renderId = -1;
public BlockBanner() {
public BlockBanner() {
super(Material.rock);
setBlockBounds(0, 0, 0, 1, 2, 1);
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
ItemStack item = player.inventory.getCurrentItem();
if(item == null)
return false;
}
if(item.getItem() != null && item.getItem() instanceof ItemNpcTool && item.getItemDamage() == 0)
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack item = player.inventory.getCurrentItem();
if (item == null)
return false;
int meta = par1World.getBlockMetadata(i, j, k);
if(meta >= 7)
j--;
TileBanner tile = (TileBanner) par1World.getTileEntity(i, j, k);
if(tile.canEdit())
return true;
else if(TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE)
return false;
if (item.getItem() != null && item.getItem() instanceof ItemNpcTool && item.getItemDamage() == 0)
return false;
int meta = par1World.getBlockMetadata(i, j, k);
if (meta >= 7)
j--;
TileBanner tile = (TileBanner) par1World.getTileEntity(i, j, k);
if (tile.canEdit())
return true;
else if (TileColorable.allowColorChange(item) != TileColorable.ColorChangeType.DYE)
return false;
int color = colorTableInts[BlockColored.func_150031_c(item.getItemDamage())];
if(tile.color != color){
NoppesUtilServer.consumeItemStack(1, player);
tile.color = color;
par1World.markBlockForUpdate(i, j, k);
}
return true;
if (tile.color != color) {
NoppesUtilServer.consumeItemStack(1, player);
tile.color = color;
par1World.markBlockForUpdate(i, j, k);
}
return true;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
@@ -74,94 +76,90 @@ public class BlockBanner extends BlockContainer{
}
@Override
public int damageDropped(int par1)
{
public int damageDropped(int par1) {
return par1 % 7;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if(meta >= 7)
if (meta >= 7)
setBlockBounds(0, -1, 0, 1, 1, 1);
else
setBlockBounds(0, 0, 0, 1, 2, 1);
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
if(!par1World.isAirBlock(par2, par3 + 1, par4)){
par1World.setBlockToAir(par2, par3, par4);
}
else{
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
if (!par1World.isAirBlock(par2, par3 + 1, par4)) {
par1World.setBlockToAir(par2, par3, par4);
} else {
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
TileBanner tile = (TileBanner) par1World.getTileEntity(par2, par3, par4);
TileBanner tile = (TileBanner) par1World.getTileEntity(par2, par3, par4);
tile.rotation = l;
tile.color = colorTableInts[15 - par6ItemStack.getItemDamage()];
if(par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){
if (par6ItemStack.hasTagCompound() && par6ItemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)) {
tile.color = par6ItemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG);
}
tile.time = System.currentTimeMillis();
tile.time = System.currentTimeMillis();
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
par1World.setBlock(par2, par3 + 1, par4, this, par6ItemStack.getItemDamage() + 7, 2);
if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote)
((EntityPlayer)par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
}
if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote)
((EntityPlayer) par5EntityLivingBase).addChatComponentMessage(new ChatComponentTranslation("availability.editIcon"));
}
}
@Override
public boolean isOpaqueCube(){
return false;
}
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock(){
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType(){
return renderId;
}
public int getRenderType() {
return renderId;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
public void registerBlockIcons(IIconRegister par1IconRegister) {
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta)
{
meta %= 7;
if(meta == 1)
public IIcon getIcon(int p_149691_1_, int meta) {
meta %= 7;
if (meta == 1)
return Blocks.stone.getIcon(p_149691_1_, 0);
else if(meta == 2)
else if (meta == 2)
return Blocks.iron_block.getIcon(p_149691_1_, 0);
else if(meta == 3)
else if (meta == 3)
return Blocks.gold_block.getIcon(p_149691_1_, 0);
else if(meta == 4)
else if (meta == 4)
return Blocks.diamond_block.getIcon(p_149691_1_, 0);
return Blocks.planks.getIcon(p_149691_1_, 0);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
if(var2 < 7)
return new TileBanner();
return null;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
if (var2 < 7)
return new TileBanner();
return null;
}
@Override
public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_)
{
@Override
public void onBlockHarvested(World p_149681_1_, int p_149681_2_, int p_149681_3_, int p_149681_4_, int p_149681_5_, EntityPlayer p_149681_6_) {
if (p_149681_5_ >= 7 && p_149681_1_.getBlock(p_149681_2_, p_149681_3_ - 1, p_149681_4_) == this)
p_149681_1_.setBlockToAir(p_149681_2_, p_149681_3_ - 1, p_149681_4_);
@@ -172,7 +170,7 @@ public class BlockBanner extends BlockContainer{
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if(meta >= 7)
if (meta >= 7)
y--;
TileEntity tileentity = world.getTileEntity(x, y, z);
@@ -16,14 +16,14 @@ import noppes.npcs.constants.EnumGuiType;
import java.util.List;
public class BlockBarrel extends BlockRotated{
public class BlockBarrel extends BlockRotated {
public BlockBarrel() {
public BlockBarrel() {
super(Blocks.planks);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
@@ -32,42 +32,43 @@ public class BlockBarrel extends BlockRotated{
par3List.add(new ItemStack(par1, 1, 5));
}
@Override
public int damageDropped(int par1){
@Override
public int damageDropped(int par1) {
return par1;
}
public int maxRotation(){
return 8;
public int maxRotation() {
return 8;
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
if(par1World.isRemote)
return true;
par1World.playSoundEffect(i, j + 0.5D, k, "random.chestopen", 0.5F, par1World.rand.nextFloat() * 0.1F + 0.9F);
player.openGui(CustomNpcs.instance, EnumGuiType.Crate.ordinal(), par1World, i, j, k);
return true;
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (par1World.isRemote)
return true;
par1World.playSoundEffect(i, j + 0.5D, k, "random.chestopen", 0.5F, par1World.rand.nextFloat() * 0.1F + 0.9F);
player.openGui(CustomNpcs.instance, EnumGuiType.Crate.ordinal(), par1World, i, j, k);
return true;
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBarrel();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_){
TileNpcContainer tile = (TileNpcContainer)world.getTileEntity(x, y, z);
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBarrel();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) {
TileNpcContainer tile = (TileNpcContainer) world.getTileEntity(x, y, z);
if (tile == null)
return;
return;
tile.dropItems(world, x, y, z);
world.func_147453_f(x, y, z, block);
+28 -30
View File
@@ -13,14 +13,14 @@ import noppes.npcs.blocks.tiles.TileVariant;
import java.util.List;
public class BlockBeam extends BlockRotated{
public class BlockBeam extends BlockRotated {
public BlockBeam() {
public BlockBeam() {
super(Blocks.planks);
}
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
@@ -30,41 +30,39 @@ public class BlockBeam extends BlockRotated{
}
@Override
public int damageDropped(int par1){
public int damageDropped(int par1) {
return par1;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
TileEntity tileentity = world.getTileEntity(x, y, z);
if(!(tileentity instanceof TileVariant)){
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
if(tile.rotation == 0){
setBlockBounds(0.33f, 0.33f, 0.25f, 0.67f, 0.67f, 1f );
}
else if(tile.rotation == 2){
setBlockBounds(0.33f, 0.33f, 0, 0.67f, 0.67f, 0.75f );
}
else if(tile.rotation == 3){
setBlockBounds(0.25f, 0.33f, 0.33f, 1f, 0.67f, 0.67f );
}
else if(tile.rotation == 1){
setBlockBounds(0, 0.33f, 0.33f, 0.75f, 0.67f, 0.67f );
}
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntity tileentity = world.getTileEntity(x, y, z);
if (!(tileentity instanceof TileVariant)) {
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
if (tile.rotation == 0) {
setBlockBounds(0.33f, 0.33f, 0.25f, 0.67f, 0.67f, 1f);
} else if (tile.rotation == 2) {
setBlockBounds(0.33f, 0.33f, 0, 0.67f, 0.67f, 0.75f);
} else if (tile.rotation == 3) {
setBlockBounds(0.25f, 0.33f, 0.33f, 1f, 0.67f, 0.67f);
} else if (tile.rotation == 1) {
setBlockBounds(0, 0.33f, 0.33f, 0.75f, 0.67f, 0.67f);
}
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBeam();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBeam();
}
}
@@ -23,104 +23,106 @@ import noppes.npcs.blocks.tiles.TileBigSign;
import noppes.npcs.blocks.tiles.TileVariant;
import noppes.npcs.constants.EnumGuiType;
public class BlockBigSign extends BlockContainer{
public class BlockBigSign extends BlockContainer {
public int renderId = -1;
public int renderId = -1;
public BlockBigSign() {
public BlockBigSign() {
super(Material.wood);
}
}
@Override
public int damageDropped(int par1){
public int damageDropped(int par1) {
return par1;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_){
return null;
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int p_149668_2_, int p_149668_3_, int p_149668_4_) {
return null;
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
if(par1World.isRemote)
return false;
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BIGSIGN)) {
TileBigSign tile = (TileBigSign) par1World.getTileEntity(i, j, k);
tile.canEdit = true;
NoppesUtilServer.sendOpenGui(player, EnumGuiType.BigSign, null, i, j, k);
return true;
}
return false;
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (par1World.isRemote)
return false;
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BIGSIGN)) {
TileBigSign tile = (TileBigSign) par1World.getTileEntity(i, j, k);
tile.canEdit = true;
NoppesUtilServer.sendOpenGui(player, EnumGuiType.BigSign, null, i, j, k);
return true;
}
return false;
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
TileBigSign tile = (TileBigSign) par1World.getTileEntity(par2, par3, par4);
tile.rotation = l;
tile.rotation = l;
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote){
CustomNpcs.proxy.openGui(par2, par3, par4, EnumGuiType.BigSign, (EntityPlayer) par5EntityLivingBase);
}
if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) {
CustomNpcs.proxy.openGui(par2, par3, par4, EnumGuiType.BigSign, (EntityPlayer) par5EntityLivingBase);
}
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
TileEntity tileentity = world.getTileEntity(x, y, z);
if(!(tileentity instanceof TileVariant)){
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntity tileentity = world.getTileEntity(x, y, z);
if (!(tileentity instanceof TileVariant)) {
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
int meta = tile.getBlockMetadata();
float xStart = 0;
float zStart = 0;
float xEnd = 1;
float zEnd = 1;
if(tile.rotation == 0)
zStart = 0.87f;
else if(tile.rotation == 2)
zEnd = 0.13f;
else if(tile.rotation == 3)
xStart = 0.87f;
else if(tile.rotation == 1)
xEnd = 0.13f;
float xStart = 0;
float zStart = 0;
float xEnd = 1;
float zEnd = 1;
if (tile.rotation == 0)
zStart = 0.87f;
else if (tile.rotation == 2)
zEnd = 0.13f;
else if (tile.rotation == 3)
xStart = 0.87f;
else if (tile.rotation == 1)
xEnd = 0.13f;
setBlockBounds(xStart, 0, zStart, xEnd, 1, zEnd);
}
@Override
public boolean isOpaqueCube(){
return false;
}
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock(){
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType(){
return renderId;
}
public int getRenderType() {
return renderId;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
public void registerBlockIcons(IIconRegister par1IconRegister) {
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta)
{
public IIcon getIcon(int p_149691_1_, int meta) {
return Blocks.planks.getIcon(p_149691_1_, meta);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBigSign();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBigSign();
}
}
@@ -16,80 +16,80 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import noppes.npcs.CustomItems;
public class BlockBlood extends Block{
public class BlockBlood extends Block {
@SideOnly(Side.CLIENT)
private IIcon blockIcon2;
@SideOnly(Side.CLIENT)
private IIcon blockIcon3;
private final int renderId = RenderingRegistry.getNextAvailableRenderId();
public BlockBlood(){
public BlockBlood() {
super(Material.rock);
this.setBlockUnbreakable();
setCreativeTab(CustomItems.tabMisc);
setBlockBounds(0.01f, 0.01f, 0.01f, 0.99f, 0.99f, 0.99f);
this.setLightLevel(0.08f);
this.setBlockUnbreakable();
setCreativeTab(CustomItems.tabMisc);
setBlockBounds(0.01f, 0.01f, 0.01f, 0.99f, 0.99f, 0.99f);
this.setLightLevel(0.08f);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int metadata){
metadata += side;
if(metadata % 3 == 1)
return blockIcon2;
if(metadata % 3 == 2)
return blockIcon3;
return this.blockIcon;
public IIcon getIcon(int side, int metadata) {
metadata += side;
if (metadata % 3 == 1)
return blockIcon2;
if (metadata % 3 == 2)
return blockIcon3;
return this.blockIcon;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k){
return null;
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k) {
return null;
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4){
return AxisAlignedBB.getBoundingBox(par2, par3, par4 , par2, par3, par4 );
public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4) {
return AxisAlignedBB.getBoundingBox(par2, par3, par4, par2, par3, par4);
}
@Override
public boolean renderAsNormalBlock(){
public boolean renderAsNormalBlock() {
return false;
}
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister par1IconRegister){
public void registerBlockIcons(IIconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName());
this.blockIcon2 = par1IconRegister.registerIcon(getTextureName() + "2");
this.blockIcon3 = par1IconRegister.registerIcon(getTextureName() + "3");
}
@Override
public boolean shouldSideBeRendered(IBlockAccess world, int par2, int par3, int par4, int par5){
public boolean shouldSideBeRendered(IBlockAccess world, int par2, int par3, int par4, int par5) {
Block block = world.getBlock(par2, par3, par4);
return block != Blocks.air && block.renderAsNormalBlock(); //only render the side if a block is adjacent
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderBlockPass(){
@Override
public int getRenderBlockPass() {
return 1;
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item){
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3;
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item) {
int var6 = MathHelper.floor_double((double) (par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3;
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6, 2); //add metadata based on player rotation
}
public int getRenderType(){
return renderId;
public int getRenderType() {
return renderId;
}
}
+20 -20
View File
@@ -14,35 +14,35 @@ import noppes.npcs.CustomItems;
import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.blocks.tiles.TileBook;
public class BlockBook extends BlockRotated{
public class BlockBook extends BlockRotated {
public BlockBook() {
public BlockBook() {
super(Blocks.planks);
setBlockBounds(0, 0, 0, 1, 0.2f, 1);
}
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
if(par1World.isRemote)
return true;
TileEntity tile = par1World.getTileEntity(i, j, k);
if(!(tile instanceof TileBook))
return false;
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BOOK)) {
((TileBook)tile).book.func_150996_a(Items.writable_book);
}
PacketHandler.Instance.sendToPlayer(new GuiOpenBookPacket(i, j, k, ((TileBook)tile).book.writeToNBT(new NBTTagCompound())), (EntityPlayerMP) player);
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (par1World.isRemote)
return true;
TileEntity tile = par1World.getTileEntity(i, j, k);
if (!(tile instanceof TileBook))
return false;
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_BOOK)) {
((TileBook) tile).book.func_150996_a(Items.writable_book);
}
PacketHandler.Instance.sendToPlayer(new GuiOpenBookPacket(i, j, k, ((TileBook) tile).book.writeToNBT(new NBTTagCompound())), (EntityPlayerMP) player);
return true;
}
@Override
public String getUnlocalizedName(){
return "item.book";
public String getUnlocalizedName() {
return "item.book";
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBook();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBook();
}
}
@@ -18,86 +18,85 @@ import noppes.npcs.CustomNpcs;
import noppes.npcs.blocks.tiles.TileBorder;
import noppes.npcs.constants.EnumGuiType;
public class BlockBorder extends BlockContainer{
public int renderId = -1;
public class BlockBorder extends BlockContainer {
public int renderId = -1;
public BlockBorder() {
super(Material.rock);
setBlockUnbreakable();
}
public BlockBorder() {
super(Material.rock);
setBlockUnbreakable();
}
@Override
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
if(side == 1){
return this.blockIcon;
}
return Blocks.iron_block.getIcon(side, meta);
public IIcon getIcon(int side, int meta) {
if (side == 1) {
return this.blockIcon;
}
return Blocks.iron_block.getIcon(side, meta);
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9)
{
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand) {
CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Border, player);
return true;
}
return false;
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand) {
CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.Border, player);
return true;
}
return false;
}
@Override
public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
@Override
public void onBlockPlacedBy(World par1World, int x, int y, int z, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
TileBorder tile = (TileBorder) par1World.getTileEntity(x, y, z);
TileBorder adjacent = getTile(par1World, x - 1, y, z);
if(adjacent == null)
adjacent = getTile(par1World, x, y, z - 1);
if(adjacent == null)
adjacent = getTile(par1World, x, y, z + 1);
if(adjacent == null)
adjacent = getTile(par1World, x + 1, y, z);
if(adjacent != null){
NBTTagCompound compound = new NBTTagCompound();
adjacent.writeExtraNBT(compound);
tile.readExtraNBT(compound);
}
tile.rotation = l;
if(par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote){
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Border, (EntityPlayer) par5EntityLivingBase);
}
TileBorder adjacent = getTile(par1World, x - 1, y, z);
if (adjacent == null)
adjacent = getTile(par1World, x, y, z - 1);
if (adjacent == null)
adjacent = getTile(par1World, x, y, z + 1);
if (adjacent == null)
adjacent = getTile(par1World, x + 1, y, z);
if (adjacent != null) {
NBTTagCompound compound = new NBTTagCompound();
adjacent.writeExtraNBT(compound);
tile.readExtraNBT(compound);
}
tile.rotation = l;
if (par5EntityLivingBase instanceof EntityPlayer && par1World.isRemote) {
CustomNpcs.proxy.openGui(x, y, z, EnumGuiType.Border, (EntityPlayer) par5EntityLivingBase);
}
}
private TileBorder getTile(World world, int x, int y, int z){
TileEntity tile = world.getTileEntity(x, y, z);
if(tile != null && tile instanceof TileBorder)
return (TileBorder) tile;
return null;
private TileBorder getTile(World world, int x, int y, int z) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile != null && tile instanceof TileBorder)
return (TileBorder) tile;
return null;
}
@Override
public int getRenderType(){
return renderId;
}
@Override
public boolean isOpaqueCube(){
return false;
}
@Override
public int getRenderType() {
return renderId;
}
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBorder();
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBorder();
}
}
@@ -21,100 +21,99 @@ import org.lwjgl.opengl.GL11;
import java.util.Random;
public class BlockCampfire extends BlockLightable{
public class BlockCampfire extends BlockLightable {
public BlockCampfire(boolean lit) {
public BlockCampfire(boolean lit) {
super(Blocks.cobblestone, lit);
setBlockBounds(0, 0, 0, 1, 0.5f, 1);
if(lit)
setLightLevel(0.9375F);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCampfire();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
ItemStack item = player.inventory.getCurrentItem();
if(item == null)
return true;
int meta = world.getBlockMetadata(x, y, z);
if((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this){
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
CustomNpcs.proxy.spawnParticle("largesmoke", x + 0.5f, y + 0.5f, z + 0.5f, 0.0D, 0.0D, 0.0D, 2);
if(item.getItem() == Items.flint)
NoppesUtilServer.consumeItemStack(1, player);
else
item.damageItem(1, player);
return true;
}
if(item.getItem() == Item.getItemFromBlock(Blocks.sand) && litBlock() == this){
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
}
return true;
if (lit)
setLightLevel(0.9375F);
}
@Override
public int maxRotation(){
return 8;
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCampfire();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack item = player.inventory.getCurrentItem();
if (item == null)
return true;
int meta = world.getBlockMetadata(x, y, z);
if ((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this) {
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
CustomNpcs.proxy.spawnParticle("largesmoke", x + 0.5f, y + 0.5f, z + 0.5f, 0.0D, 0.0D, 0.0D, 2);
if (item.getItem() == Items.flint)
NoppesUtilServer.consumeItemStack(1, player);
else
item.damageItem(1, player);
return true;
}
if (item.getItem() == Item.getItemFromBlock(Blocks.sand) && litBlock() == this) {
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
}
return true;
}
@Override
public int maxRotation() {
return 8;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister par1IconRegister){
public void registerBlockIcons(IIconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName());
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta){
public IIcon getIcon(int p_149691_1_, int meta) {
return this.blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random random){
public void randomDisplayTick(World world, int x, int y, int z, Random random) {
int meta = world.getBlockMetadata(x, y, z);
if(meta == 1)
return;
if (meta == 1)
return;
if(random.nextInt(36) == 0){
world.playSound(x + 0.5F, y + 0.5F, z + 0.5F, "fire.fire", 1.0F + random.nextFloat(), 0.3F + random.nextFloat() * 0.7f , false);
}
if (random.nextInt(36) == 0) {
world.playSound(x + 0.5F, y + 0.5F, z + 0.5F, "fire.fire", 1.0F + random.nextFloat(), 0.3F + random.nextFloat() * 0.7f, false);
}
TileCampfire tile = (TileCampfire) world.getTileEntity(x, y, z);
TileCampfire tile = (TileCampfire) world.getTileEntity(x, y, z);
float xOffset = 0.5f, yOffset = 0.7f, zOffset = 0.5f;
float xOffset = 0.5f, yOffset = 0.7f, zOffset = 0.5f;
double d0 = (double)((float)x + xOffset);
double d1 = (double)((float)y + yOffset);
double d2 = (double)((float)z + zOffset);
double d0 = (double) ((float) x + xOffset);
double d1 = (double) ((float) y + yOffset);
double d2 = (double) ((float) z + zOffset);
GL11.glPushMatrix();
if(ConfigClient.LegacyCampfire){
if (ConfigClient.LegacyCampfire) {
CustomNpcs.proxy.spawnParticle("largesmoke", d0, d1, d2, 0.0D, 0.0D, 0.0D, 2);
CustomNpcs.proxy.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D, 4);
}
else {
} else {
tile.updateEntity();
}
GL11.glPopMatrix();
}
@Override
public Block unlitBlock() {
return CustomItems.campfire_unlit;
}
@Override
public Block unlitBlock() {
return CustomItems.campfire_unlit;
}
@Override
public Block litBlock() {
return CustomItems.campfire;
}
@Override
public Block litBlock() {
return CustomItems.campfire;
}
}
+116 -118
View File
@@ -15,155 +15,153 @@ import noppes.npcs.blocks.tiles.TileVariant;
import java.util.Random;
public class BlockCandle extends BlockLightable{
public class BlockCandle extends BlockLightable {
public BlockCandle(boolean lit) {
public BlockCandle(boolean lit) {
super(Blocks.stone, lit);
setBlockBounds(0.3f, 0, 0.3f, 0.7f, 0.5f, 0.7f);
}
@Override
public int maxRotation(){
return 8;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
TileEntity tileentity = world.getTileEntity(x, y, z);
if(!(tileentity instanceof TileVariant)){
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
if(tile.variant == 2){
float xOffset = 0;
float yOffset = 0;
if(tile.rotation == 0)
yOffset = 0.2f;
else if(tile.rotation == 4)
yOffset = -0.2f;
else if(tile.rotation == 6)
xOffset = 0.2f;
else if(tile.rotation == 2)
xOffset = -0.2f;
@Override
public int maxRotation() {
return 8;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntity tileentity = world.getTileEntity(x, y, z);
if (!(tileentity instanceof TileVariant)) {
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
if (tile.variant == 2) {
float xOffset = 0;
float yOffset = 0;
if (tile.rotation == 0)
yOffset = 0.2f;
else if (tile.rotation == 4)
yOffset = -0.2f;
else if (tile.rotation == 6)
xOffset = 0.2f;
else if (tile.rotation == 2)
xOffset = -0.2f;
setBlockBounds(0.2f + xOffset, 0.4f, 0.2f + yOffset, 0.8f + xOffset, 0.9f, 0.8f + yOffset);
}
else if(tile.variant == 1)
} else if (tile.variant == 1)
setBlockBounds(0.1f, 0.1f, 0.1f, 0.9f, 0.8f, 0.9f);
else
else
setBlockBounds(0.3f, 0, 0.3f, 0.7f, 0.5f, 0.7f);
}
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta){
public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta) {
return side;
}
@Override
public void onPostBlockPlaced(World world, int x, int y, int z, int meta) {
TileCandle tile = (TileCandle) world.getTileEntity(x, y, z);
if(meta == 1)
tile.variant = 0;
else if(meta == 0)
tile.variant = 1;
else{
tile.variant = 2;
if(meta == 2)
tile.rotation = 0;
else if(meta == 3)
tile.rotation = 4;
else if(meta == 4)
tile.rotation = 6;
else if(meta == 5)
tile.rotation = 2;
}
world.setBlockMetadataWithNotify(x, y, z, 0, 4);
TileCandle tile = (TileCandle) world.getTileEntity(x, y, z);
if (meta == 1)
tile.variant = 0;
else if (meta == 0)
tile.variant = 1;
else {
tile.variant = 2;
if (meta == 2)
tile.rotation = 0;
else if (meta == 3)
tile.rotation = 4;
else if (meta == 4)
tile.rotation = 6;
else if (meta == 5)
tile.rotation = 2;
}
world.setBlockMetadataWithNotify(x, y, z, 0, 4);
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister par1IconRegister){
public void registerBlockIcons(IIconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName());
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta){
public IIcon getIcon(int p_149691_1_, int meta) {
return this.blockIcon;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCandle();
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random p_149734_5_){
if(this == unlitBlock())
return;
TileCandle tile = (TileCandle) world.getTileEntity(x, y, z);
if(tile.variant == 1){
if(tile.rotation % 2 == 0){
world.spawnParticle("smoke", x + 0.5f, y + 0.66f, z + 0.13f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.5f, y + 0.65f, z + 0.13f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.5f, y + 0.66f, z + 0.87f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.5f, y + 0.65f, z + 0.87f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.13f, y + 0.66f, z + 0.5f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.13f, y + 0.65f, z + 0.5f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.87f, y + 0.66f, z + 0.5f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.87f, y + 0.65f, z + 0.5f, 0.0D, 0.0D, 0.0D);
}
else{
world.spawnParticle("smoke", x + 0.24f, y + 0.66f, z + 0.24f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.24f, y + 0.65f, z + 0.24f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.76f, y + 0.66f, z + 0.76f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.76f, y + 0.65f, z + 0.76f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.24f, y + 0.66f, z + 0.76f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.24f, y + 0.65f, z + 0.76f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.76f, y + 0.66f, z + 0.24f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.76f, y + 0.65f, z + 0.24f, 0.0D, 0.0D, 0.0D);
}
}
else{
float xOffset = 0.5f, yOffset = 0.45f, zOffset = 0.5f;
if(tile.variant == 2){
yOffset = 1.05f;
if(tile.rotation == 0)
zOffset += 0.12f;
if(tile.rotation == 4)
zOffset -= 0.12f;
if(tile.rotation == 6)
xOffset += 0.12f;
if(tile.rotation == 2)
xOffset -= 0.12f;
}
double d0 = (double)((float)x + xOffset);
double d1 = (double)((float)y + yOffset);
double d2 = (double)((float)z + zOffset);
world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCandle();
}
@Override
public Block unlitBlock() {
return CustomItems.candle_unlit;
}
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random p_149734_5_) {
if (this == unlitBlock())
return;
TileCandle tile = (TileCandle) world.getTileEntity(x, y, z);
@Override
public Block litBlock() {
return CustomItems.candle;
}
if (tile.variant == 1) {
if (tile.rotation % 2 == 0) {
world.spawnParticle("smoke", x + 0.5f, y + 0.66f, z + 0.13f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.5f, y + 0.65f, z + 0.13f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.5f, y + 0.66f, z + 0.87f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.5f, y + 0.65f, z + 0.87f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.13f, y + 0.66f, z + 0.5f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.13f, y + 0.65f, z + 0.5f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.87f, y + 0.66f, z + 0.5f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.87f, y + 0.65f, z + 0.5f, 0.0D, 0.0D, 0.0D);
} else {
world.spawnParticle("smoke", x + 0.24f, y + 0.66f, z + 0.24f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.24f, y + 0.65f, z + 0.24f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.76f, y + 0.66f, z + 0.76f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.76f, y + 0.65f, z + 0.76f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.24f, y + 0.66f, z + 0.76f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.24f, y + 0.65f, z + 0.76f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", x + 0.76f, y + 0.66f, z + 0.24f, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", x + 0.76f, y + 0.65f, z + 0.24f, 0.0D, 0.0D, 0.0D);
}
} else {
float xOffset = 0.5f, yOffset = 0.45f, zOffset = 0.5f;
if (tile.variant == 2) {
yOffset = 1.05f;
if (tile.rotation == 0)
zOffset += 0.12f;
if (tile.rotation == 4)
zOffset -= 0.12f;
if (tile.rotation == 6)
xOffset += 0.12f;
if (tile.rotation == 2)
xOffset -= 0.12f;
}
double d0 = (double) ((float) x + xOffset);
double d1 = (double) ((float) y + yOffset);
double d2 = (double) ((float) z + zOffset);
world.spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
}
@Override
public Block unlitBlock() {
return CustomItems.candle_unlit;
}
@Override
public Block litBlock() {
return CustomItems.candle;
}
}
@@ -22,42 +22,38 @@ import noppes.npcs.constants.EnumGuiType;
import java.util.List;
public class BlockCarpentryBench extends BlockContainer
{
public int renderId = -1;
public BlockCarpentryBench()
{
public class BlockCarpentryBench extends BlockContainer {
public int renderId = -1;
public BlockCarpentryBench() {
super(Material.rock);
setStepSound(soundTypePiston);
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z)
{
public int getLightValue(IBlockAccess world, int x, int y, int z) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (block != this)
{
if (block != this) {
return block.getLightValue(world, x, y, z);
}
if(meta >= 4)
if (meta >= 4)
return 5;
return getLightValue();
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9)
{
if(!par1World.isRemote){
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (!par1World.isRemote) {
int meta = par1World.getBlockMetadata(i, j, k);
if(meta >= 4){
if (meta >= 4) {
player.openGui(CustomNpcs.instance, EnumGuiType.PlayerAnvil.ordinal(), par1World, i, j, k);
} else {
player.openGui(CustomNpcs.instance, EnumGuiType.PlayerCarpentryBench.ordinal(), par1World, i, j, k);
}
}
return true;
}
return true;
}
@Override
@@ -71,6 +67,7 @@ public class BlockCarpentryBench extends BlockContainer
{
return renderId;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
@@ -82,35 +79,32 @@ public class BlockCarpentryBench extends BlockContainer
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
if(meta >= 4){
public IIcon getIcon(int side, int meta) {
if (meta >= 4) {
return Blocks.anvil.getIcon(side, 0);
}
return Blocks.planks.getIcon(side, 0);
}
@Override
public int damageDropped(int par1)
{
return par1/4;
public int damageDropped(int par1) {
return par1 / 4;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item)
{
int var6 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3;
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLiving, ItemStack item) {
int var6 = MathHelper.floor_double((double) (par5EntityLiving.rotationYaw / 90.0F) + 0.5D) & 3;
par1World.setBlockMetadataWithNotify(par2, par3, par4, var6 + item.getItemDamage() * 4, 2);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBlockAnvil();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileBlockAnvil();
}
}
@@ -19,17 +19,17 @@ import noppes.npcs.items.ItemNpcTool;
import java.util.List;
public class BlockChair extends BlockRotated{
public class BlockChair extends BlockRotated {
public BlockChair() {
public BlockChair() {
super(Blocks.planks);
setBlockBounds(0.1f, 0, 0.1f, 0.9f, 1, 0.9f);
}
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
@@ -37,7 +37,7 @@ public class BlockChair extends BlockRotated{
if (te instanceof TileChair && ((TileChair) te).isPushed()) {
// Use the rotation to set a vertical slab hitbox on the pushed side.
int rotation = ((TileVariant) te).rotation;
switch(rotation) {
switch (rotation) {
case 0: // North: slab from z to z+0.3.
return AxisAlignedBB.getBoundingBox(x + 0.1, y, z, x + 0.9, y + 1, z + 0.3);
case 1: // East: slab from x+0.7 to x+1.
@@ -88,10 +88,8 @@ public class BlockChair extends BlockRotated{
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
@@ -101,19 +99,19 @@ public class BlockChair extends BlockRotated{
}
@Override
public int damageDropped(int par1){
public int damageDropped(int par1) {
return par1;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileChair();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileChair();
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_){
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) {
ItemStack item = player.inventory.getCurrentItem();
if(item != null && item.getItem() != null && item.getItem() instanceof ItemNpcTool)
if (item != null && item.getItem() != null && item.getItem() instanceof ItemNpcTool)
return false;
return MountBlock(world, x, y, z, player);
@@ -21,23 +21,24 @@ import noppes.npcs.blocks.tiles.TileCouchWood;
import java.util.List;
public class BlockCouchWood extends BlockContainer{
public class BlockCouchWood extends BlockContainer {
public int renderId = -1;
public int renderId = -1;
public BlockCouchWood() {
super(Material.wood);
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
ItemStack item = player.inventory.getCurrentItem();
if(item == null)
return BlockChair.MountBlock(par1World, i, j, k, player);
return true;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack item = player.inventory.getCurrentItem();
if (item == null)
return BlockChair.MountBlock(par1World, i, j, k, player);
return true;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
@@ -47,104 +48,101 @@ public class BlockCouchWood extends BlockContainer{
}
@Override
public int damageDropped(int par1)
{
public int damageDropped(int par1) {
return par1;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z){
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z) {
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 0.5, z + 1);
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
TileCouchWood tile = (TileCouchWood) par1World.getTileEntity(par2, par3, par4);
tile.rotation = l;
tile.rotation = l;
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
updateModel(par1World, par2, par3, par4, tile);
updateModel(par1World, par2, par3, par4, tile);
onNeighborBlockChange(par1World, par2 + 1, par3, par4, this);
onNeighborBlockChange(par1World, par2 - 1, par3, par4, this);
onNeighborBlockChange(par1World, par2, par3, par4 + 1, this);
onNeighborBlockChange(par1World, par2, par3, par4 - 1, this);
updateModel(par1World, par2, par3, par4, tile);
updateModel(par1World, par2, par3, par4, tile);
par1World.markBlockForUpdate(par2, par3, par4);
}
@Override
public void onNeighborBlockChange(World worldObj, int x, int y, int z, Block block) {
if(worldObj.isRemote || block != this)
return;
TileEntity tile = worldObj.getTileEntity(x, y, z);
if(tile == null || !(tile instanceof TileCouchWood))
return;
updateModel(worldObj, x, y, z, (TileCouchWood) tile);
worldObj.markBlockForUpdate(x, y, z);
if (worldObj.isRemote || block != this)
return;
TileEntity tile = worldObj.getTileEntity(x, y, z);
if (tile == null || !(tile instanceof TileCouchWood))
return;
updateModel(worldObj, x, y, z, (TileCouchWood) tile);
worldObj.markBlockForUpdate(x, y, z);
}
private void updateModel(World world, int x, int y, int z, TileCouchWood tile){
if(world.isRemote)
return;
int meta = tile.getBlockMetadata();
if(tile.rotation == 0){
tile.hasLeft = compareTiles(tile, x - 1, y, z, world, meta);
tile.hasRight = compareTiles(tile, x + 1, y, z, world, meta);
}
else if(tile.rotation == 2){
tile.hasLeft = compareTiles(tile, x + 1, y, z, world, meta);
tile.hasRight = compareTiles(tile, x - 1, y, z, world, meta);
}
else if(tile.rotation == 1){
tile.hasLeft = compareTiles(tile, x, y, z - 1, world, meta);
tile.hasRight = compareTiles(tile, x, y, z + 1, world, meta);
}
else if(tile.rotation == 3){
tile.hasLeft = compareTiles(tile, x, y, z + 1, world, meta);
tile.hasRight = compareTiles(tile, x, y, z - 1, world, meta);
}
private void updateModel(World world, int x, int y, int z, TileCouchWood tile) {
if (world.isRemote)
return;
int meta = tile.getBlockMetadata();
if (tile.rotation == 0) {
tile.hasLeft = compareTiles(tile, x - 1, y, z, world, meta);
tile.hasRight = compareTiles(tile, x + 1, y, z, world, meta);
} else if (tile.rotation == 2) {
tile.hasLeft = compareTiles(tile, x + 1, y, z, world, meta);
tile.hasRight = compareTiles(tile, x - 1, y, z, world, meta);
} else if (tile.rotation == 1) {
tile.hasLeft = compareTiles(tile, x, y, z - 1, world, meta);
tile.hasRight = compareTiles(tile, x, y, z + 1, world, meta);
} else if (tile.rotation == 3) {
tile.hasLeft = compareTiles(tile, x, y, z + 1, world, meta);
tile.hasRight = compareTiles(tile, x, y, z - 1, world, meta);
}
}
private boolean compareTiles(TileCouchWood tile, int x, int y, int z, World world, int meta){
int meta2 = world.getBlockMetadata(x, y, z);
if(meta2 != meta)
return false;
TileEntity tile2 = world.getTileEntity(x, y, z);
if(tile2 == null || !(tile2 instanceof TileCouchWood))
return false;
TileCouchWood couch = (TileCouchWood) tile2;
return tile.rotation == couch.rotation;
private boolean compareTiles(TileCouchWood tile, int x, int y, int z, World world, int meta) {
int meta2 = world.getBlockMetadata(x, y, z);
if (meta2 != meta)
return false;
TileEntity tile2 = world.getTileEntity(x, y, z);
if (tile2 == null || !(tile2 instanceof TileCouchWood))
return false;
TileCouchWood couch = (TileCouchWood) tile2;
return tile.rotation == couch.rotation;
}
@Override
public boolean isOpaqueCube(){
return false;
}
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock(){
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType(){
return renderId;
}
public int getRenderType() {
return renderId;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
public void registerBlockIcons(IIconRegister par1IconRegister) {
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta)
{
public IIcon getIcon(int p_149691_1_, int meta) {
return Blocks.planks.getIcon(p_149691_1_, meta);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCouchWood();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCouchWood();
}
}
@@ -31,35 +31,36 @@ import static noppes.npcs.items.ItemNpcTool.BRUSH_COLOR_TAG;
public class BlockCouchWool extends BlockContainer {
public int renderId = -1;
public int renderId = -1;
public BlockCouchWool() {
super(Material.wood);
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
ItemStack item = player.inventory.getCurrentItem();
TileColorable.ColorChangeType colorChangeType = TileColorable.allowColorChange(item);
if(colorChangeType == TileColorable.ColorChangeType.NONE)
return BlockChair.MountBlock(par1World, i, j, k, player);
else if(colorChangeType == TileColorable.ColorChangeType.PAINTBRUSH)
return false;
int meta = par1World.getBlockMetadata(i, j, k);
if(meta >= 7)
j--;
TileColorable tile = (TileColorable) par1World.getTileEntity(i, j, k);
int color = colorTableInts[BlockColored.func_150031_c(item.getItemDamage())];
if(tile.color != color){
NoppesUtilServer.consumeItemStack(1, player);
tile.color = color;
par1World.markBlockForUpdate(i, j, k);
}
return true;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
ItemStack item = player.inventory.getCurrentItem();
TileColorable.ColorChangeType colorChangeType = TileColorable.allowColorChange(item);
if (colorChangeType == TileColorable.ColorChangeType.NONE)
return BlockChair.MountBlock(par1World, i, j, k, player);
else if (colorChangeType == TileColorable.ColorChangeType.PAINTBRUSH)
return false;
int meta = par1World.getBlockMetadata(i, j, k);
if (meta >= 7)
j--;
TileColorable tile = (TileColorable) par1World.getTileEntity(i, j, k);
int color = colorTableInts[BlockColored.func_150031_c(item.getItemDamage())];
if (tile.color != color) {
NoppesUtilServer.consumeItemStack(1, player);
tile.color = color;
par1World.markBlockForUpdate(i, j, k);
}
return true;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
@@ -69,134 +70,132 @@ public class BlockCouchWool extends BlockContainer {
}
@Override
public int damageDropped(int par1)
{
public int damageDropped(int par1) {
return par1;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z){
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z) {
return AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 0.5, z + 1);
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack itemStack)
{
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack itemStack) {
int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
TileCouchWool tile = (TileCouchWool) par1World.getTileEntity(par2, par3, par4);
tile.rotation = l;
tile.color = colorTableInts[15 - itemStack.getItemDamage()];
if(itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)){
if (itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey(BRUSH_COLOR_TAG)) {
tile.color = itemStack.getTagCompound().getInteger(BRUSH_COLOR_TAG);
}
par1World.setBlockMetadataWithNotify(par2, par3, par4, itemStack.getItemDamage(), 2);
updateModel(par1World, par2, par3, par4, tile);
updateModel(par1World, par2, par3, par4, tile);
onNeighborBlockChange(par1World, par2 + 1, par3, par4, this);
onNeighborBlockChange(par1World, par2 - 1, par3, par4, this);
onNeighborBlockChange(par1World, par2, par3, par4 + 1, this);
onNeighborBlockChange(par1World, par2, par3, par4 - 1, this);
updateModel(par1World, par2, par3, par4, tile);
updateModel(par1World, par2, par3, par4, tile);
par1World.markBlockForUpdate(par2, par3, par4);
}
@Override
public void onNeighborBlockChange(World worldObj, int x, int y, int z, Block block) {
if(worldObj.isRemote || block != this)
return;
TileEntity tile = worldObj.getTileEntity(x, y, z);
if(tile == null || !(tile instanceof TileCouchWool))
return;
updateModel(worldObj, x, y, z, (TileCouchWool) tile);
worldObj.markBlockForUpdate(x, y, z);
if (worldObj.isRemote || block != this)
return;
TileEntity tile = worldObj.getTileEntity(x, y, z);
if (tile == null || !(tile instanceof TileCouchWool))
return;
updateModel(worldObj, x, y, z, (TileCouchWool) tile);
worldObj.markBlockForUpdate(x, y, z);
}
private void updateModel(World world, int x, int y, int z, TileCouchWool tile){
if(world.isRemote)
return;
int meta = tile.getBlockMetadata();
if(tile.rotation == 0){
tile.hasCornerLeft = compareCornerTiles(tile, x, y, z - 1, world, meta, true);
tile.hasCornerRight = compareCornerTiles(tile, x, y, z - 1, world, meta, false);
tile.hasLeft = compareTiles(tile, x - 1, y, z, world, meta);
tile.hasRight = compareTiles(tile, x + 1, y, z, world, meta);
}
else if(tile.rotation == 2){
tile.hasCornerLeft = compareCornerTiles(tile, x, y, z + 1, world, meta, true);
tile.hasCornerRight = compareCornerTiles(tile, x, y, z + 1, world, meta, false);
tile.hasLeft = compareTiles(tile, x + 1, y, z, world, meta);
tile.hasRight = compareTiles(tile, x - 1, y, z, world, meta);
}
else if(tile.rotation == 1){
tile.hasCornerLeft = compareCornerTiles(tile, x + 1, y, z, world, meta, true);
tile.hasCornerRight = compareCornerTiles(tile, x + 1, y, z, world, meta, false);
tile.hasLeft = compareTiles(tile, x, y, z - 1, world, meta);
tile.hasRight = compareTiles(tile, x, y, z + 1, world, meta);
}
else if(tile.rotation == 3){
tile.hasCornerLeft = compareCornerTiles(tile, x - 1, y, z, world, meta, true);
tile.hasCornerRight = compareCornerTiles(tile, x - 1, y, z, world, meta, false);
tile.hasLeft = compareTiles(tile, x, y, z + 1, world, meta);
tile.hasRight = compareTiles(tile, x, y, z - 1, world, meta);
}
private void updateModel(World world, int x, int y, int z, TileCouchWool tile) {
if (world.isRemote)
return;
int meta = tile.getBlockMetadata();
if (tile.rotation == 0) {
tile.hasCornerLeft = compareCornerTiles(tile, x, y, z - 1, world, meta, true);
tile.hasCornerRight = compareCornerTiles(tile, x, y, z - 1, world, meta, false);
tile.hasLeft = compareTiles(tile, x - 1, y, z, world, meta);
tile.hasRight = compareTiles(tile, x + 1, y, z, world, meta);
} else if (tile.rotation == 2) {
tile.hasCornerLeft = compareCornerTiles(tile, x, y, z + 1, world, meta, true);
tile.hasCornerRight = compareCornerTiles(tile, x, y, z + 1, world, meta, false);
tile.hasLeft = compareTiles(tile, x + 1, y, z, world, meta);
tile.hasRight = compareTiles(tile, x - 1, y, z, world, meta);
} else if (tile.rotation == 1) {
tile.hasCornerLeft = compareCornerTiles(tile, x + 1, y, z, world, meta, true);
tile.hasCornerRight = compareCornerTiles(tile, x + 1, y, z, world, meta, false);
tile.hasLeft = compareTiles(tile, x, y, z - 1, world, meta);
tile.hasRight = compareTiles(tile, x, y, z + 1, world, meta);
} else if (tile.rotation == 3) {
tile.hasCornerLeft = compareCornerTiles(tile, x - 1, y, z, world, meta, true);
tile.hasCornerRight = compareCornerTiles(tile, x - 1, y, z, world, meta, false);
tile.hasLeft = compareTiles(tile, x, y, z + 1, world, meta);
tile.hasRight = compareTiles(tile, x, y, z - 1, world, meta);
}
}
private boolean compareCornerTiles(TileCouchWool tile, int x, int y, int z, World world, int meta, boolean isLeft){
int meta2 = world.getBlockMetadata(x, y, z);
private boolean compareCornerTiles(TileCouchWool tile, int x, int y, int z, World world, int meta, boolean isLeft) {
int meta2 = world.getBlockMetadata(x, y, z);
// if(meta2 != meta)
// return false;
TileEntity tile2 = world.getTileEntity(x , y, z);
int rotation = (tile.rotation + (!isLeft?1:3)) % 4;
return tile2 != null & tile2 instanceof TileCouchWool && ((TileCouchWool)tile2).rotation == rotation;
TileEntity tile2 = world.getTileEntity(x, y, z);
int rotation = (tile.rotation + (!isLeft ? 1 : 3)) % 4;
return tile2 != null & tile2 instanceof TileCouchWool && ((TileCouchWool) tile2).rotation == rotation;
}
private boolean compareTiles(TileCouchWool tile, int x, int y, int z, World world, int meta){
int meta2 = world.getBlockMetadata(x, y, z);
private boolean compareTiles(TileCouchWool tile, int x, int y, int z, World world, int meta) {
int meta2 = world.getBlockMetadata(x, y, z);
// if(meta2 != meta)
// return false;
TileEntity tile2 = world.getTileEntity(x, y, z);
if(tile2 == null || !(tile2 instanceof TileCouchWool))
return false;
TileCouchWool couch = (TileCouchWool) tile2;
int rotation = couch.rotation;
if(tile.rotation == rotation)
return true;
if(couch.hasCornerLeft)
rotation += 3;
else if(couch.hasCornerRight)
rotation += 1;
rotation %= 4;
return tile.rotation == rotation;
TileEntity tile2 = world.getTileEntity(x, y, z);
if (tile2 == null || !(tile2 instanceof TileCouchWool))
return false;
TileCouchWool couch = (TileCouchWool) tile2;
int rotation = couch.rotation;
if (tile.rotation == rotation)
return true;
if (couch.hasCornerLeft)
rotation += 3;
else if (couch.hasCornerRight)
rotation += 1;
rotation %= 4;
return tile.rotation == rotation;
}
@Override
public boolean isOpaqueCube(){
return false;
}
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock(){
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType(){
return renderId;
}
public int getRenderType() {
return renderId;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
public void registerBlockIcons(IIconRegister par1IconRegister) {
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta)
{
public IIcon getIcon(int p_149691_1_, int meta) {
return Blocks.planks.getIcon(p_149691_1_, meta);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCouchWool();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCouchWool();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z) {
@@ -16,23 +16,25 @@ import noppes.npcs.constants.EnumGuiType;
import java.util.List;
public class BlockCrate extends BlockRotated{
public class BlockCrate extends BlockRotated {
public BlockCrate() {
public BlockCrate() {
super(Blocks.planks);
//setBlockBounds(0f, 0, 0f, 1f, 0.75f, 1f);
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
if(par1World.isRemote)
return true;
par1World.playSoundEffect(i, j + 0.5D, k, "random.chestopen", 0.5F, par1World.rand.nextFloat() * 0.1F + 0.9F);
player.openGui(CustomNpcs.instance, EnumGuiType.Crate.ordinal(), par1World, i, j, k);
return true;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (par1World.isRemote)
return true;
par1World.playSoundEffect(i, j + 0.5D, k, "random.chestopen", 0.5F, par1World.rand.nextFloat() * 0.1F + 0.9F);
player.openGui(CustomNpcs.instance, EnumGuiType.Crate.ordinal(), par1World, i, j, k);
return true;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
@@ -41,28 +43,28 @@ public class BlockCrate extends BlockRotated{
par3List.add(new ItemStack(par1, 1, 5));
}
@Override
public int damageDropped(int par1){
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCrate();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileCrate();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_){
TileNpcContainer tile = (TileNpcContainer)world.getTileEntity(x, y, z);
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) {
TileNpcContainer tile = (TileNpcContainer) world.getTileEntity(x, y, z);
if (tile == null)
return;
return;
tile.dropItems(world, x, y, z);
world.func_147453_f(x, y, z, block);
@@ -12,58 +12,59 @@ import net.minecraft.world.IBlockAccess;
import java.util.List;
public class BlockCrystal extends BlockBreakable{
public BlockCrystal() {
super("customnpcs:npcCrystal",Material.glass, false);
setLightLevel(0.8f);
}
public class BlockCrystal extends BlockBreakable {
public BlockCrystal() {
super("customnpcs:npcCrystal", Material.glass, false);
setLightLevel(0.8f);
}
@Override
public boolean isOpaqueCube(){
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock(){
return false;
}
@Override
public int getRenderBlockPass(){
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderBlockPass() {
return 1;
}
@Override
public int damageDropped(int meta){
public int damageDropped(int meta) {
return meta;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item item, CreativeTabs tab, List list){
for (int i = 0; i < 16; ++i){
list.add(new ItemStack(item, 1, i));
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
for (int i = 0; i < 16; ++i) {
list.add(new ItemStack(item, 1, i));
}
}
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess world, int x, int y, int z){
public int colorMultiplier(IBlockAccess world, int x, int y, int z) {
return getRenderColor(world.getBlockMetadata(x, y, z));
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderColor(int meta){
public int getRenderColor(int meta) {
return MapColor.getMapColorForBlockColored(meta).colorValue;
}
public MapColor getMapColor(int p_149728_1_){
public MapColor getMapColor(int p_149728_1_) {
return MapColor.getMapColorForBlockColored(p_149728_1_);
}
@Override
public String getUnlocalizedName(){
return "item.npcCrystal";
@Override
public String getUnlocalizedName() {
return "item.npcCrystal";
}
}
@@ -13,95 +13,94 @@ import noppes.npcs.CustomItems;
import noppes.npcs.blocks.tiles.TileLamp;
import noppes.npcs.blocks.tiles.TileVariant;
public class BlockLantern extends BlockLightable{
public class BlockLantern extends BlockLightable {
public BlockLantern(boolean lit) {
public BlockLantern(boolean lit) {
super(Blocks.iron_block, lit);
setBlockBounds(0.3f, 0, 0.3f, 0.7f, 0.6f, 0.7f);
}
@Override
public int maxRotation(){
return 8;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
TileEntity tileentity = world.getTileEntity(x, y, z);
if(!(tileentity instanceof TileVariant)){
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
if(tile.variant == 2){
float xOffset = 0;
float yOffset = 0;
if(tile.rotation == 0)
yOffset = 0.2f;
else if(tile.rotation == 4)
yOffset = -0.2f;
else if(tile.rotation == 6)
xOffset = 0.2f;
else if(tile.rotation == 2)
xOffset = -0.2f;
public int maxRotation() {
return 8;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntity tileentity = world.getTileEntity(x, y, z);
if (!(tileentity instanceof TileVariant)) {
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
if (tile.variant == 2) {
float xOffset = 0;
float yOffset = 0;
if (tile.rotation == 0)
yOffset = 0.2f;
else if (tile.rotation == 4)
yOffset = -0.2f;
else if (tile.rotation == 6)
xOffset = 0.2f;
else if (tile.rotation == 2)
xOffset = -0.2f;
setBlockBounds(0.3f + xOffset, 0.2f, 0.3f + yOffset, 0.7f + xOffset, 0.7f, 0.7f + yOffset);
}
else
} else
setBlockBounds(0.3f, 0, 0.3f, 0.7f, 0.6f, 0.7f);
}
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta){
public int onBlockPlaced(World world, int x, int y, int z, int side, float p_149660_6_, float p_149660_7_, float p_149660_8_, int meta) {
return side;
}
@Override
public void onPostBlockPlaced(World world, int x, int y, int z, int meta) {
TileLamp tile = (TileLamp) world.getTileEntity(x, y, z);
if(meta == 1)
tile.variant = 0;
else if(meta == 0)
tile.variant = 1;
else{
tile.variant = 2;
if(meta == 2)
tile.rotation = 0;
else if(meta == 3)
tile.rotation = 4;
else if(meta == 4)
tile.rotation = 6;
else if(meta == 5)
tile.rotation = 2;
}
world.setBlockMetadataWithNotify(x, y, z, 0, 4);
TileLamp tile = (TileLamp) world.getTileEntity(x, y, z);
if (meta == 1)
tile.variant = 0;
else if (meta == 0)
tile.variant = 1;
else {
tile.variant = 2;
if (meta == 2)
tile.rotation = 0;
else if (meta == 3)
tile.rotation = 4;
else if (meta == 4)
tile.rotation = 6;
else if (meta == 5)
tile.rotation = 2;
}
world.setBlockMetadataWithNotify(x, y, z, 0, 4);
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister par1IconRegister){
public void registerBlockIcons(IIconRegister par1IconRegister) {
this.blockIcon = par1IconRegister.registerIcon(this.getTextureName());
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta){
public IIcon getIcon(int p_149691_1_, int meta) {
return this.blockIcon;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileLamp();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileLamp();
}
@Override
public Block unlitBlock() {
return CustomItems.lantern_unlit;
}
@Override
public Block unlitBlock() {
return CustomItems.lantern_unlit;
}
@Override
public Block litBlock() {
return CustomItems.lantern;
}
@Override
public Block litBlock() {
return CustomItems.lantern;
}
}
@@ -14,19 +14,20 @@ import java.util.Random;
public abstract class BlockLightable extends BlockRotated {
protected BlockLightable(Block block, boolean lit) {
super(block);
protected BlockLightable(Block block, boolean lit) {
super(block);
if (lit)
this.setLightLevel(1.0F);
}
}
public abstract Block unlitBlock();
public abstract Block litBlock();
public abstract Block unlitBlock();
public abstract Block litBlock();
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
// Get the current tile entity and store its NBT
TileEntity oldTile = world.getTileEntity(x, y, z);
NBTTagCompound compound = new NBTTagCompound();
@@ -41,7 +42,7 @@ public abstract class BlockLightable extends BlockRotated {
// Get the new tile and load the stored NBT
TileEntity newTile = world.getTileEntity(x, y, z);
if(newTile != null){
if (newTile != null) {
newTile.readFromNBT(compound);
newTile.markDirty();
}
@@ -53,18 +54,18 @@ public abstract class BlockLightable extends BlockRotated {
}
@Override
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_){
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
return Item.getItemFromBlock(litBlock());
}
@Override
@SideOnly(Side.CLIENT)
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_){
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) {
return Item.getItemFromBlock(litBlock());
}
@Override
protected ItemStack createStackedBlock(int p_149644_1_){
protected ItemStack createStackedBlock(int p_149644_1_) {
return new ItemStack(litBlock());
}
@@ -23,32 +23,30 @@ import noppes.npcs.constants.EnumGuiType;
import java.util.ArrayList;
import java.util.List;
public class BlockMailbox extends BlockContainer{
public class BlockMailbox extends BlockContainer {
public int renderId = -1;
public int renderId = -1;
public BlockMailbox() {
public BlockMailbox() {
super(Material.iron);
}
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
if(!par1World.isRemote){
GuiOpenPacket.openGUI((EntityPlayerMP)player, EnumGuiType.PlayerMailbox, i, j, k);
}
return true;
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (!par1World.isRemote) {
GuiOpenPacket.openGUI((EntityPlayerMP) player, EnumGuiType.PlayerMailbox, i, j, k);
}
return true;
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune)
{
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
int damage = this.getDamageValue(world, x, y, z);
ret.add(new ItemStack(this, 1, damage));
@@ -56,48 +54,46 @@ public class BlockMailbox extends BlockContainer{
}
@Override
public int damageDropped(int par1)
{
public int damageDropped(int par1) {
return par1 >> 2;
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)
{
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
l %= 4;
par1World.setBlockMetadataWithNotify(par2, par3, par4, l | par6ItemStack.getItemDamage() << 2, 2);
}
@Override
public boolean isOpaqueCube(){
return false;
}
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock(){
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType(){
return renderId;
}
public int getRenderType() {
return renderId;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
public void registerBlockIcons(IIconRegister par1IconRegister) {
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int p_149691_2_)
{
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
return Blocks.soul_sand.getBlockTextureFromSide(p_149691_1_);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileMailbox();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileMailbox();
}
}
@@ -18,28 +18,28 @@ import noppes.npcs.CustomNpcsPermissions;
import noppes.npcs.blocks.tiles.TileRedstoneBlock;
import noppes.npcs.constants.EnumGuiType;
public class BlockNpcRedstone extends BlockContainer{
public BlockNpcRedstone(){
public class BlockNpcRedstone extends BlockContainer {
public BlockNpcRedstone() {
super(Material.rock);
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9){
if(par1World.isRemote)
return false;
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_REDSTONE)) {
TileEntity tile = par1World.getTileEntity(i, j, k);
NBTTagCompound compound = new NBTTagCompound();
tile.writeToNBT(compound);
PacketHandler.Instance.sendToPlayer(new GuiRedstonePacket(compound), (EntityPlayerMP)player);
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (par1World.isRemote)
return false;
ItemStack currentItem = player.inventory.getCurrentItem();
if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, CustomNpcsPermissions.EDIT_REDSTONE)) {
TileEntity tile = par1World.getTileEntity(i, j, k);
NBTTagCompound compound = new NBTTagCompound();
tile.writeToNBT(compound);
PacketHandler.Instance.sendToPlayer(new GuiRedstonePacket(compound), (EntityPlayerMP) player);
return true;
}
return false;
}
return false;
}
@Override
public void onBlockAdded(World par1World, int par2, int par3, int par4){
public void onBlockAdded(World par1World, int par2, int par3, int par4) {
par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this);
par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this);
par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this);
@@ -50,46 +50,46 @@ public class BlockNpcRedstone extends BlockContainer{
}
@Override
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack item){
if(entityliving instanceof EntityPlayer && world.isRemote){
CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.RedstoneBlock, (EntityPlayer) entityliving);
}
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack item) {
if (entityliving instanceof EntityPlayer && world.isRemote) {
CustomNpcs.proxy.openGui(i, j, k, EnumGuiType.RedstoneBlock, (EntityPlayer) entityliving);
}
}
@Override
public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5) {
onBlockAdded(par1World, par2, par3, par4);
onBlockAdded(par1World, par2, par3, par4);
}
@Override
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4){
if(isActivated(par1IBlockAccess, par2, par3, par4) > 0)
return 0xFF6B68;
else
return super.colorMultiplier(par1IBlockAccess, par2, par3, par4);
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
if (isActivated(par1IBlockAccess, par2, par3, par4) > 0)
return 0xFF6B68;
else
return super.colorMultiplier(par1IBlockAccess, par2, par3, par4);
}
@Override
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5){
public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) {
return isActivated(par1IBlockAccess, par2, par3, par4);
}
@Override
public int isProvidingStrongPower(IBlockAccess par1World, int par2, int par3, int par4, int par5){
public int isProvidingStrongPower(IBlockAccess par1World, int par2, int par3, int par4, int par5) {
return isActivated(par1World, par2, par3, par4);
}
@Override
public boolean canProvidePower(){
public boolean canProvidePower() {
return true;
}
public int isActivated(IBlockAccess par1IBlockAccess, int par2, int par3, int par4){
return par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 1?15 : 0;
}
public int isActivated(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) {
return par1IBlockAccess.getBlockMetadata(par2, par3, par4) == 1 ? 15 : 0;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileRedstoneBlock();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileRedstoneBlock();
}
}
@@ -20,40 +20,39 @@ import noppes.npcs.blocks.tiles.TileVariant;
import java.util.List;
public class BlockPedestal extends BlockTrigger{
public class BlockPedestal extends BlockTrigger {
public BlockPedestal() {
public BlockPedestal() {
super(Blocks.stone);
}
@Override
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
if(par1World.isRemote)
return true;
TilePedestal tile = (TilePedestal) par1World.getTileEntity(i, j, k);
ItemStack item = player.getCurrentEquippedItem();
ItemStack weapon = tile.getStackInSlot(0);
if(item == null && weapon != null){
tile.setInventorySlotContents(0, null);
player.inventory.setInventorySlotContents(player.inventory.currentItem, weapon);
par1World.markBlockForUpdate(i, j, k);
updateSurrounding(par1World, i, j, k);
}
else if(item == null || item.getItem() == null || item.getItem() instanceof ItemBlock)
return true;
else if(item != null && weapon == null){
tile.setInventorySlotContents(0, item);
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
par1World.markBlockForUpdate(i, j, k);
updateSurrounding(par1World, i, j, k);
}
return true;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
public boolean onBlockActivated(World par1World, int i, int j, int k, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (par1World.isRemote)
return true;
TilePedestal tile = (TilePedestal) par1World.getTileEntity(i, j, k);
ItemStack item = player.getCurrentEquippedItem();
ItemStack weapon = tile.getStackInSlot(0);
if (item == null && weapon != null) {
tile.setInventorySlotContents(0, null);
player.inventory.setInventorySlotContents(player.inventory.currentItem, weapon);
par1World.markBlockForUpdate(i, j, k);
updateSurrounding(par1World, i, j, k);
} else if (item == null || item.getItem() == null || item.getItem() instanceof ItemBlock)
return true;
else if (item != null && weapon == null) {
tile.setInventorySlotContents(0, item);
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
par1World.markBlockForUpdate(i, j, k);
updateSurrounding(par1World, i, j, k);
}
return true;
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
@@ -62,58 +61,57 @@ public class BlockPedestal extends BlockTrigger{
}
@Override
public int damageDropped(int par1){
public int damageDropped(int par1) {
return par1;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
TileEntity tileentity = world.getTileEntity(x, y, z);
if(!(tileentity instanceof TileVariant)){
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
if(tile.rotation % 2 == 0){
setBlockBounds(0f, 0, 0.2f, 1, 0.5f, 0.8f );
}
else{
setBlockBounds(0.2f, 0, 0, 0.8f, 0.5f, 1 );
}
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntity tileentity = world.getTileEntity(x, y, z);
if (!(tileentity instanceof TileVariant)) {
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
if (tile.rotation % 2 == 0) {
setBlockBounds(0f, 0, 0.2f, 1, 0.5f, 0.8f);
} else {
setBlockBounds(0.2f, 0, 0, 0.8f, 0.5f, 1);
}
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta)
{
meta %= 7;
if(meta == 1)
public IIcon getIcon(int p_149691_1_, int meta) {
meta %= 7;
if (meta == 1)
return Blocks.stone.getIcon(p_149691_1_, 0);
else if(meta == 2)
else if (meta == 2)
return Blocks.iron_block.getIcon(p_149691_1_, 0);
else if(meta == 3)
else if (meta == 3)
return Blocks.gold_block.getIcon(p_149691_1_, 0);
else if(meta == 4)
else if (meta == 4)
return Blocks.diamond_block.getIcon(p_149691_1_, 0);
return Blocks.planks.getIcon(p_149691_1_, 0);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TilePedestal();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TilePedestal();
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_){
TileNpcContainer tile = (TileNpcContainer)world.getTileEntity(x, y, z);
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) {
TileNpcContainer tile = (TileNpcContainer) world.getTileEntity(x, y, z);
if (tile == null)
return;
return;
tile.dropItems(world, x, y, z);
world.func_147453_f(x, y, z, block);
@@ -14,45 +14,44 @@ import net.minecraft.world.World;
import java.util.List;
public class BlockPlaceholder extends Block{
private IIcon[] icons = new IIcon[16];
public class BlockPlaceholder extends Block {
public BlockPlaceholder() {
private IIcon[] icons = new IIcon[16];
public BlockPlaceholder() {
super(Material.rock);
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
for(int i = 0; i < 16; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public int damageDropped(int par1){
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
for (int i = 0; i < 16; i++)
par3List.add(new ItemStack(par1, 1, i));
}
@Override
public int damageDropped(int par1) {
return par1;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister){
for(int i = 0; i < 16; i++){
icons[i] = par1IconRegister.registerIcon("customnpcs:placeholder_" + i);
}
public void registerBlockIcons(IIconRegister par1IconRegister) {
for (int i = 0; i < 16; i++) {
icons[i] = par1IconRegister.registerIcon("customnpcs:placeholder_" + i);
}
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta)
{
if(meta < icons.length)
return icons[meta];
public IIcon getIcon(int p_149691_1_, int meta) {
if (meta < icons.length)
return icons[meta];
return icons[0];
}
@@ -16,59 +16,62 @@ import net.minecraftforge.common.util.ForgeDirection;
import noppes.npcs.blocks.tiles.TileVariant;
public abstract class BlockRotated extends BlockContainer {
private Block block;
protected BlockRotated(Block block) {
super(block.getMaterial());
this.block = block;
}
private Block block;
public int renderId = -1;
protected BlockRotated(Block block) {
super(block.getMaterial());
this.block = block;
}
public int renderId = -1;
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * maxRotation() / 360.0F) + 0.5D) & (maxRotation() - 1);
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * maxRotation() / 360.0F) + 0.5D) & (maxRotation() - 1);
l %= maxRotation();
TileVariant tile = (TileVariant) par1World.getTileEntity(par2, par3, par4);
tile.rotation = l;
TileVariant tile = (TileVariant) par1World.getTileEntity(par2, par3, par4);
tile.rotation = l;
}
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z){
setBlockBoundsBasedOnState(world, x, y, z);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
setBlockBoundsBasedOnState(world, x, y, z);
return super.getCollisionBoundingBoxFromPool(world, x, y, z);
}
public int maxRotation(){
return 4;
public int maxRotation() {
return 4;
}
@Override
public boolean isOpaqueCube(){
return false;
}
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean renderAsNormalBlock(){
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public int getRenderType(){
return renderId;
}
public int getRenderType() {
return renderId;
}
@Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side){
return true;
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
public void registerBlockIcons(IIconRegister par1IconRegister) {
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int p_149691_1_, int meta){
public IIcon getIcon(int p_149691_1_, int meta) {
return block.getIcon(p_149691_1_, meta);
}
@@ -45,7 +45,7 @@ public class BlockScripted extends BlockContainer {
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
if (tile != null && tile.isPassible && (tile.blockModel == null || tile.blockModel == Blocks.air))
return AABB_EMPTY;
return AABB.getOffsetBoundingBox(x,y,z);
return AABB.getOffsetBoundingBox(x, y, z);
}
@Override
@@ -53,12 +53,11 @@ public class BlockScripted extends BlockContainer {
TileScripted tile = (TileScripted) world.getTileEntity(x, y, z);
if (tile != null && tile.isPassible)
return AABB_EMPTY;
return AABB.getOffsetBoundingBox(x,y,z);
return AABB.getOffsetBoundingBox(x, y, z);
}
@Override
public boolean getBlocksMovement(IBlockAccess worldIn, int x, int y, int z)
{
public boolean getBlocksMovement(IBlockAccess worldIn, int x, int y, int z) {
TileScripted tile = (TileScripted) worldIn.getTileEntity(x, y, z);
return tile != null && tile.isPassible;
}
@@ -118,6 +117,7 @@ public class BlockScripted extends BlockContainer {
public int getRenderType() {
return renderId;
}
@Override
public boolean isOpaqueCube() {
return false;
@@ -235,7 +235,7 @@ public class BlockScripted extends BlockContainer {
int power = 0;
for (EnumFacing enumfacing : EnumFacing.values()) {
int p = world.getIndirectPowerLevelTo(x + enumfacing.getFrontOffsetX(),
y + enumfacing.getFrontOffsetZ(), z + enumfacing.getFrontOffsetZ(), enumfacing.ordinal());
y + enumfacing.getFrontOffsetZ(), z + enumfacing.getFrontOffsetZ(), enumfacing.ordinal());
if (p > power)
power = p;
}
@@ -14,26 +14,26 @@ import noppes.npcs.blocks.tiles.TileVariant;
import java.util.List;
public class BlockShelf extends BlockRotated{
public class BlockShelf extends BlockRotated {
public BlockShelf() {
public BlockShelf() {
super(Blocks.planks);
}
@Override
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage() , 2);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z){
setBlockBoundsBasedOnState(p_149668_1_, x, y, z);
public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) {
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack);
par1World.setBlockMetadataWithNotify(par2, par3, par4, par6ItemStack.getItemDamage(), 2);
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World p_149668_1_, int x, int y, int z) {
setBlockBoundsBasedOnState(p_149668_1_, x, y, z);
return AxisAlignedBB.getBoundingBox(x + minX, y + 0.9f, z + minZ, x + maxX, y + 1, z + maxZ);
}
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List){
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
par3List.add(new ItemStack(par1, 1, 0));
par3List.add(new ItemStack(par1, 1, 1));
par3List.add(new ItemStack(par1, 1, 2));
@@ -41,37 +41,38 @@ public class BlockShelf extends BlockRotated{
par3List.add(new ItemStack(par1, 1, 4));
par3List.add(new ItemStack(par1, 1, 5));
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z){
TileEntity tileentity = world.getTileEntity(x, y, z);
if(!(tileentity instanceof TileVariant)){
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
float xStart = 0;
float zStart = 0;
float xEnd = 1;
float zEnd = 1;
if(tile.rotation == 0)
zStart = 0.3f;
else if(tile.rotation == 2)
zEnd = 0.7f;
else if(tile.rotation == 3)
xStart = 0.3f;
else if(tile.rotation == 1)
xEnd = 0.7f;
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
TileEntity tileentity = world.getTileEntity(x, y, z);
if (!(tileentity instanceof TileVariant)) {
super.setBlockBoundsBasedOnState(world, x, y, z);
return;
}
TileVariant tile = (TileVariant) tileentity;
float xStart = 0;
float zStart = 0;
float xEnd = 1;
float zEnd = 1;
if (tile.rotation == 0)
zStart = 0.3f;
else if (tile.rotation == 2)
zEnd = 0.7f;
else if (tile.rotation == 3)
xStart = 0.3f;
else if (tile.rotation == 1)
xEnd = 0.7f;
setBlockBounds(xStart, 0.44f, zStart, xEnd, 1, zEnd);
}
@Override
public int damageDropped(int par1){
public int damageDropped(int par1) {
return par1;
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileShelf();
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileShelf();
}
}
Loaded 100 of 1179 files, more files were not shown because too many files have changed in this diff. Show more