deploy surface-to-yellow-one missile

This commit is contained in:
Boblet 2025-05-23 13:40:48 +02:00
parent 4fc41c631d
commit 148ba19721
22 changed files with 1148 additions and 1682 deletions

View File

@ -6,5 +6,10 @@
* Area and block abilities can now be toggled independently from each other. For example, the vein miner ability can be combined with silk touch * Area and block abilities can now be toggled independently from each other. For example, the vein miner ability can be combined with silk touch
* Clicking on the same ability allows switching between levels * Clicking on the same ability allows switching between levels
* Updated textures for the armor and gun modification tables * Updated textures for the armor and gun modification tables
* Ported the fire extinguisher to the SEDNA gun system, eliminating the final remaining ItemGunBase gun
* Water extinguishers can now wash away foam blocks
## Fixed ## Fixed
* Conveyor ejectors should now correctly place items onto the back of splitters instead of on the output belts
* Fixed strand caster fluid gauges going out of bounds
* Fixed arc welder and soldering station not changing buffer size based on upgrade, preventing use of higher overdrive tiers

View File

@ -13,10 +13,6 @@ public class BulletConfigSyncingUtil {
public static int TEST_CONFIG = i++; public static int TEST_CONFIG = i++;
public static int FEXT_NORMAL = i++;
public static int FEXT_FOAM = i++;
public static int FEXT_SAND = i++;
public static int TURBINE = i++; public static int TURBINE = i++;
public static int MASKMAN_BULLET = i++; public static int MASKMAN_BULLET = i++;
@ -33,10 +29,6 @@ public class BulletConfigSyncingUtil {
public static void loadConfigsForSync() { public static void loadConfigsForSync() {
configSet.put(FEXT_NORMAL, GunEnergyFactory.getFextConfig());
configSet.put(FEXT_FOAM, GunEnergyFactory.getFextFoamConfig());
configSet.put(FEXT_SAND, GunEnergyFactory.getFextSandConfig());
configSet.put(TURBINE, GunEnergyFactory.getTurbineConfig()); configSet.put(TURBINE, GunEnergyFactory.getTurbineConfig());
configSet.put(MASKMAN_BULLET, GunNPCFactory.getMaskmanBullet()); configSet.put(MASKMAN_BULLET, GunNPCFactory.getMaskmanBullet());

View File

@ -17,6 +17,7 @@ import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSourceIndirect; import net.minecraft.util.EntityDamageSourceIndirect;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
@Deprecated
public class BulletConfiguration implements Cloneable { public class BulletConfiguration implements Cloneable {
//what item this specific configuration consumes //what item this specific configuration consumes
@ -130,15 +131,12 @@ public class BulletConfiguration implements Cloneable {
public static final int STYLE_FOLLY = 5; public static final int STYLE_FOLLY = 5;
public static final int STYLE_ROCKET = 6; public static final int STYLE_ROCKET = 6;
public static final int STYLE_STINGER = 7; public static final int STYLE_STINGER = 7;
public static final int STYLE_NUKE = 8;
public static final int STYLE_MIRV = 9;
public static final int STYLE_GRENADE = 10; public static final int STYLE_GRENADE = 10;
public static final int STYLE_BF = 11; public static final int STYLE_BF = 11;
public static final int STYLE_ORB = 12; public static final int STYLE_ORB = 12;
public static final int STYLE_METEOR = 13; public static final int STYLE_METEOR = 13;
public static final int STYLE_APDS = 14; public static final int STYLE_APDS = 14;
public static final int STYLE_BLADE = 15; public static final int STYLE_BLADE = 15;
public static final int STYLE_BARREL = 16;
public static final int STYLE_TAU = 17; public static final int STYLE_TAU = 17;
public static final int STYLE_LEADBURSTER = 18; public static final int STYLE_LEADBURSTER = 18;
@ -174,13 +172,6 @@ public class BulletConfiguration implements Cloneable {
return this; return this;
} }
public BulletConfiguration setToGuided() {
this.bntUpdate = BulletConfigFactory.getLaserSteering();
this.doesRicochet = false;
return this;
}
public BulletConfiguration getChlorophyte() { public BulletConfiguration getChlorophyte() {
this.bntUpdate = BulletConfigFactory.getHomingBehavior(30, 180); this.bntUpdate = BulletConfigFactory.getHomingBehavior(30, 180);
this.bntHurt = BulletConfigFactory.getPenHomingBehavior(); this.bntHurt = BulletConfigFactory.getPenHomingBehavior();

View File

@ -12,6 +12,7 @@ import com.hbm.render.anim.HbmAnimations.AnimType;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@Deprecated
public class GunConfiguration implements Cloneable { public class GunConfiguration implements Cloneable {
/** /**
@ -46,10 +47,6 @@ public class GunConfiguration implements Cloneable {
public boolean isCentered; public boolean isCentered;
//texture overlay when sneaking //texture overlay when sneaking
public ResourceLocation scopeTexture; public ResourceLocation scopeTexture;
//whether the FOV multiplier should be absolute or multiplicative to other modifiers, multiplicative mode is experimental!
public boolean absoluteFOV = true;
//the target FOV/multiplied FOV modifier when sneaking
public float zoomFOV = 0.0F;
//duration of every animation cycle, used also for how quickly a burst fire rifle can fire //duration of every animation cycle, used also for how quickly a burst fire rifle can fire
public int firingDuration; public int firingDuration;
@ -122,10 +119,5 @@ public class GunConfiguration implements Cloneable {
public static final String RSOUND_GRENADE = "hbm:weapon.hkReload"; public static final String RSOUND_GRENADE = "hbm:weapon.hkReload";
public static final String RSOUND_GRENADE_NEW = "hbm:weapon.glReload"; public static final String RSOUND_GRENADE_NEW = "hbm:weapon.glReload";
public static final String RSOUND_FATMAN = "hbm:weapon.fatmanReload"; public static final String RSOUND_FATMAN = "hbm:weapon.fatmanReload";
public GunConfiguration silenced() {
this.firingSound = "hbm:weapon.silencerShoot";
return this;
}
} }

View File

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.google.common.base.Functions;
import com.hbm.main.MainRegistry; import com.hbm.main.MainRegistry;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
@ -16,118 +15,109 @@ import net.minecraft.util.EnumChatFormatting;
// All abilities available on a given tool // All abilities available on a given tool
public class AvailableAbilities { public class AvailableAbilities {
// Insertion order matters // Insertion order matters
private HashMap<IBaseAbility, Integer> abilities = new HashMap<IBaseAbility, Integer>(); private HashMap<IBaseAbility, Integer> abilities = new HashMap<IBaseAbility, Integer>();
public AvailableAbilities() {} public AvailableAbilities() { }
public AvailableAbilities addAbility(IBaseAbility ability, int level) { public AvailableAbilities addAbility(IBaseAbility ability, int level) {
if (level < 0 || level >= ability.levels()) { if(level < 0 || level >= ability.levels()) {
MainRegistry.logger.warn("Illegal level " + level + " for ability " + ability.getName()); MainRegistry.logger.warn("Illegal level " + level + " for ability " + ability.getName());
level = ability.levels() - 1; level = ability.levels() - 1;
} }
if (abilities.containsKey(ability)) { if(abilities.containsKey(ability)) {
MainRegistry.logger.warn("Ability " + ability.getName() + " already had level " + abilities.get(ability) + ", overwriting with level " + level); MainRegistry.logger.warn("Ability " + ability.getName() + " already had level " + abilities.get(ability) + ", overwriting with level " + level);
} }
if (ability.isAllowed()) { if(ability.isAllowed()) {
abilities.put(ability, level); abilities.put(ability, level);
} }
return this; return this;
} }
public AvailableAbilities addToolAbilities() { public AvailableAbilities addToolAbilities() {
addAbility(IToolAreaAbility.NONE, 0); addAbility(IToolAreaAbility.NONE, 0);
addAbility(IToolHarvestAbility.NONE, 0); addAbility(IToolHarvestAbility.NONE, 0);
return this; return this;
} }
public AvailableAbilities removeAbility(IBaseAbility ability) { public AvailableAbilities removeAbility(IBaseAbility ability) {
abilities.remove(ability); abilities.remove(ability);
return this; return this;
} }
public boolean supportsAbility(IBaseAbility ability) { public boolean supportsAbility(IBaseAbility ability) {
return abilities.containsKey(ability); return abilities.containsKey(ability);
} }
public int maxLevel(IBaseAbility ability) { public int maxLevel(IBaseAbility ability) {
return abilities.getOrDefault(ability, -1); return abilities.getOrDefault(ability, -1);
} }
public Map<IBaseAbility, Integer> get() { public Map<IBaseAbility, Integer> get() {
return Collections.unmodifiableMap(abilities); return Collections.unmodifiableMap(abilities);
} }
public Map<IWeaponAbility, Integer> getWeaponAbilities() { public Map<IWeaponAbility, Integer> getWeaponAbilities() {
return abilities.keySet().stream().filter(a -> a instanceof IWeaponAbility).collect(Collectors.toMap(a -> (IWeaponAbility)a, a -> abilities.get(a))); return abilities.keySet().stream().filter(a -> a instanceof IWeaponAbility).collect(Collectors.toMap(a -> (IWeaponAbility) a, a -> abilities.get(a)));
} }
public Map<IBaseAbility, Integer> getToolAbilities() { public Map<IBaseAbility, Integer> getToolAbilities() {
return abilities.keySet().stream().filter(a -> a instanceof IToolAreaAbility || a instanceof IToolHarvestAbility).collect(Collectors.toMap(a -> a, a -> abilities.get(a))); return abilities.keySet().stream().filter(a -> a instanceof IToolAreaAbility || a instanceof IToolHarvestAbility).collect(Collectors.toMap(a -> a, a -> abilities.get(a)));
} }
public Map<IToolAreaAbility, Integer> getToolAreaAbilities() { public Map<IToolAreaAbility, Integer> getToolAreaAbilities() {
return abilities.keySet().stream().filter(a -> a instanceof IToolAreaAbility).collect(Collectors.toMap(a -> (IToolAreaAbility)a, a -> abilities.get(a))); return abilities.keySet().stream().filter(a -> a instanceof IToolAreaAbility).collect(Collectors.toMap(a -> (IToolAreaAbility) a, a -> abilities.get(a)));
} }
public Map<IToolHarvestAbility, Integer> getToolHarvestAbilities() { public Map<IToolHarvestAbility, Integer> getToolHarvestAbilities() {
return abilities.keySet().stream().filter(a -> a instanceof IToolHarvestAbility).collect(Collectors.toMap(a -> (IToolHarvestAbility)a, a -> abilities.get(a))); return abilities.keySet().stream().filter(a -> a instanceof IToolHarvestAbility).collect(Collectors.toMap(a -> (IToolHarvestAbility) a, a -> abilities.get(a)));
} }
public int size() { public int size() {
return abilities.size(); return abilities.size();
} }
public boolean isEmpty() { public boolean isEmpty() {
return abilities.isEmpty(); return abilities.isEmpty();
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void addInformation(List list) { public void addInformation(List list) {
List<Map.Entry<IBaseAbility, Integer>> toolAbilities = abilities.entrySet().stream().filter(entry -> List<Map.Entry<IBaseAbility, Integer>> toolAbilities = abilities.entrySet().stream()
(entry.getKey() instanceof IToolAreaAbility && entry.getKey() != IToolAreaAbility.NONE) || .filter(entry -> (entry.getKey() instanceof IToolAreaAbility && entry.getKey() != IToolAreaAbility.NONE)
(entry.getKey() instanceof IToolHarvestAbility && entry.getKey() != IToolHarvestAbility.NONE) || (entry.getKey() instanceof IToolHarvestAbility && entry.getKey() != IToolHarvestAbility.NONE))
).sorted( .sorted(Comparator.comparing(Map.Entry<IBaseAbility, Integer>::getKey).thenComparing(Map.Entry<IBaseAbility, Integer>::getValue)).collect(Collectors.toList());
Comparator
.comparing(Map.Entry<IBaseAbility, Integer>::getKey)
.thenComparing(Map.Entry<IBaseAbility, Integer>::getValue)
).collect(Collectors.toList());
if (!toolAbilities.isEmpty()) {
list.add("Abilities: ");
toolAbilities.forEach(entry -> { if(!toolAbilities.isEmpty()) {
IBaseAbility ability = entry.getKey(); list.add("Abilities: ");
int level = entry.getValue();
toolAbilities.forEach(entry -> {
list.add(" " + EnumChatFormatting.GOLD + ability.getFullName(level)); IBaseAbility ability = entry.getKey();
}); int level = entry.getValue();
list.add(" " + EnumChatFormatting.GOLD + ability.getFullName(level));
});
list.add("Right click to cycle through presets!"); list.add("Right click to cycle through presets!");
list.add("Sneak-click to go to first preset!"); list.add("Sneak-click to go to first preset!");
list.add("Alt-click to open customization GUI!"); list.add("Alt-click to open customization GUI!");
} }
List<Map.Entry<IBaseAbility, Integer>> weaponAbilities = abilities.entrySet().stream().filter(entry ->
(entry.getKey() instanceof IWeaponAbility && entry.getKey() != IWeaponAbility.NONE)
).sorted(
Comparator
.comparing(Map.Entry<IBaseAbility, Integer>::getKey)
.thenComparing(Map.Entry<IBaseAbility, Integer>::getValue)
).collect(Collectors.toList());
if (!weaponAbilities.isEmpty()) {
list.add("Weapon modifiers: ");
weaponAbilities.forEach(entry -> {
IBaseAbility ability = entry.getKey();
int level = entry.getValue();
list.add(" " + EnumChatFormatting.RED + ability.getFullName(level)); List<Map.Entry<IBaseAbility, Integer>> weaponAbilities = abilities.entrySet().stream().filter(entry -> (entry.getKey() instanceof IWeaponAbility && entry.getKey() != IWeaponAbility.NONE))
}); .sorted(Comparator.comparing(Map.Entry<IBaseAbility, Integer>::getKey).thenComparing(Map.Entry<IBaseAbility, Integer>::getValue)).collect(Collectors.toList());
}
} if(!weaponAbilities.isEmpty()) {
list.add("Weapon modifiers: ");
weaponAbilities.forEach(entry -> {
IBaseAbility ability = entry.getKey();
int level = entry.getValue();
list.add(" " + EnumChatFormatting.RED + ability.getFullName(level));
});
}
}
} }

View File

@ -3,34 +3,34 @@ package com.hbm.handler.ability;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
public interface IBaseAbility extends Comparable<IBaseAbility> { public interface IBaseAbility extends Comparable<IBaseAbility> {
public String getName(); public String getName();
public default String getExtension(int level) { public default String getExtension(int level) {
return ""; return "";
} }
public default String getFullName(int level) { public default String getFullName(int level) {
return I18n.format(getName()) + getExtension(level); return I18n.format(getName()) + getExtension(level);
} }
public default boolean isAllowed() { public default boolean isAllowed() {
return true; return true;
} }
// 1 means no support for levels (i.e. the level is always 0). // 1 means no support for levels (i.e. the level is always 0).
// The UI only supports levels() between 1 and 10 (inclusive). // The UI only supports levels() between 1 and 10 (inclusive).
// All calls accepting an `int level` parameters must be done // All calls accepting an `int level` parameters must be done
// with a level between 0 and levels()-1 (inclusive). // with a level between 0 and levels()-1 (inclusive).
default int levels() { default int levels() {
return 1; return 1;
} }
default int sortOrder() { default int sortOrder() {
return hashCode(); return hashCode();
} }
@Override @Override
default int compareTo(IBaseAbility o) { default int compareTo(IBaseAbility o) {
return sortOrder() - o.sortOrder(); return sortOrder() - o.sortOrder();
} }
} }

View File

@ -10,274 +10,274 @@ import com.hbm.config.ToolConfig;
import com.hbm.explosion.ExplosionNT; import com.hbm.explosion.ExplosionNT;
import com.hbm.explosion.ExplosionNT.ExAttrib; import com.hbm.explosion.ExplosionNT.ExAttrib;
import com.hbm.handler.ThreeInts; import com.hbm.handler.ThreeInts;
import com.hbm.inventory.OreDictManager;
import com.hbm.items.tool.ItemToolAbility; import com.hbm.items.tool.ItemToolAbility;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
public interface IToolAreaAbility extends IBaseAbility { public interface IToolAreaAbility extends IBaseAbility {
// Should call tool.breakExtraBlock on a bunch of blocks. // Should call tool.breakExtraBlock on a bunch of blocks.
// The initial block is implicitly broken, so don't call breakExtraBlock on it. // The initial block is implicitly broken, so don't call breakExtraBlock on it.
// Returning true skips the reference block from being broken // Returning true skips the reference block from being broken
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool); public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool);
// Whether breakExtraBlock is called at all. Currently only false for explosion
public default boolean allowsHarvest(int level) {
return true;
}
public final static int SORT_ORDER_BASE = 0; // Whether breakExtraBlock is called at all. Currently only false for explosion
public default boolean allowsHarvest(int level) {
return true;
}
// region handlers public final static int SORT_ORDER_BASE = 0;
public static final IToolAreaAbility NONE = new IToolAreaAbility() {
@Override
public String getName() {
return "";
}
@Override // region handlers
public int sortOrder() { public static final IToolAreaAbility NONE = new IToolAreaAbility() {
return SORT_ORDER_BASE + 0; @Override
} public String getName() {
return "";
@Override }
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
return false;
}
};
public static final IToolAreaAbility RECURSION = new IToolAreaAbility() { @Override
@Override public int sortOrder() {
public String getName() { return SORT_ORDER_BASE + 0;
return "tool.ability.recursion"; }
}
@Override @Override
public boolean isAllowed() { public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
return ToolConfig.abilityVein; return false;
} }
};
public final int[] radiusAtLevel = {3, 4, 5, 6, 7, 9, 10}; public static final IToolAreaAbility RECURSION = new IToolAreaAbility() {
@Override
public String getName() {
return "tool.ability.recursion";
}
@Override @Override
public int levels() { public boolean isAllowed() {
return radiusAtLevel.length; return ToolConfig.abilityVein;
} }
@Override public final int[] radiusAtLevel = { 3, 4, 5, 6, 7, 9, 10 };
public String getExtension(int level) {
return " (" + radiusAtLevel[level] + ")";
}
@Override @Override
public int sortOrder() { public int levels() {
return SORT_ORDER_BASE + 1; return radiusAtLevel.length;
} }
// Note: if reusing it across different instatces of a tool @Override
// is a problem here, then it had already been one before public String getExtension(int level) {
// the refactor! The solution is to simply make this a local return " (" + radiusAtLevel[level] + ")";
// of the onDig method and pass it around as a parameter. }
private Set<ThreeInts> pos = new HashSet<>();
@Override @Override
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) { public int sortOrder() {
Block b = world.getBlock(x, y, z); return SORT_ORDER_BASE + 1;
}
if(b == Blocks.stone && !ToolConfig.recursiveStone) {
return false;
}
if(b == Blocks.netherrack && !ToolConfig.recursiveNetherrack) { // Note: if reusing it across different instatces of a tool
return false; // is a problem here, then it had already been one before
} // the refactor! The solution is to simply make this a local
// of the onDig method and pass it around as a parameter.
pos.clear(); private Set<ThreeInts> pos = new HashSet<>();
recurse(world, x, y, z, x, y, z, player, tool, 0, radiusAtLevel[level]); @Override
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
Block b = world.getBlock(x, y, z);
return false; if(b == Blocks.stone && !ToolConfig.recursiveStone) {
} return false;
}
private final List<ThreeInts> offsets = new ArrayList<ThreeInts>(3*3*3-1) {{ if(b == Blocks.netherrack && !ToolConfig.recursiveNetherrack) {
for (int dx = -1; dx <= 1; dx++) { return false;
for (int dy = -1; dy <= 1; dy++) { }
for (int dz = -1; dz <= 1; dz++) {
if (dx != 0 || dy != 0 || dz != 0) {
add(new ThreeInts(dx, dy, dz));
}
}
}
}
}};
private void recurse(World world, int x, int y, int z, int refX, int refY, int refZ, EntityPlayer player, ItemToolAbility tool, int depth, int radius) { pos.clear();
List<ThreeInts> shuffledOffsets = new ArrayList<>(offsets);
Collections.shuffle(shuffledOffsets);
for(ThreeInts offset : shuffledOffsets) {
breakExtra(world, x + offset.x, y + offset.y, z + offset.z, refX, refY, refZ, player, tool, depth, radius);
}
}
private void breakExtra(World world, int x, int y, int z, int refX, int refY, int refZ, EntityPlayer player, ItemToolAbility tool, int depth, int radius) {
if(pos.contains(new ThreeInts(x, y, z)))
return;
depth += 1;
if(depth > ToolConfig.recursionDepth)
return;
pos.add(new ThreeInts(x, y, z));
//don't lose the ref block just yet
if(x == refX && y == refY && z == refZ)
return;
if(Vec3.createVectorHelper(x - refX, y - refY, z - refZ).lengthVector() > radius)
return;
Block b = world.getBlock(x, y, z);
Block ref = world.getBlock(refX, refY, refZ);
int meta = world.getBlockMetadata(x, y, z);
int refMeta = world.getBlockMetadata(refX, refY, refZ);
if(!isSameBlock(b, ref))
return;
if(meta != refMeta)
return;
if(player.getHeldItem() == null)
return;
tool.breakExtraBlock(world, x, y, z, player, refX, refY, refZ);
recurse(world, x, y, z, refX, refY, refZ, player, tool, depth, radius); recurse(world, x, y, z, x, y, z, player, tool, 0, radiusAtLevel[level]);
}
private boolean isSameBlock(Block b1, Block b2) {
if(b1 == b2) return true;
if((b1 == Blocks.redstone_ore && b2 == Blocks.lit_redstone_ore) || (b1 == Blocks.lit_redstone_ore && b2 == Blocks.redstone_ore)) return true;
return false;
}
};
public static final IToolAreaAbility HAMMER = new IToolAreaAbility() { return false;
@Override }
public String getName() {
return "tool.ability.hammer";
}
@Override private final List<ThreeInts> offsets = new ArrayList<ThreeInts>(3 * 3 * 3 - 1) {
public boolean isAllowed() { {
return ToolConfig.abilityHammer; for(int dx = -1; dx <= 1; dx++) {
} for(int dy = -1; dy <= 1; dy++) {
for(int dz = -1; dz <= 1; dz++) {
if(dx != 0 || dy != 0 || dz != 0) {
add(new ThreeInts(dx, dy, dz));
}
}
}
}
}
};
public final int[] rangeAtLevel = {1, 2, 3, 4}; private void recurse(World world, int x, int y, int z, int refX, int refY, int refZ, EntityPlayer player, ItemToolAbility tool, int depth, int radius) {
List<ThreeInts> shuffledOffsets = new ArrayList<>(offsets);
Collections.shuffle(shuffledOffsets);
@Override for(ThreeInts offset : shuffledOffsets) {
public int levels() { breakExtra(world, x + offset.x, y + offset.y, z + offset.z, refX, refY, refZ, player, tool, depth, radius);
return rangeAtLevel.length; }
} }
@Override private void breakExtra(World world, int x, int y, int z, int refX, int refY, int refZ, EntityPlayer player, ItemToolAbility tool, int depth, int radius) {
public String getExtension(int level) { if(pos.contains(new ThreeInts(x, y, z)))
return " (" + rangeAtLevel[level] + ")"; return;
}
@Override depth += 1;
public int sortOrder() {
return SORT_ORDER_BASE + 2;
}
@Override if(depth > ToolConfig.recursionDepth)
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) { return;
int range = rangeAtLevel[level];
for(int a = x - range; a <= x + range; a++) {
for(int b = y - range; b <= y + range; b++) {
for(int c = z - range; c <= z + range; c++) {
if (a == x && b == y && c == z)
continue;
tool.breakExtraBlock(world, a, b ,c, player, x, y, z);
}
}
}
return false; pos.add(new ThreeInts(x, y, z));
}
};
public static final IToolAreaAbility EXPLOSION = new IToolAreaAbility() { // don't lose the ref block just yet
@Override if(x == refX && y == refY && z == refZ)
public String getName() { return;
return "tool.ability.explosion";
}
@Override if(Vec3.createVectorHelper(x - refX, y - refY, z - refZ).lengthVector() > radius)
public boolean isAllowed() { return;
return ToolConfig.abilityExplosion;
}
public final float[] strengthAtLevel = {2.5F, 5F, 10F, 15F}; Block b = world.getBlock(x, y, z);
Block ref = world.getBlock(refX, refY, refZ);
int meta = world.getBlockMetadata(x, y, z);
int refMeta = world.getBlockMetadata(refX, refY, refZ);
@Override if(!isSameBlock(b, ref))
public int levels() { return;
return strengthAtLevel.length;
}
@Override if(meta != refMeta)
public String getExtension(int level) { return;
return " (" + strengthAtLevel[level] + ")";
}
@Override if(player.getHeldItem() == null)
public boolean allowsHarvest(int level) { return;
return false;
}
@Override tool.breakExtraBlock(world, x, y, z, player, refX, refY, refZ);
public int sortOrder() {
return SORT_ORDER_BASE + 3;
}
@Override recurse(world, x, y, z, refX, refY, refZ, player, tool, depth, radius);
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) { }
float strength = strengthAtLevel[level];
ExplosionNT ex = new ExplosionNT(player.worldObj, player, x + 0.5, y + 0.5, z + 0.5, strength);
ex.addAttrib(ExAttrib.ALLDROP);
ex.addAttrib(ExAttrib.NOHURT);
ex.addAttrib(ExAttrib.NOPARTICLE);
ex.doExplosionA();
ex.doExplosionB(false);
player.worldObj.createExplosion(player, x + 0.5, y + 0.5, z + 0.5, 0.1F, false);
return true;
}
};
// endregion handlers
static final IToolAreaAbility[] abilities = {NONE, RECURSION, HAMMER, EXPLOSION}; private boolean isSameBlock(Block b1, Block b2) {
if(b1 == b2)
return true;
if((b1 == Blocks.redstone_ore && b2 == Blocks.lit_redstone_ore) || (b1 == Blocks.lit_redstone_ore && b2 == Blocks.redstone_ore))
return true;
static IToolAreaAbility getByName(String name) { return false;
for(IToolAreaAbility ability : abilities) { }
if(ability.getName().equals(name)) };
return ability;
} public static final IToolAreaAbility HAMMER = new IToolAreaAbility() {
@Override
return NONE; public String getName() {
} return "tool.ability.hammer";
}
@Override
public boolean isAllowed() {
return ToolConfig.abilityHammer;
}
public final int[] rangeAtLevel = { 1, 2, 3, 4 };
@Override
public int levels() {
return rangeAtLevel.length;
}
@Override
public String getExtension(int level) {
return " (" + rangeAtLevel[level] + ")";
}
@Override
public int sortOrder() {
return SORT_ORDER_BASE + 2;
}
@Override
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
int range = rangeAtLevel[level];
for(int a = x - range; a <= x + range; a++) {
for(int b = y - range; b <= y + range; b++) {
for(int c = z - range; c <= z + range; c++) {
if(a == x && b == y && c == z)
continue;
tool.breakExtraBlock(world, a, b, c, player, x, y, z);
}
}
}
return false;
}
};
public static final IToolAreaAbility EXPLOSION = new IToolAreaAbility() {
@Override
public String getName() {
return "tool.ability.explosion";
}
@Override
public boolean isAllowed() {
return ToolConfig.abilityExplosion;
}
public final float[] strengthAtLevel = { 2.5F, 5F, 10F, 15F };
@Override
public int levels() {
return strengthAtLevel.length;
}
@Override
public String getExtension(int level) {
return " (" + strengthAtLevel[level] + ")";
}
@Override
public boolean allowsHarvest(int level) {
return false;
}
@Override
public int sortOrder() {
return SORT_ORDER_BASE + 3;
}
@Override
public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) {
float strength = strengthAtLevel[level];
ExplosionNT ex = new ExplosionNT(player.worldObj, player, x + 0.5, y + 0.5, z + 0.5, strength);
ex.addAttrib(ExAttrib.ALLDROP);
ex.addAttrib(ExAttrib.NOHURT);
ex.addAttrib(ExAttrib.NOPARTICLE);
ex.doExplosionA();
ex.doExplosionB(false);
player.worldObj.createExplosion(player, x + 0.5, y + 0.5, z + 0.5, 0.1F, false);
return true;
}
};
// endregion handlers
static final IToolAreaAbility[] abilities = { NONE, RECURSION, HAMMER, EXPLOSION };
static IToolAreaAbility getByName(String name) {
for(IToolAreaAbility ability : abilities) {
if(ability.getName().equals(name))
return ability;
}
return NONE;
}
} }

View File

@ -23,319 +23,321 @@ import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.world.World; import net.minecraft.world.World;
public interface IToolHarvestAbility extends IBaseAbility { public interface IToolHarvestAbility extends IBaseAbility {
public default void preHarvestAll(int level, World world, EntityPlayer player) {}
public default void preHarvestAll(int level, World world, EntityPlayer player) { }
public default void postHarvestAll(int level, World world, EntityPlayer player) { }
public default void postHarvestAll(int level, World world, EntityPlayer player) {} // You must call harvestBlock to actually break the block.
// If you don't, visual glitches ensue
public default void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) {
harvestBlock(false, world, x, y, z, player);
}
// You must call harvestBlock to actually break the block. public static void harvestBlock(boolean skipDefaultDrops, World world, int x, int y, int z, EntityPlayer player) {
// If you don't, visual glitches ensue if(skipDefaultDrops) {
public default void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) { // Emulate the block breaking without drops
harvestBlock(false, world, x, y, z, player); world.setBlockToAir(x, y, z);
} player.getHeldItem().damageItem(1, player);
} else if(player instanceof EntityPlayerMP) {
// Break the block conventionally
ItemToolAbility.standardDigPost(world, x, y, z, (EntityPlayerMP) player);
}
}
public static void harvestBlock(boolean skipDefaultDrops, World world, int x, int y, int z, EntityPlayer player) { public final static int SORT_ORDER_BASE = 100;
if (skipDefaultDrops) {
// Emulate the block breaking without drops
world.setBlockToAir(x, y, z);
player.getHeldItem().damageItem(1, player);
} else if (player instanceof EntityPlayerMP) {
// Break the block conventionally
ItemToolAbility.standardDigPost(world, x, y, z, (EntityPlayerMP) player);
}
}
public final static int SORT_ORDER_BASE = 100; // region handlers
public static final IToolHarvestAbility NONE = new IToolHarvestAbility() {
@Override
public String getName() {
return "";
}
// region handlers @Override
public static final IToolHarvestAbility NONE = new IToolHarvestAbility() { public int sortOrder() {
@Override return SORT_ORDER_BASE + 0;
public String getName() { }
return ""; };
}
@Override public static final IToolHarvestAbility SILK = new IToolHarvestAbility() {
public int sortOrder() { @Override
return SORT_ORDER_BASE + 0; public String getName() {
} return "tool.ability.silktouch";
}; }
public static final IToolHarvestAbility SILK = new IToolHarvestAbility() { @Override
@Override public boolean isAllowed() {
public String getName() { return ToolConfig.abilitySilk;
return "tool.ability.silktouch"; }
}
@Override @Override
public boolean isAllowed() { public int sortOrder() {
return ToolConfig.abilitySilk; return SORT_ORDER_BASE + 1;
} }
@Override @Override
public int sortOrder() { public void preHarvestAll(int level, World world, EntityPlayer player) {
return SORT_ORDER_BASE + 1; ItemStack stack = player.getHeldItem();
} EnchantmentUtil.addEnchantment(stack, Enchantment.silkTouch, 1);
}
@Override @Override
public void preHarvestAll(int level, World world, EntityPlayer player) { public void postHarvestAll(int level, World world, EntityPlayer player) {
ItemStack stack = player.getHeldItem(); // ToC-ToU mismatch should be impossible
EnchantmentUtil.addEnchantment(stack, Enchantment.silkTouch, 1); // because both calls happen on the same tick.
} // Even if can be forced somehow, the player doesn't gain any
// benefit from it.
ItemStack stack = player.getHeldItem();
EnchantmentUtil.removeEnchantment(stack, Enchantment.silkTouch);
}
};
@Override public static final IToolHarvestAbility LUCK = new IToolHarvestAbility() {
public void postHarvestAll(int level, World world, EntityPlayer player) { @Override
// ToC-ToU mismatch should be impossible public String getName() {
// because both calls happen on the same tick. return "tool.ability.luck";
// Even if can be forced somehow, the player doesn't gain any benefit from it. }
ItemStack stack = player.getHeldItem();
EnchantmentUtil.removeEnchantment(stack, Enchantment.silkTouch);
}
};
public static final IToolHarvestAbility LUCK = new IToolHarvestAbility() { @Override
@Override public boolean isAllowed() {
public String getName() { return ToolConfig.abilityLuck;
return "tool.ability.luck"; }
}
@Override public final int[] powerAtLevel = { 1, 2, 3, 4, 5, 9 };
public boolean isAllowed() {
return ToolConfig.abilityLuck;
}
public final int[] powerAtLevel = {1, 2, 3, 4, 5, 9}; @Override
public int levels() {
return powerAtLevel.length;
}
@Override @Override
public int levels() { public String getExtension(int level) {
return powerAtLevel.length; return " (" + powerAtLevel[level] + ")";
} }
@Override @Override
public String getExtension(int level) { public int sortOrder() {
return " (" + powerAtLevel[level] + ")"; return SORT_ORDER_BASE + 2;
} }
@Override @Override
public int sortOrder() { public void preHarvestAll(int level, World world, EntityPlayer player) {
return SORT_ORDER_BASE + 2; ItemStack stack = player.getHeldItem();
} EnchantmentUtil.addEnchantment(stack, Enchantment.fortune, powerAtLevel[level]);
}
@Override @Override
public void preHarvestAll(int level, World world, EntityPlayer player) { public void postHarvestAll(int level, World world, EntityPlayer player) {
ItemStack stack = player.getHeldItem(); // ToC-ToU mismatch should be impossible
EnchantmentUtil.addEnchantment(stack, Enchantment.fortune, powerAtLevel[level]); // because both calls happen on the same tick.
} // Even if can be forced somehow, the player doesn't gain any
// benefit from it.
ItemStack stack = player.getHeldItem();
EnchantmentUtil.removeEnchantment(stack, Enchantment.fortune);
}
};
@Override public static final IToolHarvestAbility SMELTER = new IToolHarvestAbility() {
public void postHarvestAll(int level, World world, EntityPlayer player) { @Override
// ToC-ToU mismatch should be impossible public String getName() {
// because both calls happen on the same tick. return "tool.ability.smelter";
// Even if can be forced somehow, the player doesn't gain any benefit from it. }
ItemStack stack = player.getHeldItem();
EnchantmentUtil.removeEnchantment(stack, Enchantment.fortune);
}
};
public static final IToolHarvestAbility SMELTER = new IToolHarvestAbility() { @Override
@Override public boolean isAllowed() {
public String getName() { return ToolConfig.abilityFurnace;
return "tool.ability.smelter"; }
}
@Override @Override
public boolean isAllowed() { public int sortOrder() {
return ToolConfig.abilityFurnace; return SORT_ORDER_BASE + 3;
} }
@Override @Override
public int sortOrder() { public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) {
return SORT_ORDER_BASE + 3; List<ItemStack> drops = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
}
@Override boolean doesSmelt = false;
public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) {
List<ItemStack> drops = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
boolean doesSmelt = false;
for(int i = 0; i < drops.size(); i++) {
ItemStack stack = drops.get(i).copy();
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
if(result != null) {
result = result.copy();
result.stackSize *= stack.stackSize;
drops.set(i, result);
doesSmelt = true;
}
}
harvestBlock(doesSmelt, world, x, y, z, player);
if(doesSmelt) { for(int i = 0; i < drops.size(); i++) {
for(ItemStack stack : drops) { ItemStack stack = drops.get(i).copy();
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack.copy())); ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack);
}
}
}
};
public static final IToolHarvestAbility SHREDDER = new IToolHarvestAbility() { if(result != null) {
@Override result = result.copy();
public String getName() { result.stackSize *= stack.stackSize;
return "tool.ability.shredder"; drops.set(i, result);
} doesSmelt = true;
}
}
@Override harvestBlock(doesSmelt, world, x, y, z, player);
public boolean isAllowed() {
return ToolConfig.abilityShredder;
}
@Override if(doesSmelt) {
public int sortOrder() { for(ItemStack stack : drops) {
return SORT_ORDER_BASE + 4; world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack.copy()));
} }
}
}
};
@Override public static final IToolHarvestAbility SHREDDER = new IToolHarvestAbility() {
public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) { @Override
//a band-aid on a gaping wound public String getName() {
if(block == Blocks.lit_redstone_ore) return "tool.ability.shredder";
block = Blocks.redstone_ore; }
ItemStack stack = new ItemStack(block, 1, meta);
ItemStack result = ShredderRecipes.getShredderResult(stack);
boolean doesShred = result != null && result.getItem() != ModItems.scrap; @Override
public boolean isAllowed() {
return ToolConfig.abilityShredder;
}
harvestBlock(doesShred, world, x, y, z, player); @Override
public int sortOrder() {
if(doesShred) { return SORT_ORDER_BASE + 4;
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, result.copy())); }
}
}
};
public static final IToolHarvestAbility CENTRIFUGE = new IToolHarvestAbility() { @Override
@Override public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) {
public String getName() { // a band-aid on a gaping wound
return "tool.ability.centrifuge"; if(block == Blocks.lit_redstone_ore)
} block = Blocks.redstone_ore;
@Override ItemStack stack = new ItemStack(block, 1, meta);
public boolean isAllowed() { ItemStack result = ShredderRecipes.getShredderResult(stack);
return ToolConfig.abilityCentrifuge;
}
@Override boolean doesShred = result != null && result.getItem() != ModItems.scrap;
public int sortOrder() {
return SORT_ORDER_BASE + 5;
}
@Override harvestBlock(doesShred, world, x, y, z, player);
public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) {
//a band-aid on a gaping wound
if(block == Blocks.lit_redstone_ore)
block = Blocks.redstone_ore;
ItemStack stack = new ItemStack(block, 1, meta);
ItemStack[] result = CentrifugeRecipes.getOutput(stack);
boolean doesCentrifuge = result != null; if(doesShred) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, result.copy()));
harvestBlock(doesCentrifuge, world, x, y, z, player); }
}
if(doesCentrifuge) { };
for(ItemStack st : result) {
if(st != null) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, st.copy()));
}
}
}
}
};
public static final IToolHarvestAbility CRYSTALLIZER = new IToolHarvestAbility() { public static final IToolHarvestAbility CENTRIFUGE = new IToolHarvestAbility() {
@Override @Override
public String getName() { public String getName() {
return "tool.ability.crystallizer"; return "tool.ability.centrifuge";
} }
@Override @Override
public boolean isAllowed() { public boolean isAllowed() {
return ToolConfig.abilityCrystallizer; return ToolConfig.abilityCentrifuge;
} }
@Override @Override
public int sortOrder() { public int sortOrder() {
return SORT_ORDER_BASE + 6; return SORT_ORDER_BASE + 5;
} }
@Override @Override
public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) { public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) {
//a band-aid on a gaping wound // a band-aid on a gaping wound
if(block == Blocks.lit_redstone_ore) if(block == Blocks.lit_redstone_ore)
block = Blocks.redstone_ore; block = Blocks.redstone_ore;
ItemStack stack = new ItemStack(block, 1, meta);
CrystallizerRecipe result = CrystallizerRecipes.getOutput(stack, Fluids.PEROXIDE);
boolean doesCrystallize = result != null; ItemStack stack = new ItemStack(block, 1, meta);
ItemStack[] result = CentrifugeRecipes.getOutput(stack);
harvestBlock(doesCrystallize, world, x, y, z, player);
if(doesCrystallize) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, result.output.copy()));
}
}
};
public static final IToolHarvestAbility MERCURY = new IToolHarvestAbility() {
@Override
public String getName() {
return "tool.ability.mercury";
}
@Override boolean doesCentrifuge = result != null;
public boolean isAllowed() {
return ToolConfig.abilityMercury;
}
@Override harvestBlock(doesCentrifuge, world, x, y, z, player);
public int sortOrder() {
return SORT_ORDER_BASE + 7;
}
@Override if(doesCentrifuge) {
public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) { for(ItemStack st : result) {
//a band-aid on a gaping wound if(st != null) {
if(block == Blocks.lit_redstone_ore) world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, st.copy()));
block = Blocks.redstone_ore; }
}
int mercury = 0; }
}
};
if(block == Blocks.redstone_ore) public static final IToolHarvestAbility CRYSTALLIZER = new IToolHarvestAbility() {
mercury = player.getRNG().nextInt(5) + 4; @Override
if(block == Blocks.redstone_block) public String getName() {
mercury = player.getRNG().nextInt(7) + 8; return "tool.ability.crystallizer";
}
boolean doesConvert = mercury > 0;
harvestBlock(doesConvert, world, x, y, z, player);
if(doesConvert) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.ingot_mercury, mercury)));
}
}
};
// endregion handlers
static final IToolHarvestAbility[] abilities = {NONE, SILK, LUCK, SMELTER, SHREDDER, CENTRIFUGE, CRYSTALLIZER, MERCURY}; @Override
public boolean isAllowed() {
return ToolConfig.abilityCrystallizer;
}
static IToolHarvestAbility getByName(String name) { @Override
for(IToolHarvestAbility ability : abilities) { public int sortOrder() {
if(ability.getName().equals(name)) return SORT_ORDER_BASE + 6;
return ability; }
}
@Override
return NONE; public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) {
} // a band-aid on a gaping wound
if(block == Blocks.lit_redstone_ore)
block = Blocks.redstone_ore;
ItemStack stack = new ItemStack(block, 1, meta);
CrystallizerRecipe result = CrystallizerRecipes.getOutput(stack, Fluids.PEROXIDE);
boolean doesCrystallize = result != null;
harvestBlock(doesCrystallize, world, x, y, z, player);
if(doesCrystallize) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, result.output.copy()));
}
}
};
public static final IToolHarvestAbility MERCURY = new IToolHarvestAbility() {
@Override
public String getName() {
return "tool.ability.mercury";
}
@Override
public boolean isAllowed() {
return ToolConfig.abilityMercury;
}
@Override
public int sortOrder() {
return SORT_ORDER_BASE + 7;
}
@Override
public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) {
// a band-aid on a gaping wound
if(block == Blocks.lit_redstone_ore)
block = Blocks.redstone_ore;
int mercury = 0;
if(block == Blocks.redstone_ore)
mercury = player.getRNG().nextInt(5) + 4;
if(block == Blocks.redstone_block)
mercury = player.getRNG().nextInt(7) + 8;
boolean doesConvert = mercury > 0;
harvestBlock(doesConvert, world, x, y, z, player);
if(doesConvert) {
world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, new ItemStack(ModItems.ingot_mercury, mercury)));
}
}
};
// endregion handlers
static final IToolHarvestAbility[] abilities = { NONE, SILK, LUCK, SMELTER, SHREDDER, CENTRIFUGE, CRYSTALLIZER, MERCURY };
static IToolHarvestAbility getByName(String name) {
for(IToolHarvestAbility ability : abilities) {
if(ability.getName().equals(name))
return ability;
}
return NONE;
}
} }

View File

@ -4,7 +4,6 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockBobble.BobbleType; import com.hbm.blocks.generic.BlockBobble.BobbleType;
import com.hbm.handler.threading.PacketThreading; import com.hbm.handler.threading.PacketThreading;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.lib.ModDamageSource;
import com.hbm.packet.toclient.AuxParticlePacketNT; import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.potion.HbmPotion; import com.hbm.potion.HbmPotion;
import com.hbm.util.ContaminationUtil; import com.hbm.util.ContaminationUtil;
@ -35,333 +34,337 @@ import net.minecraft.util.DamageSource;
import net.minecraft.world.World; import net.minecraft.world.World;
public interface IWeaponAbility extends IBaseAbility { public interface IWeaponAbility extends IBaseAbility {
// Note: tool is currently unused in weapon abilities // Note: tool is currently unused in weapon abilities
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool); public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool);
public final static int SORT_ORDER_BASE = 200;
// region handlers public final static int SORT_ORDER_BASE = 200;
public static final IWeaponAbility NONE = new IWeaponAbility() {
@Override
public String getName() {
return "";
}
@Override // region handlers
public int sortOrder() { public static final IWeaponAbility NONE = new IWeaponAbility() {
return SORT_ORDER_BASE + 0; @Override
} public String getName() {
return "";
}
@Override @Override
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {} public int sortOrder() {
}; return SORT_ORDER_BASE + 0;
}
public static final IWeaponAbility RADIATION = new IWeaponAbility() { @Override
@Override public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
public String getName() { }
return "weapon.ability.radiation"; };
}
public final float[] radAtLevel = {15F, 50F, 500F}; public static final IWeaponAbility RADIATION = new IWeaponAbility() {
@Override
public String getName() {
return "weapon.ability.radiation";
}
@Override public final float[] radAtLevel = { 15F, 50F, 500F };
public int levels() {
return radAtLevel.length;
}
@Override @Override
public String getExtension(int level) { public int levels() {
return " (" + radAtLevel[level] + ")"; return radAtLevel.length;
} }
@Override @Override
public int sortOrder() { public String getExtension(int level) {
return SORT_ORDER_BASE + 1; return " (" + radAtLevel[level] + ")";
} }
@Override @Override
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { public int sortOrder() {
if(victim instanceof EntityLivingBase) return SORT_ORDER_BASE + 1;
ContaminationUtil.contaminate((EntityLivingBase)victim, HazardType.RADIATION, ContaminationType.CREATIVE, radAtLevel[level]); }
}
};
public static final IWeaponAbility VAMPIRE = new IWeaponAbility() { @Override
@Override public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
public String getName() { if(victim instanceof EntityLivingBase)
return "weapon.ability.vampire"; ContaminationUtil.contaminate((EntityLivingBase) victim, HazardType.RADIATION, ContaminationType.CREATIVE, radAtLevel[level]);
} }
};
public final float[] amountAtLevel = {2F, 3F, 5F, 10F, 50F}; public static final IWeaponAbility VAMPIRE = new IWeaponAbility() {
@Override
public String getName() {
return "weapon.ability.vampire";
}
@Override public final float[] amountAtLevel = { 2F, 3F, 5F, 10F, 50F };
public int levels() {
return amountAtLevel.length;
}
@Override @Override
public String getExtension(int level) { public int levels() {
return " (" + amountAtLevel[level] + ")"; return amountAtLevel.length;
} }
@Override @Override
public int sortOrder() { public String getExtension(int level) {
return SORT_ORDER_BASE + 2; return " (" + amountAtLevel[level] + ")";
} }
@Override @Override
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { public int sortOrder() {
float amount = amountAtLevel[level]; return SORT_ORDER_BASE + 2;
}
if(victim instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) victim;
if(living.getHealth() <= 0) return;
living.setHealth(living.getHealth() - amount);
if(living.getHealth() <= 0) living.onDeath(DamageSource.magic);
player.heal(amount);
}
}
};
public static final IWeaponAbility STUN = new IWeaponAbility() { @Override
@Override public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
public String getName() { float amount = amountAtLevel[level];
return "weapon.ability.stun";
}
public final int[] durationAtLevel = {2, 3, 5, 10, 15}; if(victim instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) victim;
if(living.getHealth() <= 0)
return;
living.setHealth(living.getHealth() - amount);
if(living.getHealth() <= 0)
living.onDeath(DamageSource.magic);
player.heal(amount);
}
}
};
@Override public static final IWeaponAbility STUN = new IWeaponAbility() {
public int levels() { @Override
return durationAtLevel.length; public String getName() {
} return "weapon.ability.stun";
}
@Override public final int[] durationAtLevel = { 2, 3, 5, 10, 15 };
public String getExtension(int level) {
return " (" + durationAtLevel[level] + ")";
}
@Override @Override
public int sortOrder() { public int levels() {
return SORT_ORDER_BASE + 3; return durationAtLevel.length;
} }
@Override @Override
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { public String getExtension(int level) {
int duration = durationAtLevel[level]; return " (" + durationAtLevel[level] + ")";
}
if(victim instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) victim;
living.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, duration * 20, 4)); @Override
living.addPotionEffect(new PotionEffect(Potion.weakness.id, duration * 20, 4)); public int sortOrder() {
} return SORT_ORDER_BASE + 3;
} }
};
public static final IWeaponAbility PHOSPHORUS = new IWeaponAbility() { @Override
@Override public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
public String getName() { int duration = durationAtLevel[level];
return "weapon.ability.phosphorus";
}
public final int[] durationAtLevel = {60, 90}; if(victim instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) victim;
@Override living.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, duration * 20, 4));
public int levels() { living.addPotionEffect(new PotionEffect(Potion.weakness.id, duration * 20, 4));
return durationAtLevel.length; }
} }
};
@Override public static final IWeaponAbility PHOSPHORUS = new IWeaponAbility() {
public String getExtension(int level) { @Override
return " (" + durationAtLevel[level] + ")"; public String getName() {
} return "weapon.ability.phosphorus";
}
@Override public final int[] durationAtLevel = { 60, 90 };
public int sortOrder() {
return SORT_ORDER_BASE + 4;
}
@Override @Override
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { public int levels() {
int duration = durationAtLevel[level]; return durationAtLevel.length;
}
if(victim instanceof EntityLivingBase) {
EntityLivingBase living = (EntityLivingBase) victim;
living.addPotionEffect(new PotionEffect(HbmPotion.phosphorus.id, duration * 20, 4)); @Override
} public String getExtension(int level) {
} return " (" + durationAtLevel[level] + ")";
}; }
public static final IWeaponAbility FIRE = new IWeaponAbility() { @Override
@Override public int sortOrder() {
public String getName() { return SORT_ORDER_BASE + 4;
return "weapon.ability.fire"; }
}
public final int[] durationAtLevel = {5, 10}; @Override
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
int duration = durationAtLevel[level];
@Override if(victim instanceof EntityLivingBase) {
public int levels() { EntityLivingBase living = (EntityLivingBase) victim;
return durationAtLevel.length;
}
@Override living.addPotionEffect(new PotionEffect(HbmPotion.phosphorus.id, duration * 20, 4));
public String getExtension(int level) { }
return " (" + durationAtLevel[level] + ")"; }
} };
@Override public static final IWeaponAbility FIRE = new IWeaponAbility() {
public int sortOrder() { @Override
return SORT_ORDER_BASE + 6; public String getName() {
} return "weapon.ability.fire";
}
@Override public final int[] durationAtLevel = { 5, 10 };
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
if(victim instanceof EntityLivingBase) {
victim.setFire(durationAtLevel[level]);
}
}
};
public static final IWeaponAbility CHAINSAW = new IWeaponAbility() { @Override
@Override public int levels() {
public String getName() { return durationAtLevel.length;
return "weapon.ability.chainsaw"; }
}
public final int[] dividerAtLevel = {15, 10}; @Override
public String getExtension(int level) {
return " (" + durationAtLevel[level] + ")";
}
@Override @Override
public int levels() { public int sortOrder() {
return dividerAtLevel.length; return SORT_ORDER_BASE + 6;
} }
@Override @Override
public String getExtension(int level) { public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
return " (1:" + dividerAtLevel[level] + ")"; if(victim instanceof EntityLivingBase) {
} victim.setFire(durationAtLevel[level]);
}
}
};
@Override public static final IWeaponAbility CHAINSAW = new IWeaponAbility() {
public int sortOrder() { @Override
return SORT_ORDER_BASE + 7; public String getName() {
} return "weapon.ability.chainsaw";
}
@Override public final int[] dividerAtLevel = { 15, 10 };
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
int divider = dividerAtLevel[level];
if(victim instanceof EntityLivingBase) { @Override
EntityLivingBase living = (EntityLivingBase) victim; public int levels() {
return dividerAtLevel.length;
}
if(living.getHealth() <= 0.0F) { @Override
int count = Math.min((int)Math.ceil(living.getMaxHealth() / divider), 250); //safeguard to prevent funnies from bosses with obscene health public String getExtension(int level) {
return " (1:" + dividerAtLevel[level] + ")";
}
for(int i = 0; i < count; i++) { @Override
living.entityDropItem(new ItemStack(ModItems.nitra_small), 1); public int sortOrder() {
world.spawnEntityInWorld(new EntityXPOrb(world, living.posX, living.posY, living.posZ, 1)); return SORT_ORDER_BASE + 7;
} }
if(player instanceof EntityPlayerMP) { @Override
NBTTagCompound data = new NBTTagCompound(); public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
data.setString("type", "vanillaburst"); int divider = dividerAtLevel[level];
data.setInteger("count", count * 4);
data.setDouble("motion", 0.1D);
data.setString("mode", "blockdust");
data.setInteger("block", Block.getIdFromBlock(Blocks.redstone_block));
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, living.posX, living.posY + living.height * 0.5, living.posZ), new TargetPoint(living.dimension, living.posX, living.posY, living.posZ, 50));
}
world.playSoundEffect(living.posX, living.posY + living.height * 0.5, living.posZ, "hbm:weapon.chainsaw", 0.5F, 1.0F); if(victim instanceof EntityLivingBase) {
} EntityLivingBase living = (EntityLivingBase) victim;
}
}
};
public static final IWeaponAbility BEHEADER = new IWeaponAbility() { if(living.getHealth() <= 0.0F) {
@Override int count = Math.min((int) Math.ceil(living.getMaxHealth() / divider), 250); // safeguard to prevent funnies from bosses with obscene health
public String getName() {
return "weapon.ability.beheader";
}
@Override for(int i = 0; i < count; i++) {
public int sortOrder() { living.entityDropItem(new ItemStack(ModItems.nitra_small), 1);
return SORT_ORDER_BASE + 8; world.spawnEntityInWorld(new EntityXPOrb(world, living.posX, living.posY, living.posZ, 1));
} }
@Override if(player instanceof EntityPlayerMP) {
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { NBTTagCompound data = new NBTTagCompound();
if(victim instanceof EntityLivingBase && ((EntityLivingBase) victim).getHealth() <= 0.0F) { data.setString("type", "vanillaburst");
EntityLivingBase living = (EntityLivingBase) victim; data.setInteger("count", count * 4);
data.setDouble("motion", 0.1D);
data.setString("mode", "blockdust");
data.setInteger("block", Block.getIdFromBlock(Blocks.redstone_block));
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, living.posX, living.posY + living.height * 0.5, living.posZ),
new TargetPoint(living.dimension, living.posX, living.posY, living.posZ, 50));
}
if(living instanceof EntitySkeleton) { world.playSoundEffect(living.posX, living.posY + living.height * 0.5, living.posZ, "hbm:weapon.chainsaw", 0.5F, 1.0F);
if(((EntitySkeleton)living).getSkeletonType() == 0) { }
living.entityDropItem(new ItemStack(Items.skull, 1, 0), 0.0F); }
} else { }
if(world.rand.nextInt(20) == 0) };
living.entityDropItem(new ItemStack(Items.skull, 1, 1), 0.0F);
else
living.entityDropItem(new ItemStack(Items.coal, 3), 0.0F);
}
} else if(living instanceof EntityZombie) {
living.entityDropItem(new ItemStack(Items.skull, 1, 2), 0.0F);
} else if(living instanceof EntityCreeper) {
living.entityDropItem(new ItemStack(Items.skull, 1, 4), 0.0F);
} else if(living instanceof EntityMagmaCube) {
living.entityDropItem(new ItemStack(Items.magma_cream, 3), 0.0F);
} else if(living instanceof EntitySlime) {
living.entityDropItem(new ItemStack(Items.slime_ball, 3), 0.0F);
} else if(living instanceof EntityPlayer) {
ItemStack head = new ItemStack(Items.skull, 1, 3);
head.stackTagCompound = new NBTTagCompound();
head.stackTagCompound.setString("SkullOwner", ((EntityPlayer) living).getDisplayName());
living.entityDropItem(head, 0.0F);
} else {
living.entityDropItem(new ItemStack(Items.rotten_flesh, 3, 0), 0.0F);
living.entityDropItem(new ItemStack(Items.bone, 2, 0), 0.0F);
}
}
}
};
public static final IWeaponAbility BOBBLE = new IWeaponAbility() { public static final IWeaponAbility BEHEADER = new IWeaponAbility() {
@Override @Override
public String getName() { public String getName() {
return "weapon.ability.bobble"; return "weapon.ability.beheader";
} }
@Override @Override
public int sortOrder() { public int sortOrder() {
return SORT_ORDER_BASE + 9; return SORT_ORDER_BASE + 8;
} }
@Override @Override
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
if(victim instanceof EntityMob && ((EntityMob) victim).getHealth() <= 0.0F) { if(victim instanceof EntityLivingBase && ((EntityLivingBase) victim).getHealth() <= 0.0F) {
EntityMob mob = (EntityMob) victim; EntityLivingBase living = (EntityLivingBase) victim;
int chance = 1000; if(living instanceof EntitySkeleton) {
if(((EntitySkeleton) living).getSkeletonType() == 0) {
living.entityDropItem(new ItemStack(Items.skull, 1, 0), 0.0F);
} else {
if(world.rand.nextInt(20) == 0)
living.entityDropItem(new ItemStack(Items.skull, 1, 1), 0.0F);
else
living.entityDropItem(new ItemStack(Items.coal, 3), 0.0F);
}
} else if(living instanceof EntityZombie) {
living.entityDropItem(new ItemStack(Items.skull, 1, 2), 0.0F);
} else if(living instanceof EntityCreeper) {
living.entityDropItem(new ItemStack(Items.skull, 1, 4), 0.0F);
} else if(living instanceof EntityMagmaCube) {
living.entityDropItem(new ItemStack(Items.magma_cream, 3), 0.0F);
} else if(living instanceof EntitySlime) {
living.entityDropItem(new ItemStack(Items.slime_ball, 3), 0.0F);
} else if(living instanceof EntityPlayer) {
ItemStack head = new ItemStack(Items.skull, 1, 3);
head.stackTagCompound = new NBTTagCompound();
head.stackTagCompound.setString("SkullOwner", ((EntityPlayer) living).getDisplayName());
living.entityDropItem(head, 0.0F);
} else {
living.entityDropItem(new ItemStack(Items.rotten_flesh, 3, 0), 0.0F);
living.entityDropItem(new ItemStack(Items.bone, 2, 0), 0.0F);
}
}
}
};
if(mob.getMaxHealth() > 20) { public static final IWeaponAbility BOBBLE = new IWeaponAbility() {
chance = 750; @Override
} public String getName() {
return "weapon.ability.bobble";
}
if(world.rand.nextInt(chance) == 0) @Override
mob.entityDropItem(new ItemStack(ModBlocks.bobblehead, 1, world.rand.nextInt(BobbleType.values().length - 1) + 1), 0.0F); public int sortOrder() {
} return SORT_ORDER_BASE + 9;
} }
};
// endregion handlers
static final IWeaponAbility[] abilities = {NONE, RADIATION, VAMPIRE, STUN, PHOSPHORUS, FIRE, CHAINSAW, BEHEADER, BOBBLE}; @Override
public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {
if(victim instanceof EntityMob && ((EntityMob) victim).getHealth() <= 0.0F) {
EntityMob mob = (EntityMob) victim;
static IWeaponAbility getByName(String name) { int chance = 1000;
for(IWeaponAbility ability : abilities) {
if(ability.getName().equals(name)) if(mob.getMaxHealth() > 20) {
return ability; chance = 750;
} }
return NONE; if(world.rand.nextInt(chance) == 0)
} mob.entityDropItem(new ItemStack(ModBlocks.bobblehead, 1, world.rand.nextInt(BobbleType.values().length - 1) + 1), 0.0F);
}
}
};
// endregion handlers
static final IWeaponAbility[] abilities = { NONE, RADIATION, VAMPIRE, STUN, PHOSPHORUS, FIRE, CHAINSAW, BEHEADER, BOBBLE };
static IWeaponAbility getByName(String name) {
for(IWeaponAbility ability : abilities) {
if(ability.getName().equals(name))
return ability;
}
return NONE;
}
} }

View File

@ -7,93 +7,94 @@ import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
public class ToolPreset { public class ToolPreset {
public IToolAreaAbility areaAbility = IToolAreaAbility.NONE; public IToolAreaAbility areaAbility = IToolAreaAbility.NONE;
public int areaAbilityLevel = 0; public int areaAbilityLevel = 0;
public IToolHarvestAbility harvestAbility = IToolHarvestAbility.NONE; public IToolHarvestAbility harvestAbility = IToolHarvestAbility.NONE;
public int harvestAbilityLevel = 0; public int harvestAbilityLevel = 0;
public ToolPreset() {} public ToolPreset() {
}
public ToolPreset(IToolAreaAbility areaAbility, IToolHarvestAbility harvestAbility) { public ToolPreset(IToolAreaAbility areaAbility, IToolHarvestAbility harvestAbility) {
this.areaAbility = areaAbility; this.areaAbility = areaAbility;
this.harvestAbility = harvestAbility; this.harvestAbility = harvestAbility;
} }
public ToolPreset(IToolAreaAbility areaAbility, int areaAbilityLevel, IToolHarvestAbility harvestAbility, int harvestAbilityLevel) { public ToolPreset(IToolAreaAbility areaAbility, int areaAbilityLevel, IToolHarvestAbility harvestAbility, int harvestAbilityLevel) {
this.areaAbility = areaAbility; this.areaAbility = areaAbility;
this.areaAbilityLevel = areaAbilityLevel; this.areaAbilityLevel = areaAbilityLevel;
this.harvestAbility = harvestAbility; this.harvestAbility = harvestAbility;
this.harvestAbilityLevel = harvestAbilityLevel; this.harvestAbilityLevel = harvestAbilityLevel;
} }
public ChatComponentText getMessage() { public ChatComponentText getMessage() {
if (isNone()) if(isNone())
return ChatBuilder.start("[Tool ability deactivated]").color(EnumChatFormatting.GOLD).flush(); return ChatBuilder.start("[Tool ability deactivated]").color(EnumChatFormatting.GOLD).flush();
String areaPart = areaAbility.getFullName(areaAbilityLevel);
String harvestPart = harvestAbility.getFullName(harvestAbilityLevel);
ChatBuilder builder = ChatBuilder.start("[Enabled ");
if (!areaPart.isEmpty()) String areaPart = areaAbility.getFullName(areaAbilityLevel);
builder.next(areaPart); String harvestPart = harvestAbility.getFullName(harvestAbilityLevel);
if (!areaPart.isEmpty() && !harvestPart.isEmpty()) ChatBuilder builder = ChatBuilder.start("[Enabled ");
builder.next(" + ");
if (!harvestPart.isEmpty()) if(!areaPart.isEmpty())
builder.next(harvestPart); builder.next(areaPart);
return builder.colorAll(EnumChatFormatting.YELLOW).flush();
}
public boolean isNone() { if(!areaPart.isEmpty() && !harvestPart.isEmpty())
return areaAbility == IToolAreaAbility.NONE && harvestAbility == IToolHarvestAbility.NONE; builder.next(" + ");
}
public void writeToNBT(NBTTagCompound nbt) { if(!harvestPart.isEmpty())
nbt.setString("area", areaAbility.getName()); builder.next(harvestPart);
nbt.setInteger("areaLevel", areaAbilityLevel);
nbt.setString("harvest", harvestAbility.getName());
nbt.setInteger("harvestLevel", harvestAbilityLevel);
}
public void readFromNBT(NBTTagCompound nbt) { return builder.colorAll(EnumChatFormatting.YELLOW).flush();
areaAbility = IToolAreaAbility.getByName(nbt.getString("area")); }
areaAbilityLevel = nbt.getInteger("areaLevel");
harvestAbility = IToolHarvestAbility.getByName(nbt.getString("harvest"));
harvestAbilityLevel = nbt.getInteger("harvestLevel");
areaAbilityLevel = Math.min(areaAbilityLevel, areaAbility.levels() - 1); public boolean isNone() {
harvestAbilityLevel = Math.min(harvestAbilityLevel, harvestAbility.levels() - 1); return areaAbility == IToolAreaAbility.NONE && harvestAbility == IToolHarvestAbility.NONE;
} }
public void restrictTo(AvailableAbilities availableAbilities) { public void writeToNBT(NBTTagCompound nbt) {
int maxAreaLevel = availableAbilities.maxLevel(areaAbility); nbt.setString("area", areaAbility.getName());
nbt.setInteger("areaLevel", areaAbilityLevel);
nbt.setString("harvest", harvestAbility.getName());
nbt.setInteger("harvestLevel", harvestAbilityLevel);
}
if (maxAreaLevel == -1) { public void readFromNBT(NBTTagCompound nbt) {
areaAbility = IToolAreaAbility.NONE; areaAbility = IToolAreaAbility.getByName(nbt.getString("area"));
areaAbilityLevel = 0; areaAbilityLevel = nbt.getInteger("areaLevel");
} else if (areaAbilityLevel > maxAreaLevel) { harvestAbility = IToolHarvestAbility.getByName(nbt.getString("harvest"));
areaAbilityLevel = maxAreaLevel; harvestAbilityLevel = nbt.getInteger("harvestLevel");
} else if (areaAbilityLevel < 0) {
areaAbilityLevel = 0;
}
if (!areaAbility.allowsHarvest(areaAbilityLevel)) { areaAbilityLevel = Math.min(areaAbilityLevel, areaAbility.levels() - 1);
harvestAbility = IToolHarvestAbility.NONE; harvestAbilityLevel = Math.min(harvestAbilityLevel, harvestAbility.levels() - 1);
harvestAbilityLevel = 0; }
}
int maxHarvestLevel = availableAbilities.maxLevel(harvestAbility); public void restrictTo(AvailableAbilities availableAbilities) {
int maxAreaLevel = availableAbilities.maxLevel(areaAbility);
if (maxHarvestLevel == -1) { if(maxAreaLevel == -1) {
harvestAbility = IToolHarvestAbility.NONE; areaAbility = IToolAreaAbility.NONE;
harvestAbilityLevel = 0; areaAbilityLevel = 0;
} else if (harvestAbilityLevel > maxHarvestLevel) { } else if(areaAbilityLevel > maxAreaLevel) {
harvestAbilityLevel = maxHarvestLevel; areaAbilityLevel = maxAreaLevel;
} else if (harvestAbilityLevel < 0) { } else if(areaAbilityLevel < 0) {
harvestAbilityLevel = 0; areaAbilityLevel = 0;
} }
}
if(!areaAbility.allowsHarvest(areaAbilityLevel)) {
harvestAbility = IToolHarvestAbility.NONE;
harvestAbilityLevel = 0;
}
int maxHarvestLevel = availableAbilities.maxLevel(harvestAbility);
if(maxHarvestLevel == -1) {
harvestAbility = IToolHarvestAbility.NONE;
harvestAbilityLevel = 0;
} else if(harvestAbilityLevel > maxHarvestLevel) {
harvestAbilityLevel = maxHarvestLevel;
} else if(harvestAbilityLevel < 0) {
harvestAbilityLevel = 0;
}
}
} }

View File

@ -4,26 +4,11 @@ import java.util.List;
import com.hbm.entity.projectile.EntityBulletBaseNT; import com.hbm.entity.projectile.EntityBulletBaseNT;
import com.hbm.entity.projectile.EntityBulletBaseNT.*; import com.hbm.entity.projectile.EntityBulletBaseNT.*;
import com.hbm.explosion.ExplosionNukeSmall;
import com.hbm.explosion.ExplosionNukeSmall.MukeParams;
import com.hbm.handler.BulletConfiguration; import com.hbm.handler.BulletConfiguration;
import com.hbm.handler.threading.PacketThreading;
import com.hbm.lib.Library;
import com.hbm.packet.toclient.AuxParticlePacketNT;
import com.hbm.potion.HbmPotion;
import com.hbm.util.ArmorRegistry;
import com.hbm.util.ArmorRegistry.HazardClass;
import com.hbm.util.BobMathUtil; import com.hbm.util.BobMathUtil;
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
public class BulletConfigFactory { public class BulletConfigFactory {
@ -57,37 +42,6 @@ public class BulletConfigFactory {
return bullet; return bullet;
} }
public static BulletConfiguration standardPistolConfig() {
BulletConfiguration bullet = standardBulletConfig();
bullet.style = BulletConfiguration.STYLE_PISTOL;
bullet.plink = BulletConfiguration.PLINK_BULLET;
return bullet;
}
public static BulletConfiguration standardBuckshotConfig() {
BulletConfiguration bullet = new BulletConfiguration();
bullet.velocity = 5.0F;
bullet.spread = defaultSpread * 10F;
bullet.wear = 10;
bullet.bulletsMin = 6;
bullet.bulletsMax = 8;
bullet.gravity = 0D;
bullet.maxAge = 100;
bullet.doesRicochet = true;
bullet.ricochetAngle = 5;
bullet.HBRC = 10;
bullet.LBRC = 95;
bullet.bounceMod = 0.8;
bullet.doesPenetrate = false;
bullet.doesBreakGlass = true;
bullet.style = BulletConfiguration.STYLE_PELLET;
bullet.plink = BulletConfiguration.PLINK_BULLET;
bullet.leadChance = 10;
return bullet;
}
public static BulletConfiguration standardRocketConfig() { public static BulletConfiguration standardRocketConfig() {
@ -141,218 +95,6 @@ public class BulletConfigFactory {
return bullet; return bullet;
} }
public static BulletConfiguration standardShellConfig() {
BulletConfiguration bullet = new BulletConfiguration();
bullet.velocity = 3.0F;
bullet.spread = defaultSpread;
bullet.wear = 10;
bullet.bulletsMin = 1;
bullet.bulletsMax = 1;
bullet.gravity = 0.005D;
bullet.maxAge = 300;
bullet.doesRicochet = true;
bullet.ricochetAngle = 10;
bullet.HBRC = 2;
bullet.LBRC = 100;
bullet.bounceMod = 0.8;
bullet.doesPenetrate = false;
bullet.doesBreakGlass = false;
bullet.style = BulletConfiguration.STYLE_GRENADE;
bullet.plink = BulletConfiguration.PLINK_GRENADE;
bullet.vPFX = "smoke";
return bullet;
}
public static BulletConfiguration standardNukeConfig() {
BulletConfiguration bullet = new BulletConfiguration();
bullet.velocity = 3.0F;
bullet.spread = defaultSpread;
bullet.wear = 10;
bullet.bulletsMin = 1;
bullet.bulletsMax = 1;
bullet.dmgMin = 1000;
bullet.dmgMax = 1000;
bullet.gravity = 0.025D;
bullet.maxAge = 300;
bullet.doesRicochet = false;
bullet.ricochetAngle = 0;
bullet.HBRC = 0;
bullet.LBRC = 0;
bullet.bounceMod = 1.0;
bullet.doesPenetrate = true;
bullet.doesBreakGlass = false;
bullet.style = BulletConfiguration.STYLE_NUKE;
bullet.plink = BulletConfiguration.PLINK_GRENADE;
return bullet;
}
/*
* Sizes:
* 0 - safe
* 1 - tot
* 2 - small
* 3 - medium
* 4 - big
*/
public static void nuclearExplosion(Entity entity, int x, int y, int z, MukeParams params) {
if(!entity.worldObj.isRemote) {
double posX = entity.posX;
double posY = entity.posY + 0.5;
double posZ = entity.posZ;
if(y >= 0) {
posX = x + 0.5;
posY = y + 1.5;
posZ = z + 0.5;
}
ExplosionNukeSmall.explode(entity.worldObj, posX, posY, posZ, params);
}
}
public static void makeFlechette(BulletConfiguration bullet) {
bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> {
bulletnt.getStuck(x, y, z, sideHit);
};
}
public static IBulletImpactBehaviorNT getPhosphorousEffect(final int radius, final int duration, final int count, final double motion, float hazeChance) {
IBulletImpactBehaviorNT impact = new IBulletImpactBehaviorNT() {
@Override
public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) {
List<Entity> hit = bullet.worldObj.getEntitiesWithinAABBExcludingEntity(bullet, AxisAlignedBB.getBoundingBox(bullet.posX - radius, bullet.posY - radius, bullet.posZ - radius, bullet.posX + radius, bullet.posY + radius, bullet.posZ + radius));
for(Entity e : hit) {
if(!Library.isObstructed(bullet.worldObj, bullet.posX, bullet.posY, bullet.posZ, e.posX, e.posY + e.getEyeHeight(), e.posZ)) {
e.setFire(5);
if(e instanceof EntityLivingBase) {
PotionEffect eff = new PotionEffect(HbmPotion.phosphorus.id, duration, 0, true);
eff.getCurativeItems().clear();
((EntityLivingBase)e).addPotionEffect(eff);
}
}
}
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaburst");
data.setString("mode", "flame");
data.setInteger("count", count);
data.setDouble("motion", motion);
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, bullet.posX, bullet.posY, bullet.posZ), new TargetPoint(bullet.dimension, bullet.posX, bullet.posY, bullet.posZ, 50));
if(bullet.worldObj.rand.nextFloat() < hazeChance) {
NBTTagCompound haze = new NBTTagCompound();
haze.setString("type", "haze");
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(haze, bullet.posX, bullet.posY, bullet.posZ), new TargetPoint(bullet.dimension, bullet.posX, bullet.posY, bullet.posZ, 150));
}
}
};
return impact;
}
public static IBulletImpactBehaviorNT getGasEffect(final int radius, final int duration) {
IBulletImpactBehaviorNT impact = new IBulletImpactBehaviorNT() {
@Override
public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) {
List<Entity> hit = bullet.worldObj.getEntitiesWithinAABBExcludingEntity(bullet, AxisAlignedBB.getBoundingBox(bullet.posX - radius, bullet.posY - radius, bullet.posZ - radius, bullet.posX + radius, bullet.posY + radius, bullet.posZ + radius));
for(Entity e : hit) {
if(!Library.isObstructed(bullet.worldObj, bullet.posX, bullet.posY, bullet.posZ, e.posX, e.posY + e.getEyeHeight(), e.posZ)) {
if(e instanceof EntityLivingBase) {
EntityLivingBase entity = (EntityLivingBase) e;
if(ArmorRegistry.hasAllProtection(entity, 3, HazardClass.GAS_LUNG))
continue;
PotionEffect eff0 = new PotionEffect(Potion.poison.id, duration, 2, true);
PotionEffect eff1 = new PotionEffect(Potion.digSlowdown.id, duration, 2, true);
PotionEffect eff2 = new PotionEffect(Potion.weakness.id, duration, 4, true);
PotionEffect eff3 = new PotionEffect(Potion.wither.id, (int)Math.ceil(duration * 0.1), 0, true);
eff0.getCurativeItems().clear();
eff1.getCurativeItems().clear();
eff2.getCurativeItems().clear();
eff3.getCurativeItems().clear();
entity.addPotionEffect(eff0);
entity.addPotionEffect(eff1);
entity.addPotionEffect(eff2);
entity.addPotionEffect(eff3);
}
}
}
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaburst");
data.setString("mode", "cloud");
data.setInteger("count", 15);
data.setDouble("motion", 0.1D);
PacketThreading.createAllAroundThreadedPacket(new AuxParticlePacketNT(data, bullet.posX, bullet.posY, bullet.posZ), new TargetPoint(bullet.dimension, bullet.posX, bullet.posY, bullet.posZ, 50));
}
};
return impact;
}
public static IBulletUpdateBehaviorNT getLaserSteering() {
IBulletUpdateBehaviorNT onUpdate = new IBulletUpdateBehaviorNT() {
@Override
public void behaveUpdate(EntityBulletBaseNT bullet) {
if(bullet.getThrower() == null || !(bullet.getThrower() instanceof EntityPlayer))
return;
if(Vec3.createVectorHelper(bullet.posX - bullet.getThrower().posX, bullet.posY - bullet.getThrower().posY, bullet.posZ - bullet.getThrower().posZ).lengthVector() > 100)
return;
MovingObjectPosition mop = Library.rayTrace((EntityPlayer)bullet.getThrower(), 200, 1);
if(mop == null || mop.hitVec == null)
return;
Vec3 vec = Vec3.createVectorHelper(mop.hitVec.xCoord - bullet.posX, mop.hitVec.yCoord - bullet.posY, mop.hitVec.zCoord - bullet.posZ);
if(vec.lengthVector() < 3)
return;
vec = vec.normalize();
double speed = Vec3.createVectorHelper(bullet.motionX, bullet.motionY, bullet.motionZ).lengthVector();
bullet.motionX = vec.xCoord * speed;
bullet.motionY = vec.yCoord * speed;
bullet.motionZ = vec.zCoord * speed;
}
};
return onUpdate;
}
public static IBulletUpdateBehaviorNT getHomingBehavior(final double range, final double angle) { public static IBulletUpdateBehaviorNT getHomingBehavior(final double range, final double angle) {
IBulletUpdateBehaviorNT onUpdate = new IBulletUpdateBehaviorNT() { IBulletUpdateBehaviorNT onUpdate = new IBulletUpdateBehaviorNT() {

View File

@ -1,96 +0,0 @@
package com.hbm.handler.guncfg;
import com.hbm.explosion.ExplosionNukeSmall;
import com.hbm.handler.BulletConfiguration;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.items.ItemAmmoEnums.Ammo240Shell;
import com.hbm.items.ModItems;
import com.hbm.particle.SpentCasing;
import com.hbm.particle.SpentCasing.CasingType;
public class GunCannonFactory {
protected static SpentCasing CASINNG240MM;
static {
CASINNG240MM = new SpentCasing(CasingType.BOTTLENECK).setScale(7.5F).setBounceMotion(0.5F, 0.5F).setColor(SpentCasing.COLOR_CASE_BRASS).setupSmoke(1F, 0.5D, 60, 20);
}
public static BulletConfiguration getShellConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardShellConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_shell.stackFromEnum(Ammo240Shell.STOCK));
bullet.dmgMin = 25;
bullet.dmgMax = 35;
bullet.explosive = 4F;
bullet.blockDamage = false;
bullet.spentCasing = CASINNG240MM.register("240MM"); //same instance everywhere, only register once
return bullet;
}
public static BulletConfiguration getShellExplosiveConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardShellConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_shell.stackFromEnum(Ammo240Shell.EXPLOSIVE));
bullet.dmgMin = 35;
bullet.dmgMax = 45;
bullet.explosive = 4F;
bullet.blockDamage = true;
bullet.spentCasing = CASINNG240MM;
return bullet;
}
public static BulletConfiguration getShellAPConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardShellConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_shell.stackFromEnum(Ammo240Shell.APFSDS_T));
bullet.dmgMin = 50;
bullet.dmgMax = 55;
bullet.doesPenetrate = true;
bullet.style = BulletConfiguration.STYLE_APDS;
bullet.spentCasing = CASINNG240MM;
return bullet;
}
public static BulletConfiguration getShellDUConfig() {
BulletConfiguration bullet = BulletConfigFactory.standardShellConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_shell.stackFromEnum(Ammo240Shell.APFSDS_DU));
bullet.dmgMin = 70;
bullet.dmgMax = 80;
bullet.doesPenetrate = true;
bullet.style = BulletConfiguration.STYLE_APDS;
bullet.spentCasing = CASINNG240MM;
return bullet;
}
public static BulletConfiguration getShellW9Config() {
BulletConfiguration bullet = BulletConfigFactory.standardShellConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_shell.stackFromEnum(Ammo240Shell.W9));
bullet.dmgMin = 100;
bullet.dmgMax = 150;
bullet.bntImpact = (bulletnt, x, y, z, sideHit) -> {
BulletConfigFactory.nuclearExplosion(bulletnt, x, y, z, ExplosionNukeSmall.PARAMS_TOTS);
};
bullet.spentCasing = CASINNG240MM;
return bullet;
}
}

View File

@ -1,317 +1,11 @@
package com.hbm.handler.guncfg; package com.hbm.handler.guncfg;
import java.util.ArrayList;
import com.hbm.blocks.ModBlocks;
import com.hbm.entity.projectile.EntityBulletBaseNT;
import com.hbm.entity.projectile.EntityBulletBaseNT.IBulletImpactBehaviorNT;
import com.hbm.entity.projectile.EntityBulletBaseNT.IBulletUpdateBehaviorNT;
import com.hbm.handler.BulletConfigSyncingUtil;
import com.hbm.handler.BulletConfiguration; import com.hbm.handler.BulletConfiguration;
import com.hbm.handler.GunConfiguration;
import com.hbm.inventory.RecipesCommon.ComparableStack; import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.items.ItemAmmoEnums.AmmoFireExt;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.weapon.sedna.Crosshair;
import com.hbm.lib.HbmCollection.EnumGunManufacturer;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IRepairable;
import com.hbm.tileentity.IRepairable.EnumExtinguishType;
import com.hbm.util.CompatExternal;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
public class GunEnergyFactory { public class GunEnergyFactory {
public static GunConfiguration getExtConfig() {
GunConfiguration config = new GunConfiguration();
config.rateOfFire = 1;
config.roundsPerCycle = 1;
config.gunMode = GunConfiguration.MODE_NORMAL;
config.firingMode = GunConfiguration.FIRE_AUTO;
config.reloadDuration = 20;
config.reloadSoundEnd = false;
config.firingDuration = 0;
config.ammoCap = 300; //good for 15 seconds of continued spray
config.durability = 10000;
config.reloadType = GunConfiguration.RELOAD_FULL;
config.allowsInfinity = true;
config.crosshair = Crosshair.L_CIRCLE;
config.firingSound = "hbm:weapon.extinguisher";
config.reloadSound = "hbm:weapon.flamerReload";
config.name = "PROTEX Fire Exinguisher 6kg";
config.manufacturer = EnumGunManufacturer.GLORIA;
config.config = new ArrayList<Integer>();
config.config.add(BulletConfigSyncingUtil.FEXT_NORMAL);
config.config.add(BulletConfigSyncingUtil.FEXT_FOAM);
config.config.add(BulletConfigSyncingUtil.FEXT_SAND);
return config;
}
public static BulletConfiguration getFextConfig() {
BulletConfiguration bullet = new BulletConfiguration();
bullet.ammo = new ComparableStack(ModItems.ammo_fireext.stackFromEnum(AmmoFireExt.WATER));
bullet.ammoCount = 300;
bullet.velocity = 0.75F;
bullet.spread = 0.025F;
bullet.wear = 1;
bullet.bulletsMin = 2;
bullet.bulletsMax = 3;
bullet.dmgMin = 0;
bullet.dmgMax = 0;
bullet.gravity = 0.04D;
bullet.maxAge = 100;
bullet.doesRicochet = false;
bullet.doesPenetrate = true;
bullet.doesBreakGlass = false;
bullet.style = BulletConfiguration.STYLE_NONE;
bullet.plink = BulletConfiguration.PLINK_NONE;
bullet.bntHurt = (bulletEntity, target) -> { target.extinguish(); };
bullet.bntImpact = new IBulletImpactBehaviorNT() {
@Override
public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) {
if(!bullet.worldObj.isRemote) {
int ix = (int)Math.floor(bullet.posX);
int iy = (int)Math.floor(bullet.posY);
int iz = (int)Math.floor(bullet.posZ);
boolean fizz = false;
for(int i = -1; i <= 1; i++) {
for(int j = -1; j <= 1; j++) {
for(int k = -1; k <= 1; k++) {
if(bullet.worldObj.getBlock(ix + i, iy + j, iz + k) == Blocks.fire) {
bullet.worldObj.setBlock(ix + i, iy + j, iz + k, Blocks.air);
fizz = true;
}
}
}
}
TileEntity core = CompatExternal.getCoreFromPos(bullet.worldObj, ix, iy, iz);
if(core instanceof IRepairable) {
((IRepairable) core).tryExtinguish(bullet.worldObj, ix, iy, iz, EnumExtinguishType.WATER);
}
if(fizz)
bullet.worldObj.playSoundEffect(bullet.posX, bullet.posY, bullet.posZ, "random.fizz", 1.0F, 1.5F + bullet.worldObj.rand.nextFloat() * 0.5F);
}
}
};
bullet.bntUpdate = new IBulletUpdateBehaviorNT() {
@Override
public void behaveUpdate(EntityBulletBaseNT bullet) {
if(bullet.worldObj.isRemote) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaExt");
data.setString("mode", "blockdust");
data.setInteger("block", Block.getIdFromBlock(Blocks.water));
data.setDouble("posX", bullet.posX);
data.setDouble("posY", bullet.posY);
data.setDouble("posZ", bullet.posZ);
data.setDouble("mX", bullet.motionX + bullet.worldObj.rand.nextGaussian() * 0.05);
data.setDouble("mY", bullet.motionY - 0.2 + bullet.worldObj.rand.nextGaussian() * 0.05);
data.setDouble("mZ", bullet.motionZ + bullet.worldObj.rand.nextGaussian() * 0.05);
MainRegistry.proxy.effectNT(data);
} else {
int x = (int)Math.floor(bullet.posX);
int y = (int)Math.floor(bullet.posY);
int z = (int)Math.floor(bullet.posZ);
if(bullet.worldObj.getBlock(x, y, z) == ModBlocks.volcanic_lava_block && bullet.worldObj.getBlockMetadata(x, y, z) == 0) {
bullet.worldObj.setBlock(x, y, z, Blocks.obsidian);
bullet.setDead();
}
}
}
};
return bullet;
}
public static BulletConfiguration getFextFoamConfig() {
BulletConfiguration bullet = getFextConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_fireext.stackFromEnum(AmmoFireExt.FOAM));
bullet.spread = 0.05F;
bullet.bntImpact = new IBulletImpactBehaviorNT() {
@Override
public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) {
if(!bullet.worldObj.isRemote) {
int ix = (int)Math.floor(bullet.posX);
int iy = (int)Math.floor(bullet.posY);
int iz = (int)Math.floor(bullet.posZ);
boolean fizz = false;
for(int i = -1; i <= 1; i++) {
for(int j = -1; j <= 1; j++) {
for(int k = -1; k <= 1; k++) {
Block b = bullet.worldObj.getBlock(ix + i, iy + j, iz + k);
if(b.getMaterial() == Material.fire) {
bullet.worldObj.setBlock(ix + i, iy + j, iz + k, Blocks.air);
fizz = true;
}
}
}
}
Block b = bullet.worldObj.getBlock(ix, iy, iz);
TileEntity core = CompatExternal.getCoreFromPos(bullet.worldObj, ix, iy, iz);
if(core instanceof IRepairable) {
((IRepairable) core).tryExtinguish(bullet.worldObj, ix, iy, iz, EnumExtinguishType.FOAM);
return;
}
if(b.isReplaceable(bullet.worldObj, ix, iy, iz) && ModBlocks.foam_layer.canPlaceBlockAt(bullet.worldObj, ix, iy, iz)) {
if(b != ModBlocks.foam_layer) {
bullet.worldObj.setBlock(ix, iy, iz, ModBlocks.foam_layer);
} else {
int meta = bullet.worldObj.getBlockMetadata(ix, iy, iz);
if(meta < 6)
bullet.worldObj.setBlockMetadataWithNotify(ix, iy, iz, meta + 1, 3);
else
bullet.worldObj.setBlock(ix, iy, iz, ModBlocks.block_foam);
}
}
if(fizz)
bullet.worldObj.playSoundEffect(bullet.posX, bullet.posY, bullet.posZ, "random.fizz", 1.0F, 1.5F + bullet.worldObj.rand.nextFloat() * 0.5F);
}
}
};
bullet.bntUpdate = new IBulletUpdateBehaviorNT() {
@Override
public void behaveUpdate(EntityBulletBaseNT bullet) {
if(bullet.worldObj.isRemote) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaExt");
data.setString("mode", "blockdust");
data.setInteger("block", Block.getIdFromBlock(ModBlocks.block_foam));
data.setDouble("posX", bullet.posX);
data.setDouble("posY", bullet.posY);
data.setDouble("posZ", bullet.posZ);
data.setDouble("mX", bullet.motionX + bullet.worldObj.rand.nextGaussian() * 0.05);
data.setDouble("mY", bullet.motionY - 0.2 + bullet.worldObj.rand.nextGaussian() * 0.05);
data.setDouble("mZ", bullet.motionZ + bullet.worldObj.rand.nextGaussian() * 0.05);
MainRegistry.proxy.effectNT(data);
}
}
};
return bullet;
}
public static BulletConfiguration getFextSandConfig() {
BulletConfiguration bullet = getFextConfig();
bullet.ammo = new ComparableStack(ModItems.ammo_fireext.stackFromEnum(AmmoFireExt.SAND));
bullet.spread = 0.1F;
bullet.bntHurt = null; // does not extinguish entities
bullet.bntImpact = new IBulletImpactBehaviorNT() {
@Override
public void behaveBlockHit(EntityBulletBaseNT bullet, int x, int y, int z, int sideHit) {
if(!bullet.worldObj.isRemote) {
int ix = (int)Math.floor(bullet.posX);
int iy = (int)Math.floor(bullet.posY);
int iz = (int)Math.floor(bullet.posZ);
Block b = bullet.worldObj.getBlock(ix, iy, iz);
TileEntity core = CompatExternal.getCoreFromPos(bullet.worldObj, ix, iy, iz);
if(core instanceof IRepairable) {
((IRepairable) core).tryExtinguish(bullet.worldObj, ix, iy, iz, EnumExtinguishType.SAND);
return;
}
if((b.isReplaceable(bullet.worldObj, ix, iy, iz) || b == ModBlocks.sand_boron_layer) && ModBlocks.sand_boron_layer.canPlaceBlockAt(bullet.worldObj, ix, iy, iz)) {
if(b != ModBlocks.sand_boron_layer) {
bullet.worldObj.setBlock(ix, iy, iz, ModBlocks.sand_boron_layer);
} else {
int meta = bullet.worldObj.getBlockMetadata(ix, iy, iz);
if(meta < 6)
bullet.worldObj.setBlockMetadataWithNotify(ix, iy, iz, meta + 1, 3);
else
bullet.worldObj.setBlock(ix, iy, iz, ModBlocks.sand_boron);
}
if(b.getMaterial() == Material.fire)
bullet.worldObj.playSoundEffect(bullet.posX, bullet.posY, bullet.posZ, "random.fizz", 1.0F, 1.5F + bullet.worldObj.rand.nextFloat() * 0.5F);
}
}
}
};
bullet.bntUpdate = new IBulletUpdateBehaviorNT() {
@Override
public void behaveUpdate(EntityBulletBaseNT bullet) {
if(bullet.worldObj.isRemote) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaExt");
data.setString("mode", "blockdust");
data.setInteger("block", Block.getIdFromBlock(ModBlocks.sand_boron));
data.setDouble("posX", bullet.posX);
data.setDouble("posY", bullet.posY);
data.setDouble("posZ", bullet.posZ);
data.setDouble("mX", bullet.motionX + bullet.worldObj.rand.nextGaussian() * 0.1);
data.setDouble("mY", bullet.motionY - 0.2 + bullet.worldObj.rand.nextGaussian() * 0.1);
data.setDouble("mZ", bullet.motionZ + bullet.worldObj.rand.nextGaussian() * 0.1);
MainRegistry.proxy.effectNT(data);
}
}
};
return bullet;
}
public static BulletConfiguration getTurbineConfig() { public static BulletConfiguration getTurbineConfig() {
BulletConfiguration bullet = new BulletConfiguration(); BulletConfiguration bullet = new BulletConfiguration();

View File

@ -6,7 +6,6 @@ import com.hbm.handler.BucketHandler;
import com.hbm.handler.ability.IToolAreaAbility; import com.hbm.handler.ability.IToolAreaAbility;
import com.hbm.handler.ability.IToolHarvestAbility; import com.hbm.handler.ability.IToolHarvestAbility;
import com.hbm.handler.ability.IWeaponAbility; import com.hbm.handler.ability.IWeaponAbility;
import com.hbm.handler.guncfg.*;
import com.hbm.interfaces.ICustomWarhead.SaltedFuel.HalfLifeType; import com.hbm.interfaces.ICustomWarhead.SaltedFuel.HalfLifeType;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.fluid.tank.FluidTank;
@ -3790,7 +3789,6 @@ public class ModItems {
gun_b92_ammo = new GunB92Cell().setUnlocalizedName("gun_b92_ammo").setMaxStackSize(1).setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_b92_ammo_alt"); gun_b92_ammo = new GunB92Cell().setUnlocalizedName("gun_b92_ammo").setMaxStackSize(1).setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_b92_ammo_alt");
gun_b92 = new GunB92().setUnlocalizedName("gun_b92").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_b92"); gun_b92 = new GunB92().setUnlocalizedName("gun_b92").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_b92");
gun_fireext = new ItemGunBase(GunEnergyFactory.getExtConfig()).setUnlocalizedName("gun_fireext").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":gun_fireext");
ToolMaterial matCrucible = EnumHelper.addToolMaterial("CRUCIBLE", 10, 3, 50.0F, 100.0F, 0); ToolMaterial matCrucible = EnumHelper.addToolMaterial("CRUCIBLE", 10, 3, 50.0F, 100.0F, 0);
crucible = new ItemCrucible(5000, 1F, matCrucible).setUnlocalizedName("crucible").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":crucible"); crucible = new ItemCrucible(5000, 1F, matCrucible).setUnlocalizedName("crucible").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":crucible");
@ -6374,7 +6372,6 @@ public class ModItems {
//Guns //Guns
GameRegistry.registerItem(gun_b92, gun_b92.getUnlocalizedName()); GameRegistry.registerItem(gun_b92, gun_b92.getUnlocalizedName());
GameRegistry.registerItem(gun_fireext, gun_fireext.getUnlocalizedName());
GameRegistry.registerItem(crucible, crucible.getUnlocalizedName()); GameRegistry.registerItem(crucible, crucible.getUnlocalizedName());
GameRegistry.registerItem(gun_debug, gun_debug.getUnlocalizedName()); GameRegistry.registerItem(gun_debug, gun_debug.getUnlocalizedName());
@ -6439,7 +6436,8 @@ public class ModItems {
GameRegistry.registerItem(gun_aberrator_eott, gun_aberrator_eott.getUnlocalizedName()); GameRegistry.registerItem(gun_aberrator_eott, gun_aberrator_eott.getUnlocalizedName());
GameRegistry.registerItem(gun_double_barrel, gun_double_barrel.getUnlocalizedName()); GameRegistry.registerItem(gun_double_barrel, gun_double_barrel.getUnlocalizedName());
GameRegistry.registerItem(gun_double_barrel_sacred_dragon, gun_double_barrel_sacred_dragon.getUnlocalizedName()); GameRegistry.registerItem(gun_double_barrel_sacred_dragon, gun_double_barrel_sacred_dragon.getUnlocalizedName());
GameRegistry.registerItem(gun_fireext, gun_fireext.getUnlocalizedName());
GameRegistry.registerItem(gun_charge_thrower, gun_charge_thrower.getUnlocalizedName()); GameRegistry.registerItem(gun_charge_thrower, gun_charge_thrower.getUnlocalizedName());
GameRegistry.registerItem(ammo_standard, ammo_standard.getUnlocalizedName()); GameRegistry.registerItem(ammo_standard, ammo_standard.getUnlocalizedName());

View File

@ -287,6 +287,7 @@ public class GunFactoryClient {
((ItemGunBaseNT) ModItems.gun_aberrator) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_AMMO); ((ItemGunBaseNT) ModItems.gun_aberrator) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_AMMO);
((ItemGunBaseNT) ModItems.gun_double_barrel) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); ((ItemGunBaseNT) ModItems.gun_double_barrel) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO);
((ItemGunBaseNT) ModItems.gun_double_barrel_sacred_dragon) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); ((ItemGunBaseNT) ModItems.gun_double_barrel_sacred_dragon) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO);
((ItemGunBaseNT) ModItems.gun_fireext) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO);
((ItemGunBaseNT) ModItems.gun_charge_thrower) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO); ((ItemGunBaseNT) ModItems.gun_charge_thrower) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY, LegoClient.HUD_COMPONENT_AMMO);
((ItemGunBaseNT) ModItems.gun_light_revolver_dani) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY_MIRROR, LegoClient.HUD_COMPONENT_AMMO_MIRROR); ((ItemGunBaseNT) ModItems.gun_light_revolver_dani) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY_MIRROR, LegoClient.HUD_COMPONENT_AMMO_MIRROR);

