Altar works
This commit is contained in:
parent
352c6b9e5f
commit
a6d329cf98
|
@ -1,7 +1,7 @@
|
||||||
package WayofTime.bloodmagic;
|
package WayofTime.bloodmagic;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.util.helper.LogHelper;
|
import WayofTime.bloodmagic.api.util.helper.LogHelper;
|
||||||
import WayofTime.bloodmagic.network.AlchemicalWizardryPacketHandler;
|
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||||
import WayofTime.bloodmagic.proxy.CommonProxy;
|
import WayofTime.bloodmagic.proxy.CommonProxy;
|
||||||
import WayofTime.bloodmagic.registry.*;
|
import WayofTime.bloodmagic.registry.*;
|
||||||
import WayofTime.bloodmagic.util.handler.EventHandler;
|
import WayofTime.bloodmagic.util.handler.EventHandler;
|
||||||
|
@ -66,7 +66,7 @@ public class BloodMagic {
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Mod.EventHandler
|
||||||
public void init(FMLInitializationEvent event) {
|
public void init(FMLInitializationEvent event) {
|
||||||
AlchemicalWizardryPacketHandler.init();
|
BloodMagicPacketHandler.init();
|
||||||
|
|
||||||
ModRecipes.init();
|
ModRecipes.init();
|
||||||
ModRituals.initRituals();
|
ModRituals.initRituals();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import WayofTime.bloodmagic.api.altar.*;
|
||||||
import WayofTime.bloodmagic.block.BlockBloodRune;
|
import WayofTime.bloodmagic.block.BlockBloodRune;
|
||||||
import WayofTime.bloodmagic.block.BlockBloodStoneBrick;
|
import WayofTime.bloodmagic.block.BlockBloodStoneBrick;
|
||||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||||
|
import net.minecraft.block.BlockAir;
|
||||||
import net.minecraft.block.BlockBeacon;
|
import net.minecraft.block.BlockBeacon;
|
||||||
import net.minecraft.block.BlockGlowstone;
|
import net.minecraft.block.BlockGlowstone;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
@ -15,8 +16,17 @@ import java.util.List;
|
||||||
|
|
||||||
public class BloodAltar {
|
public class BloodAltar {
|
||||||
|
|
||||||
|
static {
|
||||||
|
EnumAltarTier.ONE.buildComponents();
|
||||||
|
EnumAltarTier.TWO.buildComponents();
|
||||||
|
EnumAltarTier.THREE.buildComponents();
|
||||||
|
EnumAltarTier.FOUR.buildComponents();
|
||||||
|
EnumAltarTier.FIVE.buildComponents();
|
||||||
|
EnumAltarTier.SIX.buildComponents();
|
||||||
|
}
|
||||||
|
|
||||||
public static EnumAltarTier getAltarTier(World world, BlockPos pos) {
|
public static EnumAltarTier getAltarTier(World world, BlockPos pos) {
|
||||||
for (int i = EnumAltarTier.MAXTIERS - 1; i >= 2; i--) {
|
for (int i = EnumAltarTier.MAXTIERS - 1; i >= 1; i--) {
|
||||||
if (checkAltarIsValid(world, pos, i)) {
|
if (checkAltarIsValid(world, pos, i)) {
|
||||||
return EnumAltarTier.values()[i];
|
return EnumAltarTier.values()[i];
|
||||||
}
|
}
|
||||||
|
@ -26,6 +36,7 @@ public class BloodAltar {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier) {
|
public static boolean checkAltarIsValid(World world, BlockPos worldPos, int altarTier) {
|
||||||
|
|
||||||
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) {
|
for (AltarComponent altarComponent : EnumAltarTier.values()[altarTier].getAltarComponents()) {
|
||||||
|
|
||||||
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
BlockPos componentPos = worldPos.add(altarComponent.getOffset());
|
||||||
|
@ -35,8 +46,9 @@ public class BloodAltar {
|
||||||
if (!checkRune(altarComponent, worldBlock)) {
|
if (!checkRune(altarComponent, worldBlock)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!altarComponent.isBloodRune()) {
|
||||||
if (((altarComponent.getBlockStack().getBlock() != worldBlock.getBlock()) || (altarComponent.getBlockStack().getMeta() != worldBlock.getMeta())) && (altarComponent.getBlockStack().getBlock() == Blocks.air && !world.isAirBlock(componentPos))) {
|
if (world.isAirBlock(componentPos)) return false;
|
||||||
|
if (((altarComponent.getBlockStack().getBlock() != worldBlock.getBlock()) || (altarComponent.getBlockStack().getMeta() != worldBlock.getMeta()))) {
|
||||||
if (!checkSpecials(altarComponent, worldBlock)) {
|
if (!checkSpecials(altarComponent, worldBlock)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +56,7 @@ public class BloodAltar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier) {
|
public static AltarUpgrade getUpgrades(World world, BlockPos pos, EnumAltarTier altarTier) {
|
||||||
|
@ -111,7 +123,6 @@ public class BloodAltar {
|
||||||
if (blockStack.getBlock() instanceof BlockBloodRune || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.BLOODRUNE))) {
|
if (blockStack.getBlock() instanceof BlockBloodRune || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.BLOODRUNE))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -119,11 +130,11 @@ public class BloodAltar {
|
||||||
private static boolean checkSpecials(AltarComponent altarComponent, BlockStack blockStack) {
|
private static boolean checkSpecials(AltarComponent altarComponent, BlockStack blockStack) {
|
||||||
if (altarComponent.getBlockStack().getBlock() == ModBlocks.bloodStoneBrick)
|
if (altarComponent.getBlockStack().getBlock() == ModBlocks.bloodStoneBrick)
|
||||||
if (blockStack.getBlock() instanceof BlockBloodStoneBrick || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.BLOODSTONE)))
|
if (blockStack.getBlock() instanceof BlockBloodStoneBrick || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.BLOODSTONE)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (altarComponent.getBlockStack().getBlock() == ModBlocks.crystal)
|
// if (altarComponent.getBlockStack().getBlock() == ModBlocks.crystal)
|
||||||
// if (blockStack.getBlock() instanceof BlockCrystal || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.CRYSTAL)))
|
// if (blockStack.getBlock() instanceof BlockCrystal || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.CRYSTAL)))
|
||||||
return true;
|
// return true;
|
||||||
|
|
||||||
if (altarComponent.getBlockStack().getBlock() == Blocks.glowstone)
|
if (altarComponent.getBlockStack().getBlock() == Blocks.glowstone)
|
||||||
if (blockStack.getBlock() instanceof BlockGlowstone || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.GLOWSTONE)))
|
if (blockStack.getBlock() instanceof BlockGlowstone || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.GLOWSTONE)))
|
||||||
|
@ -133,6 +144,10 @@ public class BloodAltar {
|
||||||
if (blockStack.getBlock() instanceof BlockBeacon || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.BEACON)))
|
if (blockStack.getBlock() instanceof BlockBeacon || (blockStack.getBlock() instanceof IAltarComponent && (((IAltarComponent) blockStack.getBlock()).getType(blockStack.getMeta()) == EnumAltarComponent.BEACON)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (altarComponent.getBlockStack().getBlock() == Blocks.air)
|
||||||
|
if (blockStack.getBlock() != Blocks.air)
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,10 +20,34 @@ public class NBTHolder {
|
||||||
public static final String NBT_RUNTIME = "runtime";
|
public static final String NBT_RUNTIME = "runtime";
|
||||||
public static final String NBT_REAGENTTANK = "reagentTanks";
|
public static final String NBT_REAGENTTANK = "reagentTanks";
|
||||||
public static final String NBT_CURRENT_INCENSE = "BM:CurrentIncense";
|
public static final String NBT_CURRENT_INCENSE = "BM:CurrentIncense";
|
||||||
|
public static final String NBT_EMPTY = "Empty";
|
||||||
|
public static final String NBT_OUTPUT_AMOUNT = "outputAmount";
|
||||||
|
public static final String NBT_INPUT_AMOUNT = "inputAmount";
|
||||||
|
|
||||||
|
//Altar Shtuff
|
||||||
public static final String NBT_ALTAR_TIER = "upgradeLevel";
|
public static final String NBT_ALTAR_TIER = "upgradeLevel";
|
||||||
public static final String NBT_ALTAR_ACTIVE = "isActive";
|
public static final String NBT_ALTAR_ACTIVE = "isActive";
|
||||||
public static final String NBT_ALTAR_LIQUID_REQ = "liquidRequired";
|
public static final String NBT_ALTAR_LIQUID_REQ = "liquidRequired";
|
||||||
public static final String NBT_ALTAR_FILLABLE = "canBeFilled";
|
public static final String NBT_ALTAR_FILLABLE = "canBeFilled";
|
||||||
|
public static final String NBT_ALTAR_UPGRADED = "isUpgraded";
|
||||||
|
public static final String NBT_ALTAR_CONSUMPTION_RATE = "consumptionRate";
|
||||||
|
public static final String NBT_ALTAR_DRAIN_RATE = "drainRate";
|
||||||
|
public static final String NBT_ALTAR_CONSUMPTION_MULTIPLIER = "consumptionMultiplier";
|
||||||
|
public static final String NBT_ALTAR_EFFICIENCY_MULTIPLIER = "efficiencyMultiplier";
|
||||||
|
public static final String NBT_ALTAR_SELF_SACRIFICE_MULTIPLIER = "selfSacrificeMultiplier";
|
||||||
|
public static final String NBT_ALTAR_SACRIFICE_MULTIPLIER = "sacrificeMultiplier";
|
||||||
|
public static final String NBT_ALTAR_CAPACITY_MULTIPLIER = "capacityMultiplier";
|
||||||
|
public static final String NBT_ALTAR_ORB_CAPACITY_MULTIPLIER = "orbCapacityMultiplier";
|
||||||
|
public static final String NBT_ALTAR_DISLOCATION_MULTIPLIER = "dislocationMultiplier";
|
||||||
|
public static final String NBT_ALTAR_CAPACITY = "capacity";
|
||||||
|
public static final String NBT_ALTAR_BUFFER_CAPACITY = "bufferCapacity";
|
||||||
|
public static final String NBT_ALTAR_PROGRESS = "progress";
|
||||||
|
public static final String NBT_ALTAR_IS_RESULT_BLOCK = "isResultBlock";
|
||||||
|
public static final String NBT_ALTAR_LOCKDOWN_DURATION = "lockdownDuration";
|
||||||
|
public static final String NBT_ALTAR_ACCELERATION_UPGRADES = "accelerationUpgrades";
|
||||||
|
public static final String NBT_ALTAR_DEMON_BLOOD_DURATION = "demonBloodDuration";
|
||||||
|
public static final String NBT_ALTAR_COOLDOWN_AFTER_CRAFTING = "cooldownAfterCrafting";
|
||||||
|
|
||||||
public static final String NBT_STORED_LP = "storedLP";
|
public static final String NBT_STORED_LP = "storedLP";
|
||||||
|
|
||||||
public static ItemStack checkNBT(ItemStack stack) {
|
public static ItemStack checkNBT(ItemStack stack) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package WayofTime.bloodmagic.api.altar;
|
package WayofTime.bloodmagic.api.altar;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ public class AltarRecipe {
|
||||||
|
|
||||||
public final int syphon, consumeRate, drainRate;
|
public final int syphon, consumeRate, drainRate;
|
||||||
public final boolean useTag;
|
public final boolean useTag;
|
||||||
public final ItemStackWrapper input, output;
|
public final ItemStack input, output;
|
||||||
public final EnumAltarTier minTier;
|
public final EnumAltarTier minTier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,26 @@ public class AltarRecipe {
|
||||||
* @param drainRate - The rate at which LP is drained during crafting
|
* @param drainRate - The rate at which LP is drained during crafting
|
||||||
* @param useTag -
|
* @param useTag -
|
||||||
*/
|
*/
|
||||||
public AltarRecipe(ItemStackWrapper input, @Nullable ItemStackWrapper output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) {
|
// public AltarRecipe(ItemStackWrapper input, @Nullable ItemStackWrapper output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) {
|
||||||
|
// this.input = input;
|
||||||
|
// this.output = output;
|
||||||
|
// this.minTier = minTier;
|
||||||
|
// this.syphon = syphon;
|
||||||
|
// this.consumeRate = consumeRate;
|
||||||
|
// this.drainRate = drainRate;
|
||||||
|
// this.useTag = useTag;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public AltarRecipe(ItemStackWrapper input, ItemStackWrapper output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||||
|
// this(input, output, minTier, syphon, consumeRate, drainRate, false);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public AltarRecipe(ItemStackWrapper input, EnumAltarTier minTier, int consumeRate, int drainRate) {
|
||||||
|
// this(input, null, minTier, 0, consumeRate, drainRate);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.output = output;
|
this.output = output;
|
||||||
this.minTier = minTier;
|
this.minTier = minTier;
|
||||||
|
@ -37,11 +56,11 @@ public class AltarRecipe {
|
||||||
this.useTag = useTag;
|
this.useTag = useTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarRecipe(ItemStackWrapper input, ItemStackWrapper output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
public AltarRecipe(ItemStack input, ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate) {
|
||||||
this(input, output, minTier, syphon, consumeRate, drainRate, false);
|
this(input, output, minTier, syphon, consumeRate, drainRate, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AltarRecipe (ItemStackWrapper input, EnumAltarTier minTier, int consumeRate, int drainRate) {
|
public AltarRecipe(ItemStack input, EnumAltarTier minTier, int consumeRate, int drainRate) {
|
||||||
this(input, null, minTier, 0, consumeRate, drainRate);
|
this(input, null, minTier, 0, consumeRate, drainRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package WayofTime.bloodmagic.api.registry;
|
package WayofTime.bloodmagic.api.registry;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
|
||||||
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class AltarRecipeRegistry {
|
public class AltarRecipeRegistry {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static BiMap<ItemStackWrapper, AltarRecipe> recipes = HashBiMap.create();
|
private static BiMap<ItemStack, AltarRecipe> recipes = HashBiMap.create();
|
||||||
|
|
||||||
public static void registerRecipe(AltarRecipe recipe) {
|
public static void registerRecipe(AltarRecipe recipe) {
|
||||||
if (!recipes.containsValue(recipe))
|
if (!recipes.containsValue(recipe))
|
||||||
|
@ -19,7 +19,7 @@ public class AltarRecipeRegistry {
|
||||||
BloodMagicAPI.getLogger().error("Error adding recipe for " + recipe.input.getDisplayName() + (recipe.output == null ? "" : " -> " + recipe.output.getDisplayName()) + ". Recipe already exists.");
|
BloodMagicAPI.getLogger().error("Error adding recipe for " + recipe.input.getDisplayName() + (recipe.output == null ? "" : " -> " + recipe.output.getDisplayName()) + ". Recipe already exists.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AltarRecipe getRecipeForInput(ItemStackWrapper input) {
|
public static AltarRecipe getRecipeForInput(ItemStack input) {
|
||||||
return recipes.get(input);
|
return recipes.get(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,10 @@ public class BlockAltar extends BlockContainer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.insertItemToTile(altar, player);
|
if (Utils.insertItemToTile(altar, player))
|
||||||
|
altar.startCycle();
|
||||||
|
else
|
||||||
|
altar.setActive();
|
||||||
|
|
||||||
world.markBlockForUpdate(pos);
|
world.markBlockForUpdate(pos);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
|
||||||
public class AlchemicalWizardryPacketHandler {
|
public class BloodMagicPacketHandler {
|
||||||
|
|
||||||
public static final SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(BloodMagic.MODID);
|
public static final SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(BloodMagic.MODID);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package WayofTime.bloodmagic.registry;
|
package WayofTime.bloodmagic.registry;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
|
||||||
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
||||||
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
||||||
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class ModRecipes {
|
public class ModRecipes {
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
@ -12,7 +12,8 @@ public class ModRecipes {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addAltarRecipes() {
|
public static void addAltarRecipes() {
|
||||||
AltarRecipeRegistry.registerRecipe(new AltarRecipe(new ItemStackWrapper(ModItems.bloodOrb, 0), new ItemStackWrapper(Items.diamond), EnumAltarTier.ONE, 2000, 2, 1, false));
|
// AltarRecipeRegistry.registerRecipe(new AltarRecipe(new ItemStackWrapper(Items.diamond), new ItemStackWrapper(ModItems.bloodOrb, 0), EnumAltarTier.ONE, 2000, 2, 1, false));
|
||||||
|
AltarRecipeRegistry.registerRecipe(new AltarRecipe(new ItemStack(Items.diamond), new ItemStack(ModItems.bloodOrb, 0), EnumAltarTier.ONE, 2000, 2, 1, false));
|
||||||
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 1), new ItemStack(Items.emerald), 2, 5000, 5, 5, false);
|
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 1), new ItemStack(Items.emerald), 2, 5000, 5, 5, false);
|
||||||
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 2), new ItemStack(Blocks.gold_block), 3, 25000, 20, 20, false);
|
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 2), new ItemStack(Blocks.gold_block), 3, 25000, 20, 20, false);
|
||||||
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 3), new ItemStack(ModItems.weakBloodShard), 4, 40000, 30, 50, false);
|
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 3), new ItemStack(ModItems.weakBloodShard), 4, 40000, 30, 50, false);
|
||||||
|
|
|
@ -2,7 +2,6 @@ package WayofTime.bloodmagic.tile;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.altar.BloodAltar;
|
import WayofTime.bloodmagic.altar.BloodAltar;
|
||||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
|
||||||
import WayofTime.bloodmagic.api.NBTHolder;
|
import WayofTime.bloodmagic.api.NBTHolder;
|
||||||
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
||||||
import WayofTime.bloodmagic.api.altar.AltarUpgrade;
|
import WayofTime.bloodmagic.api.altar.AltarUpgrade;
|
||||||
|
@ -13,10 +12,13 @@ import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||||
import WayofTime.bloodmagic.block.BlockLifeEssence;
|
import WayofTime.bloodmagic.block.BlockLifeEssence;
|
||||||
import com.google.common.base.Enums;
|
import com.google.common.base.Enums;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
import net.minecraftforge.fluids.*;
|
import net.minecraftforge.fluids.*;
|
||||||
|
|
||||||
public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlayerListBox, IFluidTank, IFluidHandler {
|
public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlayerListBox, IFluidTank, IFluidHandler {
|
||||||
|
@ -46,34 +48,33 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
private int bufferCapacity = FluidContainerRegistry.BUCKET_VOLUME;
|
private int bufferCapacity = FluidContainerRegistry.BUCKET_VOLUME;
|
||||||
private int progress;
|
private int progress;
|
||||||
|
|
||||||
public boolean isActive;
|
public boolean isActive = false;
|
||||||
|
|
||||||
private int lockdownDuration;
|
private int lockdownDuration;
|
||||||
private int demonBloodDuration;
|
private int demonBloodDuration;
|
||||||
|
|
||||||
private int cooldownAfterCrafting = 500;
|
private int cooldownAfterCrafting = 500;
|
||||||
|
|
||||||
|
private ItemStack result;
|
||||||
|
|
||||||
public TileAltar() {
|
public TileAltar() {
|
||||||
super(1, "altar");
|
super(1, "altar");
|
||||||
|
|
||||||
this.capacity = FluidContainerRegistry.BUCKET_VOLUME * 10;
|
|
||||||
this.bufferCapacity = FluidContainerRegistry.BUCKET_VOLUME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||||
super.readFromNBT(tagCompound);
|
super.readFromNBT(tagCompound);
|
||||||
|
|
||||||
if (!tagCompound.hasKey("Empty")) {
|
if (!tagCompound.hasKey(NBTHolder.NBT_EMPTY)) {
|
||||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound);
|
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound);
|
||||||
|
|
||||||
if (fluid != null)
|
if (fluid != null)
|
||||||
setMainFluid(fluid);
|
setMainFluid(fluid);
|
||||||
|
|
||||||
FluidStack fluidOut = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger("outputAmount"));
|
FluidStack fluidOut = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger(NBTHolder.NBT_OUTPUT_AMOUNT));
|
||||||
setOutputFluid(fluidOut);
|
setOutputFluid(fluidOut);
|
||||||
|
|
||||||
FluidStack fluidIn = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger("inputAmount"));
|
FluidStack fluidIn = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger(NBTHolder.NBT_INPUT_AMOUNT));
|
||||||
setInputFluid(fluidIn);
|
setInputFluid(fluidIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,24 +82,24 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
isActive = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_ACTIVE);
|
isActive = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_ACTIVE);
|
||||||
liquidRequired = tagCompound.getInteger(NBTHolder.NBT_ALTAR_LIQUID_REQ);
|
liquidRequired = tagCompound.getInteger(NBTHolder.NBT_ALTAR_LIQUID_REQ);
|
||||||
canBeFilled = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_FILLABLE);
|
canBeFilled = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_FILLABLE);
|
||||||
isUpgraded = tagCompound.getBoolean("isUpgraded");
|
isUpgraded = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_UPGRADED);
|
||||||
consumptionRate = tagCompound.getInteger("consumptionRate");
|
consumptionRate = tagCompound.getInteger(NBTHolder.NBT_ALTAR_CONSUMPTION_RATE);
|
||||||
drainRate = tagCompound.getInteger("drainRate");
|
drainRate = tagCompound.getInteger(NBTHolder.NBT_ALTAR_DRAIN_RATE);
|
||||||
consumptionMultiplier = tagCompound.getFloat("consumptionMultiplier");
|
consumptionMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_CONSUMPTION_MULTIPLIER);
|
||||||
efficiencyMultiplier = tagCompound.getFloat("efficiencyMultiplier");
|
efficiencyMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_EFFICIENCY_MULTIPLIER);
|
||||||
selfSacrificeEfficiencyMultiplier = tagCompound.getFloat("selfSacrificeEfficiencyMultiplier");
|
selfSacrificeEfficiencyMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_SELF_SACRIFICE_MULTIPLIER);
|
||||||
sacrificeEfficiencyMultiplier = tagCompound.getFloat("sacrificeEfficiencyMultiplier");
|
sacrificeEfficiencyMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_SACRIFICE_MULTIPLIER);
|
||||||
capacityMultiplier = tagCompound.getFloat("capacityMultiplier");
|
capacityMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_CAPACITY_MULTIPLIER);
|
||||||
orbCapacityMultiplier = tagCompound.getFloat("orbCapacityMultiplier");
|
orbCapacityMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_ORB_CAPACITY_MULTIPLIER);
|
||||||
dislocationMultiplier = tagCompound.getFloat("dislocationMultiplier");
|
dislocationMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_DISLOCATION_MULTIPLIER);
|
||||||
capacity = tagCompound.getInteger("capacity");
|
capacity = tagCompound.getInteger(NBTHolder.NBT_ALTAR_CAPACITY);
|
||||||
bufferCapacity = tagCompound.getInteger("bufferCapacity");
|
bufferCapacity = tagCompound.getInteger(NBTHolder.NBT_ALTAR_BUFFER_CAPACITY);
|
||||||
progress = tagCompound.getInteger("progress");
|
progress = tagCompound.getInteger(NBTHolder.NBT_ALTAR_PROGRESS);
|
||||||
isResultBlock = tagCompound.getBoolean("isResultBlock");
|
isResultBlock = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_IS_RESULT_BLOCK);
|
||||||
lockdownDuration = tagCompound.getInteger("lockdownDuration");
|
lockdownDuration = tagCompound.getInteger(NBTHolder.NBT_ALTAR_LOCKDOWN_DURATION);
|
||||||
accelerationUpgrades = tagCompound.getInteger("accelerationUpgrades");
|
accelerationUpgrades = tagCompound.getInteger(NBTHolder.NBT_ALTAR_ACCELERATION_UPGRADES);
|
||||||
demonBloodDuration = tagCompound.getInteger("demonBloodDuration");
|
demonBloodDuration = tagCompound.getInteger(NBTHolder.NBT_ALTAR_DEMON_BLOOD_DURATION);
|
||||||
cooldownAfterCrafting = tagCompound.getInteger("cooldownAfterCrafting");
|
cooldownAfterCrafting = tagCompound.getInteger(NBTHolder.NBT_ALTAR_COOLDOWN_AFTER_CRAFTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,37 +109,37 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
if (fluid != null)
|
if (fluid != null)
|
||||||
fluid.writeToNBT(tagCompound);
|
fluid.writeToNBT(tagCompound);
|
||||||
else
|
else
|
||||||
tagCompound.setString("Empty", "");
|
tagCompound.setString(NBTHolder.NBT_EMPTY, "");
|
||||||
|
|
||||||
|
|
||||||
if (fluidOutput != null)
|
if (fluidOutput != null)
|
||||||
tagCompound.setInteger("outputAmount", fluidOutput.amount);
|
tagCompound.setInteger(NBTHolder.NBT_OUTPUT_AMOUNT, fluidOutput.amount);
|
||||||
|
|
||||||
if (fluidInput != null)
|
if (fluidInput != null)
|
||||||
tagCompound.setInteger("inputAmount", fluidInput.amount);
|
tagCompound.setInteger(NBTHolder.NBT_INPUT_AMOUNT, fluidInput.amount);
|
||||||
|
|
||||||
tagCompound.setString("upgradeLevel", altarTier.name());
|
tagCompound.setString(NBTHolder.NBT_ALTAR_TIER, altarTier.name());
|
||||||
tagCompound.setBoolean("isActive", isActive);
|
tagCompound.setBoolean(NBTHolder.NBT_ALTAR_ACTIVE, isActive);
|
||||||
tagCompound.setInteger("liquidRequired", liquidRequired);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_LIQUID_REQ, liquidRequired);
|
||||||
tagCompound.setBoolean("canBeFilled", canBeFilled);
|
tagCompound.setBoolean(NBTHolder.NBT_ALTAR_FILLABLE, canBeFilled);
|
||||||
tagCompound.setBoolean("isUpgraded", isUpgraded);
|
tagCompound.setBoolean(NBTHolder.NBT_ALTAR_UPGRADED, isUpgraded);
|
||||||
tagCompound.setInteger("consumptionRate", consumptionRate);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_CONSUMPTION_RATE, consumptionRate);
|
||||||
tagCompound.setInteger("drainRate", drainRate);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_DRAIN_RATE, drainRate);
|
||||||
tagCompound.setFloat("consumptionMultiplier", consumptionMultiplier);
|
tagCompound.setFloat(NBTHolder.NBT_ALTAR_CONSUMPTION_MULTIPLIER, consumptionMultiplier);
|
||||||
tagCompound.setFloat("efficiencyMultiplier", efficiencyMultiplier);
|
tagCompound.setFloat(NBTHolder.NBT_ALTAR_EFFICIENCY_MULTIPLIER, efficiencyMultiplier);
|
||||||
tagCompound.setFloat("sacrificeEfficiencyMultiplier", sacrificeEfficiencyMultiplier);
|
tagCompound.setFloat(NBTHolder.NBT_ALTAR_SACRIFICE_MULTIPLIER, sacrificeEfficiencyMultiplier);
|
||||||
tagCompound.setFloat("selfSacrificeEfficiencyMultiplier", selfSacrificeEfficiencyMultiplier);
|
tagCompound.setFloat(NBTHolder.NBT_ALTAR_SELF_SACRIFICE_MULTIPLIER, selfSacrificeEfficiencyMultiplier);
|
||||||
tagCompound.setBoolean("isResultBlock", isResultBlock);
|
tagCompound.setBoolean(NBTHolder.NBT_ALTAR_IS_RESULT_BLOCK, isResultBlock);
|
||||||
tagCompound.setFloat("capacityMultiplier", capacityMultiplier);
|
tagCompound.setFloat(NBTHolder.NBT_ALTAR_CAPACITY_MULTIPLIER, capacityMultiplier);
|
||||||
tagCompound.setFloat("orbCapacityMultiplier", orbCapacityMultiplier);
|
tagCompound.setFloat(NBTHolder.NBT_ALTAR_ORB_CAPACITY_MULTIPLIER, orbCapacityMultiplier);
|
||||||
tagCompound.setFloat("dislocationMultiplier", dislocationMultiplier);
|
tagCompound.setFloat(NBTHolder.NBT_ALTAR_DISLOCATION_MULTIPLIER, dislocationMultiplier);
|
||||||
tagCompound.setInteger("capacity", capacity);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_CAPACITY, capacity);
|
||||||
tagCompound.setInteger("progress", progress);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_PROGRESS, progress);
|
||||||
tagCompound.setInteger("bufferCapacity", bufferCapacity);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_BUFFER_CAPACITY, bufferCapacity);
|
||||||
tagCompound.setInteger("lockdownDuration", lockdownDuration);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_LOCKDOWN_DURATION, lockdownDuration);
|
||||||
tagCompound.setInteger("accelerationUpgrades", this.accelerationUpgrades);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_ACCELERATION_UPGRADES, accelerationUpgrades);
|
||||||
tagCompound.setInteger("demonBloodDuration", demonBloodDuration);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_DEMON_BLOOD_DURATION, demonBloodDuration);
|
||||||
tagCompound.setInteger("cooldownAfterCrafting", cooldownAfterCrafting);
|
tagCompound.setInteger(NBTHolder.NBT_ALTAR_COOLDOWN_AFTER_CRAFTING, cooldownAfterCrafting);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,11 +147,34 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
if (getWorld().isRemote)
|
if (getWorld().isRemote)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (getWorld().getTotalWorldTime() % (Math.max(20 - getUpgrade().getSpeedCount(), 1)) == 0)
|
this.decrementDemonBlood();
|
||||||
|
|
||||||
|
if (lockdownDuration > 0)
|
||||||
|
lockdownDuration--;
|
||||||
|
|
||||||
|
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) {
|
||||||
|
{
|
||||||
|
IBlockState block = worldObj.getBlockState(new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()));
|
||||||
|
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()), block, block.getBlock());
|
||||||
|
block = worldObj.getBlockState(new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()));
|
||||||
|
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX() - 1, this.pos.getY(), this.pos.getZ()), block, block.getBlock());
|
||||||
|
block = worldObj.getBlockState(new BlockPos(this.pos.getX(), this.pos.getY() + 1, this.pos.getZ()));
|
||||||
|
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX() , this.pos.getY() + 1, this.pos.getZ()), block, block.getBlock());
|
||||||
|
block = worldObj.getBlockState(new BlockPos(this.pos.getX(), this.pos.getY() - 1, this.pos.getZ()));
|
||||||
|
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX(), this.pos.getY() - 1, this.pos.getZ()), block, block.getBlock());
|
||||||
|
block = worldObj.getBlockState(new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() + 1));
|
||||||
|
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() + 1), block, block.getBlock());
|
||||||
|
block = worldObj.getBlockState(new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1));
|
||||||
|
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1), block, block.getBlock());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getWorld().getTotalWorldTime() % (Math.max(20 - this.accelerationUpgrades, 1)) == 0)
|
||||||
everySecond();
|
everySecond();
|
||||||
|
|
||||||
if (getWorld().getTotalWorldTime() % 100 == 0)
|
if (getWorld().getTotalWorldTime() % 100 == 0 && (this.isActive || this.cooldownAfterCrafting <= 0))
|
||||||
everyFiveSeconds();
|
everyFiveSeconds();
|
||||||
|
|
||||||
|
updat();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void everySecond() {
|
private void everySecond() {
|
||||||
|
@ -169,9 +193,9 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
|
|
||||||
private void everyFiveSeconds() {
|
private void everyFiveSeconds() {
|
||||||
startCycle();
|
startCycle();
|
||||||
updat();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void startCycle() {
|
public void startCycle() {
|
||||||
if (worldObj != null)
|
if (worldObj != null)
|
||||||
worldObj.markBlockForUpdate(pos);
|
worldObj.markBlockForUpdate(pos);
|
||||||
|
@ -187,15 +211,19 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
|
|
||||||
if (getStackInSlot(0) != null) {
|
if (getStackInSlot(0) != null) {
|
||||||
// Do recipes
|
// Do recipes
|
||||||
if (AltarRecipeRegistry.getRecipes().containsKey(ItemStackWrapper.getHolder(getStackInSlot(0)))) {
|
for (ItemStack itemStack : AltarRecipeRegistry.getRecipes().keySet()) {
|
||||||
AltarRecipe recipe = AltarRecipeRegistry.getRecipeForInput(ItemStackWrapper.getHolder(getStackInSlot(0)));
|
if (getStackInSlot(0).getIsItemStackEqual(AltarRecipeRegistry.getRecipes().get(itemStack).getInput())) {
|
||||||
|
AltarRecipe recipe = AltarRecipeRegistry.getRecipeForInput(itemStack);
|
||||||
|
|
||||||
if (altarTier.ordinal() >= recipe.getMinTier().ordinal()) {
|
if (altarTier.ordinal() >= recipe.getMinTier().ordinal()) {
|
||||||
this.liquidRequired = recipe.getSyphon();
|
this.isActive = true;
|
||||||
this.canBeFilled = recipe.isUseTag();
|
this.result = new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata());
|
||||||
this.consumptionRate = recipe.getConsumeRate();
|
this.liquidRequired = recipe.getSyphon();
|
||||||
this.drainRate = recipe.getDrainRate();
|
this.canBeFilled = recipe.isUseTag();
|
||||||
this.isActive = true;
|
this.consumptionRate = recipe.getConsumeRate();
|
||||||
|
this.drainRate = recipe.getDrainRate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,6 +236,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
if (cooldownAfterCrafting > 0) {
|
if (cooldownAfterCrafting > 0) {
|
||||||
cooldownAfterCrafting--;
|
cooldownAfterCrafting--;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getStackInSlot(0) == null) {
|
if (getStackInSlot(0) == null) {
|
||||||
|
@ -216,9 +245,13 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
|
|
||||||
int worldTime = (int) (worldObj.getWorldTime() % 24000);
|
int worldTime = (int) (worldObj.getWorldTime() % 24000);
|
||||||
|
|
||||||
if (worldObj.isRemote) {
|
if (worldObj.isRemote)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
float f = 1.0F;
|
||||||
|
float f1 = f * 0.6F + 0.4F;
|
||||||
|
float f2 = f * f * 0.7F - 0.5F;
|
||||||
|
float f3 = f * f * 0.6F - 0.7F;
|
||||||
|
|
||||||
if (!canBeFilled) {
|
if (!canBeFilled) {
|
||||||
if (fluid != null && fluid.amount >= 1) {
|
if (fluid != null && fluid.amount >= 1) {
|
||||||
|
@ -233,11 +266,11 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
progress += liquidDrained;
|
progress += liquidDrained;
|
||||||
|
|
||||||
if (worldTime % 4 == 0) {
|
if (worldTime % 4 == 0) {
|
||||||
// SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 1, xCoord, yCoord, zCoord);
|
worldObj.spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progress >= liquidRequired * stackSize) {
|
if (progress >= liquidRequired * stackSize) {
|
||||||
ItemStack result = AltarRecipeRegistry.getRecipeForInput(ItemStackWrapper.getHolder(getStackInSlot(0))) != null ? (AltarRecipeRegistry.getRecipeForInput(ItemStackWrapper.getHolder(getStackInSlot(0))).getOutput() != null ? AltarRecipeRegistry.getRecipeForInput(ItemStackWrapper.getHolder(getStackInSlot(0))).getOutput().toStack() : null) : null;
|
ItemStack result = this.result;
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
result.stackSize *= stackSize;
|
result.stackSize *= stackSize;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +279,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
progress = 0;
|
progress = 0;
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
// SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 4, xCoord + 0.5f, yCoord + 1.0f, zCoord + 0.5f);
|
worldObj.spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
|
||||||
}
|
}
|
||||||
this.isActive = false;
|
this.isActive = false;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +287,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
progress -= (int) (efficiencyMultiplier * drainRate);
|
progress -= (int) (efficiencyMultiplier * drainRate);
|
||||||
|
|
||||||
if (worldTime % 2 == 0) {
|
if (worldTime % 2 == 0) {
|
||||||
// SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 2, xCoord, yCoord, zCoord);
|
worldObj.spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -271,7 +304,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ownerName = itemTag.getString("ownerName");
|
String ownerName = itemTag.getString(NBTHolder.NBT_OWNER);
|
||||||
|
|
||||||
if (ownerName.equals("")) {
|
if (ownerName.equals("")) {
|
||||||
return;
|
return;
|
||||||
|
@ -285,7 +318,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
fluid.amount = fluid.amount - drain;
|
fluid.amount = fluid.amount - drain;
|
||||||
|
|
||||||
if (worldTime % 4 == 0) {
|
if (worldTime % 4 == 0) {
|
||||||
// SpellHelper.sendIndexedParticleToAllAround(worldObj, xCoord, yCoord, zCoord, 20, worldObj.provider.dimensionId, 3, xCoord, yCoord, zCoord);
|
worldObj.spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,6 +351,7 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
||||||
return filledAmount;
|
return filledAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void sacrificialDaggerCall(int amount, boolean isSacrifice) {
|
public void sacrificialDaggerCall(int amount, boolean isSacrifice) {
|
||||||
if (this.lockdownDuration > 0) {
|
if (this.lockdownDuration > 0) {
|
||||||
int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
package WayofTime.bloodmagic.tile;
|
package WayofTime.bloodmagic.tile;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.InventoryHelper;
|
import net.minecraft.inventory.InventoryHelper;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.network.NetworkManager;
|
||||||
|
import net.minecraft.network.Packet;
|
||||||
|
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
import net.minecraft.util.IChatComponent;
|
import net.minecraft.util.IChatComponent;
|
||||||
import net.minecraft.util.StatCollector;
|
import net.minecraft.util.StatCollector;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class TileInventory extends TileEntity implements IInventory {
|
public class TileInventory extends TileEntity implements IInventory {
|
||||||
|
|
||||||
|
@ -17,12 +23,23 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||||
private int size;
|
private int size;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
protected int[] syncedSlots = new int[0];
|
||||||
|
|
||||||
public TileInventory(int size, String name) {
|
public TileInventory(int size, String name) {
|
||||||
this.inventory = new ItemStack[size];
|
this.inventory = new ItemStack[size];
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSyncedSlot(int slot) {
|
||||||
|
for (int s : this.syncedSlots) {
|
||||||
|
if (s == slot) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||||
super.readFromNBT(tagCompound);
|
super.readFromNBT(tagCompound);
|
||||||
|
@ -30,11 +47,13 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||||
inventory = new ItemStack[getSizeInventory()];
|
inventory = new ItemStack[getSizeInventory()];
|
||||||
|
|
||||||
for (int i = 0; i < tags.tagCount(); i++) {
|
for (int i = 0; i < tags.tagCount(); i++) {
|
||||||
NBTTagCompound data = tags.getCompoundTagAt(i);
|
if (!isSyncedSlot(i)) {
|
||||||
int j = data.getByte("Slot") & 255;
|
NBTTagCompound data = tags.getCompoundTagAt(i);
|
||||||
|
byte j = data.getByte("Slot") ;
|
||||||
|
|
||||||
if (j >= 0 && j < inventory.length) {
|
if (j >= 0 && j < inventory.length) {
|
||||||
inventory[j] = ItemStack.loadItemStackFromNBT(data);
|
inventory[j] = ItemStack.loadItemStackFromNBT(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +64,7 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||||
NBTTagList tags = new NBTTagList();
|
NBTTagList tags = new NBTTagList();
|
||||||
|
|
||||||
for (int i = 0; i < inventory.length; i++) {
|
for (int i = 0; i < inventory.length; i++) {
|
||||||
if (inventory[i] != null) {
|
if ((inventory[i] != null) && !isSyncedSlot(i)) {
|
||||||
NBTTagCompound data = new NBTTagCompound();
|
NBTTagCompound data = new NBTTagCompound();
|
||||||
data.setByte("Slot", (byte) i);
|
data.setByte("Slot", (byte) i);
|
||||||
inventory[i].writeToNBT(data);
|
inventory[i].writeToNBT(data);
|
||||||
|
@ -74,30 +93,46 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int index, int count) {
|
public ItemStack decrStackSize(int index, int count) {
|
||||||
ItemStack slotStack = getStackInSlot(index);
|
if (inventory[index] != null) {
|
||||||
|
if (!worldObj.isRemote)
|
||||||
|
worldObj.markBlockForUpdate(this.pos);
|
||||||
|
|
||||||
if (slotStack.stackSize > count)
|
if (inventory[index].stackSize <= count) {
|
||||||
slotStack.stackSize -= count;
|
ItemStack itemStack = inventory[index];
|
||||||
else if (slotStack.stackSize <= count)
|
inventory[index] = null;
|
||||||
return null;
|
markDirty();
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
return slotStack;
|
ItemStack itemStack = inventory[index].splitStack(count);
|
||||||
|
if (inventory[index].stackSize == 0)
|
||||||
|
inventory[index] = null;
|
||||||
|
|
||||||
|
markDirty();
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||||
ItemStack stack = getStackInSlot(slot);
|
if (inventory[slot] != null) {
|
||||||
if (stack != null)
|
ItemStack itemStack = inventory[slot];
|
||||||
setInventorySlotContents(slot, null);
|
setInventorySlotContents(slot, null);
|
||||||
return stack;
|
return itemStack;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||||
inventory[slot] = stack;
|
inventory[slot] = stack;
|
||||||
worldObj.markBlockForUpdate(pos);
|
|
||||||
if (stack != null && stack.stackSize > getInventoryStackLimit())
|
if (stack != null && stack.stackSize > getInventoryStackLimit())
|
||||||
stack.stackSize = getInventoryStackLimit();
|
stack.stackSize = getInventoryStackLimit();
|
||||||
|
markDirty();
|
||||||
|
if (!worldObj.isRemote)
|
||||||
|
worldObj.markBlockForUpdate(this.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -161,4 +196,25 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||||
public IChatComponent getDisplayName() {
|
public IChatComponent getDisplayName() {
|
||||||
return new ChatComponentTranslation("tile.BloodMagic." + name + ".name");
|
return new ChatComponentTranslation("tile.BloodMagic." + name + ".name");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Packet getDescriptionPacket()
|
||||||
|
{
|
||||||
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
writeToNBT(nbt);
|
||||||
|
return new S35PacketUpdateTileEntity(getPos(), -999, nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
|
||||||
|
{
|
||||||
|
super.onDataPacket(net, pkt);
|
||||||
|
readFromNBT(pkt.getNbtCompound());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
|
||||||
|
{
|
||||||
|
return oldState.getBlock() != newState.getBlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package WayofTime.bloodmagic.util;
|
package WayofTime.bloodmagic.util;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.network.AlchemicalWizardryPacketHandler;
|
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -233,6 +233,6 @@ public class ChatUtil {
|
||||||
*/
|
*/
|
||||||
public static void sendNoSpam(EntityPlayerMP player, IChatComponent... lines) {
|
public static void sendNoSpam(EntityPlayerMP player, IChatComponent... lines) {
|
||||||
if (lines.length > 0)
|
if (lines.length > 0)
|
||||||
AlchemicalWizardryPacketHandler.INSTANCE.sendTo(new PacketNoSpamChat(lines), player);
|
BloodMagicPacketHandler.INSTANCE.sendTo(new PacketNoSpamChat(lines), player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,18 +27,22 @@ public class Utils {
|
||||||
* @param tile - The {@link TileInventory} to input the item to
|
* @param tile - The {@link TileInventory} to input the item to
|
||||||
* @param player - The player to take the item from.
|
* @param player - The player to take the item from.
|
||||||
*/
|
*/
|
||||||
public static void insertItemToTile(TileInventory tile, EntityPlayer player) {
|
public static boolean insertItemToTile(TileInventory tile, EntityPlayer player) {
|
||||||
if (tile.getStackInSlot(0) == null && player.getHeldItem() != null) {
|
if (tile.getStackInSlot(0) == null && player.getHeldItem() != null) {
|
||||||
ItemStack input = player.getHeldItem().copy();
|
ItemStack input = player.getHeldItem().copy();
|
||||||
input.stackSize = 1;
|
input.stackSize = 1;
|
||||||
player.getHeldItem().stackSize--;
|
player.getHeldItem().stackSize--;
|
||||||
tile.setInventorySlotContents(0, input);
|
tile.setInventorySlotContents(0, input);
|
||||||
|
return true;
|
||||||
} else if (tile.getStackInSlot(0) != null && player.getHeldItem() == null) {
|
} else if (tile.getStackInSlot(0) != null && player.getHeldItem() == null) {
|
||||||
if (!tile.getWorld().isRemote) {
|
if (!tile.getWorld().isRemote) {
|
||||||
EntityItem invItem = new EntityItem(tile.getWorld(), player.posX, player.posY + 0.25, player.posZ, tile.getStackInSlot(0));
|
EntityItem invItem = new EntityItem(tile.getWorld(), player.posX, player.posY + 0.25, player.posZ, tile.getStackInSlot(0));
|
||||||
tile.getWorld().spawnEntityInWorld(invItem);
|
tile.getWorld().spawnEntityInWorld(invItem);
|
||||||
}
|
}
|
||||||
tile.clear();
|
tile.clear();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue