diff options
author | Tec <daniel112092@gmail.com> | 2022-01-09 19:19:04 +0100 |
---|---|---|
committer | Martin Robertz <dream-master@gmx.net> | 2022-01-29 21:18:47 +0100 |
commit | 5bb0894b4c54cd10e987493ad3402ad9522407db (patch) | |
tree | 9ccd25f55fc231ec52e3a2d9295135fbeb54c6ce /src/main/java | |
parent | f2bf25053f9d4d576aa0624b80c35d8bfa3efb70 (diff) | |
download | GT5-Unofficial-5bb0894b4c54cd10e987493ad3402ad9522407db.tar.gz GT5-Unofficial-5bb0894b4c54cd10e987493ad3402ad9522407db.tar.bz2 GT5-Unofficial-5bb0894b4c54cd10e987493ad3402ad9522407db.zip |
Cleanup and update EM turret projectile
(cherry picked from commit de8bf3e68e9e4d7cee485d0d6951a4e4ccb5859d)
Diffstat (limited to 'src/main/java')
4 files changed, 49 insertions, 37 deletions
diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java index 702ed77315..92acd71ecd 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/entity/projectiles/projectileEM.java @@ -18,6 +18,8 @@ import openmodularturrets.tileentity.turretbase.TurretBase; import openmodularturrets.util.PlayerUtil; import openmodularturrets.util.TurretHeadUtil; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; + /** * Created by Bass on 27/07/2017. @@ -26,7 +28,7 @@ public class projectileEM extends LaserProjectile { public float gravity=0; private TurretBase turretBase; - private boolean exotic, antiMatter,isAmped; + private boolean strange, antiMatter,isAmped; private int ampLevel; @@ -45,36 +47,23 @@ public class projectileEM extends LaserProjectile { } } - public projectileEM(World par1World, TurretBase turretBase, cElementalInstanceStackMap avalableEM) { + public projectileEM(World par1World, TurretBase turretBase, cElementalInstanceStack projectileContent) { super(par1World, turretBase); this.turretBase = turretBase; - boolean onlyQuarks=true; - if(avalableEM!=null && avalableEM.hasStacks()) { - for (cElementalInstanceStack stack : avalableEM.values()) { - if (!(stack.definition instanceof eQuarkDefinition)) { - onlyQuarks = false; - } - } - if (onlyQuarks) { - avalableEM.clear(); - } else { - cElementalInstanceStack consumeFromThis=avalableEM.get(TecTech.RANDOM.nextInt(avalableEM.size())); - massFactor =(float) (consumeFromThis.definition.getMass()/ dHadronDefinition.hadron_n_.getMass()); + if(projectileContent != null){ + massFactor =(float) (projectileContent.definition.getMass()/ dHadronDefinition.hadron_n_.getMass()); - if(consumeFromThis.definition.getType()>1 || consumeFromThis.definition.getType()<-1) { - exotic = true; - } - if(consumeFromThis.definition.getType()<0) { - antiMatter = true; - } - - if (consumeFromThis.definition.getCharge() == 0) { - gravity = massFactor / 100f; - } else { - gravity = Math.min(0.0025F / Math.abs(consumeFromThis.definition.getCharge()), massFactor / 100f); - } + if(projectileContent.definition.getType()>1 || projectileContent.definition.getType()<-1) { + strange = true; + } + if(projectileContent.definition.getType()<0) { + antiMatter = true; + } - avalableEM.removeAmount(false,consumeFromThis.definition.getStackForm(1)); + if (projectileContent.definition.getCharge() == 0) { + gravity = massFactor / 100f; + } else { + gravity = Math.min(0.0025F / Math.abs(projectileContent.definition.getCharge()), massFactor / 100f); } } //todo make the recipe require some overflow hatches @@ -97,7 +86,8 @@ public class projectileEM extends LaserProjectile { worldObj.createExplosion(null, movingobjectposition.blockX + 0.5D, movingobjectposition.blockY + 0.5D, - movingobjectposition.blockZ + 0.5D, (exotic?10:1) * TecTech.configTecTech.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1) * (ticksExisted/250f), true); + movingobjectposition.blockZ + 0.5D, + (strange ?10:1) * TecTech.configTecTech.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1) * (ticksExisted/250f), true); } else { return; } @@ -107,18 +97,18 @@ public class projectileEM extends LaserProjectile { if(movingobjectposition.entityHit != null && !worldObj.isRemote) { worldObj.playSoundEffect(posX, posY, posZ, "openmodularturrets:laserHit", ConfigHandler.getTurretSoundVolume(), TecTech.RANDOM.nextFloat() + 0.5F); if(movingobjectposition.entityHit != null && !worldObj.isRemote) { - float damage = (exotic?10:1) * TecTech.configTecTech.TURRET_DAMAGE_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1); + float damage = (strange ?10:1) * TecTech.configTecTech.TURRET_DAMAGE_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1); if(movingobjectposition.entityHit instanceof EntityPlayer) { if(canDamagePlayer((EntityPlayer)movingobjectposition.entityHit)) { - movingobjectposition.entityHit.setFire((exotic?10:1)*2); + movingobjectposition.entityHit.setFire((strange ?10:1)*2); movingobjectposition.entityHit.attackEntityFrom(new NormalDamageSource("laser"), damage); if(antiMatter) { movingobjectposition.entityHit.hurtResistantTime = 0; } } } else { - movingobjectposition.entityHit.setFire((exotic?10:1)*2); + movingobjectposition.entityHit.setFire((strange ?10:1)*2); movingobjectposition.entityHit.attackEntityFrom(new NormalDamageSource("laser"), damage); if(antiMatter) { movingobjectposition.entityHit.hurtResistantTime = 0; @@ -133,7 +123,8 @@ public class projectileEM extends LaserProjectile { worldObj.createExplosion(null, movingobjectposition.entityHit.posX, movingobjectposition.entityHit.posY, - movingobjectposition.entityHit.posZ, (exotic?10:1) * TecTech.configTecTech.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1) * (ticksExisted/250f), true); + movingobjectposition.entityHit.posZ, + (strange ?10:1) * TecTech.configTecTech.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped? ampLevel*.1f +1:1) * (ticksExisted/250f), true); } } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turret/TileTurretHeadEM.java b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turret/TileTurretHeadEM.java index 2de6b39c4c..1c8d476a36 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turret/TileTurretHeadEM.java +++ b/src/main/java/com/github/technus/tectech/compatibility/openmodularturrets/tileentity/turret/TileTurretHeadEM.java @@ -1,8 +1,12 @@ package com.github.technus.tectech.compatibility.openmodularturrets.tileentity.turret; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.compatibility.openmodularturrets.entity.projectiles.projectileEM; import com.github.technus.tectech.compatibility.openmodularturrets.tileentity.turretbase.TileTurretBaseEM; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.complex.dHadronDefinition; +import com.github.technus.tectech.mechanics.elementalMatter.definitions.primitive.eQuarkDefinition; import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; import net.minecraft.entity.Entity; import net.minecraft.item.Item; @@ -13,6 +17,8 @@ import openmodularturrets.handler.ConfigHandler; import openmodularturrets.tileentity.turrets.TurretHead; import openmodularturrets.util.TurretHeadUtil; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.*; + /** * Created by Bass on 27/07/2017. */ @@ -64,7 +70,18 @@ public class TileTurretHeadEM extends TurretHead{ @Override public final TurretProjectile createProjectile(World world, Entity target, ItemStack ammo) { - return new projectileEM(world, TurretHeadUtil.getTurretBase(worldObj, xCoord, yCoord, zCoord), hatchContentPointer); + while(hatchContentPointer!=null && hatchContentPointer.hasStacks()) { + cElementalInstanceStack stack = hatchContentPointer.get(TecTech.RANDOM.nextInt(hatchContentPointer.size())); + if(stack.amount<AVOGADRO_CONSTANT_KIND_OF_SMALLER){ + hatchContentPointer.remove(stack.definition); + continue; + } + hatchContentPointer.removeAmount(false, stack.definition.getStackForm(AVOGADRO_CONSTANT)); + stack=stack.clone(); + stack.amount = AVOGADRO_CONSTANT; + return new projectileEM(world, TurretHeadUtil.getTurretBase(worldObj, xCoord, yCoord, zCoord), stack); + } + return new projectileEM(world, TurretHeadUtil.getTurretBase(worldObj, xCoord, yCoord, zCoord), null); } @Override diff --git a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java index 55ee24e2f6..ec5391a0b4 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java +++ b/src/main/java/com/github/technus/tectech/mechanics/elementalMatter/core/transformations/bTransformationInfo.java @@ -2,6 +2,7 @@ package com.github.technus.tectech.mechanics.elementalMatter.core.transformation import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.iHasElementalDefinition; import com.github.technus.tectech.mechanics.elementalMatter.core.templates.iElementalDefinition; +import com.github.technus.tectech.util.DoubleCount; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import net.minecraft.item.ItemStack; @@ -20,8 +21,12 @@ import static com.github.technus.tectech.thing.item.DebugElementalInstanceContai */ public class bTransformationInfo { public static final double AVOGADRO_CONSTANT =6.02214076e23D; - public static final double AVOGADRO_CONSTANT_UNCERTAINTY =(144*1000)/6.02214076e23D; + public static final double AVOGADRO_CONSTANT_UNCERTAINTY =(144*1000)/AVOGADRO_CONSTANT; + public static final double AVOGADRO_CONSTANT_EPSILON = AVOGADRO_CONSTANT / (144 * 1000); + public static final double AVOGADRO_CONSTANT_KIND_OF_SMALLER =AVOGADRO_CONSTANT-AVOGADRO_CONSTANT_EPSILON; + public static final double AVOGADRO_CONSTANT_KIND_OF_BIGGER =AVOGADRO_CONSTANT+AVOGADRO_CONSTANT_EPSILON; public static final double AVOGADRO_CONSTANT_144 = AVOGADRO_CONSTANT *144D; + public static final double AVOGADRO_CONSTANT_1000 = AVOGADRO_CONSTANT *1000D; public static final Map<Integer,aFluidQuantizationInfo> fluidQuantization=new HashMap<>(32); public static final Map<aItemQuantizationInfo,aItemQuantizationInfo> itemQuantization=new HashMap<>(32); diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java index 6850b24e0f..bfd7d266c0 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java @@ -31,8 +31,7 @@ import java.util.TreeSet; import static com.github.technus.tectech.Reference.MODID; import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.loader.gui.CreativeTabTecTech.creativeTabTecTech; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT; -import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.AVOGADRO_CONSTANT_144; +import static com.github.technus.tectech.mechanics.elementalMatter.core.transformations.bTransformationInfo.*; import static cpw.mods.fml.relauncher.Side.CLIENT; import static net.minecraft.util.StatCollector.translateToLocal; @@ -145,7 +144,7 @@ public final class DebugElementalInstanceContainer_EM extends Item implements IE for(iElementalDefinition definition: STACKS_REGISTERED){ list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 1 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT)))); list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 144 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT_144)))); - list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 1000 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT *1000)))); + list.add(setContent(new ItemStack(this).setStackDisplayName(definition.getName()+" 1000 mol"),new cElementalInstanceStackMap(new cElementalInstanceStack(definition, AVOGADRO_CONSTANT_1000)))); } } |