mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
custom missile external compat
This commit is contained in:
parent
98ed3fad91
commit
ff405e5aeb
@ -30,8 +30,8 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLoader {
|
||||
|
||||
protected float fuel;
|
||||
protected float consumption;
|
||||
public float fuel;
|
||||
public float consumption;
|
||||
|
||||
public EntityMissileCustom(World world) {
|
||||
super(world);
|
||||
@ -81,6 +81,12 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
|
||||
ItemCustomMissilePart part = (ItemCustomMissilePart) Item.getItemById(this.dataWatcher.getWatchableObjectInt(9));
|
||||
WarheadType type = (WarheadType) part.attributes[0];
|
||||
if(type != null && type.updateCustom != null) {
|
||||
type.updateCustom.accept(this);
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
if(this.hasPropulsion()) this.fuel -= this.consumption;
|
||||
@ -152,6 +158,11 @@ public class EntityMissileCustom extends EntityMissileBaseNT implements IChunkLo
|
||||
|
||||
WarheadType type = (WarheadType) part.attributes[0];
|
||||
float strength = (Float) part.attributes[1];
|
||||
|
||||
if(type.impactCustom != null) {
|
||||
type.impactCustom.accept(this);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case HE:
|
||||
|
||||
@ -2,7 +2,9 @@ package com.hbm.items.weapon;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.hbm.entity.missile.EntityMissileCustom;
|
||||
import com.hbm.items.special.ItemLootCrate;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
@ -86,7 +88,17 @@ public class ItemCustomMissilePart extends Item {
|
||||
SCHRAB,
|
||||
TAINT,
|
||||
CLOUD,
|
||||
TURBINE
|
||||
TURBINE,
|
||||
|
||||
//shit solution but it works. this allows traits to be attached to these empty dummy types, allowing for custom warheads
|
||||
CUSTOM0, CUSTOM1, CUSTOM2, CUSTOM3, CUSTOM4, CUSTOM5, CUSTOM6, CUSTOM7, CUSTOM8, CUSTOM9;
|
||||
|
||||
/** Overrides that type's impact effect. Only runs serverside */
|
||||
public Consumer<EntityMissileCustom> impactCustom = null;
|
||||
/** Runs at the beginning of the missile's update cycle, both client and serverside. */
|
||||
public Consumer<EntityMissileCustom> updateCustom = null;
|
||||
/** Override for the warhead's name in the missile description */
|
||||
public String labelCustom = null;
|
||||
}
|
||||
|
||||
public enum FuelType {
|
||||
@ -246,6 +258,8 @@ public class ItemCustomMissilePart extends Item {
|
||||
|
||||
public String getWarhead(WarheadType type) {
|
||||
|
||||
if(type.labelCustom != null) return type.labelCustom;
|
||||
|
||||
switch(type) {
|
||||
case HE:
|
||||
return EnumChatFormatting.YELLOW + "HE";
|
||||
|
||||
@ -5,10 +5,14 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.entity.missile.EntityMissileCustom;
|
||||
import com.hbm.explosion.ExplosionNukeSmall;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.items.weapon.ItemCustomMissilePart.WarheadType;
|
||||
import com.hbm.tileentity.machine.TileEntityDummy;
|
||||
import com.hbm.tileentity.turret.TileEntityTurretSentry;
|
||||
|
||||
@ -21,6 +25,7 @@ import net.minecraft.entity.passive.EntityChicken;
|
||||
import net.minecraft.entity.passive.EntityCow;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
@ -178,6 +183,10 @@ public class CompatExternal {
|
||||
public static void registerTurretTargetingCondition(Class clazz, BiFunction<Entity, Object, Integer> bi) {
|
||||
turretTargetBlacklist.add(clazz);
|
||||
}
|
||||
|
||||
public static void setWarheadLabel(WarheadType type, String label) { type.labelCustom = label; }
|
||||
public static void setWarheadImpact(WarheadType type, Consumer<EntityMissileCustom> impact) { type.impactCustom = impact; }
|
||||
public static void setWarheadUpdate(WarheadType type, Consumer<EntityMissileCustom> update) { type.updateCustom = update; }
|
||||
|
||||
public static void compatExamples() {
|
||||
// Makes all cows be targeted by turrets if player mode is active in addition to the existing rules. Applies to all entities that inherit EntityCow.
|
||||
@ -190,5 +199,10 @@ public class CompatExternal {
|
||||
if(turret instanceof TileEntityTurretSentry) return -1;
|
||||
return 0;
|
||||
});
|
||||
//configures CUSTOM0 to have a custom label and impact effect
|
||||
CompatExternal.setWarheadLabel(WarheadType.CUSTOM0, EnumChatFormatting.YELLOW + "Micro Nuke");
|
||||
CompatExternal.setWarheadImpact(WarheadType.CUSTOM0, (missile) -> {
|
||||
ExplosionNukeSmall.explode(missile.worldObj, missile.posX, missile.posY + 0.5, missile.posZ, ExplosionNukeSmall.PARAMS_MEDIUM);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user