diff --git a/build.gradle b/build.gradle index 6f9d15cae..950b0f544 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ group= "am2" // http://maven.apache.org/guides/mini/guide-naming-conventions.htm archivesBaseName = "AM2" minecraft { - version = "1.7.10-10.13.4.1448-1.7.10" + version = "1.7.10-10.13.4.1492-1.7.10" runDir = "run" //mappings = "stable_12" //uncomment this line to use newest Forge mappings. Needs a lot of rework. } diff --git a/src/main/java/am2/AMClientEventHandler.java b/src/main/java/am2/AMClientEventHandler.java index 8d9b312e9..ed9d85a6d 100644 --- a/src/main/java/am2/AMClientEventHandler.java +++ b/src/main/java/am2/AMClientEventHandler.java @@ -259,7 +259,7 @@ public void onPlayerRender(RenderPlayerEvent.Pre event){ float shrink = ExtendedProperties.For(event.entityPlayer).getShrinkPct(); if (shrink > 0){ GL11.glPushMatrix(); - GL11.glTranslatef(0, -0.5f, 0); + GL11.glTranslatef(0, 0 - 0.5f * shrink, 0); GL11.glScalef(1 - 0.5f * shrink, 1 - 0.5f * shrink, 1 - 0.5f * shrink); } diff --git a/src/main/java/am2/AMEventHandler.java b/src/main/java/am2/AMEventHandler.java index 5eab56b57..caeb4f74c 100644 --- a/src/main/java/am2/AMEventHandler.java +++ b/src/main/java/am2/AMEventHandler.java @@ -14,7 +14,6 @@ import am2.buffs.BuffList; import am2.buffs.BuffStatModifiers; import am2.damage.DamageSources; -import am2.enchantments.EnchantmentSoulbound; import am2.entities.EntityFlicker; import am2.items.ItemsCommonProxy; import am2.network.AMNetHandler; @@ -67,12 +66,9 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import java.util.Random; public class AMEventHandler{ - private final Random rand = new Random(); - @SubscribeEvent public void onPotionBrewed(PotionBrewedEvent brewEvent){ for (ItemStack stack : brewEvent.brewingStacks){ @@ -143,7 +139,6 @@ public void onEntityConstructing(EntityConstructing event){ @SubscribeEvent(priority = EventPriority.HIGHEST) public void onEntityDeath(LivingDeathEvent event){ - String s = EnchantmentSoulbound.class.getName(); EntityLivingBase soonToBeDead = event.entityLiving; if (soonToBeDead.isPotionActive(BuffList.temporalAnchor.id)){ event.setCanceled(true); @@ -227,8 +222,6 @@ public void onEntityJump(LivingJumpEvent event){ double xVelocity = 0; double zVelocity = 0; - Random rand = new Random(); - Vec3 vec = event.entityLiving.getLookVec().normalize(); switch (event.entityLiving.getActivePotionEffect(BuffList.leap).getAmplifier() + 1){ case BuffPowerLevel.Low: @@ -246,6 +239,8 @@ public void onEntityJump(LivingJumpEvent event){ xVelocity = velocityTarget.motionX * 1.75 * Math.abs(vec.xCoord); zVelocity = velocityTarget.motionZ * 1.75 * Math.abs(vec.zCoord); break; + default: + break; } float maxHorizontalVelocity = 1.45f; @@ -325,8 +320,6 @@ public void onEntityLiving(LivingUpdateEvent event){ World world = ent.worldObj; - boolean isRemote = world.isRemote; - BuffStatModifiers.instance.applyStatModifiersBasedOnBuffs(ent); ExtendedProperties extendedProperties; @@ -337,10 +330,8 @@ public void onEntityLiving(LivingUpdateEvent event){ //archmage armor effects & infusion if (ent instanceof EntityPlayer){ - extendedProperties.overrideEyeHeight(); - if (ent.worldObj.isRemote){ - int divisor = ExtendedProperties.For(ent).getAuraDelay() > 0 ? ExtendedProperties.For(ent).getAuraDelay() : 1; + int divisor = extendedProperties.getAuraDelay() > 0 ? extendedProperties.getAuraDelay() : 1; if (ent.ticksExisted % divisor == 0) AMCore.instance.proxy.particleManager.spawnAuraParticles(ent); AMCore.proxy.setViewSettings(); @@ -401,7 +392,7 @@ public void onEntityLiving(LivingUpdateEvent event){ } } - if (extendedProperties.getContingencyType() == ContingencyTypes.FALL && !ent.onGround && extendedProperties.getContingencyEffect() != null && ent.fallDistance >= 4f){ + if (!ent.onGround && ent.fallDistance >= 4f && extendedProperties.getContingencyType() == ContingencyTypes.FALL && extendedProperties.getContingencyEffect() != null){ int distanceToGround = MathUtilities.getDistanceToGround(ent, world); if (distanceToGround < -8 * ent.motionY){ extendedProperties.procContingency(); @@ -480,6 +471,8 @@ public void onEntityLiving(LivingUpdateEvent event){ case BuffPowerLevel.High: extendedProperties.setFallProtection(45); break; + default: + break; } } @@ -491,7 +484,10 @@ public void onEntityLiving(LivingUpdateEvent event){ //slowfall/shrink buff - if (event.entityLiving.isPotionActive(BuffList.slowfall) || event.entityLiving.isPotionActive(BuffList.shrink) || (!ent.isSneaking() && ent instanceof EntityPlayer && AffinityData.For(ent).getAffinityDepth(Affinity.NATURE) == 1.0f)){ + // (isSneaking calls DataWatcher which are slow, so we test it late) + if ( event.entityLiving.isPotionActive(BuffList.slowfall) + || event.entityLiving.isPotionActive(BuffList.shrink) + || (ent instanceof EntityPlayer && AffinityData.For(ent).getAffinityDepth(Affinity.NATURE) == 1.0f && !ent.isSneaking())){ if (!event.entityLiving.onGround && event.entityLiving.motionY < 0.0D){ event.entityLiving.motionY *= 0.79999999999999998D; } @@ -569,8 +565,14 @@ public void onEntityAttacked(LivingAttackEvent event){ ExtendedProperties.For(event.entityLiving).deductMana(event.ammount * 100f); ExtendedProperties.For(event.entityLiving).forceSync(); for (int i = 0; i < Math.min(event.ammount, 5 * AMCore.config.getGFXLevel()); ++i) - AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY + rand.nextFloat() * event.entityLiving.getEyeHeight(), event.entityLiving.posZ, event.entityLiving.posX - 1 + rand.nextFloat() * 2, event.entityLiving.posY - 1 + rand.nextFloat() * 2, event.entityLiving.posZ - 1 + rand.nextFloat() * 2, 6, -1); - event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, rand.nextFloat() + 0.5f); + AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, + event.entityLiving.posX, + event.entityLiving.posY + event.entityLiving.worldObj.rand.nextFloat() * event.entityLiving.getEyeHeight(), + event.entityLiving.posZ, + event.entityLiving.posX - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, + event.entityLiving.posY - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, + event.entityLiving.posZ - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, 6, -1); + event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, event.entityLiving.worldObj.rand.nextFloat() + 0.5f); event.setCanceled(true); return; } @@ -594,22 +596,32 @@ public void onEntityHurt(LivingHurtEvent event){ ExtendedProperties.For(event.entityLiving).deductMana(manaToTake); ExtendedProperties.For(event.entityLiving).forceSync(); for (int i = 0; i < Math.min(event.ammount, 5 * AMCore.config.getGFXLevel()); ++i) - AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY + rand.nextFloat() * event.entityLiving.getEyeHeight(), event.entityLiving.posZ, event.entityLiving.posX - 1 + rand.nextFloat() * 2, event.entityLiving.posY + event.entityLiving.getEyeHeight() - 1 + rand.nextFloat() * 2, event.entityLiving.posZ - 1 + rand.nextFloat() * 2, 6, -1); - event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, rand.nextFloat() + 0.5f); + AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, + event.entityLiving.posX, + event.entityLiving.posY + event.entityLiving.worldObj.rand.nextFloat() * event.entityLiving.getEyeHeight(), + event.entityLiving.posZ, + event.entityLiving.posX - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, + event.entityLiving.posY + event.entityLiving.getEyeHeight() - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, + event.entityLiving.posZ - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, 6, -1); + event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, event.entityLiving.worldObj.rand.nextFloat() + 0.5f); if (event.ammount <= 0){ event.setCanceled(true); return; } } - if (event.source.getSourceOfDamage() instanceof EntityPlayer && ((EntityPlayer)event.source.getSourceOfDamage()).inventory.armorInventory[2] != null && ((EntityPlayer)event.source.getSourceOfDamage()).inventory.armorInventory[2].getItem() == ItemsCommonProxy.earthGuardianArmor && ((EntityPlayer)event.source.getSourceOfDamage()).getCurrentEquippedItem() == null){ + Entity entitySource = event.source.getSourceOfDamage(); + if ( entitySource instanceof EntityPlayer + && ((EntityPlayer)entitySource).inventory.armorInventory[2] != null + && ((EntityPlayer)entitySource).inventory.armorInventory[2].getItem() == ItemsCommonProxy.earthGuardianArmor + && ((EntityPlayer)entitySource).getCurrentEquippedItem() == null ){ event.ammount += 4; - double deltaZ = event.entityLiving.posZ - event.source.getSourceOfDamage().posZ; - double deltaX = event.entityLiving.posX - event.source.getSourceOfDamage().posX; + double deltaZ = event.entityLiving.posZ - entitySource.posZ; + double deltaX = event.entityLiving.posX - entitySource.posX; double angle = Math.atan2(deltaZ, deltaX); - double speed = ((EntityPlayer)event.source.getSourceOfDamage()).isSprinting() ? 3 : 2; - double vertSpeed = ((EntityPlayer)event.source.getSourceOfDamage()).isSprinting() ? 0.5 : 0.325; + double speed = ((EntityPlayer)entitySource).isSprinting() ? 3 : 2; + double vertSpeed = ((EntityPlayer)entitySource).isSprinting() ? 0.5 : 0.325; if (event.entityLiving instanceof EntityPlayer){ AMNetHandler.INSTANCE.sendVelocityAddPacket(event.entityLiving.worldObj, event.entityLiving, speed * Math.cos(angle), vertSpeed, speed * Math.sin(angle)); @@ -633,9 +645,8 @@ public void onEntityHurt(LivingHurtEvent event){ if (ent.isPotionActive(BuffList.fury.id)) event.ammount /= 2; - if (event.source.getSourceOfDamage() != null && - event.source.getSourceOfDamage() instanceof EntityLivingBase && - ((EntityLivingBase)event.source.getSourceOfDamage()).isPotionActive(BuffList.shrink)) + if ( entitySource instanceof EntityLivingBase + && ((EntityLivingBase)entitySource).isPotionActive(BuffList.shrink)) event.ammount /= 2; } @@ -663,7 +674,7 @@ public void onManaCost(ManaCostEvent event){ @SubscribeEvent public void onPlayerPickupItem(EntityItemPickupEvent event){ - if (!(event.entityPlayer instanceof EntityPlayer)) + if (event.entityPlayer == null) return; if (!event.entityPlayer.worldObj.isRemote && ExtendedProperties.For(event.entityPlayer).getMagicLevel() <= 0 && event.item.getEntityItem().getItem() == ItemsCommonProxy.arcaneCompendium){ diff --git a/src/main/java/am2/ShrinkHandler.java b/src/main/java/am2/ShrinkHandler.java index 70db30fe9..446a79f2a 100644 --- a/src/main/java/am2/ShrinkHandler.java +++ b/src/main/java/am2/ShrinkHandler.java @@ -1,60 +1,86 @@ package am2; import am2.api.math.AMVector2; +import am2.buffs.BuffList; import am2.playerextensions.ExtendedProperties; +import am2.spell.SkillManager; +import am2.spell.SkillTreeManager; import am2.utility.EntityUtilities; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.event.entity.living.LivingEvent; -import scala.collection.mutable.HashMap; public class ShrinkHandler{ - private HashMap currentSizes = new HashMap(); - private HashMap sizeModifiers = new HashMap(); - @SubscribeEvent public void onEntityLiving(LivingEvent event){ - ExtendedProperties exProps = null; - if (!(event.entityLiving instanceof EntityPlayer)) return; - EntityLivingBase ent = event.entityLiving; + + EntityPlayer player = (EntityPlayer) event.entityLiving; + + if (SkillTreeManager.instance.isSkillDisabled(SkillManager.instance.getSkill("Shrink"))) + return; + + + ExtendedProperties exProps = null; try{ - exProps = ExtendedProperties.For(event.entityLiving); + exProps = ExtendedProperties.For(player); }catch (Throwable t){ return; } if (exProps.originalSize == null){ - exProps.originalSize = new AMVector2(event.entityLiving.width, event.entityLiving.height); + exProps.originalSize = new AMVector2(player.width, player.height); } - float shrinkPct = 1 - (0.5f * exProps.getShrinkPct()); + boolean shrunk = exProps.getIsShrunk(); - float calculatedSizeW = (float)(exProps.originalSize.x * shrinkPct); - float calculatedSizeH = (float)(exProps.originalSize.y * shrinkPct); + if (!player.worldObj.isRemote && shrunk && !player.isPotionActive(BuffList.shrink)){ + exProps.setIsShrunk(false); + shrunk = false; + player.yOffset = (float)exProps.getOriginalSize().y * 0.9f; + }else if (!player.worldObj.isRemote && !shrunk && player.isPotionActive(BuffList.shrink)){ + exProps.setIsShrunk(true); + shrunk = true; + player.yOffset = 0.0F; + } - exProps.shrinkTick(); + float shrinkPct = exProps.getShrinkPct(); + if (shrunk && shrinkPct < 1f){ + shrinkPct = Math.min(1f, shrinkPct + 0.005f); + }else if (!shrunk && shrinkPct > 0f){ + shrinkPct = Math.max(0f, shrinkPct - 0.005f); + } + exProps.setShrinkPct(shrinkPct); if (exProps.getShrinkPct() > 0f){ if (exProps.shrinkAmount == 0f || //shrink hasn't yet been applied - exProps.getOriginalSize().x * 0.5 != ent.width || //width has changed through other means - exProps.getOriginalSize().y * 0.5 != ent.height){ //height has changed through other means - exProps.setOriginalSize(new AMVector2(ent.width, ent.height)); - EntityUtilities.setSize(ent, ent.width * 0.5f, ent.height * 0.5f); + exProps.getOriginalSize().x * 0.5 != player.width || //width has changed through other means + exProps.getOriginalSize().y * 0.5 != player.height){ //height has changed through other means + exProps.setOriginalSize(new AMVector2(player.width, player.height)); exProps.shrinkAmount = 0.5f; + EntityUtilities.setSize(player, player.width * exProps.shrinkAmount, player.height * exProps.shrinkAmount); + player.eyeHeight = player.getDefaultEyeHeight() * exProps.shrinkAmount; + player.yOffset = 0.0f; } }else{ if (exProps.shrinkAmount != 0f){ - AMVector2 size = ExtendedProperties.For(ent).getOriginalSize(); - EntityUtilities.setSize(ent, (float)(size.x), (float)(size.y)); + AMVector2 size = ExtendedProperties.For(player).getOriginalSize(); + EntityUtilities.setSize(player, (float)(size.x), (float)(size.y)); exProps.shrinkAmount = 0f; + player.eyeHeight = player.getDefaultEyeHeight(); + player.yOffset = 0.0f; if (exProps.getIsFlipped()){ - ent.moveEntity(0, -1, 0); + event.entityLiving.moveEntity(0, -1, 0); } } } + + // update Y offset + if (player.worldObj.isRemote && exProps.getPrevShrinkPct() != exProps.getShrinkPct()){ + // Vanilla player is 1.8f height with 1.62f yOffset => 0.9f + player.yOffset = (float)exProps.getOriginalSize().y * 0.9f * (1f - 0.5f * exProps.getShrinkPct()); + } } } diff --git a/src/main/java/am2/affinity/AffinityHelper.java b/src/main/java/am2/affinity/AffinityHelper.java index 0dc91ad01..a14a63149 100644 --- a/src/main/java/am2/affinity/AffinityHelper.java +++ b/src/main/java/am2/affinity/AffinityHelper.java @@ -44,8 +44,6 @@ public class AffinityHelper{ - private final Random rand = new Random(); - @SubscribeEvent public void onEntityLivingBase(LivingUpdateEvent event){ EntityLivingBase ent = event.entityLiving; @@ -138,10 +136,10 @@ public void onEntityLivingBase(LivingUpdateEvent event){ } } - if (waterDepth > 0.4 && rand.nextInt(20) < 4) + if (waterDepth > 0.4 && ent.worldObj.rand.nextInt(20) < 4) ent.setAir(ent.getAir() + 1); - if (!ent.worldObj.isRemote && rand.nextInt(100) < 5){ + if (!ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 5){ ent.setAir(ent.getAir() + 1); byte[] data = new AMDataWriter().add(ent.getEntityId()).add(ent.getAir()).generate(); AMNetHandler.INSTANCE.sendPacketToClientPlayer((EntityPlayerMP)ent, AMPacketIDs.SYNC_AIR_CHANGE, data); @@ -164,11 +162,11 @@ public void onEntityLivingBase(LivingUpdateEvent event){ if (ent.worldObj.isRaining() && !ent.worldObj.isRemote && ent.worldObj.getBiomeGenForCoords((int)Math.floor(ent.posX), (int)Math.floor(ent.posZ)).canSpawnLightningBolt()){ float airDepth = affinityData.getAffinityDepth(Affinity.AIR); - if (airDepth > 0.5f && airDepth < 0.85f && !ent.worldObj.isRemote && rand.nextInt(100) < 10){ + if (airDepth > 0.5f && airDepth < 0.85f && !ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 10){ if (!ent.isSneaking() && !ent.isPotionActive(BuffList.gravityWell) && !ent.isInsideOfMaterial(Material.water) && ent.isWet()){ - double velX = rand.nextDouble() - 0.5; - double velY = rand.nextDouble() - 0.5; - double velZ = rand.nextDouble() - 0.5; + double velX = ent.worldObj.rand.nextDouble() - 0.5; + double velY = ent.worldObj.rand.nextDouble() - 0.5; + double velZ = ent.worldObj.rand.nextDouble() - 0.5; ent.addVelocity(velX, velY, velZ); AMNetHandler.INSTANCE.sendVelocityAddPacket(ent.worldObj, ent, velX, velY, velZ); } @@ -223,7 +221,7 @@ private void applyFulmintion(EntityPlayer ent, float lightningDepth){ AMCore.proxy.particleManager.BoltFromEntityToPoint(ent.worldObj, ent, ent.posX - 2 + ent.getRNG().nextDouble() * 4, ent.posY + ent.getEyeHeight() - 2 + ent.getRNG().nextDouble() * 4, ent.posZ - 2 + ent.getRNG().nextDouble() * 4); }else{ if (ent.getRNG().nextDouble() < 0.4f) - ent.worldObj.playSoundAtEntity(ent, "arsmagica2:misc.event.mana_shield_block", 1.0f, rand.nextFloat() + 0.5f); + ent.worldObj.playSoundAtEntity(ent, "arsmagica2:misc.event.mana_shield_block", 1.0f, ent.worldObj.rand.nextFloat() + 0.5f); } } } @@ -437,7 +435,7 @@ public void onSpellCast(SpellCastingEvent.Post event){ if (event.caster instanceof EntityPlayer && event.castResult == SpellCastResult.SUCCESS){ float affinityDepth = AffinityData.For(event.caster).getAffinityDepth(Affinity.ARCANE); if (affinityDepth > 0.4f){ - if (rand.nextInt(100) < 5 && !event.caster.worldObj.isRemote){ + if (event.caster.worldObj.rand.nextInt(100) < 5 && !event.caster.worldObj.isRemote){ event.caster.addPotionEffect(new BuffEffectClarity(140, 0)); } } diff --git a/src/main/java/am2/blocks/BlockArcaneReconstructor.java b/src/main/java/am2/blocks/BlockArcaneReconstructor.java index 6237f4397..fea0df589 100644 --- a/src/main/java/am2/blocks/BlockArcaneReconstructor.java +++ b/src/main/java/am2/blocks/BlockArcaneReconstructor.java @@ -16,15 +16,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import java.util.Random; public class BlockArcaneReconstructor extends AMSpecialRenderPoweredBlock{ - private final Random rand; - protected BlockArcaneReconstructor(){ super(Material.rock); - rand = new Random(); setHardness(3.0f); setResistance(3.0f); setBlockBounds(0, 0, 0, 1, 0.52f, 1); @@ -61,14 +57,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -77,9 +73,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockArmorInfuser.java b/src/main/java/am2/blocks/BlockArmorInfuser.java index 6471f3692..2ffd479b9 100644 --- a/src/main/java/am2/blocks/BlockArmorInfuser.java +++ b/src/main/java/am2/blocks/BlockArmorInfuser.java @@ -106,7 +106,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityArmorImbuer imbuer = (TileEntityArmorImbuer)world.getTileEntity(i, j, k); if (imbuer == null) return; for (int l = 0; l < imbuer.getSizeInventory() - 3; l++){ @@ -114,14 +113,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -130,9 +129,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockAstralBarrier.java b/src/main/java/am2/blocks/BlockAstralBarrier.java index 41c9645c3..32461aa87 100644 --- a/src/main/java/am2/blocks/BlockAstralBarrier.java +++ b/src/main/java/am2/blocks/BlockAstralBarrier.java @@ -66,7 +66,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityAstralBarrier barrier = (TileEntityAstralBarrier)world.getTileEntity(i, j, k); if (barrier == null) return; for (int l = 0; l < barrier.getSizeInventory() - 3; l++){ @@ -74,14 +73,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -90,9 +89,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockCalefactor.java b/src/main/java/am2/blocks/BlockCalefactor.java index adcc68b1d..22b174d0a 100644 --- a/src/main/java/am2/blocks/BlockCalefactor.java +++ b/src/main/java/am2/blocks/BlockCalefactor.java @@ -54,7 +54,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityCalefactor calefactor = (TileEntityCalefactor)world.getTileEntity(i, j, k); if (calefactor == null) return; for (int l = 0; l < calefactor.getSizeInventory() - 3; l++){ @@ -62,14 +61,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -78,9 +77,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockDesertNova.java b/src/main/java/am2/blocks/BlockDesertNova.java index 5a8ce9e56..63c4c80e8 100644 --- a/src/main/java/am2/blocks/BlockDesertNova.java +++ b/src/main/java/am2/blocks/BlockDesertNova.java @@ -8,14 +8,20 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.oredict.OreDictionary; +import java.util.Collection; +import java.util.HashSet; import java.util.Random; public class BlockDesertNova extends AMFlower{ + static HashSet blockSands = null; + protected BlockDesertNova(){ super(); } @@ -32,7 +38,20 @@ public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z){ @Override protected boolean canPlaceBlockOn(Block block){ - return block == Blocks.sand; + if (block == Blocks.sand){ + return true; + } + if (blockSands == null){// sand is defined by Forge, hence only first call will be 'true' + Collection itemStackSands = OreDictionary.getOres("sand", false); + blockSands = new HashSet(itemStackSands.size()); + for (ItemStack itemStack : itemStackSands){ + Block oreBlock = Block.getBlockFromItem(itemStack.getItem()); + if (oreBlock != Blocks.air){ + blockSands.add(oreBlock); + } + } + } + return blockSands != null && blockSands.contains(block); } @Override diff --git a/src/main/java/am2/blocks/BlockEssenceGenerator.java b/src/main/java/am2/blocks/BlockEssenceGenerator.java index 4372eb336..4a86fdfe4 100644 --- a/src/main/java/am2/blocks/BlockEssenceGenerator.java +++ b/src/main/java/am2/blocks/BlockEssenceGenerator.java @@ -130,7 +130,6 @@ public void breakBlock(World par1World, int par2, int par3, int par4, Block par5 super.breakBlock(par1World, par2, par3, par4, par5, par6); return; } - Random rand = new Random(); TileEntityObelisk obelisk = getTileEntity(par1World, par2, par3, par4); if (obelisk == null) return; for (int l = 0; l < obelisk.getSizeInventory(); l++){ @@ -138,14 +137,14 @@ public void breakBlock(World par1World, int par2, int par3, int par4, Block par5 if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = par1World.rand.nextFloat() * 0.8F + 0.1F; + float f1 = par1World.rand.nextFloat() * 0.8F + 0.1F; + float f2 = par1World.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = par1World.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -154,9 +153,9 @@ public void breakBlock(World par1World, int par2, int par3, int par4, Block par5 newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(par1World, par2 + f, par3 + f1, par4 + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)par1World.rand.nextGaussian() * f3; + entityitem.motionY = (float)par1World.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)par1World.rand.nextGaussian() * f3; par1World.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockEssenceRefiner.java b/src/main/java/am2/blocks/BlockEssenceRefiner.java index 28a7ea6ee..1b3a3f59f 100644 --- a/src/main/java/am2/blocks/BlockEssenceRefiner.java +++ b/src/main/java/am2/blocks/BlockEssenceRefiner.java @@ -27,7 +27,6 @@ public class BlockEssenceRefiner extends PoweredBlock{ - private Random essenceRefinerRand; private static boolean keepRefinerInventory = false; @SideOnly(Side.CLIENT) @@ -36,7 +35,6 @@ public class BlockEssenceRefiner extends PoweredBlock{ public BlockEssenceRefiner(){ super(Material.wood); - essenceRefinerRand = new Random(); setHardness(2.0f); } @@ -166,14 +164,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = essenceRefinerRand.nextFloat() * 0.8F + 0.1F; - float f1 = essenceRefinerRand.nextFloat() * 0.8F + 0.1F; - float f2 = essenceRefinerRand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = essenceRefinerRand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -182,9 +180,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)essenceRefinerRand.nextGaussian() * f3; - entityitem.motionY = (float)essenceRefinerRand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)essenceRefinerRand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockFlickerHabitat.java b/src/main/java/am2/blocks/BlockFlickerHabitat.java index e67b1c8ef..f23d759aa 100644 --- a/src/main/java/am2/blocks/BlockFlickerHabitat.java +++ b/src/main/java/am2/blocks/BlockFlickerHabitat.java @@ -155,18 +155,17 @@ public void breakBlock(World world, int x, int y, int z, Block oldBlockID, int o //if the habitat has a flicker throw it on the ground if (habitat.hasFlicker()){ - Random rand = new Random(); ItemStack stack = habitat.getStackInSlot(0); - float offsetX = rand.nextFloat() * 0.8F + 0.1F; - float offsetY = rand.nextFloat() * 0.8F + 0.1F; - float offsetZ = rand.nextFloat() * 0.8F + 0.1F; + float offsetX = world.rand.nextFloat() * 0.8F + 0.1F; + float offsetY = world.rand.nextFloat() * 0.8F + 0.1F; + float offsetZ = world.rand.nextFloat() * 0.8F + 0.1F; float force = 0.05F; EntityItem entityItem = new EntityItem(world, x + offsetX, y + offsetY, z + offsetZ, stack); - entityItem.motionX = (float)rand.nextGaussian() * force; - entityItem.motionY = (float)rand.nextGaussian() * force + 0.2F; - entityItem.motionZ = (float)rand.nextGaussian() * force; + entityItem.motionX = (float)world.rand.nextGaussian() * force; + entityItem.motionY = (float)world.rand.nextGaussian() * force + 0.2F; + entityItem.motionZ = (float)world.rand.nextGaussian() * force; world.spawnEntityInWorld(entityItem); } diff --git a/src/main/java/am2/blocks/BlockInertSpawner.java b/src/main/java/am2/blocks/BlockInertSpawner.java index a2f2b5008..596446ab9 100644 --- a/src/main/java/am2/blocks/BlockInertSpawner.java +++ b/src/main/java/am2/blocks/BlockInertSpawner.java @@ -68,18 +68,17 @@ public void breakBlock(World world, int x, int y, int z, Block oldBlockID, int o //if the habitat has a flicker throw it on the ground if (spawner.getStackInSlot(0) != null){ - Random rand = new Random(); ItemStack stack = spawner.getStackInSlot(0); - float offsetX = rand.nextFloat() * 0.8F + 0.1F; - float offsetY = rand.nextFloat() * 0.8F + 0.1F; - float offsetZ = rand.nextFloat() * 0.8F + 0.1F; + float offsetX = world.rand.nextFloat() * 0.8F + 0.1F; + float offsetY = world.rand.nextFloat() * 0.8F + 0.1F; + float offsetZ = world.rand.nextFloat() * 0.8F + 0.1F; float force = 0.05F; EntityItem entityItem = new EntityItem(world, x + offsetX, y + offsetY, z + offsetZ, stack); - entityItem.motionX = (float)rand.nextGaussian() * force; - entityItem.motionY = (float)rand.nextGaussian() * force + 0.2F; - entityItem.motionZ = (float)rand.nextGaussian() * force; + entityItem.motionX = (float)world.rand.nextGaussian() * force; + entityItem.motionY = (float)world.rand.nextGaussian() * force + 0.2F; + entityItem.motionZ = (float)world.rand.nextGaussian() * force; world.spawnEntityInWorld(entityItem); } diff --git a/src/main/java/am2/blocks/BlockInscriptionTable.java b/src/main/java/am2/blocks/BlockInscriptionTable.java index 86995c06e..c52b1d6d8 100644 --- a/src/main/java/am2/blocks/BlockInscriptionTable.java +++ b/src/main/java/am2/blocks/BlockInscriptionTable.java @@ -218,15 +218,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat } private void spawnItemOnBreak(World world, int i, int j, int k, Block par5, int metadata, ItemStack itemstack){ - Random rand = new Random(); - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -235,9 +234,9 @@ private void spawnItemOnBreak(World world, int i, int j, int k, Block par5, int newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockKeystoneChest.java b/src/main/java/am2/blocks/BlockKeystoneChest.java index 0960319d0..e93e93b3b 100644 --- a/src/main/java/am2/blocks/BlockKeystoneChest.java +++ b/src/main/java/am2/blocks/BlockKeystoneChest.java @@ -93,7 +93,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityKeystoneChest receptacle = (TileEntityKeystoneChest)world.getTileEntity(i, j, k); if (receptacle == null) return; @@ -105,14 +104,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -121,9 +120,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockLectern.java b/src/main/java/am2/blocks/BlockLectern.java index 03b446b11..10d80ee43 100644 --- a/src/main/java/am2/blocks/BlockLectern.java +++ b/src/main/java/am2/blocks/BlockLectern.java @@ -40,21 +40,20 @@ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer p if (te == null){ return true; } - Random rand = new Random(); if (te.hasStack()){ if (player.isSneaking()){ if (!world.isRemote && ((player instanceof EntityPlayerMP) && ((EntityPlayerMP)player).theItemInWorldManager.getGameType() != GameType.ADVENTURE)){ - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; ItemStack newItem = new ItemStack(te.getStack().getItem(), 1, te.getStack().getItemDamage()); if (te.getStack().stackTagCompound != null) newItem.setTagCompound((NBTTagCompound)te.getStack().stackTagCompound.copy()); EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); te.setStack(null); } @@ -82,19 +81,18 @@ public void breakBlock(World world, int x, int y, int z, Block par5, int par6){ return; } if (!world.isRemote){ - Random rand = new Random(); if (te.hasStack()){ - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; ItemStack newItem = new ItemStack(te.getStack().getItem(), 1, te.getStack().getItemDamage()); if (te.getStack().stackTagCompound != null) newItem.setTagCompound((NBTTagCompound)te.getStack().stackTagCompound.copy()); EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); } } diff --git a/src/main/java/am2/blocks/BlockMageLight.java b/src/main/java/am2/blocks/BlockMageLight.java index f677e0079..d5c1b1140 100644 --- a/src/main/java/am2/blocks/BlockMageLight.java +++ b/src/main/java/am2/blocks/BlockMageLight.java @@ -24,8 +24,6 @@ public class BlockMageLight extends AMSpecialRenderBlock{ - private final Random rand = new Random(); - protected BlockMageLight(){ super(Material.circuits); setBlockBounds(0.35f, 0.35f, 0.35f, 0.65f, 0.65f, 0.65f); @@ -39,7 +37,7 @@ public int tickRate(World par1World){ @Override @SideOnly(Side.CLIENT) - public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random){ + public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random rand){ int meta = par1World.getBlockMetadata(par2, par3, par4); int color = ItemDye.field_150922_c[meta]; diff --git a/src/main/java/am2/blocks/BlockMagiciansWorkbench.java b/src/main/java/am2/blocks/BlockMagiciansWorkbench.java index 8bab2e37d..0dd2a65ef 100644 --- a/src/main/java/am2/blocks/BlockMagiciansWorkbench.java +++ b/src/main/java/am2/blocks/BlockMagiciansWorkbench.java @@ -138,7 +138,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntityMagiciansWorkbench workbench = (TileEntityMagiciansWorkbench)world.getTileEntity(i, j, k); if (workbench == null || KeystoneUtilities.instance.getKeyFromRunes(workbench.getRunesInKey()) != 0) return; @@ -147,14 +146,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -163,23 +162,23 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } if(workbench.getUpgradeStatus(TileEntityMagiciansWorkbench.UPG_CRAFT)){ - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; ItemStack newItem = new ItemStack(ItemsCommonProxy.workbenchUpgrade, 1); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); } diff --git a/src/main/java/am2/blocks/BlockManaBattery.java b/src/main/java/am2/blocks/BlockManaBattery.java index 4396a0bc9..647b028fe 100644 --- a/src/main/java/am2/blocks/BlockManaBattery.java +++ b/src/main/java/am2/blocks/BlockManaBattery.java @@ -134,11 +134,10 @@ public void onBlockPreDestroy(World par1World, int par2, int par3, int par4, int private void destroy(World world, int i, int j, int k){ TileEntityManaBattery te = getTileEntity(world, i, j, k); - Random rand = new Random(); if (te != null && !world.isRemote){ - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; int dmg = (int)((PowerNodeRegistry.For(world).getPower(te, te.getPowerType()) / te.getCapacity()) * 100); if (dmg == 0) dmg = 1; ItemStack stack = new ItemStack(this); @@ -158,9 +157,9 @@ private void destroy(World world, int i, int j, int k){ EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, stack); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); } } diff --git a/src/main/java/am2/blocks/BlockSeerStone.java b/src/main/java/am2/blocks/BlockSeerStone.java index 25960869c..63e8ea44f 100644 --- a/src/main/java/am2/blocks/BlockSeerStone.java +++ b/src/main/java/am2/blocks/BlockSeerStone.java @@ -196,7 +196,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntitySeerStone myTE = (TileEntitySeerStone)world.getTileEntity(i, j, k); if (myTE == null) return; for (int l = 0; l < myTE.getSizeInventory() - 3; l++){ @@ -204,14 +203,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -220,9 +219,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockSpellSealedDoor.java b/src/main/java/am2/blocks/BlockSpellSealedDoor.java index 59836d96c..192c714a7 100644 --- a/src/main/java/am2/blocks/BlockSpellSealedDoor.java +++ b/src/main/java/am2/blocks/BlockSpellSealedDoor.java @@ -27,7 +27,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import java.util.Random; public class BlockSpellSealedDoor extends BlockDoor implements ITileEntityProvider{ @@ -153,21 +152,20 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (world.getBlock(i, j - 1, k) == BlocksCommonProxy.spellSealedDoor) j--; - Random rand = new Random(); TileEntitySpellSealedDoor door = (TileEntitySpellSealedDoor)world.getTileEntity(i, j, k); if (door == null) return; ItemStack itemstack = door.getStackInSlot(3); if (itemstack == null){ return; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -176,9 +174,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat newItem.setTagCompound(itemstack.getTagCompound()); EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newItem); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); diff --git a/src/main/java/am2/blocks/BlockSummoner.java b/src/main/java/am2/blocks/BlockSummoner.java index 749bdcd86..9660896a8 100644 --- a/src/main/java/am2/blocks/BlockSummoner.java +++ b/src/main/java/am2/blocks/BlockSummoner.java @@ -21,7 +21,6 @@ import net.minecraft.util.Vec3; import net.minecraft.world.World; -import java.util.Random; public class BlockSummoner extends AMSpecialRenderPoweredBlock{ @@ -92,7 +91,6 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat super.breakBlock(world, i, j, k, par5, metadata); return; } - Random rand = new Random(); TileEntitySummoner summoner = (TileEntitySummoner)world.getTileEntity(i, j, k); if (summoner == null) return; for (int l = 0; l < summoner.getSizeInventory() - 3; l++){ @@ -100,14 +98,14 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat if (itemstack == null){ continue; } - float f = rand.nextFloat() * 0.8F + 0.1F; - float f1 = rand.nextFloat() * 0.8F + 0.1F; - float f2 = rand.nextFloat() * 0.8F + 0.1F; + float f = world.rand.nextFloat() * 0.8F + 0.1F; + float f1 = world.rand.nextFloat() * 0.8F + 0.1F; + float f2 = world.rand.nextFloat() * 0.8F + 0.1F; do{ if (itemstack.stackSize <= 0){ break; } - int i1 = rand.nextInt(21) + 10; + int i1 = world.rand.nextInt(21) + 10; if (i1 > itemstack.stackSize){ i1 = itemstack.stackSize; } @@ -118,9 +116,9 @@ public void breakBlock(World world, int i, int j, int k, Block par5, int metadat } EntityItem entityitem = new EntityItem(world, i + f, j + f1, k + f2, newStack); float f3 = 0.05F; - entityitem.motionX = (float)rand.nextGaussian() * f3; - entityitem.motionY = (float)rand.nextGaussian() * f3 + 0.2F; - entityitem.motionZ = (float)rand.nextGaussian() * f3; + entityitem.motionX = (float)world.rand.nextGaussian() * f3; + entityitem.motionY = (float)world.rand.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)world.rand.nextGaussian() * f3; world.spawnEntityInWorld(entityitem); }while (true); } diff --git a/src/main/java/am2/blocks/BlockTarmaRoot.java b/src/main/java/am2/blocks/BlockTarmaRoot.java index cff9d5dd4..f00019b85 100644 --- a/src/main/java/am2/blocks/BlockTarmaRoot.java +++ b/src/main/java/am2/blocks/BlockTarmaRoot.java @@ -1,13 +1,19 @@ package am2.blocks; +import java.util.HashSet; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; +import net.minecraftforge.oredict.OreDictionary; public class BlockTarmaRoot extends AMFlower{ + static HashSet blockStones = null; + protected BlockTarmaRoot(){ super(); } @@ -25,7 +31,23 @@ public boolean canBlockStay(World worldIn, int x, int y, int z){ @Override protected boolean canPlaceBlockOn(Block block){ - return block == Blocks.stone || block == Blocks.cobblestone; + if (block == Blocks.stone || block == Blocks.cobblestone){ + return true; + } + if (blockStones == null){// stone and cobblestone are defined by Forge, hence only first call will be 'true' + HashSet itemStackStones = new HashSet(); + itemStackStones.addAll(OreDictionary.getOres("stone", false)); + itemStackStones.addAll(OreDictionary.getOres("stoneCobble", false)); + itemStackStones.addAll(OreDictionary.getOres("cobblestone", false)); + blockStones = new HashSet(itemStackStones.size()); + for (ItemStack itemStack : itemStackStones){ + Block oreBlock = Block.getBlockFromItem(itemStack.getItem()); + if (oreBlock != Blocks.air){ + blockStones.add(oreBlock); + } + } + } + return blockStones != null && blockStones.contains(block); } //EoD: Tarmas should only grow in dark places diff --git a/src/main/java/am2/blocks/BlocksCommonProxy.java b/src/main/java/am2/blocks/BlocksCommonProxy.java index 999c3570c..66ee3071e 100644 --- a/src/main/java/am2/blocks/BlocksCommonProxy.java +++ b/src/main/java/am2/blocks/BlocksCommonProxy.java @@ -621,11 +621,11 @@ public void InitRecipes(){ }); //storage blocks - createStorageBlockRecipe(new ItemStack(AMOres, 1, 5), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_MOONSTONE)); - createStorageBlockRecipe(new ItemStack(AMOres, 1, 6), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_VINTEUMDUST)); - createStorageBlockRecipe(new ItemStack(AMOres, 1, 7), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_BLUETOPAZ)); - createStorageBlockRecipe(new ItemStack(AMOres, 1, 8), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_SUNSTONE)); - createStorageBlockRecipe(new ItemStack(AMOres, 1, 9), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_CHIMERITE)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_MOONSTONE_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_MOONSTONE)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_VINTEUM_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_VINTEUMDUST)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_BLUE_TOPAZ_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_BLUETOPAZ)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_SUNSTONE_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_SUNSTONE)); + createStorageBlockRecipe(new ItemStack(AMOres, 1, AMOres.META_CHIMERITE_BLOCK), new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_CHIMERITE)); //furnace recipes GameRegistry.addSmelting(new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_ARCANECOMPOUND), new ItemStack(ItemsCommonProxy.itemOre, 2, ItemsCommonProxy.itemOre.META_ARCANEASH), 0); diff --git a/src/main/java/am2/blocks/IllusionBlock.java b/src/main/java/am2/blocks/IllusionBlock.java index ca55ce2a2..e6d05d37d 100644 --- a/src/main/java/am2/blocks/IllusionBlock.java +++ b/src/main/java/am2/blocks/IllusionBlock.java @@ -91,7 +91,6 @@ public AMVector3 getMimicLocation(IBlockAccess blockAccess, int x, int y, int z) AMVector3 position = new AMVector3(x, y, z); AMVector3 offset = new AMVector3(dir.offsetX, dir.offsetY, dir.offsetZ); int count = 0; - boolean found = false; while (count++ < SEARCH_MAX_DIST){ position = position.add(offset); @@ -272,7 +271,7 @@ public int GetCraftingQuantity(){ */ @Override public void randomDisplayTick(World world, int i, int j, int k, Random random){ - int meta = world.getBlockMetadata(i, j, k); + // int meta = world.getBlockMetadata(i, j, k); EntityPlayer closest = world.getClosestPlayer(i, j, k, 5.0); if (closest == null){ @@ -280,19 +279,17 @@ public void randomDisplayTick(World world, int i, int j, int k, Random random){ return; }else if (closest.isPotionActive(BuffList.trueSight.id)){ world.markBlockForUpdate(i, j, k); - Random rnd = new Random(); if (tickCount++ == 20){ this.tickCount = 0; for (int x = 0; x < 10; ++x){ - double factor = 1; double movement = 2; world.spawnParticle("reddust", - i + ((rnd.nextDouble() * 2 - 1) * movement), - j + ((rnd.nextDouble() * 2 - 1) * movement), - k + ((rnd.nextDouble() * 2 - 1) * movement), - rnd.nextDouble() / 4 + 0.75, + i + ((random.nextDouble() * 2 - 1) * movement), + j + ((random.nextDouble() * 2 - 1) * movement), + k + ((random.nextDouble() * 2 - 1) * movement), + random.nextDouble() / 4 + 0.75, 0.5f, - rnd.nextDouble() / 2 + 0.75); + random.nextDouble() / 2 + 0.75); } } }else{ diff --git a/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java b/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java index 04b2a3079..b451ff65c 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityArcaneReconstructor.java @@ -26,8 +26,6 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.Constants; -import java.util.Random; - public class TileEntityArcaneReconstructor extends TileEntityAMPower implements IInventory, ISidedInventory, IKeystoneLockable{ private ItemStack[] inventory; @@ -39,16 +37,16 @@ public class TileEntityArcaneReconstructor extends TileEntityAMPower implements private final AMVector3 middleRingRotation; private final AMVector3 innerRingRotation; private float rotateOffset = 0; + private int deactivationDelayTicks = 0; private EntityLiving dummyEntity; - private final AMVector3 outerRingRotationSpeeds; - private final AMVector3 middleRingRotationSpeeds; - private final AMVector3 innerRingRotationSpeeds; - - private final Random rand; + private AMVector3 outerRingRotationSpeeds; + private AMVector3 middleRingRotationSpeeds; + private AMVector3 innerRingRotationSpeeds; private static final int SLOT_ACTIVE = 3; + private boolean isFirstTick = true; public TileEntityArcaneReconstructor(){ super(500); @@ -60,11 +58,6 @@ public TileEntityArcaneReconstructor(){ middleRingRotation = new AMVector3(0, 0, 0); innerRingRotation = new AMVector3(0, 0, 0); - rand = new Random(); - outerRingRotationSpeeds = new AMVector3(rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2); - middleRingRotationSpeeds = new AMVector3(rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2); - innerRingRotationSpeeds = new AMVector3(rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2, rand.nextDouble() * 4 - 2); - } @Override @@ -89,19 +82,34 @@ public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){ @Override public void updateEntity(){ - if (PowerNodeRegistry.For(this.worldObj).checkPower(this, this.getRepairCost()) && repairCounter++ % getRepairRate() == 0){ - if (!queueRepairableItem()){ - if (performRepair()){ + if (isFirstTick) { + outerRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); + middleRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); + innerRingRotationSpeeds = new AMVector3(worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2, worldObj.rand.nextDouble() * 4 - 2); + isFirstTick = false; + } + + if (PowerNodeRegistry.For(this.worldObj).checkPower(this, this.getRepairCost())) {// has enough power + if ((repairCounter++ % getRepairRate() == 0) && (!queueRepairableItem())) {// has ticked and already has item queued + if (performRepair()){// something to repair if (!worldObj.isRemote){ PowerNodeRegistry.For(this.worldObj).consumePower(this, PowerNodeRegistry.For(worldObj).getHighestPowerType(this), this.getRepairCost()); } } } + deactivationDelayTicks = 0; + } else if (!worldObj.isRemote && active){// out of power, on server and active + if (deactivationDelayTicks++ > 100) {// 5 seconds + deactivationDelayTicks = 0; + this.active = false; + if (!worldObj.isRemote) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } } if (worldObj.isRemote){ updateRotations(); if (shouldRenderItemStack()){ - AMParticle p = (AMParticle)AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle2", xCoord + 0.2 + (rand.nextDouble() * 0.6), yCoord + 0.4, zCoord + 0.2 + (rand.nextDouble() * 0.6)); + AMParticle p = (AMParticle)AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle2", xCoord + 0.2 + (worldObj.rand.nextDouble() * 0.6), yCoord + 0.4, zCoord + 0.2 + (worldObj.rand.nextDouble() * 0.6)); if (p != null){ p.AddParticleController(new ParticleFloatUpward(p, 0.0f, 0.02f, 1, false)); p.setIgnoreMaxAge(true); @@ -137,9 +145,10 @@ public boolean shouldRenderRotateOffset(){ private void updateRotations(){ if (active){ - if (ringOffset < 0.5){ + if (ringOffset < 0.5f){ ringOffset += 0.015f; }else{ + ringOffset = 0.51f; outerRingRotation.add(outerRingRotationSpeeds); middleRingRotation.add(middleRingRotationSpeeds); innerRingRotation.add(innerRingRotationSpeeds); @@ -165,8 +174,10 @@ private void updateRotations(){ innerRingRotation.y = easeCoordinate(innerRingRotation.y, innerRingRotationSpeeds.y); innerRingRotation.z = easeCoordinate(innerRingRotation.z, innerRingRotationSpeeds.z); }else{ - if (ringOffset > 0){ + if (ringOffset > 0f){ ringOffset -= 0.03f; + } else { + ringOffset = 0f; } } } @@ -222,7 +233,14 @@ public AMVector3 getOuterRingRotation(){ } private boolean queueRepairableItem(){ - if (inventory[SLOT_ACTIVE] != null) return false; + if (inventory[SLOT_ACTIVE] != null) { + if (!active) { + this.active = true; + if (!worldObj.isRemote) + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + return false; + } for (int i = 4; i < 10; ++i){ if (itemStackIsValid(inventory[i])){ inventory[SLOT_ACTIVE] = inventory[i].copy(); @@ -257,7 +275,6 @@ private boolean performRepair(){ return true; } - if (inventory[SLOT_ACTIVE].isItemDamaged()){ if (!worldObj.isRemote) inventory[SLOT_ACTIVE].damageItem(-1, getDummyEntity()); @@ -369,6 +386,8 @@ public void readFromNBT(NBTTagCompound nbttagcompound){ inventory[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } + active = nbttagcompound.getBoolean("ArcaneReconstructorActive"); + repairCounter = nbttagcompound.getInteger("ArcaneReconstructorRepairCounter"); } @Override @@ -386,6 +405,8 @@ public void writeToNBT(NBTTagCompound nbttagcompound){ } nbttagcompound.setTag("ArcaneReconstructorInventory", nbttaglist); + nbttagcompound.setBoolean("ArcaneReconstructorActive", active); + nbttagcompound.setInteger("ArcaneReconstructorRepairCounter", repairCounter); } private int numFociOfType(Class type){ diff --git a/src/main/java/am2/blocks/tileentities/TileEntityAstralBarrier.java b/src/main/java/am2/blocks/tileentities/TileEntityAstralBarrier.java index 6286e399f..e9f49c66d 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityAstralBarrier.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityAstralBarrier.java @@ -30,7 +30,6 @@ public class TileEntityAstralBarrier extends TileEntityAMPower implements IInven private static final int maxRadius = 20; private static final int minRadius = 5; private boolean displayAura; - private Random rand; private int particleTickCounter; public static int keystoneSlot = 0; @@ -39,7 +38,6 @@ public TileEntityAstralBarrier(){ super(250); inventory = new ItemStack[getSizeInventory()]; displayAura = false; - rand = new Random(); particleTickCounter = 0; } @@ -101,13 +99,13 @@ public void updateEntity(){ particleTickCounter = 0; String particleName = ""; - AMParticle effect = (AMParticle)AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5, yCoord + 0.1 + rand.nextDouble() * 0.5, zCoord + 0.5); + AMParticle effect = (AMParticle)AMCore.instance.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5, yCoord + 0.1 + worldObj.rand.nextDouble() * 0.5, zCoord + 0.5); if (effect != null){ effect.setIgnoreMaxAge(false); effect.setMaxAge(100); effect.setParticleScale(0.5f); - float color = rand.nextFloat() * 0.2f + 0.8f; - effect.AddParticleController(new ParticleOrbitPoint(effect, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 1, false).SetOrbitSpeed(0.005).SetTargetDistance(rand.nextDouble() * 0.6 - 0.3)); + float color = worldObj.rand.nextFloat() * 0.2f + 0.8f; + effect.AddParticleController(new ParticleOrbitPoint(effect, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, 1, false).SetOrbitSpeed(0.005).SetTargetDistance(worldObj.rand.nextDouble() * 0.6 - 0.3)); effect.AddParticleController(new ParticleHoldPosition(effect, 80, 2, true)); effect.AddParticleController(new ParticleFadeOut(effect, 3, false).setFadeSpeed(0.05f)); } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java b/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java index f2f78c00b..2b89ded11 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityCalefactor.java @@ -32,7 +32,7 @@ public class TileEntityCalefactor extends TileEntityAMPower implements IInventor private ItemStack calefactorItemStacks[]; private float rotationX, rotationY, rotationZ; - private final float rotationStepX, rotationStepY, rotationStepZ; + private float rotationStepX; private final short baseCookTime = 220; //default to the same as a standard furnace private short timeSpentCooking = 0; private final float basePowerConsumedPerTickCooking = 0.85f; @@ -40,16 +40,12 @@ public class TileEntityCalefactor extends TileEntityAMPower implements IInventor private boolean isCooking; private static final byte PKT_PRG_UPDATE = 1; + private boolean isFirstTick = true; public TileEntityCalefactor(){ super(100); - Random rand = new Random(); - calefactorItemStacks = new ItemStack[getSizeInventory()]; - rotationStepX = rand.nextFloat() * 0.03f - 0.015f; - rotationStepY = rand.nextFloat() * 0.03f - 0.015f; - rotationStepZ = rand.nextFloat() * 0.03f - 0.015f; isCooking = false; } @@ -240,7 +236,10 @@ private boolean isSmelting(){ @Override public void updateEntity(){ super.updateEntity(); - boolean didSmeltItem = false; + if (isFirstTick) { + rotationStepX = worldObj.rand.nextFloat() * 0.03f - 0.015f; + isFirstTick = false; + } if (this.worldObj.isRemote){ incrementRotations(); @@ -288,7 +287,6 @@ public void updateEntity(){ if (this.timeSpentCooking >= getModifiedCookTime()){ if (!this.worldObj.isRemote){ this.smeltItem(); - didSmeltItem = true; }else{ worldObj.playSound(xCoord, yCoord, zCoord, "arsmagica2:misc.calefactor.burn", 0.2f, 1.0f, true); } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java b/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java index 51f43fd4f..f77b09714 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityEssenceConduit.java @@ -15,24 +15,26 @@ public class TileEntityEssenceConduit extends TileEntityAMPower{ private float rotationIncrementX; private float rotationIncrementY; private float rotationIncrementZ; + + private boolean isFirstTick = false; public TileEntityEssenceConduit(){ super(1); - Random rand = new Random(); - rotationX = rand.nextInt(360); - rotationY = rand.nextInt(360); - rotationZ = rand.nextInt(360); redstonePowered = false; - - rotationIncrementX = rand.nextFloat() * 0.002f + 0.005f; - rotationIncrementY = rand.nextFloat() * 0.002f + 0.005f; - rotationIncrementZ = rand.nextFloat() * 0.002f + 0.005f; - } @Override public void updateEntity(){ + if (isFirstTick) { + rotationX = worldObj.rand.nextInt(360); + rotationY = worldObj.rand.nextInt(360); + rotationZ = worldObj.rand.nextInt(360); + rotationIncrementX = worldObj.rand.nextFloat() * 0.002f + 0.005f; + rotationIncrementY = worldObj.rand.nextFloat() * 0.002f + 0.005f; + rotationIncrementZ = worldObj.rand.nextFloat() * 0.002f + 0.005f; + isFirstTick = false; + } if (worldObj != null && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){ redstonePowered = true; }else{ diff --git a/src/main/java/am2/blocks/tileentities/TileEntityFlickerHabitat.java b/src/main/java/am2/blocks/tileentities/TileEntityFlickerHabitat.java index deed74deb..9e87cbb05 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityFlickerHabitat.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityFlickerHabitat.java @@ -71,9 +71,8 @@ public TileEntityFlickerHabitat(){ initLocationLists(); if (worldObj != null && worldObj.isRemote){ - Random rnd = new Random(System.currentTimeMillis()); - rotateOffset = rnd.nextFloat() * FULL_CIRCLE - 1; - floatOffset = MAX_FLOAT_DOWN + (rnd.nextFloat() * (MAX_FLOAT_UP - MAX_FLOAT_DOWN) + 1); + rotateOffset = worldObj.rand.nextFloat() * FULL_CIRCLE - 1; + floatOffset = MAX_FLOAT_DOWN + (worldObj.rand.nextFloat() * (MAX_FLOAT_UP - MAX_FLOAT_DOWN) + 1); } } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityInscriptionTable.java b/src/main/java/am2/blocks/tileentities/TileEntityInscriptionTable.java index 9dc087fed..b50eac8c2 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityInscriptionTable.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityInscriptionTable.java @@ -57,7 +57,6 @@ public class TileEntityInscriptionTable extends TileEntity implements IInventory public static int inkIndex = 3; private EntityPlayer currentPlayerUsing; private int ticksToNextParticle = 20; - private final Random rand; private final HashMap modifierCount; private String currentSpellName; private boolean currentSpellIsReadOnly; @@ -69,7 +68,6 @@ public class TileEntityInscriptionTable extends TileEntity implements IInventory public TileEntityInscriptionTable(){ inscriptionTableItemStacks = new ItemStack[getSizeInventory()]; currentPlayerUsing = null; - rand = new Random(); currentSpellName = ""; currentRecipe = new ArrayList(); shapeGroups = new ArrayList>(); @@ -216,13 +214,13 @@ private void candleUpdate(){ effect.setMaxAge(400); } - if (rand.nextInt(100) > 80){ + if (worldObj.rand.nextInt(100) > 80){ AMParticle smoke = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, "smoke", particleX, yCoord + 1.4, particleZ); if (smoke != null){ smoke.setParticleScale(0.025f); smoke.AddParticleController(new ParticleFloatUpward(smoke, 0.01f, 0.01f, 1, false)); smoke.setIgnoreMaxAge(false); - smoke.setMaxAge(20 + rand.nextInt(10)); + smoke.setMaxAge(20 + worldObj.rand.nextInt(10)); } } } @@ -260,13 +258,13 @@ private void candleUpdate(){ effect.setMaxAge(400); } - if (rand.nextInt(100) > 80){ + if (worldObj.rand.nextInt(100) > 80){ AMParticle smoke = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, "smoke", particleX, yCoord + 1.4, particleZ); if (smoke != null){ smoke.setParticleScale(0.025f); smoke.AddParticleController(new ParticleFloatUpward(smoke, 0.01f, 0.01f, 1, false)); smoke.setIgnoreMaxAge(false); - smoke.setMaxAge(20 + rand.nextInt(10)); + smoke.setMaxAge(20 + worldObj.rand.nextInt(10)); } } } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityKeystoneRecepticle.java b/src/main/java/am2/blocks/tileentities/TileEntityKeystoneRecepticle.java index 0255c01b0..83d579eba 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityKeystoneRecepticle.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityKeystoneRecepticle.java @@ -36,7 +36,6 @@ public class TileEntityKeystoneRecepticle extends TileEntityAMPower implements I private boolean isActive; private long key; - private final Random rand; private final int boltType = 2; private int surroundingCheckTicks = 20; @@ -50,7 +49,6 @@ public class TileEntityKeystoneRecepticle extends TileEntityAMPower implements I public TileEntityKeystoneRecepticle(){ super(250000); this.isActive = false; - this.rand = new Random(); inventory = new ItemStack[getSizeInventory()]; initMultiblock(); } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityLectern.java b/src/main/java/am2/blocks/tileentities/TileEntityLectern.java index 5503e9a27..136ae9812 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityLectern.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityLectern.java @@ -23,7 +23,6 @@ public class TileEntityLectern extends TileEntityEnchantmentTable{ private ItemStack stack; - private Random rand; private ItemStack tooltipStack; private boolean needsBook; private boolean overPowered; @@ -32,7 +31,6 @@ public class TileEntityLectern extends TileEntityEnchantmentTable{ private boolean increasing = true; public TileEntityLectern(){ - rand = new Random(); } public void resetParticleAge(){ @@ -53,9 +51,9 @@ public void updateEntity(){ if (worldObj.isRemote){ updateBookRender(); if (tooltipStack != null && field_145926_a % 2 == 0){ - AMParticle particle = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5 + ((rand.nextDouble() * 0.2) - 0.1), yCoord + 1, zCoord + 0.5 + ((rand.nextDouble() * 0.2) - 0.1)); + AMParticle particle = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, "sparkle", xCoord + 0.5 + ((worldObj.rand.nextDouble() * 0.2) - 0.1), yCoord + 1, zCoord + 0.5 + ((worldObj.rand.nextDouble() * 0.2) - 0.1)); if (particle != null){ - particle.AddParticleController(new ParticleMoveOnHeading(particle, rand.nextDouble() * 360, -45 - rand.nextInt(90), 0.05f, 1, false)); + particle.AddParticleController(new ParticleMoveOnHeading(particle, worldObj.rand.nextDouble() * 360, -45 - worldObj.rand.nextInt(90), 0.05f, 1, false)); particle.AddParticleController(new ParticleFadeOut(particle, 2, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true)); particle.setIgnoreMaxAge(true); if (getOverpowered()){ @@ -82,11 +80,11 @@ private void updateBookRender(){ this.field_145930_m += 0.1F; - if (this.field_145930_m < 0.5F || rand.nextInt(40) == 0){ + if (this.field_145930_m < 0.5F || worldObj.rand.nextInt(40) == 0){ float f1 = this.field_145932_k; do{ - this.field_145932_k += (float)(rand.nextInt(4) - rand.nextInt(4)); + this.field_145932_k += (float)(worldObj.rand.nextInt(4) - worldObj.rand.nextInt(4)); } while (f1 == this.field_145932_k); } diff --git a/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java b/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java index a9854a899..aa65ebaf4 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java +++ b/src/main/java/am2/blocks/tileentities/TileEntityParticleEmitter.java @@ -32,15 +32,11 @@ public class TileEntityParticleEmitter extends TileEntity{ private float speed; private boolean hasReceivedFullUpdate = false; - private int fullUpdateDelayTicks; - private int updateCounter = 0; private int spawnTicks = 0; private int showTicks = 0; boolean forceShow; - private Random random = new Random(); - public TileEntityParticleEmitter(){ particleType = 0; particleQuantity = 1; @@ -53,7 +49,6 @@ public TileEntityParticleEmitter(){ randomColor = false; show = true; forceShow = false; - fullUpdateDelayTicks = random.nextInt(40); } @Override @@ -88,9 +83,9 @@ public void updateEntity(){ private void doSpawn(){ if (!hasReceivedFullUpdate) return; - double x = randomzieCoord(xCoord + 0.5); - double y = randomzieCoord(yCoord + 0.5); - double z = randomzieCoord(zCoord + 0.5); + double x = randomizeCoord(xCoord + 0.5); + double y = randomizeCoord(yCoord + 0.5); + double z = randomizeCoord(zCoord + 0.5); AMParticle particle = (AMParticle)AMCore.proxy.particleManager.spawn(worldObj, AMParticle.particleTypes[particleType], x, y, z); if (particle != null){ particle.AddParticleController(AMCore.proxy.particleManager.createDefaultParticleController(particleBehaviour, particle, new AMVector3(x, y, z), speed, worldObj.getBlockMetadata(xCoord, yCoord, zCoord))); @@ -102,13 +97,13 @@ private void doSpawn(){ if (!randomColor) particle.setRGBColorF(((particleColor >> 16) & 0xFF) / 255f, ((particleColor >> 8) & 0xFF) / 255f, (particleColor & 0xFF) / 255f); else - particle.setRGBColorF(random.nextFloat(), random.nextFloat(), random.nextFloat()); + particle.setRGBColorF(worldObj.rand.nextFloat(), worldObj.rand.nextFloat(), worldObj.rand.nextFloat()); } } } - private double randomzieCoord(double base){ - return base + random.nextDouble() - 0.5; + private double randomizeCoord(double base){ + return base + worldObj.rand.nextDouble() - 0.5; } @Override diff --git a/src/main/java/am2/blocks/tileentities/TileEntitySeerStone.java b/src/main/java/am2/blocks/tileentities/TileEntitySeerStone.java index 0cc60a05b..60059e9e2 100644 --- a/src/main/java/am2/blocks/tileentities/TileEntitySeerStone.java +++ b/src/main/java/am2/blocks/tileentities/TileEntitySeerStone.java @@ -129,7 +129,7 @@ public boolean isInvertingDetection(){ private SpriteRenderInfo GetWeightedRandomAnimation(){ currentAnimation.reset(false); - int randomNumber = new Random().nextInt(100); + int randomNumber = worldObj.rand.nextInt(100); int index = 0; SpriteRenderInfo current = animations.get(0); diff --git a/src/main/java/am2/bosses/AM2Boss.java b/src/main/java/am2/bosses/AM2Boss.java index 73e7cdbe6..d4f5334d4 100644 --- a/src/main/java/am2/bosses/AM2Boss.java +++ b/src/main/java/am2/bosses/AM2Boss.java @@ -129,7 +129,7 @@ public boolean canBeCollidedWith(){ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2){ if (par1DamageSource == DamageSource.inWall){ - if (!worldObj.isRemote){ + if (!worldObj.isRemote){// dead code? (calling canSnowAt() without using the result) could it be a buggy upgrade to 1.7.10? for (int i = -1; i <= 1; ++i){ for (int j = 0; j < 3; ++j){ for (int k = -1; k <= 1; ++k){ diff --git a/src/main/java/am2/bosses/EntityArcaneGuardian.java b/src/main/java/am2/bosses/EntityArcaneGuardian.java index b47a7ac24..ebcbf2fcd 100644 --- a/src/main/java/am2/bosses/EntityArcaneGuardian.java +++ b/src/main/java/am2/bosses/EntityArcaneGuardian.java @@ -96,13 +96,17 @@ public boolean attackEntityFrom(DamageSource par1DamageSource, float par2){ return super.attackEntityFrom(par1DamageSource, par2); } - if (checkRuneRetaliation(par1DamageSource)) + if (checkRuneRetaliation(par1DamageSource)){ return super.attackEntityFrom(par1DamageSource, par2); - return false; + } + return super.attackEntityFrom(par1DamageSource, par2 * 0.8F); } private boolean checkRuneRetaliation(DamageSource damagesource){ Entity source = damagesource.getSourceOfDamage(); + if (source instanceof EntityArcaneGuardian) { + return true; + } double deltaX = source.posX - this.posX; double deltaZ = source.posZ - this.posZ; @@ -132,6 +136,7 @@ private boolean checkRuneRetaliation(DamageSource damagesource){ source.motionY = vertSpeed; source.attackEntityFrom(DamageSource.causeMobDamage(this), 2); + return false; } } return true; diff --git a/src/main/java/am2/bosses/ai/EntityAIChaosWaterBolt.java b/src/main/java/am2/bosses/ai/EntityAIChaosWaterBolt.java index 784e7f5d0..704b554c2 100644 --- a/src/main/java/am2/bosses/ai/EntityAIChaosWaterBolt.java +++ b/src/main/java/am2/bosses/ai/EntityAIChaosWaterBolt.java @@ -13,7 +13,6 @@ public class EntityAIChaosWaterBolt extends EntityAIBase{ private final EntityWaterGuardian host; private int cooldownTicks = 0; - private final Random rand; private static final ItemStack castStack = createDummyStack(); @@ -26,7 +25,6 @@ private static ItemStack createDummyStack(){ public EntityAIChaosWaterBolt(EntityWaterGuardian host){ this.host = host; this.setMutexBits(1); - rand = new Random(); } @Override @@ -51,7 +49,7 @@ public void updateTask(){ host.setCurrentAction(BossActions.CASTING); if (!host.worldObj.isRemote && host.getCurrentAction() == BossActions.CASTING){ - float yaw = rand.nextFloat() * 360; + float yaw = host.worldObj.rand.nextFloat() * 360; host.rotationYaw = yaw; host.prevRotationYaw = yaw; SpellHelper.instance.applyStackStage(castStack, host, host, host.posX, host.posY, host.posZ, 0, host.worldObj, false, false, 0); diff --git a/src/main/java/am2/buffs/BuffEffect.java b/src/main/java/am2/buffs/BuffEffect.java index 890d2ca4f..67fc9920b 100644 --- a/src/main/java/am2/buffs/BuffEffect.java +++ b/src/main/java/am2/buffs/BuffEffect.java @@ -11,14 +11,12 @@ public abstract class BuffEffect extends PotionEffect{ protected boolean InitialApplication; protected boolean HasNotified; - protected Random rand; private static float maxExtendDuration = 900; //30 seconds public BuffEffect(int buffID, int duration, int amplifier){ super(buffID, duration, amplifier > 0 ? amplifier - 1 : amplifier); InitialApplication = true; HasNotified = ((duration / 20) > 5) ? false : true; //disable notification for effects that last less than 5 seconds - rand = new Random(); } public static boolean SetAmplifier(PotionEffect pe, int amplifier){ @@ -42,9 +40,11 @@ private void effectEnding(EntityLivingBase entityliving){ } //Effect that is performed on intermediate ticks + @Override public void performEffect(EntityLivingBase entityliving){ } + @Override public void combine(PotionEffect potioneffect){ //don't combine "potion effects" with other buff effects if (!(potioneffect instanceof BuffEffect)){ @@ -57,6 +57,7 @@ public void combine(PotionEffect potioneffect){ } } + @Override public boolean onUpdate(EntityLivingBase entityliving){ //check for if we are for the first time applying the effect if (InitialApplication){ @@ -89,6 +90,7 @@ public boolean isReady(int i, int j){ protected abstract String spellBuffName(); + @Override public String getEffectName(){ return String.format("Spell: %s", spellBuffName()); } diff --git a/src/main/java/am2/buffs/BuffEffectRegeneration.java b/src/main/java/am2/buffs/BuffEffectRegeneration.java index 13a3eac18..1bed1aa77 100644 --- a/src/main/java/am2/buffs/BuffEffectRegeneration.java +++ b/src/main/java/am2/buffs/BuffEffectRegeneration.java @@ -33,9 +33,12 @@ public boolean onUpdate(EntityLivingBase entityliving){ if (!world.isRemote){ entityliving.heal(1); }else{ - AMParticle effect = (AMParticle)AMCore.instance.proxy.particleManager.spawn(world, "hr_sparkles_1", entityliving.posX + rand.nextDouble() * entityliving.height - (entityliving.height / 2), entityliving.posY + rand.nextDouble() * entityliving.height - (entityliving.height / 2), entityliving.posZ + rand.nextDouble() * entityliving.height - (entityliving.height / 2)); + AMParticle effect = (AMParticle)AMCore.instance.proxy.particleManager.spawn(world, "hr_sparkles_1", + entityliving.posX + world.rand.nextDouble() * entityliving.height - (entityliving.height / 2), + entityliving.posY + world.rand.nextDouble() * entityliving.height - (entityliving.height / 2), + entityliving.posZ + world.rand.nextDouble() * entityliving.height - (entityliving.height / 2)); if (effect != null){ - effect.setMaxAge(15 + rand.nextInt(10)); + effect.setMaxAge(15 + world.rand.nextInt(10)); effect.setIgnoreMaxAge(false); effect.AddParticleController(new ParticleFadeOut(effect, 1, true)); effect.setRGBColorF(0.15f, 0.92f, 0.37f); diff --git a/src/main/java/am2/buffs/BuffStatModifiers.java b/src/main/java/am2/buffs/BuffStatModifiers.java index a8823d332..d4c43724b 100644 --- a/src/main/java/am2/buffs/BuffStatModifiers.java +++ b/src/main/java/am2/buffs/BuffStatModifiers.java @@ -17,15 +17,11 @@ public void applyStatModifiersBasedOnBuffs(EntityLivingBase entity){ //entangled applyOrRemoveModifiersForBuff(entity, BuffList.entangled.id, new KeyValuePair(SharedMonsterAttributes.movementSpeed, entangled)); //frost slow - applyOrRemoveModifiersForBuff(entity, BuffList.frostSlowed.id, 0, new KeyValuePair(SharedMonsterAttributes.movementSpeed, frostSlow_Diminished)); - applyOrRemoveModifiersForBuff(entity, BuffList.frostSlowed.id, 1, new KeyValuePair(SharedMonsterAttributes.movementSpeed, frostSlow_Normal)); - applyOrRemoveModifiersForBuff(entity, BuffList.frostSlowed.id, 2, new KeyValuePair(SharedMonsterAttributes.movementSpeed, frostSlow_Augmented)); + applyOrRemoveScalingModifiersForBuff(entity, BuffList.frostSlowed.id, SharedMonsterAttributes.movementSpeed, frostSlow_Diminished, frostSlow_Normal, frostSlow_Augmented); //fury applyOrRemoveModifiersForBuff(entity, BuffList.fury.id, new KeyValuePair(SharedMonsterAttributes.movementSpeed, furyMoveMod), new KeyValuePair(SharedMonsterAttributes.attackDamage, furyDmgMod)); //haste - applyOrRemoveModifiersForBuff(entity, BuffList.haste.id, 0, new KeyValuePair(SharedMonsterAttributes.movementSpeed, hasteSpeedBoost_Diminished)); - applyOrRemoveModifiersForBuff(entity, BuffList.haste.id, 1, new KeyValuePair(SharedMonsterAttributes.movementSpeed, hasteSpeedBoost_Normal)); - applyOrRemoveModifiersForBuff(entity, BuffList.haste.id, 2, new KeyValuePair(SharedMonsterAttributes.movementSpeed, hasteSpeedBoost_Augmented)); + applyOrRemoveScalingModifiersForBuff(entity, BuffList.haste.id, SharedMonsterAttributes.movementSpeed, hasteSpeedBoost_Diminished, hasteSpeedBoost_Normal, hasteSpeedBoost_Augmented); } private void applyOrRemoveModifiersForBuff(EntityLivingBase entity, int buffID, KeyValuePair... modifiers){ @@ -36,12 +32,25 @@ private void applyOrRemoveModifiersForBuff(EntityLivingBase entity, int buffID, } } - private void applyOrRemoveModifiersForBuff(EntityLivingBase entity, int buffID, int magnitude, KeyValuePair... modifiers){ - if (entity.isPotionActive(buffID)){ - if (entity.getActivePotionEffect(Potion.potionTypes[buffID]).getAmplifier() == magnitude) - applyAllModifiers(entity, modifiers); + private void applyOrRemoveScalingModifiersForBuff(EntityLivingBase entity, int potionID, IAttribute attribute, AttributeModifier... modifiers){ + IAttributeInstance inst = entity.getEntityAttribute(attribute); + if (inst == null) { + return; + } + AttributeModifier currentModifier = inst.getModifier(modifiers[0].getID()); + if (entity.isPotionActive(potionID)){ + int magnitude = entity.getActivePotionEffect(Potion.potionTypes[potionID]).getAmplifier(); + AttributeModifier modifier = modifiers[Math.min(magnitude, modifiers.length - 1)]; + if (currentModifier != modifier) { + if (currentModifier != null) { + inst.removeModifier(currentModifier); + } + inst.applyModifier(modifier); + } }else{ - clearAllModifiers(entity, modifiers); + if (currentModifier != null) { + inst.removeModifier(currentModifier); + } } } @@ -50,8 +59,13 @@ private void applyAllModifiers(EntityLivingBase entity, KeyValuePair ApplyIllEffect(World world, int x, int y, int z HashMap toReturn = new HashMap(); if (world.isRemote) return toReturn; - Random rand = new Random(); - List located_players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 3, y - 3, z - 3, x + 3, y + 3, z + 3)); EntityPlayer[] players = located_players.toArray(new EntityPlayer[located_players.size()]); diff --git a/src/main/java/am2/illeffect/IllEffectSpark.java b/src/main/java/am2/illeffect/IllEffectSpark.java index e57219c33..d57c7b3a7 100644 --- a/src/main/java/am2/illeffect/IllEffectSpark.java +++ b/src/main/java/am2/illeffect/IllEffectSpark.java @@ -24,11 +24,10 @@ public IllEffectSeverity GetSeverity(){ public Map ApplyIllEffect(World world, int x, int y, int z){ HashMap toReturn = new HashMap(); if (world.isRemote) return toReturn; - Random rand = new Random(); List located_players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 3, y - 3, z - 3, x + 3, y + 3, z + 3)); EntityPlayer[] players = located_players.toArray(new EntityPlayer[located_players.size()]); if (players.length == 0) return toReturn; - EntityPlayer unlucky = players[rand.nextInt(players.length)]; + EntityPlayer unlucky = players[world.rand.nextInt(players.length)]; AMCore.instance.proxy.particleManager.BoltFromPointToPoint(world, x, y, z, unlucky.posX, unlucky.posY, unlucky.posZ, 4, -1); unlucky.attackEntityFrom(DamageSource.generic, 1); diff --git a/src/main/java/am2/illeffect/IllEffectSparkStorm.java b/src/main/java/am2/illeffect/IllEffectSparkStorm.java index 36c258b4d..1ab11214d 100644 --- a/src/main/java/am2/illeffect/IllEffectSparkStorm.java +++ b/src/main/java/am2/illeffect/IllEffectSparkStorm.java @@ -24,7 +24,6 @@ public IllEffectSeverity GetSeverity(){ public Map ApplyIllEffect(World world, int x, int y, int z){ HashMap toReturn = new HashMap(); if (world.isRemote) return toReturn; - Random rand = new Random(); List located_players = world.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(x - 3, y - 3, z - 3, x + 3, y + 3, z + 3)); EntityPlayer[] players = located_players.toArray(new EntityPlayer[located_players.size()]); if (players.length == 0) return toReturn; diff --git a/src/main/java/am2/illeffect/IllEffectsManager.java b/src/main/java/am2/illeffect/IllEffectsManager.java index f924dbf15..4fba2f836 100644 --- a/src/main/java/am2/illeffect/IllEffectsManager.java +++ b/src/main/java/am2/illeffect/IllEffectsManager.java @@ -10,12 +10,11 @@ public class IllEffectsManager{ private TreeMap DarkNexusBadThings; - private Random rand; public static IllEffectsManager instance = new IllEffectsManager(); + private static Random rand = new Random(); private IllEffectsManager(){ DarkNexusBadThings = new TreeMap(); - rand = new Random(); } public void ApplyRandomBadThing(TileEntity te, IllEffectSeverity maxSev, BadThingTypes type){ diff --git a/src/main/java/am2/items/ItemArcaneCompendium.java b/src/main/java/am2/items/ItemArcaneCompendium.java index 43f5b4b85..bdaed9e6f 100644 --- a/src/main/java/am2/items/ItemArcaneCompendium.java +++ b/src/main/java/am2/items/ItemArcaneCompendium.java @@ -1,9 +1,19 @@ package am2.items; import am2.guis.AMGuiHelper; +import am2.texture.ResourceManager; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import am2.texture.ResourceManager; public class ItemArcaneCompendium extends ArsMagicaItem{ @@ -24,4 +34,9 @@ public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int return false; } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister){ + this.itemIcon = ResourceManager.RegisterTexture("arcanecompendium", par1IconRegister); + } } diff --git a/src/main/java/am2/items/ItemCrystalPhylactery.java b/src/main/java/am2/items/ItemCrystalPhylactery.java index 4b7735955..d15c5b9e2 100644 --- a/src/main/java/am2/items/ItemCrystalPhylactery.java +++ b/src/main/java/am2/items/ItemCrystalPhylactery.java @@ -189,7 +189,6 @@ public int getColorFromItemStack(ItemStack stack, int pass){ } public void getSpawnableEntities(World world){ - Random random = new Random(); for (Object clazz : EntityList.classToStringMapping.keySet()){ if (EntityCreature.class.isAssignableFrom((Class)clazz)){ try{ @@ -209,7 +208,7 @@ public void getSpawnableEntities(World world){ } if (!found){ //no spawn egg...pick random color? - color = random.nextInt(); + color = world.rand.nextInt(); } spawnableEntities.put((String)EntityList.classToStringMapping.get(clazz), color); } diff --git a/src/main/java/am2/lore/StoryManager.java b/src/main/java/am2/lore/StoryManager.java index 8a5e36da3..1c21cd4d1 100644 --- a/src/main/java/am2/lore/StoryManager.java +++ b/src/main/java/am2/lore/StoryManager.java @@ -8,13 +8,12 @@ public class StoryManager{ private ArrayList stories; - private Random rand; + private static final Random rand = new Random(); public static StoryManager INSTANCE = new StoryManager(); private StoryManager(){ stories = new ArrayList(); - rand = new Random(); } public void AddStory(String resourceFileName) throws IOException{ diff --git a/src/main/java/am2/models/ModelCloaks.java b/src/main/java/am2/models/ModelCloaks.java index e8a255772..363258cd4 100644 --- a/src/main/java/am2/models/ModelCloaks.java +++ b/src/main/java/am2/models/ModelCloaks.java @@ -167,8 +167,8 @@ public void render(EntityPlayer player, ModelBiped mainModel, float f5, float pa GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F); copyRotations(mainModel); - if (ExtendedProperties.For(player).getShrinkPct() > 0){ - float pct = ExtendedProperties.For(player).getShrinkPct(); + float pct = ExtendedProperties.For(player).getShrinkPct(); + if (pct > 0){ float amt = 0.5f * pct; GL11.glTranslatef(0, 1 * 1 - pct, 0); GL11.glScalef(1 - amt, 1 - amt, 1 - amt); diff --git a/src/main/java/am2/navigation/PathNavigator.java b/src/main/java/am2/navigation/PathNavigator.java index 03f61ec1d..982ada604 100644 --- a/src/main/java/am2/navigation/PathNavigator.java +++ b/src/main/java/am2/navigation/PathNavigator.java @@ -15,7 +15,6 @@ public class PathNavigator{ private final EntityLivingBase pathEntity; private int PathUpdateTicks; private Point3D currentLocation; - private final Random rand; private Point3D lastLocation; private int ticksStuck; private Point3D longRangeWaypoint; @@ -29,7 +28,6 @@ public PathNavigator(EntityLivingBase entity){ currentWaypoint = null; pathData = null; pathIsLongRange = false; - rand = new Random(); } public boolean HasWaypoint(){ @@ -67,9 +65,9 @@ public void GenerateNewRandomWaypoint(World world, Entity entity){ int newX, newY, newZ; for (int i = 0; i < 5; ++i){ - newX = (int)Math.round(pathEntity.posX + (rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); - newY = (int)Math.round(pathEntity.posY + (rand.nextDouble() * 8 - (4))); - newZ = (int)Math.round(pathEntity.posZ + (rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); + newX = (int)Math.round(pathEntity.posX + (world.rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); + newY = (int)Math.round(pathEntity.posY + (world.rand.nextDouble() * 8 - (4))); + newZ = (int)Math.round(pathEntity.posZ + (world.rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); if (world.getBlock(newX, newY, newZ) == Blocks.air && newY > 5){ getEntityLocation(world); @@ -84,9 +82,9 @@ public void GenerateNewRandomWaypoint(World world, Entity entity, int minY, int int newX, newY, newZ; for (int i = 0; i < 5; ++i){ - newX = (int)Math.round(pathEntity.posX + (rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); - newY = (int)Math.round(minY + (rand.nextDouble() * (maxY - minY))); - newZ = (int)Math.round(pathEntity.posZ + (rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); + newX = (int)Math.round(pathEntity.posX + (world.rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); + newY = (int)Math.round(minY + (world.rand.nextDouble() * (maxY - minY))); + newZ = (int)Math.round(pathEntity.posZ + (world.rand.nextDouble() * MaxPathDistance - (MaxPathDistance / 2))); if (world.getBlock(newX, newY, newZ) == Blocks.air && newY > 5){ getEntityLocation(world); diff --git a/src/main/java/am2/particles/AMParticle.java b/src/main/java/am2/particles/AMParticle.java index f3b5b8398..0d97b084e 100644 --- a/src/main/java/am2/particles/AMParticle.java +++ b/src/main/java/am2/particles/AMParticle.java @@ -95,7 +95,7 @@ public boolean isBurning(){ } @Override - protected boolean canTriggerWalking(){ + public boolean canTriggerWalking() { return false; } diff --git a/src/main/java/am2/particles/ParticleArcToEntity.java b/src/main/java/am2/particles/ParticleArcToEntity.java index 4668bc08f..53376a54a 100644 --- a/src/main/java/am2/particles/ParticleArcToEntity.java +++ b/src/main/java/am2/particles/ParticleArcToEntity.java @@ -43,8 +43,8 @@ public ParticleArcToEntity generateControlPoints(){ start.y + ((target.posY - start.y) / 3 * 2), start.z + ((target.posZ - start.z) / 3 * 2)); - double offsetX = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; - double offsetZ = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetX = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetZ = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; AMVector3 offset = new AMVector3(offsetX, 0, offsetZ); diff --git a/src/main/java/am2/particles/ParticleArcToPoint.java b/src/main/java/am2/particles/ParticleArcToPoint.java index de5f008f5..aec72464d 100644 --- a/src/main/java/am2/particles/ParticleArcToPoint.java +++ b/src/main/java/am2/particles/ParticleArcToPoint.java @@ -40,9 +40,9 @@ public ParticleArcToPoint generateControlPoints(){ start.y + ((target.y - start.y) / 3 * 2), start.z + ((target.z - start.z) / 3 * 2)); - double offsetX = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; - double offsetZ = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; - double offsetY = (rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetX = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetZ = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; + double offsetY = (particle.worldObj.rand.nextFloat() * offsetFactor) - halfOffsetFactor; AMVector3 offset = new AMVector3(offsetX, offsetY, offsetZ); diff --git a/src/main/java/am2/particles/ParticleColorShift.java b/src/main/java/am2/particles/ParticleColorShift.java index a51dc8f0d..d2b8cafe9 100644 --- a/src/main/java/am2/particles/ParticleColorShift.java +++ b/src/main/java/am2/particles/ParticleColorShift.java @@ -74,9 +74,9 @@ public ParticleColorShift SetEndOnReachingTargetColor(){ } private void GenerateNextColorTarget(){ - targetRed = (rand.nextFloat() * (maxRed - minRed)) + minRed; - targetGreen = (rand.nextFloat() * (maxGreen - minGreen)) + minGreen; - targetBlue = (rand.nextFloat() * (maxBlue - minBlue)) + minBlue; + targetRed = (particle.worldObj.rand.nextFloat() * (maxRed - minRed)) + minRed; + targetGreen = (particle.worldObj.rand.nextFloat() * (maxGreen - minGreen)) + minGreen; + targetBlue = (particle.worldObj.rand.nextFloat() * (maxBlue - minBlue)) + minBlue; } @Override diff --git a/src/main/java/am2/particles/ParticleController.java b/src/main/java/am2/particles/ParticleController.java index 4e969ccd8..98929fe60 100644 --- a/src/main/java/am2/particles/ParticleController.java +++ b/src/main/java/am2/particles/ParticleController.java @@ -7,7 +7,6 @@ public abstract class ParticleController{ protected AMParticle particle; - protected Random rand; protected int priority; protected boolean exclusive; @@ -29,7 +28,6 @@ public abstract class ParticleController{ public ParticleController(AMParticle particleEffect, int priority, boolean exclusive){ this.particle = particleEffect; - rand = new Random(); this.priority = priority; this.exclusive = exclusive; this.killParticleOnFinish = false; diff --git a/src/main/java/am2/particles/ParticleFloatUpward.java b/src/main/java/am2/particles/ParticleFloatUpward.java index f07eaa31d..c5e3f9646 100644 --- a/src/main/java/am2/particles/ParticleFloatUpward.java +++ b/src/main/java/am2/particles/ParticleFloatUpward.java @@ -21,7 +21,7 @@ public void doUpdate(){ this.finish(); return; } - particle.moveEntity((rand.nextDouble() * jitter) - halfJitter, speed, (rand.nextDouble() * jitter) - halfJitter); + particle.moveEntity((particle.worldObj.rand.nextDouble() * jitter) - halfJitter, speed, (particle.worldObj.rand.nextDouble() * jitter) - halfJitter); } @Override diff --git a/src/main/java/am2/particles/ParticleManagerClient.java b/src/main/java/am2/particles/ParticleManagerClient.java index 6d405ac7b..701c80571 100644 --- a/src/main/java/am2/particles/ParticleManagerClient.java +++ b/src/main/java/am2/particles/ParticleManagerClient.java @@ -26,7 +26,6 @@ public class ParticleManagerClient extends ParticleManagerServer{ public static final byte PKT_BOLT_PT_PT = 63; public static final byte PKT_BEAM_ENT_ENT = 62; public static final byte PKT_BEAM_PT_PT = 61; - private final Random rand = new Random(); private final ParticleRenderer particleRenderer; public ParticleManagerClient(){ @@ -428,15 +427,16 @@ public void spawnAuraParticles(EntityLivingBase ent){ particleQuantity = AMCore.config.getAuraQuantity(); particleSpeed = AMCore.config.getAuraSpeed() / 10; }else{ - particleIndex = ExtendedProperties.For(ent).getAuraIndex(); - particleBehaviour = ExtendedProperties.For(ent).getAuraBehaviour(); - particleScale = ExtendedProperties.For(ent).getAuraScale() / 10; - particleAlpha = ExtendedProperties.For(ent).getAuraAlpha(); - particleDefaultColor = ExtendedProperties.For(ent).getAuraColorDefault(); - particleRandomColor = ExtendedProperties.For(ent).getAuraColorRandomize(); - particleColor = ExtendedProperties.For(ent).getAuraColor(); - particleQuantity = ExtendedProperties.For(ent).getAuraQuantity(); - particleSpeed = ExtendedProperties.For(ent).getAuraSpeed() / 10; + ExtendedProperties entProperties = ExtendedProperties.For(ent); + particleIndex = entProperties.getAuraIndex(); + particleBehaviour = entProperties.getAuraBehaviour(); + particleScale = entProperties.getAuraScale() / 10; + particleAlpha = entProperties.getAuraAlpha(); + particleDefaultColor = entProperties.getAuraColorDefault(); + particleRandomColor = entProperties.getAuraColorRandomize(); + particleColor = entProperties.getAuraColor(); + particleQuantity = entProperties.getAuraQuantity(); + particleSpeed = entProperties.getAuraSpeed() / 10; } if (particleIndex == 31) //fix radiant particle's scaling issues... @@ -446,15 +446,32 @@ public void spawnAuraParticles(EntityLivingBase ent){ if (Minecraft.getMinecraft().thePlayer != ent || Minecraft.getMinecraft().gameSettings.thirdPersonView > 0){ if (AMParticle.particleTypes[particleIndex].startsWith("lightning_bolts")){ int type = Integer.parseInt(new String(new char[]{AMParticle.particleTypes[particleIndex].charAt(AMParticle.particleTypes[particleIndex].length() - 1)})); - if (rand.nextInt(100) < 90){ - BoltFromPointToPoint(ent.worldObj, ent.posX + (rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - ent.height + (rand.nextFloat() * ent.height), ent.posZ + (rand.nextFloat() - 0.5f), ent.posX + (rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - ent.height + (rand.nextFloat() * ent.height), ent.posZ + (rand.nextFloat() - 0.5f), type, -1); + if (ent.worldObj.rand.nextInt(100) < 90){ + BoltFromPointToPoint(ent.worldObj, + ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), + ent.posY + ent.getEyeHeight() - ent.height + (ent.worldObj.rand.nextFloat() * ent.height), + ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f), + ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), + ent.posY + ent.getEyeHeight() - ent.height + (ent.worldObj.rand.nextFloat() * ent.height), + ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f), + type, -1); }else{ - BoltFromPointToPoint(ent.worldObj, ent.posX, ent.posY + ent.getEyeHeight() - 0.4, ent.posZ, ent.posX + (rand.nextFloat() * 10 - 5), ent.posY + (rand.nextFloat() * 10 - 5), ent.posZ + (rand.nextFloat() * 10 - 5), type, -1); + BoltFromPointToPoint(ent.worldObj, + ent.posX, + ent.posY + ent.getEyeHeight() - 0.4, + ent.posZ, + ent.posX + (ent.worldObj.rand.nextFloat() * 10 - 5), + ent.posY + (ent.worldObj.rand.nextFloat() * 10 - 5), + ent.posZ + (ent.worldObj.rand.nextFloat() * 10 - 5), + type, -1); } }else{ int offset = 0; for (int i = 0; i < particleQuantity; ++i){ - AMParticle effect = spawn(ent.worldObj, AMParticle.particleTypes[particleIndex], ent.posX + (rand.nextFloat() - 0.5f), ent.posY + ent.getEyeHeight() - 0.5f + offset - (rand.nextFloat() * 0.5), ent.posZ + (rand.nextFloat() - 0.5f)); + AMParticle effect = spawn(ent.worldObj, AMParticle.particleTypes[particleIndex], + ent.posX + (ent.worldObj.rand.nextFloat() - 0.5f), + ent.posY + ent.getEyeHeight() - 0.5f + offset - (ent.worldObj.rand.nextFloat() * 0.5), + ent.posZ + (ent.worldObj.rand.nextFloat() - 0.5f)); if (effect != null){ effect.setIgnoreMaxAge(false); effect.setMaxAge(40); @@ -463,7 +480,7 @@ public void spawnAuraParticles(EntityLivingBase ent){ effect.noClip = false; if (!particleDefaultColor){ if (particleRandomColor){ - effect.setRGBColorF(rand.nextFloat(), rand.nextFloat(), rand.nextFloat()); + effect.setRGBColorF(ent.worldObj.rand.nextFloat(), ent.worldObj.rand.nextFloat(), ent.worldObj.rand.nextFloat()); }else{ effect.setRGBColorI(particleColor); } @@ -506,7 +523,6 @@ public void spawnAuraParticles(EntityLivingBase ent){ @Override public void spawnBuffParticles(EntityLivingBase entityliving){ - Random rand = new Random(); World world = entityliving.worldObj; if (!world.isRemote) return; @@ -517,10 +533,14 @@ public void spawnBuffParticles(EntityLivingBase entityliving){ for (int i = -radius; i <= radius; ++i){ for (int j = -radius; j <= radius; ++j){ for (int k = -radius; k <= radius; ++k){ - if (entityliving.worldObj.getBlock((int)entityliving.posX + i, (int)entityliving.posY + j, (int)entityliving.posZ + k) == Blocks.air && entityliving.worldObj.getBlockLightValue((int)entityliving.posX + i, (int)entityliving.posY + j, (int)entityliving.posZ + k) <= 7){ - AMParticle effect = spawn(world, "hr_sparkles_1", (int)entityliving.posX - 1 + i + (rand.nextDouble() * 3), (int)entityliving.posY - 1 + j + (rand.nextDouble() * 3), (int)entityliving.posZ - 1 + k + (rand.nextDouble() * 3)); + if (entityliving.worldObj.getBlock((int)entityliving.posX + i, (int)entityliving.posY + j, (int)entityliving.posZ + k) == Blocks.air + && entityliving.worldObj.getBlockLightValue((int)entityliving.posX + i, (int)entityliving.posY + j, (int)entityliving.posZ + k) <= 7){ + AMParticle effect = spawn(world, "hr_sparkles_1", + (int)entityliving.posX - 1 + i + (world.rand.nextDouble() * 3), + (int)entityliving.posY - 1 + j + (world.rand.nextDouble() * 3), + (int)entityliving.posZ - 1 + k + (world.rand.nextDouble() * 3)); if (effect != null){ - effect.setRGBColorF(rand.nextFloat() * 0.4f + 0.3f, 0.6f, rand.nextFloat() * 0.4f + 0.6f); + effect.setRGBColorF(world.rand.nextFloat() * 0.4f + 0.3f, 0.6f, world.rand.nextFloat() * 0.4f + 0.6f); effect.setIgnoreMaxAge(false); effect.setMaxAge(40); effect.AddParticleController(new ParticleFloatUpward(effect, 0.01f, 0.01f, 1, false)); diff --git a/src/main/java/am2/particles/ParticleManagerServer.java b/src/main/java/am2/particles/ParticleManagerServer.java index 1c5d6c5f2..f0ef7c7d8 100644 --- a/src/main/java/am2/particles/ParticleManagerServer.java +++ b/src/main/java/am2/particles/ParticleManagerServer.java @@ -23,7 +23,6 @@ public class ParticleManagerServer{ public static final byte PKT_ARC_PT_PT = 58; public static final byte PKT_ARC_PT_ENT = 57; public static final byte PKT_ARC_ENT_ENT = 56; - private final Random rand = new Random(); public Object spawn(World world, String name, double x, double y, double z){ return null; diff --git a/src/main/java/am2/particles/ParticleOrbitEntity.java b/src/main/java/am2/particles/ParticleOrbitEntity.java index 5156a9230..df4053dd7 100644 --- a/src/main/java/am2/particles/ParticleOrbitEntity.java +++ b/src/main/java/am2/particles/ParticleOrbitEntity.java @@ -22,10 +22,10 @@ public final class ParticleOrbitEntity extends ParticleController{ public ParticleOrbitEntity(AMParticle particleEffect, Entity orbitTarget, double orbitSpeed, int priority, boolean exclusive){ super(particleEffect, priority, exclusive); target = orbitTarget; - orbitAngle = rand.nextInt(360); - rotateClockwise = rand.nextBoolean(); + orbitAngle = particle.worldObj.rand.nextInt(360); + rotateClockwise = particle.worldObj.rand.nextBoolean(); generateNewTargetY(); - targetDistance = 1 + (rand.nextDouble() * 0.5); + targetDistance = 1 + (particle.worldObj.rand.nextDouble() * 0.5); this.orbitSpeed = orbitSpeed; } @@ -41,7 +41,7 @@ public ParticleOrbitEntity SetTargetDistance(double targetDistance){ private void generateNewTargetY(){ if (target != null){ - targetY = (new Random().nextDouble() * target.height); + targetY = particle.worldObj.rand.nextDouble() * target.height; }else{ targetY = 0; } @@ -49,7 +49,7 @@ private void generateNewTargetY(){ private void generateNewDistance(){ if (target != null){ - targetDistance = new Random().nextDouble() * 2; + targetDistance = particle.worldObj.rand.nextDouble() * 2; }else{ targetDistance = 0; } diff --git a/src/main/java/am2/particles/ParticleOrbitPoint.java b/src/main/java/am2/particles/ParticleOrbitPoint.java index 72902409f..4d53d1e41 100644 --- a/src/main/java/am2/particles/ParticleOrbitPoint.java +++ b/src/main/java/am2/particles/ParticleOrbitPoint.java @@ -32,10 +32,10 @@ public CoordStore(double x, double y, double z){ public ParticleOrbitPoint(AMParticle particleEffect, double orbitX, double orbitY, double orbitZ, int priority, boolean exclusive){ super(particleEffect, priority, exclusive); target = new CoordStore(orbitX, orbitY, orbitZ); - orbitAngle = rand.nextInt(360); - rotateClockwise = rand.nextInt(10) < 5; + orbitAngle = particle.worldObj.rand.nextInt(360); + rotateClockwise = particle.worldObj.rand.nextInt(10) < 5; generateNewTargetY(); - targetDistance = 1 + (rand.nextDouble() * 0.5); + targetDistance = 1 + (particle.worldObj.rand.nextDouble() * 0.5); } public ParticleOrbitPoint setOrbitY(double orbitY){ @@ -73,7 +73,7 @@ public ParticleOrbitPoint SetShrinkingOrbit(double shrinkSpeed, double newTarget private void generateNewTargetY(){ if (target != null){ - targetY = (new Random().nextDouble() * 2); + targetY = particle.worldObj.rand.nextDouble() * 2; }else{ targetY = 0; } @@ -81,7 +81,7 @@ private void generateNewTargetY(){ private void generateNewDistance(){ if (target != null){ - targetDistance = new Random().nextDouble() * 2; + targetDistance = particle.worldObj.rand.nextDouble() * 2; }else{ targetDistance = 0; } diff --git a/src/main/java/am2/particles/ParticlePendulum.java b/src/main/java/am2/particles/ParticlePendulum.java index bd06ad73a..0a7457fa6 100644 --- a/src/main/java/am2/particles/ParticlePendulum.java +++ b/src/main/java/am2/particles/ParticlePendulum.java @@ -27,7 +27,7 @@ public ParticlePendulum setStopOnCollide(boolean stop){ } private void generateNewAngle(){ - angle = Math.toRadians(rand.nextInt(360)); + angle = Math.toRadians(particle.worldObj.rand.nextInt(360)); } @Override diff --git a/src/main/java/am2/playerextensions/ExtendedProperties.java b/src/main/java/am2/playerextensions/ExtendedProperties.java index 2fac84fc0..d8947db97 100644 --- a/src/main/java/am2/playerextensions/ExtendedProperties.java +++ b/src/main/java/am2/playerextensions/ExtendedProperties.java @@ -37,7 +37,6 @@ import java.util.ArrayList; import java.util.Iterator; -import java.util.Random; public class ExtendedProperties implements IExtendedProperties, IExtendedEntityProperties{ private EntityLivingBase entity; @@ -415,6 +414,11 @@ public float getPrevShrinkPct(){ return this.prevShrinkPct; } + public void setShrinkPct(float pct){ + this.prevShrinkPct = this.shrinkPct; + this.shrinkPct = pct; + } + public boolean shouldReverseInput(){ return getFlipRotation() > 0 || this.entity.isPotionActive(BuffList.scrambleSynapses.id); } @@ -423,23 +427,6 @@ public AMVector2 getOriginalSize(){ return this.originalSize; } - public void overrideEyeHeight(){ - if (SkillTreeManager.instance.isSkillDisabled(SkillManager.instance.getSkill("Shrink"))) - return; - - if (entity instanceof EntityPlayer){ - float baseEyeHeight = ((EntityPlayer)entity).getDefaultEyeHeight(); - float baseYOffset = entity.worldObj.isRemote ? (entity == AMCore.proxy.getLocalPlayer() ? 1.62f : 0) : 0; - if (entity.isPotionActive(BuffList.shrink)){ - ((EntityPlayer)entity).eyeHeight = baseEyeHeight / 2; - entity.yOffset = baseYOffset / 2; - }else{ - ((EntityPlayer)entity).eyeHeight = baseEyeHeight; - entity.yOffset = baseYOffset; - } - } - } - public boolean getCanHeal(){ return healCooldown <= 0; } @@ -990,7 +977,7 @@ public void init(Entity entity, World world){ updateFlags = 0; - ticksToSync = new Random().nextInt(syncTickDelay); + ticksToSync = world.rand.nextInt(syncTickDelay); hasInitialized = true; } @@ -1037,9 +1024,20 @@ public void addBurnout(float burnout){ burnout *= 0.75f; this.setCurrentFatigue(currentFatigue + burnout); } - + + @Override + public String toString() { + try { + return hashCode() + " " + entity; + } catch(Exception exception) { + return hashCode() + " (error)"; + } + } + public void handleExtendedPropertySync(){ - if (!this.getHasDoneFullSync()) this.setFullSync(); + if (!entity.worldObj.isRemote && !this.getHasDoneFullSync()) { + this.setFullSync(); + } if (!entity.worldObj.isRemote && this.getHasUpdate()){ byte[] data = this.getUpdateData(); @@ -1103,9 +1101,10 @@ public void manaBurnoutTick(){ if (ticksSinceLastRegen >= ticksToRegen){ //mana regeneration - if (getCurrentMana() < getMaxMana()){ + float actualMaxMana = getMaxMana(); + if (getCurrentMana() < actualMaxMana){ if (entity instanceof EntityPlayer && ((EntityPlayer)entity).capabilities.isCreativeMode){ - setCurrentMana(getMaxMana()); + setCurrentMana(actualMaxMana); }else{ if (getCurrentMana() < 0){ setCurrentMana(0); @@ -1150,12 +1149,9 @@ public void manaBurnoutTick(){ } //actual mana regen - float manaToAdd = (getMaxMana() / regenTicks) * ticksSinceLastRegen; + float manaToAdd = (actualMaxMana / regenTicks) * ticksSinceLastRegen; setCurrentMana(getCurrentMana() + manaToAdd); - if (getCurrentMana() > getMaxMana()){ - setCurrentMana(getMaxMana()); - } } } //fatigue decrease @@ -1196,29 +1192,6 @@ else if (!flipped && flipRotation > 0) flipRotation -= 15; } - public void shrinkTick(){ - - if (SkillTreeManager.instance.isSkillDisabled(SkillManager.instance.getSkill("Shrink"))) - return; - - boolean shrunk = getIsShrunk(); - - if (!entity.worldObj.isRemote && shrunk && !entity.isPotionActive(BuffList.shrink)){ - setIsShrunk(false); - return; - }else if (!entity.worldObj.isRemote && !shrunk && entity.isPotionActive(BuffList.shrink)){ - setIsShrunk(true); - return; - } - - prevShrinkPct = shrinkPct; - if (shrunk && shrinkPct < 1f){ - shrinkPct += 0.05f; - }else if (!shrunk && shrinkPct > 0f){ - shrinkPct -= 0.05f; - } - } - public void cleanupManaLinks(){ Iterator it = this.manaLinks.iterator(); while (it.hasNext()){ diff --git a/src/main/java/am2/preloader/AM2PreloaderContainer.java b/src/main/java/am2/preloader/AM2PreloaderContainer.java index 2fb176085..81ec7db0e 100644 --- a/src/main/java/am2/preloader/AM2PreloaderContainer.java +++ b/src/main/java/am2/preloader/AM2PreloaderContainer.java @@ -18,7 +18,8 @@ public class AM2PreloaderContainer extends DummyModContainer implements IFMLLoad private final ModMetadata md = new ModMetadata(); public static boolean foundThaumcraft = false; - public static boolean foundOptifine = false; + private static boolean foundOptiFine = false; + private static boolean confirmedOptiFine = false; public static boolean foundDragonAPI = false; public static boolean isDevEnvironment = false; @@ -46,7 +47,7 @@ public String getName(){ @Override public String getVersion(){ - return "0.0.2"; + return "0.0.3"; } @Override @@ -82,6 +83,8 @@ public String getSetupClass(){ @Override public void injectData(Map data){ + // This is very crude check for mods presence using filename. + // Some mods may refer to others in their name, so we'll to confirm those assumption with class presence check. File loc = (File)data.get("mcLocation"); LogHelper.trace("MC located at: " + loc.getAbsolutePath()); @@ -89,17 +92,21 @@ public void injectData(Map data){ File mcFolder = new File(loc.getAbsolutePath() + File.separatorChar + "mods"); File[] subfiles = mcFolder.listFiles(); - for (File f : subfiles){ - if (f.getName() != null){ - if (f.getName().toLowerCase().contains("thaumcraft")){ - LogHelper.info("Core: Located Thaumcraft"); - foundThaumcraft = true; - }else if (f.getName().toLowerCase().contains("optifine")){ - LogHelper.info("Core: Located Optifine"); - foundOptifine = true; - }else if (f.getName().toLowerCase().contains("dragonapi")){ - LogHelper.info("Core: Located DragonAPI"); - foundDragonAPI = true; + for (File file : subfiles){ + String name = file.getName(); + if (name != null) { + name = name.toLowerCase(); + if (name.endsWith(".jar") || name.endsWith(".zip")){ + if (name.contains("thaumcraft")){ + LogHelper.info("Core: Located Thaumcraft in " + file.getName()); + foundThaumcraft = true; + }else if (name.contains("optifine")){ + LogHelper.info("Core: Located OptiFine in " + file.getName() + ". We'll to confirm that..."); + foundOptiFine = true; + }else if (name.contains("dragonapi")){ + LogHelper.info("Core: Located DragonAPI in " + file.getName()); + foundDragonAPI = true; + } } } } @@ -110,4 +117,27 @@ public String getAccessTransformerClass(){ return null; } + public static boolean isOptiFinePresent(){ + if (!confirmedOptiFine && foundOptiFine){ + // Check presence of OptiFine core classes + try{ + Class.forName("optifine.OptiFineForgeTweaker"); + } + catch (ClassNotFoundException exception1){ + try{ + Class.forName("optifine.OptiFineTweaker"); + } + catch (ClassNotFoundException exception2){ + foundOptiFine = false; + } + } + if (foundOptiFine){ + LogHelper.info("Core: OptiFine presence has been confirmed."); + } else { + LogHelper.info("Core: OptiFine doesn't seem to be there actually."); + } + confirmedOptiFine = true; + } + return foundOptiFine; + } } diff --git a/src/main/java/am2/preloader/BytecodeTransformers.java b/src/main/java/am2/preloader/BytecodeTransformers.java index f3c83407a..8f2e7dc6b 100644 --- a/src/main/java/am2/preloader/BytecodeTransformers.java +++ b/src/main/java/am2/preloader/BytecodeTransformers.java @@ -2,13 +2,12 @@ import am2.LogHelper; import net.minecraft.launchwrapper.IClassTransformer; + import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.Opcodes; import org.objectweb.asm.tree.*; -import org.objectweb.asm.Type; - import java.lang.reflect.Field; import java.util.Iterator; @@ -276,7 +275,7 @@ private byte[] alterEntityRenderer(byte[] bytes, boolean is_obfuscated){ } if (target != null){ - int iRegister = AM2PreloaderContainer.foundOptifine ? 3 : 2; + int iRegister = AM2PreloaderContainer.isOptiFinePresent() ? 3 : 2; VarInsnNode aLoad = new VarInsnNode(Opcodes.ALOAD, 0); VarInsnNode fLoad = new VarInsnNode(Opcodes.FLOAD, 1); @@ -860,7 +859,7 @@ private byte[] alterS1DPacketEntityEffect(byte[] bytes, boolean is_obfuscated, S method3_name.setVal("func_149427_e", false); method3_name.setVal("e", true); - String method3_desc = "()B"; + // String method3_desc = "()B"; String method3_newdesc = "()I"; @@ -1123,7 +1122,6 @@ private byte[] alterS1EPacketRemoveEntityEffect(byte[] bytes, boolean is_obfusca if (mn.name.equals(method1_name.getVal(is_obfuscated)) && mn.desc.equals(method1_desc.getVal(is_obfuscated))){ // readPacketData AbstractInsnNode target = null; - AbstractInsnNode target2 = null; LogHelper.debug("Core: Located target method " + mn.name + mn.desc); Iterator instructions = mn.instructions.iterator(); diff --git a/src/main/java/am2/spell/SpellHelper.java b/src/main/java/am2/spell/SpellHelper.java index ce141b5a4..21e7d0a4e 100644 --- a/src/main/java/am2/spell/SpellHelper.java +++ b/src/main/java/am2/spell/SpellHelper.java @@ -31,6 +31,7 @@ import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; @@ -45,10 +46,7 @@ public class SpellHelper{ public static final SpellHelper instance = new SpellHelper(); - private final Random rand; - private SpellHelper(){ - rand = new Random(); } public SpellCastResult applyStageToGround(ItemStack stack, EntityLivingBase caster, World world, int blockX, int blockY, int blockZ, int blockFace, double impactX, double impactY, double impactZ, int stage, boolean consumeMBR){ @@ -81,7 +79,7 @@ public SpellCastResult applyStageToGround(ItemStack stack, EntityLivingBase cast } } } - component.spawnParticles(world, blockX, blockY, blockZ, caster, caster, rand, color); + component.spawnParticles(world, blockX, blockY, blockZ, caster, caster, world.rand, color); } if (consumeMBR) SpellUtils.instance.doAffinityShift(caster, component, stageShape); @@ -95,6 +93,10 @@ public SpellCastResult applyStageToEntity(ItemStack stack, EntityLivingBase cast ISpellShape stageShape = SpellUtils.instance.getShapeForStage(stack, 0); if (stageShape == null) return SpellCastResult.MALFORMED_SPELL_STACK; + if ((!AMCore.config.getAllowCreativeTargets()) && target instanceof EntityPlayerMP && ((EntityPlayerMP) target).capabilities.isCreativeMode) { + return SpellCastResult.EFFECT_FAILED; + } + ISpellComponent[] components = SpellUtils.instance.getComponentsForStage(stack, 0); boolean appliedOneComponent = false; @@ -118,7 +120,7 @@ public SpellCastResult applyStageToEntity(ItemStack stack, EntityLivingBase cast } } } - component.spawnParticles(world, target.posX, target.posY + target.getEyeHeight(), target.posZ, caster, target, rand, color); + component.spawnParticles(world, target.posX, target.posY + target.getEyeHeight(), target.posZ, caster, target, world.rand, color); } if (shiftAffinityAndXP) SpellUtils.instance.doAffinityShift(caster, component, stageShape); diff --git a/src/main/java/am2/spell/components/Accelerate.java b/src/main/java/am2/spell/components/Accelerate.java index 4ee547e04..f0bdcd89a 100644 --- a/src/main/java/am2/spell/components/Accelerate.java +++ b/src/main/java/am2/spell/components/Accelerate.java @@ -19,14 +19,12 @@ public class Accelerate implements ISpellComponent{ - private final Random rand = new Random(); - @Override public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int blocky, int blockz, int blockFace, double impactX, double impactY, double impactZ, EntityLivingBase caster){ - if (rand.nextDouble() < 0.5){ + if (world.rand.nextDouble() < 0.5){ Block block = world.getBlock(blockx, blocky, blockz); if (block != Blocks.air){ - block.updateTick(world, blocky, blocky, blockz, rand); + block.updateTick(world, blocky, blocky, blockz, world.rand); } } return true; diff --git a/src/main/java/am2/spell/components/Appropriation.java b/src/main/java/am2/spell/components/Appropriation.java index 3107f5d2d..e91fd662b 100644 --- a/src/main/java/am2/spell/components/Appropriation.java +++ b/src/main/java/am2/spell/components/Appropriation.java @@ -1,28 +1,39 @@ package am2.spell.components; import am2.AMCore; +import am2.api.ArsMagicaApi; import am2.api.spell.component.interfaces.ISpellComponent; import am2.api.spell.enums.Affinity; import am2.blocks.BlocksCommonProxy; import am2.items.ItemSpellBook; import am2.particles.AMParticle; import am2.particles.ParticleOrbitPoint; +import am2.playerextensions.ExtendedProperties; import am2.spell.SpellUtils; +import am2.utility.DummyEntityPlayer; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.stats.StatList; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.StatCollector; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.world.BlockEvent.BreakEvent; import java.util.EnumSet; +import java.util.List; import java.util.Random; public class Appropriation implements ISpellComponent{ @@ -51,17 +62,25 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl return false; ItemStack originalSpellStack = getOriginalSpellStack((EntityPlayer)caster); - if (originalSpellStack == null) + if (originalSpellStack == null){ return false; + } + + if (originalSpellStack.stackTagCompound == null){ + return false; + } Block block = world.getBlock(blockx, blocky, blockz); - if (block == null) + if (block == null){ return false; + } - for (String s : AMCore.config.getAppropriationBlockBlacklist()) - if (block.getUnlocalizedName() == s) + for (String s : AMCore.config.getAppropriationBlockBlacklist()){ + if (block.getUnlocalizedName() == s){ return false; + } + } if (!world.isRemote){ if (originalSpellStack.stackTagCompound.hasKey(storageKey)){ @@ -90,18 +109,95 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl } } - if (world.isAirBlock(blockx, blocky, blockz) || !world.getBlock(blockx, blocky, blockz).getMaterial().isSolid()) + if (world.isAirBlock(blockx, blocky, blockz) || !world.getBlock(blockx, blocky, blockz).getMaterial().isSolid()){ + + // save current spell + NBTTagCompound nbt = null; + if (stack.getTagCompound() != null){ + nbt = (NBTTagCompound)stack.getTagCompound().copy(); + } + + + EntityPlayerMP casterPlayer = (EntityPlayerMP)DummyEntityPlayer.fromEntityLiving(caster); + world.captureBlockSnapshots = true; restore((EntityPlayer)caster, world, originalSpellStack, blockx, blocky, blockz, impactX, impactY, impactZ); + world.captureBlockSnapshots = false; + + // save new spell data + NBTTagCompound newNBT = null; + if (stack.getTagCompound() != null){ + newNBT = (NBTTagCompound)stack.getTagCompound().copy(); + } + + net.minecraftforge.event.world.BlockEvent.PlaceEvent placeEvent = null; + List blockSnapshots = (List) world.capturedBlockSnapshots.clone(); + world.capturedBlockSnapshots.clear(); + + // restore original item data for event + if (nbt != null){ + stack.setTagCompound(nbt); + } + if (blockSnapshots.size() > 1){ + placeEvent = ForgeEventFactory.onPlayerMultiBlockPlace(casterPlayer, blockSnapshots, ForgeDirection.UNKNOWN); + } else if (blockSnapshots.size() == 1){ + placeEvent = ForgeEventFactory.onPlayerBlockPlace(casterPlayer, blockSnapshots.get(0), ForgeDirection.UNKNOWN); + } + + if (placeEvent != null && (placeEvent.isCanceled())){ + // revert back all captured blocks + for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots){ + world.restoringBlockSnapshots = true; + blocksnapshot.restore(true, false); + world.restoringBlockSnapshots = false; + } + return false; + } else { + // Change the stack to its new content + if (nbt != null){ + stack.setTagCompound(newNBT); + } + + for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots){ + int blockX = blocksnapshot.x; + int blockY = blocksnapshot.y; + int blockZ = blocksnapshot.z; + int metadata = world.getBlockMetadata(blockX, blockY, blockZ); + int updateFlag = blocksnapshot.flag; + Block oldBlock = blocksnapshot.replacedBlock; + Block newBlock = world.getBlock(blockX, blockY, blockZ); + if (newBlock != null && !(newBlock.hasTileEntity(metadata))){ // Containers get placed automatically + newBlock.onBlockAdded(world, blockX, blockY, blockZ); + } + + world.markAndNotifyBlock(blockX, blockY, blockZ, null, oldBlock, newBlock, updateFlag); + } + } + world.capturedBlockSnapshots.clear(); + + // restore((EntityPlayer)caster, world, originalSpellStack, blockx, blocky, blockz, impactX, impactY, impactZ); + } }else{ - if (block == null || block.getBlockHardness(world, blockx, blocky, blockz) == -1.0f) + if (block == null || block.getBlockHardness(world, blockx, blocky, blockz) == -1.0f){ return false; + } NBTTagCompound data = new NBTTagCompound(); data.setString(storageType, "block"); //data.setString("blockName", block.getUnlocalizedName().replace("tile.", "")); data.setInteger("blockID", Block.getIdFromBlock(block)); - data.setInteger("meta", world.getBlockMetadata(blockx, blocky, blockz)); + int meta = world.getBlockMetadata(blockx, blocky, blockz); + data.setInteger("meta", meta); + + EntityPlayerMP casterPlayer = (EntityPlayerMP)DummyEntityPlayer.fromEntityLiving(caster); + if (!ForgeEventFactory.doPlayerHarvestCheck(casterPlayer, block, true)){ + return false; + } + + BreakEvent event = ForgeHooks.onBlockBreakEvent(world, casterPlayer.theItemInWorldManager.getGameType(), casterPlayer, blockx, blocky, blockz); + if (event.isCanceled()){ + return false; + } TileEntity te = world.getTileEntity(blockx, blocky, blockz); if (te != null){ @@ -109,12 +205,11 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl te.writeToNBT(teData); data.setTag("tileEntity", teData); - //essentially reset the tile entity before destroying the block - this corrects several issues such as inventory items dropping - //we don't want this as the inventory items are already saved in the NBT! + // remove tile entity first to prevent content dropping which is already saved in the NBT try{ - world.setTileEntity(blockx, blocky, blockz, te.getClass().newInstance()); - }catch (Throwable e){ - e.printStackTrace(); + world.removeTileEntity(blockx, blocky, blockz); + }catch (Throwable exception){ + exception.printStackTrace(); } } diff --git a/src/main/java/am2/spell/components/Blink.java b/src/main/java/am2/spell/components/Blink.java index 19308b6d0..8fe13c4cf 100644 --- a/src/main/java/am2/spell/components/Blink.java +++ b/src/main/java/am2/spell/components/Blink.java @@ -53,8 +53,6 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase double d = motionX, d1 = motionY, d2 = motionZ; - Random rand = new Random(); - float f2 = MathHelper.sqrt_double(d * d + d1 * d1 + d2 * d2); d /= f2; d1 /= f2; @@ -235,8 +233,6 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase } - Random rnd = new Random(); - if (world.isRemote && astralBarrierBlocked && coordsValid){ ExtendedProperties.For((EntityLivingBase)target).astralBarrierBlocked = true; if (finalBlocker != null){ diff --git a/src/main/java/am2/spell/components/Dig.java b/src/main/java/am2/spell/components/Dig.java index 4b8a65075..f1c1cbdc6 100644 --- a/src/main/java/am2/spell/components/Dig.java +++ b/src/main/java/am2/spell/components/Dig.java @@ -78,21 +78,21 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl int miningLevel = 2 + SpellUtils.instance.countModifiers(SpellModifiers.MINING_POWER, stack, 0); if (harvestLevel > miningLevel) return false; - if (ForgeEventFactory.doPlayerHarvestCheck(DummyEntityPlayer.fromEntityLiving(caster), block, true)){ + EntityPlayer casterPlayer = DummyEntityPlayer.fromEntityLiving(caster); + if (ForgeEventFactory.doPlayerHarvestCheck(casterPlayer, block, true)){ float xMana = block.getBlockHardness(world, blockx, blocky, blockz) * hardnessManaFactor; float xBurnout = ArsMagicaApi.instance.getBurnoutFromMana(xMana); if (!world.isRemote){ - EntityPlayerMP casterPlayer = (EntityPlayerMP)DummyEntityPlayer.fromEntityLiving(caster); - BreakEvent event = ForgeHooks.onBlockBreakEvent(world, casterPlayer.theItemInWorldManager.getGameType(), casterPlayer, blockx, blocky, blockz); + BreakEvent event = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP)casterPlayer).theItemInWorldManager.getGameType(), (EntityPlayerMP)casterPlayer, blockx, blocky, blockz); if (event.isCanceled()){ return false; } - block.onBlockHarvested(world, blockx, blocky, blockz, meta, DummyEntityPlayer.fromEntityLiving(caster)); - boolean flag = block.removedByPlayer(world, DummyEntityPlayer.fromEntityLiving(caster), blockx, blocky, blockz, true); + block.onBlockHarvested(world, blockx, blocky, blockz, meta, casterPlayer); + boolean flag = block.removedByPlayer(world, casterPlayer, blockx, blocky, blockz, true); if(flag){ block.onBlockDestroyedByPlayer(world, blockx, blocky, blockz, meta); - block.harvestBlock(world, DummyEntityPlayer.fromEntityLiving(caster), blockx, blocky, blockz, meta); + block.harvestBlock(world, casterPlayer, blockx, blocky, blockz, meta); } } diff --git a/src/main/java/am2/spell/components/Disarm.java b/src/main/java/am2/spell/components/Disarm.java index b72242481..6a1201f43 100644 --- a/src/main/java/am2/spell/components/Disarm.java +++ b/src/main/java/am2/spell/components/Disarm.java @@ -45,7 +45,7 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase if (target instanceof EntityLightMage || target instanceof EntityDarkMage) return false; - if (target instanceof EntityPlayer && (!AMCore.config.getDisarmAffectsPlayers() || !MinecraftServer.getServer().isPVPEnabled())) + if (target instanceof EntityPlayer && (!AMCore.config.getDisarmAffectsPlayers() || (!world.isRemote && !MinecraftServer.getServer().isPVPEnabled()))) return false; if (target instanceof EntityPlayer && ((EntityPlayer)target).getHeldItem() != null && !target.worldObj.isRemote){ diff --git a/src/main/java/am2/spell/components/Entangle.java b/src/main/java/am2/spell/components/Entangle.java index 8a060c79c..a8de2efaa 100644 --- a/src/main/java/am2/spell/components/Entangle.java +++ b/src/main/java/am2/spell/components/Entangle.java @@ -33,7 +33,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl @Override public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target){ if (target instanceof EntityLivingBase){ - int duration = SpellUtils.instance.getModifiedInt_Mul(BuffList.default_buff_duration, stack, caster, target, world, 0, SpellModifiers.DURATION); + int duration = 140 + SpellUtils.instance.getModifiedInt_Mul(BuffList.default_buff_duration / 10, stack, caster, target, world, 0, SpellModifiers.DURATION); duration = SpellUtils.instance.modifyDurationBasedOnArmor(caster, duration); int x = (int)Math.floor(target.posX); @@ -58,7 +58,7 @@ public float manaCost(EntityLivingBase caster){ @Override public float burnout(EntityLivingBase caster){ - return ArsMagicaApi.instance.getBurnoutFromMana(manaCost(caster)); + return ArsMagicaApi.instance.getBurnoutFromMana(manaCost(caster)) * 4; } @Override diff --git a/src/main/java/am2/spell/components/Grow.java b/src/main/java/am2/spell/components/Grow.java index 866986dd0..3fb9257eb 100644 --- a/src/main/java/am2/spell/components/Grow.java +++ b/src/main/java/am2/spell/components/Grow.java @@ -32,7 +32,6 @@ public class Grow implements ISpellComponent{ - private final Random random = new Random(); private final static ArrayList growableAMflowers = new ArrayList(Arrays.asList( BlocksCommonProxy.cerublossom, BlocksCommonProxy.desertNova, BlocksCommonProxy.wakebloom, BlocksCommonProxy.aum, BlocksCommonProxy.tarmaRoot)); @@ -50,7 +49,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl } //EoD: Spawn AM2 flowers with 3% chance. This has to be the first one in the list to override all others - if (random.nextInt(100) < 3 && block.isNormalCube() && + if (world.rand.nextInt(100) < 3 && block.isNormalCube() && (world.getBlock(blockx, blocky + 1, blockz).isAir(null, 0, 0, 0) || world.getBlock(blockx, blocky + 1, blockz) == Blocks.tallgrass)){ // shuffle the flower list every time we want to try to find one. Collections.shuffle(growableAMflowers); @@ -68,7 +67,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl //Grow huge mushrooms 10% of the time. if (block instanceof BlockMushroom){ - if (!world.isRemote && random.nextInt(10) < 1){ + if (!world.isRemote && world.rand.nextInt(10) < 1){ ((BlockMushroom)block).func_149884_c(world, blockx, blocky, blockz, world.rand); } @@ -79,7 +78,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl //If the spell is executed in water, check if we have space for a wakebloom above and create one 3% of the time. if (block == Blocks.water){ if (world.getBlock(blockx, blocky + 1, blockz) == Blocks.air){ - if (!world.isRemote && random.nextInt(100) < 3){ + if (!world.isRemote && world.rand.nextInt(100) < 3){ world.setBlock(blockx, blocky + 1, blockz, BlocksCommonProxy.wakebloom); } return true; @@ -89,7 +88,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl //EoD: If there is already tallgrass present, let's grow it further 20% of the time. if (block == Blocks.tallgrass){ if (Blocks.tallgrass.canBlockStay(world, blockx, blocky + 1, blockz)){ - if (!world.isRemote && random.nextInt(10) < 2){ + if (!world.isRemote && world.rand.nextInt(10) < 2){ world.setBlock(blockx, blocky, blockz, Blocks.tallgrass, 1, 2); } return true; @@ -100,7 +99,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl // This works only on podzol in vanilla MC. if (block == Blocks.deadbush){ if (Blocks.tallgrass.canBlockStay(world, blockx, blocky, blockz)){ - if (!world.isRemote && random.nextInt(10) < 2){ + if (!world.isRemote && world.rand.nextInt(10) < 2){ world.setBlock(blockx, blocky, blockz, Blocks.tallgrass, 1, 2); } return true; @@ -114,7 +113,7 @@ public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int bl //AMCore.log.getLogger().info("Grow component found IGrowable"); if (igrowable.func_149851_a(world, blockx, blocky, blockz, world.isRemote)){ - if (!world.isRemote && random.nextInt(10) < 3){ + if (!world.isRemote && world.rand.nextInt(10) < 3){ if (igrowable.func_149852_a(world, world.rand, blockx, blocky, blockz)){ igrowable.func_149853_b(world, world.rand, blockx, blocky, blockz); } diff --git a/src/main/java/am2/spell/components/LifeTap.java b/src/main/java/am2/spell/components/LifeTap.java index 132c88d3e..b55c26ede 100644 --- a/src/main/java/am2/spell/components/LifeTap.java +++ b/src/main/java/am2/spell/components/LifeTap.java @@ -56,11 +56,12 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase if (!(target instanceof EntityLivingBase)) return false; if (!world.isRemote){ double damage = SpellUtils.instance.getModifiedDouble_Mul(2, stack, caster, target, world, 0, SpellModifiers.DAMAGE); - float manaRefunded = (float)(((damage * 0.01)) * ExtendedProperties.For(caster).getMaxMana()); + ExtendedProperties casterProperties = ExtendedProperties.For(caster); + float manaRefunded = (float)(((damage * 0.01)) * casterProperties.getMaxMana()); if ((caster).attackEntityFrom(DamageSource.outOfWorld, (int)Math.floor(damage))){ - ExtendedProperties.For(caster).setCurrentMana(Math.min(ExtendedProperties.For(caster).getCurrentMana() + manaRefunded, ExtendedProperties.For(caster).getMaxMana())); - ExtendedProperties.For(caster).forceSync(); + casterProperties.setCurrentMana(casterProperties.getCurrentMana() + manaRefunded); + casterProperties.forceSync(); }else{ return false; } diff --git a/src/main/java/am2/spell/components/ManaDrain.java b/src/main/java/am2/spell/components/ManaDrain.java index 781843b27..3438086b4 100644 --- a/src/main/java/am2/spell/components/ManaDrain.java +++ b/src/main/java/am2/spell/components/ManaDrain.java @@ -28,13 +28,15 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase if (!(target instanceof EntityLivingBase)) return false; double manaStolen = 250; - if (manaStolen > ExtendedProperties.For((EntityLivingBase)target).getCurrentMana()){ - manaStolen = ExtendedProperties.For((EntityLivingBase)target).getCurrentMana(); + ExtendedProperties targetProperties = ExtendedProperties.For((EntityLivingBase)target); + if (manaStolen > targetProperties.getCurrentMana()){ + manaStolen = targetProperties.getCurrentMana(); } - ExtendedProperties.For((EntityLivingBase)target).setCurrentMana((float)(ExtendedProperties.For((EntityLivingBase)target).getCurrentMana() - manaStolen)); - ExtendedProperties.For((EntityLivingBase)target).forceSync(); - ExtendedProperties.For(caster).setCurrentMana((float)(ExtendedProperties.For(caster).getCurrentMana() + manaStolen)); - ExtendedProperties.For(caster).forceSync(); + targetProperties.setCurrentMana((float)(targetProperties.getCurrentMana() - manaStolen)); + targetProperties.forceSync(); + ExtendedProperties casterProperties = ExtendedProperties.For(caster); + casterProperties.setCurrentMana((float)(casterProperties.getCurrentMana() + manaStolen)); + casterProperties.forceSync(); return true; } diff --git a/src/main/java/am2/spell/components/RandomTeleport.java b/src/main/java/am2/spell/components/RandomTeleport.java index 74588cc5e..4d4c396b7 100644 --- a/src/main/java/am2/spell/components/RandomTeleport.java +++ b/src/main/java/am2/spell/components/RandomTeleport.java @@ -23,8 +23,6 @@ public class RandomTeleport implements ISpellComponent{ - private final Random rand = new Random(); - @Override public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int blocky, int blockz, int blockFace, double impactX, double impactY, double impactZ, EntityLivingBase caster){ return false; @@ -40,7 +38,7 @@ private AMVector3 getRandomTeleportLocation(World world, ItemStack stack, Entity AMVector3 origin = new AMVector3(target); float maxDist = 9; maxDist = (float)SpellUtils.instance.getModifiedDouble_Mul(maxDist, stack, caster, target, world, 0, SpellModifiers.RANGE); - origin.add(new AMVector3((rand.nextDouble() - 0.5) * maxDist, (rand.nextDouble() - 0.5) * maxDist, (rand.nextDouble() - 0.5) * maxDist)); + origin.add(new AMVector3((world.rand.nextDouble() - 0.5) * maxDist, (world.rand.nextDouble() - 0.5) * maxDist, (world.rand.nextDouble() - 0.5) * maxDist)); return origin; } @@ -114,7 +112,7 @@ public ItemStack[] reagents(EntityLivingBase caster){ @Override public void spawnParticles(World world, double x, double y, double z, EntityLivingBase caster, Entity target, Random rand, int colorModifier){ - world.spawnParticle("portal", target.posX + (this.rand.nextDouble() - 0.5D) * target.width, target.posY + this.rand.nextDouble() * target.height - 0.25D, target.posZ + (this.rand.nextDouble() - 0.5D) * target.width, (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(), (this.rand.nextDouble() - 0.5D) * 2.0D); + world.spawnParticle("portal", target.posX + (rand.nextDouble() - 0.5D) * target.width, target.posY + rand.nextDouble() * target.height - 0.25D, target.posZ + (rand.nextDouble() - 0.5D) * target.width, (rand.nextDouble() - 0.5D) * 2.0D, -rand.nextDouble(), (rand.nextDouble() - 0.5D) * 2.0D); } @Override diff --git a/src/main/java/am2/spell/components/Recall.java b/src/main/java/am2/spell/components/Recall.java index a5223a24d..4c237ca20 100644 --- a/src/main/java/am2/spell/components/Recall.java +++ b/src/main/java/am2/spell/components/Recall.java @@ -62,19 +62,18 @@ public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase return handleRitualReagents(ritualRunes, world, x, y, z, caster, target); } - if (!ExtendedProperties.For(caster).getMarkSet()){ + ExtendedProperties casterProperties = ExtendedProperties.For(caster); + if (!casterProperties.getMarkSet()){ if (caster instanceof EntityPlayer && !world.isRemote) ((EntityPlayer)caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.noMark"))); return false; - }else if (ExtendedProperties.For(caster).getMarkDimension() != caster.dimension){ + }else if (casterProperties.getMarkDimension() != caster.dimension){ if (caster instanceof EntityPlayer && !world.isRemote) ((EntityPlayer)caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.diffDimMark"))); return false; } if (!world.isRemote){ - ((EntityLivingBase)target).setPositionAndUpdate(ExtendedProperties - .For(caster).getMarkX(), ExtendedProperties.For(caster) - .getMarkY(), ExtendedProperties.For(caster).getMarkZ()); + ((EntityLivingBase)target).setPositionAndUpdate(casterProperties.getMarkX(), casterProperties.getMarkY(), casterProperties.getMarkZ()); } return true; } diff --git a/src/main/java/am2/spell/components/Storm.java b/src/main/java/am2/spell/components/Storm.java index 119a489c8..78b4242dc 100644 --- a/src/main/java/am2/spell/components/Storm.java +++ b/src/main/java/am2/spell/components/Storm.java @@ -24,8 +24,6 @@ public class Storm implements ISpellComponent{ - private final Random rand = new Random(); - @Override public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int blocky, int blockz, int blockFace, double impactX, double impactY, double impactZ, EntityLivingBase caster){ applyEffect(caster, world); @@ -43,10 +41,10 @@ private void applyEffect(EntityLivingBase caster, World world){ if (rainStrength > 0.9D){ if (!world.isRemote){ int xzradius = 50; - int random = rand.nextInt(100); + int random = world.rand.nextInt(100); if (random < 20){ - int randPosX = (int)caster.posX + rand.nextInt(xzradius * 2) - xzradius; - int randPosZ = (int)caster.posZ + rand.nextInt(xzradius * 2) - xzradius; + int randPosX = (int)caster.posX + world.rand.nextInt(xzradius * 2) - xzradius; + int randPosZ = (int)caster.posZ + world.rand.nextInt(xzradius * 2) - xzradius; int posY = (int)caster.posY; while (!world.canBlockSeeTheSky(randPosX, posY, randPosZ)){ @@ -63,7 +61,7 @@ private void applyEffect(EntityLivingBase caster, World world){ if (entities.size() <= 0){ return; } - Entity target = entities.get(rand.nextInt(entities.size())); + Entity target = entities.get(world.rand.nextInt(entities.size())); if (target != null && world.canBlockSeeTheSky((int)target.posX, (int)target.posY, (int)target.posZ)){ if (caster instanceof EntityPlayer){ target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)caster), 1); diff --git a/src/main/resources/assets/arsmagica2/lang/en_US.lang b/src/main/resources/assets/arsmagica2/lang/en_US.lang index 17b1fbaca..792083b22 100644 --- a/src/main/resources/assets/arsmagica2/lang/en_US.lang +++ b/src/main/resources/assets/arsmagica2/lang/en_US.lang @@ -400,6 +400,9 @@ am2.spell.manaregenii=Mana Regen II am2.spell.manaregeniii=Mana Regen III am2.spell.spellmotion=Spell Motion +am2.spell.nauseate=Nauseate +am2.spell.scramblesynapses=Scramble synapses + #tooltips am2.tooltip.air_sled=§3Fly through the air with the greatest of ease...§f am2.tooltip.approError=Something went wrong restoring the block. This spell was likely a spell from an older version. The stored block has been cleared to prevent a crash, and the spell should work moving forward. Sorry! @@ -515,7 +518,14 @@ am2.tooltip.wrongWrenchMode=The wrench isn't in the right mode to interact with am2.tooltip.wtrbrth=Water Breathing am2.tooltip.wtrwalk=Water Walking -key.activateAffinityAbility=Affinity Ability +# Control keys +key.am2.category=ArsMagica2 +key.ActivateAffinityAbility=Activate affinity ability +key.AuraCustomization=Aura customization +key.ShapeGroups=Shape groups +key.SpellBookNext=Spell book, Next +key.SpellBookPrev=Spell book, Previous +key.ToggleManaDisplay=Toggle mana display #guis am2.gui.Affinity=Affinity diff --git a/src/main/resources/assets/arsmagica2/lang/ru_RU.lang b/src/main/resources/assets/arsmagica2/lang/ru_RU.lang index bb418b460..31bd897bd 100644 --- a/src/main/resources/assets/arsmagica2/lang/ru_RU.lang +++ b/src/main/resources/assets/arsmagica2/lang/ru_RU.lang @@ -374,7 +374,7 @@ am2.spell.targetnonsolid=Цель: Нетвёрдые блоки am2.spell.velocityadded=Добавление скорости am2.spell.affinitygains=Сродство даёт усиление -am2.spell.augmentedcasting=Augmented Casting +am2.spell.augmentedcasting=Улучшенное литьё am2.spell.extrasummon=Дополнительный призыв am2.spell.magebandi=Поиск маны I am2.spell.magebandii=Поиск маны II @@ -604,56 +604,56 @@ am2.npc.partyrefuse=Вы должны стать более сильным, пр #affinity effect descriptions ##air -am2.affinity.agile=Agile -am2.affinity.lightasafeather=Light as a Feather +am2.affinity.agile=Проворство +am2.affinity.lightasafeather=Перо это свет ##arcane -am2.affinity.clearcaster=Clearcaster -am2.affinity.magicweakness=Magic Weakness -am2.affinity.onewithmagic=Magical Focus +am2.affinity.clearcaster=Чистая аура +am2.affinity.magicweakness=Магическая слабость +am2.affinity.onewithmagic=Сфокусирование магии ##earth -am2.affinity.solidbones=Solid Bones -am2.affinity.stoneskin=Stone Skin +am2.affinity.solidbones=Твёрдые Кости +am2.affinity.stoneskin=Каменная Кожа ##ender -am2.affinity.darkvision=Darkvision -am2.affinity.poisonresistance=Resistant to Poison -am2.affinity.sunlightweakness=Weakness to Sunlight -am2.affinity.waterweakness=Weakness to Water +am2.affinity.darkvision=Темновидиние +am2.affinity.poisonresistance=Устойчивость к яду +am2.affinity.sunlightweakness=Устойчивость к солнечному свету +am2.affinity.waterweakness=Устойчивость к воде ##fire -am2.affinity.firepunch=Fire Punch -am2.affinity.fireresistance=Resistant to Fire -am2.affinity.waterweakness=Weakness to Water +am2.affinity.firepunch=Огненный шлепок +am2.affinity.fireresistance=Слабость к Огню +am2.affinity.waterweakness=Слабость к воде ##ice -am2.affinity.coldblooded=Cold Blooded -am2.affinity.lavafreeze=Frozen Footsteps (Lava) -am2.affinity.waterfreeze=Frozen Footsteps (Water) +am2.affinity.coldblooded=Окровлённый холод +am2.affinity.lavafreeze=Замороженные Шаги (Лава) +am2.affinity.waterfreeze=Замороженные шаги (Вода) ##life -am2.affinity.fasthealing=Fast Healing -am2.affinity.pacifist=Pacifist +am2.affinity.fasthealing=Быстрое лечение +am2.affinity.pacifist=Пацифист ##water -am2.affinity.antiendermen=Endermen-Repellant -am2.affinity.expandedlungs=Expanded Lungs -am2.affinity.fireweakness=Fire Weakness -am2.affinity.fluidity=Fluidity -am2.affinity.swiftswim=Swift Swimmer +am2.affinity.antiendermen=Эндерман-откидывание +am2.affinity.expandedlungs=Расширенная лёгкость +am2.affinity.fireweakness=Слабость к огню +am2.affinity.fluidity=Текучесть +am2.affinity.swiftswim=Быстрое лето ##nature -am2.affinity.harvester=Harvester -am2.affinity.photosynthesis=Photosynthesis -am2.affinity.rooted=Rooted -am2.affinity.thorns=Thorns Aura +am2.affinity.harvester=Комбайн +am2.affinity.photosynthesis=Фотосинтез +am2.affinity.rooted=Коренноый +am2.affinity.thorns=Шыпастая аура ##lightning -am2.affinity.fulmination=Fulmination -am2.affinity.reflexes=Lightning Reflexes -am2.affinity.shortcircuit=Short Circuit -am2.affinity.thunderpunch=Thunderpunch +am2.affinity.fulmination=Инициированный врзыр +am2.affinity.reflexes=Рефлекты света +am2.affinity.shortcircuit=Короткая схема +am2.affinity.thunderpunch=Громовой шлепок #achievements diff --git a/src/main/resources/assets/arsmagica2/lang/zh_CN.lang b/src/main/resources/assets/arsmagica2/lang/zh_CN.lang index f83e72017..f5bf30004 100644 --- a/src/main/resources/assets/arsmagica2/lang/zh_CN.lang +++ b/src/main/resources/assets/arsmagica2/lang/zh_CN.lang @@ -6,6 +6,7 @@ item.arsmagica2:FlickerFocusPrefix=闪烁核心: %s item.arsmagica2:FlickerOperatorButchery.name=屠宰场 item.arsmagica2:FlickerOperatorContainment.name=蕴含 item.arsmagica2:FlickerOperatorFelledOak.name=倒下的橡木 +item.arsmagica2:FlickerOperatorFishing.name=鱼满舱 item.arsmagica2:FlickerOperatorFlatLands.name=大地平坦 item.arsmagica2:FlickerOperatorGentleRains.name=和风细雨 item.arsmagica2:FlickerOperatorInterdiction.name=禁制 @@ -74,6 +75,9 @@ item.arsmagica2:helmet_mage.name=法师头巾 item.arsmagica2:highEssenceCore.name=高级源质核心 item.arsmagica2:iceEssence.name=寒冰源质 item.arsmagica2:infinityOrb.name=无限之球 +item.arsmagica2:inscup_1.name=符文拓印台1阶升级 +item.arsmagica2:inscup_2.name=符文拓印台2阶升级 +item.arsmagica2:inscup_3.name=符文拓印台3阶升级 item.arsmagica2:item_focus.name=物品核心 item.arsmagica2:keystone.name=楔石 item.arsmagica2:keystoneDoor.name=楔石之门 @@ -87,7 +91,7 @@ item.arsmagica2:lightBlueRune.name=浅蓝色符文 item.arsmagica2:lightGrayRune.name=浅灰色符文 item.arsmagica2:lightningEssence.name=雷霆源质 item.arsmagica2:lightningcharm.name=§6闪电魔咒§f -item.arsmagica2:limeRune.name=柠檬色符文 +item.arsmagica2:limeRune.name=黄绿色符文 item.arsmagica2:liquidEssenceBucket.name=液态源质桶 item.arsmagica2:magentaRune.name=品红色符文 item.arsmagica2:magic_broom.name=魔法扫帚 @@ -95,6 +99,7 @@ item.arsmagica2:magitechGoggles.name=奥术护目镜 item.arsmagica2:manaScepter.name=魔杖 item.arsmagica2:mana_boost_potion.name=蕴魔源质药水 item.arsmagica2:mana_cake.name=魔力蛋糕 +item.arsmagica2:mana_martini.name=魔力马天尼 item.arsmagica2:mana_potion_epic.name=史诗魔力药水 item.arsmagica2:mana_potion_greater.name=卓越魔力药水 item.arsmagica2:mana_potion_legendary.name=传奇魔力药水 @@ -130,6 +135,7 @@ item.arsmagica2:sigil_naturesbounty=自然的馈赠 item.arsmagica2:sigil_packedearth=壅塞大地 item.arsmagica2:sigil_progeny=后裔 item.arsmagica2:spellBook.name=法术书 +item.arsmagica2:spellSealedDoor.name=咒封之门 item.arsmagica2:spell_parchment.name=法术卷轴 item.arsmagica2:spell_staff_journeyman.name=学徒魔杖 item.arsmagica2:spell_staff_magitech.name=奥术魔杖 @@ -161,19 +167,21 @@ tile.arsmagica2:blockastralbarrier.name=星界屏障 tile.arsmagica2:blockcaster.name=施术台 tile.arsmagica2:blockkeystonerecepticle.name=楔石插槽 tile.arsmagica2:blockseerstone.name=占卜之眼 -tile.arsmagica2:blue_orchid.name=万代兰 tile.arsmagica2:brokenLink.name=破损能量链接 tile.arsmagica2:calefactor.name=魔力炉 tile.arsmagica2:candle.name=守护蜡烛 tile.arsmagica2:casterRune.name=施术台符文 tile.arsmagica2:celestialprism.name=仙域棱镜 +tile.arsmagica2:cerublossom.name=万代兰 tile.arsmagica2:crystalMarker.cm_export.name=导出水晶 +tile.arsmagica2:crystalMarker.cm_final.name=终末导出水晶 tile.arsmagica2:crystalMarker.cm_import.name=导入水晶 tile.arsmagica2:crystalMarker.cm_likeExport.name=伪装导出水晶 tile.arsmagica2:crystalMarker.cm_regulateExport.name=调校导出水晶 tile.arsmagica2:crystalMarker.cm_regulateMulti.name=调校双向水晶 tile.arsmagica2:crystalMarker.cm_setExport.name=设置导出水晶 tile.arsmagica2:crystalMarker.cm_setImport.name=设置导入水晶 +tile.arsmagica2:crystalMarker.cm_spellExport.name=法术导出水晶 tile.arsmagica2:crystalpillar.name=水晶柱 tile.arsmagica2:desert_nova.name=沙漠新星 tile.arsmagica2:essence_refiner.name=源质提炼机 @@ -187,9 +195,12 @@ tile.arsmagica2:illusionBlock.nobarrier.name=天域幻象方块 tile.arsmagica2:inertSpawner.name=惰性刷怪笼 tile.arsmagica2:inscriptionTable.name=符文拓印台 tile.arsmagica2:iron_inlay.name=黑铁镶嵌物 +tile.arsmagica2:keystoneDoor.name=楔石门 tile.arsmagica2:keystoneTrapdoor.name=楔石陷阱门 tile.arsmagica2:keystonechest.name=楔石箱子 tile.arsmagica2:lectern.name=讲坛 +tile.arsmagica2:liquidEssence.name=液态乙金 +tile.arsmagica2:magetorch.name=魔导之光 tile.arsmagica2:magicWall.name=魔力屏障 tile.arsmagica2:magic_sigil.name=徽记底座 tile.arsmagica2:magiciansWorkbench.name=巫师工作台 @@ -206,6 +217,7 @@ tile.arsmagica2:ores.6.name=温特姆方块 tile.arsmagica2:ores.7.name=蓝晶石方块 tile.arsmagica2:ores.8.name=太阳石方块 tile.arsmagica2:ores.9.name=精灵石矿石 +tile.arsmagica2:otherworld_aura.name=异世界灵气 tile.arsmagica2:particleEmitter.name=粒子效果发生器 tile.arsmagica2:planksWitchwood.name=巫魂树木板 tile.arsmagica2:redstone_inlay.name=红石镶嵌物 @@ -223,6 +235,9 @@ tile.arsmagica2:witchwoodleaves.name=巫魂树树叶 tile.arsmagica2:witchwoodlog.name=巫魂树原木 tile.arsmagica2:wizardchalk.name=巫师粉笔符文 +#fluids +fluid.liquidEssence=液态乙金 + #entities entity.arsmagica2.BattleChicken.name=战斗鸡 entity.arsmagica2.BossAirGuardian.name=风之守卫者 @@ -236,6 +251,7 @@ entity.arsmagica2.BossNatureGuardian.name=自然守卫者 entity.arsmagica2.BossTowerGuardian.name=法师塔守卫者 entity.arsmagica2.BossWaterGuardian.name=水之守卫者 entity.arsmagica2.BossWinterGuardian.name=冬之守卫者 +entity.arsmagica2.DaBroom.name=魔法扫帚 entity.arsmagica2.EarthElemental.name=地之元素 entity.arsmagica2.Flicker.name=闪烁妖精 entity.arsmagica2.HellCow.name=深渊牛 @@ -257,7 +273,7 @@ am2.spell.validate.compMiss=至少需要一种复合物作为施法材料. am2.spell.validate.principum=为正确施术是否需要在其后添加规则形态以及目标形态.参阅巫师宝典以获得详细信息. am2.spell.validate.terminus=是否在其后添加的终端形态或者任何其他形态不会被执行.参阅巫师宝典以获得详细信息. -am2.spell.aoe=AOE法术 +am2.spell.aoe=范围法术 am2.spell.beam=束状法术 am2.spell.binding=具现化法术 am2.spell.chain=链状法术 @@ -385,6 +401,7 @@ am2.spell.spellmotion=施术动作 #tooltips am2.tooltip.air_sled=§3飘逸地翱翔天际...§f +am2.tooltip.approError=恢复方块时发生了错误.这个法术似乎来自旧版本.储存的方块会被清除以防止崩溃,且法术应当继续进行.抱歉! am2.tooltip.arcanespellbook=§3获得老巫师的力量.§f am2.tooltip.armorlevel=护甲XP等级:%d am2.tooltip.armorxp=灌魔经验:%d @@ -393,7 +410,11 @@ am2.tooltip.candlecantplace=你不能放置调谐好的蜡烛. am2.tooltip.cantSummonSelf=你不能使用仪式召唤自己. am2.tooltip.charge=充能 am2.tooltip.clearKey=在破坏方块前先清除楔石组合! +am2.tooltip.compEntryNotFound=摘要词条(提示符: %s)未找到 am2.tooltip.containedXP=包含经验 %d +am2.tooltip.det_eth=探测到%s%s§f乙金: %s +am2.tooltip.diffDimMark=你的标记在另一个世界 +am2.tooltip.disconnectPower=所有能源到此方块的连接均已中断. am2.tooltip.dispel=驱散 am2.tooltip.dr_drn=窒息伤害抵御 am2.tooltip.dr_exp=爆炸伤害抵御 @@ -405,7 +426,7 @@ am2.tooltip.dr_mage=魔法伤害抵御 am2.tooltip.dr_phy=物理伤害抵御 am2.tooltip.earth_armor=§3像大地一样弹乎乎的.§f am2.tooltip.empty=空 -am2.tooltip.ender_boots=§3我拒绝汝之现实,以我自己的来代替.!§f +am2.tooltip.ender_boots=§3吾欲拒汝之实感,代之以吾自所感!§f am2.tooltip.fallprot=跌落防护 am2.tooltip.fire_ears=§3拥抱火焰.§f am2.tooltip.fireprot=灼伤防护 @@ -416,15 +437,15 @@ am2.tooltip.highjump=跳跃加成 am2.tooltip.hungerup=饱腹回复 am2.tooltip.infOrbBlue=你获得了一个§9蓝色§f技能点! am2.tooltip.infOrbFail0=你全神贯注盯着球看,结果成了斗鸡眼. -am2.tooltip.infOrbFail1=僵尸吃掉了你的脑子. -am2.tooltip.infOrbFail2=我擦! -am2.tooltip.infOrbFail3=我认为我这几周白干了. -am2.tooltip.infOrbFail4=我的理性和理智已经飞去鲁尼外奥了. -am2.tooltip.infOrbFail5=我以披萨之神的名义,CHARGE! -am2.tooltip.infOrbFail6=做这些仅仅是为了耍帅? +am2.tooltip.infOrbFail1=你不再感觉到你的头脑. +am2.tooltip.infOrbFail2=浑身难受. +am2.tooltip.infOrbFail3=我认为我这几周成了废物. +am2.tooltip.infOrbFail4=我们已经离开了利森(理性)街和森尼提(理智)大道路口.下一站,卢尼维尔. +am2.tooltip.infOrbFail5=我以披萨之神的名义,充能! +am2.tooltip.infOrbFail6=做这些仅仅是为了堆辞藻? am2.tooltip.infOrbFail7=华夫饼就像沾了甜酱的煎饼. -am2.tooltip.infOrbFail8=你还敢不敢说你看到了啥. -am2.tooltip.infOrbFail9=你深信有什么重要人物会接见你. +am2.tooltip.infOrbFail8=你不再会说你看到了啥. +am2.tooltip.infOrbFail9=你深信有一辆南瓜车会找你. am2.tooltip.infOrbGreen=你获得了一个§2绿色§f 技能点! am2.tooltip.infOrbRed=你获得了一个§4红色§f 技能点! am2.tooltip.journalOwner2=日记之主:%s @@ -442,9 +463,13 @@ am2.tooltip.mn_reg=魔力回复加成 am2.tooltip.mwLock=左SHIFT+右击锁定合成表 am2.tooltip.mwUnlock=左SHIFT+右击解锁合成表 am2.tooltip.nature_scythe=§3我杀死了你的主人,臣服于我吧!§f +am2.tooltip.noKeyPresent=这里没有楔石锁. +am2.tooltip.noMark=没有可供唤回的标记. am2.tooltip.noMatchingGate=无法找到匹配的门户. am2.tooltip.noMatchingPlayer=无法找到匹配玩家. +am2.tooltip.noMoreSummons=你不能再继续召唤. am2.tooltip.noPathFound=旋转节点间未发现路径. +am2.tooltip.noPriIn=输入标记不能登记优先级. am2.tooltip.noSupportedPowertypes=目标所需类型的能量节点无法供应. am2.tooltip.nodePairToSelf=你无法使节点同自己配对! am2.tooltip.nodesTooFar=节点相距过远,无法配对! @@ -456,11 +481,13 @@ am2.tooltip.pctFull=已充满%.2f百分比 am2.tooltip.phyEss= §b%s源质 am2.tooltip.placeBlockSpell=放置方块将会放置: %s am2.tooltip.pp_ore=探明矿藏(消耗守护蜡烛) +am2.tooltip.priSet=优先级已设为%s. +am2.tooltip.priority=优先级: %s am2.tooltip.recoil=召回 am2.tooltip.regen=为AM2 beta测试人员增加法力回复速度 am2.tooltip.run_spd=奔速加成 am2.tooltip.runes=激活符文 -am2.tooltip.rupees=不差钱! +am2.tooltip.rupees=不差卢比! am2.tooltip.shiftForAffinity=按住左shift详细查看亲和力 am2.tooltip.shiftForDetails=按住左shift键以查看细节. am2.tooltip.soulbnd=灵魂绑定 @@ -469,12 +496,17 @@ am2.tooltip.success=配对成功! am2.tooltip.swimspd=泳速加成 am2.tooltip.tc_nrv=神秘视野(需安装神秘时代) am2.tooltip.unattuned=未调谐 +am2.tooltip.unfinishedSpellRecipe=未完成法术配方. +am2.tooltip.unlockSuccess=词条解锁. am2.tooltip.unowned=日记的页面为空白. am2.tooltip.upToDate=你的魔法艺术2版本已升级. -am2.tooltip.updateAvailable=模组升级可用.左击前往下载地址. +am2.tooltip.updateAvailable=模组升级可用.左击前往下载地址.右击阅读升级日志. am2.tooltip.uses=剩余次数 am2.tooltip.water_orbs=§3水乃你盆友.§f am2.tooltip.winter_arm=§3冷酷到底.§f +am2.tooltip.wrongKeystoneBreak=你没有破坏此方块应使用的楔石. +am2.tooltip.wrongKeystoneUse=你没有使用此方块应使用的楔石. +am2.tooltip.wrongWrenchMode=扳手未设定到正确的模式. am2.tooltip.wtrbrth=水下呼吸 am2.tooltip.wtrwalk=水上行走 @@ -489,7 +521,7 @@ am2.gui.action=执行 am2.gui.affinity=亲和力UI am2.gui.airAffinity=风系 am2.gui.all=全部 -am2.gui.alpha=透明通道 +am2.gui.alpha=阿尔法 am2.gui.arcaneAffinity=奥术 am2.gui.armorUI=显示护甲状态 am2.gui.back=返回 @@ -520,6 +552,10 @@ am2.gui.done=完成 am2.gui.earthAffinity=地系 am2.gui.enderAffinity=末影 am2.gui.fireAffinity=火系 +am2.gui.flicker_doesntneedpower=不需要乙金.一旦提供会消耗. +am2.gui.flicker_needspower=需要乙金以释放. +am2.gui.flicker_optime=施法时间: %s 秒 +am2.gui.flicker_powerperop=乙金/每施法: %s am2.gui.green=绿 am2.gui.greenPoint=绿色技能点 am2.gui.gridInUse1=可用合成网格均被占用. @@ -587,12 +623,17 @@ am2.gui.xpBar=经验条 am2.gui.yes=是 #death messages -am2.death.backfire=%s's法术失灵. -am2.death.fire=%s被火烤焦了. -am2.death.frost=%s冻成了冰块. -am2.death.lightning=%s触电身亡. -am2.death.wind=%s被风吹走了. -am2.death.wtfboom=%s狠狠撞上了仙人掌,又被卷入了岩浆湖中. +death.attack.am2.backfire.player=%1$s在与%2$s战斗时法术失灵 +death.attack.am2.backfire==%s的法术失灵. +death.attack.am2.darkNexus.player=%1$s在与%2$s战斗时生命力耗竭 +death.attack.am2.darkNexus=%s的生命力耗竭 +death.attack.am2.fire=%1$s走入火中因为%2$s +death.attack.am2.frost=%1$s被%2$s冻结了 +death.attack.am2.holy=%1$s看见了%2$s的真正光芒并当场解体 +death.attack.am2.lightning=%1$s被%2$s电击 +death.attack.am2.wind=%1$s被%2$s吹走了 +death.attack.am2.wtfboom.player=%1$s因为%2$s狠狠撞上了仙人掌,又被卷入了岩浆湖中 +death.attack.am2.wtfboom=%s狠狠撞上了仙人掌,又被卷入了岩浆湖中. #npc messages am2.npc.nopartyskill=我认识你吗? @@ -618,6 +659,7 @@ am2.affinity.stoneskin=石肤 ##ender am2.affinity.darkvision=夜视 +am2.affinity.phasing=相位化 am2.affinity.poisonresistance=抗毒 am2.affinity.sunlightweakness=惧光 am2.affinity.waterweakness=畏水 @@ -656,7 +698,13 @@ am2.affinity.reflexes=闪电反应 am2.affinity.shortcircuit=短路 am2.affinity.thunderpunch=雷拳 +#abilities +am2.affinity.enderTPFailed=不不不不不!!!! #achievements achievement.compendiumData=新条目解锁 achievement.componentUnlock=发现法术组件 + +Epic Mana Restoration.postfix=史诗魔力药水 +Greater Mana Restoration.postfix=卓越魔力药水 +Legendary Mana Restoration.postfix=传奇魔力药水 diff --git a/src/main/resources/assets/arsmagica2/sounds.json b/src/main/resources/assets/arsmagica2/sounds.json index 4f0e992ff..57448f762 100644 --- a/src/main/resources/assets/arsmagica2/sounds.json +++ b/src/main/resources/assets/arsmagica2/sounds.json @@ -519,9 +519,7 @@ }, "spell.loop.none": { "category": "ambient", - "sounds": [ - "spell/loop/none" - ] + "sounds": [] }, "spell.loop.water": { "category": "ambient", diff --git a/src/main/resources/assets/arsmagica2/textures/items/spells/components/Nauseate.png b/src/main/resources/assets/arsmagica2/textures/items/spells/components/Nauseate.png new file mode 100644 index 000000000..2d6b5e835 Binary files /dev/null and b/src/main/resources/assets/arsmagica2/textures/items/spells/components/Nauseate.png differ diff --git a/src/main/resources/assets/arsmagica2/textures/items/spells/components/ScrambleSynapses.png b/src/main/resources/assets/arsmagica2/textures/items/spells/components/ScrambleSynapses.png new file mode 100644 index 000000000..67cc21538 Binary files /dev/null and b/src/main/resources/assets/arsmagica2/textures/items/spells/components/ScrambleSynapses.png differ