From 148ba197210e4e04062dccc05a35c2145c48fa10 Mon Sep 17 00:00:00 2001 From: Boblet Date: Fri, 23 May 2025 13:40:48 +0200 Subject: [PATCH] deploy surface-to-yellow-one missile --- changelog | 7 +- .../hbm/handler/BulletConfigSyncingUtil.java | 8 - .../com/hbm/handler/BulletConfiguration.java | 11 +- .../com/hbm/handler/GunConfiguration.java | 10 +- .../handler/ability/AvailableAbilities.java | 174 +++--- .../com/hbm/handler/ability/IBaseAbility.java | 44 +- .../hbm/handler/ability/IToolAreaAbility.java | 452 +++++++-------- .../handler/ability/IToolHarvestAbility.java | 540 ++++++++--------- .../hbm/handler/ability/IWeaponAbility.java | 547 +++++++++--------- .../com/hbm/handler/ability/ToolPreset.java | 147 ++--- .../handler/guncfg/BulletConfigFactory.java | 258 --------- .../hbm/handler/guncfg/GunCannonFactory.java | 96 --- .../hbm/handler/guncfg/GunEnergyFactory.java | 306 ---------- src/main/java/com/hbm/items/ModItems.java | 6 +- .../sedna/factory/GunFactoryClient.java | 1 + .../weapon/sedna/factory/Orchestras.java | 11 + .../weapon/sedna/factory/XFactoryTool.java | 166 ++++++ .../com/hbm/main/ModEventHandlerClient.java | 21 - .../render/item/weapon/ItemRenderFireExt.java | 20 +- .../machine/TileEntityMachineArcWelder.java | 2 +- .../TileEntityMachineSolderingStation.java | 2 +- .../TileEntityMachineStrandCaster.java | 1 - 22 files changed, 1148 insertions(+), 1682 deletions(-) delete mode 100644 src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java diff --git a/changelog b/changelog index 3520d9bca..b730d65b1 100644 --- a/changelog +++ b/changelog @@ -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 * Clicking on the same ability allows switching between levels * 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 \ No newline at end of file +## 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 \ No newline at end of file diff --git a/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java b/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java index 8864f159a..3deab1d17 100644 --- a/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java +++ b/src/main/java/com/hbm/handler/BulletConfigSyncingUtil.java @@ -13,10 +13,6 @@ public class BulletConfigSyncingUtil { 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 MASKMAN_BULLET = i++; @@ -33,10 +29,6 @@ public class BulletConfigSyncingUtil { 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(MASKMAN_BULLET, GunNPCFactory.getMaskmanBullet()); diff --git a/src/main/java/com/hbm/handler/BulletConfiguration.java b/src/main/java/com/hbm/handler/BulletConfiguration.java index aa1d73ca5..c2b269b27 100644 --- a/src/main/java/com/hbm/handler/BulletConfiguration.java +++ b/src/main/java/com/hbm/handler/BulletConfiguration.java @@ -17,6 +17,7 @@ import net.minecraft.util.DamageSource; import net.minecraft.util.EntityDamageSourceIndirect; import net.minecraft.util.EnumChatFormatting; +@Deprecated public class BulletConfiguration implements Cloneable { //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_ROCKET = 6; 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_BF = 11; public static final int STYLE_ORB = 12; public static final int STYLE_METEOR = 13; public static final int STYLE_APDS = 14; 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_LEADBURSTER = 18; @@ -174,13 +172,6 @@ public class BulletConfiguration implements Cloneable { return this; } - public BulletConfiguration setToGuided() { - - this.bntUpdate = BulletConfigFactory.getLaserSteering(); - this.doesRicochet = false; - return this; - } - public BulletConfiguration getChlorophyte() { this.bntUpdate = BulletConfigFactory.getHomingBehavior(30, 180); this.bntHurt = BulletConfigFactory.getPenHomingBehavior(); diff --git a/src/main/java/com/hbm/handler/GunConfiguration.java b/src/main/java/com/hbm/handler/GunConfiguration.java index 974322d00..9cce19944 100644 --- a/src/main/java/com/hbm/handler/GunConfiguration.java +++ b/src/main/java/com/hbm/handler/GunConfiguration.java @@ -12,6 +12,7 @@ import com.hbm.render.anim.HbmAnimations.AnimType; import net.minecraft.util.ResourceLocation; +@Deprecated public class GunConfiguration implements Cloneable { /** @@ -46,10 +47,6 @@ public class GunConfiguration implements Cloneable { public boolean isCentered; //texture overlay when sneaking 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 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_NEW = "hbm:weapon.glReload"; public static final String RSOUND_FATMAN = "hbm:weapon.fatmanReload"; - - public GunConfiguration silenced() { - this.firingSound = "hbm:weapon.silencerShoot"; - return this; - } } diff --git a/src/main/java/com/hbm/handler/ability/AvailableAbilities.java b/src/main/java/com/hbm/handler/ability/AvailableAbilities.java index 6e05b5a30..2949c42d5 100644 --- a/src/main/java/com/hbm/handler/ability/AvailableAbilities.java +++ b/src/main/java/com/hbm/handler/ability/AvailableAbilities.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import com.google.common.base.Functions; import com.hbm.main.MainRegistry; import cpw.mods.fml.relauncher.Side; @@ -16,118 +15,109 @@ import net.minecraft.util.EnumChatFormatting; // All abilities available on a given tool public class AvailableAbilities { - // Insertion order matters - private HashMap abilities = new HashMap(); + // Insertion order matters + private HashMap abilities = new HashMap(); - public AvailableAbilities() {} + public AvailableAbilities() { } - public AvailableAbilities addAbility(IBaseAbility ability, int level) { - if (level < 0 || level >= ability.levels()) { - MainRegistry.logger.warn("Illegal level " + level + " for ability " + ability.getName()); - level = ability.levels() - 1; - } + public AvailableAbilities addAbility(IBaseAbility ability, int level) { + if(level < 0 || level >= ability.levels()) { + MainRegistry.logger.warn("Illegal level " + level + " for ability " + ability.getName()); + level = ability.levels() - 1; + } - if (abilities.containsKey(ability)) { - MainRegistry.logger.warn("Ability " + ability.getName() + " already had level " + abilities.get(ability) + ", overwriting with level " + level); - } + if(abilities.containsKey(ability)) { + MainRegistry.logger.warn("Ability " + ability.getName() + " already had level " + abilities.get(ability) + ", overwriting with level " + level); + } - if (ability.isAllowed()) { - abilities.put(ability, level); - } + if(ability.isAllowed()) { + abilities.put(ability, level); + } - return this; - } + return this; + } - public AvailableAbilities addToolAbilities() { - addAbility(IToolAreaAbility.NONE, 0); - addAbility(IToolHarvestAbility.NONE, 0); - return this; - } + public AvailableAbilities addToolAbilities() { + addAbility(IToolAreaAbility.NONE, 0); + addAbility(IToolHarvestAbility.NONE, 0); + return this; + } - public AvailableAbilities removeAbility(IBaseAbility ability) { - abilities.remove(ability); - return this; - } + public AvailableAbilities removeAbility(IBaseAbility ability) { + abilities.remove(ability); + return this; + } - public boolean supportsAbility(IBaseAbility ability) { - return abilities.containsKey(ability); - } + public boolean supportsAbility(IBaseAbility ability) { + return abilities.containsKey(ability); + } - public int maxLevel(IBaseAbility ability) { - return abilities.getOrDefault(ability, -1); - } + public int maxLevel(IBaseAbility ability) { + return abilities.getOrDefault(ability, -1); + } - public Map get() { - return Collections.unmodifiableMap(abilities); - } + public Map get() { + return Collections.unmodifiableMap(abilities); + } - public Map getWeaponAbilities() { - return abilities.keySet().stream().filter(a -> a instanceof IWeaponAbility).collect(Collectors.toMap(a -> (IWeaponAbility)a, a -> abilities.get(a))); - } + public Map getWeaponAbilities() { + return abilities.keySet().stream().filter(a -> a instanceof IWeaponAbility).collect(Collectors.toMap(a -> (IWeaponAbility) a, a -> abilities.get(a))); + } - public Map getToolAbilities() { - return abilities.keySet().stream().filter(a -> a instanceof IToolAreaAbility || a instanceof IToolHarvestAbility).collect(Collectors.toMap(a -> a, a -> abilities.get(a))); - } + public Map getToolAbilities() { + return abilities.keySet().stream().filter(a -> a instanceof IToolAreaAbility || a instanceof IToolHarvestAbility).collect(Collectors.toMap(a -> a, a -> abilities.get(a))); + } - public Map getToolAreaAbilities() { - return abilities.keySet().stream().filter(a -> a instanceof IToolAreaAbility).collect(Collectors.toMap(a -> (IToolAreaAbility)a, a -> abilities.get(a))); - } + public Map getToolAreaAbilities() { + return abilities.keySet().stream().filter(a -> a instanceof IToolAreaAbility).collect(Collectors.toMap(a -> (IToolAreaAbility) a, a -> abilities.get(a))); + } - public Map getToolHarvestAbilities() { - return abilities.keySet().stream().filter(a -> a instanceof IToolHarvestAbility).collect(Collectors.toMap(a -> (IToolHarvestAbility)a, a -> abilities.get(a))); - } + public Map getToolHarvestAbilities() { + return abilities.keySet().stream().filter(a -> a instanceof IToolHarvestAbility).collect(Collectors.toMap(a -> (IToolHarvestAbility) a, a -> abilities.get(a))); + } - public int size() { - return abilities.size(); - } + public int size() { + return abilities.size(); + } - public boolean isEmpty() { - return abilities.isEmpty(); - } + public boolean isEmpty() { + return abilities.isEmpty(); + } - @SideOnly(Side.CLIENT) - public void addInformation(List list) { - List> toolAbilities = abilities.entrySet().stream().filter(entry -> - (entry.getKey() instanceof IToolAreaAbility && entry.getKey() != IToolAreaAbility.NONE) || - (entry.getKey() instanceof IToolHarvestAbility && entry.getKey() != IToolHarvestAbility.NONE) - ).sorted( - Comparator - .comparing(Map.Entry::getKey) - .thenComparing(Map.Entry::getValue) - ).collect(Collectors.toList()); - - if (!toolAbilities.isEmpty()) { - list.add("Abilities: "); + @SideOnly(Side.CLIENT) + public void addInformation(List list) { + List> toolAbilities = abilities.entrySet().stream() + .filter(entry -> (entry.getKey() instanceof IToolAreaAbility && entry.getKey() != IToolAreaAbility.NONE) + || (entry.getKey() instanceof IToolHarvestAbility && entry.getKey() != IToolHarvestAbility.NONE)) + .sorted(Comparator.comparing(Map.Entry::getKey).thenComparing(Map.Entry::getValue)).collect(Collectors.toList()); - toolAbilities.forEach(entry -> { - IBaseAbility ability = entry.getKey(); - int level = entry.getValue(); - - list.add(" " + EnumChatFormatting.GOLD + ability.getFullName(level)); - }); + if(!toolAbilities.isEmpty()) { + list.add("Abilities: "); + + toolAbilities.forEach(entry -> { + 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("Sneak-click to go to first preset!"); list.add("Alt-click to open customization GUI!"); - } - - List> weaponAbilities = abilities.entrySet().stream().filter(entry -> - (entry.getKey() instanceof IWeaponAbility && entry.getKey() != IWeaponAbility.NONE) - ).sorted( - Comparator - .comparing(Map.Entry::getKey) - .thenComparing(Map.Entry::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> weaponAbilities = abilities.entrySet().stream().filter(entry -> (entry.getKey() instanceof IWeaponAbility && entry.getKey() != IWeaponAbility.NONE)) + .sorted(Comparator.comparing(Map.Entry::getKey).thenComparing(Map.Entry::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)); + }); + } + } } diff --git a/src/main/java/com/hbm/handler/ability/IBaseAbility.java b/src/main/java/com/hbm/handler/ability/IBaseAbility.java index 9999bcaa0..b8318cc94 100644 --- a/src/main/java/com/hbm/handler/ability/IBaseAbility.java +++ b/src/main/java/com/hbm/handler/ability/IBaseAbility.java @@ -3,34 +3,34 @@ package com.hbm.handler.ability; import net.minecraft.client.resources.I18n; public interface IBaseAbility extends Comparable { - public String getName(); + public String getName(); public default String getExtension(int level) { - return ""; - } + return ""; + } public default String getFullName(int level) { - return I18n.format(getName()) + getExtension(level); - } + return I18n.format(getName()) + getExtension(level); + } - public default boolean isAllowed() { - return true; - } + public default boolean isAllowed() { + return true; + } - // 1 means no support for levels (i.e. the level is always 0). - // The UI only supports levels() between 1 and 10 (inclusive). - // All calls accepting an `int level` parameters must be done - // with a level between 0 and levels()-1 (inclusive). - default int levels() { - return 1; - } + // 1 means no support for levels (i.e. the level is always 0). + // The UI only supports levels() between 1 and 10 (inclusive). + // All calls accepting an `int level` parameters must be done + // with a level between 0 and levels()-1 (inclusive). + default int levels() { + return 1; + } - default int sortOrder() { - return hashCode(); - } + default int sortOrder() { + return hashCode(); + } - @Override - default int compareTo(IBaseAbility o) { - return sortOrder() - o.sortOrder(); - } + @Override + default int compareTo(IBaseAbility o) { + return sortOrder() - o.sortOrder(); + } } diff --git a/src/main/java/com/hbm/handler/ability/IToolAreaAbility.java b/src/main/java/com/hbm/handler/ability/IToolAreaAbility.java index 9929cd303..1d0bcf02b 100644 --- a/src/main/java/com/hbm/handler/ability/IToolAreaAbility.java +++ b/src/main/java/com/hbm/handler/ability/IToolAreaAbility.java @@ -10,274 +10,274 @@ import com.hbm.config.ToolConfig; import com.hbm.explosion.ExplosionNT; import com.hbm.explosion.ExplosionNT.ExAttrib; import com.hbm.handler.ThreeInts; -import com.hbm.inventory.OreDictManager; import com.hbm.items.tool.ItemToolAbility; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; import net.minecraft.util.Vec3; import net.minecraft.world.World; -import net.minecraftforge.oredict.OreDictionary; public interface IToolAreaAbility extends IBaseAbility { - // Should call tool.breakExtraBlock on a bunch of blocks. - // The initial block is implicitly broken, so don't call breakExtraBlock on it. - // 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); - - // Whether breakExtraBlock is called at all. Currently only false for explosion - public default boolean allowsHarvest(int level) { - return true; - } + // Should call tool.breakExtraBlock on a bunch of blocks. + // The initial block is implicitly broken, so don't call breakExtraBlock on it. + // 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 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 static final IToolAreaAbility NONE = new IToolAreaAbility() { - @Override - public String getName() { - return ""; - } + public final static int SORT_ORDER_BASE = 0; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 0; - } - - @Override - public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) { - return false; - } - }; + // region handlers + public static final IToolAreaAbility NONE = new IToolAreaAbility() { + @Override + public String getName() { + return ""; + } - public static final IToolAreaAbility RECURSION = new IToolAreaAbility() { - @Override - public String getName() { - return "tool.ability.recursion"; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 0; + } - @Override - public boolean isAllowed() { - return ToolConfig.abilityVein; - } + @Override + public boolean onDig(int level, World world, int x, int y, int z, EntityPlayer player, ItemToolAbility tool) { + 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 - public int levels() { - return radiusAtLevel.length; - } + @Override + public boolean isAllowed() { + return ToolConfig.abilityVein; + } - @Override - public String getExtension(int level) { - return " (" + radiusAtLevel[level] + ")"; - } + public final int[] radiusAtLevel = { 3, 4, 5, 6, 7, 9, 10 }; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 1; - } + @Override + public int levels() { + return radiusAtLevel.length; + } - // Note: if reusing it across different instatces of a tool - // 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. - private Set pos = new HashSet<>(); + @Override + public String getExtension(int level) { + return " (" + 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); - - if(b == Blocks.stone && !ToolConfig.recursiveStone) { - return false; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 1; + } - if(b == Blocks.netherrack && !ToolConfig.recursiveNetherrack) { - return false; - } - - pos.clear(); + // Note: if reusing it across different instatces of a tool + // 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. + private Set 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 offsets = new ArrayList(3*3*3-1) {{ - 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)); - } - } - } - } - }}; + if(b == Blocks.netherrack && !ToolConfig.recursiveNetherrack) { + return false; + } - 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 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); + pos.clear(); - recurse(world, x, y, z, refX, refY, refZ, player, tool, depth, radius); - } - - 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; - } - }; + recurse(world, x, y, z, x, y, z, player, tool, 0, radiusAtLevel[level]); - public static final IToolAreaAbility HAMMER = new IToolAreaAbility() { - @Override - public String getName() { - return "tool.ability.hammer"; - } + return false; + } - @Override - public boolean isAllowed() { - return ToolConfig.abilityHammer; - } + private final List offsets = new ArrayList(3 * 3 * 3 - 1) { + { + 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 shuffledOffsets = new ArrayList<>(offsets); + Collections.shuffle(shuffledOffsets); - @Override - public int levels() { - return rangeAtLevel.length; - } + for(ThreeInts offset : shuffledOffsets) { + breakExtra(world, x + offset.x, y + offset.y, z + offset.z, refX, refY, refZ, player, tool, depth, radius); + } + } - @Override - public String getExtension(int level) { - return " (" + rangeAtLevel[level] + ")"; - } + 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; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 2; - } + depth += 1; - @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); - } - } - } + if(depth > ToolConfig.recursionDepth) + return; - return false; - } - }; + pos.add(new ThreeInts(x, y, z)); - public static final IToolAreaAbility EXPLOSION = new IToolAreaAbility() { - @Override - public String getName() { - return "tool.ability.explosion"; - } + // don't lose the ref block just yet + if(x == refX && y == refY && z == refZ) + return; - @Override - public boolean isAllowed() { - return ToolConfig.abilityExplosion; - } + if(Vec3.createVectorHelper(x - refX, y - refY, z - refZ).lengthVector() > radius) + return; - 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 - public int levels() { - return strengthAtLevel.length; - } + if(!isSameBlock(b, ref)) + return; - @Override - public String getExtension(int level) { - return " (" + strengthAtLevel[level] + ")"; - } + if(meta != refMeta) + return; - @Override - public boolean allowsHarvest(int level) { - return false; - } + if(player.getHeldItem() == null) + return; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 3; - } + tool.breakExtraBlock(world, x, y, z, player, refX, refY, refZ); - @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 + recurse(world, x, y, z, refX, refY, refZ, player, tool, depth, radius); + } - 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) { - for(IToolAreaAbility ability : abilities) { - if(ability.getName().equals(name)) - return ability; - } - - return NONE; - } + return false; + } + }; + + public static final IToolAreaAbility HAMMER = new IToolAreaAbility() { + @Override + 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; + } } diff --git a/src/main/java/com/hbm/handler/ability/IToolHarvestAbility.java b/src/main/java/com/hbm/handler/ability/IToolHarvestAbility.java index b1d54dd11..9f002bfbd 100644 --- a/src/main/java/com/hbm/handler/ability/IToolHarvestAbility.java +++ b/src/main/java/com/hbm/handler/ability/IToolHarvestAbility.java @@ -23,319 +23,321 @@ import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.world.World; 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. - // 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); - } + public static void harvestBlock(boolean skipDefaultDrops, World world, int x, int y, int z, EntityPlayer player) { + 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 static void harvestBlock(boolean skipDefaultDrops, World world, int x, int y, int z, EntityPlayer player) { - 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; - public final static int SORT_ORDER_BASE = 100; + // region handlers + public static final IToolHarvestAbility NONE = new IToolHarvestAbility() { + @Override + public String getName() { + return ""; + } - // region handlers - public static final IToolHarvestAbility NONE = new IToolHarvestAbility() { - @Override - public String getName() { - return ""; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 0; + } + }; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 0; - } - }; + public static final IToolHarvestAbility SILK = new IToolHarvestAbility() { + @Override + public String getName() { + return "tool.ability.silktouch"; + } - public static final IToolHarvestAbility SILK = new IToolHarvestAbility() { - @Override - public String getName() { - return "tool.ability.silktouch"; - } + @Override + public boolean isAllowed() { + return ToolConfig.abilitySilk; + } - @Override - public boolean isAllowed() { - return ToolConfig.abilitySilk; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 1; + } - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 1; - } + @Override + public void preHarvestAll(int level, World world, EntityPlayer player) { + ItemStack stack = player.getHeldItem(); + EnchantmentUtil.addEnchantment(stack, Enchantment.silkTouch, 1); + } - @Override - public void preHarvestAll(int level, World world, EntityPlayer player) { - ItemStack stack = player.getHeldItem(); - EnchantmentUtil.addEnchantment(stack, Enchantment.silkTouch, 1); - } + @Override + public void postHarvestAll(int level, World world, EntityPlayer player) { + // ToC-ToU mismatch should be impossible + // 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 void postHarvestAll(int level, World world, EntityPlayer player) { - // ToC-ToU mismatch should be impossible - // 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); - } - }; + public static final IToolHarvestAbility LUCK = new IToolHarvestAbility() { + @Override + public String getName() { + return "tool.ability.luck"; + } - public static final IToolHarvestAbility LUCK = new IToolHarvestAbility() { - @Override - public String getName() { - return "tool.ability.luck"; - } + @Override + public boolean isAllowed() { + return ToolConfig.abilityLuck; + } - @Override - public boolean isAllowed() { - return ToolConfig.abilityLuck; - } + public final int[] powerAtLevel = { 1, 2, 3, 4, 5, 9 }; - public final int[] powerAtLevel = {1, 2, 3, 4, 5, 9}; + @Override + public int levels() { + return powerAtLevel.length; + } - @Override - public int levels() { - return powerAtLevel.length; - } + @Override + public String getExtension(int level) { + return " (" + powerAtLevel[level] + ")"; + } - @Override - public String getExtension(int level) { - return " (" + powerAtLevel[level] + ")"; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 2; + } - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 2; - } + @Override + public void preHarvestAll(int level, World world, EntityPlayer player) { + ItemStack stack = player.getHeldItem(); + EnchantmentUtil.addEnchantment(stack, Enchantment.fortune, powerAtLevel[level]); + } - @Override - public void preHarvestAll(int level, World world, EntityPlayer player) { - ItemStack stack = player.getHeldItem(); - EnchantmentUtil.addEnchantment(stack, Enchantment.fortune, powerAtLevel[level]); - } + @Override + public void postHarvestAll(int level, World world, EntityPlayer player) { + // ToC-ToU mismatch should be impossible + // 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 void postHarvestAll(int level, World world, EntityPlayer player) { - // ToC-ToU mismatch should be impossible - // 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); - } - }; + public static final IToolHarvestAbility SMELTER = new IToolHarvestAbility() { + @Override + public String getName() { + return "tool.ability.smelter"; + } - public static final IToolHarvestAbility SMELTER = new IToolHarvestAbility() { - @Override - public String getName() { - return "tool.ability.smelter"; - } + @Override + public boolean isAllowed() { + return ToolConfig.abilityFurnace; + } - @Override - public boolean isAllowed() { - return ToolConfig.abilityFurnace; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 3; + } - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 3; - } + @Override + public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) { + List drops = block.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0); - @Override - public void onHarvestBlock(int level, World world, int x, int y, int z, EntityPlayer player, Block block, int meta) { - List 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); + boolean doesSmelt = false; - if(doesSmelt) { - for(ItemStack stack : drops) { - world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack.copy())); - } - } - } - }; + for(int i = 0; i < drops.size(); i++) { + ItemStack stack = drops.get(i).copy(); + ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(stack); - public static final IToolHarvestAbility SHREDDER = new IToolHarvestAbility() { - @Override - public String getName() { - return "tool.ability.shredder"; - } + if(result != null) { + result = result.copy(); + result.stackSize *= stack.stackSize; + drops.set(i, result); + doesSmelt = true; + } + } - @Override - public boolean isAllowed() { - return ToolConfig.abilityShredder; - } + harvestBlock(doesSmelt, world, x, y, z, player); - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 4; - } + if(doesSmelt) { + for(ItemStack stack : drops) { + world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack.copy())); + } + } + } + }; - @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; - - ItemStack stack = new ItemStack(block, 1, meta); - ItemStack result = ShredderRecipes.getShredderResult(stack); + public static final IToolHarvestAbility SHREDDER = new IToolHarvestAbility() { + @Override + public String getName() { + return "tool.ability.shredder"; + } - boolean doesShred = result != null && result.getItem() != ModItems.scrap; + @Override + public boolean isAllowed() { + return ToolConfig.abilityShredder; + } - harvestBlock(doesShred, world, x, y, z, player); - - if(doesShred) { - world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, result.copy())); - } - } - }; + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 4; + } - public static final IToolHarvestAbility CENTRIFUGE = new IToolHarvestAbility() { - @Override - public String getName() { - return "tool.ability.centrifuge"; - } + @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; - @Override - public boolean isAllowed() { - return ToolConfig.abilityCentrifuge; - } + ItemStack stack = new ItemStack(block, 1, meta); + ItemStack result = ShredderRecipes.getShredderResult(stack); - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 5; - } + boolean doesShred = result != null && result.getItem() != ModItems.scrap; - @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; - - ItemStack stack = new ItemStack(block, 1, meta); - ItemStack[] result = CentrifugeRecipes.getOutput(stack); + harvestBlock(doesShred, world, x, y, z, player); - boolean doesCentrifuge = result != null; - - 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())); - } - } - } - } - }; + if(doesShred) { + world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, result.copy())); + } + } + }; - public static final IToolHarvestAbility CRYSTALLIZER = new IToolHarvestAbility() { - @Override - public String getName() { - return "tool.ability.crystallizer"; - } + public static final IToolHarvestAbility CENTRIFUGE = new IToolHarvestAbility() { + @Override + public String getName() { + return "tool.ability.centrifuge"; + } - @Override - public boolean isAllowed() { - return ToolConfig.abilityCrystallizer; - } + @Override + public boolean isAllowed() { + return ToolConfig.abilityCentrifuge; + } - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 6; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 5; + } - @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; - - ItemStack stack = new ItemStack(block, 1, meta); - CrystallizerRecipe result = CrystallizerRecipes.getOutput(stack, Fluids.PEROXIDE); + @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; - 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"; - } + ItemStack stack = new ItemStack(block, 1, meta); + ItemStack[] result = CentrifugeRecipes.getOutput(stack); - @Override - public boolean isAllowed() { - return ToolConfig.abilityMercury; - } + boolean doesCentrifuge = result != null; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 7; - } + harvestBlock(doesCentrifuge, world, x, y, z, player); - @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(doesCentrifuge) { + for(ItemStack st : result) { + if(st != null) { + world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, st.copy())); + } + } + } + } + }; - 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 + public static final IToolHarvestAbility CRYSTALLIZER = new IToolHarvestAbility() { + @Override + public String getName() { + return "tool.ability.crystallizer"; + } - static final IToolHarvestAbility[] abilities = {NONE, SILK, LUCK, SMELTER, SHREDDER, CENTRIFUGE, CRYSTALLIZER, MERCURY}; + @Override + public boolean isAllowed() { + return ToolConfig.abilityCrystallizer; + } - static IToolHarvestAbility getByName(String name) { - for(IToolHarvestAbility ability : abilities) { - if(ability.getName().equals(name)) - return ability; - } - - return NONE; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 6; + } + + @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; + + 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; + } } diff --git a/src/main/java/com/hbm/handler/ability/IWeaponAbility.java b/src/main/java/com/hbm/handler/ability/IWeaponAbility.java index 9a874dbb1..f3571ab6a 100644 --- a/src/main/java/com/hbm/handler/ability/IWeaponAbility.java +++ b/src/main/java/com/hbm/handler/ability/IWeaponAbility.java @@ -4,7 +4,6 @@ import com.hbm.blocks.ModBlocks; import com.hbm.blocks.generic.BlockBobble.BobbleType; import com.hbm.handler.threading.PacketThreading; import com.hbm.items.ModItems; -import com.hbm.lib.ModDamageSource; import com.hbm.packet.toclient.AuxParticlePacketNT; import com.hbm.potion.HbmPotion; import com.hbm.util.ContaminationUtil; @@ -35,333 +34,337 @@ import net.minecraft.util.DamageSource; import net.minecraft.world.World; public interface IWeaponAbility extends IBaseAbility { - // Note: tool is currently unused in weapon abilities - public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool); - - public final static int SORT_ORDER_BASE = 200; + // Note: tool is currently unused in weapon abilities + public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool); - // region handlers - public static final IWeaponAbility NONE = new IWeaponAbility() { - @Override - public String getName() { - return ""; - } + public final static int SORT_ORDER_BASE = 200; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 0; - } + // region handlers + public static final IWeaponAbility NONE = new IWeaponAbility() { + @Override + public String getName() { + return ""; + } - @Override - public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) {} - }; + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 0; + } - public static final IWeaponAbility RADIATION = new IWeaponAbility() { - @Override - public String getName() { - return "weapon.ability.radiation"; - } + @Override + public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { + } + }; - public final float[] radAtLevel = {15F, 50F, 500F}; + public static final IWeaponAbility RADIATION = new IWeaponAbility() { + @Override + public String getName() { + return "weapon.ability.radiation"; + } - @Override - public int levels() { - return radAtLevel.length; - } + public final float[] radAtLevel = { 15F, 50F, 500F }; - @Override - public String getExtension(int level) { - return " (" + radAtLevel[level] + ")"; - } + @Override + public int levels() { + return radAtLevel.length; + } - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 1; - } + @Override + public String getExtension(int level) { + return " (" + radAtLevel[level] + ")"; + } - @Override - public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { - if(victim instanceof EntityLivingBase) - ContaminationUtil.contaminate((EntityLivingBase)victim, HazardType.RADIATION, ContaminationType.CREATIVE, radAtLevel[level]); - } - }; + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 1; + } - public static final IWeaponAbility VAMPIRE = new IWeaponAbility() { - @Override - public String getName() { - return "weapon.ability.vampire"; - } + @Override + public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { + if(victim instanceof EntityLivingBase) + 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 int levels() { - return amountAtLevel.length; - } + public final float[] amountAtLevel = { 2F, 3F, 5F, 10F, 50F }; - @Override - public String getExtension(int level) { - return " (" + amountAtLevel[level] + ")"; - } + @Override + public int levels() { + return amountAtLevel.length; + } - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 2; - } + @Override + public String getExtension(int level) { + return " (" + amountAtLevel[level] + ")"; + } - @Override - public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { - float amount = amountAtLevel[level]; - - 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 int sortOrder() { + return SORT_ORDER_BASE + 2; + } - public static final IWeaponAbility STUN = new IWeaponAbility() { - @Override - public String getName() { - return "weapon.ability.stun"; - } + @Override + public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { + float amount = amountAtLevel[level]; - 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 int levels() { - return durationAtLevel.length; - } + public static final IWeaponAbility STUN = new IWeaponAbility() { + @Override + public String getName() { + return "weapon.ability.stun"; + } - @Override - public String getExtension(int level) { - return " (" + durationAtLevel[level] + ")"; - } + public final int[] durationAtLevel = { 2, 3, 5, 10, 15 }; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 3; - } + @Override + public int levels() { + return durationAtLevel.length; + } - @Override - public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { - int duration = durationAtLevel[level]; - - if(victim instanceof EntityLivingBase) { - EntityLivingBase living = (EntityLivingBase) victim; + @Override + public String getExtension(int level) { + return " (" + durationAtLevel[level] + ")"; + } - living.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, duration * 20, 4)); - living.addPotionEffect(new PotionEffect(Potion.weakness.id, duration * 20, 4)); - } - } - }; + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 3; + } - public static final IWeaponAbility PHOSPHORUS = new IWeaponAbility() { - @Override - public String getName() { - return "weapon.ability.phosphorus"; - } + @Override + public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { + int duration = durationAtLevel[level]; - public final int[] durationAtLevel = {60, 90}; + if(victim instanceof EntityLivingBase) { + EntityLivingBase living = (EntityLivingBase) victim; - @Override - public int levels() { - return durationAtLevel.length; - } + living.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, duration * 20, 4)); + living.addPotionEffect(new PotionEffect(Potion.weakness.id, duration * 20, 4)); + } + } + }; - @Override - public String getExtension(int level) { - return " (" + durationAtLevel[level] + ")"; - } + public static final IWeaponAbility PHOSPHORUS = new IWeaponAbility() { + @Override + public String getName() { + return "weapon.ability.phosphorus"; + } - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 4; - } + public final int[] durationAtLevel = { 60, 90 }; - @Override - public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { - int duration = durationAtLevel[level]; - - if(victim instanceof EntityLivingBase) { - EntityLivingBase living = (EntityLivingBase) victim; + @Override + public int levels() { + return durationAtLevel.length; + } - 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 - public String getName() { - return "weapon.ability.fire"; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 4; + } - 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 - public int levels() { - return durationAtLevel.length; - } + if(victim instanceof EntityLivingBase) { + EntityLivingBase living = (EntityLivingBase) victim; - @Override - public String getExtension(int level) { - return " (" + durationAtLevel[level] + ")"; - } + living.addPotionEffect(new PotionEffect(HbmPotion.phosphorus.id, duration * 20, 4)); + } + } + }; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 6; - } + public static final IWeaponAbility FIRE = new IWeaponAbility() { + @Override + public String getName() { + return "weapon.ability.fire"; + } - @Override - public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { - if(victim instanceof EntityLivingBase) { - victim.setFire(durationAtLevel[level]); - } - } - }; + public final int[] durationAtLevel = { 5, 10 }; - public static final IWeaponAbility CHAINSAW = new IWeaponAbility() { - @Override - public String getName() { - return "weapon.ability.chainsaw"; - } + @Override + public int levels() { + return durationAtLevel.length; + } - public final int[] dividerAtLevel = {15, 10}; + @Override + public String getExtension(int level) { + return " (" + durationAtLevel[level] + ")"; + } - @Override - public int levels() { - return dividerAtLevel.length; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 6; + } - @Override - public String getExtension(int level) { - return " (1:" + dividerAtLevel[level] + ")"; - } + @Override + public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { + if(victim instanceof EntityLivingBase) { + victim.setFire(durationAtLevel[level]); + } + } + }; - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 7; - } + public static final IWeaponAbility CHAINSAW = new IWeaponAbility() { + @Override + public String getName() { + return "weapon.ability.chainsaw"; + } - @Override - public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { - int divider = dividerAtLevel[level]; + public final int[] dividerAtLevel = { 15, 10 }; - if(victim instanceof EntityLivingBase) { - EntityLivingBase living = (EntityLivingBase) victim; + @Override + public int levels() { + return dividerAtLevel.length; + } - if(living.getHealth() <= 0.0F) { - int count = Math.min((int)Math.ceil(living.getMaxHealth() / divider), 250); //safeguard to prevent funnies from bosses with obscene health + @Override + public String getExtension(int level) { + return " (1:" + dividerAtLevel[level] + ")"; + } - for(int i = 0; i < count; i++) { - living.entityDropItem(new ItemStack(ModItems.nitra_small), 1); - world.spawnEntityInWorld(new EntityXPOrb(world, living.posX, living.posY, living.posZ, 1)); - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 7; + } - if(player instanceof EntityPlayerMP) { - NBTTagCompound data = new NBTTagCompound(); - data.setString("type", "vanillaburst"); - 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)); - } + @Override + public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { + int divider = dividerAtLevel[level]; - 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() { - @Override - public String getName() { - return "weapon.ability.beheader"; - } + if(living.getHealth() <= 0.0F) { + int count = Math.min((int) Math.ceil(living.getMaxHealth() / divider), 250); // safeguard to prevent funnies from bosses with obscene health - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 8; - } + for(int i = 0; i < count; i++) { + living.entityDropItem(new ItemStack(ModItems.nitra_small), 1); + world.spawnEntityInWorld(new EntityXPOrb(world, living.posX, living.posY, living.posZ, 1)); + } - @Override - public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { - if(victim instanceof EntityLivingBase && ((EntityLivingBase) victim).getHealth() <= 0.0F) { - EntityLivingBase living = (EntityLivingBase) victim; + if(player instanceof EntityPlayerMP) { + NBTTagCompound data = new NBTTagCompound(); + data.setString("type", "vanillaburst"); + 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) { - 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); - } - } - } - }; + world.playSoundEffect(living.posX, living.posY + living.height * 0.5, living.posZ, "hbm:weapon.chainsaw", 0.5F, 1.0F); + } + } + } + }; - public static final IWeaponAbility BOBBLE = new IWeaponAbility() { - @Override - public String getName() { - return "weapon.ability.bobble"; - } + public static final IWeaponAbility BEHEADER = new IWeaponAbility() { + @Override + public String getName() { + return "weapon.ability.beheader"; + } - @Override - public int sortOrder() { - return SORT_ORDER_BASE + 9; - } + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 8; + } - @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; + @Override + public void onHit(int level, World world, EntityPlayer player, Entity victim, Item tool) { + if(victim instanceof EntityLivingBase && ((EntityLivingBase) victim).getHealth() <= 0.0F) { + 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) { - chance = 750; - } + public static final IWeaponAbility BOBBLE = new IWeaponAbility() { + @Override + public String getName() { + return "weapon.ability.bobble"; + } - 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 + @Override + public int sortOrder() { + return SORT_ORDER_BASE + 9; + } - 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) { - for(IWeaponAbility ability : abilities) { - if(ability.getName().equals(name)) - return ability; - } - - return NONE; - } + int chance = 1000; + + if(mob.getMaxHealth() > 20) { + chance = 750; + } + + 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; + } } diff --git a/src/main/java/com/hbm/handler/ability/ToolPreset.java b/src/main/java/com/hbm/handler/ability/ToolPreset.java index ce8f36dd5..e705b23a9 100644 --- a/src/main/java/com/hbm/handler/ability/ToolPreset.java +++ b/src/main/java/com/hbm/handler/ability/ToolPreset.java @@ -7,93 +7,94 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; public class ToolPreset { - public IToolAreaAbility areaAbility = IToolAreaAbility.NONE; - public int areaAbilityLevel = 0; - public IToolHarvestAbility harvestAbility = IToolHarvestAbility.NONE; - public int harvestAbilityLevel = 0; + public IToolAreaAbility areaAbility = IToolAreaAbility.NONE; + public int areaAbilityLevel = 0; + public IToolHarvestAbility harvestAbility = IToolHarvestAbility.NONE; + public int harvestAbilityLevel = 0; - public ToolPreset() {} + public ToolPreset() { + } - public ToolPreset(IToolAreaAbility areaAbility, IToolHarvestAbility harvestAbility) { - this.areaAbility = areaAbility; - this.harvestAbility = harvestAbility; - } + public ToolPreset(IToolAreaAbility areaAbility, IToolHarvestAbility harvestAbility) { + this.areaAbility = areaAbility; + this.harvestAbility = harvestAbility; + } - public ToolPreset(IToolAreaAbility areaAbility, int areaAbilityLevel, IToolHarvestAbility harvestAbility, int harvestAbilityLevel) { - this.areaAbility = areaAbility; - this.areaAbilityLevel = areaAbilityLevel; - this.harvestAbility = harvestAbility; - this.harvestAbilityLevel = harvestAbilityLevel; - } + public ToolPreset(IToolAreaAbility areaAbility, int areaAbilityLevel, IToolHarvestAbility harvestAbility, int harvestAbilityLevel) { + this.areaAbility = areaAbility; + this.areaAbilityLevel = areaAbilityLevel; + this.harvestAbility = harvestAbility; + this.harvestAbilityLevel = harvestAbilityLevel; + } - public ChatComponentText getMessage() { - if (isNone()) - 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 "); + public ChatComponentText getMessage() { + if(isNone()) + return ChatBuilder.start("[Tool ability deactivated]").color(EnumChatFormatting.GOLD).flush(); - if (!areaPart.isEmpty()) - builder.next(areaPart); + String areaPart = areaAbility.getFullName(areaAbilityLevel); + String harvestPart = harvestAbility.getFullName(harvestAbilityLevel); - if (!areaPart.isEmpty() && !harvestPart.isEmpty()) - builder.next(" + "); + ChatBuilder builder = ChatBuilder.start("[Enabled "); - if (!harvestPart.isEmpty()) - builder.next(harvestPart); - - return builder.colorAll(EnumChatFormatting.YELLOW).flush(); - } + if(!areaPart.isEmpty()) + builder.next(areaPart); - public boolean isNone() { - return areaAbility == IToolAreaAbility.NONE && harvestAbility == IToolHarvestAbility.NONE; - } + if(!areaPart.isEmpty() && !harvestPart.isEmpty()) + builder.next(" + "); - public void writeToNBT(NBTTagCompound nbt) { - nbt.setString("area", areaAbility.getName()); - nbt.setInteger("areaLevel", areaAbilityLevel); - nbt.setString("harvest", harvestAbility.getName()); - nbt.setInteger("harvestLevel", harvestAbilityLevel); - } + if(!harvestPart.isEmpty()) + builder.next(harvestPart); - public void readFromNBT(NBTTagCompound nbt) { - areaAbility = IToolAreaAbility.getByName(nbt.getString("area")); - areaAbilityLevel = nbt.getInteger("areaLevel"); - harvestAbility = IToolHarvestAbility.getByName(nbt.getString("harvest")); - harvestAbilityLevel = nbt.getInteger("harvestLevel"); + return builder.colorAll(EnumChatFormatting.YELLOW).flush(); + } - areaAbilityLevel = Math.min(areaAbilityLevel, areaAbility.levels() - 1); - harvestAbilityLevel = Math.min(harvestAbilityLevel, harvestAbility.levels() - 1); - } + public boolean isNone() { + return areaAbility == IToolAreaAbility.NONE && harvestAbility == IToolHarvestAbility.NONE; + } - public void restrictTo(AvailableAbilities availableAbilities) { - int maxAreaLevel = availableAbilities.maxLevel(areaAbility); + public void writeToNBT(NBTTagCompound nbt) { + nbt.setString("area", areaAbility.getName()); + nbt.setInteger("areaLevel", areaAbilityLevel); + nbt.setString("harvest", harvestAbility.getName()); + nbt.setInteger("harvestLevel", harvestAbilityLevel); + } - if (maxAreaLevel == -1) { - areaAbility = IToolAreaAbility.NONE; - areaAbilityLevel = 0; - } else if (areaAbilityLevel > maxAreaLevel) { - areaAbilityLevel = maxAreaLevel; - } else if (areaAbilityLevel < 0) { - areaAbilityLevel = 0; - } + public void readFromNBT(NBTTagCompound nbt) { + areaAbility = IToolAreaAbility.getByName(nbt.getString("area")); + areaAbilityLevel = nbt.getInteger("areaLevel"); + harvestAbility = IToolHarvestAbility.getByName(nbt.getString("harvest")); + harvestAbilityLevel = nbt.getInteger("harvestLevel"); - if (!areaAbility.allowsHarvest(areaAbilityLevel)) { - harvestAbility = IToolHarvestAbility.NONE; - harvestAbilityLevel = 0; - } + areaAbilityLevel = Math.min(areaAbilityLevel, areaAbility.levels() - 1); + harvestAbilityLevel = Math.min(harvestAbilityLevel, harvestAbility.levels() - 1); + } - int maxHarvestLevel = availableAbilities.maxLevel(harvestAbility); + public void restrictTo(AvailableAbilities availableAbilities) { + int maxAreaLevel = availableAbilities.maxLevel(areaAbility); - if (maxHarvestLevel == -1) { - harvestAbility = IToolHarvestAbility.NONE; - harvestAbilityLevel = 0; - } else if (harvestAbilityLevel > maxHarvestLevel) { - harvestAbilityLevel = maxHarvestLevel; - } else if (harvestAbilityLevel < 0) { - harvestAbilityLevel = 0; - } - } + if(maxAreaLevel == -1) { + areaAbility = IToolAreaAbility.NONE; + areaAbilityLevel = 0; + } else if(areaAbilityLevel > maxAreaLevel) { + areaAbilityLevel = maxAreaLevel; + } else if(areaAbilityLevel < 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; + } + } } diff --git a/src/main/java/com/hbm/handler/guncfg/BulletConfigFactory.java b/src/main/java/com/hbm/handler/guncfg/BulletConfigFactory.java index 2290cedcb..83332e52a 100644 --- a/src/main/java/com/hbm/handler/guncfg/BulletConfigFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/BulletConfigFactory.java @@ -4,26 +4,11 @@ import java.util.List; 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.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 cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; import net.minecraft.entity.Entity; 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; public class BulletConfigFactory { @@ -57,37 +42,6 @@ public class BulletConfigFactory { 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() { @@ -141,218 +95,6 @@ public class BulletConfigFactory { 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 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 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) { IBulletUpdateBehaviorNT onUpdate = new IBulletUpdateBehaviorNT() { diff --git a/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java b/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java deleted file mode 100644 index 13a68e433..000000000 --- a/src/main/java/com/hbm/handler/guncfg/GunCannonFactory.java +++ /dev/null @@ -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; - } - -} diff --git a/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java b/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java index 3d622c7f7..d0e8e6bd7 100644 --- a/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java +++ b/src/main/java/com/hbm/handler/guncfg/GunEnergyFactory.java @@ -1,317 +1,11 @@ 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.GunConfiguration; import com.hbm.inventory.RecipesCommon.ComparableStack; -import com.hbm.items.ItemAmmoEnums.AmmoFireExt; 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 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(); - 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() { BulletConfiguration bullet = new BulletConfiguration(); diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index ff7ea8338..b60160874 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -6,7 +6,6 @@ import com.hbm.handler.BucketHandler; import com.hbm.handler.ability.IToolAreaAbility; import com.hbm.handler.ability.IToolHarvestAbility; import com.hbm.handler.ability.IWeaponAbility; -import com.hbm.handler.guncfg.*; import com.hbm.interfaces.ICustomWarhead.SaltedFuel.HalfLifeType; import com.hbm.inventory.fluid.Fluids; 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 = 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); crucible = new ItemCrucible(5000, 1F, matCrucible).setUnlocalizedName("crucible").setCreativeTab(MainRegistry.weaponTab).setTextureName(RefStrings.MODID + ":crucible"); @@ -6374,7 +6372,6 @@ public class ModItems { //Guns GameRegistry.registerItem(gun_b92, gun_b92.getUnlocalizedName()); - GameRegistry.registerItem(gun_fireext, gun_fireext.getUnlocalizedName()); GameRegistry.registerItem(crucible, crucible.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_double_barrel, gun_double_barrel.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(ammo_standard, ammo_standard.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java index 58945b2cf..7a613fbb0 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/GunFactoryClient.java @@ -287,6 +287,7 @@ public class GunFactoryClient { ((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_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_light_revolver_dani) .getConfig(null, 0).hud(LegoClient.HUD_COMPONENT_DURABILITY_MIRROR, LegoClient.HUD_COMPONENT_AMMO_MIRROR); diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java index 8951e97d7..b8bbe7266 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/Orchestras.java @@ -1466,6 +1466,17 @@ public class Orchestras { } }; + public static BiConsumer 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 ORCHESTRA_CHARGE_THROWER = (stack, ctx) -> { EntityLivingBase entity = ctx.entity; if(entity.worldObj.isRemote) return; diff --git a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryTool.java b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryTool.java index f010af5a2..9f3179947 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryTool.java +++ b/src/main/java/com/hbm/items/weapon/sedna/factory/XFactoryTool.java @@ -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.impl.ItemGunChargeThrower; import com.hbm.items.weapon.sedna.mags.MagazineFullReload; +import com.hbm.main.MainRegistry; import com.hbm.particle.helper.ExplosionCreator; import com.hbm.render.anim.BusAnimation; import com.hbm.render.anim.BusAnimationSequence; import com.hbm.render.anim.BusAnimationKeyframe.IType; 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 net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; +import net.minecraftforge.common.util.ForgeDirection; 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_mortar; public static BulletConfig ct_mortar_charge; + + public static BiConsumer 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 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 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 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 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 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 LAMBDA_SET_HOOK = (entity) -> { EntityBulletBaseMK4 bullet = (EntityBulletBaseMK4) entity; @@ -88,6 +230,19 @@ public class XFactoryTool { 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) .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) @@ -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) .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() .dura(3_000).draw(10).inspect(55).reloadChangeType(true).hideCrosshair(false).crosshair(Crosshair.L_CIRCUMFLEX) .rec(new Receiver(0) diff --git a/src/main/java/com/hbm/main/ModEventHandlerClient.java b/src/main/java/com/hbm/main/ModEventHandlerClient.java index 4af2dd3c3..d01ac85f5 100644 --- a/src/main/java/com/hbm/main/ModEventHandlerClient.java +++ b/src/main/java/com/hbm/main/ModEventHandlerClient.java @@ -491,27 +491,6 @@ public class ModEventHandlerClient { EntityPlayer player = Minecraft.getMinecraft().thePlayer; 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; IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(held, IItemRenderer.ItemRenderType.EQUIPPED); diff --git a/src/main/java/com/hbm/render/item/weapon/ItemRenderFireExt.java b/src/main/java/com/hbm/render/item/weapon/ItemRenderFireExt.java index 012294910..62997552c 100644 --- a/src/main/java/com/hbm/render/item/weapon/ItemRenderFireExt.java +++ b/src/main/java/com/hbm/render/item/weapon/ItemRenderFireExt.java @@ -2,9 +2,9 @@ package com.hbm.render.item.weapon; import org.lwjgl.opengl.GL11; -import com.hbm.handler.BulletConfigSyncingUtil; -import com.hbm.items.ModItems; -import com.hbm.items.weapon.ItemGunBase; +import com.hbm.items.weapon.sedna.ItemGunBaseNT; +import com.hbm.items.weapon.sedna.factory.XFactoryTool; +import com.hbm.items.weapon.sedna.mags.IMagazine; import com.hbm.main.ResourceManager; import net.minecraft.client.Minecraft; @@ -41,15 +41,11 @@ public class ItemRenderFireExt implements IItemRenderer { GL11.glEnable(GL11.GL_CULL_FACE); - int magType = ItemGunBase.getMagType(item); - int config = ((ItemGunBase)ModItems.gun_fireext).mainConfig.config.get(magType); - int ammo = BulletConfigSyncingUtil.pullConfig(config).ammo.meta; - ResourceLocation tex; - switch (ammo) { - case 0: tex = ResourceManager.fireext_foam_tex; break; - case 1: tex = ResourceManager.fireext_sand_tex; break; - default: tex = ResourceManager.fireext_tex; break; - } + ItemGunBaseNT gun = (ItemGunBaseNT) item.getItem(); + IMagazine mag = gun.getConfig(item, 0).getReceivers(item)[0].getMagazine(item); + ResourceLocation tex = ResourceManager.fireext_tex; + if(mag.getType(item, null) == XFactoryTool.fext_foam) tex = ResourceManager.fireext_foam_tex; + if(mag.getType(item, null) == XFactoryTool.fext_sand) tex = ResourceManager.fireext_sand_tex; Minecraft.getMinecraft().renderEngine.bindTexture(tex); switch(type) { diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineArcWelder.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineArcWelder.java index aa9f9736f..9db6921c8 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineArcWelder.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineArcWelder.java @@ -99,7 +99,7 @@ public class TileEntityMachineArcWelder extends TileEntityMachineBase implements 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 *= Math.pow(2, blackLevel); - intendedMaxPower = recipe.consumption * 20; + intendedMaxPower = consumption * 20; if(canProcess(recipe)) { this.progress += (1 + blackLevel); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineSolderingStation.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineSolderingStation.java index 5515a816d..b8cfe0333 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineSolderingStation.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineSolderingStation.java @@ -105,7 +105,7 @@ public class TileEntityMachineSolderingStation extends TileEntityMachineBase imp 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 *= Math.pow(2, blackLevel); - intendedMaxPower = recipe.consumption * 20; + intendedMaxPower = consumption * 20; if(canProcess(recipe)) { this.progress += (1 + blackLevel); diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineStrandCaster.java b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineStrandCaster.java index 84c56ab7c..9ca467285 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityMachineStrandCaster.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityMachineStrandCaster.java @@ -11,7 +11,6 @@ import com.hbm.inventory.material.Mats; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemMold; import com.hbm.items.machine.ItemScraps; -import com.hbm.main.MainRegistry; import com.hbm.tileentity.IGUIProvider; import com.hbm.util.fauxpointtwelve.DirPos; import cpw.mods.fml.relauncher.Side;