Minor refactoring
This commit is contained in:
parent
23ae02af78
commit
7b67070c65
|
@ -3,7 +3,7 @@ package com.wayoftime.bloodmagic.api.impl;
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.wayoftime.bloodmagic.api.IBloodMagicAPI;
|
import com.wayoftime.bloodmagic.api.IBloodMagicAPI;
|
||||||
import com.wayoftime.bloodmagic.core.type.ComponentType;
|
import com.wayoftime.bloodmagic.core.altar.ComponentType;
|
||||||
import com.wayoftime.bloodmagic.core.util.BMLog;
|
import com.wayoftime.bloodmagic.core.util.BMLog;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import com.wayoftime.bloodmagic.api.IBloodMagicPlugin;
|
||||||
import com.wayoftime.bloodmagic.api.IBloodMagicRecipeRegistrar;
|
import com.wayoftime.bloodmagic.api.IBloodMagicRecipeRegistrar;
|
||||||
import com.wayoftime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
import com.wayoftime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||||
import com.wayoftime.bloodmagic.core.RegistrarBloodMagicRecipes;
|
import com.wayoftime.bloodmagic.core.RegistrarBloodMagicRecipes;
|
||||||
import com.wayoftime.bloodmagic.core.type.ComponentType;
|
import com.wayoftime.bloodmagic.core.altar.ComponentType;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.properties.IProperty;
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.block.state.BlockStateContainer;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.wayoftime.bloodmagic.block;
|
package com.wayoftime.bloodmagic.block;
|
||||||
|
|
||||||
import com.wayoftime.bloodmagic.core.type.BloodRunes;
|
import com.wayoftime.bloodmagic.core.altar.BloodRunes;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
|
||||||
public class BlockBloodRune extends BlockMundane {
|
public class BlockBloodRune extends BlockMundane {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.wayoftime.bloodmagic.block;
|
package com.wayoftime.bloodmagic.block;
|
||||||
|
|
||||||
import com.wayoftime.bloodmagic.BloodMagic;
|
import com.wayoftime.bloodmagic.BloodMagic;
|
||||||
import com.wayoftime.bloodmagic.core.type.DemonWillType;
|
import com.wayoftime.bloodmagic.core.will.DemonWill;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
|
@ -15,9 +15,9 @@ import java.util.List;
|
||||||
|
|
||||||
public class BlockDemonDecor extends BlockMundane {
|
public class BlockDemonDecor extends BlockMundane {
|
||||||
|
|
||||||
private final DemonWillType type;
|
private final DemonWill type;
|
||||||
|
|
||||||
public BlockDemonDecor(Material material, String decorType, DemonWillType type) {
|
public BlockDemonDecor(Material material, String decorType, DemonWill type) {
|
||||||
super(material, decorType + "_" + type.getName());
|
super(material, decorType + "_" + type.getName());
|
||||||
|
|
||||||
setTranslationKey(BloodMagic.MODID + ":" + decorType);
|
setTranslationKey(BloodMagic.MODID + ":" + decorType);
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.wayoftime.bloodmagic.block.BlockBloodAltar;
|
||||||
import com.wayoftime.bloodmagic.block.BlockBloodRune;
|
import com.wayoftime.bloodmagic.block.BlockBloodRune;
|
||||||
import com.wayoftime.bloodmagic.block.BlockMundane;
|
import com.wayoftime.bloodmagic.block.BlockMundane;
|
||||||
import com.wayoftime.bloodmagic.client.render.TESRBloodAltar;
|
import com.wayoftime.bloodmagic.client.render.TESRBloodAltar;
|
||||||
import com.wayoftime.bloodmagic.core.type.BloodRunes;
|
import com.wayoftime.bloodmagic.core.altar.BloodRunes;
|
||||||
import com.wayoftime.bloodmagic.tile.TileBloodAltar;
|
import com.wayoftime.bloodmagic.tile.TileBloodAltar;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.stream.Collectors;
|
||||||
/*
|
/*
|
||||||
* TODO - See checklist
|
* TODO - See checklist
|
||||||
* - [-] Upgrades (Names pulled from 2.0 class names)
|
* - [-] Upgrades (Names pulled from 2.0 class names)
|
||||||
* - [-] Arrow Protect
|
* - [x] Arrow Protect
|
||||||
* - [-] Arrow Shot
|
* - [-] Arrow Shot
|
||||||
* - [-] Critical Strike
|
* - [-] Critical Strike
|
||||||
* - [ ] Digging
|
* - [ ] Digging
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.wayoftime.bloodmagic.core.altar;
|
package com.wayoftime.bloodmagic.core.altar;
|
||||||
|
|
||||||
import com.wayoftime.bloodmagic.core.type.ComponentType;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public class AltarComponent {
|
public class AltarComponent {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import static com.wayoftime.bloodmagic.core.type.ComponentType.*;
|
import static com.wayoftime.bloodmagic.core.altar.ComponentType.*;
|
||||||
|
|
||||||
public enum AltarTier {
|
public enum AltarTier {
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package com.wayoftime.bloodmagic.core.altar;
|
package com.wayoftime.bloodmagic.core.altar;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.wayoftime.bloodmagic.core.type.BloodRunes;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.fluids.Fluid;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
|
||||||
import static com.wayoftime.bloodmagic.core.type.BloodRunes.*;
|
import static com.wayoftime.bloodmagic.core.altar.BloodRunes.*;
|
||||||
|
|
||||||
public class AltarUpgrades {
|
public class AltarUpgrades {
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||||
import com.wayoftime.bloodmagic.block.BlockBloodRune;
|
import com.wayoftime.bloodmagic.block.BlockBloodRune;
|
||||||
import com.wayoftime.bloodmagic.core.RegistrarBloodMagic;
|
import com.wayoftime.bloodmagic.core.RegistrarBloodMagic;
|
||||||
import com.wayoftime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
import com.wayoftime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||||
import com.wayoftime.bloodmagic.core.type.ComponentType;
|
|
||||||
import com.wayoftime.bloodmagic.core.util.BooleanResult;
|
import com.wayoftime.bloodmagic.core.util.BooleanResult;
|
||||||
import com.wayoftime.bloodmagic.event.SacrificeEvent;
|
import com.wayoftime.bloodmagic.event.SacrificeEvent;
|
||||||
import com.wayoftime.bloodmagic.tile.TileBloodAltar;
|
import com.wayoftime.bloodmagic.tile.TileBloodAltar;
|
||||||
|
@ -18,7 +17,6 @@ import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.wayoftime.bloodmagic.core.type;
|
package com.wayoftime.bloodmagic.core.altar;
|
||||||
|
|
||||||
import net.minecraft.util.IStringSerializable;
|
import net.minecraft.util.IStringSerializable;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.wayoftime.bloodmagic.core.type;
|
package com.wayoftime.bloodmagic.core.altar;
|
||||||
|
|
||||||
public enum ComponentType {
|
public enum ComponentType {
|
||||||
|
|
|
@ -5,8 +5,20 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows items to interact with the altar via right click without being inserted.
|
||||||
|
*/
|
||||||
public interface IAltarManipulator {
|
public interface IAltarManipulator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows an item to decide whether or not it should be inserted into the altar.
|
||||||
|
*
|
||||||
|
* @param player The player interacting with the altar
|
||||||
|
* @param stack The ItemStack being tested
|
||||||
|
* @param world The World the altar is in
|
||||||
|
* @param pos The position in the world of the altar
|
||||||
|
* @return false if the item should be inserted, true if not.
|
||||||
|
*/
|
||||||
default boolean tryManipulate(EntityPlayer player, ItemStack stack, World world, BlockPos pos) {
|
default boolean tryManipulate(EntityPlayer player, ItemStack stack, World world, BlockPos pos) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,18 +39,35 @@ public class LivingStatusWatcher {
|
||||||
if (!(event.getEntity() instanceof EntityPlayer))
|
if (!(event.getEntity() instanceof EntityPlayer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
handleFallDamage(event);
|
||||||
|
handleProjectileDamage(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void handleFallDamage(LivingHurtEvent event) {
|
||||||
if (event.getSource() != DamageSource.FALL)
|
if (event.getSource() != DamageSource.FALL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EntityPlayer player = (EntityPlayer) event.getEntity();
|
EntityPlayer player = (EntityPlayer) event.getEntity();
|
||||||
LivingStats stats = LivingUtil.applyNewExperience(player, RegistrarBloodMagicLivingArmor.UPGRADE_JUMP, 1);
|
LivingStats stats = LivingStats.fromPlayer(player);
|
||||||
if (stats == null)
|
if (stats == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int level = stats.getLevel(RegistrarBloodMagicLivingArmor.UPGRADE_JUMP.getKey());
|
int level = stats.getLevel(RegistrarBloodMagicLivingArmor.UPGRADE_JUMP.getKey());
|
||||||
double fallBonus = RegistrarBloodMagicLivingArmor.UPGRADE_JUMP.getBonusValue("fall", level).doubleValue();
|
double fallBonus = RegistrarBloodMagicLivingArmor.UPGRADE_JUMP.getBonusValue("fall", level).doubleValue();
|
||||||
float oldAmount = event.getAmount();
|
event.setAmount(event.getAmount() * Math.max(1F - (float) fallBonus, 0F));
|
||||||
float newAmount = oldAmount * Math.max(1F - (float) fallBonus, 0F);
|
}
|
||||||
event.setAmount(newAmount);
|
|
||||||
|
private static void handleProjectileDamage(LivingHurtEvent event) {
|
||||||
|
if (!event.getSource().isProjectile())
|
||||||
|
return;
|
||||||
|
|
||||||
|
EntityPlayer player = (EntityPlayer) event.getEntity();
|
||||||
|
LivingStats stats = LivingUtil.applyNewExperience(player, RegistrarBloodMagicLivingArmor.UPGRADE_ARROW_PROTECT, 1);
|
||||||
|
if (stats == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int level = stats.getLevel(RegistrarBloodMagicLivingArmor.UPGRADE_ARROW_PROTECT.getKey());
|
||||||
|
double damageBonus = RegistrarBloodMagicLivingArmor.UPGRADE_ARROW_PROTECT.getBonusValue("arrow_protect", level).doubleValue();
|
||||||
|
event.setAmount(event.getAmount() * Math.max(1F - (float) damageBonus, 0F));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class LivingUpgrade {
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IArmorProvider {
|
public interface IArmorProvider {
|
||||||
double getProtection(EntityPlayer player, DamageSource source, int level);
|
double getProtection(EntityPlayer player, LivingStats stats, DamageSource source, int level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Level {
|
public static class Level {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.wayoftime.bloodmagic.core.living;
|
package com.wayoftime.bloodmagic.core.living;
|
||||||
|
|
||||||
|
import com.wayoftime.bloodmagic.event.LivingEquipmentEvent;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.text.TextComponentTranslation;
|
import net.minecraft.util.text.TextComponentTranslation;
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class Binding implements INBTSerializable<NBTTagCompound> {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
NBTBase bindingTag = stack.getTagCompound().getTag("binding");
|
NBTBase bindingTag = stack.getTagCompound().getTag("binding");
|
||||||
if (bindingTag == null || bindingTag.getId() != 10 || bindingTag.isEmpty()) // Make sure it's both a tag compound and that it has actual data.
|
if (bindingTag.getId() != 10 || bindingTag.isEmpty()) // Make sure it's both a tag compound and that it has actual data.
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Binding binding = new Binding();
|
Binding binding = new Binding();
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
package com.wayoftime.bloodmagic.core.handler;
|
package com.wayoftime.bloodmagic.core.network;
|
||||||
|
|
||||||
import com.wayoftime.bloodmagic.BloodMagic;
|
import com.wayoftime.bloodmagic.BloodMagic;
|
||||||
import com.wayoftime.bloodmagic.core.network.Binding;
|
|
||||||
import com.wayoftime.bloodmagic.core.network.BloodOrb;
|
|
||||||
import com.wayoftime.bloodmagic.core.network.IBloodOrb;
|
|
||||||
import com.wayoftime.bloodmagic.core.network.SoulNetwork;
|
|
||||||
import com.wayoftime.bloodmagic.event.BindingEvent;
|
import com.wayoftime.bloodmagic.event.BindingEvent;
|
||||||
import com.wayoftime.bloodmagic.item.IBindable;
|
import com.wayoftime.bloodmagic.item.IBindable;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -16,7 +12,7 @@ import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID)
|
@Mod.EventBusSubscriber(modid = BloodMagic.MODID)
|
||||||
public class GenericEventHandler {
|
public class SoulNetworkEventHandler {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onItemUse(PlayerInteractEvent.RightClickItem event) {
|
public static void onItemUse(PlayerInteractEvent.RightClickItem event) {
|
|
@ -1,5 +1,7 @@
|
||||||
package com.wayoftime.bloodmagic.core.living;
|
package com.wayoftime.bloodmagic.event;
|
||||||
|
|
||||||
|
import com.wayoftime.bloodmagic.core.living.LivingStats;
|
||||||
|
import com.wayoftime.bloodmagic.core.living.LivingUpgrade;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
|
@ -35,6 +35,7 @@ import java.util.Map;
|
||||||
public class ItemLivingArmor extends ItemArmor implements ILivingContainer, ISpecialArmor, IBindable {
|
public class ItemLivingArmor extends ItemArmor implements ILivingContainer, ISpecialArmor, IBindable {
|
||||||
|
|
||||||
public static final ArmorMaterial MATERIAL = EnumHelper.addArmorMaterial("living", "living", 100, new int[]{1, 2, 3, 4}, 3, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 2.0F);
|
public static final ArmorMaterial MATERIAL = EnumHelper.addArmorMaterial("living", "living", 100, new int[]{1, 2, 3, 4}, 3, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 2.0F);
|
||||||
|
private static final int MAX_ABSORPTION = 100000;
|
||||||
|
|
||||||
public ItemLivingArmor(EntityEquipmentSlot slot) {
|
public ItemLivingArmor(EntityEquipmentSlot slot) {
|
||||||
super(MATERIAL, 0, slot);
|
super(MATERIAL, 0, slot);
|
||||||
|
@ -78,7 +79,6 @@ public class ItemLivingArmor extends ItemArmor implements ILivingContainer, ISpe
|
||||||
double armorReduction;
|
double armorReduction;
|
||||||
double damageAmount = 0.25;
|
double damageAmount = 0.25;
|
||||||
double armorPenetrationReduction = 0;
|
double armorPenetrationReduction = 0;
|
||||||
int maxAbsorption = 100000;
|
|
||||||
|
|
||||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOR_FEET || armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOR_HEAD)
|
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOR_FEET || armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOR_HEAD)
|
||||||
damageAmount = 3d / 20d * 0.6;
|
damageAmount = 3d / 20d * 0.6;
|
||||||
|
@ -91,22 +91,22 @@ public class ItemLivingArmor extends ItemArmor implements ILivingContainer, ISpe
|
||||||
armorReduction = 0.24 / 0.64; // This values puts it at iron level
|
armorReduction = 0.24 / 0.64; // This values puts it at iron level
|
||||||
|
|
||||||
if (!LivingUtil.hasFullSet((EntityPlayer) player))
|
if (!LivingUtil.hasFullSet((EntityPlayer) player))
|
||||||
return new ArmorProperties(-1, damageAmount * armorReduction, maxAbsorption);
|
return new ArmorProperties(-1, damageAmount * armorReduction, MAX_ABSORPTION);
|
||||||
|
|
||||||
LivingStats stats = getLivingStats(armor);
|
LivingStats stats = getLivingStats(armor);
|
||||||
double protection = 1.0D;
|
double protection = 1.0D;
|
||||||
if (stats != null)
|
if (stats != null)
|
||||||
for (Map.Entry<LivingUpgrade, Integer> entry : stats.getUpgrades().entrySet())
|
for (Map.Entry<LivingUpgrade, Integer> entry : stats.getUpgrades().entrySet())
|
||||||
if (entry.getKey().getArmorProvider() != null)
|
if (entry.getKey().getArmorProvider() != null)
|
||||||
protection *= 1 - entry.getKey().getArmorProvider().getProtection((EntityPlayer) player, source, entry.getKey().getLevel(entry.getValue()));
|
protection *= 1 - entry.getKey().getArmorProvider().getProtection((EntityPlayer) player, stats, source, entry.getKey().getLevel(entry.getValue()));
|
||||||
|
|
||||||
armorReduction += (1 - protection) * (1 - armorReduction);
|
armorReduction += (1 - protection) * (1 - armorReduction);
|
||||||
damageAmount *= armorReduction;
|
damageAmount *= armorReduction;
|
||||||
return new ArmorProperties(-1, source.isUnblockable() ? 1 - protection : damageAmount, maxAbsorption);
|
return new ArmorProperties(-1, source.isUnblockable() ? 1 - protection : damageAmount, MAX_ABSORPTION);
|
||||||
} else if (source.isUnblockable())
|
} else if (source.isUnblockable())
|
||||||
return new ArmorProperties(-1, damageAmount * armorPenetrationReduction, maxAbsorption);
|
return new ArmorProperties(-1, damageAmount * armorPenetrationReduction, MAX_ABSORPTION);
|
||||||
|
|
||||||
return new ArmorProperties(-1, damageAmount, maxAbsorption);
|
return new ArmorProperties(-1, damageAmount, MAX_ABSORPTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue