Skip to content

Commit

Permalink
Merge pull request #43 from 70000hp/newchanges
Browse files Browse the repository at this point in the history
MIRV PR
  • Loading branch information
TheOriginalGolem authored Nov 23, 2022
2 parents 49509ab + 6867e78 commit 557b9dd
Show file tree
Hide file tree
Showing 14 changed files with 1,408 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/main/java/api/hbm/entity/IRadarDetectable.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static enum RadarTargetType {
MISSILE_15_20("Size 15/20 Custom Missile"), //size 15/20 custom missiles
MISSILE_20("Size 20 Custom Missile"), //size 20 custom missiles
MISSILE_AB("Anti-Ballistic Missile"), //anti ballistic missile
MIRVLET("Mirvlet"), //anti ballistic missile
PLAYER("Player"); //airborne players

public String name;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/hbm/creativetabs/MissileTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public void displayAllRelevantItems(NonNullList<ItemStack> list) {

list.add(ItemCustomMissile.buildMissile(
ModItems.mp_chip_5,
ModItems.mp_warhead_15_boxcar,
ModItems.mp_fuselage_15_kerosene_blackjack,
ModItems.mp_stability_15_thin,
ModItems.mp_thruster_15_kerosene).setStackDisplayName(TextFormatting.RED + "Auntie Blackjack"));
ModItems.mp_warhead_15_mirv,
ModItems.mp_fuselage_15_kerosene_lambda,
ModItems.mp_stability_15_soyuz,
ModItems.mp_thruster_15_kerosene).setStackDisplayName(TextFormatting.BLUE + "7 For 1 Package Deal"));

