small fluid tweaks, HIMARS rocket item class, cargo arty shell

This commit is contained in:
Boblet 2022-10-12 16:44:43 +02:00
parent 8130b62821
commit 37ff82ee16
9 changed files with 197 additions and 105 deletions

View File

@ -140,109 +140,125 @@ public abstract class EntityThrowableNT extends Entity implements IProjectile {
}
return;
}
} else {
this.inGround = false;
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
this.inGround = false;
this.motionX *= (double) (this.rand.nextFloat() * 0.2F);
this.motionY *= (double) (this.rand.nextFloat() * 0.2F);
this.motionZ *= (double) (this.rand.nextFloat() * 0.2F);
this.ticksInGround = 0;
this.ticksInAir = 0;
}
} else {
++this.ticksInAir;
}
Vec3 pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 nextPos = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(pos, nextPos);
pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
nextPos = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if(mop != null) {
nextPos = Vec3.createVectorHelper(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
}
if(!this.worldObj.isRemote) {
Entity hitEntity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double nearest = 0.0D;
EntityLivingBase thrower = this.getThrower();
for(int j = 0; j < list.size(); ++j) {
Entity entity = (Entity) list.get(j);
if(entity.canBeCollidedWith() && (entity != thrower || this.ticksInAir >= 5)) {
double hitbox = 0.3F;
AxisAlignedBB aabb = entity.boundingBox.expand(hitbox, hitbox, hitbox);
MovingObjectPosition hitMop = aabb.calculateIntercept(pos, nextPos);
if(hitMop != null) {
double dist = pos.distanceTo(hitMop.hitVec);
if(dist < nearest || nearest == 0.0D) {
hitEntity = entity;
nearest = dist;
Vec3 pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
Vec3 nextPos = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
MovingObjectPosition mop = this.worldObj.rayTraceBlocks(pos, nextPos);
pos = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
nextPos = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if(mop != null) {
nextPos = Vec3.createVectorHelper(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
}
if(!this.worldObj.isRemote) {
Entity hitEntity = null;
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
double nearest = 0.0D;
EntityLivingBase thrower = this.getThrower();
for(int j = 0; j < list.size(); ++j) {
Entity entity = (Entity) list.get(j);
if(entity.canBeCollidedWith() && (entity != thrower || this.ticksInAir >= 5)) {
double hitbox = 0.3F;
AxisAlignedBB aabb = entity.boundingBox.expand(hitbox, hitbox, hitbox);
MovingObjectPosition hitMop = aabb.calculateIntercept(pos, nextPos);
if(hitMop != null) {
double dist = pos.distanceTo(hitMop.hitVec);
if(dist < nearest || nearest == 0.0D) {
hitEntity = entity;
nearest = dist;
}
}
}
}
if(hitEntity != null) {
mop = new MovingObjectPosition(hitEntity);
}
}
if(hitEntity != null) {
mop = new MovingObjectPosition(hitEntity);
if(mop != null) {
if(mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ) == Blocks.portal) {
this.setInPortal();
} else {
this.onImpact(mop);
}
}
}
if(mop != null) {
if(mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && this.worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ) == Blocks.portal) {
this.setInPortal();
} else {
this.onImpact(mop);
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
float hyp = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for(this.rotationPitch = (float) (Math.atan2(this.motionY, (double) hyp) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
;
}
}
this.posX += this.motionX;
this.posY += this.motionY;
this.posZ += this.motionZ;
float hyp = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
for(this.rotationPitch = (float) (Math.atan2(this.motionY, (double) hyp) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
;
}
while(this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
while(this.rotationYaw - this.prevRotationYaw < -180.0F) {
this.prevRotationYaw -= 360.0F;
}
while(this.rotationYaw - this.prevRotationYaw >= 180.0F) {
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float drag = this.getAirDrag();
double gravity = this.getGravityVelocity();
if(this.isInWater()) {
for(int i = 0; i < 4; ++i) {
float f = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f, this.posY - this.motionY * (double) f, this.posZ - this.motionZ * (double) f, this.motionX, this.motionY, this.motionZ);
while(this.rotationPitch - this.prevRotationPitch >= 180.0F) {
this.prevRotationPitch += 360.0F;
}
while(this.rotationYaw - this.prevRotationYaw < -180.0F) {
this.prevRotationYaw -= 360.0F;
}
while(this.rotationYaw - this.prevRotationYaw >= 180.0F) {
this.prevRotationYaw += 360.0F;
}
this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
float drag = this.getAirDrag();
double gravity = this.getGravityVelocity();
if(this.isInWater()) {
for(int i = 0; i < 4; ++i) {
float f = 0.25F;
this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double) f, this.posY - this.motionY * (double) f, this.posZ - this.motionZ * (double) f, this.motionX, this.motionY, this.motionZ);
}
drag = this.getWaterDrag();
}
this.motionX *= (double) drag;
this.motionY *= (double) drag;
this.motionZ *= (double) drag;
this.motionY -= gravity;
this.setPosition(this.posX, this.posY, this.posZ);
drag = this.getWaterDrag();
}
this.motionX *= (double) drag;
this.motionY *= (double) drag;
this.motionZ *= (double) drag;
this.motionY -= gravity;
this.setPosition(this.posX, this.posY, this.posZ);
}
public boolean alowMultiImpact() {
return false; //TODO
}
public void getStuck(int x, int y, int z) {
this.stuckBlockX = x;
this.stuckBlockY = y;
this.stuckBlockZ = z;
this.stuckBlock = worldObj.getBlock(x, y, z);
this.inGround = true;
}
public double getGravityVelocity() {

View File

@ -324,6 +324,9 @@ public class Fluids {
OIL.addTraits(new FT_Heatable().setEff(HeatingType.BOILER, 1.0D).setEff(HeatingType.HEATEXCHANGER, 1.0D).addStep(10, 1, HOTOIL, 1));
CRACKOIL.addTraits(new FT_Heatable().setEff(HeatingType.BOILER, 1.0D).setEff(HeatingType.HEATEXCHANGER, 1.0D).addStep(10, 1, HOTCRACKOIL, 1));
HOTOIL.addTraits(new FT_Coolable(OIL, 1, 1, 10).setEff(CoolingType.HEATEXCHANGER, 1.0D));
HOTCRACKOIL.addTraits(new FT_Coolable(CRACKOIL, 1, 1, 10).setEff(CoolingType.HEATEXCHANGER, 1.0D));
if(idMapping.size() != metaOrder.size()) {
throw new IllegalStateException("A severe error has occoured during NTM's fluid registering process! The MetaOrder and Mappings are inconsistent! Mapping size: " + idMapping.size()+ " / MetaOrder size: " + metaOrder.size());

View File

@ -1587,6 +1587,7 @@ public class ModItems {
public static Item ammo_shell_w9;
public static Item ammo_dgk;
public static Item ammo_arty;
public static Item ammo_himars;
public static Item ammo_nuke;
public static Item ammo_nuke_low;
public static Item ammo_nuke_high;
@ -4340,6 +4341,7 @@ public class ModItems {
ammo_shell_w9 = new ItemAmmo().setUnlocalizedName("ammo_shell_w9");
ammo_dgk = new ItemAmmo().setUnlocalizedName("ammo_dgk");
ammo_arty = new ItemAmmoArty().setUnlocalizedName("ammo_arty");
ammo_himars = new ItemAmmoHIMARS().setUnlocalizedName("ammo_himars");
ammo_nuke = new ItemAmmo().setUnlocalizedName("ammo_nuke");
ammo_nuke_low = new ItemAmmo().setUnlocalizedName("ammo_nuke_low");
ammo_nuke_high = new ItemAmmo().setUnlocalizedName("ammo_nuke_high");
@ -7441,6 +7443,7 @@ public class ModItems {
GameRegistry.registerItem(ammo_shell_w9, ammo_shell_w9.getUnlocalizedName());
GameRegistry.registerItem(ammo_dgk, ammo_dgk.getUnlocalizedName());
GameRegistry.registerItem(ammo_arty, ammo_arty.getUnlocalizedName());
GameRegistry.registerItem(ammo_himars, ammo_himars.getUnlocalizedName());
GameRegistry.registerItem(ammo_nuke, ammo_nuke.getUnlocalizedName());
GameRegistry.registerItem(ammo_nuke_low, ammo_nuke_low.getUnlocalizedName());
GameRegistry.registerItem(ammo_nuke_high, ammo_nuke_high.getUnlocalizedName());

View File

@ -38,11 +38,12 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
public class ItemAmmoArty extends Item {
public static ArtilleryShell[] itemTypes = new ArtilleryShell[ /* >>> */ 8 /* <<< */ ];
public static ArtilleryShell[] shellTypes = new ArtilleryShell[ /* >>> */ 8 /* <<< */ ];
public static ArtilleryShell[] itemTypes = new ArtilleryShell[ /* >>> */ 9 /* <<< */ ];
//public static ArtilleryShell[] shellTypes = new ArtilleryShell[ /* >>> */ 8 /* <<< */ ];
/* item types */
public final int NORMAL = 0;
public final int CLASSIC = 1;
@ -52,6 +53,7 @@ public class ItemAmmoArty extends Item {
public final int PHOSPHORUS = 5;
public final int MINI_NUKE_MULTI = 6;
public final int PHOSPHORUS_MULTI = 7;
public final int CARGO = 8;
/* non-item shell types */
public ItemAmmoArty() {
@ -71,6 +73,7 @@ public class ItemAmmoArty extends Item {
list.add(new ItemStack(item, 1, MINI_NUKE));
list.add(new ItemStack(item, 1, MINI_NUKE_MULTI));
list.add(new ItemStack(item, 1, NUKE));
list.add(new ItemStack(item, 1, CARGO));
}
@Override
@ -204,12 +207,12 @@ public class ItemAmmoArty extends Item {
private void init() {
/* STANDARD SHELLS */
this.shellTypes[NORMAL] = this.itemTypes[NORMAL] = new ArtilleryShell("ammo_arty") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 10F, 3F, false); }};
this.shellTypes[CLASSIC] = this.itemTypes[CLASSIC] = new ArtilleryShell("ammo_arty_classic") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 15F, 5F, false); }};
this.shellTypes[EXPLOSIVE] = this.itemTypes[EXPLOSIVE] = new ArtilleryShell("ammo_arty_he") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 15F, 3F, true); }};
this.itemTypes[NORMAL] = new ArtilleryShell("ammo_arty") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 10F, 3F, false); }};
this.itemTypes[CLASSIC] = new ArtilleryShell("ammo_arty_classic") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 15F, 5F, false); }};
this.itemTypes[EXPLOSIVE] = new ArtilleryShell("ammo_arty_he") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { standardExplosion(shell, mop, 15F, 3F, true); }};
/* MINI NUKE */
this.shellTypes[MINI_NUKE] = this.itemTypes[MINI_NUKE] = new ArtilleryShell("ammo_arty_mini_nuke") {
this.itemTypes[MINI_NUKE] = new ArtilleryShell("ammo_arty_mini_nuke") {
public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) {
shell.killAndClear();
Vec3 vec = Vec3.createVectorHelper(shell.motionX, shell.motionY, shell.motionZ).normalize();
@ -218,7 +221,7 @@ public class ItemAmmoArty extends Item {
};
/* FULL NUKE */
this.shellTypes[NUKE] = this.itemTypes[NUKE] = new ArtilleryShell("ammo_arty_nuke") {
this.itemTypes[NUKE] = new ArtilleryShell("ammo_arty_nuke") {
public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) {
shell.worldObj.spawnEntityInWorld(EntityNukeExplosionMK4.statFac(shell.worldObj, BombConfig.missileRadius, mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord));
EntityNukeCloudSmall entity2 = new EntityNukeCloudSmall(shell.worldObj, 1000, BombConfig.missileRadius * 0.005F);
@ -231,7 +234,7 @@ public class ItemAmmoArty extends Item {
};
/* PHOSPHORUS */
this.shellTypes[PHOSPHORUS] = this.itemTypes[PHOSPHORUS] = new ArtilleryShell("ammo_arty_phosphorus") {
this.itemTypes[PHOSPHORUS] = new ArtilleryShell("ammo_arty_phosphorus") {
public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) {
standardExplosion(shell, mop, 10F, 3F, false);
shell.worldObj.playSoundEffect(shell.posX, shell.posY, shell.posZ, "hbm:weapon.explosionMedium", 20.0F, 0.9F + shell.worldObj.rand.nextFloat() * 0.2F);
@ -259,13 +262,21 @@ public class ItemAmmoArty extends Item {
}
};
/* THIS DOOFUS */
this.itemTypes[NORMAL] = new ArtilleryShell("ammo_arty_cargo") { public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) {
if(mop.typeOfHit == MovingObjectType.BLOCK) {
shell.setPosition(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
shell.getStuck(mop.blockX, mop.blockY, mop.blockZ);
}
}};
/* CLUSTER SHELLS */
this.shellTypes[PHOSPHORUS_MULTI] = this.itemTypes[PHOSPHORUS_MULTI] = new ArtilleryShell("ammo_arty_phosphorus_multi") {
public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { ItemAmmoArty.this.shellTypes[PHOSPHORUS].onImpact(shell, mop); }
this.itemTypes[PHOSPHORUS_MULTI] = new ArtilleryShell("ammo_arty_phosphorus_multi") {
public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { ItemAmmoArty.this.itemTypes[PHOSPHORUS].onImpact(shell, mop); }
public void onUpdate(EntityArtilleryShell shell) { standardCluster(shell, PHOSPHORUS, 10, 300, 5); }
};
this.shellTypes[MINI_NUKE_MULTI] = this.itemTypes[MINI_NUKE_MULTI] = new ArtilleryShell("ammo_arty_mini_nuke_multi") {
public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { ItemAmmoArty.this.shellTypes[MINI_NUKE].onImpact(shell, mop); }
this.itemTypes[MINI_NUKE_MULTI] = new ArtilleryShell("ammo_arty_mini_nuke_multi") {
public void onImpact(EntityArtilleryShell shell, MovingObjectPosition mop) { ItemAmmoArty.this.itemTypes[MINI_NUKE].onImpact(shell, mop); }
public void onUpdate(EntityArtilleryShell shell) { standardCluster(shell, MINI_NUKE, 5, 300, 5); }
};
}

View File

@ -0,0 +1,56 @@
package com.hbm.items.weapon;
import java.util.List;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
public class ItemAmmoHIMARS extends Item {
public static HIMARSRocket[] itemTypes = new HIMARSRocket[ /* >>> */ 2 /* <<< */ ];
public final int SMALL = 0;
public final int LARGE = 1;
public ItemAmmoHIMARS() {
this.setHasSubtypes(true);
this.setCreativeTab(MainRegistry.weaponTab);
this.setTextureName(RefStrings.MODID + ":ammo_rocket");
init();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
list.add(new ItemStack(item, 1, SMALL));
list.add(new ItemStack(item, 1, LARGE));
}
public abstract class HIMARSRocket {
String name;
public HIMARSRocket() { }
public HIMARSRocket(String name) {
this.name = name;
}
public abstract void onImpact(Entity rocket, MovingObjectPosition mop);
public void onUpdate(Entity rocket) { }
}
private void init() {
/* STANDARD SHELLS */
this.itemTypes[SMALL] = new HIMARSRocket("ammo_himars") { public void onImpact(Entity rocket, MovingObjectPosition mop) { }};
this.itemTypes[LARGE] = new HIMARSRocket("ammo_himars_large") { public void onImpact(Entity rocket, MovingObjectPosition mop) { }};
}
}

View File

@ -349,6 +349,7 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
//the amount of material in the entire recipe input
int recipeContent = recipe != null ? recipe.getInputAmount() : 0;
//the total amount of the current waste stack, used for simulation
int recipeAmount = getQuantaFromType(this.recipeStack, null);
int wasteAmount = getQuantaFromType(this.wasteStack, null);
for(MaterialStack mat : materials) {
@ -366,14 +367,16 @@ public class TileEntityCrucible extends TileEntityMachineBase implements IGUIPro
matchesRecipe = true;
recipeAmount += mat.amount;
//if the amount of that input would exceed the amount dictated by the recipe, return false
if(recipe != null && amountStored + mat.amount > matMaximum)
return false;
}
}
//if the waste amount doesn't exceed the capacity and the recipe matches (or isn't null), return true
return wasteAmount <= this.wasteZCapacity && matchesRecipe;
//if the amount doesn't exceed the capacity and the recipe matches (or isn't null), return true
return recipeAmount <= this.recipeZCapacity && wasteAmount <= this.wasteZCapacity && matchesRecipe;
}
public void addToStack(List<MaterialStack> stack, MaterialStack matStack) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B