View File

@ -1466,6 +1466,17 @@ public class Orchestras {
} }
}; };
public static BiConsumer<ItemStack, LambdaContext> ORCHESTRA_FIREEXT = (stack, ctx) -> {
EntityLivingBase entity = ctx.entity;
if(entity.worldObj.isRemote) return;
AnimType type = ItemGunBaseNT.getLastAnim(stack, ctx.configIndex);
int timer = ItemGunBaseNT.getAnimTimer(stack, ctx.configIndex);
if(type == AnimType.RELOAD) {
if(timer == 0) entity.worldObj.playSoundAtEntity(entity, "hbm:weapon.reload.pressureValve", 1F, 1F);
}
};
public static BiConsumer<ItemStack, LambdaContext> ORCHESTRA_CHARGE_THROWER = (stack, ctx) -> { public static BiConsumer<ItemStack, LambdaContext> ORCHESTRA_CHARGE_THROWER = (stack, ctx) -> {
EntityLivingBase entity = ctx.entity; EntityLivingBase entity = ctx.entity;
if(entity.worldObj.isRemote) return; if(entity.worldObj.isRemote) return;

View File

@ -25,23 +25,165 @@ import com.hbm.items.weapon.sedna.ItemGunBaseNT.WeaponQuality;
import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo; import com.hbm.items.weapon.sedna.factory.GunFactory.EnumAmmo;
import com.hbm.items.weapon.sedna.impl.ItemGunChargeThrower; import com.hbm.items.weapon.sedna.impl.ItemGunChargeThrower;
import com.hbm.items.weapon.sedna.mags.MagazineFullReload; import com.hbm.items.weapon.sedna.mags.MagazineFullReload;
import com.hbm.main.MainRegistry;
import com.hbm.particle.helper.ExplosionCreator; import com.hbm.particle.helper.ExplosionCreator;
import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimation;
import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.BusAnimationSequence;
import com.hbm.render.anim.BusAnimationKeyframe.IType; import com.hbm.render.anim.BusAnimationKeyframe.IType;
import com.hbm.render.anim.HbmAnimations.AnimType; import com.hbm.render.anim.HbmAnimations.AnimType;
import com.hbm.tileentity.IRepairable;
import com.hbm.tileentity.IRepairable.EnumExtinguishType;
import com.hbm.util.CompatExternal;
import com.hbm.util.Vec3NT; import com.hbm.util.Vec3NT;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.util.ForgeDirection;
public class XFactoryTool { public class XFactoryTool {
public static BulletConfig fext_water;
public static BulletConfig fext_foam;
public static BulletConfig fext_sand;
public static BulletConfig ct_hook; public static BulletConfig ct_hook;
public static BulletConfig ct_mortar; public static BulletConfig ct_mortar;
public static BulletConfig ct_mortar_charge; public static BulletConfig ct_mortar_charge;
public static BiConsumer<EntityBulletBaseMK4, MovingObjectPosition> LAMBDA_WATER_HIT = (bullet, mop) -> {
if(!bullet.worldObj.isRemote) {
int ix = mop.blockX;
int iy = mop.blockY;
int iz = mop.blockZ;
boolean fizz = false;
for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++) for(int k = -1; k <= 1; k++) {
Block block = bullet.worldObj.getBlock(ix + i, iy + j, iz + k);
if(block == Blocks.fire || block == ModBlocks.foam_layer || block == ModBlocks.block_foam) {
bullet.worldObj.setBlock(ix + i, iy + j, iz + k, Blocks.air);
fizz = true;
}
}
TileEntity core = CompatExternal.getCoreFromPos(bullet.worldObj, ix, iy, iz);
if(core instanceof IRepairable) ((IRepairable) core).tryExtinguish(bullet.worldObj, ix, iy, iz, EnumExtinguishType.WATER);
if(fizz) bullet.worldObj.playSoundEffect(bullet.posX, bullet.posY, bullet.posZ, "random.fizz", 1.0F, 1.5F + bullet.worldObj.rand.nextFloat() * 0.5F);
bullet.setDead();
}
};
public static Consumer<Entity> LAMBDA_WATER_UPDATE = (bullet) -> {
if(bullet.worldObj.isRemote) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaExt");
data.setString("mode", "blockdust");
data.setInteger("block", Block.getIdFromBlock(Blocks.water));
data.setDouble("posX", bullet.posX); data.setDouble("posY", bullet.posY); data.setDouble("posZ", bullet.posZ);
data.setDouble("mX", bullet.motionX + bullet.worldObj.rand.nextGaussian() * 0.05);
data.setDouble("mY", bullet.motionY - 0.2 + bullet.worldObj.rand.nextGaussian() * 0.05);
data.setDouble("mZ", bullet.motionZ + bullet.worldObj.rand.nextGaussian() * 0.05);
MainRegistry.proxy.effectNT(data);
} else {
int x = (int)Math.floor(bullet.posX);
int y = (int)Math.floor(bullet.posY);
int z = (int)Math.floor(bullet.posZ);
if(bullet.worldObj.getBlock(x, y, z) == ModBlocks.volcanic_lava_block && bullet.worldObj.getBlockMetadata(x, y, z) == 0) {
bullet.worldObj.setBlock(x, y, z, Blocks.obsidian);
bullet.setDead();
}
}
};
public static BiConsumer<EntityBulletBaseMK4, MovingObjectPosition> LAMBDA_FOAM_HIT = (bullet, mop) -> {
if(!bullet.worldObj.isRemote) {
int ix = mop.blockX;
int iy = mop.blockY;
int iz = mop.blockZ;
boolean fizz = false;
for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++) for(int k = -1; k <= 1; k++) {
Block b = bullet.worldObj.getBlock(ix + i, iy + j, iz + k);
if(b.getMaterial() == Material.fire) {
bullet.worldObj.setBlock(ix + i, iy + j, iz + k, Blocks.air);
fizz = true;
}
}
TileEntity core = CompatExternal.getCoreFromPos(bullet.worldObj, ix, iy, iz);
if(core instanceof IRepairable) { ((IRepairable) core).tryExtinguish(bullet.worldObj, ix, iy, iz, EnumExtinguishType.FOAM); return; }
if(bullet.worldObj.rand.nextBoolean()) {
ForgeDirection dir = ForgeDirection.getOrientation(mop.sideHit);
ix += dir.offsetX; iy += dir.offsetY; iz += dir.offsetZ;
}
Block b = bullet.worldObj.getBlock(ix, iy, iz);
if(b.isReplaceable(bullet.worldObj, ix, iy, iz) && ModBlocks.foam_layer.canPlaceBlockAt(bullet.worldObj, ix, iy, iz)) {
if(b != ModBlocks.foam_layer) {
bullet.worldObj.setBlock(ix, iy, iz, ModBlocks.foam_layer);
} else {
int meta = bullet.worldObj.getBlockMetadata(ix, iy, iz);
if(meta < 6) bullet.worldObj.setBlockMetadataWithNotify(ix, iy, iz, meta + 1, 3);
else bullet.worldObj.setBlock(ix, iy, iz, ModBlocks.block_foam);
}
}
if(fizz) bullet.worldObj.playSoundEffect(bullet.posX, bullet.posY, bullet.posZ, "random.fizz", 1.0F, 1.5F + bullet.worldObj.rand.nextFloat() * 0.5F);
}
};
public static Consumer<Entity> LAMBDA_FOAM_UPDATE = (bullet) -> {
if(bullet.worldObj.isRemote) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaExt");
data.setString("mode", "blockdust");
data.setInteger("block", Block.getIdFromBlock(ModBlocks.block_foam));
data.setDouble("posX", bullet.posX); data.setDouble("posY", bullet.posY); data.setDouble("posZ", bullet.posZ);
data.setDouble("mX", bullet.motionX + bullet.worldObj.rand.nextGaussian() * 0.1);
data.setDouble("mY", bullet.motionY - 0.2 + bullet.worldObj.rand.nextGaussian() * 0.1);
data.setDouble("mZ", bullet.motionZ + bullet.worldObj.rand.nextGaussian() * 0.1);
MainRegistry.proxy.effectNT(data);
}
};
public static BiConsumer<EntityBulletBaseMK4, MovingObjectPosition> LAMBDA_SAND_HIT = (bullet, mop) -> {
if(!bullet.worldObj.isRemote) {
int ix = mop.blockX;
int iy = mop.blockY;
int iz = mop.blockZ;
TileEntity core = CompatExternal.getCoreFromPos(bullet.worldObj, ix, iy, iz);
if(core instanceof IRepairable) { ((IRepairable) core).tryExtinguish(bullet.worldObj, ix, iy, iz, EnumExtinguishType.SAND); return; }
if(bullet.worldObj.rand.nextBoolean()) {
ForgeDirection dir = ForgeDirection.getOrientation(mop.sideHit);
ix += dir.offsetX; iy += dir.offsetY; iz += dir.offsetZ;
}
Block b = bullet.worldObj.getBlock(ix, iy, iz);
if((b.isReplaceable(bullet.worldObj, ix, iy, iz) || b == ModBlocks.sand_boron_layer) && ModBlocks.sand_boron_layer.canPlaceBlockAt(bullet.worldObj, ix, iy, iz)) {
if(b != ModBlocks.sand_boron_layer) {
bullet.worldObj.setBlock(ix, iy, iz, ModBlocks.sand_boron_layer);
} else {
int meta = bullet.worldObj.getBlockMetadata(ix, iy, iz);
if(meta < 6) bullet.worldObj.setBlockMetadataWithNotify(ix, iy, iz, meta + 1, 3);
else bullet.worldObj.setBlock(ix, iy, iz, ModBlocks.sand_boron);
}
if(b.getMaterial() == Material.fire) bullet.worldObj.playSoundEffect(bullet.posX, bullet.posY, bullet.posZ, "random.fizz", 1.0F, 1.5F + bullet.worldObj.rand.nextFloat() * 0.5F);
}
}
};
public static Consumer<Entity> LAMBDA_SAND_UPDATE = (bullet) -> {
if(bullet.worldObj.isRemote) {
NBTTagCompound data = new NBTTagCompound();
data.setString("type", "vanillaExt");
data.setString("mode", "blockdust");
data.setInteger("block", Block.getIdFromBlock(ModBlocks.sand_boron));
data.setDouble("posX", bullet.posX); data.setDouble("posY", bullet.posY); data.setDouble("posZ", bullet.posZ);
data.setDouble("mX", bullet.motionX + bullet.worldObj.rand.nextGaussian() * 0.1);
data.setDouble("mY", bullet.motionY - 0.2 + bullet.worldObj.rand.nextGaussian() * 0.1);
data.setDouble("mZ", bullet.motionZ + bullet.worldObj.rand.nextGaussian() * 0.1);
MainRegistry.proxy.effectNT(data);
}
};
public static Consumer<Entity> LAMBDA_SET_HOOK = (entity) -> { public static Consumer<Entity> LAMBDA_SET_HOOK = (entity) -> {
EntityBulletBaseMK4 bullet = (EntityBulletBaseMK4) entity; EntityBulletBaseMK4 bullet = (EntityBulletBaseMK4) entity;
@ -88,6 +230,19 @@ public class XFactoryTool {
public static void init() { public static void init() {
fext_water = new BulletConfig().setItem(new ItemStack(ModItems.ammo_fireext, 1, 0)).setReloadCount(300).setLife(100).setVel(0.75F).setGrav(0.04D).setSpread(0.025F)
.setOnUpdate(LAMBDA_WATER_UPDATE)
.setOnEntityHit((bulletEntity, target) -> { if(target.entityHit != null) target.entityHit.extinguish(); })
.setOnRicochet(LAMBDA_WATER_HIT);
fext_foam = new BulletConfig().setItem(new ItemStack(ModItems.ammo_fireext, 1, 1)).setReloadCount(300).setLife(100).setVel(0.75F).setGrav(0.04D).setSpread(0.05F)
.setOnUpdate(LAMBDA_FOAM_UPDATE)
.setOnEntityHit((bulletEntity, target) -> { if(target.entityHit != null) target.entityHit.extinguish(); })
.setOnRicochet(LAMBDA_FOAM_HIT);
fext_sand = new BulletConfig().setItem(new ItemStack(ModItems.ammo_fireext, 1, 1)).setReloadCount(300).setLife(100).setVel(0.75F).setGrav(0.04D).setSpread(0.05F)
.setOnUpdate(LAMBDA_SAND_UPDATE)
.setOnEntityHit((bulletEntity, target) -> { if(target.entityHit != null) target.entityHit.extinguish(); })
.setOnRicochet(LAMBDA_SAND_HIT);
ct_hook = new BulletConfig().setItem(EnumAmmo.CT_HOOK).setRenderRotations(false).setLife(6_000).setVel(3F).setGrav(0.035D).setDoesPenetrate(true).setDamageFalloffByPen(false) ct_hook = new BulletConfig().setItem(EnumAmmo.CT_HOOK).setRenderRotations(false).setLife(6_000).setVel(3F).setGrav(0.035D).setDoesPenetrate(true).setDamageFalloffByPen(false)
.setOnUpdate(LAMBDA_SET_HOOK).setOnImpact(LAMBDA_HOOK); .setOnUpdate(LAMBDA_SET_HOOK).setOnImpact(LAMBDA_HOOK);
ct_mortar = new BulletConfig().setItem(EnumAmmo.CT_MORTAR).setDamage(2.5F).setLife(200).setVel(3F).setGrav(0.035D) ct_mortar = new BulletConfig().setItem(EnumAmmo.CT_MORTAR).setDamage(2.5F).setLife(200).setVel(3F).setGrav(0.035D)
@ -95,6 +250,17 @@ public class XFactoryTool {
ct_mortar_charge = new BulletConfig().setItem(EnumAmmo.CT_MORTAR_CHARGE).setDamage(5F).setLife(200).setVel(3F).setGrav(0.035D) ct_mortar_charge = new BulletConfig().setItem(EnumAmmo.CT_MORTAR_CHARGE).setDamage(5F).setLife(200).setVel(3F).setGrav(0.035D)
.setOnImpact(LAMBDA_MORTAR_CHARGE); .setOnImpact(LAMBDA_MORTAR_CHARGE);
ModItems.gun_fireext = new ItemGunBaseNT(WeaponQuality.UTILITY, new GunConfig()
.dura(5_000).draw(10).inspect(55).reloadChangeType(true).hideCrosshair(false).crosshair(Crosshair.L_CIRCLE)
.rec(new Receiver(0)
.dmg(0F).delay(1).dry(0).auto(true).spread(0F).spreadHipfire(0F).reload(20).jam(0).sound("hbm:weapon.extinguisher", 1.0F, 1.0F)
.mag(new MagazineFullReload(0, 300).addConfigs(fext_water, fext_foam, fext_sand))
.offset(1, -0.0625 * 2.5, -0.25D)
.setupStandardFire())
.setupStandardConfiguration()
.orchestra(Orchestras.ORCHESTRA_FIREEXT)
).setUnlocalizedName("gun_fireext");
ModItems.gun_charge_thrower = new ItemGunChargeThrower(WeaponQuality.UTILITY, new GunConfig() ModItems.gun_charge_thrower = new ItemGunChargeThrower(WeaponQuality.UTILITY, new GunConfig()
.dura(3_000).draw(10).inspect(55).reloadChangeType(true).hideCrosshair(false).crosshair(Crosshair.L_CIRCUMFLEX) .dura(3_000).draw(10).inspect(55).reloadChangeType(true).hideCrosshair(false).crosshair(Crosshair.L_CIRCUMFLEX)
.rec(new Receiver(0) .rec(new Receiver(0)

View File

@ -491,27 +491,6 @@ public class ModEventHandlerClient {
EntityPlayer player = Minecraft.getMinecraft().thePlayer; EntityPlayer player = Minecraft.getMinecraft().thePlayer;
ItemStack held = player.getHeldItem(); ItemStack held = player.getHeldItem();
if(held == null) return;
if(!(held.getItem() instanceof ItemGunBase)) return;
GunConfiguration config = ((ItemGunBase) held.getItem()).mainConfig;
if(config == null) return;
if(config.zoomFOV == 0F || !player.isSneaking()) return;
if(config.absoluteFOV) {
event.newfov = config.zoomFOV;
} else {
event.newfov += config.zoomFOV;
}
}
@SubscribeEvent
public void setupNewFOV(FOVUpdateEvent event) {
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
ItemStack held = player.getHeldItem();
if(held == null) return; if(held == null) return;
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(held, IItemRenderer.ItemRenderType.EQUIPPED); IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(held, IItemRenderer.ItemRenderType.EQUIPPED);

View File

@ -2,9 +2,9 @@ package com.hbm.render.item.weapon;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.hbm.handler.BulletConfigSyncingUtil; import com.hbm.items.weapon.sedna.ItemGunBaseNT;
import com.hbm.items.ModItems; import com.hbm.items.weapon.sedna.factory.XFactoryTool;
import com.hbm.items.weapon.ItemGunBase; import com.hbm.items.weapon.sedna.mags.IMagazine;
import com.hbm.main.ResourceManager; import com.hbm.main.ResourceManager;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -41,15 +41,11 @@ public class ItemRenderFireExt implements IItemRenderer {
GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_CULL_FACE);
int magType = ItemGunBase.getMagType(item); ItemGunBaseNT gun = (ItemGunBaseNT) item.getItem();
int config = ((ItemGunBase)ModItems.gun_fireext).mainConfig.config.get(magType); IMagazine mag = gun.getConfig(item, 0).getReceivers(item)[0].getMagazine(item);
int ammo = BulletConfigSyncingUtil.pullConfig(config).ammo.meta; ResourceLocation tex = ResourceManager.fireext_tex;
ResourceLocation tex; if(mag.getType(item, null) == XFactoryTool.fext_foam) tex = ResourceManager.fireext_foam_tex;
switch (ammo) { if(mag.getType(item, null) == XFactoryTool.fext_sand) tex = ResourceManager.fireext_sand_tex;
case 0: tex = ResourceManager.fireext_foam_tex; break;
case 1: tex = ResourceManager.fireext_sand_tex; break;
default: tex = ResourceManager.fireext_tex; break;
}
Minecraft.getMinecraft().renderEngine.bindTexture(tex); Minecraft.getMinecraft().renderEngine.bindTexture(tex);
switch(type) { switch(type) {

View File

@ -99,7 +99,7 @@ public class TileEntityMachineArcWelder extends TileEntityMachineBase implements
this.processTime = recipe.duration - (recipe.duration * redLevel / 6) + (recipe.duration * blueLevel / 3); this.processTime = recipe.duration - (recipe.duration * redLevel / 6) + (recipe.duration * blueLevel / 3);
this.consumption = recipe.consumption + (recipe.consumption * redLevel) - (recipe.consumption * blueLevel / 6); this.consumption = recipe.consumption + (recipe.consumption * redLevel) - (recipe.consumption * blueLevel / 6);
this.consumption *= Math.pow(2, blackLevel); this.consumption *= Math.pow(2, blackLevel);
intendedMaxPower = recipe.consumption * 20; intendedMaxPower = consumption * 20;
if(canProcess(recipe)) { if(canProcess(recipe)) {
this.progress += (1 + blackLevel); this.progress += (1 + blackLevel);

View File

@ -105,7 +105,7 @@ public class TileEntityMachineSolderingStation extends TileEntityMachineBase imp
this.processTime = recipe.duration - (recipe.duration * redLevel / 6) + (recipe.duration * blueLevel / 3); this.processTime = recipe.duration - (recipe.duration * redLevel / 6) + (recipe.duration * blueLevel / 3);
this.consumption = recipe.consumption + (recipe.consumption * redLevel) - (recipe.consumption * blueLevel / 6); this.consumption = recipe.consumption + (recipe.consumption * redLevel) - (recipe.consumption * blueLevel / 6);
this.consumption *= Math.pow(2, blackLevel); this.consumption *= Math.pow(2, blackLevel);
intendedMaxPower = recipe.consumption * 20; intendedMaxPower = consumption * 20;
if(canProcess(recipe)) { if(canProcess(recipe)) {
this.progress += (1 + blackLevel); this.progress += (1 + blackLevel);

View File

@ -11,7 +11,6 @@ import com.hbm.inventory.material.Mats;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemMold; import com.hbm.items.machine.ItemMold;
import com.hbm.items.machine.ItemScraps; import com.hbm.items.machine.ItemScraps;
import com.hbm.main.MainRegistry;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;