list.add(ItemCustomMissile.buildMissile(
ModItems.mp_chip_4,
Expand Down
91 changes: 90 additions & 1 deletion src/main/java/com/hbm/entity/missile/EntityMIRV.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,69 @@
package com.hbm.entity.missile;

import java.util.ArrayList;
import java.util.List;

import api.hbm.entity.IRadarDetectable;

import com.hbm.config.BombConfig;
import com.hbm.entity.effect.EntityNukeCloudSmall;
import com.hbm.entity.logic.EntityNukeExplosionMK4;
import com.hbm.entity.logic.IChunkLoader;
import com.hbm.entity.particle.EntitySmokeFX;
import com.hbm.explosion.ExplosionLarge;
import com.hbm.interfaces.IConstantRenderer;
import com.hbm.main.MainRegistry;

import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeChunkManager;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.ForgeChunkManager.Type;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class EntityMIRV extends EntityThrowable {
public class EntityMIRV extends EntityThrowable implements IChunkLoader, IConstantRenderer, IRadarDetectable {
private Ticket loaderTicket;
public static final DataParameter<Integer> HEALTH = EntityDataManager.createKey(EntityMIRV.class, DataSerializers.VARINT);
public int health = 25;

public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) {
if(!this.isDead && !this.world.isRemote) {
health -= p_70097_2_;

if(this.health <= 0) {
this.setDead();
this.killMissile();
}
}

return true;
}


private void killMissile() {
ExplosionLarge.explode(world, posX, posY, posZ, 5, true, false, true);
ExplosionLarge.spawnShrapnelShower(world, posX, posY, posZ, motionX, motionY, motionZ, 15, 0.075);
}
public EntityMIRV(World worldIn) {
super(worldIn);
this.ignoreFrustumCheck = true;
}
@Override
protected void entityInit() {
init(ForgeChunkManager.requestTicket(MainRegistry.instance, world, Type.ENTITY));
this.getDataManager().register(HEALTH, Integer.valueOf(this.health));
}

@Override
public void onUpdate() {
Expand Down Expand Up @@ -89,4 +133,49 @@ protected void onImpact(RayTraceResult result) {

}

@Override
public RadarTargetType getTargetType() {
return RadarTargetType.MIRVLET;
}

@Override
public void init(Ticket ticket) {
if(!world.isRemote) {

if(ticket != null) {

if(loaderTicket == null) {

loaderTicket = ticket;
loaderTicket.bindEntity(this);
loaderTicket.getModData();
}

ForgeChunkManager.forceChunk(loaderTicket, new ChunkPos(chunkCoordX, chunkCoordZ));
}
}
}
List<ChunkPos> loadedChunks = new ArrayList<ChunkPos>();
public void loadNeighboringChunks(int newChunkX, int newChunkZ) {
if (!world.isRemote && loaderTicket != null) {
for (ChunkPos chunk : loadedChunks) {
ForgeChunkManager.unforceChunk(loaderTicket, chunk);
}

loadedChunks.clear();
loadedChunks.add(new ChunkPos(newChunkX, newChunkZ));
loadedChunks.add(new ChunkPos(newChunkX + 1, newChunkZ + 1));
loadedChunks.add(new ChunkPos(newChunkX - 1, newChunkZ - 1));
loadedChunks.add(new ChunkPos(newChunkX + 1, newChunkZ - 1));
loadedChunks.add(new ChunkPos(newChunkX - 1, newChunkZ + 1));
loadedChunks.add(new ChunkPos(newChunkX + 1, newChunkZ));
loadedChunks.add(new ChunkPos(newChunkX, newChunkZ + 1));
loadedChunks.add(new ChunkPos(newChunkX - 1, newChunkZ));
loadedChunks.add(new ChunkPos(newChunkX, newChunkZ - 1));

for (ChunkPos chunk : loadedChunks) {
ForgeChunkManager.forceChunk(loaderTicket, chunk);
}
}
}
}
40 changes: 37 additions & 3 deletions src/main/java/com/hbm/entity/missile/EntityMissileCustom.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ public void onUpdate() {
this.getDataManager().set(HEALTH, this.health);
if(world.isRemote)
template = this.getDataManager().get(TEMPLATE);


WarheadType type1 = (WarheadType)template.warhead.attributes[0];;
this.setLocationAndAngles(posX + this.motionX * velocity, posY + this.motionY * velocity, posZ + this.motionZ * velocity, 0, 0);

this.rotation();
Expand Down Expand Up @@ -367,10 +368,42 @@ public void onUpdate() {
for(int i = 0; i < velocity; i++)
MainRegistry.proxy.spawnParticle(posX - v.xCoord * i, posY - v.yCoord * i, posZ - v.zCoord * i, smoke, null);
}

if(type1 == WarheadType.MIRV){
mirvSplit();
}
loadNeighboringChunks((int)(posX / 16), (int)(posZ / 16));
}

public void mirvSplit(){
if((motionY <= 0) && (posY <= 300)) {

if(world.isRemote)
return;

this.setDead();

double mod;
double mod2;
for(int i = 0; i < 8; i++) {
EntityMIRV nuke3 = new EntityMIRV(this.world);
nuke3.setPosition(posX,posY,posZ);
mod = (i == 1 || i == 2) ? 1 : -1;
mod2 = (i == 1 || i == 3) ? 1 : -1;

if(i==5){ mod2 = 0; mod = 2;}
if(i==6){ mod2 = 0; mod = -2;}
if(i==7){ mod2 = 0; mod = 0;}

nuke3.motionX = this.motionX+mod;
nuke3.motionY = this.motionY;
nuke3.motionZ = this.motionZ+mod2;
this.world.spawnEntity(nuke3);

}


}
}

@Override
@SideOnly(Side.CLIENT)
public boolean isInRangeToRenderDist(double distance)
Expand Down Expand Up @@ -400,6 +433,7 @@ public void onImpact() {
break;
case NUCLEAR:
case TX:
case MIRV:
world.spawnEntity(EntityNukeExplosionMK4.statFac(world, (int) strength, posX, posY, posZ));

EntityNukeCloudSmall nuke = new EntityNukeCloudSmall(world, strength);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/hbm/inventory/AssemblerRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private static void registerDefaults() {
makeRecipe(new ComparableStack(ModItems.mp_warhead_15_nuclear, 1), new AStack[] { new ComparableStack(ModItems.seg_15, 1), new OreDictStack("plateSteel", 24), new OreDictStack("plateTitanium", 12), new ComparableStack(ModItems.ingot_pu239, 3), new ComparableStack(ModBlocks.det_nuke, 1), new ComparableStack(ModItems.circuit_targeting_tier4, 1), }, 500);
makeRecipe(new ComparableStack(ModItems.mp_warhead_15_thermo, 1), new AStack[] { new ComparableStack(ModItems.seg_15, 1), new OreDictStack("plateSteel", 32), new OreDictStack("plateTitanium", 16), new ComparableStack(ModBlocks.det_nuke, 2), new ComparableStack(ModItems.mike_deut, 1), new ComparableStack(ModItems.mike_core, 1), new ComparableStack(ModItems.circuit_targeting_tier5, 1), }, 600);
makeRecipe(new ComparableStack(ModItems.mp_warhead_15_volcano, 1), new AStack[] { new ComparableStack(ModItems.seg_15, 1), new OreDictStack("plateSteel", 32), new OreDictStack("plateTitanium", 16), new ComparableStack(ModBlocks.det_nuke, 4), new OreDictStack("blockUranium238", 32), new ComparableStack(ModItems.circuit_tantalium, 6), new ComparableStack(ModItems.circuit_targeting_tier4, 1) }, 600);

makeRecipe(new ComparableStack(ModItems.mp_warhead_15_mirv, 1), new AStack[] { new ComparableStack(ModItems.seg_15, 1), new OreDictStack("plateTitanium", 16), new OreDictStack("plateSteel", 12), new ComparableStack(ModItems.ingot_semtex, 7), new ComparableStack(ModItems.ingot_beryllium, 7), new ComparableStack(ModItems.billet_u238, 7), new ComparableStack(ModItems.nugget_u235, 10), new NbtComparableStack(ItemCell.getFullCell(ModForgeFluids.deuterium, 10)),new NbtComparableStack(ItemCell.getFullCell(ModForgeFluids.tritium, 10)),new ComparableStack(ModItems.hull_small_steel, 7),new ComparableStack(ModItems.circuit_targeting_tier4, 3), },600);
makeRecipe(new ComparableStack(ModItems.mp_warhead_15_n2, 1), new AStack[] { new ComparableStack(ModItems.seg_15, 1), new OreDictStack("plateSteel", 8), new OreDictStack("plateTitanium", 20), new ComparableStack(ModBlocks.det_charge, 24), new ComparableStack(Blocks.REDSTONE_BLOCK, 12), new ComparableStack(ModItems.powder_magnetized_tungsten, 6), new ComparableStack(ModItems.circuit_targeting_tier5, 1), }, 400);
makeRecipe(new ComparableStack(ModItems.missile_soyuz0, 1), new AStack[] { new ComparableStack(ModItems.rocket_fuel, 40), new ComparableStack(ModBlocks.det_cord, 20), new ComparableStack(ModItems.thruster_medium, 12), new ComparableStack(ModItems.thruster_small, 12), new ComparableStack(ModItems.tank_steel, 10), new ComparableStack(ModItems.circuit_targeting_tier4, 4), new ComparableStack(ModItems.circuit_targeting_tier3, 8), new ComparableStack(ModItems.plate_polymer, 64), new ComparableStack(ModItems.fins_small_steel, 4), new ComparableStack(ModItems.hull_big_titanium, 40), new ComparableStack(ModItems.hull_big_steel, 24), new ComparableStack(ModItems.ingot_fiberglass, 64), }, 600);
makeRecipe(new ComparableStack(ModItems.missile_soyuz_lander, 1), new AStack[] { new ComparableStack(ModItems.rocket_fuel, 10), new ComparableStack(ModItems.thruster_small, 3), new ComparableStack(ModItems.tank_steel, 2), new ComparableStack(ModItems.circuit_targeting_tier3, 4), new ComparableStack(ModItems.plate_polymer, 32), new ComparableStack(ModItems.hull_big_aluminium, 2), new ComparableStack(ModItems.sphere_steel, 1), new ComparableStack(ModItems.ingot_fiberglass, 12), }, 600);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/hbm/items/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -3172,6 +3172,7 @@ public class ModItems {
public static final Item mp_warhead_15_nuclear = new ItemMissile("mp_warhead_15_nuclear").makeWarhead(WarheadType.NUCLEAR, 125F, 5F, PartSize.SIZE_15).setTitle("Auntie Bertha").setHealth(15F).setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab);
public static final Item mp_warhead_15_nuclear_shark = ((ItemMissile) mp_warhead_15_nuclear).copy("mp_warhead_15_nuclear_shark").setRarity(Rarity.UNCOMMON).setTitle("Discount Bullet Bill").setWittyText("Nose art on a cannon bullet? Who does that?");
public static final Item mp_warhead_15_thermo = new ItemMissile("mp_warhead_15_thermo").makeWarhead(WarheadType.TX, 250F, 6.5F, PartSize.SIZE_15).setHealth(25F).setRarity(Rarity.RARE).setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab);
public static final Item mp_warhead_15_mirv = new ItemMissile("mp_warhead_15_mirv").makeWarhead(WarheadType.MIRV, 75F, 7.5F, PartSize.SIZE_15).setRarity(Rarity.LEGENDARY).setAuthor("Seven").setHealth(20F).setWittyText("I wanna know, have you ever seen the rain?").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab);
public static final Item mp_warhead_15_boxcar = new ItemMissile("mp_warhead_15_boxcar").makeWarhead(WarheadType.TX, 500F, 7.5F, PartSize.SIZE_15).setWittyText("?!?!").setHealth(35F).setRarity(Rarity.LEGENDARY).setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab);
public static final Item mp_warhead_15_n2 = new ItemMissile("mp_warhead_15_n2").makeWarhead(WarheadType.N2, 100F, 5F, PartSize.SIZE_15).setWittyText("[screams geometrically]").setHealth(20F).setRarity(Rarity.RARE).setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab);
public static final Item mp_warhead_15_balefire = new ItemMissile("mp_warhead_15_balefire").makeWarhead(WarheadType.BALEFIRE, 100F, 7.5F, PartSize.SIZE_15).setRarity(Rarity.LEGENDARY).setAuthor("VT-6/24").setHealth(15F).setWittyText("Hightower, never forgetti.").setMaxStackSize(1).setCreativeTab(MainRegistry.missileTab);
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/hbm/items/weapon/ItemMissile.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public enum WarheadType {
SCHRAB,
TAINT,
CLOUD,
VOLCANO
VOLCANO,
MIRV
}

public enum FuelType {
Expand Down Expand Up @@ -274,6 +275,8 @@ public String getWarhead(WarheadType type) {
return TextFormatting.LIGHT_PURPLE + "Cloud";
case VOLCANO:
return TextFormatting.DARK_RED + "Volcano";
case MIRV:
return TextFormatting.DARK_PURPLE + "MIRV";
default:
return TextFormatting.BOLD + "N/A";
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/hbm/main/ResourceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ public class ResourceManager {
public static final IModelCustom mp_w_15_boxcar = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/missile_parts/mp_w_15_boxcar.obj"));
public static final IModelCustom mp_w_15_n2 = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/missile_parts/mp_w_15_n2.obj"));
public static final IModelCustom mp_w_15_balefire = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/missile_parts/mp_w_15_balefire.obj"));
public static final IModelCustom mp_w_15_mirv = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/missile_parts/mp_w_15_mirv.obj"));
public static final IModelCustom mp_w_20 = AdvancedModelLoader.loadModel(new ResourceLocation(RefStrings.MODID, "models/missile_parts/mp_w_20.obj"));

//Anti Mass Spectrometer
Expand Down Expand Up @@ -1210,6 +1211,7 @@ public class ResourceManager {
public static final ResourceLocation mp_w_15_n2_tex = new ResourceLocation(RefStrings.MODID, "textures/models/missile_parts/warheads/mp_w_15_n2.png");
public static final ResourceLocation mp_w_15_balefire_tex = new ResourceLocation(RefStrings.MODID, "textures/models/missile_parts/warheads/mp_w_15_balefire.png");
public static final ResourceLocation mp_w_15_volcano_tex = new ResourceLocation(RefStrings.MODID, "textures/models/missile_parts/warheads/mp_w_15_volcano.png");
public static final ResourceLocation mp_w_15_mirv_tex = new ResourceLocation(RefStrings.MODID, "textures/models/missile_parts/warheads/mp_w_15_mirv.png");

//Keypad
public static final ResourceLocation keypad_tex = new ResourceLocation(RefStrings.MODID, "textures/models/keypad.png");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private ResourceLocation getMushroomTexture(float cloudAge, boolean isBalefire,
private void mushWrapper(EntityNukeCloudSmall cloud, float interp) {

float size = cloud.getDataManager().get(EntityNukeCloudSmall.SCALE) * 5;
float maxage = cloud.getDataManager().get(EntityNukeCloudSmall.MAXAGE);
float maxage = (float) cloud.getDataManager().get(EntityNukeCloudSmall.MAXAGE);


double height = Math.max(20 - 1000 / (cloud.age + interp - 13), 0);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/hbm/render/misc/MissilePart.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public static void registerAllParts() {
MissilePart.registerPart(ModItems.mp_warhead_15_volcano, PartType.WARHEAD, 3.5, 2, ResourceManager.mp_w_15_nuclear, ResourceManager.mp_w_15_volcano_tex);
MissilePart.registerPart(ModItems.mp_warhead_15_boxcar, PartType.WARHEAD, 2.25, 7.5, ResourceManager.mp_w_15_boxcar, ResourceManager.boxcar_tex);
MissilePart.registerPart(ModItems.mp_warhead_15_n2, PartType.WARHEAD, 3, 2, ResourceManager.mp_w_15_n2, ResourceManager.mp_w_15_n2_tex);
MissilePart.registerPart(ModItems.mp_warhead_15_mirv, PartType.WARHEAD, 3, 2, ResourceManager.mp_w_15_mirv, ResourceManager.mp_w_15_mirv_tex);
MissilePart.registerPart(ModItems.mp_warhead_15_balefire, PartType.WARHEAD, 2.75, 2, ResourceManager.mp_w_15_balefire, ResourceManager.mp_w_15_balefire_tex);
//
//MissilePart.registerPart(ModItems.mp_warhead_20_he, PartType.WARHEAD, 3, 2.25, ResourceManager.mp_w_20, ResourceManager.universal);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/hbm/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -2933,6 +2933,7 @@ item.mp_warhead_15_nuclear_shark.name=Size 15 Nuclear Warhead
item.mp_warhead_15_boxcar.name=Size 15 Boxcar?
item.mp_warhead_15_n2.name=Size 15 N² Mine
item.mp_warhead_15_balefire.name=Size 15 BF Warhead
item.mp_warhead_15_mirv.name=Size 15 MIRV Warhead

item.mp_fuselage_10_kerosene.name=Size 10 Kerosene Fuselage
item.mp_fuselage_10_kerosene_camo.name=Size 10 Kerosene Fuselage
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "hbm:items/code"
}
}
Loading

0 comments on commit 557b9dd

Please sign in to comment.