Creation of 1.16.3 branch
Initial publishing of the 1.16.3 branch of the mod. A lot of systems are missing (such as Rituals and Living Armour), but enough is present for a decent Alpha release.
This commit is contained in:
parent
0e02b983f1
commit
d617911d7a
1662 changed files with 18791 additions and 85075 deletions
80
src/main/java/wayoftime/bloodmagic/api/IBloodMagicAPI.java
Normal file
80
src/main/java/wayoftime/bloodmagic/api/IBloodMagicAPI.java
Normal file
|
@ -0,0 +1,80 @@
|
|||
package wayoftime.bloodmagic.api;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
/**
|
||||
* The main interface between a plugin and Blood Magic's internals.
|
||||
*
|
||||
* This API is intended for <i>compatibility</i> between other mods and Blood
|
||||
* Magic. More advanced integration is out of the scope of this API and are
|
||||
* considered "addons".
|
||||
*
|
||||
* To get an instance of this without actually creating an
|
||||
* {@link IBloodMagicPlugin}, use {@link BloodMagicPlugin.Inject}.
|
||||
*/
|
||||
public interface IBloodMagicAPI
|
||||
{
|
||||
|
||||
// /**
|
||||
// * Retrieves the instance of the blacklist.
|
||||
// *
|
||||
// * @return the active {@link IBloodMagicBlacklist} instance
|
||||
// */
|
||||
// @Nonnull
|
||||
// IBloodMagicBlacklist getBlacklist();
|
||||
|
||||
/**
|
||||
* Retrieves the instance of the recipe registrar.
|
||||
*
|
||||
* @return the active {@link IBloodMagicRecipeRegistrar} instance
|
||||
*/
|
||||
@Nonnull
|
||||
IBloodMagicRecipeRegistrar getRecipeRegistrar();
|
||||
//
|
||||
// /**
|
||||
// * Retrieves the instance of the value manager.
|
||||
// *
|
||||
// * @return the active {@link IBloodMagicValueManager} instance
|
||||
// */
|
||||
// @Nonnull
|
||||
// IBloodMagicValueManager getValueManager();
|
||||
|
||||
/**
|
||||
* Registers an {@link IBlockState} as a given component for the Blood Altar.
|
||||
* <p>
|
||||
* Valid component types:
|
||||
* <ul>
|
||||
* <li>GLOWSTONE</li>
|
||||
* <li>BLOODSTONE</li>
|
||||
* <li>BEACON</li>
|
||||
* <li>BLOODRUNE</li>
|
||||
* <li>CRYSTAL</li>
|
||||
* <li>NOTAIR</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param state The state to register
|
||||
* @param componentType The type of Blood Altar component to register as.
|
||||
*/
|
||||
void registerAltarComponent(@Nonnull BlockState state, @Nonnull String componentType);
|
||||
|
||||
/**
|
||||
* Removes an {@link IBlockState} from the component mappings
|
||||
* <p>
|
||||
* Valid component types:
|
||||
* <ul>
|
||||
* <li>GLOWSTONE</li>
|
||||
* <li>BLOODSTONE</li>
|
||||
* <li>BEACON</li>
|
||||
* <li>BLOODRUNE</li>
|
||||
* <li>CRYSTAL</li>
|
||||
* <li>NOTAIR</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param state The state to unregister
|
||||
* @param componentType The type of Blood Altar component to unregister from.
|
||||
*/
|
||||
void unregisterAltarComponent(@Nonnull BlockState state, @Nonnull String componentType);
|
||||
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package wayoftime.bloodmagic.api;
|
||||
|
||||
/**
|
||||
* Allows recipe addition and removal.
|
||||
*/
|
||||
public interface IBloodMagicRecipeRegistrar
|
||||
{
|
||||
|
||||
// /**
|
||||
// * Adds a new recipe to the Blood Altar.
|
||||
// *
|
||||
// * @param input An input {@link Ingredient}.
|
||||
// * @param output An output {@link ItemStack}.
|
||||
// * @param minimumTier The minimum Blood Altar tier required for this recipe.
|
||||
// * @param syphon The amount of Life Essence to syphon from the Blood Altar
|
||||
// * over the course of the craft.
|
||||
// * @param consumeRate How quickly the Life Essence is syphoned.
|
||||
// * @param drainRate How quickly progress is lost if the Blood Altar runs out
|
||||
// * of Life Essence during the craft.
|
||||
// */
|
||||
// void addBloodAltar(@Nonnull Ingredient input, @Nonnull ItemStack output, @Nonnegative int minimumTier,
|
||||
// @Nonnegative int syphon, @Nonnegative int consumeRate, @Nonnegative int drainRate);
|
||||
//
|
||||
// /**
|
||||
// * Removes a Blood Altar recipe based on an input {@link ItemStack}.
|
||||
// *
|
||||
// * @param input The input item to remove the recipe of.
|
||||
// * @return Whether or not a recipe was removed.
|
||||
// */
|
||||
// boolean removeBloodAltar(@Nonnull ItemStack input);
|
||||
//
|
||||
// /**
|
||||
// * Adds a new recipe to the Alchemy Table.
|
||||
// *
|
||||
// * @param output An output {@link ItemStack}.
|
||||
// * @param syphon The amount of Life Essence to syphon from the Blood Orb's
|
||||
// * bound network over the course of the craft.
|
||||
// * @param ticks The amount of ticks it takes to complete the craft.
|
||||
// * @param minimumTier The minimum Blood Orb tier required for this recipe.
|
||||
// * @param input An array of {@link Ingredient}s to accept as inputs.
|
||||
// */
|
||||
// void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks,
|
||||
// @Nonnegative int minimumTier, @Nonnull Ingredient... input);
|
||||
//
|
||||
// /**
|
||||
// * Removes an Alchemy Table recipe based on an input {@link ItemStack} array.
|
||||
// *
|
||||
// * @param input The input items to remove the recipe of.
|
||||
// * @return Whether or not a recipe was removed.
|
||||
// */
|
||||
// boolean removeAlchemyTable(@Nonnull ItemStack... input);
|
||||
//
|
||||
// /**
|
||||
// * Adds a new recipe to the Soul/Tartaric Forge.
|
||||
// *
|
||||
// * @param output An output {@link ItemStack}.
|
||||
// * @param minimumSouls The minimum number of souls that must be contained in the
|
||||
// * Soul Gem.
|
||||
// * @param soulDrain The number of souls to drain from the Soul Gem.
|
||||
// * @param input An array of {@link Ingredient}s to accept as inputs.
|
||||
// */
|
||||
// void addTartaricForge(@Nonnull ItemStack output, @Nonnegative double minimumSouls, @Nonnegative double soulDrain,
|
||||
// @Nonnull Ingredient... input);
|
||||
//
|
||||
// /**
|
||||
// * Removes a Soul/Tartaric Forge recipe based on an input {@link ItemStack}
|
||||
// * array.
|
||||
// *
|
||||
// * @param input The input items to remove the recipe of.
|
||||
// * @return Whether or not a recipe was removed.
|
||||
// */
|
||||
// boolean removeTartaricForge(@Nonnull ItemStack... input);
|
||||
//
|
||||
// /**
|
||||
// * Adds a new recipe to the Alchemy Array.
|
||||
// *
|
||||
// * @param input An input {@link Ingredient}. First item put into the
|
||||
// * Alchemy Array.
|
||||
// * @param catalyst A catalyst {@link Ingredient}. Second item put into the
|
||||
// * Alchemy Array.
|
||||
// * @param output An output {@link ItemStack}.
|
||||
// * @param circleTexture The texture to render for the Alchemy Array circle.
|
||||
// */
|
||||
// void addAlchemyArray(@Nonnull Ingredient input, @Nonnull Ingredient catalyst, @Nonnull ItemStack output,
|
||||
// @Nullable ResourceLocation circleTexture);
|
||||
//
|
||||
// /**
|
||||
// * Removes an Alchemy Array recipe based on an input {@link ItemStack} and it's
|
||||
// * catalyst {@link ItemStack}.
|
||||
// *
|
||||
// * @param input The input item to remove the recipe of.
|
||||
// * @param catalyst The catalyst item to remove the recipe of.
|
||||
// * @return Whether or not a recipe was removed.
|
||||
// */
|
||||
// boolean removeAlchemyArray(@Nonnull ItemStack input, @Nonnull ItemStack catalyst);
|
||||
//
|
||||
// void addSacrificeCraft(@Nonnull ItemStack output, @Nonnegative double healthRequired, @Nonnull Ingredient... input);
|
||||
//
|
||||
// boolean removeSacrificeCraft(@Nonnull ItemStack... input);
|
||||
}
|
60
src/main/java/wayoftime/bloodmagic/api/SerializerHelper.java
Normal file
60
src/main/java/wayoftime/bloodmagic/api/SerializerHelper.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package wayoftime.bloodmagic.api;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ShapedRecipe;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
|
||||
/**
|
||||
* Copied liberally from Mekanism. Thanks, pupnewfster!
|
||||
*
|
||||
*/
|
||||
public class SerializerHelper
|
||||
{
|
||||
private SerializerHelper()
|
||||
{
|
||||
}
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||
|
||||
private static void validateKey(@Nonnull JsonObject json, @Nonnull String key)
|
||||
{
|
||||
if (!json.has(key))
|
||||
{
|
||||
throw new JsonSyntaxException("Missing '" + key + "', expected to find an object");
|
||||
}
|
||||
if (!json.get(key).isJsonObject())
|
||||
{
|
||||
throw new JsonSyntaxException("Expected '" + key + "' to be an object");
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemStack(@Nonnull JsonObject json, @Nonnull String key)
|
||||
{
|
||||
validateKey(json, key);
|
||||
return ShapedRecipe.deserializeItem(JSONUtils.getJsonObject(json, key));
|
||||
}
|
||||
|
||||
public static JsonElement serializeItemStack(@Nonnull ItemStack stack)
|
||||
{
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty(Constants.JSON.ITEM, stack.getItem().getRegistryName().toString());
|
||||
if (stack.getCount() > 1)
|
||||
{
|
||||
json.addProperty(Constants.JSON.COUNT, stack.getCount());
|
||||
}
|
||||
if (stack.hasTag())
|
||||
{
|
||||
json.addProperty(Constants.JSON.NBT, stack.getTag().toString());
|
||||
}
|
||||
return json;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package wayoftime.bloodmagic.api.event;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public class BloodMagicCraftedEvent extends Event
|
||||
{
|
||||
|
||||
private final boolean modifiable;
|
||||
private final ItemStack[] inputs;
|
||||
private ItemStack output;
|
||||
|
||||
public BloodMagicCraftedEvent(ItemStack output, ItemStack[] inputs, boolean modifiable)
|
||||
{
|
||||
this.modifiable = modifiable;
|
||||
this.inputs = inputs;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public boolean isModifiable()
|
||||
{
|
||||
return modifiable;
|
||||
}
|
||||
|
||||
public ItemStack[] getInputs()
|
||||
{
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public ItemStack getOutput()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
public void setOutput(ItemStack output)
|
||||
{
|
||||
if (isModifiable())
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired whenever a craft is completed in a Blood Altar.
|
||||
*
|
||||
* It is not cancelable, however you can modify the output stack.
|
||||
*/
|
||||
public static class Altar extends BloodMagicCraftedEvent
|
||||
{
|
||||
|
||||
public Altar(ItemStack output, ItemStack input)
|
||||
{
|
||||
super(output, new ItemStack[]
|
||||
{ input }, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired whenever a craft is completed in a Soul Forge.
|
||||
*
|
||||
* It is not cancelable, however you can modify the output stack.
|
||||
*/
|
||||
public static class SoulForge extends BloodMagicCraftedEvent
|
||||
{
|
||||
|
||||
public SoulForge(ItemStack output, ItemStack[] inputs)
|
||||
{
|
||||
super(output, inputs, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired whenever a craft is completed in an Alchemy Table.
|
||||
*
|
||||
* It is not cancelable, however you can modify the output stack.
|
||||
*/
|
||||
public static class AlchemyTable extends BloodMagicCraftedEvent
|
||||
{
|
||||
|
||||
public AlchemyTable(ItemStack output, ItemStack[] inputs)
|
||||
{
|
||||
super(output, inputs, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package wayoftime.bloodmagic.api.impl.recipe;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.api.inventory.IgnoredIInventory;
|
||||
|
||||
public abstract class BloodMagicRecipe implements IRecipe<IgnoredIInventory>
|
||||
{
|
||||
private final ResourceLocation id;
|
||||
|
||||
protected BloodMagicRecipe(ResourceLocation id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes this recipe to a PacketBuffer.
|
||||
*
|
||||
* @param buffer The buffer to write to.
|
||||
*/
|
||||
public abstract void write(PacketBuffer buffer);
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(@Nonnull IgnoredIInventory inv, @Nonnull World world)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDynamic()
|
||||
{
|
||||
// Note: If we make this non dynamic, we can make it show in vanilla's crafting
|
||||
// book and also then obey the recipe locking.
|
||||
// For now none of that works/makes sense in our concept so don't lock it
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult(@Nonnull IgnoredIInventory inv)
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFit(int width, int height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getRecipeOutput()
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package wayoftime.bloodmagic.api.inventory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public final class IgnoredIInventory implements IInventory
|
||||
{
|
||||
public static final IgnoredIInventory INSTANCE = new IgnoredIInventory();
|
||||
|
||||
private IgnoredIInventory()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int index)
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int index, @Nonnull ItemStack stack)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsableByPlayer(@Nonnull PlayerEntity player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package wayoftime.bloodmagic.api.providers;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import wayoftime.bloodmagic.api.text.IHasTextComponent;
|
||||
import wayoftime.bloodmagic.api.text.IHasTranslationKey;
|
||||
|
||||
public interface IBaseProvider extends IHasTextComponent, IHasTranslationKey
|
||||
{
|
||||
ResourceLocation getRegistryName();
|
||||
|
||||
default String getName()
|
||||
{
|
||||
return getRegistryName().getPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
default ITextComponent getTextComponent()
|
||||
{
|
||||
return new TranslationTextComponent(getTranslationKey());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package wayoftime.bloodmagic.api.providers;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public interface IEntityTypeProvider extends IBaseProvider
|
||||
{
|
||||
|
||||
@Nonnull
|
||||
EntityType<?> getEntityType();
|
||||
|
||||
@Override
|
||||
default ResourceLocation getRegistryName()
|
||||
{
|
||||
return getEntityType().getRegistryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
default ITextComponent getTextComponent()
|
||||
{
|
||||
return getEntityType().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
default String getTranslationKey()
|
||||
{
|
||||
return getEntityType().getTranslationKey();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package wayoftime.bloodmagic.api.text;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public interface IHasTextComponent
|
||||
{
|
||||
ITextComponent getTextComponent();
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package wayoftime.bloodmagic.api.text;
|
||||
|
||||
public interface IHasTranslationKey
|
||||
{
|
||||
String getTranslationKey();
|
||||
}
|
98
src/main/java/wayoftime/bloodmagic/client/ClientEvents.java
Normal file
98
src/main/java/wayoftime/bloodmagic/client/ClientEvents.java
Normal file
|
@ -0,0 +1,98 @@
|
|||
package wayoftime.bloodmagic.client;
|
||||
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.IItemPropertyGetter;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemModelsProperties;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.client.render.block.RenderAlchemyArray;
|
||||
import wayoftime.bloodmagic.client.render.block.RenderAltar;
|
||||
import wayoftime.bloodmagic.client.screens.ScreenSoulForge;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilToggleable;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemSentientSword;
|
||||
import wayoftime.bloodmagic.iface.IMultiWillTool;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
import wayoftime.bloodmagic.tile.TileAltar;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = BloodMagic.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ClientEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent event)
|
||||
{
|
||||
ClientRegistry.bindTileEntityRenderer(TileAltar.TYPE, RenderAltar::new);
|
||||
ClientRegistry.bindTileEntityRenderer(TileAlchemyArray.TYPE, RenderAlchemyArray::new);
|
||||
// ClientRegistry.bindTileEntityRenderer(TileSoulForge.TYPE, RenderAlchemyArray::new);
|
||||
}
|
||||
|
||||
public static void registerContainerScreens()
|
||||
{
|
||||
ScreenManager.registerFactory(BloodMagicBlocks.SOUL_FORGE_CONTAINER.get(), ScreenSoulForge::new);
|
||||
}
|
||||
|
||||
public static void registerItemModelProperties(FMLClientSetupEvent event)
|
||||
{
|
||||
registerToggleableProperties(BloodMagicItems.GREEN_GROVE_SIGIL.get());
|
||||
registerToggleableProperties(BloodMagicItems.FAST_MINER_SIGIL.get());
|
||||
registerToggleableProperties(BloodMagicItems.MAGNETISM_SIGIL.get());
|
||||
registerToggleableProperties(BloodMagicItems.ICE_SIGIL.get());
|
||||
registerMultiWillTool(BloodMagicItems.SENTIENT_SWORD.get());
|
||||
registerMultiWillTool(BloodMagicItems.PETTY_GEM.get());
|
||||
registerMultiWillTool(BloodMagicItems.LESSER_GEM.get());
|
||||
registerMultiWillTool(BloodMagicItems.COMMON_GEM.get());
|
||||
|
||||
ItemModelsProperties.registerProperty(BloodMagicItems.SENTIENT_SWORD.get(), BloodMagic.rl("active"), new IItemPropertyGetter()
|
||||
{
|
||||
@Override
|
||||
public float call(ItemStack stack, ClientWorld world, LivingEntity entity)
|
||||
{
|
||||
return ((ItemSentientSword) stack.getItem()).getActivated(stack) ? 1 : 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerToggleableProperties(Item item)
|
||||
{
|
||||
ItemModelsProperties.registerProperty(item, BloodMagic.rl("active"), new IItemPropertyGetter()
|
||||
{
|
||||
@Override
|
||||
public float call(ItemStack stack, ClientWorld world, LivingEntity entity)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ItemSigilToggleable)
|
||||
{
|
||||
return ((ItemSigilToggleable) item).getActivated(stack) ? 1 : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerMultiWillTool(Item item)
|
||||
{
|
||||
ItemModelsProperties.registerProperty(item, BloodMagic.rl("type"), new IItemPropertyGetter()
|
||||
{
|
||||
@Override
|
||||
public float call(ItemStack stack, ClientWorld world, LivingEntity entity)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof IMultiWillTool)
|
||||
{
|
||||
return ((IMultiWillTool) item).getCurrentType(stack).ordinal();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package wayoftime.bloodmagic.client.render;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class BloodMagicRenderer
|
||||
{
|
||||
public static float getRed(int color)
|
||||
{
|
||||
return (color >> 16 & 0xFF) / 255.0F;
|
||||
}
|
||||
|
||||
public static float getGreen(int color)
|
||||
{
|
||||
return (color >> 8 & 0xFF) / 255.0F;
|
||||
}
|
||||
|
||||
public static float getBlue(int color)
|
||||
{
|
||||
return (color & 0xFF) / 255.0F;
|
||||
}
|
||||
|
||||
public static float getAlpha(int color)
|
||||
{
|
||||
return (color >> 24 & 0xFF) / 255.0F;
|
||||
}
|
||||
|
||||
public static class Model3D
|
||||
{
|
||||
public double minX, minY, minZ;
|
||||
public double maxX, maxY, maxZ;
|
||||
|
||||
public final TextureAtlasSprite[] textures = new TextureAtlasSprite[6];
|
||||
|
||||
public final boolean[] renderSides = new boolean[]
|
||||
{ true, true, true, true, true, true, false };
|
||||
|
||||
public double sizeX()
|
||||
{
|
||||
return maxX - minX;
|
||||
}
|
||||
|
||||
public double sizeY()
|
||||
{
|
||||
return maxY - minY;
|
||||
}
|
||||
|
||||
public double sizeZ()
|
||||
{
|
||||
return maxZ - minZ;
|
||||
}
|
||||
|
||||
public void setSideRender(Direction side, boolean value)
|
||||
{
|
||||
renderSides[side.ordinal()] = value;
|
||||
}
|
||||
|
||||
public boolean shouldSideRender(Direction side)
|
||||
{
|
||||
return renderSides[side.ordinal()];
|
||||
}
|
||||
|
||||
public void setTexture(TextureAtlasSprite tex)
|
||||
{
|
||||
Arrays.fill(textures, tex);
|
||||
}
|
||||
|
||||
public void setTextures(TextureAtlasSprite down, TextureAtlasSprite up, TextureAtlasSprite north, TextureAtlasSprite south, TextureAtlasSprite west, TextureAtlasSprite east)
|
||||
{
|
||||
textures[0] = down;
|
||||
textures[1] = up;
|
||||
textures[2] = north;
|
||||
textures[3] = south;
|
||||
textures[4] = west;
|
||||
textures[5] = east;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Model2D
|
||||
{
|
||||
public double minX, minY;
|
||||
public double maxX, maxY;
|
||||
|
||||
public ResourceLocation resource;
|
||||
|
||||
public double sizeX()
|
||||
{
|
||||
return maxX - minX;
|
||||
}
|
||||
|
||||
public double sizeY()
|
||||
{
|
||||
return maxY - minY;
|
||||
}
|
||||
|
||||
public void setTexture(ResourceLocation resource)
|
||||
{
|
||||
this.resource = resource;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
package wayoftime.bloodmagic.client.render;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Direction.AxisDirection;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model3D;
|
||||
|
||||
/**
|
||||
* Adapted from BuildCraft
|
||||
*/
|
||||
public class RenderResizableCuboid
|
||||
{
|
||||
public static final RenderResizableCuboid INSTANCE = new RenderResizableCuboid();
|
||||
private static final Vector3f VEC_ZERO = new Vector3f(0, 0, 0);
|
||||
private static final int U_MIN = 0;
|
||||
private static final int U_MAX = 1;
|
||||
private static final int V_MIN = 2;
|
||||
private static final int V_MAX = 3;
|
||||
|
||||
protected EntityRendererManager manager = Minecraft.getInstance().getRenderManager();
|
||||
|
||||
private static Vector3f withValue(Vector3f vector, Axis axis, float value)
|
||||
{
|
||||
if (axis == Axis.X)
|
||||
{
|
||||
return new Vector3f(value, vector.getY(), vector.getZ());
|
||||
} else if (axis == Axis.Y)
|
||||
{
|
||||
return new Vector3f(vector.getX(), value, vector.getZ());
|
||||
} else if (axis == Axis.Z)
|
||||
{
|
||||
return new Vector3f(vector.getX(), vector.getY(), value);
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
}
|
||||
|
||||
public static double getValue(Vector3d vector, Axis axis)
|
||||
{
|
||||
if (axis == Axis.X)
|
||||
{
|
||||
return vector.x;
|
||||
} else if (axis == Axis.Y)
|
||||
{
|
||||
return vector.y;
|
||||
} else if (axis == Axis.Z)
|
||||
{
|
||||
return vector.z;
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
}
|
||||
|
||||
public void renderCube(Model3D cube, MatrixStack matrix, IVertexBuilder buffer, int argb, int light, int overlay)
|
||||
{
|
||||
float red = BloodMagicRenderer.getRed(argb);
|
||||
float green = BloodMagicRenderer.getGreen(argb);
|
||||
float blue = BloodMagicRenderer.getBlue(argb);
|
||||
float alpha = BloodMagicRenderer.getAlpha(argb);
|
||||
Vector3d size = new Vector3d(cube.sizeX(), cube.sizeY(), cube.sizeZ());
|
||||
matrix.push();
|
||||
matrix.translate(cube.minX, cube.minY, cube.minZ);
|
||||
MatrixStack.Entry lastMatrix = matrix.getLast();
|
||||
Matrix4f matrix4f = lastMatrix.getMatrix();
|
||||
Matrix3f normal = lastMatrix.getNormal();
|
||||
for (Direction face : Direction.values())
|
||||
{
|
||||
if (cube.shouldSideRender(face))
|
||||
{
|
||||
int ordinal = face.ordinal();
|
||||
TextureAtlasSprite sprite = cube.textures[ordinal];
|
||||
if (sprite != null)
|
||||
{
|
||||
Axis u = face.getAxis() == Axis.X ? Axis.Z : Axis.X;
|
||||
Axis v = face.getAxis() == Axis.Y ? Axis.Z : Axis.Y;
|
||||
float other = face.getAxisDirection() == AxisDirection.POSITIVE
|
||||
? (float) getValue(size, face.getAxis())
|
||||
: 0;
|
||||
|
||||
// Swap the face if this is positive: the renderer returns indexes that ALWAYS
|
||||
// are for the negative face, so light it properly this way
|
||||
face = face.getAxisDirection() == AxisDirection.NEGATIVE ? face : face.getOpposite();
|
||||
Direction opposite = face.getOpposite();
|
||||
|
||||
float minU = sprite.getMinU();
|
||||
float maxU = sprite.getMaxU();
|
||||
// Flip the v
|
||||
float minV = sprite.getMaxV();
|
||||
float maxV = sprite.getMinV();
|
||||
double sizeU = getValue(size, u);
|
||||
double sizeV = getValue(size, v);
|
||||
// TODO: Look into this more, as it makes tiling of multiple objects not render
|
||||
// properly if they don't fit the full texture.
|
||||
// Example: Mechanical pipes rendering water or lava, makes it relatively easy
|
||||
// to see the texture artifacts
|
||||
for (int uIndex = 0; uIndex < sizeU; uIndex++)
|
||||
{
|
||||
float[] baseUV = new float[]
|
||||
{ minU, maxU, minV, maxV };
|
||||
double addU = 1;
|
||||
// If the size of the texture is greater than the cuboid goes on for then make
|
||||
// sure the texture positions are lowered
|
||||
if (uIndex + addU > sizeU)
|
||||
{
|
||||
addU = sizeU - uIndex;
|
||||
baseUV[U_MAX] = baseUV[U_MIN] + (baseUV[U_MAX] - baseUV[U_MIN]) * (float) addU;
|
||||
}
|
||||
for (int vIndex = 0; vIndex < sizeV; vIndex++)
|
||||
{
|
||||
float[] uv = Arrays.copyOf(baseUV, 4);
|
||||
double addV = 1;
|
||||
if (vIndex + addV > sizeV)
|
||||
{
|
||||
addV = sizeV - vIndex;
|
||||
uv[V_MAX] = uv[V_MIN] + (uv[V_MAX] - uv[V_MIN]) * (float) addV;
|
||||
}
|
||||
float[] xyz = new float[]
|
||||
{ uIndex, (float) (uIndex + addU), vIndex, (float) (vIndex + addV) };
|
||||
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, false, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, false, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, false, false, red, green, blue, alpha, light, overlay);
|
||||
|
||||
renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, false, false, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, false, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, true, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, true, false, red, green, blue, alpha, light, overlay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
matrix.pop();
|
||||
}
|
||||
|
||||
private void renderPoint(Matrix4f matrix4f, Matrix3f normal, IVertexBuilder buffer, Direction face, Axis u, Axis v,
|
||||
float other, float[] uv, float[] xyz, boolean minU, boolean minV, float red, float green, float blue,
|
||||
float alpha, int light, int overlay)
|
||||
{
|
||||
int U_ARRAY = minU ? U_MIN : U_MAX;
|
||||
int V_ARRAY = minV ? V_MIN : V_MAX;
|
||||
Vector3f vertex = withValue(VEC_ZERO, u, xyz[U_ARRAY]);
|
||||
vertex = withValue(vertex, v, xyz[V_ARRAY]);
|
||||
vertex = withValue(vertex, face.getAxis(), other);
|
||||
Vector3i normalForFace = face.getDirectionVec();
|
||||
// TODO: Figure out how and why this works, it gives about the same brightness
|
||||
// as we used to have but I don't understand why/how
|
||||
float adjustment = 2.5F;
|
||||
Vector3f norm = new Vector3f(normalForFace.getX() + adjustment, normalForFace.getY()
|
||||
+ adjustment, normalForFace.getZ() + adjustment);
|
||||
norm.normalize();
|
||||
buffer.pos(matrix4f, vertex.getX(), vertex.getY(), vertex.getZ()).color(red, green, blue, alpha).tex(uv[U_ARRAY], uv[V_ARRAY]).overlay(overlay).lightmap(light).normal(normal, norm.getX(), norm.getY(), norm.getZ()).endVertex();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
package wayoftime.bloodmagic.client.render;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.Direction.AxisDirection;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Matrix3f;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model2D;
|
||||
|
||||
public class RenderResizableQuadrilateral
|
||||
{
|
||||
public static final RenderResizableQuadrilateral INSTANCE = new RenderResizableQuadrilateral();
|
||||
private static final Vector3f VEC_ZERO = new Vector3f(0, 0, 0);
|
||||
private static final int U_MIN = 0;
|
||||
private static final int U_MAX = 1;
|
||||
private static final int V_MIN = 2;
|
||||
private static final int V_MAX = 3;
|
||||
|
||||
protected EntityRendererManager manager = Minecraft.getInstance().getRenderManager();
|
||||
|
||||
private static Vector3f withValue(Vector3f vector, Axis axis, float value)
|
||||
{
|
||||
if (axis == Axis.X)
|
||||
{
|
||||
return new Vector3f(value, vector.getY(), vector.getZ());
|
||||
} else if (axis == Axis.Y)
|
||||
{
|
||||
return new Vector3f(vector.getX(), value, vector.getZ());
|
||||
} else if (axis == Axis.Z)
|
||||
{
|
||||
return new Vector3f(vector.getX(), vector.getY(), value);
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
}
|
||||
|
||||
public static double getValue(Vector3d vector, Axis axis)
|
||||
{
|
||||
if (axis == Axis.X)
|
||||
{
|
||||
return vector.x;
|
||||
} else if (axis == Axis.Y)
|
||||
{
|
||||
return vector.y;
|
||||
} else if (axis == Axis.Z)
|
||||
{
|
||||
return vector.z;
|
||||
}
|
||||
throw new RuntimeException("Was given a null axis! That was probably not intentional, consider this a bug! (Vector = "
|
||||
+ vector + ")");
|
||||
}
|
||||
|
||||
public void renderSquare(Model2D square, MatrixStack matrix, IVertexBuilder buffer, int argb, int light, int overlay)
|
||||
{
|
||||
float red = BloodMagicRenderer.getRed(argb);
|
||||
float green = BloodMagicRenderer.getGreen(argb);
|
||||
float blue = BloodMagicRenderer.getBlue(argb);
|
||||
float alpha = BloodMagicRenderer.getAlpha(argb);
|
||||
Vector3d size = new Vector3d(square.sizeX(), 0, square.sizeY());
|
||||
matrix.push();
|
||||
matrix.translate(square.minX, 0, square.minY);
|
||||
MatrixStack.Entry lastMatrix = matrix.getLast();
|
||||
Matrix4f matrix4f = lastMatrix.getMatrix();
|
||||
Matrix3f normal = lastMatrix.getNormal();
|
||||
Direction face = Direction.UP;
|
||||
// for (Direction face : Direction.values())
|
||||
|
||||
int ordinal = face.ordinal();
|
||||
// TextureAtlasSprite sprite = cube.textures[ordinal];
|
||||
ResourceLocation rl = square.resource;
|
||||
if (rl != null)
|
||||
{
|
||||
// Minecraft.getInstance().textureManager.bindTexture(rl);
|
||||
Axis u = face.getAxis() == Axis.X ? Axis.Z : Axis.X;
|
||||
Axis v = face.getAxis() == Axis.Y ? Axis.Z : Axis.Y;
|
||||
float other = face.getAxisDirection() == AxisDirection.POSITIVE ? (float) getValue(size, face.getAxis())
|
||||
: 0;
|
||||
|
||||
// Swap the face if this is positive: the renderer returns indexes that ALWAYS
|
||||
// are for the negative face, so light it properly this way
|
||||
face = face.getAxisDirection() == AxisDirection.NEGATIVE ? face : face.getOpposite();
|
||||
// Direction opposite = face.getOpposite();
|
||||
|
||||
float minU = 0;
|
||||
float maxU = 1;
|
||||
// Flip the v
|
||||
float minV = 1;
|
||||
float maxV = 0;
|
||||
// float minU = sprite.getMinU();
|
||||
// float maxU = sprite.getMaxU();
|
||||
// // Flip the v
|
||||
// float minV = sprite.getMaxV();
|
||||
// float maxV = sprite.getMinV();
|
||||
double sizeU = getValue(size, u);
|
||||
double sizeV = getValue(size, v);
|
||||
// TODO: Look into this more, as it makes tiling of multiple objects not render
|
||||
// properly if they don't fit the full texture.
|
||||
// Example: Mechanical pipes rendering water or lava, makes it relatively easy
|
||||
// to see the texture artifacts
|
||||
for (int uIndex = 0; uIndex < sizeU; uIndex++)
|
||||
{
|
||||
float[] baseUV = new float[]
|
||||
{ minU, maxU, minV, maxV };
|
||||
double addU = 1;
|
||||
// If the size of the texture is greater than the cuboid goes on for then make
|
||||
// sure the texture positions are lowered
|
||||
if (uIndex + addU > sizeU)
|
||||
{
|
||||
// addU = sizeU - uIndex;
|
||||
baseUV[U_MAX] = baseUV[U_MIN] + (baseUV[U_MAX] - baseUV[U_MIN]) * (float) addU;
|
||||
}
|
||||
for (int vIndex = 0; vIndex < sizeV; vIndex++)
|
||||
{
|
||||
float[] uv = Arrays.copyOf(baseUV, 4);
|
||||
double addV = 1;
|
||||
if (vIndex + addV > sizeV)
|
||||
{
|
||||
// addV = sizeV - vIndex;
|
||||
uv[V_MAX] = uv[V_MIN] + (uv[V_MAX] - uv[V_MIN]) * (float) addV;
|
||||
}
|
||||
float[] xyz = new float[]
|
||||
{ uIndex, (float) (uIndex + addU), vIndex, (float) (vIndex + addV) };
|
||||
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, false, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, true, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, false, true, red, green, blue, alpha, light, overlay);
|
||||
renderPoint(matrix4f, normal, buffer, face, u, v, other, uv, xyz, false, false, red, green, blue, alpha, light, overlay);
|
||||
|
||||
// renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, false, false, red, green, blue, alpha, light, overlay);
|
||||
// renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, false, true, red, green, blue, alpha, light, overlay);
|
||||
// renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, true, true, red, green, blue, alpha, light, overlay);
|
||||
// renderPoint(matrix4f, normal, buffer, opposite, u, v, other, uv, xyz, true, false, red, green, blue, alpha, light, overlay);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
matrix.pop();
|
||||
}
|
||||
|
||||
private void renderPoint(Matrix4f matrix4f, Matrix3f normal, IVertexBuilder buffer, Direction face, Axis u, Axis v, float other, float[] uv, float[] xyz, boolean minU, boolean minV, float red, float green, float blue, float alpha, int light, int overlay)
|
||||
{
|
||||
int U_ARRAY = minU ? U_MIN : U_MAX;
|
||||
int V_ARRAY = minV ? V_MIN : V_MAX;
|
||||
Vector3f vertex = withValue(VEC_ZERO, u, xyz[U_ARRAY]);
|
||||
vertex = withValue(vertex, v, xyz[V_ARRAY]);
|
||||
vertex = withValue(vertex, face.getAxis(), other);
|
||||
Vector3i normalForFace = face.getDirectionVec();
|
||||
// TODO: Figure out how and why this works, it gives about the same brightness
|
||||
// as we used to have but I don't understand why/how
|
||||
float adjustment = 2.5F;
|
||||
Vector3f norm = new Vector3f(normalForFace.getX() + adjustment, normalForFace.getY()
|
||||
+ adjustment, normalForFace.getZ() + adjustment);
|
||||
norm.normalize();
|
||||
buffer.pos(matrix4f, vertex.getX(), vertex.getY(), vertex.getZ()).color(red, green, blue, alpha).tex(uv[U_ARRAY], uv[V_ARRAY]).overlay(overlay).lightmap(light).normal(normal, norm.getX(), norm.getY(), norm.getZ()).endVertex();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package wayoftime.bloodmagic.client.render.alchemyarray;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer;
|
||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model2D;
|
||||
import wayoftime.bloodmagic.client.render.RenderResizableQuadrilateral;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class AlchemyArrayRenderer
|
||||
{
|
||||
public final ResourceLocation arrayResource;
|
||||
|
||||
public AlchemyArrayRenderer()
|
||||
{
|
||||
this(new ResourceLocation("bloodmagic", "textures/models/alchemyarrays/sightsigil.png"));
|
||||
}
|
||||
|
||||
public AlchemyArrayRenderer(ResourceLocation arrayResource)
|
||||
{
|
||||
this.arrayResource = arrayResource;
|
||||
}
|
||||
|
||||
public float getRotation(float craftTime)
|
||||
{
|
||||
float offset = 2;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.5);
|
||||
return modifier * 1f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSecondaryRotation(float craftTime)
|
||||
{
|
||||
float offset = 50;
|
||||
if (craftTime >= offset)
|
||||
{
|
||||
float modifier = (float) Math.pow(craftTime - offset, 1.7);
|
||||
return modifier * 0.5f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getSizeModifier(float craftTime)
|
||||
{
|
||||
if (craftTime >= 150 && craftTime <= 250)
|
||||
{
|
||||
return (200 - craftTime) / 50f;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public float getVerticalOffset(float craftTime)
|
||||
{
|
||||
if (craftTime >= 5)
|
||||
{
|
||||
if (craftTime <= 40)
|
||||
{
|
||||
return (float) (-0.4 + (0.4) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -0.4f;
|
||||
}
|
||||
|
||||
public void renderAt(TileAlchemyArray tileArray, double x, double y, double z, float craftTime, MatrixStack matrixStack, IRenderTypeBuffer renderer, int combinedLightIn, int combinedOverlayIn)
|
||||
{
|
||||
matrixStack.push();
|
||||
|
||||
matrixStack.translate(0.5, 0.5, 0.5);
|
||||
|
||||
float rot = getRotation(craftTime);
|
||||
float secondaryRot = getSecondaryRotation(craftTime);
|
||||
|
||||
float size = 1.0F * getSizeModifier(craftTime);
|
||||
Direction rotation = tileArray.getRotation();
|
||||
|
||||
matrixStack.push();
|
||||
matrixStack.translate(0, getVerticalOffset(craftTime), 0);
|
||||
matrixStack.rotate(new Quaternion(Direction.UP.toVector3f(), -rotation.getHorizontalAngle(), true));
|
||||
|
||||
matrixStack.push();
|
||||
|
||||
matrixStack.rotate(new Quaternion(Direction.UP.toVector3f(), rot, true));
|
||||
matrixStack.rotate(new Quaternion(Direction.NORTH.toVector3f(), secondaryRot, true));
|
||||
matrixStack.rotate(new Quaternion(Direction.EAST.toVector3f(), secondaryRot * 0.45812f, true));
|
||||
|
||||
IVertexBuilder twoDBuffer = renderer.getBuffer(RenderType.getEntityTranslucent(arrayResource));
|
||||
Model2D arrayModel = new BloodMagicRenderer.Model2D();
|
||||
arrayModel.minX = -0.5;
|
||||
arrayModel.maxX = +0.5;
|
||||
arrayModel.minY = -0.5;
|
||||
arrayModel.maxY = +0.5;
|
||||
arrayModel.resource = arrayResource;
|
||||
|
||||
matrixStack.scale(size, size, size);
|
||||
|
||||
RenderResizableQuadrilateral.INSTANCE.renderSquare(arrayModel, matrixStack, twoDBuffer, 0xFFFFFFFF, combinedLightIn, combinedOverlayIn);
|
||||
|
||||
matrixStack.pop();
|
||||
matrixStack.pop();
|
||||
matrixStack.pop();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package wayoftime.bloodmagic.client.render.entity;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.entity.SpriteRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IRendersAsItem;
|
||||
|
||||
public class BloodLightRenderer<T extends Entity & IRendersAsItem> extends SpriteRenderer<T>
|
||||
{
|
||||
public BloodLightRenderer(EntityRendererManager renderManagerIn)
|
||||
{
|
||||
super(renderManagerIn, Minecraft.getInstance().getItemRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn)
|
||||
{
|
||||
super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package wayoftime.bloodmagic.client.render.entity;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererManager;
|
||||
import net.minecraft.client.renderer.entity.SpriteRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IRendersAsItem;
|
||||
|
||||
public class SoulSnareRenderer<T extends Entity & IRendersAsItem> extends SpriteRenderer<T>
|
||||
{
|
||||
public SoulSnareRenderer(EntityRendererManager renderManagerIn)
|
||||
{
|
||||
super(renderManagerIn, Minecraft.getInstance().getItemRenderer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(T entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn)
|
||||
{
|
||||
super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package wayoftime.bloodmagic.client.screens;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
|
||||
public abstract class ScreenBase<T extends Container> extends ContainerScreen<T>
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation(BloodMagic.MODID, "textures/gui/soulforge.png");
|
||||
|
||||
protected final T container;
|
||||
|
||||
public ScreenBase(T container, PlayerInventory playerInventory, ITextComponent title)
|
||||
{
|
||||
super(container, playerInventory, title);
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public ResourceLocation getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
|
||||
this.renderHoveredTooltip(stack, mouseX, mouseY); // @mcp: func_230459_a_ = renderHoveredToolTip
|
||||
// if (mouseX > (guiLeft + 7) && mouseX < (guiLeft + 7) + 18 && mouseY > (guiTop + 7)
|
||||
// && mouseY < (guiTop + 7) + 73)
|
||||
// this.renderTooltip(stack, LanguageMap.getInstance().func_244260_a(Arrays.asList(new TranslationTextComponent("screen.diregoo.energy", MagicHelpers.withSuffix(this.container.getEnergy()), MagicHelpers.withSuffix(this.container.getMaxPower())))), mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
// RenderSystem.color4f(1, 1, 1, 1);
|
||||
// getMinecraft().getTextureManager().bindTexture(getBackground());
|
||||
// this.blit(stack, guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
// int maxEnergy = this.container.getMaxPower(), height = 70;
|
||||
// if (maxEnergy > 0)
|
||||
// {
|
||||
// int remaining = (this.container.getEnergy() * height) / maxEnergy;
|
||||
// this.blit(stack, guiLeft + 8, guiTop + 78 - remaining, 176, 84 - remaining, 16, remaining + 1);
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
protected static TranslationTextComponent getTrans(String key, Object... args)
|
||||
{
|
||||
return new TranslationTextComponent(BloodMagic.MODID + "." + key, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package wayoftime.bloodmagic.client.screens;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.tile.TileSoulForge;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerSoulForge;
|
||||
|
||||
public class ScreenSoulForge extends ScreenBase<ContainerSoulForge>
|
||||
{
|
||||
private static final ResourceLocation background = new ResourceLocation(BloodMagic.MODID, "textures/gui/soulforge.png");
|
||||
public IInventory tileSoulForge;
|
||||
|
||||
public ScreenSoulForge(ContainerSoulForge container, PlayerInventory playerInventory, ITextComponent title)
|
||||
{
|
||||
super(container, playerInventory, title);
|
||||
tileSoulForge = container.tileForge;
|
||||
this.xSize = 176;
|
||||
this.ySize = 205;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
// public
|
||||
|
||||
// public ScreenSoulForge(InventoryPlayer playerInventory, IInventory tileSoulForge)
|
||||
// {
|
||||
// super(new ContainerSoulForge(playerInventory, tileSoulForge));
|
||||
// this.tileSoulForge = tileSoulForge;
|
||||
// this.xSize = 176;
|
||||
// this.ySize = 205;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks)
|
||||
// {
|
||||
// this.drawDefaultBackground();
|
||||
// super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
// this.renderHoveredToolTip(mouseX, mouseY);
|
||||
// }
|
||||
//
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack stack, int mouseX, int mouseY)
|
||||
{
|
||||
this.font.func_243248_b(stack, new TranslationTextComponent("tile.bloodmagic.soulforge.name"), 8, 5, 4210752);
|
||||
this.font.func_243248_b(stack, new TranslationTextComponent("container.inventory"), 8, 111, 4210752);
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack stack, float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
getMinecraft().getTextureManager().bindTexture(background);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.blit(stack, i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int l = this.getCookProgressScaled(90);
|
||||
this.blit(stack, i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l);
|
||||
}
|
||||
|
||||
//
|
||||
public int getCookProgressScaled(int scale)
|
||||
{
|
||||
double progress = ((TileSoulForge) tileSoulForge).getProgressForGui();
|
||||
// if (tileSoulForge != null)
|
||||
// {
|
||||
// System.out.println("Tile is NOT null");
|
||||
// }
|
||||
// double progress = ((float) this.container.data.get(0)) / ((float) this.container.data.get(1));
|
||||
// System.out.println(this.container.data.get(0));
|
||||
return (int) (progress * scale);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package wayoftime.bloodmagic.common.alchemyarray;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public abstract class AlchemyArrayEffect
|
||||
{
|
||||
public abstract AlchemyArrayEffect getNewCopy();
|
||||
|
||||
public abstract void readFromNBT(CompoundNBT compound);
|
||||
|
||||
public abstract void writeToNBT(CompoundNBT compound);
|
||||
|
||||
public abstract boolean update(TileAlchemyArray array, int activeCounter);
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package wayoftime.bloodmagic.common.alchemyarray;
|
||||
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class AlchemyArrayEffectCrafting extends AlchemyArrayEffect
|
||||
{
|
||||
public final ItemStack outputStack;
|
||||
public int tickLimit;
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack)
|
||||
{
|
||||
this(outputStack, 200);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit)
|
||||
{
|
||||
this.outputStack = outputStack;
|
||||
this.tickLimit = tickLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileAlchemyArray tile, int ticksActive)
|
||||
{
|
||||
// TODO: Add recipe rechecking to verify nothing screwy is going on.
|
||||
if (tile.getWorld().isRemote)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ticksActive >= tickLimit)
|
||||
{
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
|
||||
ItemEntity outputEntity = new ItemEntity(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ()
|
||||
+ 0.5, output);
|
||||
|
||||
tile.getWorld().addEntity(outputEntity);
|
||||
// tile.getWorld().spawnEntity(outputEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy()
|
||||
{
|
||||
return new AlchemyArrayEffectCrafting(outputStack, tickLimit);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package wayoftime.bloodmagic.common.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
import wayoftime.bloodmagic.util.Utils;
|
||||
|
||||
public class BlockAlchemyArray extends Block
|
||||
{
|
||||
protected static final VoxelShape BODY = Block.makeCuboidShape(1, 0, 1, 15, 1, 15);
|
||||
|
||||
public BlockAlchemyArray()
|
||||
{
|
||||
super(Properties.create(Material.WOOL).hardnessAndResistance(1.0F, 0).doesNotBlockMovement());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
|
||||
{
|
||||
return BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world)
|
||||
{
|
||||
return new TileAlchemyArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state)
|
||||
{
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult)
|
||||
{
|
||||
TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos);
|
||||
|
||||
if (array == null || player.isSneaking())
|
||||
return ActionResultType.FAIL;
|
||||
|
||||
ItemStack playerItem = player.getHeldItem(hand);
|
||||
|
||||
if (!playerItem.isEmpty())
|
||||
{
|
||||
if (array.getStackInSlot(0).isEmpty())
|
||||
{
|
||||
Utils.insertItemToTile(array, player, 0);
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
} else if (!array.getStackInSlot(0).isEmpty())
|
||||
{
|
||||
Utils.insertItemToTile(array, player, 1);
|
||||
array.attemptCraft();
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
} else
|
||||
{
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
|
||||
{
|
||||
TileAlchemyArray alchemyArray = (TileAlchemyArray) world.getTileEntity(blockPos);
|
||||
if (alchemyArray != null)
|
||||
alchemyArray.dropItems();
|
||||
|
||||
super.onPlayerDestroy(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
if (!state.isIn(newState.getBlock()))
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
if (tileentity instanceof TileAlchemyArray)
|
||||
{
|
||||
((TileAlchemyArray) tileentity).dropItems();
|
||||
worldIn.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
|
||||
super.onReplaced(state, worldIn, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
100
src/main/java/wayoftime/bloodmagic/common/block/BlockAltar.java
Normal file
100
src/main/java/wayoftime/bloodmagic/common/block/BlockAltar.java
Normal file
|
@ -0,0 +1,100 @@
|
|||
package wayoftime.bloodmagic.common.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import wayoftime.bloodmagic.iface.IAltarReader;
|
||||
import wayoftime.bloodmagic.tile.TileAltar;
|
||||
import wayoftime.bloodmagic.util.Utils;
|
||||
|
||||
public class BlockAltar extends Block
|
||||
{
|
||||
protected static final VoxelShape BODY = Block.makeCuboidShape(0, 0, 0, 16, 12, 16);
|
||||
|
||||
public BlockAltar()
|
||||
{
|
||||
super(Properties.create(Material.ROCK).hardnessAndResistance(2.0F, 5.0F).harvestTool(ToolType.PICKAXE).harvestLevel(1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
|
||||
{
|
||||
return BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world)
|
||||
{
|
||||
return new TileAltar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult)
|
||||
{
|
||||
TileAltar altar = (TileAltar) world.getTileEntity(pos);
|
||||
|
||||
if (altar == null || player.isSneaking())
|
||||
return ActionResultType.FAIL;
|
||||
|
||||
ItemStack playerItem = player.getHeldItem(hand);
|
||||
|
||||
if (playerItem.getItem() instanceof IAltarReader)// || playerItem.getItem() instanceof IAltarManipulator)
|
||||
{
|
||||
playerItem.getItem().onItemRightClick(world, player, hand);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if (Utils.insertItemToTile(altar, player))
|
||||
altar.startCycle();
|
||||
else
|
||||
altar.setActive();
|
||||
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
|
||||
{
|
||||
TileAltar altar = (TileAltar) world.getTileEntity(blockPos);
|
||||
if (altar != null)
|
||||
altar.dropItems();
|
||||
|
||||
super.onPlayerDestroy(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving)
|
||||
{
|
||||
if (!state.isIn(newState.getBlock()))
|
||||
{
|
||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
||||
if (tileentity instanceof TileAltar)
|
||||
{
|
||||
((TileAltar) tileentity).dropItems();
|
||||
worldIn.updateComparatorOutputLevel(pos, this);
|
||||
}
|
||||
|
||||
super.onReplaced(state, worldIn, pos, newState, isMoving);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package wayoftime.bloodmagic.common.block;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.particles.RedstoneParticleData;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public class BlockBloodLight extends Block
|
||||
{
|
||||
protected static final VoxelShape BODY = Block.makeCuboidShape(7, 7, 7, 9, 9, 9);
|
||||
|
||||
public BlockBloodLight()
|
||||
{
|
||||
super(Properties.create(Material.WOOL).doesNotBlockMovement().setLightLevel((state) -> {
|
||||
return 15;
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
|
||||
{
|
||||
return BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state)
|
||||
{
|
||||
return BlockRenderType.ENTITYBLOCK_ANIMATED;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void animateTick(BlockState stateIn, World world, BlockPos pos, Random rand)
|
||||
{
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
|
||||
if (rand.nextInt(3) != 0)
|
||||
{
|
||||
world.addParticle(RedstoneParticleData.REDSTONE_DUST, pos.getX() + 0.5D
|
||||
+ rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0);
|
||||
ItemStack heldItem = player.getHeldItem(Hand.MAIN_HAND);
|
||||
|
||||
// if (heldItem.isEmpty() || heldItem.getItem() != RegistrarBloodMagicItems.SIGIL_BLOOD_LIGHT)
|
||||
// return;
|
||||
//
|
||||
// for (int i = 0; i < 8; i++) world.addParticle(RedstoneParticleData.REDSTONE_DUST, pos.getX() + 0.5D
|
||||
// + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package wayoftime.bloodmagic.common.block;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import wayoftime.bloodmagic.block.enums.BloodRuneType;
|
||||
import wayoftime.bloodmagic.iface.IBloodRune;
|
||||
|
||||
public class BlockBloodRune extends Block implements IBloodRune
|
||||
{
|
||||
private final BloodRuneType type;
|
||||
|
||||
public BlockBloodRune(BloodRuneType type)
|
||||
{
|
||||
super(Properties.create(Material.ROCK).hardnessAndResistance(2.0F, 5.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.STONE));
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BloodRuneType getBloodRune(World world, BlockPos pos)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, @Nullable IBlockReader world, List<ITextComponent> tooltip,
|
||||
ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.decoration.safe"));
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package wayoftime.bloodmagic.common.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
import wayoftime.bloodmagic.tile.TileSoulForge;
|
||||
|
||||
public class BlockSoulForge extends Block// implements IBMBlock
|
||||
{
|
||||
protected static final VoxelShape BODY = Block.makeCuboidShape(1, 0, 1, 15, 12, 15);
|
||||
|
||||
public BlockSoulForge()
|
||||
{
|
||||
super(Properties.create(Material.IRON).hardnessAndResistance(2.0F, 5.0F).harvestTool(ToolType.PICKAXE).harvestLevel(1));
|
||||
|
||||
// setTranslationKey(BloodMagic.MODID + ".soulForge");
|
||||
// setHardness(2.0F);
|
||||
// setResistance(5.0F);
|
||||
// setSoundType(SoundType.METAL);
|
||||
// setHarvestLevel("pickaxe", 1);
|
||||
// setCreativeTab(BloodMagic.TAB_BM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
|
||||
{
|
||||
return BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world)
|
||||
{
|
||||
return new TileSoulForge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state)
|
||||
{
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult)
|
||||
{
|
||||
if (world.isRemote)
|
||||
return ActionResultType.SUCCESS;
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (!(tile instanceof TileSoulForge))
|
||||
return ActionResultType.FAIL;
|
||||
|
||||
NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tile, pos);
|
||||
// player.openGui(BloodMagic.instance, Constants.Gui.SOUL_FORGE_GUI, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
|
||||
// {
|
||||
// TileSoulForge tileSoulForge = (TileSoulForge) world.getTileEntity(blockPos);
|
||||
// if (tileSoulForge != null)
|
||||
// tileSoulForge.dropItems();
|
||||
//
|
||||
// super.breakBlock(world, blockPos, blockState);
|
||||
// }
|
||||
|
||||
//
|
||||
// @Override
|
||||
// public BlockItem getItem()
|
||||
// {
|
||||
// return new BlockItem(this);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package wayoftime.bloodmagic.common.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.FlowingFluidBlock;
|
||||
import net.minecraft.fluid.FlowingFluid;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.BucketItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.block.enums.BloodRuneType;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.tile.contailer.ContainerSoulForge;
|
||||
|
||||
public class BloodMagicBlocks
|
||||
{
|
||||
public static final ResourceLocation FLUID_STILL = new ResourceLocation("bloodmagic:block/lifeessencestill");
|
||||
public static final ResourceLocation FLUID_FLOWING = new ResourceLocation("bloodmagic:block/lifeessenceflowing");
|
||||
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, BloodMagic.MODID);
|
||||
public static final DeferredRegister<Block> BASICBLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, BloodMagic.MODID);
|
||||
public static final DeferredRegister<Item> ITEMS = BloodMagicItems.ITEMS;
|
||||
public static final DeferredRegister<Fluid> FLUIDS = DeferredRegister.create(ForgeRegistries.FLUIDS, BloodMagic.MODID);
|
||||
public static final DeferredRegister<ContainerType<?>> CONTAINERS = DeferredRegister.create(ForgeRegistries.CONTAINERS, BloodMagic.MODID);
|
||||
|
||||
// public static final RegistryObject<Block> BLOODSTONE = BASICBLOCKS.register("ruby_block", BloodstoneBlock::new);
|
||||
public static final RegistryObject<Block> SOUL_FORGE = BLOCKS.register("soulforge", BlockSoulForge::new);
|
||||
public static final RegistryObject<Block> ALCHEMY_ARRAY = BLOCKS.register("alchemyarray", BlockAlchemyArray::new);
|
||||
public static final RegistryObject<Block> BLANK_RUNE = BASICBLOCKS.register("blankrune", () -> new BlockBloodRune(BloodRuneType.BLANK));
|
||||
public static final RegistryObject<Block> SPEED_RUNE = BASICBLOCKS.register("speedrune", () -> new BlockBloodRune(BloodRuneType.SPEED));
|
||||
public static final RegistryObject<Block> SACRIFICE_RUNE = BASICBLOCKS.register("sacrificerune", () -> new BlockBloodRune(BloodRuneType.SACRIFICE));
|
||||
public static final RegistryObject<Block> SELF_SACRIFICE_RUNE = BASICBLOCKS.register("selfsacrificerune", () -> new BlockBloodRune(BloodRuneType.SELF_SACRIFICE));
|
||||
public static final RegistryObject<Block> DISPLACEMENT_RUNE = BASICBLOCKS.register("dislocationrune", () -> new BlockBloodRune(BloodRuneType.DISPLACEMENT));
|
||||
public static final RegistryObject<Block> CAPACITY_RUNE = BASICBLOCKS.register("altarcapacityrune", () -> new BlockBloodRune(BloodRuneType.CAPACITY));
|
||||
public static final RegistryObject<Block> AUGMENTED_CAPACITY_RUNE = BASICBLOCKS.register("bettercapacityrune", () -> new BlockBloodRune(BloodRuneType.AUGMENTED_CAPACITY));
|
||||
public static final RegistryObject<Block> ORB_RUNE = BASICBLOCKS.register("orbcapacityrune", () -> new BlockBloodRune(BloodRuneType.ORB));
|
||||
public static final RegistryObject<Block> ACCELERATION_RUNE = BASICBLOCKS.register("accelerationrune", () -> new BlockBloodRune(BloodRuneType.ACCELERATION));
|
||||
public static final RegistryObject<Block> CHARGING_RUNE = BASICBLOCKS.register("chargingrune", () -> new BlockBloodRune(BloodRuneType.CHARGING));
|
||||
|
||||
public static final RegistryObject<Block> BLOOD_ALTAR = BLOCKS.register("altar", () -> new BlockAltar());
|
||||
public static final RegistryObject<Block> BLOOD_LIGHT = BLOCKS.register("bloodlight", () -> new BlockBloodLight());
|
||||
|
||||
private static ForgeFlowingFluid.Properties makeProperties()
|
||||
{
|
||||
return new ForgeFlowingFluid.Properties(LIFE_ESSENCE_FLUID, LIFE_ESSENCE_FLUID_FLOWING, FluidAttributes.builder(FLUID_STILL, FLUID_FLOWING)).bucket(LIFE_ESSENCE_BUCKET).block(LIFE_ESSENCE_BLOCK);
|
||||
}
|
||||
|
||||
public static RegistryObject<FlowingFluid> LIFE_ESSENCE_FLUID = FLUIDS.register("life_essence_fluid", () -> new ForgeFlowingFluid.Source(makeProperties()));
|
||||
public static RegistryObject<FlowingFluid> LIFE_ESSENCE_FLUID_FLOWING = FLUIDS.register("life_essence_fluid_flowing", () -> new ForgeFlowingFluid.Flowing(makeProperties()));
|
||||
|
||||
public static RegistryObject<FlowingFluidBlock> LIFE_ESSENCE_BLOCK = BLOCKS.register("life_essence_block", () -> new FlowingFluidBlock(LIFE_ESSENCE_FLUID, Block.Properties.create(net.minecraft.block.material.Material.WATER).doesNotBlockMovement().hardnessAndResistance(100.0F).noDrops()));
|
||||
public static RegistryObject<Item> LIFE_ESSENCE_BUCKET = ITEMS.register("life_essence_bucket", () -> new BucketItem(LIFE_ESSENCE_FLUID, new Item.Properties().containerItem(Items.BUCKET).maxStackSize(1).group(BloodMagic.TAB)));
|
||||
|
||||
public static final RegistryObject<ContainerType<ContainerSoulForge>> SOUL_FORGE_CONTAINER = CONTAINERS.register("soul_forge_container", () -> IForgeContainerType.create(ContainerSoulForge::new));
|
||||
// public static final RegistryObject<BloodstoneBlock> BLOOD_STONE = registerNoItem("blood_stone", () -> new BloodstoneBlock());
|
||||
//
|
||||
//// private static <T extends Block> RegistryObject<T> register(String name, Supplier<? extends T> sup, Function<RegistryObject<T>, Supplier<? extends Item>> itemCreator)
|
||||
//// {
|
||||
//// RegistryObject<T> ret = registerNoItem(name, sup);
|
||||
//// ITEMS.register(name, itemCreator.apply(ret));
|
||||
//// return ret;
|
||||
//// }
|
||||
//
|
||||
// private static <T extends Block> RegistryObject<T> register(String name, Supplier<? extends T> sup, Function<RegistryObject<T>, Supplier<? extends Item>> itemCreator)
|
||||
// {
|
||||
// RegistryObject<T> ret = registerNoItem(name, sup);
|
||||
// ITEMS.register(name, itemCreator.apply(ret));
|
||||
// return ret;
|
||||
// }
|
||||
//
|
||||
// private static <T extends Block> RegistryObject<T> registerNoItem(String name, Supplier<? extends T> sup)
|
||||
// {
|
||||
// return BLOCKS.register(name, sup);
|
||||
// }
|
||||
|
||||
// private static Supplier<BlockItem> item(final RegistryObject<? extends Block> block, final Supplier<Callable<ItemStackTileEntityRenderer>> renderMethod)
|
||||
// {
|
||||
// return () -> new BlockItem(block.get(), new Item.Properties().group(IronChests.IRONCHESTS_ITEM_GROUP).setISTER(renderMethod));
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package wayoftime.bloodmagic.common.block;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class BloodstoneBlock extends Block
|
||||
{
|
||||
public BloodstoneBlock()
|
||||
{
|
||||
super(Properties.create(Material.ROCK));
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package wayoftime.bloodmagic.common.data;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.data.ShapedRecipeBuilder;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.data.recipe.BaseRecipeProvider;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.core.recipe.IngredientBloodOrb;
|
||||
|
||||
public class GeneratorBaseRecipes extends BaseRecipeProvider
|
||||
{
|
||||
public GeneratorBaseRecipes(DataGenerator gen)
|
||||
{
|
||||
super(gen, BloodMagic.MODID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
addVanillaRecipes(consumer);
|
||||
addBloodOrbRecipes(consumer);
|
||||
}
|
||||
|
||||
private void addVanillaRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.SACRIFICIAL_DAGGER.get()).key('g', Tags.Items.GLASS).key('G', Tags.Items.INGOTS_GOLD).key('i', Tags.Items.INGOTS_IRON).patternLine("ggg").patternLine(" Gg").patternLine("i g").addCriterion("has_glass", hasItem(Items.GLASS)).build(consumer, BloodMagic.rl("sacrificial_dagger"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.BLOOD_ALTAR.get()).key('a', Tags.Items.STONE).key('b', Items.FURNACE).key('c', Tags.Items.INGOTS_GOLD).key('d', BloodMagicItems.MONSTER_SOUL_RAW.get()).patternLine("a a").patternLine("aba").patternLine("cdc").addCriterion("has_will", hasItem(BloodMagicItems.MONSTER_SOUL_RAW.get())).build(consumer, BloodMagic.rl("blood_altar"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SOUL_FORGE.get()).key('s', Tags.Items.STONE).key('g', Tags.Items.INGOTS_GOLD).key('i', Tags.Items.INGOTS_IRON).key('o', Tags.Items.STORAGE_BLOCKS_IRON).patternLine("i i").patternLine("sgs").patternLine("sos").addCriterion("has_gold", hasItem(Items.GOLD_INGOT)).build(consumer, BloodMagic.rl("soul_forge"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicItems.SOUL_SNARE.get(), 4).key('r', Tags.Items.DUSTS_REDSTONE).key('s', Tags.Items.STRING).key('i', Tags.Items.INGOTS_IRON).patternLine("sis").patternLine("iri").patternLine("sis").addCriterion("has_redstone", hasItem(Items.REDSTONE)).build(consumer, BloodMagic.rl("soul_snare"));
|
||||
}
|
||||
|
||||
private void addBloodOrbRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.BLANK_RUNE.get()).key('a', Tags.Items.STONE).key('s', Ingredient.fromItems(BloodMagicItems.SLATE.get())).key('o', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_WEAK.get())).patternLine("aaa").patternLine("sos").patternLine("aaa").addCriterion("has_weak_orb", hasItem(BloodMagicItems.WEAK_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("blood_rune_blank"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SPEED_RUNE.get()).key('a', Tags.Items.STONE).key('b', Ingredient.fromItems(BloodMagicItems.SLATE.get())).key('c', Ingredient.fromItems(Items.SUGAR)).key('d', BloodMagicBlocks.BLANK_RUNE.get()).patternLine("aba").patternLine("cdc").patternLine("aba").addCriterion("has_blank_rune", hasItem(BloodMagicItems.BLANK_RUNE_ITEM.get())).build(consumer, BloodMagic.rl("blood_rune_speed"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SACRIFICE_RUNE.get()).key('a', Tags.Items.STONE).key('b', BloodMagicItems.REINFORCED_SLATE.get()).key('c', Tags.Items.INGOTS_GOLD).key('d', BloodMagicBlocks.BLANK_RUNE.get()).key('e', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_APPRENTICE.get())).patternLine("aba").patternLine("cdc").patternLine("aea").addCriterion("has_apprentice_orb", hasItem(BloodMagicItems.APPRENTICE_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("blood_rune_sacrifice"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SELF_SACRIFICE_RUNE.get()).key('a', Tags.Items.STONE).key('b', Ingredient.fromItems(BloodMagicItems.REINFORCED_SLATE.get())).key('c', Ingredient.fromItems(Items.GLOWSTONE_DUST)).key('d', Ingredient.fromItems(BloodMagicItems.BLANK_RUNE_ITEM.get())).key('e', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_APPRENTICE.get())).patternLine("aba").patternLine("cdc").patternLine("aea").addCriterion("has_apprentice_orb", hasItem(BloodMagicItems.APPRENTICE_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("blood_rune_self_sacrifice"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.CAPACITY_RUNE.get()).key('a', Tags.Items.STONE).key('b', Items.BUCKET).key('c', BloodMagicBlocks.BLANK_RUNE.get()).key('d', BloodMagicItems.IMBUED_SLATE.get()).patternLine("aba").patternLine("bcb").patternLine("ada").addCriterion("has_imbued_slate", hasItem(BloodMagicItems.IMBUED_SLATE.get())).build(consumer, BloodMagic.rl("blood_rune_capacity"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.ORB_RUNE.get()).key('a', Tags.Items.STONE).key('b', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_WEAK.get())).key('c', BloodMagicBlocks.BLANK_RUNE.get()).key('d', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MASTER.get())).patternLine("aba").patternLine("cdc").patternLine("aba").addCriterion("has_master_orb", hasItem(BloodMagicItems.MASTER_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("blood_rune_orb"));
|
||||
ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.CHARGING_RUNE.get()).key('R', Tags.Items.DUSTS_REDSTONE).key('r', BloodMagicBlocks.BLANK_RUNE.get()).key('s', BloodMagicItems.DEMONIC_SLATE.get()).key('e', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_MASTER.get())).key('G', Tags.Items.DUSTS_GLOWSTONE).patternLine("RsR").patternLine("GrG").patternLine("ReR").addCriterion("has_master_orb", hasItem(BloodMagicItems.MASTER_BLOOD_ORB.get())).build(consumer, BloodMagic.rl("blood_rune_charging"));
|
||||
// ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SPEED_RUNE.get()).key('s', Items.GLASS).key('o', Ingredient.fromItems(Items.DIAMOND)).patternLine("sss").patternLine("sos").patternLine("sss").addCriterion("has_diamond", hasItem(Items.DIAMOND)).build(consumer, new ResourceLocation(BloodMagic.MODID, "speed_rune_from_standard"));
|
||||
// ShapedRecipeBuilder.shapedRecipe(BloodMagicBlocks.SPEED_RUNE.get()).key('s', Items.GLASS).key('o', IngredientBloodOrb.fromOrb(BloodMagicItems.ORB_WEAK.get())).patternLine("sss").patternLine("sos").patternLine("sss").addCriterion("has_diamond", hasItem(Items.DIAMOND)).build(consumer, new ResourceLocation(BloodMagic.MODID, "speed_rune_from_orb"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package wayoftime.bloodmagic.common.data;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ConfiguredModel;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
|
||||
public class GeneratorBlockStates extends BlockStateProvider
|
||||
{
|
||||
public GeneratorBlockStates(DataGenerator gen, ExistingFileHelper exFileHelper)
|
||||
{
|
||||
super(gen, BloodMagic.MODID, exFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerStatesAndModels()
|
||||
{
|
||||
// buildCubeAll(BloodMagicBlocks.TARTARICFORGE.get());
|
||||
// buildCubeAll(BloodMagicBlocks.SPEED_RUNE.get());
|
||||
|
||||
for (RegistryObject<Block> block : BloodMagicBlocks.BASICBLOCKS.getEntries())
|
||||
{
|
||||
buildCubeAll(block.get());
|
||||
}
|
||||
|
||||
buildCubeAll(BloodMagicBlocks.BLOOD_LIGHT.get());
|
||||
}
|
||||
|
||||
private void buildCubeAll(Block block)
|
||||
{
|
||||
getVariantBuilder(block).forAllStates(state -> ConfiguredModel.builder().modelFile(cubeAll(block)).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package wayoftime.bloodmagic.common.data;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.client.model.generators.ItemModelBuilder;
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
|
||||
public class GeneratorItemModels extends ItemModelProvider
|
||||
{
|
||||
public GeneratorItemModels(DataGenerator generator, ExistingFileHelper existingFileHelper)
|
||||
{
|
||||
super(generator, BloodMagic.MODID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerModels()
|
||||
{
|
||||
// registerBlockModel(BloodMagicBlocks.TARTARICFORGE.get());
|
||||
// registerBlockModel(BloodMagicBlocks.SPEED_RUNE.get());
|
||||
|
||||
for (RegistryObject<Item> item : BloodMagicItems.BASICITEMS.getEntries())
|
||||
{
|
||||
registerBasicItem(item.get());
|
||||
}
|
||||
|
||||
for (RegistryObject<Block> block : BloodMagicBlocks.BASICBLOCKS.getEntries())
|
||||
{
|
||||
registerBlockModel(block.get());
|
||||
}
|
||||
|
||||
registerToggleableItem(BloodMagicItems.GREEN_GROVE_SIGIL.get());
|
||||
registerToggleableItem(BloodMagicItems.FAST_MINER_SIGIL.get());
|
||||
registerToggleableItem(BloodMagicItems.MAGNETISM_SIGIL.get());
|
||||
registerToggleableItem(BloodMagicItems.ICE_SIGIL.get());
|
||||
registerDemonWillVariantItem(BloodMagicItems.PETTY_GEM.get());
|
||||
registerDemonWillVariantItem(BloodMagicItems.LESSER_GEM.get());
|
||||
registerDemonWillVariantItem(BloodMagicItems.COMMON_GEM.get());
|
||||
registerDemonSword(BloodMagicItems.SENTIENT_SWORD.get());
|
||||
}
|
||||
|
||||
private void registerBlockModel(Block block)
|
||||
{
|
||||
String path = block.getRegistryName().getPath();
|
||||
getBuilder(path).parent(new ModelFile.UncheckedModelFile(modLoc("block/" + path)));
|
||||
}
|
||||
|
||||
private void registerBasicItem(Item item)
|
||||
{
|
||||
String path = item.getRegistryName().getPath();
|
||||
singleTexture(path, mcLoc("item/handheld"), "layer0", modLoc("item/" + path));
|
||||
}
|
||||
|
||||
private void registerToggleableItem(Item item)
|
||||
{
|
||||
String path = item.getRegistryName().getPath();
|
||||
ModelFile activatedFile = singleTexture("item/variants/" + path + "_activated", mcLoc("item/handheld"), "layer0", modLoc("item/" + path + "_activated"));
|
||||
ModelFile deactivatedFile = singleTexture("item/variants/" + path + "_deactivated", mcLoc("item/handheld"), "layer0", modLoc("item/" + path + "_deactivated"));
|
||||
getBuilder(path).override().predicate(BloodMagic.rl("active"), 0).model(deactivatedFile).end().override().predicate(BloodMagic.rl("active"), 1).model(activatedFile).end();
|
||||
}
|
||||
|
||||
private void registerDemonWillVariantItem(Item item)
|
||||
{
|
||||
String path = item.getRegistryName().getPath();
|
||||
ItemModelBuilder builder = getBuilder(path);
|
||||
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
String name = "";
|
||||
if (type.ordinal() != 0)
|
||||
{
|
||||
name = "_" + type.name().toLowerCase();
|
||||
}
|
||||
ModelFile willFile = singleTexture("item/variants/" + path + name, mcLoc("item/handheld"), "layer0", modLoc("item/" + path + name));
|
||||
builder = builder.override().predicate(BloodMagic.rl("type"), type.ordinal()).model(willFile).end();
|
||||
}
|
||||
}
|
||||
|
||||
private void registerDemonSword(Item item)
|
||||
{
|
||||
String path = item.getRegistryName().getPath();
|
||||
ItemModelBuilder builder = getBuilder(path);
|
||||
|
||||
for (int i = 0; i <= 1; i++)
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
String name = i == 0 ? "_deactivated" : "_activated";
|
||||
if (type.ordinal() != 0)
|
||||
{
|
||||
name = "_" + type.name().toLowerCase() + name;
|
||||
}
|
||||
ModelFile willFile = singleTexture("item/variants/" + path + name, mcLoc("item/handheld"), "layer0", modLoc("item/" + path + name));
|
||||
builder = builder.override().predicate(BloodMagic.rl("type"), type.ordinal()).predicate(BloodMagic.rl("active"), i).model(willFile).end();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
package wayoftime.bloodmagic.common.data;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraftforge.common.data.LanguageProvider;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
|
||||
public class GeneratorLanguage extends LanguageProvider
|
||||
{
|
||||
public GeneratorLanguage(DataGenerator gen)
|
||||
{
|
||||
super(gen, BloodMagic.MODID, "en_us");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTranslations()
|
||||
{
|
||||
// Creative Tab
|
||||
add("itemGroup.bloodmagic.creativeTab", "Blood Magic");
|
||||
|
||||
// Tile Entitites
|
||||
add("tile.bloodmagic.soulforge.name", "Hellfire Forge");
|
||||
|
||||
// Blood Orb tooltips
|
||||
add("tooltip.bloodmagic.extraInfo", "&9-Hold shift for more info-");
|
||||
add("tooltip.bloodmagic.orb.desc", "Stores raw Life Essence");
|
||||
add("tooltip.bloodmagic.orb.owner", "Added by: %s");
|
||||
add("tooltip.bloodmagic.currentOwner", "Current owner: %s");
|
||||
add("tooltip.bloodmagic.currentTier", "Current tier: %d");
|
||||
add("tooltip.bloodmagic.config.disabled", "Currently disabled in the Config");
|
||||
add("tooltip.bloodmagic.tier", "Tier %d");
|
||||
|
||||
// Sigil tooltips
|
||||
add("tooltip.bloodmagic.sigil.divination.desc", "Peer into the soul");
|
||||
add("tooltip.bloodmagic.sigil.divination.otherNetwork", "Peering into the soul of %s");
|
||||
add("tooltip.bloodmagic.sigil.divination.currentAltarTier", "Current Tier: %d");
|
||||
add("tooltip.bloodmagic.sigil.divination.currentEssence", "Current Essence: %d LP");
|
||||
add("tooltip.bloodmagic.sigil.divination.currentAltarCapacity", "Current Capacity: %d LP");
|
||||
add("tooltip.bloodmagic.sigil.divination.currentTranquility", "Current Tranquility: %d");
|
||||
// add("tooltip.bloodmagic.sigil.divination.currentInversion", "Current Inversion: %d");
|
||||
add("tooltip.bloodmagic.sigil.divination.currentBonus", "Current Bonus: +%d%%");
|
||||
|
||||
add("tooltip.bloodmagic.decoration.safe", "Safe for decoration");
|
||||
add("tooltip.bloodmagic.decoration.notSafe", "Dangerous for decoration");
|
||||
|
||||
// General Tooltips
|
||||
add("tooltip.bloodmagic.arcaneAshes", "Ashes used to draw an alchemy circle");
|
||||
add("tooltip.bloodmagic.will", "Will Quality: %s");
|
||||
add("tooltip.bloodmagic.sentientSword.desc", "Uses demon will to unleash its full potential.");
|
||||
add("tooltip.bloodmagic.sentientAxe.desc", "Uses demon will to unleash its full potential.");
|
||||
add("tooltip.bloodmagic.sentientPickaxe.desc", "Uses demon will to unleash its full potential.");
|
||||
add("tooltip.bloodmagic.sentientShovel.desc", "Uses demon will to unleash its full potential.");
|
||||
add("tooltip.bloodmagic.soulGem.petty", "A gem used to contain a little will");
|
||||
add("tooltip.bloodmagic.soulGem.lesser", "A gem used to contain some will");
|
||||
add("tooltip.bloodmagic.soulGem.common", "A gem used to contain more will");
|
||||
add("tooltip.bloodmagic.soulGem.greater", "A gem used to contain a greater amount of will");
|
||||
add("tooltip.bloodmagic.soulGem.grand", "A gem used to contain a large amount of will");
|
||||
add("tooltip.bloodmagic.soulSnare.desc", "Throw at a monster and then kill them to obtain their demonic will");
|
||||
|
||||
add("tooltip.bloodmagic.currentType.default", "Contains: Raw Will");
|
||||
add("tooltip.bloodmagic.currentType.corrosive", "Contains: Corrosive Will");
|
||||
add("tooltip.bloodmagic.currentType.destructive", "Contains: Destructive Will");
|
||||
add("tooltip.bloodmagic.currentType.vengeful", "Contains: Vengeful Will");
|
||||
add("tooltip.bloodmagic.currentType.steadfast", "Contains: Steadfast Will");
|
||||
|
||||
add("tooltip.bloodmagic.currentBaseType.default", "Raw");
|
||||
add("tooltip.bloodmagic.currentBaseType.corrosive", "Corrosive");
|
||||
add("tooltip.bloodmagic.currentBaseType.destructive", "Destructive");
|
||||
add("tooltip.bloodmagic.currentBaseType.vengeful", "Vengeful");
|
||||
add("tooltip.bloodmagic.currentBaseType.steadfast", "Steadfast");
|
||||
add("tooltip.bloodmagic.sacrificialdagger.desc", "Just a prick of the finger will suffice...");
|
||||
add("tooltip.bloodmagic.slate.desc", "Infused stone inside of a Blood Altar");
|
||||
|
||||
add("tooltip.bloodmagic.sigil.water.desc", "Infinite water, anyone?");
|
||||
add("tooltip.bloodmagic.sigil.lava.desc", "HOT! DO NOT EAT");
|
||||
add("tooltip.bloodmagic.sigil.void.desc", "Better than a Swiffer®!");
|
||||
add("tooltip.bloodmagic.sigil.greengrove.desc", "Environmentally friendly");
|
||||
add("tooltip.bloodmagic.sigil.magnetism.desc", "I have a very magnetic personality");
|
||||
add("tooltip.bloodmagic.sigil.fastminer.desc", "Keep mining, and mining...");
|
||||
add("tooltip.bloodmagic.sigil.air.desc", "I feel lighter already...");
|
||||
add("tooltip.bloodmagic.sigil.bloodlight.desc", "I see a light!");
|
||||
|
||||
add("itemGroup.bloodmagictab", "Blood Magic");
|
||||
|
||||
// Block names
|
||||
addBlock(BloodMagicBlocks.BLANK_RUNE, "Blank Rune");
|
||||
addBlock(BloodMagicBlocks.SPEED_RUNE, "Speed Rune");
|
||||
addBlock(BloodMagicBlocks.SACRIFICE_RUNE, "Rune of Sacrifice");
|
||||
addBlock(BloodMagicBlocks.SELF_SACRIFICE_RUNE, "Rune of Self Sacrifice");
|
||||
addBlock(BloodMagicBlocks.DISPLACEMENT_RUNE, "DisplacementRune");
|
||||
addBlock(BloodMagicBlocks.CAPACITY_RUNE, "Rune of Capacity");
|
||||
addBlock(BloodMagicBlocks.AUGMENTED_CAPACITY_RUNE, "Rune of Augmented Capacity");
|
||||
addBlock(BloodMagicBlocks.ORB_RUNE, "Rune of the Orb");
|
||||
addBlock(BloodMagicBlocks.ACCELERATION_RUNE, "Acceleration Rune");
|
||||
addBlock(BloodMagicBlocks.CHARGING_RUNE, "Charging Rune");
|
||||
addBlock(BloodMagicBlocks.BLOOD_ALTAR, "Blood Altar");
|
||||
addBlock(BloodMagicBlocks.SOUL_FORGE, "Hellfire Forge");
|
||||
|
||||
// Item names
|
||||
addItem(BloodMagicItems.WEAK_BLOOD_ORB, "Weak Blood Orb");
|
||||
addItem(BloodMagicItems.APPRENTICE_BLOOD_ORB, "Apprentice Blood Orb");
|
||||
addItem(BloodMagicItems.MAGICIAN_BLOOD_ORB, "Magician Blood Orb");
|
||||
addItem(BloodMagicItems.MASTER_BLOOD_ORB, "Master Blood Orb");
|
||||
addItem(BloodMagicItems.DIVINATION_SIGIL, "Divination Sigil");
|
||||
addItem(BloodMagicItems.WATER_SIGIL, "Water Sigil");
|
||||
addItem(BloodMagicItems.LAVA_SIGIL, "Lava Sigil");
|
||||
addItem(BloodMagicItems.VOID_SIGIL, "Void Sigil");
|
||||
addItem(BloodMagicItems.GREEN_GROVE_SIGIL, "Sigil of the Green Grove");
|
||||
addItem(BloodMagicItems.FAST_MINER_SIGIL, "Sigil of the Fast Miner");
|
||||
addItem(BloodMagicItems.MAGNETISM_SIGIL, "Sigil of Magnetism");
|
||||
addItem(BloodMagicItems.ICE_SIGIL, "Sigil of the Frozen Lake");
|
||||
addItem(BloodMagicItems.AIR_SIGIL, "Air Sigil");
|
||||
addItem(BloodMagicItems.BLOOD_LIGHT_SIGIL, "Sigil of the Blood Lamp");
|
||||
|
||||
addItem(BloodMagicBlocks.LIFE_ESSENCE_BUCKET, "Bucket of Life");
|
||||
addItem(BloodMagicItems.ARCANE_ASHES, "Arcane Ashes");
|
||||
addItem(BloodMagicItems.SLATE, "Blank Slate");
|
||||
addItem(BloodMagicItems.REINFORCED_SLATE, "Reinforced Slate");
|
||||
addItem(BloodMagicItems.IMBUED_SLATE, "Imbued Slate");
|
||||
addItem(BloodMagicItems.DEMONIC_SLATE, "Demonic Slate");
|
||||
addItem(BloodMagicItems.ETHEREAL_SLATE, "Ethereal Slate");
|
||||
|
||||
addItem(BloodMagicItems.DAGGER_OF_SACRIFICE, "Dagger of Sacrifice");
|
||||
addItem(BloodMagicItems.SACRIFICIAL_DAGGER, "Sacrificial Knife");
|
||||
|
||||
addItem(BloodMagicItems.REAGENT_WATER, "Water Reagent");
|
||||
addItem(BloodMagicItems.REAGENT_LAVA, "Lava Reagent");
|
||||
addItem(BloodMagicItems.REAGENT_FAST_MINER, "Mining Reagent");
|
||||
addItem(BloodMagicItems.REAGENT_GROWTH, "Growth Reagent");
|
||||
addItem(BloodMagicItems.REAGENT_VOID, "Void Reagent");
|
||||
addItem(BloodMagicItems.REAGENT_MAGNETISM, "Magnetism Reagent");
|
||||
addItem(BloodMagicItems.REAGENT_AIR, "Air Reagent");
|
||||
addItem(BloodMagicItems.REAGENT_BLOOD_LIGHT, "Blood Lamp Reagent");
|
||||
|
||||
addItem(BloodMagicItems.PETTY_GEM, "Petty Tartaric Gem");
|
||||
addItem(BloodMagicItems.LESSER_GEM, "Lesser Tartaric Gem");
|
||||
addItem(BloodMagicItems.COMMON_GEM, "Common Tartaric Gem");
|
||||
addItem(BloodMagicItems.MONSTER_SOUL_RAW, "Demon Will");
|
||||
addItem(BloodMagicItems.MONSTER_SOUL_CORROSIVE, "Demon Will");
|
||||
addItem(BloodMagicItems.MONSTER_SOUL_DESTRUCTIVE, "Demon Will");
|
||||
addItem(BloodMagicItems.MONSTER_SOUL_STEADFAST, "Demon Will");
|
||||
addItem(BloodMagicItems.MONSTER_SOUL_VENGEFUL, "Demon Will");
|
||||
addItem(BloodMagicItems.SOUL_SNARE, "Soul Snare");
|
||||
addItem(BloodMagicItems.SENTIENT_SWORD, "Sentient Sword");
|
||||
|
||||
// addItem(BloodMagicItems , "");
|
||||
|
||||
// JEI
|
||||
add("jei.bloodmagic.recipe.minimumsouls", "Minimum: %s Will");
|
||||
add("jei.bloodmagic.recipe.soulsdrained", "Drained: %s Will");
|
||||
add("jei.bloodmagic.recipe.requiredlp", "LP: %d");
|
||||
add("jei.bloodmagic.recipe.requiredtier", "Tier: %d");
|
||||
add("jei.bloodmagic.recipe.consumptionrate", "Consumption: %s LP/t");
|
||||
add("jei.bloodmagic.recipe.drainrate", "Drain: %s LP/t");
|
||||
|
||||
add("jei.bloodmagic.recipe.altar", "Blood Altar");
|
||||
add("jei.bloodmagic.recipe.soulforge", "Hellfire Forge");
|
||||
add("jei.bloodmagic.recipe.alchemyarraycrafting", "Alchemy Array");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package wayoftime.bloodmagic.common.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.LootTableProvider;
|
||||
import net.minecraft.data.loot.BlockLootTables;
|
||||
import net.minecraft.loot.LootParameterSet;
|
||||
import net.minecraft.loot.LootParameterSets;
|
||||
import net.minecraft.loot.LootPool;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import net.minecraft.loot.LootTableManager;
|
||||
import net.minecraft.loot.ValidationTracker;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
|
||||
public class GeneratorLootTable extends LootTableProvider
|
||||
{
|
||||
public GeneratorLootTable(DataGenerator dataGeneratorIn)
|
||||
{
|
||||
super(dataGeneratorIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootParameterSet>> getTables()
|
||||
{
|
||||
return ImmutableList.of(Pair.of(Blocks::new, LootParameterSets.BLOCK));
|
||||
}
|
||||
|
||||
private static class Blocks extends BlockLootTables
|
||||
{
|
||||
@Override
|
||||
protected void addTables()
|
||||
{
|
||||
for (RegistryObject<Block> block : BloodMagicBlocks.BASICBLOCKS.getEntries())
|
||||
{
|
||||
this.registerDropSelfLootTable(block.get());
|
||||
}
|
||||
|
||||
this.registerDropSelfLootTable(BloodMagicBlocks.BLOOD_ALTAR.get());
|
||||
registerNoDropLootTable(BloodMagicBlocks.ALCHEMY_ARRAY.get());
|
||||
registerNoDropLootTable(BloodMagicBlocks.BLOOD_LIGHT.get());
|
||||
this.registerDropSelfLootTable(BloodMagicBlocks.SOUL_FORGE.get());
|
||||
|
||||
// LootPool.Builder builder = LootPool.builder().name(ModBlocks.GOO_BLOCK.get().getRegistryName().toString()).rolls(ConstantRange.of(1)).acceptCondition(SurvivesExplosion.builder()).addEntry(ItemLootEntry.builder(ModItems.GOO_RESIDUE.get()));
|
||||
// this.registerLootTable(ModBlocks.GOO_BLOCK.get(), LootTable.builder().addLootPool(builder));
|
||||
//
|
||||
// LootPool.Builder builder2 = LootPool.builder().name(ModBlocks.GOO_BLOCK_TERRAIN.get().getRegistryName().toString()).rolls(ConstantRange.of(1)).acceptCondition(SurvivesExplosion.builder()).addEntry(ItemLootEntry.builder(ModItems.GOO_RESIDUE.get()));
|
||||
// this.registerLootTable(ModBlocks.GOO_BLOCK_TERRAIN.get(), LootTable.builder().addLootPool(builder2));
|
||||
//
|
||||
// this.registerDropSelfLootTable(ModBlocks.GOO_BLOCK_POISON.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.GNT_BLOCK_T1.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.GNT_BLOCK_T2.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.GNT_BLOCK_T3.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.GNT_BLOCK_T4.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.TURRET_BLOCK.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.ZAPPER_TURRET_BLOCK.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.ANTI_GOO_BEACON.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.ANTI_GOO_FIELD_GEN.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.GOOLIMINATIONFIELDGEN.get());
|
||||
// this.registerDropSelfLootTable(ModBlocks.GOO_DETECTOR.get());
|
||||
// this.registerDropping(ModBlocks.GOO_RENDER.get(), ItemStack.EMPTY.getItem());
|
||||
// // this.registerDropping(ModBlocks.GOO_RENDER_BURST.get(),
|
||||
// // ItemStack.EMPTY.getItem());
|
||||
// this.registerDropping(ModBlocks.GOO_RENDER_TERRAIN.get(), ItemStack.EMPTY.getItem());
|
||||
|
||||
}
|
||||
|
||||
private void registerNoDropLootTable(Block block)
|
||||
{
|
||||
LootPool.Builder builder = LootPool.builder().name(block.getRegistryName().toString());
|
||||
this.registerLootTable(block, LootTable.builder().addLootPool(builder));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Block> getKnownBlocks()
|
||||
{
|
||||
return ForgeRegistries.BLOCKS.getValues().stream().filter(b -> b.getRegistryName().getNamespace().equals(BloodMagic.MODID)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validate(Map<ResourceLocation, LootTable> map, ValidationTracker validationtracker)
|
||||
{
|
||||
map.forEach((name, table) -> LootTableManager.validateLootTable(validationtracker, name, table));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package wayoftime.bloodmagic.common.data.recipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.data.RecipeProvider;
|
||||
import wayoftime.bloodmagic.common.recipe.ISubRecipeProvider;
|
||||
|
||||
public abstract class BaseRecipeProvider extends RecipeProvider
|
||||
{
|
||||
private final String modid;
|
||||
|
||||
public BaseRecipeProvider(DataGenerator gen, String modid)
|
||||
{
|
||||
super(gen);
|
||||
this.modid = modid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return super.getName() + modid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
getSubRecipeProviders().forEach(subRecipeProvider -> subRecipeProvider.addRecipes(consumer));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the sub/offloaded recipe providers that this recipe provider has.
|
||||
*
|
||||
* @implNote This is only called once per provider so there is no need to bother
|
||||
* caching the list that this returns
|
||||
*/
|
||||
protected List<ISubRecipeProvider> getSubRecipeProviders()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package wayoftime.bloodmagic.common.data.recipe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementRewards;
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
import net.minecraft.advancements.IRequirementsStrategy;
|
||||
import net.minecraft.advancements.criterion.RecipeUnlockedTrigger;
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
|
||||
public abstract class BloodMagicRecipeBuilder<BUILDER extends BloodMagicRecipeBuilder<BUILDER>>
|
||||
{
|
||||
|
||||
protected static ResourceLocation bmSerializer(String name)
|
||||
{
|
||||
return new ResourceLocation(BloodMagic.MODID, name);
|
||||
}
|
||||
|
||||
protected final List<ICondition> conditions = new ArrayList<>();
|
||||
protected final Advancement.Builder advancementBuilder = Advancement.Builder.builder();
|
||||
protected final ResourceLocation serializerName;
|
||||
|
||||
protected BloodMagicRecipeBuilder(ResourceLocation serializerName)
|
||||
{
|
||||
this.serializerName = serializerName;
|
||||
}
|
||||
|
||||
public BUILDER addCriterion(RecipeCriterion criterion)
|
||||
{
|
||||
return addCriterion(criterion.name, criterion.criterion);
|
||||
}
|
||||
|
||||
public BUILDER addCriterion(String name, ICriterionInstance criterion)
|
||||
{
|
||||
advancementBuilder.withCriterion(name, criterion);
|
||||
return (BUILDER) this;
|
||||
}
|
||||
|
||||
public BUILDER addCondition(ICondition condition)
|
||||
{
|
||||
conditions.add(condition);
|
||||
return (BUILDER) this;
|
||||
}
|
||||
|
||||
protected boolean hasCriteria()
|
||||
{
|
||||
return !advancementBuilder.getCriteria().isEmpty();
|
||||
}
|
||||
|
||||
protected abstract RecipeResult getResult(ResourceLocation id);
|
||||
|
||||
protected void validate(ResourceLocation id)
|
||||
{
|
||||
}
|
||||
|
||||
public void build(Consumer<IFinishedRecipe> consumer, ResourceLocation id)
|
||||
{
|
||||
validate(id);
|
||||
if (hasCriteria())
|
||||
{
|
||||
// If there is a way to "unlock" this recipe then add an advancement with the
|
||||
// criteria
|
||||
advancementBuilder.withParentId(new ResourceLocation("recipes/root")).withCriterion("has_the_recipe", RecipeUnlockedTrigger.create(id)).withRewards(AdvancementRewards.Builder.recipe(id)).withRequirementsStrategy(IRequirementsStrategy.OR);
|
||||
}
|
||||
consumer.accept(getResult(id));
|
||||
}
|
||||
|
||||
protected abstract class RecipeResult implements IFinishedRecipe
|
||||
{
|
||||
|
||||
private final ResourceLocation id;
|
||||
|
||||
public RecipeResult(ResourceLocation id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getRecipeJson()
|
||||
{
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty(Constants.JSON.TYPE, serializerName.toString());
|
||||
if (!conditions.isEmpty())
|
||||
{
|
||||
JsonArray conditionsArray = new JsonArray();
|
||||
for (ICondition condition : conditions)
|
||||
{
|
||||
conditionsArray.add(CraftingHelper.serialize(condition));
|
||||
}
|
||||
jsonObject.add(Constants.JSON.CONDITIONS, conditionsArray);
|
||||
}
|
||||
this.serialize(jsonObject);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer()
|
||||
{
|
||||
// Note: This may be null if something is screwed up but this method isn't
|
||||
// actually used so it shouldn't matter
|
||||
// and in fact it will probably be null if only the API is included. But again,
|
||||
// as we manually just use
|
||||
// the serializer's name this should not effect us
|
||||
return ForgeRegistries.RECIPE_SERIALIZERS.getValue(serializerName);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getID()
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JsonObject getAdvancementJson()
|
||||
{
|
||||
return hasCriteria() ? advancementBuilder.serialize() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getAdvancementID()
|
||||
{
|
||||
return new ResourceLocation(id.getNamespace(), "recipes/" + id.getPath());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package wayoftime.bloodmagic.common.data.recipe;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.recipe.AlchemyArrayRecipeProvider;
|
||||
import wayoftime.bloodmagic.common.recipe.BloodAltarRecipeProvider;
|
||||
import wayoftime.bloodmagic.common.recipe.ISubRecipeProvider;
|
||||
import wayoftime.bloodmagic.common.recipe.TartaricForgeRecipeProvider;
|
||||
|
||||
public class BloodMagicRecipeProvider extends BaseRecipeProvider
|
||||
{
|
||||
public BloodMagicRecipeProvider(DataGenerator gen)
|
||||
{
|
||||
super(gen, BloodMagic.MODID);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ISubRecipeProvider> getSubRecipeProviders()
|
||||
{
|
||||
return Arrays.asList(new BloodAltarRecipeProvider(), new AlchemyArrayRecipeProvider(), new TartaricForgeRecipeProvider());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package wayoftime.bloodmagic.common.data.recipe;
|
||||
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
|
||||
public class RecipeCriterion
|
||||
{
|
||||
public final String name;
|
||||
public final ICriterionInstance criterion;
|
||||
|
||||
private RecipeCriterion(String name, ICriterionInstance criterion)
|
||||
{
|
||||
this.name = name;
|
||||
this.criterion = criterion;
|
||||
}
|
||||
|
||||
public static RecipeCriterion of(String name, ICriterionInstance criterion)
|
||||
{
|
||||
return new RecipeCriterion(name, criterion);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package wayoftime.bloodmagic.common.data.recipe.builder;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.api.SerializerHelper;
|
||||
import wayoftime.bloodmagic.common.data.recipe.BloodMagicRecipeBuilder;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
|
||||
public class AlchemyArrayRecipeBuilder extends BloodMagicRecipeBuilder<AlchemyArrayRecipeBuilder>
|
||||
{
|
||||
private final ResourceLocation texture;
|
||||
private final Ingredient baseInput;
|
||||
private final Ingredient addedInput;
|
||||
private final ItemStack output;
|
||||
|
||||
protected AlchemyArrayRecipeBuilder(ResourceLocation texture, Ingredient baseInput, Ingredient addedInput, ItemStack output)
|
||||
{
|
||||
super(bmSerializer("array"));
|
||||
this.texture = texture;
|
||||
this.baseInput = baseInput;
|
||||
this.addedInput = addedInput;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
public static AlchemyArrayRecipeBuilder array(ResourceLocation texture, Ingredient baseInput, Ingredient addedInput, ItemStack output)
|
||||
{
|
||||
return new AlchemyArrayRecipeBuilder(texture, baseInput, addedInput, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AlchemyArrayRecipeResult getResult(ResourceLocation id)
|
||||
{
|
||||
return new AlchemyArrayRecipeResult(id);
|
||||
}
|
||||
|
||||
public class AlchemyArrayRecipeResult extends RecipeResult
|
||||
{
|
||||
protected AlchemyArrayRecipeResult(ResourceLocation id)
|
||||
{
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@Nonnull JsonObject json)
|
||||
{
|
||||
json.addProperty(Constants.JSON.TEXTURE, texture.toString());
|
||||
// JSONUtils.getString(json, );
|
||||
json.add(Constants.JSON.BASEINPUT, baseInput.serialize());
|
||||
json.add(Constants.JSON.ADDEDINPUT, addedInput.serialize());
|
||||
json.add(Constants.JSON.OUTPUT, SerializerHelper.serializeItemStack(output));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package wayoftime.bloodmagic.common.data.recipe.builder;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.api.SerializerHelper;
|
||||
import wayoftime.bloodmagic.common.data.recipe.BloodMagicRecipeBuilder;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
|
||||
public class BloodAltarRecipeBuilder extends BloodMagicRecipeBuilder<BloodAltarRecipeBuilder>
|
||||
{
|
||||
private final Ingredient input;
|
||||
private final ItemStack output;
|
||||
private final int minimumTier;
|
||||
private final int syphon;
|
||||
private final int consumeRate;
|
||||
private final int drainRate;
|
||||
|
||||
protected BloodAltarRecipeBuilder(Ingredient input, ItemStack output, int minimumTier, int syphon, int consumeRate, int drainRate)
|
||||
{
|
||||
super(bmSerializer("altar"));
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.minimumTier = minimumTier;
|
||||
this.syphon = syphon;
|
||||
this.consumeRate = consumeRate;
|
||||
this.drainRate = drainRate;
|
||||
}
|
||||
|
||||
public static BloodAltarRecipeBuilder altar(Ingredient input, ItemStack output, int minimumTier, int syphon, int consumeRate, int drainRate)
|
||||
{
|
||||
return new BloodAltarRecipeBuilder(input, output, minimumTier, syphon, consumeRate, drainRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BloodAltarRecipeResult getResult(ResourceLocation id)
|
||||
{
|
||||
return new BloodAltarRecipeResult(id);
|
||||
}
|
||||
|
||||
public class BloodAltarRecipeResult extends RecipeResult
|
||||
{
|
||||
protected BloodAltarRecipeResult(ResourceLocation id)
|
||||
{
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@Nonnull JsonObject json)
|
||||
{
|
||||
json.add(Constants.JSON.INPUT, input.serialize());
|
||||
json.add(Constants.JSON.OUTPUT, SerializerHelper.serializeItemStack(output));
|
||||
json.addProperty(Constants.JSON.ALTAR_TIER, minimumTier);
|
||||
json.addProperty(Constants.JSON.ALTAR_SYPHON, syphon);
|
||||
json.addProperty(Constants.JSON.ALTAR_CONSUMPTION_RATE, consumeRate);
|
||||
json.addProperty(Constants.JSON.ALTAR_DRAIN_RATE, drainRate);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package wayoftime.bloodmagic.common.data.recipe.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.api.SerializerHelper;
|
||||
import wayoftime.bloodmagic.common.data.recipe.BloodMagicRecipeBuilder;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
|
||||
public class TartaricForgeRecipeBuilder extends BloodMagicRecipeBuilder<TartaricForgeRecipeBuilder>
|
||||
{
|
||||
private final List<Ingredient> input;
|
||||
private final ItemStack output;
|
||||
private final double minimumSouls;
|
||||
private final double soulDrain;
|
||||
|
||||
protected TartaricForgeRecipeBuilder(List<Ingredient> input, ItemStack output, double minimumSouls, double soulDrain)
|
||||
{
|
||||
super(bmSerializer("soulforge"));
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.minimumSouls = minimumSouls;
|
||||
this.soulDrain = soulDrain;
|
||||
}
|
||||
|
||||
public static TartaricForgeRecipeBuilder tartaricForge(List<Ingredient> input, ItemStack output, double minimumSouls, double soulDrain)
|
||||
{
|
||||
return new TartaricForgeRecipeBuilder(input, output, minimumSouls, soulDrain);
|
||||
}
|
||||
|
||||
public static TartaricForgeRecipeBuilder tartaricForge(ItemStack output, double minimumSouls, double soulDrain, Ingredient... inputArray)
|
||||
{
|
||||
List<Ingredient> inputList = new ArrayList<Ingredient>();
|
||||
for (int i = 0; i < inputArray.length; i++)
|
||||
{
|
||||
inputList.add(inputArray[i]);
|
||||
}
|
||||
return new TartaricForgeRecipeBuilder(inputList, output, minimumSouls, soulDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TartaricForgeRecipeResult getResult(ResourceLocation id)
|
||||
{
|
||||
return new TartaricForgeRecipeResult(id);
|
||||
}
|
||||
|
||||
public class TartaricForgeRecipeResult extends RecipeResult
|
||||
{
|
||||
protected TartaricForgeRecipeResult(ResourceLocation id)
|
||||
{
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(@Nonnull JsonObject json)
|
||||
{
|
||||
for (int i = 0; i < Math.min(input.size(), 4); i++)
|
||||
{
|
||||
json.add(Constants.JSON.INPUT + i, input.get(i).serialize());
|
||||
}
|
||||
|
||||
json.add(Constants.JSON.OUTPUT, SerializerHelper.serializeItemStack(output));
|
||||
json.addProperty(Constants.JSON.TARTARIC_MINIMUM, (float) minimumSouls);
|
||||
json.addProperty(Constants.JSON.TARTARIC_DRAIN, (float) soulDrain);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilAir;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilBloodLight;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilDivination;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilFastMiner;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilFrost;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilGreenGrove;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilLava;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilMagnetism;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilVoid;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilWater;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemMonsterSoul;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemSentientSword;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemSoulGem;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemSoulSnare;
|
||||
import wayoftime.bloodmagic.common.registration.impl.BloodOrbDeferredRegister;
|
||||
import wayoftime.bloodmagic.common.registration.impl.BloodOrbRegistryObject;
|
||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
|
||||
public class BloodMagicItems
|
||||
{
|
||||
// public static Item.ToolMaterial SOUL_TOOL_MATERIAL = EnumHelper.addToolMaterial("demonic", 4, 520, 7, 8, 50);
|
||||
// public static final BloodOrb WEAK_ORB_INSTANCE = new BloodOrb(new ResourceLocation(BloodMagic.MODID, "weakbloodorb"), 0, 5000, 10);
|
||||
public static final BloodOrbDeferredRegister BLOOD_ORBS = new BloodOrbDeferredRegister(BloodMagic.MODID);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, BloodMagic.MODID);
|
||||
public static final DeferredRegister<Item> BASICITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, BloodMagic.MODID);
|
||||
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_WEAK = BLOOD_ORBS.register("weakbloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "weakbloodorb"), 1, 5000, 2));
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_APPRENTICE = BLOOD_ORBS.register("apprenticebloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "apprenticebloodorb"), 2, 25000, 5));
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_MAGICIAN = BLOOD_ORBS.register("magicianbloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "magicianbloodorb"), 3, 150000, 15));
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_MASTER = BLOOD_ORBS.register("masterbloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "masterbloodorb"), 4, 1000000, 25));
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_ARCHMAGE = BLOOD_ORBS.register("archmagebloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "archmagebloodorb"), 5, 10000000, 50));
|
||||
// public static final DeferredRegister<BloodOrb> BLOOD_ORBS = DeferredRegister.create(RegistrarBloodMagic.BLOOD_ORBS, BloodMagic.MODID);
|
||||
|
||||
// public static final RegistryObject<Item> BLOODSTONE_ITEM = ITEMS.register("ruby_block", () -> new BlockItem(BloodMagicBlocks.BLOODSTONE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> SOUL_FORGE_ITEM = ITEMS.register("soulforge", () -> new BlockItem(BloodMagicBlocks.SOUL_FORGE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> BLANK_RUNE_ITEM = ITEMS.register("blankrune", () -> new BlockItem(BloodMagicBlocks.BLANK_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> SPEED_RUNE_ITEM = ITEMS.register("speedrune", () -> new BlockItem(BloodMagicBlocks.SPEED_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> SACRIFICE_RUNE_ITEM = ITEMS.register("sacrificerune", () -> new BlockItem(BloodMagicBlocks.SACRIFICE_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> SELF_SACRIFICE_RUNE_ITEM = ITEMS.register("selfsacrificerune", () -> new BlockItem(BloodMagicBlocks.SELF_SACRIFICE_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> DISPLACEMENT_RUNE_ITEM = ITEMS.register("dislocationrune", () -> new BlockItem(BloodMagicBlocks.DISPLACEMENT_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> CAPACITY_RUNE_ITEM = ITEMS.register("altarcapacityrune", () -> new BlockItem(BloodMagicBlocks.CAPACITY_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> AUGMENTED_CAPACITY_RUNE_ITEM = ITEMS.register("bettercapacityrune", () -> new BlockItem(BloodMagicBlocks.AUGMENTED_CAPACITY_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> ORB_RUNE_ITEM = ITEMS.register("orbcapacityrune", () -> new BlockItem(BloodMagicBlocks.ORB_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> ACCELERATION_RUNE_ITEM = ITEMS.register("accelerationrune", () -> new BlockItem(BloodMagicBlocks.ACCELERATION_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> CHARGING_RUNE_ITEM = ITEMS.register("chargingrune", () -> new BlockItem(BloodMagicBlocks.CHARGING_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
|
||||
public static final RegistryObject<Item> BLOOD_ALTAR_ITEM = ITEMS.register("altar", () -> new BlockItem(BloodMagicBlocks.BLOOD_ALTAR.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
|
||||
// TODO: Need to rework the above instantiations for the ItemBlocks so that it's
|
||||
// done with the Blocks.
|
||||
|
||||
// public static final RegistryObject<Item> WEAK_BLOOD_ORB = BASICITEMS.register("weakbloodorb", ItemBloodOrb::new);
|
||||
// public static final RegistryObject<Item> WEAK_BLOOD_ORB = BASICITEMS.register("weakbloodorb", () -> new ItemBloodOrb(WEAK_ORB_INSTANCE));
|
||||
public static final RegistryObject<Item> WEAK_BLOOD_ORB = BASICITEMS.register("weakbloodorb", () -> new ItemBloodOrb(ORB_WEAK));
|
||||
public static final RegistryObject<Item> APPRENTICE_BLOOD_ORB = BASICITEMS.register("apprenticebloodorb", () -> new ItemBloodOrb(ORB_APPRENTICE));
|
||||
public static final RegistryObject<Item> MAGICIAN_BLOOD_ORB = BASICITEMS.register("magicianbloodorb", () -> new ItemBloodOrb(ORB_MAGICIAN));
|
||||
public static final RegistryObject<Item> MASTER_BLOOD_ORB = BASICITEMS.register("masterbloodorb", () -> new ItemBloodOrb(ORB_MASTER));
|
||||
|
||||
public static final RegistryObject<Item> DIVINATION_SIGIL = BASICITEMS.register("divinationsigil", () -> new ItemSigilDivination(true));
|
||||
public static final RegistryObject<Item> SACRIFICIAL_DAGGER = BASICITEMS.register("sacrificialdagger", () -> new ItemSacrificialDagger());
|
||||
public static final RegistryObject<Item> SLATE = BASICITEMS.register("blankslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REINFORCED_SLATE = BASICITEMS.register("reinforcedslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> IMBUED_SLATE = BASICITEMS.register("infusedslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> DEMONIC_SLATE = BASICITEMS.register("demonslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> ETHEREAL_SLATE = BASICITEMS.register("etherealslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> WATER_SIGIL = BASICITEMS.register("watersigil", () -> new ItemSigilWater());
|
||||
public static final RegistryObject<Item> VOID_SIGIL = BASICITEMS.register("voidsigil", () -> new ItemSigilVoid());
|
||||
public static final RegistryObject<Item> LAVA_SIGIL = BASICITEMS.register("lavasigil", () -> new ItemSigilLava());
|
||||
public static final RegistryObject<Item> GREEN_GROVE_SIGIL = ITEMS.register("growthsigil", () -> new ItemSigilGreenGrove());
|
||||
public static final RegistryObject<Item> FAST_MINER_SIGIL = ITEMS.register("miningsigil", () -> new ItemSigilFastMiner());
|
||||
public static final RegistryObject<Item> MAGNETISM_SIGIL = ITEMS.register("sigilofmagnetism", () -> new ItemSigilMagnetism());
|
||||
public static final RegistryObject<Item> ICE_SIGIL = ITEMS.register("icesigil", () -> new ItemSigilFrost());
|
||||
public static final RegistryObject<Item> AIR_SIGIL = BASICITEMS.register("airsigil", ItemSigilAir::new);
|
||||
public static final RegistryObject<Item> BLOOD_LIGHT_SIGIL = BASICITEMS.register("bloodlightsigil", ItemSigilBloodLight::new);
|
||||
|
||||
public static final RegistryObject<Item> ARCANE_ASHES = BASICITEMS.register("arcaneashes", () -> new ItemArcaneAshes());
|
||||
public static final RegistryObject<Item> DAGGER_OF_SACRIFICE = BASICITEMS.register("daggerofsacrifice", () -> new ItemDaggerOfSacrifice());
|
||||
|
||||
// Reagents used to make the Sigils
|
||||
public static final RegistryObject<Item> REAGENT_WATER = BASICITEMS.register("reagentwater", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_LAVA = BASICITEMS.register("reagentlava", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_VOID = BASICITEMS.register("reagentvoid", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_GROWTH = BASICITEMS.register("reagentgrowth", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_FAST_MINER = BASICITEMS.register("reagentfastminer", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_MAGNETISM = BASICITEMS.register("reagentmagnetism", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_AIR = BASICITEMS.register("reagentair", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_BLOOD_LIGHT = BASICITEMS.register("reagentbloodlight", () -> new ItemBase());
|
||||
|
||||
// Tartaric Gems
|
||||
public static final RegistryObject<Item> PETTY_GEM = ITEMS.register("soulgempetty", () -> new ItemSoulGem("petty", 64));
|
||||
public static final RegistryObject<Item> LESSER_GEM = ITEMS.register("soulgemlesser", () -> new ItemSoulGem("lesser", 256));
|
||||
public static final RegistryObject<Item> COMMON_GEM = ITEMS.register("soulgemcommon", () -> new ItemSoulGem("common", 1024));
|
||||
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_RAW = BASICITEMS.register("basemonstersoul", () -> new ItemMonsterSoul(EnumDemonWillType.DEFAULT));
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_CORROSIVE = BASICITEMS.register("basemonstersoul_corrosive", () -> new ItemMonsterSoul(EnumDemonWillType.CORROSIVE));
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_DESTRUCTIVE = BASICITEMS.register("basemonstersoul_destructive", () -> new ItemMonsterSoul(EnumDemonWillType.DESTRUCTIVE));
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_STEADFAST = BASICITEMS.register("basemonstersoul_steadfast", () -> new ItemMonsterSoul(EnumDemonWillType.STEADFAST));
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_VENGEFUL = BASICITEMS.register("basemonstersoul_vengeful", () -> new ItemMonsterSoul(EnumDemonWillType.VENGEFUL));
|
||||
|
||||
public static final RegistryObject<Item> SOUL_SNARE = BASICITEMS.register("soulsnare", ItemSoulSnare::new);
|
||||
public static final RegistryObject<Item> SENTIENT_SWORD = ITEMS.register("soulsword", () -> new ItemSentientSword());
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class ItemArcaneAshes extends Item
|
||||
{
|
||||
public ItemArcaneAshes()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB).maxDamage(20));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.arcaneAshes"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext context)
|
||||
{
|
||||
ItemStack stack = context.getItem();
|
||||
BlockPos newPos = context.getPos().offset(context.getFace());
|
||||
World world = context.getWorld();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
|
||||
if (world.isAirBlock(newPos))
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Direction rotation = Direction.fromAngle(player.getRotationYawHead());
|
||||
world.setBlockState(newPos, BloodMagicBlocks.ALCHEMY_ARRAY.get().getDefaultState());
|
||||
TileEntity tile = world.getTileEntity(newPos);
|
||||
if (tile instanceof TileAlchemyArray)
|
||||
{
|
||||
((TileAlchemyArray) tile).setRotation(rotation);
|
||||
}
|
||||
|
||||
// PickaxeItem d;
|
||||
stack.damageItem(1, player, (entity) -> {
|
||||
entity.sendBreakAnimation(EquipmentSlotType.MAINHAND);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public ActionResultType onItemUse(PlayerEntity player, World world, BlockPos blockPos, Hand hand, Direction side, float hitX, float hitY, float hitZ)
|
||||
// {
|
||||
// ItemStack stack = player.getHeldItem(hand);
|
||||
// BlockPos newPos = blockPos.offset(side);
|
||||
//
|
||||
// if (world.isAirBlock(newPos))
|
||||
// {
|
||||
// if (!world.isRemote)
|
||||
// {
|
||||
// Direction rotation = Direction.fromAngle(player.getRotationYawHead());
|
||||
// world.setBlockState(newPos, RegistrarBloodMagicBlocks.ALCHEMY_ARRAY.getDefaultState());
|
||||
// TileEntity tile = world.getTileEntity(newPos);
|
||||
// if (tile instanceof TileAlchemyArray)
|
||||
// {
|
||||
// ((TileAlchemyArray) tile).setRotation(rotation);
|
||||
// }
|
||||
//
|
||||
// stack.damageItem(1, player);
|
||||
// }
|
||||
//
|
||||
// return ActionResultType.SUCCESS;
|
||||
// }
|
||||
//
|
||||
// return ActionResultType.FAIL;
|
||||
// }
|
||||
|
||||
}
|
38
src/main/java/wayoftime/bloodmagic/common/item/ItemBase.java
Normal file
38
src/main/java/wayoftime/bloodmagic/common/item/ItemBase.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
|
||||
public class ItemBase extends Item
|
||||
{
|
||||
private final String desc;
|
||||
|
||||
public ItemBase()
|
||||
{
|
||||
this("");
|
||||
}
|
||||
|
||||
public ItemBase(String desc)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(64).group(BloodMagic.TAB));
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
if (!desc.isEmpty())
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic." + desc));
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.iface.IBindable;
|
||||
|
||||
public class ItemBindableBase extends Item implements IBindable
|
||||
{
|
||||
public ItemBindableBase()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
if (!stack.hasTag())
|
||||
return;
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding != null)
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
|
||||
}
|
||||
}
|
106
src/main/java/wayoftime/bloodmagic/common/item/ItemBloodOrb.java
Normal file
106
src/main/java/wayoftime/bloodmagic/common/item/ItemBloodOrb.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.extensions.IForgeItem;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.core.data.SoulNetwork;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
||||
import wayoftime.bloodmagic.orb.IBloodOrb;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IForgeItem
|
||||
{
|
||||
private final Supplier<BloodOrb> sup;
|
||||
|
||||
public ItemBloodOrb(Supplier<BloodOrb> sup)
|
||||
{
|
||||
this.sup = sup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BloodOrb getOrb(ItemStack stack)
|
||||
{
|
||||
return sup.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
BloodOrb orb = getOrb(stack);
|
||||
|
||||
if (orb == null)
|
||||
return ActionResult.resultFail(stack);
|
||||
|
||||
if (world == null)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F
|
||||
+ (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (!stack.hasTag())
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding == null)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (world.isRemote)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
SoulNetwork ownerNetwork = NetworkHelper.getSoulNetwork(binding);
|
||||
if (binding.getOwnerId().equals(player.getGameProfile().getId()))
|
||||
ownerNetwork.setOrbTier(orb.getTier());
|
||||
|
||||
ownerNetwork.add(SoulTicket.item(stack, world, player, 200), orb.getCapacity()); // Add LP to owner's network
|
||||
ownerNetwork.hurtPlayer(player, 200); // Hurt whoever is using it
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.orb.desc"));
|
||||
|
||||
BloodOrb orb = getOrb(stack);
|
||||
if (flag.isAdvanced() && orb != null)
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.orb.owner", stack.getItem().getRegistryName()));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack stack)
|
||||
{
|
||||
return stack.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerSacrificeHelper;
|
||||
|
||||
public class ItemDaggerOfSacrifice extends Item
|
||||
{
|
||||
public ItemDaggerOfSacrifice()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker)
|
||||
{
|
||||
if (attacker instanceof FakePlayer)
|
||||
return false;
|
||||
|
||||
if (target == null || attacker == null || attacker.getEntityWorld().isRemote
|
||||
|| (attacker instanceof PlayerEntity && !(attacker instanceof ServerPlayerEntity)))
|
||||
return false;
|
||||
|
||||
if (!target.isNonBoss())
|
||||
return false;
|
||||
|
||||
if (target instanceof PlayerEntity)
|
||||
return false;
|
||||
|
||||
if (target.isChild() && !(target instanceof IMob))
|
||||
return false;
|
||||
|
||||
if (!target.isAlive() || target.getHealth() < 0.5F)
|
||||
return false;
|
||||
|
||||
// EntityEntry entityEntry = EntityRegistry.getEntry(target.getClass());
|
||||
// if (entityEntry == null)
|
||||
// return false;
|
||||
// int lifeEssenceRatio = BloodMagicAPI.INSTANCE.getValueManager().getSacrificial().getOrDefault(entityEntry.getRegistryName(), 25);
|
||||
int lifeEssenceRatio = 25;
|
||||
|
||||
if (lifeEssenceRatio <= 0)
|
||||
return false;
|
||||
|
||||
int lifeEssence = (int) (lifeEssenceRatio * target.getHealth());
|
||||
// if (target instanceof AnimalEntity)
|
||||
// {
|
||||
// lifeEssence = (int) (lifeEssence * (1 + PurificationHelper.getCurrentPurity((AnimalEntity) target)));
|
||||
// }
|
||||
|
||||
if (target.isChild())
|
||||
{
|
||||
lifeEssence *= 0.5F;
|
||||
}
|
||||
|
||||
if (PlayerSacrificeHelper.findAndFillAltar(attacker.getEntityWorld(), target, lifeEssence, true))
|
||||
{
|
||||
target.getEntityWorld().playSound(null, target.getPosX(), target.getPosY(), target.getPosZ(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F
|
||||
+ (target.getEntityWorld().rand.nextFloat() - target.getEntityWorld().rand.nextFloat()) * 0.8F);
|
||||
target.setHealth(-1);
|
||||
target.onDeath(DamageSourceBloodMagic.INSTANCE);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,204 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.UseAction;
|
||||
import net.minecraft.particles.RedstoneParticleData;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.ConfigHandler;
|
||||
import wayoftime.bloodmagic.event.SacrificeKnifeUsedEvent;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerSacrificeHelper;
|
||||
|
||||
public class ItemSacrificialDagger extends Item
|
||||
{
|
||||
|
||||
public ItemSacrificialDagger()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.sacrificialDagger.desc"))));
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.sacrificialdagger.desc"));
|
||||
|
||||
// if (stack.getItemDamage() == 1)
|
||||
// list.add(TextHelper.localizeEffect("tooltip.bloodmagic.sacrificialDagger.creative"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft)
|
||||
{
|
||||
if (entityLiving instanceof PlayerEntity && !entityLiving.getEntityWorld().isRemote)
|
||||
PlayerSacrificeHelper.sacrificePlayerHealth((PlayerEntity) entityLiving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUseDuration(ItemStack stack)
|
||||
{
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseAction getUseAction(ItemStack stack)
|
||||
{
|
||||
return UseAction.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (this.canUseForSacrifice(stack))
|
||||
{
|
||||
player.setActiveHand(hand);
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
|
||||
int lpAdded = ConfigHandler.values.sacrificialDaggerConversion * 2;
|
||||
|
||||
// RayTraceResult rayTrace = rayTrace(world, player, false);
|
||||
// if (rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
// {
|
||||
// TileEntity tile = world.getTileEntity(rayTrace.getBlockPos());
|
||||
//
|
||||
// if (tile != null && tile instanceof TileAltar && stack.getItemDamage() == 1)
|
||||
// lpAdded = ((TileAltar) tile).getCapacity();
|
||||
// }
|
||||
|
||||
if (!player.abilities.isCreativeMode)
|
||||
{
|
||||
SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2, lpAdded);
|
||||
if (MinecraftForge.EVENT_BUS.post(evt))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (evt.shouldDrainHealth)
|
||||
{
|
||||
player.hurtResistantTime = 0;
|
||||
player.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 0.001F);
|
||||
player.setHealth(Math.max(player.getHealth() - 1.998F, 0.0001f));
|
||||
if (player.getHealth() <= 0.001f)
|
||||
{
|
||||
player.onDeath(DamageSourceBloodMagic.INSTANCE);
|
||||
player.setHealth(0);
|
||||
}
|
||||
// player.attackEntityFrom(BloodMagicAPI.getDamageSource(), 2.0F);
|
||||
}
|
||||
|
||||
if (!evt.shouldFillAltar)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
lpAdded = evt.lpAdded;
|
||||
}
|
||||
|
||||
double posX = player.getPosX();
|
||||
double posY = player.getPosY();
|
||||
double posZ = player.getPosZ();
|
||||
world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F
|
||||
+ (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
|
||||
for (int l = 0; l < 8; ++l) world.addParticle(RedstoneParticleData.REDSTONE_DUST, posX + Math.random()
|
||||
- Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), 0, 0, 0);
|
||||
|
||||
if (!world.isRemote && PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
// TODO - Check if SoulFray is active
|
||||
PlayerSacrificeHelper.findAndFillAltar(world, player, lpAdded, false);
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (!world.isRemote && entity instanceof PlayerEntity)
|
||||
this.setUseForSacrifice(stack, this.isPlayerPreparedForSacrifice(world, (PlayerEntity) entity));
|
||||
}
|
||||
|
||||
public boolean isPlayerPreparedForSacrifice(World world, PlayerEntity player)
|
||||
{
|
||||
return !world.isRemote && (PlayerSacrificeHelper.getPlayerIncense(player) > 0);
|
||||
}
|
||||
|
||||
public boolean canUseForSacrifice(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
return stack.getTag().getBoolean(Constants.NBT.SACRIFICE);
|
||||
}
|
||||
|
||||
public void setUseForSacrifice(ItemStack stack, boolean sacrifice)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
stack.getTag().putBoolean(Constants.NBT.SACRIFICE, sacrifice);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public ItemMeshDefinition getMeshDefinition()
|
||||
// {
|
||||
// return stack -> {
|
||||
// String variant = "type=normal";
|
||||
// if (stack.getItemDamage() != 0)
|
||||
// variant = "type=creative";
|
||||
//
|
||||
// if (canUseForSacrifice(stack))
|
||||
// variant = "type=ceremonial";
|
||||
//
|
||||
// return new ModelResourceLocation(getRegistryName(), variant);
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void gatherVariants(Consumer<String> variants)
|
||||
// {
|
||||
// variants.accept("type=normal");
|
||||
// variants.accept("type=creative");
|
||||
// variants.accept("type=ceremonial");
|
||||
// }
|
||||
//
|
||||
// public enum DaggerType implements ISubItem
|
||||
// {
|
||||
//
|
||||
// NORMAL, CREATIVE,;
|
||||
//
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public String getInternalName()
|
||||
// {
|
||||
// return name().toLowerCase(Locale.ROOT);
|
||||
// }
|
||||
//
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public ItemStack getStack(int count)
|
||||
// {
|
||||
// return new ItemStack(RegistrarBloodMagicItems.SACRIFICIAL_DAGGER, count, ordinal());
|
||||
// }
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.iface.IBindable;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
|
||||
/**
|
||||
* Base class for all (static) sigils.
|
||||
*/
|
||||
public class ItemSigil extends Item implements IBindable, ISigil
|
||||
{
|
||||
private int lpUsed;
|
||||
|
||||
public ItemSigil(Properties prop, int lpUsed)
|
||||
{
|
||||
super(prop);
|
||||
|
||||
this.lpUsed = lpUsed;
|
||||
}
|
||||
|
||||
public boolean isUnusable(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
return stack.getTag().getBoolean(Constants.NBT.UNUSABLE);
|
||||
}
|
||||
|
||||
public ItemStack setUnusable(ItemStack stack, boolean unusable)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
stack.getTag().putBoolean(Constants.NBT.UNUSABLE, unusable);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public int getLpUsed()
|
||||
{
|
||||
return lpUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
if (!stack.hasTag())
|
||||
return;
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding != null)
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilAir extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilAir()
|
||||
{
|
||||
super("air", 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.resultFail(stack);
|
||||
|
||||
boolean unusable = isUnusable(stack);
|
||||
if (world.isRemote && !unusable)
|
||||
{
|
||||
Vector3d vec = player.getLookVec();
|
||||
double wantedVelocity = 1.7;
|
||||
|
||||
// TODO - Revisit after potions
|
||||
// if (player.isPotionActive(RegistrarBloodMagic.BOOST))
|
||||
// {
|
||||
// int amplifier = player.getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier();
|
||||
// wantedVelocity += (1 + amplifier) * (0.35);
|
||||
// }
|
||||
|
||||
player.setMotion(vec.x * wantedVelocity, vec.y * wantedVelocity, vec.z * wantedVelocity);
|
||||
|
||||
world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F
|
||||
+ (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!player.isCreative())
|
||||
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess());
|
||||
|
||||
if (!unusable)
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.item.ItemSigil;
|
||||
|
||||
public class ItemSigilBase extends ItemSigil
|
||||
{
|
||||
protected final String tooltipBase;
|
||||
// private final String name;
|
||||
|
||||
public ItemSigilBase(String name, int lpUsed)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB), lpUsed);
|
||||
// super(lpUsed);
|
||||
|
||||
// this.name = name;
|
||||
this.tooltipBase = "tooltip.bloodmagic.sigil." + name + ".";
|
||||
}
|
||||
|
||||
public ItemSigilBase(String name)
|
||||
{
|
||||
this(name, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent(tooltipBase + "desc"));
|
||||
// if (TextHelper.canTranslate(tooltipBase + "desc"))
|
||||
// tooltip.addAll(Arrays.asList(WordUtils.wrap(TextHelper.localizeEffect(tooltipBase
|
||||
// + "desc"), 30, "/cut", false).split("/cut")));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
// public String getName()
|
||||
// {
|
||||
// return name;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.core.data.SoulNetwork;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntityBloodLight;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilBloodLight extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilBloodLight()
|
||||
{
|
||||
super("bloodlight", 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (getCooldownRemainder(stack) > 0)
|
||||
reduceCooldown(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.resultFail(stack);
|
||||
|
||||
RayTraceResult mop = rayTrace(world, player, RayTraceContext.FluidMode.NONE);
|
||||
|
||||
if (getCooldownRemainder(stack) > 0)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (mop != null && mop.getType() == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
BlockRayTraceResult blockRayTrace = (BlockRayTraceResult) mop;
|
||||
BlockPos blockPos = blockRayTrace.getPos().offset(blockRayTrace.getFace());
|
||||
|
||||
if (world.isAirBlock(blockPos))
|
||||
{
|
||||
world.setBlockState(blockPos, BloodMagicBlocks.BLOOD_LIGHT.get().getDefaultState());
|
||||
if (!world.isRemote)
|
||||
{
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
|
||||
network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed()));
|
||||
}
|
||||
resetCooldown(stack);
|
||||
player.swingArm(hand);
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
|
||||
EntityBloodLight light = new EntityBloodLight(world, player);
|
||||
light.func_234612_a_(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
|
||||
world.addEntity(light);
|
||||
network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed()));
|
||||
}
|
||||
resetCooldown(stack);
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
return oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
public int getCooldownRemainder(ItemStack stack)
|
||||
{
|
||||
return NBTHelper.checkNBT(stack).getTag().getInt(Constants.NBT.TICKS_REMAINING);
|
||||
}
|
||||
|
||||
public void reduceCooldown(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTag().putInt(Constants.NBT.TICKS_REMAINING, getCooldownRemainder(stack) - 1);
|
||||
}
|
||||
|
||||
public void resetCooldown(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTag().putInt(Constants.NBT.TICKS_REMAINING, 10);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceContext.FluidMode;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.altar.IBloodAltar;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.iface.IAltarReader;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.ChatUtil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.NumeralHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
|
||||
{
|
||||
|
||||
public ItemSigilDivination(boolean simple)
|
||||
{
|
||||
super(simple ? "divination" : "seer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.resultFail(stack);
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
RayTraceResult position = Item.rayTrace(world, player, FluidMode.NONE);
|
||||
|
||||
if (position == null || position.getType() == RayTraceResult.Type.MISS)
|
||||
{
|
||||
super.onItemRightClick(world, player, hand);
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding != null)
|
||||
{
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(binding).getCurrentEssence();
|
||||
List<ITextComponent> toSend = Lists.newArrayList();
|
||||
if (!binding.getOwnerId().equals(player.getGameProfile().getId()))
|
||||
toSend.add(new TranslationTextComponent(tooltipBase + "otherNetwork", binding.getOwnerName()));
|
||||
toSend.add(new TranslationTextComponent(tooltipBase + "currentEssence", currentEssence));
|
||||
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (position.getType() == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(position.getHitVec()));
|
||||
|
||||
if (tile != null && tile instanceof IBloodAltar)
|
||||
{
|
||||
IBloodAltar altar = (IBloodAltar) tile;
|
||||
int tier = altar.getTier().ordinal() + 1;
|
||||
int currentEssence = altar.getCurrentBlood();
|
||||
int capacity = altar.getCapacity();
|
||||
altar.checkTier();
|
||||
ChatUtil.sendNoSpam(player, new TranslationTextComponent(tooltipBase
|
||||
+ "currentAltarTier", NumeralHelper.toRoman(tier)), new TranslationTextComponent(tooltipBase
|
||||
+ "currentEssence", currentEssence), new TranslationTextComponent(tooltipBase
|
||||
+ "currentAltarCapacity", capacity));
|
||||
}
|
||||
// else if (tile != null && tile instanceof TileIncenseAltar)
|
||||
// {
|
||||
// TileIncenseAltar altar = (TileIncenseAltar) tile;
|
||||
// altar.recheckConstruction();
|
||||
// double tranquility = altar.tranquility;
|
||||
// ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentTranquility", (int) ((100D * (int) (100 * tranquility)) / 100d)), new TextComponentTranslation(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition)));
|
||||
// } else if (tile != null && tile instanceof TileInversionPillar)
|
||||
// {
|
||||
// TileInversionPillar pillar = (TileInversionPillar) tile;
|
||||
// double inversion = pillar.getCurrentInversion();
|
||||
// ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentInversion", ((int) (10 * inversion)) / 10d));
|
||||
// }
|
||||
else
|
||||
{
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding != null)
|
||||
{
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(binding).getCurrentEssence();
|
||||
List<ITextComponent> toSend = Lists.newArrayList();
|
||||
if (!binding.getOwnerId().equals(player.getGameProfile().getId()))
|
||||
toSend.add(new TranslationTextComponent(tooltipBase
|
||||
+ "otherNetwork", binding.getOwnerName()));
|
||||
toSend.add(new TranslationTextComponent(tooltipBase + "currentEssence", currentEssence));
|
||||
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilFastMiner extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilFastMiner()
|
||||
{
|
||||
super("fast_miner", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
player.addPotionEffect(new EffectInstance(Effects.HASTE, 2, 0, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performArrayEffect(World world, BlockPos pos)
|
||||
{
|
||||
double radius = 10;
|
||||
int ticks = 600;
|
||||
int potionPotency = 2;
|
||||
|
||||
AxisAlignedBB bb = new AxisAlignedBB(pos).grow(radius);
|
||||
List<PlayerEntity> playerList = world.getEntitiesWithinAABB(PlayerEntity.class, bb);
|
||||
for (PlayerEntity player : playerList)
|
||||
{
|
||||
if (!player.isPotionActive(Effects.HASTE) || (player.isPotionActive(Effects.HASTE)
|
||||
&& player.getActivePotionEffect(Effects.HASTE).getAmplifier() < potionPotency))
|
||||
{
|
||||
player.addPotionEffect(new EffectInstance(Effects.HASTE, ticks, potionPotency));
|
||||
if (!player.isCreative())
|
||||
{
|
||||
player.hurtResistantTime = 0;
|
||||
player.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArrayEffect()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BucketItem;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import net.minecraftforge.fluids.capability.wrappers.BlockWrapper;
|
||||
|
||||
public abstract class ItemSigilFluidBase extends ItemSigilBase
|
||||
{
|
||||
// Class for sigils that interact with fluids, either creating or deleting them.
|
||||
// Sigils still have to define their own onRightClick behavior, but the actual
|
||||
// fluid-interacting code is largely limited to here.
|
||||
public final FluidStack sigilFluid;
|
||||
|
||||
public ItemSigilFluidBase(String name, int lpUsed, FluidStack fluid)
|
||||
{
|
||||
super(name, lpUsed);
|
||||
sigilFluid = fluid;
|
||||
}
|
||||
|
||||
public ItemSigilFluidBase(String name, FluidStack fluid)
|
||||
{
|
||||
super(name);
|
||||
sigilFluid = fluid;
|
||||
}
|
||||
|
||||
public ItemSigilFluidBase(String name)
|
||||
{
|
||||
super(name);
|
||||
sigilFluid = null;
|
||||
}
|
||||
|
||||
// The following are handler functions for fluids, all genericized.
|
||||
// They're all based off of the Forge FluidUtil methods, but directly taking the
|
||||
// sigilFluid constant instead of getting an argument.
|
||||
|
||||
/*
|
||||
* Gets a fluid handler for the targeted block and siding. Works for both tile
|
||||
* entity liquid containers and fluid blocks. This one is literally identical to
|
||||
* the FluidUtil method of the same signature.
|
||||
*/
|
||||
@Nullable
|
||||
protected IFluidHandler getFluidHandler(World world, BlockPos blockPos, @Nullable Direction side)
|
||||
{
|
||||
BlockState state = world.getBlockState(blockPos);
|
||||
Block block = state.getBlock();
|
||||
BucketItem b;
|
||||
System.out.println(block);
|
||||
IFluidHandler targetFluidHandler = FluidUtil.getFluidHandler(world, blockPos, side).orElse(null);
|
||||
System.out.println(targetFluidHandler);
|
||||
|
||||
if (targetFluidHandler == null)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
return targetFluidHandler;
|
||||
// if (block instanceof IFluidBlock)
|
||||
// return new FluidBlockWrapper((IFluidBlock) block, world, blockPos);
|
||||
// else if (block instanceof BlockLiquid)
|
||||
// return new BlockLiquidWrapper((BlockLiquid) block, world, blockPos);
|
||||
// return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tries to insert fluid into a fluid handler. If doTransfer is false, only
|
||||
* simulate the transfer. If true, actually do so. Returns true if the transfer
|
||||
* is successful, false otherwise.
|
||||
*/
|
||||
protected boolean tryInsertSigilFluid(IFluidHandler destination, boolean doTransfer)
|
||||
{
|
||||
if (destination == null)
|
||||
return false;
|
||||
return destination.fill(sigilFluid, doTransfer ? FluidAction.EXECUTE : FluidAction.SIMULATE) > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tries basically the oppostive of the above, removing fluids instead of adding
|
||||
* them
|
||||
*/
|
||||
protected boolean tryRemoveFluid(IFluidHandler source, int amount, boolean doTransfer)
|
||||
{
|
||||
if (source == null)
|
||||
return false;
|
||||
return source.drain(amount, doTransfer ? FluidAction.EXECUTE : FluidAction.SIMULATE) != null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tries to place a fluid block in the world. Returns true if successful,
|
||||
* otherwise false. This is the big troublesome one, oddly enough. It's
|
||||
* genericized in case anyone wants to create variant sigils with weird fluids.
|
||||
*/
|
||||
protected boolean tryPlaceSigilFluid(PlayerEntity player, World world, BlockPos blockPos)
|
||||
{
|
||||
BlockState state = sigilFluid.getFluid().getAttributes().getBlock(world, blockPos, sigilFluid.getFluid().getDefaultState());
|
||||
BlockWrapper wrapper = new BlockWrapper(state, world, blockPos);
|
||||
return wrapper.fill(sigilFluid, FluidAction.EXECUTE) > 0;
|
||||
// // Make sure world coordinants are valid
|
||||
// if (world == null || blockPos == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// // Make sure fluid is placeable
|
||||
// Fluid fluid = sigilFluid.getFluid();
|
||||
// if (!fluid.getAttributes().canBePlacedInWorld(world, blockPos, sigilFluid))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Check if the block is an air block or otherwise replaceable
|
||||
// BlockState state = world.getBlockState(blockPos);
|
||||
// Material mat = state.getMaterial();
|
||||
// boolean isDestSolid = mat.isSolid();
|
||||
// boolean isDestReplaceable = state.getBlock().isReplaceable(state, fluid);
|
||||
// if (!world.isAirBlock(blockPos) && isDestSolid && !isDestReplaceable)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//// // If the fluid vaporizes, this exists here in the lava sigil solely so the code
|
||||
//// // is usable for other fluids
|
||||
//// if (world.provider.doesWaterVaporize() && fluid.doesVaporize(sigilFluid))
|
||||
//// {
|
||||
//// fluid.vaporize(player, world, blockPos, sigilFluid);
|
||||
//// return true;
|
||||
//// }
|
||||
//
|
||||
// // Finally we've done enough checking to make sure everything at the end is
|
||||
// // safe, let's place some fluid.
|
||||
// IFluidHandler handler;
|
||||
// Block block = fluid.getAttributes().getStateForPlacement(world, blockPos, sigilFluid).getBlockState().getBlock();
|
||||
// if (block instanceof IFluidBlock)
|
||||
// {
|
||||
// handler = new FluidBlockWrapper((IFluidBlock) block, world, blockPos);
|
||||
// } else if (block instanceof BlockLiquid)
|
||||
// handler = new BlockLiquidWrapper((BlockLiquid) block, world, blockPos);
|
||||
// else
|
||||
// handler = new BlockWrapper(block, world, blockPos);
|
||||
// return tryInsertSigilFluid(handler, true);
|
||||
//// return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.enchantment.FrostWalkerEnchantment;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilFrost extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilFrost()
|
||||
{
|
||||
super("frost", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
FrostWalkerEnchantment.freezeNearby(player, world, player.getPosition(), 1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilGreenGrove extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilGreenGrove()
|
||||
{
|
||||
super("green_grove", 150);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSigilUse(ItemStack stack, PlayerEntity player, World world, BlockPos blockPos, Direction side, Vector3d vec)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return false;
|
||||
|
||||
if (NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()
|
||||
&& applyBonemeal(stack, world, blockPos, player))
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
world.playEvent(2005, blockPos, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World worldIn, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
int range = 3;
|
||||
int verticalRange = 2;
|
||||
int posX = (int) Math.round(player.getPosX() - 0.5f);
|
||||
int posY = (int) player.getPosY();
|
||||
int posZ = (int) Math.round(player.getPosZ() - 0.5f);
|
||||
if (worldIn instanceof ServerWorld)
|
||||
{
|
||||
ServerWorld serverWorld = (ServerWorld) worldIn;
|
||||
for (int ix = posX - range; ix <= posX + range; ix++)
|
||||
{
|
||||
for (int iz = posZ - range; iz <= posZ + range; iz++)
|
||||
{
|
||||
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++)
|
||||
{
|
||||
BlockPos blockPos = new BlockPos(ix, iy, iz);
|
||||
BlockState state = worldIn.getBlockState(blockPos);
|
||||
|
||||
// if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state))
|
||||
{
|
||||
if (state.getBlock() instanceof IGrowable)
|
||||
{
|
||||
if (worldIn.rand.nextInt(50) == 0)
|
||||
{
|
||||
BlockState preBlockState = worldIn.getBlockState(blockPos);
|
||||
((IGrowable) state.getBlock()).grow(serverWorld, worldIn.rand, blockPos, state);
|
||||
|
||||
BlockState newState = worldIn.getBlockState(blockPos);
|
||||
if (!newState.equals(preBlockState) && !worldIn.isRemote)
|
||||
worldIn.playEvent(2005, blockPos, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos pos, PlayerEntity player)
|
||||
{
|
||||
BlockState blockstate = worldIn.getBlockState(pos);
|
||||
int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, pos, blockstate, stack);
|
||||
if (hook != 0)
|
||||
return hook > 0;
|
||||
if (blockstate.getBlock() instanceof IGrowable)
|
||||
{
|
||||
IGrowable igrowable = (IGrowable) blockstate.getBlock();
|
||||
if (igrowable.canGrow(worldIn, pos, blockstate, worldIn.isRemote))
|
||||
{
|
||||
if (worldIn instanceof ServerWorld)
|
||||
{
|
||||
if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos, blockstate))
|
||||
{
|
||||
igrowable.grow((ServerWorld) worldIn, worldIn.rand, pos, blockstate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilLava extends ItemSigilFluidBase
|
||||
{
|
||||
public ItemSigilLava()
|
||||
{
|
||||
super("lava", 1000, new FluidStack(Fluids.LAVA, 10000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.resultFail(stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
RayTraceResult rayTrace = rayTrace(world, player, RayTraceContext.FluidMode.NONE);
|
||||
|
||||
if (rayTrace == null || rayTrace.getType() != RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
return ActionResult.resultFail(stack);
|
||||
}
|
||||
|
||||
BlockRayTraceResult blockRayTrace = (BlockRayTraceResult) rayTrace;
|
||||
BlockPos blockPos = blockRayTrace.getPos();
|
||||
Direction sideHit = blockRayTrace.getFace();
|
||||
BlockPos blockpos1 = blockPos.offset(sideHit);
|
||||
|
||||
if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockpos1, sideHit, stack))
|
||||
{
|
||||
|
||||
// Case for if block at blockPos is a fluid handler like a tank
|
||||
// Try to put fluid into tank
|
||||
IFluidHandler destination = getFluidHandler(world, blockPos, null);
|
||||
if (destination != null && tryInsertSigilFluid(destination, false)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
boolean result = tryInsertSigilFluid(destination, true);
|
||||
if (result)
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
// Do the same as above, but use sidedness to interact with the fluid handler.
|
||||
IFluidHandler destinationSide = getFluidHandler(world, blockPos, sideHit);
|
||||
if (destinationSide != null && tryInsertSigilFluid(destinationSide, false)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
boolean result = tryInsertSigilFluid(destinationSide, true);
|
||||
if (result)
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
|
||||
// Case for if block at blockPos is not a tank
|
||||
// Place fluid in world
|
||||
if (destination == null && destinationSide == null)
|
||||
{
|
||||
BlockPos targetPos = blockPos.offset(sideHit);
|
||||
if (tryPlaceSigilFluid(player, world, targetPos)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.item.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilMagnetism extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilMagnetism()
|
||||
{
|
||||
super("magnetism", 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
int range = 5;
|
||||
int verticalRange = 5;
|
||||
float posX = Math.round(player.getPosX());
|
||||
float posY = (float) (player.getPosY() - player.getEyeHeight());
|
||||
float posZ = Math.round(player.getPosZ());
|
||||
List<ItemEntity> entities = player.getEntityWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(posX
|
||||
- 0.5f, posY - 0.5f, posZ
|
||||
- 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
|
||||
List<ExperienceOrbEntity> xpOrbs = player.getEntityWorld().getEntitiesWithinAABB(ExperienceOrbEntity.class, new AxisAlignedBB(posX
|
||||
- 0.5f, posY - 0.5f, posZ
|
||||
- 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
|
||||
|
||||
for (ItemEntity entity : entities)
|
||||
{
|
||||
if (entity != null && !world.isRemote && entity.isAlive())
|
||||
{
|
||||
entity.onCollideWithPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
for (ExperienceOrbEntity xpOrb : xpOrbs)
|
||||
{
|
||||
if (xpOrb != null && !world.isRemote)
|
||||
{
|
||||
xpOrb.onCollideWithPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.common.item.ItemSigil;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.IActivatable;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
/**
|
||||
* Base class for all toggleable sigils.
|
||||
*/
|
||||
public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
||||
{
|
||||
|
||||
public ItemSigilToggleable(Properties property, int lpUsed)
|
||||
{
|
||||
super(property, lpUsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActivated(ItemStack stack)
|
||||
{
|
||||
return !stack.isEmpty() && NBTHelper.checkNBT(stack).getTag().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated)
|
||||
{
|
||||
if (!stack.isEmpty())
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTag().putBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.resultFail(stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
if (player.isSneaking())
|
||||
setActivatedState(stack, !getActivated(stack));
|
||||
if (getActivated(stack))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext context)
|
||||
{
|
||||
World world = context.getWorld();
|
||||
BlockPos blockpos = context.getPos();
|
||||
|
||||
PlayerEntity player = context.getPlayer();
|
||||
ItemStack stack = context.getItem();
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding == null || player.isSneaking()) // Make sure Sigils are bound before handling. Also ignores while
|
||||
// toggling state
|
||||
return ActionResultType.PASS;
|
||||
|
||||
return onSigilUse(stack, player, world, blockpos, context.getFace(), context.getHitVec())
|
||||
? ActionResultType.SUCCESS
|
||||
: ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
public boolean onSigilUse(ItemStack itemStack, PlayerEntity player, World world, BlockPos blockPos, Direction side, Vector3d hitVec)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (!worldIn.isRemote && entityIn instanceof PlayerEntity && getActivated(stack))
|
||||
{
|
||||
if (entityIn.ticksExisted % 100 == 0)
|
||||
{
|
||||
if (!NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage((PlayerEntity) entityIn, SoulTicket.item(stack, worldIn, entityIn, getLpUsed())).isSuccess())
|
||||
{
|
||||
setActivatedState(stack, false);
|
||||
}
|
||||
}
|
||||
|
||||
onSigilUpdate(stack, worldIn, (PlayerEntity) entityIn, itemSlot, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSigilUpdate(ItemStack stack, World world, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
|
||||
public class ItemSigilToggleableBase extends ItemSigilToggleable// implements IMeshProvider
|
||||
{
|
||||
protected final String tooltipBase;
|
||||
private final String name;
|
||||
|
||||
public ItemSigilToggleableBase(String name, int lpUsed)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB), lpUsed);
|
||||
|
||||
this.name = name;
|
||||
this.tooltipBase = "tooltip.bloodmagic.sigil." + name + ".";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
if (!stack.hasTag())
|
||||
return;
|
||||
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic." + (getActivated(stack) ? "activated"
|
||||
: "deactivated")));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public ItemMeshDefinition getMeshDefinition()
|
||||
// {
|
||||
// return new CustomMeshDefinitionActivatable("sigil_" + name.toLowerCase(Locale.ROOT));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void gatherVariants(Consumer<String> variants)
|
||||
// {
|
||||
// variants.accept("active=false");
|
||||
// variants.accept("active=true");
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.IBucketPickupHandler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilVoid extends ItemSigilFluidBase
|
||||
{
|
||||
public ItemSigilVoid()
|
||||
{
|
||||
super("void", 50, new FluidStack(Fluids.EMPTY, 1000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.resultFail(stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
RayTraceResult rayTrace = rayTrace(world, player, RayTraceContext.FluidMode.SOURCE_ONLY);
|
||||
|
||||
if (rayTrace == null || rayTrace.getType() != RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
return ActionResult.resultFail(stack);
|
||||
}
|
||||
|
||||
BlockRayTraceResult blockRayTrace = (BlockRayTraceResult) rayTrace;
|
||||
BlockPos blockPos = blockRayTrace.getPos();
|
||||
Direction sideHit = blockRayTrace.getFace();
|
||||
|
||||
if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockPos, sideHit, stack))
|
||||
{
|
||||
BlockState blockState = world.getBlockState(blockPos);
|
||||
if (blockState.getBlock() instanceof IBucketPickupHandler)
|
||||
{
|
||||
if (NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
((IBucketPickupHandler) blockState.getBlock()).pickupFluid(world, blockPos, blockState);
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
}
|
||||
// Void is simpler than the other fluid sigils, because getFluidHandler grabs
|
||||
// fluid blocks just fine
|
||||
// So extract from fluid tanks with a null side; or drain fluid blocks.
|
||||
// IFluidHandler destination = getFluidHandler(world, blockPos, sideHit);
|
||||
// if (destination != null && tryRemoveFluid(destination, 1000, false)
|
||||
// && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
// {
|
||||
// if (tryRemoveFluid(destination, 1000, true))
|
||||
// return ActionResult.resultSuccess(stack);
|
||||
// }
|
||||
// // Do the same as above, but use sidedness to interact with the fluid handler.
|
||||
// IFluidHandler destinationSide = getFluidHandler(world, blockPos, sideHit);
|
||||
// if (destinationSide != null && tryRemoveFluid(destinationSide, 1000, false)
|
||||
// && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
// {
|
||||
// if (tryRemoveFluid(destinationSide, 1000, true))
|
||||
// return ActionResult.resultSuccess(stack);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CauldronBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilWater extends ItemSigilFluidBase
|
||||
{
|
||||
public ItemSigilWater()
|
||||
{
|
||||
super("water", 100, new FluidStack(Fluids.WATER, 10000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.resultFail(stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
RayTraceResult rayTrace = rayTrace(world, player, RayTraceContext.FluidMode.NONE);
|
||||
|
||||
if (rayTrace == null || rayTrace.getType() != RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
return ActionResult.resultFail(stack);
|
||||
}
|
||||
|
||||
BlockRayTraceResult blockRayTrace = (BlockRayTraceResult) rayTrace;
|
||||
BlockPos blockPos = blockRayTrace.getPos();
|
||||
Direction sideHit = blockRayTrace.getFace();
|
||||
BlockPos blockpos1 = blockPos.offset(sideHit);
|
||||
|
||||
if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockpos1, sideHit, stack))
|
||||
{
|
||||
|
||||
// Case for if block at blockPos is a fluid handler like a tank
|
||||
// Try to put fluid into tank
|
||||
IFluidHandler destination = getFluidHandler(world, blockPos, null);
|
||||
if (destination != null && tryInsertSigilFluid(destination, false)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
boolean result = tryInsertSigilFluid(destination, true);
|
||||
if (result)
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
// Do the same as above, but use sidedness to interact with the fluid handler.
|
||||
IFluidHandler destinationSide = getFluidHandler(world, blockPos, sideHit);
|
||||
if (destinationSide != null && tryInsertSigilFluid(destinationSide, false)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
boolean result = tryInsertSigilFluid(destinationSide, true);
|
||||
if (result)
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
|
||||
// Special vanilla cauldron handling, yay.
|
||||
if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
world.setBlockState(blockPos, Blocks.CAULDRON.getDefaultState().with(CauldronBlock.LEVEL, 3));
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
|
||||
// Case for if block at blockPos is not a tank
|
||||
// Place fluid in world
|
||||
if (destination == null && destinationSide == null)
|
||||
{
|
||||
BlockPos targetPos = blockPos.offset(sideHit);
|
||||
if (tryPlaceSigilFluid(player, world, targetPos)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
package wayoftime.bloodmagic.common.item.soul;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.util.ChatUtil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.will.IDemonWill;
|
||||
|
||||
public class ItemMonsterSoul extends Item implements IDemonWill
|
||||
{
|
||||
private final EnumDemonWillType type;
|
||||
|
||||
public ItemMonsterSoul(EnumDemonWillType type)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
if (!stack.hasTag())
|
||||
return;
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.will", ChatUtil.DECIMAL_FORMAT.format(getWill(getType(stack), stack))));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getType(ItemStack stack)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWill(EnumDemonWillType type, ItemStack soulStack)
|
||||
{
|
||||
if (type != this.getType(soulStack))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
NBTHelper.checkNBT(soulStack);
|
||||
|
||||
CompoundNBT tag = soulStack.getTag();
|
||||
|
||||
return tag.getDouble(Constants.NBT.SOULS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items)
|
||||
{
|
||||
if (this.isInGroup(group))
|
||||
{
|
||||
ItemStack stack = new ItemStack(this);
|
||||
this.setWill(type, stack, 5);
|
||||
items.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setWill(EnumDemonWillType type, ItemStack soulStack, double souls)
|
||||
{
|
||||
if (type != this.getType(soulStack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
NBTHelper.checkNBT(soulStack);
|
||||
CompoundNBT tag = soulStack.getTag();
|
||||
tag.putDouble(Constants.NBT.SOULS, souls);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double drainWill(EnumDemonWillType type, ItemStack soulStack, double drainAmount)
|
||||
{
|
||||
double souls = getWill(type, soulStack);
|
||||
|
||||
double soulsDrained = Math.min(drainAmount, souls);
|
||||
setWill(type, soulStack, souls - soulsDrained);
|
||||
|
||||
return soulsDrained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack createWill(double number)
|
||||
{
|
||||
ItemStack soulStack = new ItemStack(this);
|
||||
setWill(getType(soulStack), soulStack, number);
|
||||
return soulStack;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public double getWill(ItemStack willStack)
|
||||
// {
|
||||
// return this.getWill(EnumDemonWillType.DEFAULT, willStack);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void setWill(ItemStack willStack, double will)
|
||||
// {
|
||||
// this.setWill(EnumDemonWillType.DEFAULT, willStack, will);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public double drainWill(ItemStack willStack, double drainAmount)
|
||||
// {
|
||||
// return this.drainWill(EnumDemonWillType.DEFAULT, willStack, drainAmount);
|
||||
// }
|
||||
|
||||
}
|
|
@ -0,0 +1,503 @@
|
|||
package wayoftime.bloodmagic.common.item.soul;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.monster.SlimeEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.iface.IMultiWillTool;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.will.IDemonWill;
|
||||
import wayoftime.bloodmagic.will.IDemonWillWeapon;
|
||||
import wayoftime.bloodmagic.will.PlayerDemonWillHandler;
|
||||
|
||||
public class ItemSentientSword extends Item implements IDemonWillWeapon, IMultiWillTool
|
||||
{
|
||||
public static int[] soulBracket = new int[]
|
||||
{ 16, 60, 200, 400, 1000, 2000, 4000 };
|
||||
public static double[] defaultDamageAdded = new double[]
|
||||
{ 1, 1.5, 2, 2.5, 3, 3.5, 4 };
|
||||
public static double[] destructiveDamageAdded = new double[]
|
||||
{ 1.5, 2.25, 3, 3.75, 4.5, 5.25, 6 };
|
||||
public static double[] vengefulDamageAdded = new double[]
|
||||
{ 0, 0.5, 1, 1.5, 2, 2.25, 2.5 };
|
||||
public static double[] steadfastDamageAdded = new double[]
|
||||
{ 0, 0.5, 1, 1.5, 2, 2.25, 2.5 };
|
||||
public static double[] soulDrainPerSwing = new double[]
|
||||
{ 0.05, 0.1, 0.2, 0.4, 0.75, 1, 1.25 };
|
||||
public static double[] soulDrop = new double[]
|
||||
{ 2, 4, 7, 10, 13, 15, 18 };
|
||||
public static double[] staticDrop = new double[]
|
||||
{ 1, 1, 2, 3, 3, 4, 4 };
|
||||
|
||||
public static double[] healthBonus = new double[]
|
||||
{ 0, 0, 0, 0, 0, 0, 0 }; // TODO: Think of implementing this later
|
||||
public static double[] vengefulAttackSpeed = new double[]
|
||||
{ -2.1, -2, -1.8, -1.7, -1.6, -1.6, -1.5 };
|
||||
public static double[] destructiveAttackSpeed = new double[]
|
||||
{ -2.6, -2.7, -2.8, -2.9, -3, -3, -3 };
|
||||
|
||||
public static int[] absorptionTime = new int[]
|
||||
{ 200, 300, 400, 500, 600, 700, 800 };
|
||||
|
||||
public static double maxAbsorptionHearts = 10;
|
||||
|
||||
public static int[] poisonTime = new int[]
|
||||
{ 25, 50, 60, 80, 100, 120, 150 };
|
||||
public static int[] poisonLevel = new int[]
|
||||
{ 0, 0, 0, 1, 1, 1, 1 };
|
||||
|
||||
public static double[] movementSpeed = new double[]
|
||||
{ 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4 };
|
||||
|
||||
public ItemSentientSword()
|
||||
{
|
||||
// super(RegistrarBloodMagicItems.SOUL_TOOL_MATERIAL);
|
||||
super(new Item.Properties().maxDamage(520).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||
// {
|
||||
// return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem()
|
||||
// || super.getIsRepairable(toRepair, repair);
|
||||
// }
|
||||
|
||||
public void recalculatePowers(ItemStack stack, World world, PlayerEntity player)
|
||||
{
|
||||
EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
recalculatePowers(stack, type, soulsRemaining);
|
||||
}
|
||||
|
||||
public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will)
|
||||
{
|
||||
this.setCurrentType(stack, will > 0 ? type : EnumDemonWillType.DEFAULT);
|
||||
int level = getLevel(stack, will);
|
||||
|
||||
double drain = level >= 0 ? soulDrainPerSwing[level] : 0;
|
||||
double extraDamage = getExtraDamage(type, level);
|
||||
|
||||
setActivatedState(stack, will > 16);
|
||||
|
||||
setDrainOfActivatedSword(stack, drain);
|
||||
setDamageOfActivatedSword(stack, 5 + extraDamage);
|
||||
setStaticDropOfActivatedSword(stack, level >= 0 ? staticDrop[level] : 1);
|
||||
setDropOfActivatedSword(stack, level >= 0 ? soulDrop[level] : 0);
|
||||
setAttackSpeedOfSword(stack, level >= 0 ? getAttackSpeed(type, level) : -2.4);
|
||||
setHealthBonusOfSword(stack, level >= 0 ? getHealthBonus(type, level) : 0);
|
||||
setSpeedOfSword(stack, level >= 0 ? getMovementSpeed(type, level) : 0);
|
||||
}
|
||||
|
||||
public boolean getActivated(ItemStack stack)
|
||||
{
|
||||
return !stack.isEmpty() && NBTHelper.checkNBT(stack).getTag().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated)
|
||||
{
|
||||
if (!stack.isEmpty())
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTag().putBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public double getExtraDamage(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
if (willBracket < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
case DEFAULT:
|
||||
return defaultDamageAdded[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveDamageAdded[willBracket];
|
||||
case VENGEFUL:
|
||||
return vengefulDamageAdded[willBracket];
|
||||
case STEADFAST:
|
||||
return steadfastDamageAdded[willBracket];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getAttackSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return vengefulAttackSpeed[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveAttackSpeed[willBracket];
|
||||
default:
|
||||
return -2.4;
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthBonus(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getMovementSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return movementSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void applyEffectToEntity(EnumDemonWillType type, int willBracket, LivingEntity target, LivingEntity attacker)
|
||||
{
|
||||
// switch (type)
|
||||
// {
|
||||
// case CORROSIVE:
|
||||
// target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket]));
|
||||
// break;
|
||||
// case DEFAULT:
|
||||
// break;
|
||||
// case DESTRUCTIVE:
|
||||
// break;
|
||||
// case STEADFAST:
|
||||
// if (!target.isEntityAlive())
|
||||
// {
|
||||
// float absorption = attacker.getAbsorptionAmount();
|
||||
// attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127));
|
||||
// attacker.setAbsorptionAmount((float) Math.min(absorption
|
||||
// + target.getMaxHealth() * 0.05f, maxAbsorptionHearts));
|
||||
// }
|
||||
// break;
|
||||
// case VENGEFUL:
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker)
|
||||
{
|
||||
if (super.hitEntity(stack, target, attacker))
|
||||
{
|
||||
if (attacker instanceof PlayerEntity)
|
||||
{
|
||||
PlayerEntity attackerPlayer = (PlayerEntity) attacker;
|
||||
this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer);
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
double will = PlayerDemonWillHandler.getTotalDemonWill(type, attackerPlayer);
|
||||
int willBracket = this.getLevel(stack, will);
|
||||
|
||||
applyEffectToEntity(type, willBracket, target, attackerPlayer);
|
||||
|
||||
// ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
|
||||
// if (offStack.getItem() instanceof ISentientSwordEffectProvider)
|
||||
// {
|
||||
// ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem();
|
||||
// if (provider.providesEffectForWill(type))
|
||||
// {
|
||||
// provider.applyOnHitEffect(type, stack, offStack, attacker, target);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
if (!tag.contains(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
tag.putString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
recalculatePowers(player.getHeldItem(hand), world, player);
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
return oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
private int getLevel(ItemStack stack, double soulsRemaining)
|
||||
{
|
||||
int lvl = -1;
|
||||
for (int i = 0; i < soulBracket.length; i++)
|
||||
{
|
||||
if (soulsRemaining >= soulBracket[i])
|
||||
{
|
||||
lvl = i;
|
||||
}
|
||||
}
|
||||
|
||||
return lvl;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
if (!stack.hasTag())
|
||||
return;
|
||||
|
||||
// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.sentientSword.desc"))));
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.sentientSword.desc"));
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.currentType." + getCurrentType(stack).name().toLowerCase()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity)
|
||||
{
|
||||
recalculatePowers(stack, player.getEntityWorld(), player);
|
||||
|
||||
double drain = this.getDrainOfActivatedSword(stack);
|
||||
if (drain > 0)
|
||||
{
|
||||
EnumDemonWillType type = getCurrentType(stack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
|
||||
if (drain > soulsRemaining)
|
||||
{
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
|
||||
}
|
||||
}
|
||||
|
||||
return super.onLeftClickEntity(stack, player, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getRandomDemonWillDrop(LivingEntity killedEntity, LivingEntity attackingEntity, ItemStack stack, int looting)
|
||||
{
|
||||
List<ItemStack> soulList = new ArrayList<>();
|
||||
|
||||
if (killedEntity.getEntityWorld().getDifficulty() != Difficulty.PEACEFUL && !(killedEntity instanceof IMob))
|
||||
{
|
||||
return soulList;
|
||||
}
|
||||
|
||||
double willModifier = killedEntity instanceof SlimeEntity ? 0.67 : 1;
|
||||
|
||||
IDemonWill soul = ((IDemonWill) BloodMagicItems.MONSTER_SOUL_RAW.get());
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
for (int i = 0; i <= looting; i++)
|
||||
{
|
||||
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4)
|
||||
{
|
||||
ItemStack soulStack = soul.createWill(willModifier
|
||||
* (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble()
|
||||
+ this.getStaticDropOfActivatedSword(stack))
|
||||
* killedEntity.getMaxHealth() / 20d);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
}
|
||||
|
||||
return soulList;
|
||||
}
|
||||
|
||||
// TODO: Change attack speed.
|
||||
@Override
|
||||
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack)
|
||||
{
|
||||
Multimap<Attribute, AttributeModifier> multimap = HashMultimap.create();
|
||||
if (slot == EquipmentSlotType.MAINHAND)
|
||||
{
|
||||
multimap.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), AttributeModifier.Operation.ADDITION));
|
||||
multimap.put(Attributes.ATTACK_SPEED, new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), AttributeModifier.Operation.ADDITION));
|
||||
multimap.put(Attributes.MAX_HEALTH, new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), AttributeModifier.Operation.ADDITION));
|
||||
multimap.put(Attributes.MOVEMENT_SPEED, new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), AttributeModifier.Operation.ADDITION));
|
||||
}
|
||||
|
||||
return multimap;
|
||||
}
|
||||
|
||||
public double getDamageOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE);
|
||||
}
|
||||
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
tag.putDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage);
|
||||
}
|
||||
|
||||
public double getDrainOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN);
|
||||
}
|
||||
|
||||
public void setDrainOfActivatedSword(ItemStack stack, double drain)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
tag.putDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain);
|
||||
}
|
||||
|
||||
public double getStaticDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP);
|
||||
}
|
||||
|
||||
public void setStaticDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
tag.putDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop);
|
||||
}
|
||||
|
||||
public double getDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP);
|
||||
}
|
||||
|
||||
public void setDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
tag.putDouble(Constants.NBT.SOUL_SWORD_DROP, drop);
|
||||
}
|
||||
|
||||
public double getHealthBonusOfSword(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
|
||||
}
|
||||
|
||||
public void setHealthBonusOfSword(ItemStack stack, double hp)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
tag.putDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
|
||||
}
|
||||
|
||||
public double getAttackSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED);
|
||||
}
|
||||
|
||||
public void setAttackSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
tag.putDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed);
|
||||
}
|
||||
|
||||
public double getSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED);
|
||||
}
|
||||
|
||||
public void setSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
CompoundNBT tag = stack.getTag();
|
||||
|
||||
tag.putDouble(Constants.NBT.SOUL_SWORD_SPEED, speed);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,260 @@
|
|||
package wayoftime.bloodmagic.common.item.soul;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.iface.IMultiWillTool;
|
||||
import wayoftime.bloodmagic.util.ChatUtil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.will.IDemonWill;
|
||||
import wayoftime.bloodmagic.will.IDemonWillGem;
|
||||
import wayoftime.bloodmagic.will.PlayerDemonWillHandler;
|
||||
|
||||
public class ItemSoulGem extends Item implements IDemonWillGem, IMultiWillTool
|
||||
{
|
||||
private final int maxWill;
|
||||
private final String name;
|
||||
|
||||
public ItemSoulGem(String name, int maxWill)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
this.name = name;
|
||||
this.maxWill = maxWill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items)
|
||||
{
|
||||
if (this.isInGroup(group))
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
ItemStack stack = new ItemStack(this);
|
||||
this.setCurrentType(type, stack);
|
||||
this.setWill(type, stack, maxWill);
|
||||
items.add(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10);
|
||||
|
||||
double filled = PlayerDemonWillHandler.addDemonWill(type, player, drain, stack);
|
||||
this.drainWill(type, stack, filled, true);
|
||||
|
||||
return new ActionResult<>(ActionResultType.PASS, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
if (!stack.hasTag())
|
||||
return;
|
||||
|
||||
Items d;
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.soulGem." + name));
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.will", ChatUtil.DECIMAL_FORMAT.format(getWill(type, stack))));
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.currentType." + getCurrentType(stack).name().toLowerCase()));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
double maxWill = getMaxWill(type, stack);
|
||||
if (maxWill <= 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 1.0 - (getWill(type, stack) / maxWill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
double maxWill = getMaxWill(type, stack);
|
||||
if (maxWill <= 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float) (getWill(type, stack)) / (float) maxWill) / 3.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack fillDemonWillGem(ItemStack soulGemStack, ItemStack soulStack)
|
||||
{
|
||||
if (soulStack != null && soulStack.getItem() instanceof IDemonWill)
|
||||
{
|
||||
EnumDemonWillType thisType = this.getCurrentType(soulGemStack);
|
||||
if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack))
|
||||
{
|
||||
return soulStack;
|
||||
}
|
||||
IDemonWill soul = (IDemonWill) soulStack.getItem();
|
||||
double soulsLeft = getWill(thisType, soulGemStack);
|
||||
|
||||
if (soulsLeft < getMaxWill(thisType, soulGemStack))
|
||||
{
|
||||
double newSoulsLeft = Math.min(soulsLeft
|
||||
+ soul.getWill(thisType, soulStack), getMaxWill(thisType, soulGemStack));
|
||||
soul.drainWill(thisType, soulStack, newSoulsLeft - soulsLeft);
|
||||
|
||||
setWill(thisType, soulGemStack, newSoulsLeft);
|
||||
if (soul.getWill(thisType, soulStack) <= 0)
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return soulStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWill(EnumDemonWillType type, ItemStack soulGemStack)
|
||||
{
|
||||
if (!type.equals(getCurrentType(soulGemStack)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
CompoundNBT tag = soulGemStack.getTag();
|
||||
|
||||
return tag.getDouble(Constants.NBT.SOULS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWill(EnumDemonWillType type, ItemStack soulGemStack, double souls)
|
||||
{
|
||||
setCurrentType(type, soulGemStack);
|
||||
|
||||
CompoundNBT tag = soulGemStack.getTag();
|
||||
|
||||
tag.putDouble(Constants.NBT.SOULS, souls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount, boolean doDrain)
|
||||
{
|
||||
EnumDemonWillType currentType = this.getCurrentType(soulGemStack);
|
||||
if (currentType != type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
double souls = getWill(type, soulGemStack);
|
||||
|
||||
double soulsDrained = Math.min(drainAmount, souls);
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
setWill(type, soulGemStack, souls - soulsDrained);
|
||||
}
|
||||
|
||||
return soulsDrained;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxWill(EnumDemonWillType type, ItemStack soulGemStack)
|
||||
{
|
||||
EnumDemonWillType currentType = getCurrentType(soulGemStack);
|
||||
if (!type.equals(currentType) && currentType != EnumDemonWillType.DEFAULT)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return maxWill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack soulGemStack)
|
||||
{
|
||||
NBTHelper.checkNBT(soulGemStack);
|
||||
|
||||
CompoundNBT tag = soulGemStack.getTag();
|
||||
|
||||
if (!tag.contains(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(EnumDemonWillType type, ItemStack soulGemStack)
|
||||
{
|
||||
NBTHelper.checkNBT(soulGemStack);
|
||||
|
||||
CompoundNBT tag = soulGemStack.getTag();
|
||||
|
||||
if (type == EnumDemonWillType.DEFAULT)
|
||||
{
|
||||
if (tag.contains(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
tag.remove(Constants.NBT.WILL_TYPE);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
tag.putString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill)
|
||||
{
|
||||
if (!type.equals(getCurrentType(stack)) && this.getWill(getCurrentType(stack), stack) > 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double current = this.getWill(type, stack);
|
||||
double maxWill = this.getMaxWill(type, stack);
|
||||
|
||||
double filled = Math.min(fillAmount, maxWill - current);
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
this.setWill(type, stack, filled + current);
|
||||
}
|
||||
|
||||
return filled;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package wayoftime.bloodmagic.common.item.soul;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.SnowballItem;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntitySoulSnare;
|
||||
|
||||
public class ItemSoulSnare extends Item
|
||||
{
|
||||
public static String[] names =
|
||||
{ "base" };
|
||||
|
||||
public ItemSoulSnare()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(16).group(BloodMagic.TAB));
|
||||
|
||||
// setTranslationKey(BloodMagic.MODID + ".soulSnare.");
|
||||
// setCreativeTab(BloodMagic.TAB_BM);
|
||||
// setHasSubtypes(true);
|
||||
// setMaxStackSize(16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand hand)
|
||||
{
|
||||
ItemStack stack = playerIn.getHeldItem(hand);
|
||||
if (!playerIn.isCreative())
|
||||
{
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
SnowballItem d;
|
||||
|
||||
worldIn.playSound((PlayerEntity) null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F
|
||||
/ (random.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!worldIn.isRemote)
|
||||
{
|
||||
System.out.println("Attempting to spawn");
|
||||
EntitySoulSnare snare = new EntitySoulSnare(worldIn, playerIn);
|
||||
snare.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
|
||||
worldIn.addEntity(snare);
|
||||
//
|
||||
// SnowballEntity snowballentity = new SnowballEntity(worldIn, playerIn);
|
||||
// snowballentity.setItem(itemstack);
|
||||
// snowballentity.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
|
||||
// worldIn.addEntity(snowballentity);
|
||||
}
|
||||
|
||||
return new ActionResult<>(ActionResultType.SUCCESS, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.soulSnare.desc"));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package wayoftime.bloodmagic.common.recipe;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.data.recipe.builder.AlchemyArrayRecipeBuilder;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
|
||||
public class AlchemyArrayRecipeProvider implements ISubRecipeProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
String basePath = "array/";
|
||||
// AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/airsigil.png"), Ingredient.fromItems(Items.STONE), Ingredient.fromItems(Items.STONE), new ItemStack(Items.DIAMOND)).build(consumer, BloodMagic.rl(basePath
|
||||
// + "airsigil"));
|
||||
AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/divinationsigil.png"), Ingredient.fromItems(Items.REDSTONE), Ingredient.fromItems(BloodMagicItems.SLATE.get()), new ItemStack(BloodMagicItems.DIVINATION_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "divinationsigil"));
|
||||
AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/watersigil.png"), Ingredient.fromItems(BloodMagicItems.REAGENT_WATER.get()), Ingredient.fromItems(BloodMagicItems.SLATE.get()), new ItemStack(BloodMagicItems.WATER_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "watersigil"));
|
||||
AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/lavasigil.png"), Ingredient.fromItems(BloodMagicItems.REAGENT_LAVA.get()), Ingredient.fromItems(BloodMagicItems.SLATE.get()), new ItemStack(BloodMagicItems.LAVA_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "lavasigil"));
|
||||
AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/voidsigil.png"), Ingredient.fromItems(BloodMagicItems.REAGENT_VOID.get()), Ingredient.fromItems(BloodMagicItems.REINFORCED_SLATE.get()), new ItemStack(BloodMagicItems.VOID_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "voidsigil"));
|
||||
AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/growthsigil.png"), Ingredient.fromItems(BloodMagicItems.REAGENT_GROWTH.get()), Ingredient.fromItems(BloodMagicItems.REINFORCED_SLATE.get()), new ItemStack(BloodMagicItems.GREEN_GROVE_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "growthsigil"));
|
||||
AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/fastminersigil.png"), Ingredient.fromItems(BloodMagicItems.REAGENT_FAST_MINER.get()), Ingredient.fromItems(BloodMagicItems.REINFORCED_SLATE.get()), new ItemStack(BloodMagicItems.FAST_MINER_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "fastminersigil"));
|
||||
AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/magnetismsigil.png"), Ingredient.fromItems(BloodMagicItems.REAGENT_MAGNETISM.get()), Ingredient.fromItems(BloodMagicItems.IMBUED_SLATE.get()), new ItemStack(BloodMagicItems.MAGNETISM_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "magnetismsigil"));
|
||||
AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/lightsigil.png"), Ingredient.fromItems(BloodMagicItems.REAGENT_BLOOD_LIGHT.get()), Ingredient.fromItems(BloodMagicItems.IMBUED_SLATE.get()), new ItemStack(BloodMagicItems.BLOOD_LIGHT_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "bloodlightsigil"));
|
||||
AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/airsigil.png"), Ingredient.fromItems(BloodMagicItems.REAGENT_AIR.get()), Ingredient.fromItems(BloodMagicItems.REINFORCED_SLATE.get()), new ItemStack(BloodMagicItems.AIR_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "airsigil"));
|
||||
// AlchemyArrayRecipeBuilder.array(BloodMagic.rl("textures/models/alchemyarrays/fastminersigil.png"), Ingredient.fromItems(BloodMagicItems.REAGENT_FAST_MINER.get()), Ingredient.fromItems(BloodMagicItems.REINFORCED_SLATE.get()), new ItemStack(BloodMagicItems.FAST_MINER_SIGIL.get())).build(consumer, BloodMagic.rl(basePath + "frostsigil"));
|
||||
// BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), new ItemStack(BloodMagicItems.WEAK_BLOOD_ORB.get()), AltarTier.ONE.ordinal(), 2000, 2, 1).build(consumer, new ResourceLocation(BloodMagic.MODID, basePath
|
||||
// + "weakbloodorb"));
|
||||
// BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.STONE), new ItemStack(BloodMagicItems.SLATE.get()), AltarTier.ONE.ordinal(), 1000, 5, 5).build(consumer, new ResourceLocation(BloodMagic.MODID, basePath
|
||||
// + "slate"));
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package wayoftime.bloodmagic.common.recipe;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.altar.AltarTier;
|
||||
import wayoftime.bloodmagic.common.data.recipe.builder.BloodAltarRecipeBuilder;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
|
||||
public class BloodAltarRecipeProvider implements ISubRecipeProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
String basePath = "altar/";
|
||||
|
||||
// ONE
|
||||
BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), new ItemStack(BloodMagicItems.WEAK_BLOOD_ORB.get()), AltarTier.ONE.ordinal(), 2000, 2, 1).build(consumer, new ResourceLocation(BloodMagic.MODID, basePath + "weakbloodorb"));
|
||||
BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.STONE), new ItemStack(BloodMagicItems.SLATE.get()), AltarTier.ONE.ordinal(), 1000, 5, 5).build(consumer, new ResourceLocation(BloodMagic.MODID, basePath + "slate"));
|
||||
|
||||
// TWO
|
||||
BloodAltarRecipeBuilder.altar(Ingredient.fromItems(BloodMagicItems.SLATE.get()), new ItemStack(BloodMagicItems.REINFORCED_SLATE.get()), AltarTier.THREE.ordinal(), 2000, 5, 5).build(consumer, BloodMagic.rl(basePath + "reinforcedslate"));
|
||||
BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_REDSTONE), new ItemStack(BloodMagicItems.APPRENTICE_BLOOD_ORB.get()), AltarTier.TWO.ordinal(), 5000, 5, 5).build(consumer, BloodMagic.rl(basePath + "apprenticebloodorb"));
|
||||
BloodAltarRecipeBuilder.altar(Ingredient.fromItems(Items.IRON_SWORD), new ItemStack(BloodMagicItems.DAGGER_OF_SACRIFICE.get()), AltarTier.TWO.ordinal(), 3000, 5, 5).build(consumer, BloodMagic.rl(basePath + "daggerofsacrifice"));
|
||||
|
||||
// THREE
|
||||
BloodAltarRecipeBuilder.altar(Ingredient.fromItems(BloodMagicItems.REINFORCED_SLATE.get()), new ItemStack(BloodMagicItems.IMBUED_SLATE.get()), AltarTier.THREE.ordinal(), 5000, 15, 10).build(consumer, BloodMagic.rl(basePath + "imbuedslate"));
|
||||
BloodAltarRecipeBuilder.altar(Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_GOLD), new ItemStack(BloodMagicItems.MAGICIAN_BLOOD_ORB.get()), AltarTier.THREE.ordinal(), 25000, 20, 20).build(consumer, BloodMagic.rl(basePath + "magicianbloodorb"));
|
||||
|
||||
// FOUR
|
||||
BloodAltarRecipeBuilder.altar(Ingredient.fromItems(BloodMagicItems.IMBUED_SLATE.get()), new ItemStack(BloodMagicItems.DEMONIC_SLATE.get()), AltarTier.FOUR.ordinal(), 15000, 20, 20).build(consumer, BloodMagic.rl(basePath + "demonicslate"));
|
||||
|
||||
// BloodAltarRecipeBuilder.altar(input, output, minimumTier, syphon, consumeRate, drainRate).build(consumer, BloodMagic.rl(basePath + ""));
|
||||
|
||||
// registrar.addBloodAltar(new OreIngredient("stone"), ItemSlate.SlateType.BLANK.getStack(), AltarTier.ONE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.BUCKET), FluidUtil.getFilledBucket(new FluidStack(BlockLifeEssence.getLifeEssence(), Fluid.BUCKET_VOLUME)), AltarTier.ONE.ordinal(), 1000, 5, 0);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.BOOK), new ItemStack(RegistrarBloodMagicItems.SANGUINE_BOOK), AltarTier.ONE.ordinal(), 1000, 20, 0);
|
||||
//
|
||||
// // TWO
|
||||
// registrar.addBloodAltar(new OreIngredient("blockRedstone"), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_APPRENTICE), AltarTier.TWO.ordinal(), 5000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(ItemSlate.SlateType.BLANK.getStack()), ItemSlate.SlateType.REINFORCED.getStack(), AltarTier.TWO.ordinal(), 2000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.IRON_SWORD), new ItemStack(RegistrarBloodMagicItems.DAGGER_OF_SACRIFICE), AltarTier.TWO.ordinal(), 3000, 5, 5);
|
||||
//
|
||||
// // THREE
|
||||
// registrar.addBloodAltar(new OreIngredient("blockGold"), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_MAGICIAN), AltarTier.THREE.ordinal(), 25000, 20, 20);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(ItemSlate.SlateType.REINFORCED.getStack()), ItemSlate.SlateType.IMBUED.getStack(), AltarTier.THREE.ordinal(), 5000, 15, 10);
|
||||
// registrar.addBloodAltar(new OreIngredient("obsidian"), EnumRuneType.EARTH.getStack(), AltarTier.THREE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(new OreIngredient("blockLapis"), EnumRuneType.WATER.getStack(), AltarTier.THREE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.MAGMA_CREAM), EnumRuneType.FIRE.getStack(), AltarTier.THREE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(Items.GHAST_TEAR), EnumRuneType.AIR.getStack(), AltarTier.THREE.ordinal(), 1000, 5, 5);
|
||||
// registrar.addBloodAltar(Ingredient.fromItem(RegistrarBloodMagicItems.LAVA_CRYSTAL), new ItemStack(RegistrarBloodMagicItems.ACTIVATION_CRYSTAL), AltarTier.THREE.ordinal(), 10000, 20, 10);
|
||||
//
|
||||
// // FOUR
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(new ItemStack(RegistrarBloodMagicItems.BLOOD_SHARD)), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_MASTER), AltarTier.FOUR.ordinal(), 40000, 30, 50);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(ItemSlate.SlateType.IMBUED.getStack()), ItemSlate.SlateType.DEMONIC.getStack(), AltarTier.FOUR.ordinal(), 15000, 20, 20);
|
||||
// registrar.addBloodAltar(new OreIngredient("blockCoal"), EnumRuneType.DUSK.getStack(), AltarTier.FOUR.ordinal(), 2000, 20, 10);
|
||||
// registrar.addBloodAltar(new OreIngredient("enderpearl"), new ItemStack(RegistrarBloodMagicItems.TELEPOSITION_FOCUS), AltarTier.FOUR.ordinal(), 2000, 10, 10);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(new ItemStack(RegistrarBloodMagicItems.TELEPOSITION_FOCUS)), new ItemStack(RegistrarBloodMagicItems.TELEPOSITION_FOCUS, 1, 1), AltarTier.FOUR.ordinal(), 10000, 20, 10);
|
||||
//
|
||||
// // FIVE
|
||||
// registrar.addBloodAltar(new OreIngredient("netherStar"), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_ARCHMAGE), AltarTier.FIVE.ordinal(), 80000, 50, 100);
|
||||
// registrar.addBloodAltar(Ingredient.fromStacks(ItemSlate.SlateType.DEMONIC.getStack()), ItemSlate.SlateType.ETHEREAL.getStack(), AltarTier.FIVE.ordinal(), 30000, 40, 100);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package wayoftime.bloodmagic.common.recipe;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
|
||||
|
||||
public class BloodMagicRecipeType
|
||||
{
|
||||
public static final IRecipeType<RecipeBloodAltar> ALTAR = IRecipeType.register("altar");
|
||||
public static final IRecipeType<RecipeAlchemyArray> ARRAY = IRecipeType.register("array");
|
||||
public static final IRecipeType<RecipeTartaricForge> TARTARICFORGE = IRecipeType.register("soulforge");
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package wayoftime.bloodmagic.common.recipe;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
|
||||
/**
|
||||
* Interface for helping split the recipe provider over multiple classes to make
|
||||
* it a bit easier to interact with
|
||||
*/
|
||||
public interface ISubRecipeProvider
|
||||
{
|
||||
void addRecipes(Consumer<IFinishedRecipe> consumer);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package wayoftime.bloodmagic.common.recipe;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.data.IFinishedRecipe;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.data.recipe.builder.TartaricForgeRecipeBuilder;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
|
||||
public class TartaricForgeRecipeProvider implements ISubRecipeProvider
|
||||
{
|
||||
|
||||
@Override
|
||||
public void addRecipes(Consumer<IFinishedRecipe> consumer)
|
||||
{
|
||||
String basePath = "soulforge/";
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.PETTY_GEM.get()), 1, 1, Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.INGOTS_GOLD), Ingredient.fromTag(Tags.Items.GLASS), Ingredient.fromTag(Tags.Items.GEMS_LAPIS)).build(consumer, BloodMagic.rl(basePath + "pettytartaricgem"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.LESSER_GEM.get()), 60, 20, Ingredient.fromItems(BloodMagicItems.PETTY_GEM.get()), Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_REDSTONE), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_LAPIS)).build(consumer, BloodMagic.rl(basePath + "lessertartaricgem"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.COMMON_GEM.get()), 240, 50, Ingredient.fromItems(BloodMagicItems.LESSER_GEM.get()), Ingredient.fromTag(Tags.Items.GEMS_DIAMOND), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_GOLD), Ingredient.fromItems(BloodMagicItems.IMBUED_SLATE.get())).build(consumer, BloodMagic.rl(basePath + "commontartaricgem"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.SENTIENT_SWORD.get()), 0, 0, Ingredient.fromItems(BloodMagicItems.PETTY_GEM.get()), Ingredient.fromItems(Items.IRON_SWORD)).build(consumer, BloodMagic.rl(basePath + "sentientsword"));
|
||||
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.ARCANE_ASHES.get()), 0, 0, Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.DYES_WHITE), Ingredient.fromTag(Tags.Items.GUNPOWDER), Ingredient.fromTag(ItemTags.COALS)).build(consumer, BloodMagic.rl(basePath + "arcaneashes"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_WATER.get()), 10, 3, Ingredient.fromItems(Items.SUGAR), Ingredient.fromItems(Items.WATER_BUCKET), Ingredient.fromItems(Items.WATER_BUCKET)).build(consumer, BloodMagic.rl(basePath + "reagent_water"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_LAVA.get()), 32, 10, Ingredient.fromItems(Items.LAVA_BUCKET), Ingredient.fromTag(Tags.Items.DUSTS_REDSTONE), Ingredient.fromTag(Tags.Items.COBBLESTONE), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_COAL)).build(consumer, BloodMagic.rl(basePath + "reagent_lava"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_VOID.get()), 64, 10, Ingredient.fromItems(Items.BUCKET), Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.GUNPOWDER)).build(consumer, BloodMagic.rl(basePath + "reagent_void"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_GROWTH.get()), 128, 20, Ingredient.fromTag(ItemTags.SAPLINGS), Ingredient.fromTag(ItemTags.SAPLINGS), Ingredient.fromItems(Items.SUGAR_CANE), Ingredient.fromItems(Items.SUGAR)).build(consumer, BloodMagic.rl(basePath + "reagent_growth"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_MAGNETISM.get()), 600, 10, Ingredient.fromTag(Tags.Items.STRING), Ingredient.fromTag(Tags.Items.INGOTS_GOLD), Ingredient.fromTag(Tags.Items.INGOTS_GOLD), Ingredient.fromTag(Tags.Items.STORAGE_BLOCKS_IRON)).build(consumer, BloodMagic.rl(basePath + "reagent_magnetism"));
|
||||
TartaricForgeRecipeBuilder.tartaricForge(new ItemStack(BloodMagicItems.REAGENT_FAST_MINER.get()), 128, 20, Ingredient.fromItems(Items.IRON_PICKAXE), Ingredient.fromItems(Items.IRON_AXE), Ingredient.fromItems(Items.IRON_SHOVEL), Ingredient.fromTag(Tags.Items.GUNPOWDER)).build(consumer, BloodMagic.rl(basePath + "reagent_fastminer"));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package wayoftime.bloodmagic.common.recipe.serializer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import wayoftime.bloodmagic.api.SerializerHelper;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
|
||||
public class AlchemyArrayRecipeSerializer<RECIPE extends RecipeAlchemyArray>
|
||||
extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<RECIPE>
|
||||
{
|
||||
private final IFactory<RECIPE> factory;
|
||||
|
||||
public AlchemyArrayRecipeSerializer(IFactory<RECIPE> factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json)
|
||||
{
|
||||
JsonElement input1 = JSONUtils.isJsonArray(json, Constants.JSON.BASEINPUT)
|
||||
? JSONUtils.getJsonArray(json, Constants.JSON.BASEINPUT)
|
||||
: JSONUtils.getJsonObject(json, Constants.JSON.BASEINPUT);
|
||||
|
||||
JsonElement input2 = JSONUtils.isJsonArray(json, Constants.JSON.ADDEDINPUT)
|
||||
? JSONUtils.getJsonArray(json, Constants.JSON.ADDEDINPUT)
|
||||
: JSONUtils.getJsonObject(json, Constants.JSON.ADDEDINPUT);
|
||||
|
||||
Ingredient baseInput = Ingredient.deserialize(input1);
|
||||
Ingredient addedInput = Ingredient.deserialize(input2);
|
||||
ResourceLocation texture = null;
|
||||
if (json.has(Constants.JSON.TEXTURE))
|
||||
texture = new ResourceLocation(JSONUtils.getString(json, Constants.JSON.TEXTURE));
|
||||
ItemStack output = SerializerHelper.getItemStack(json, Constants.JSON.OUTPUT);
|
||||
|
||||
return this.factory.create(recipeId, texture, baseInput, addedInput, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResourceLocation texture = null;
|
||||
if (buffer.readBoolean())
|
||||
texture = buffer.readResourceLocation();
|
||||
Ingredient baseInput = Ingredient.read(buffer);
|
||||
Ingredient addedInput = Ingredient.read(buffer);
|
||||
ItemStack output = buffer.readItemStack();
|
||||
|
||||
return this.factory.create(recipeId, texture, baseInput, addedInput, output);
|
||||
} catch (Exception e)
|
||||
{
|
||||
// Mekanism.logger.error("Error reading electrolysis recipe from packet.", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@Nonnull PacketBuffer buffer, @Nonnull RECIPE recipe)
|
||||
{
|
||||
try
|
||||
{
|
||||
recipe.write(buffer);
|
||||
} catch (Exception e)
|
||||
{
|
||||
// Mekanism.logger.error("Error writing electrolysis recipe to packet.", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IFactory<RECIPE extends RecipeAlchemyArray>
|
||||
{
|
||||
RECIPE create(ResourceLocation id, ResourceLocation texture, Ingredient baseInput, Ingredient addedInput, ItemStack output);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package wayoftime.bloodmagic.common.recipe.serializer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import wayoftime.bloodmagic.api.SerializerHelper;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
|
||||
public class BloodAltarRecipeSerializer<RECIPE extends RecipeBloodAltar>
|
||||
extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<RECIPE>
|
||||
{
|
||||
private final IFactory<RECIPE> factory;
|
||||
|
||||
public BloodAltarRecipeSerializer(IFactory<RECIPE> factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json)
|
||||
{
|
||||
JsonElement input = JSONUtils.isJsonArray(json, Constants.JSON.INPUT)
|
||||
? JSONUtils.getJsonArray(json, Constants.JSON.INPUT)
|
||||
: JSONUtils.getJsonObject(json, Constants.JSON.INPUT);
|
||||
|
||||
Ingredient inputIng = Ingredient.deserialize(input);
|
||||
ItemStack output = SerializerHelper.getItemStack(json, Constants.JSON.OUTPUT);
|
||||
int minimumTier = JSONUtils.getInt(json, Constants.JSON.ALTAR_TIER);
|
||||
int syphon = JSONUtils.getInt(json, Constants.JSON.ALTAR_SYPHON);
|
||||
int consumeRate = JSONUtils.getInt(json, Constants.JSON.ALTAR_CONSUMPTION_RATE);
|
||||
int drainRate = JSONUtils.getInt(json, Constants.JSON.ALTAR_DRAIN_RATE);
|
||||
|
||||
return this.factory.create(recipeId, inputIng, output, minimumTier, syphon, consumeRate, drainRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
Ingredient input = Ingredient.read(buffer);
|
||||
ItemStack output = buffer.readItemStack();
|
||||
int minimumTier = buffer.readInt();
|
||||
int syphon = buffer.readInt();
|
||||
int consumeRate = buffer.readInt();
|
||||
int drainRate = buffer.readInt();
|
||||
|
||||
return this.factory.create(recipeId, input, output, minimumTier, syphon, consumeRate, drainRate);
|
||||
} catch (Exception e)
|
||||
{
|
||||
// Mekanism.logger.error("Error reading electrolysis recipe from packet.", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@Nonnull PacketBuffer buffer, @Nonnull RECIPE recipe)
|
||||
{
|
||||
try
|
||||
{
|
||||
recipe.write(buffer);
|
||||
} catch (Exception e)
|
||||
{
|
||||
// Mekanism.logger.error("Error writing electrolysis recipe to packet.", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IFactory<RECIPE extends RecipeBloodAltar>
|
||||
{
|
||||
RECIPE create(ResourceLocation id, Ingredient input, ItemStack output, int minimumTier, int syphon, int consumeRate, int drainRate);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package wayoftime.bloodmagic.common.recipe.serializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import wayoftime.bloodmagic.api.SerializerHelper;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
|
||||
public class TartaricForgeRecipeSerializer<RECIPE extends RecipeTartaricForge>
|
||||
extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<RECIPE>
|
||||
{
|
||||
|
||||
private final IFactory<RECIPE> factory;
|
||||
|
||||
public TartaricForgeRecipeSerializer(IFactory<RECIPE> factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull JsonObject json)
|
||||
{
|
||||
List<Ingredient> inputList = new ArrayList<Ingredient>();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (json.has(Constants.JSON.INPUT + i))
|
||||
{
|
||||
JsonElement input = JSONUtils.isJsonArray(json, Constants.JSON.INPUT + i)
|
||||
? JSONUtils.getJsonArray(json, Constants.JSON.INPUT + i)
|
||||
: JSONUtils.getJsonObject(json, Constants.JSON.INPUT + i);
|
||||
inputList.add(Ingredient.deserialize(input));
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack output = SerializerHelper.getItemStack(json, Constants.JSON.OUTPUT);
|
||||
|
||||
float minimumSouls = JSONUtils.getFloat(json, Constants.JSON.TARTARIC_MINIMUM);
|
||||
float soulDrain = JSONUtils.getFloat(json, Constants.JSON.TARTARIC_DRAIN);
|
||||
|
||||
return this.factory.create(recipeId, inputList, output, minimumSouls, soulDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RECIPE read(@Nonnull ResourceLocation recipeId, @Nonnull PacketBuffer buffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
int size = buffer.readInt();
|
||||
List<Ingredient> input = new ArrayList<Ingredient>(size);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
input.add(i, Ingredient.read(buffer));
|
||||
}
|
||||
|
||||
ItemStack output = buffer.readItemStack();
|
||||
double minimumSouls = buffer.readDouble();
|
||||
double soulDrain = buffer.readDouble();
|
||||
|
||||
return this.factory.create(recipeId, input, output, minimumSouls, soulDrain);
|
||||
} catch (Exception e)
|
||||
{
|
||||
// Mekanism.logger.error("Error reading electrolysis recipe from packet.", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@Nonnull PacketBuffer buffer, @Nonnull RECIPE recipe)
|
||||
{
|
||||
try
|
||||
{
|
||||
recipe.write(buffer);
|
||||
} catch (Exception e)
|
||||
{
|
||||
// Mekanism.logger.error("Error writing electrolysis recipe to packet.", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface IFactory<RECIPE extends RecipeTartaricForge>
|
||||
{
|
||||
RECIPE create(ResourceLocation id, List<Ingredient> input, ItemStack output, double minimumSouls, double soulDrain);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package wayoftime.bloodmagic.common.registration;
|
||||
|
||||
public interface INamedEntry
|
||||
{
|
||||
|
||||
/**
|
||||
* Used for retrieving the path/name of a registry object before the registry
|
||||
* object has been fully initialized
|
||||
*/
|
||||
String getInternalRegistryName();
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package wayoftime.bloodmagic.common.registration;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
import net.minecraftforge.registries.RegistryBuilder;
|
||||
|
||||
public class WrappedDeferredRegister<T extends IForgeRegistryEntry<T>>
|
||||
{
|
||||
protected final DeferredRegister<T> internal;
|
||||
|
||||
protected WrappedDeferredRegister(String modid, IForgeRegistry<T> registry)
|
||||
{
|
||||
internal = DeferredRegister.create(registry, modid);
|
||||
}
|
||||
|
||||
/**
|
||||
* @apiNote For use with custom registries
|
||||
*/
|
||||
protected WrappedDeferredRegister(String modid, Class<T> base)
|
||||
{
|
||||
internal = DeferredRegister.create(base, modid);
|
||||
}
|
||||
|
||||
protected <I extends T, W extends WrappedRegistryObject<I>> W register(String name, Supplier<? extends I> sup,
|
||||
Function<RegistryObject<I>, W> objectWrapper)
|
||||
{
|
||||
return objectWrapper.apply(internal.register(name, sup));
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from mekanism and for custom registries
|
||||
*/
|
||||
public void createAndRegister(IEventBus bus, String name)
|
||||
{
|
||||
internal.makeRegistry(name, RegistryBuilder::new);
|
||||
register(bus);
|
||||
}
|
||||
|
||||
public void register(IEventBus bus)
|
||||
{
|
||||
internal.register(bus);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package wayoftime.bloodmagic.common.registration;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
public class WrappedRegistryObject<T extends IForgeRegistryEntry<? super T>> implements Supplier<T>, INamedEntry
|
||||
{
|
||||
|
||||
protected RegistryObject<T> registryObject;
|
||||
|
||||
protected WrappedRegistryObject(RegistryObject<T> registryObject)
|
||||
{
|
||||
this.registryObject = registryObject;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public T get()
|
||||
{
|
||||
return registryObject.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInternalRegistryName()
|
||||
{
|
||||
return registryObject.getId().getPath();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package wayoftime.bloodmagic.common.registration.impl;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.common.registration.WrappedDeferredRegister;
|
||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
||||
|
||||
public class BloodOrbDeferredRegister extends WrappedDeferredRegister<BloodOrb>
|
||||
{
|
||||
public BloodOrbDeferredRegister(String modid)
|
||||
{
|
||||
super(modid, BloodOrb.class);
|
||||
}
|
||||
|
||||
public BloodOrbRegistryObject<BloodOrb> register(String name, ResourceLocation rl, int tier, int capacity,
|
||||
int fillRate)
|
||||
{
|
||||
return register(name, () -> new BloodOrb(rl, tier, capacity, fillRate));
|
||||
}
|
||||
|
||||
public <ORB extends BloodOrb> BloodOrbRegistryObject<ORB> register(String name, Supplier<? extends ORB> sup)
|
||||
{
|
||||
return register(name, sup, BloodOrbRegistryObject::new);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package wayoftime.bloodmagic.common.registration.impl;
|
||||
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import wayoftime.bloodmagic.common.registration.WrappedRegistryObject;
|
||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
||||
|
||||
public class BloodOrbRegistryObject<ORB extends BloodOrb> extends WrappedRegistryObject<ORB>
|
||||
{
|
||||
public BloodOrbRegistryObject(RegistryObject<ORB> registryObject)
|
||||
{
|
||||
super(registryObject);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package wayoftime.bloodmagic.common.registration.impl;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.common.registration.WrappedDeferredRegister;
|
||||
|
||||
public class EntityTypeDeferredRegister extends WrappedDeferredRegister<EntityType<?>>
|
||||
{
|
||||
|
||||
public EntityTypeDeferredRegister(String modid)
|
||||
{
|
||||
super(modid, ForgeRegistries.ENTITIES);
|
||||
}
|
||||
|
||||
public <ENTITY extends Entity> EntityTypeRegistryObject<ENTITY> register(String name, EntityType.Builder<ENTITY> builder)
|
||||
{
|
||||
return register(name, () -> builder.build(name), EntityTypeRegistryObject::new);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package wayoftime.bloodmagic.common.registration.impl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import wayoftime.bloodmagic.api.providers.IEntityTypeProvider;
|
||||
import wayoftime.bloodmagic.common.registration.WrappedRegistryObject;
|
||||
|
||||
public class EntityTypeRegistryObject<ENTITY extends Entity> extends WrappedRegistryObject<EntityType<ENTITY>>
|
||||
implements IEntityTypeProvider
|
||||
{
|
||||
|
||||
public EntityTypeRegistryObject(RegistryObject<EntityType<ENTITY>> registryObject)
|
||||
{
|
||||
super(registryObject);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public EntityType<ENTITY> getEntityType()
|
||||
{
|
||||
return get();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package wayoftime.bloodmagic.common.registration.impl;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.common.registration.WrappedDeferredRegister;
|
||||
|
||||
public class IRecipeSerializerDeferredRegister extends WrappedDeferredRegister<IRecipeSerializer<?>>
|
||||
{
|
||||
|
||||
public IRecipeSerializerDeferredRegister(String modid)
|
||||
{
|
||||
super(modid, ForgeRegistries.RECIPE_SERIALIZERS);
|
||||
}
|
||||
|
||||
public <RECIPE extends IRecipe<?>> IRecipeSerializerRegistryObject<RECIPE> register(String name,
|
||||
Supplier<IRecipeSerializer<RECIPE>> sup)
|
||||
{
|
||||
return register(name, sup, IRecipeSerializerRegistryObject::new);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package wayoftime.bloodmagic.common.registration.impl;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import wayoftime.bloodmagic.common.registration.WrappedRegistryObject;
|
||||
|
||||
public class IRecipeSerializerRegistryObject<RECIPE extends IRecipe<?>>
|
||||
extends WrappedRegistryObject<IRecipeSerializer<RECIPE>>
|
||||
{
|
||||
|
||||
public IRecipeSerializerRegistryObject(RegistryObject<IRecipeSerializer<RECIPE>> registryObject)
|
||||
{
|
||||
super(registryObject);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public IRecipeSerializer<RECIPE> getRecipeSerializer()
|
||||
{
|
||||
return get();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package wayoftime.bloodmagic.common.registries;
|
||||
|
||||
import net.minecraft.entity.EntityClassification;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.registration.impl.EntityTypeDeferredRegister;
|
||||
import wayoftime.bloodmagic.common.registration.impl.EntityTypeRegistryObject;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntityBloodLight;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntitySoulSnare;
|
||||
|
||||
public class BloodMagicEntityTypes
|
||||
{
|
||||
private BloodMagicEntityTypes()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static final EntityTypeDeferredRegister ENTITY_TYPES = new EntityTypeDeferredRegister(BloodMagic.MODID);
|
||||
|
||||
public static final EntityTypeRegistryObject<EntitySoulSnare> SNARE = ENTITY_TYPES.register("soulsnare", EntityType.Builder.<EntitySoulSnare>create(EntitySoulSnare::new, EntityClassification.MISC).setTrackingRange(64).setUpdateInterval(1).size(0.25f, 0.25f));
|
||||
public static final EntityTypeRegistryObject<EntityBloodLight> BLOOD_LIGHT = ENTITY_TYPES.register("bloodlight", EntityType.Builder.<EntityBloodLight>create(EntityBloodLight::new, EntityClassification.MISC).setTrackingRange(64).setUpdateInterval(1).size(0.25f, 0.25f));
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package wayoftime.bloodmagic.common.registries;
|
||||
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
|
||||
import wayoftime.bloodmagic.common.recipe.serializer.AlchemyArrayRecipeSerializer;
|
||||
import wayoftime.bloodmagic.common.recipe.serializer.BloodAltarRecipeSerializer;
|
||||
import wayoftime.bloodmagic.common.recipe.serializer.TartaricForgeRecipeSerializer;
|
||||
import wayoftime.bloodmagic.common.registration.impl.IRecipeSerializerDeferredRegister;
|
||||
import wayoftime.bloodmagic.common.registration.impl.IRecipeSerializerRegistryObject;
|
||||
import wayoftime.bloodmagic.recipe.IRecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.recipe.IRecipeBloodAltar;
|
||||
import wayoftime.bloodmagic.recipe.IRecipeTartaricForge;
|
||||
|
||||
public class BloodMagicRecipeSerializers
|
||||
{
|
||||
private BloodMagicRecipeSerializers()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static final IRecipeSerializerDeferredRegister RECIPE_SERIALIZERS = new IRecipeSerializerDeferredRegister(BloodMagic.MODID);
|
||||
|
||||
public static final IRecipeSerializerRegistryObject<RecipeBloodAltar> ALTAR = RECIPE_SERIALIZERS.register("altar", () -> new BloodAltarRecipeSerializer<>(IRecipeBloodAltar::new));
|
||||
public static final IRecipeSerializerRegistryObject<RecipeAlchemyArray> ARRAY = RECIPE_SERIALIZERS.register("array", () -> new AlchemyArrayRecipeSerializer<>(IRecipeAlchemyArray::new));
|
||||
public static final IRecipeSerializerRegistryObject<RecipeTartaricForge> TARTARIC = RECIPE_SERIALIZERS.register("soulforge", () -> new TartaricForgeRecipeSerializer<>(IRecipeTartaricForge::new));
|
||||
|
||||
// public static final DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, BloodMagic.MODID);
|
||||
|
||||
// public static final DeferredObject<RecipeBloodAltar> REC = RECIPE_SERIALIZERS.register("test", () -> new BloodAltarRecipeSerializer<>(IRecipeBloodAltar::new));
|
||||
// public static final IRecipeSerializerDeferredRegister RECIPE_SERIALIZERS = new IRecipeSerializerDeferredRegister(BloodMagic.MODID);
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package wayoftime.bloodmagic.compat.jei.altar;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.util.ChatUtil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NumeralHelper;
|
||||
import wayoftime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class BloodAltarRecipeCategory implements IRecipeCategory<RecipeBloodAltar>
|
||||
{
|
||||
private static final int INPUT_SLOT = 1;
|
||||
private static final int OUTPUT_SLOT = 0;
|
||||
public static final ResourceLocation UID = BloodMagic.rl(Constants.Compat.JEI_CATEGORY_ALTAR);
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable background;
|
||||
private final IDrawable icon;
|
||||
// @Nonnull
|
||||
// private final ICraftingGridHelper craftingGridHelper;
|
||||
|
||||
public BloodAltarRecipeCategory(IGuiHelper guiHelper)
|
||||
{
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()));
|
||||
background = guiHelper.createDrawable(BloodMagic.rl("gui/jei/altar.png"), 3, 4, 155, 65);
|
||||
// craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOT);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getUid()
|
||||
{
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ITextComponent> getTooltipStrings(RecipeBloodAltar recipe, double mouseX, double mouseY)
|
||||
{
|
||||
List<ITextComponent> tooltip = Lists.newArrayList();
|
||||
|
||||
if (mouseX >= 13 && mouseX <= 64 && mouseY >= 27 && mouseY <= 58)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent("jei.bloodmagic.recipe.consumptionrate", ChatUtil.DECIMAL_FORMAT.format(recipe.getConsumeRate())));
|
||||
tooltip.add(new TranslationTextComponent("jei.bloodmagic.recipe.drainrate", ChatUtil.DECIMAL_FORMAT.format(recipe.getDrainRate())));
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return TextHelper.localize("jei.bloodmagic.recipe.altar");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IDrawable getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeBloodAltar recipe, @Nonnull IIngredients ingredients)
|
||||
{
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
guiItemStacks.init(OUTPUT_SLOT, false, 125, 30);
|
||||
guiItemStacks.init(INPUT_SLOT, true, 31, 0);
|
||||
|
||||
guiItemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends RecipeBloodAltar> getRecipeClass()
|
||||
{
|
||||
return RecipeBloodAltar.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(RecipeBloodAltar recipe, IIngredients ingredients)
|
||||
{
|
||||
ingredients.setInputIngredients(recipe.getIngredients());
|
||||
ingredients.setOutput(VanillaTypes.ITEM, recipe.getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(RecipeBloodAltar recipe, MatrixStack matrixStack, double mouseX, double mouseY)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
String[] infoString = new String[]
|
||||
{ TextHelper.localize("jei.bloodmagic.recipe.requiredtier", NumeralHelper.toRoman(recipe.getMinimumTier().toInt())),
|
||||
TextHelper.localize("jei.bloodmagic.recipe.requiredlp", recipe.getSyphon()) };
|
||||
mc.fontRenderer.drawString(matrixStack, infoString[0], 90
|
||||
- mc.fontRenderer.getStringWidth(infoString[0]) / 2, 0, Color.gray.getRGB());
|
||||
mc.fontRenderer.drawString(matrixStack, infoString[1], 90
|
||||
- mc.fontRenderer.getStringWidth(infoString[1]) / 2, 10, Color.gray.getRGB());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package wayoftime.bloodmagic.compat.jei.array;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.ingredient.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class AlchemyArrayCraftingCategory implements IRecipeCategory<RecipeAlchemyArray>
|
||||
{
|
||||
private static final int OUTPUT_SLOT = 0;
|
||||
private static final int INPUT_SLOT = 1;
|
||||
private static final int CATALYST_SLOT = 2;
|
||||
public static final ResourceLocation UID = BloodMagic.rl(Constants.Compat.JEI_CATEGORY_ALCHEMYARRAY);
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable background;
|
||||
private final IDrawable icon;
|
||||
// @Nonnull
|
||||
// private final ICraftingGridHelper craftingGridHelper;
|
||||
|
||||
public AlchemyArrayCraftingCategory(IGuiHelper guiHelper)
|
||||
{
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(BloodMagicItems.ARCANE_ASHES.get()));
|
||||
background = guiHelper.createDrawable(BloodMagic.rl("gui/jei/binding.png"), 0, 0, 100, 30);
|
||||
// craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOT);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getUid()
|
||||
{
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return TextHelper.localize("jei.bloodmagic.recipe.alchemyarraycrafting");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IDrawable getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeAlchemyArray recipe, @Nonnull IIngredients ingredients)
|
||||
{
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 73, 5);
|
||||
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5);
|
||||
recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 29, 3);
|
||||
|
||||
guiItemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends RecipeAlchemyArray> getRecipeClass()
|
||||
{
|
||||
return RecipeAlchemyArray.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(RecipeAlchemyArray recipe, IIngredients ingredients)
|
||||
{
|
||||
ingredients.setInputIngredients(recipe.getIngredients());
|
||||
ingredients.setOutput(VanillaTypes.ITEM, recipe.getOutput());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package wayoftime.bloodmagic.core.registry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.common.alchemyarray.AlchemyArrayEffect;
|
||||
import wayoftime.bloodmagic.common.alchemyarray.AlchemyArrayEffectCrafting;
|
||||
|
||||
public class AlchemyArrayRegistry
|
||||
{
|
||||
public static Map<ResourceLocation, AlchemyArrayEffect> effectMap = new HashMap<ResourceLocation, AlchemyArrayEffect>();
|
||||
|
||||
public static boolean registerEffect(ResourceLocation rl, AlchemyArrayEffect effect)
|
||||
{
|
||||
boolean hadKey = effectMap.containsKey(rl);
|
||||
|
||||
effectMap.put(rl, effect);
|
||||
|
||||
return hadKey;
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getEffect(World world, ResourceLocation rl, RecipeAlchemyArray recipe)
|
||||
{
|
||||
if (effectMap.containsKey(rl))
|
||||
{
|
||||
return effectMap.get(rl).getNewCopy();
|
||||
}
|
||||
|
||||
if (!recipe.getOutput().isEmpty())
|
||||
{
|
||||
// Return a new instance of AlchemyEffectCrafting
|
||||
return new AlchemyArrayEffectCrafting(recipe.getOutput());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static AlchemyArrayEffect getEffect(World world, ItemStack input, ItemStack catalyst)
|
||||
{
|
||||
Pair<Boolean, RecipeAlchemyArray> array = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyArray(world, input, catalyst);
|
||||
if (array == null || array.getRight() == null || !array.getLeft())
|
||||
return null;
|
||||
|
||||
return getEffect(world, array.getRight().getId(), array.getRight());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package wayoftime.bloodmagic.core.registry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.client.render.alchemyarray.AlchemyArrayRenderer;
|
||||
|
||||
public class AlchemyArrayRendererRegistry
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static final AlchemyArrayRenderer DEFAULT_RENDERER = new AlchemyArrayRenderer(new ResourceLocation("bloodmagic", "textures/models/alchemyarrays/basearray.png"));
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static Map<ResourceLocation, AlchemyArrayRenderer> rendererMap = new HashMap<ResourceLocation, AlchemyArrayRenderer>();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rl
|
||||
* @param renderer
|
||||
* @return True if there was already a renderer registered for this rl.
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static boolean registerRenderer(ResourceLocation rl, AlchemyArrayRenderer renderer)
|
||||
{
|
||||
boolean hadKey = rendererMap.containsKey(rl);
|
||||
|
||||
rendererMap.put(rl, renderer);
|
||||
|
||||
return hadKey;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static AlchemyArrayRenderer getRenderer(World world, ResourceLocation rl, RecipeAlchemyArray recipe)
|
||||
{
|
||||
if (rendererMap.containsKey(rl))
|
||||
{
|
||||
return rendererMap.get(rl);
|
||||
}
|
||||
|
||||
ResourceLocation texture = recipe.getTexture();
|
||||
if (texture != null)
|
||||
return new AlchemyArrayRenderer(texture);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static AlchemyArrayRenderer getRenderer(World world, ItemStack input, ItemStack catalyst)
|
||||
{
|
||||
Pair<Boolean, RecipeAlchemyArray> array = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyArray(world, input, catalyst);
|
||||
if (array == null || array.getRight() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return getRenderer(world, array.getRight().getId(), array.getRight());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package wayoftime.bloodmagic.entity;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class BloodMagicEntities
|
||||
{
|
||||
private BloodMagicEntities()
|
||||
{
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerEntities(RegistryEvent.Register<EntityType<?>> event)
|
||||
{
|
||||
// System.out.println("Ow O");
|
||||
// event.getRegistry().register(EntityType.Builder.<EntitySoulSnare>create(EntitySoulSnare::new, EntityClassification.MISC).setTrackingRange(64).setUpdateInterval(1).setShouldReceiveVelocityUpdates(false).setCustomClientFactory(((spawnEntity, world) -> new EntitySoulSnare(EntitySoulSnare.TYPE, world))).build("").setRegistryName(BloodMagic.rl("entitysoulsnare")));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent evt)
|
||||
{
|
||||
// System.out.println("O wO");
|
||||
// RenderingRegistry.registerEntityRenderingHandler(BloodMagicEntityTypes.SNARE.getEntityType(), SoulSnareRenderer::new);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
package wayoftime.bloodmagic.network;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.RegistryKey;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.network.PacketDistributor;
|
||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
||||
|
||||
/**
|
||||
* Copied liberally from Mekanism. Many thanks to pupnewfster!
|
||||
*
|
||||
*/
|
||||
public abstract class BasePacketHandler
|
||||
{
|
||||
|
||||
protected static SimpleChannel createChannel(ResourceLocation name)
|
||||
{
|
||||
return NetworkRegistry.ChannelBuilder.named(name).clientAcceptedVersions(getProtocolVersion()::equals).serverAcceptedVersions(getProtocolVersion()::equals).networkProtocolVersion(BasePacketHandler::getProtocolVersion).simpleChannel();
|
||||
}
|
||||
|
||||
private static String getProtocolVersion()
|
||||
{
|
||||
return "1";
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for reading strings to make sure we don't accidentally call
|
||||
* PacketBuffer#readString on the server
|
||||
*/
|
||||
public static String readString(PacketBuffer buffer)
|
||||
{
|
||||
return buffer.readString(Short.MAX_VALUE);
|
||||
}
|
||||
|
||||
// public static void log(String log)
|
||||
// {
|
||||
// // TODO: Add more logging for packets using this
|
||||
// if (MekanismConfig.general.logPackets.get())
|
||||
// {
|
||||
// Mekanism.logger.info(log);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
public static PlayerEntity getPlayer(Supplier<Context> context)
|
||||
{
|
||||
return context.get().getSender();
|
||||
}
|
||||
|
||||
private int index = 0;
|
||||
|
||||
protected abstract SimpleChannel getChannel();
|
||||
|
||||
public abstract void initialize();
|
||||
|
||||
protected <MSG> void registerClientToServer(Class<MSG> type, BiConsumer<MSG, PacketBuffer> encoder,
|
||||
Function<PacketBuffer, MSG> decoder, BiConsumer<MSG, Supplier<Context>> consumer)
|
||||
{
|
||||
getChannel().registerMessage(index++, type, encoder, decoder, consumer, Optional.of(NetworkDirection.PLAY_TO_SERVER));
|
||||
}
|
||||
|
||||
protected <MSG> void registerServerToClient(Class<MSG> type, BiConsumer<MSG, PacketBuffer> encoder,
|
||||
Function<PacketBuffer, MSG> decoder, BiConsumer<MSG, Supplier<Context>> consumer)
|
||||
{
|
||||
getChannel().registerMessage(index++, type, encoder, decoder, consumer, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to the specified player.
|
||||
*
|
||||
* @param message - the message to send
|
||||
* @param player - the player to send it to
|
||||
*/
|
||||
public <MSG> void sendTo(MSG message, ServerPlayerEntity player)
|
||||
{
|
||||
getChannel().sendTo(message, player.connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to everyone connected to the server.
|
||||
*
|
||||
* @param message - message to send
|
||||
*/
|
||||
public <MSG> void sendToAll(MSG message)
|
||||
{
|
||||
getChannel().send(PacketDistributor.ALL.noArg(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to everyone within the supplied dimension.
|
||||
*
|
||||
* @param message - the message to send
|
||||
* @param dimension - the dimension to target
|
||||
*/
|
||||
public <MSG> void sendToDimension(MSG message, RegistryKey<World> dimension)
|
||||
{
|
||||
getChannel().send(PacketDistributor.DIMENSION.with(() -> dimension), message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this message to the server.
|
||||
*
|
||||
* @param message - the message to send
|
||||
*/
|
||||
public <MSG> void sendToServer(MSG message)
|
||||
{
|
||||
getChannel().sendToServer(message);
|
||||
}
|
||||
|
||||
public <MSG> void sendToAllTracking(MSG message, Entity entity)
|
||||
{
|
||||
getChannel().send(PacketDistributor.TRACKING_ENTITY.with(() -> entity), message);
|
||||
}
|
||||
|
||||
public <MSG> void sendToAllTracking(MSG message, TileEntity tile)
|
||||
{
|
||||
sendToAllTracking(message, tile.getWorld(), tile.getPos());
|
||||
}
|
||||
|
||||
public <MSG> void sendToAllTracking(MSG message, World world, BlockPos pos)
|
||||
{
|
||||
if (world instanceof ServerWorld)
|
||||
{
|
||||
// If we have a ServerWorld just directly figure out the ChunkPos so as to not
|
||||
// require looking up the chunk
|
||||
// This provides a decent performance boost over using the packet distributor
|
||||
((ServerWorld) world).getChunkProvider().chunkManager.getTrackingPlayers(new ChunkPos(pos), false).forEach(p -> sendTo(message, p));
|
||||
} else
|
||||
{
|
||||
// Otherwise fallback to entities tracking the chunk if some mod did something
|
||||
// odd and our world is not a ServerWorld
|
||||
getChannel().send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunk(pos.getX() >> 4, pos.getZ() >> 4)), message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package wayoftime.bloodmagic.potion;
|
||||
|
||||
import net.minecraft.potion.Effect;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
public class BloodMagicPotions
|
||||
{
|
||||
public static final Effect soulSnare = new PotionSoulSnare();
|
||||
|
||||
public static void registerPotions(RegistryEvent.Register<Effect> evt)
|
||||
{
|
||||
IForgeRegistry<Effect> reg = evt.getRegistry();
|
||||
reg.register(soulSnare.setRegistryName("soulsnare"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package wayoftime.bloodmagic.potion;
|
||||
|
||||
import net.minecraft.potion.EffectType;
|
||||
|
||||
public class PotionSoulSnare extends PotionBloodMagic
|
||||
{
|
||||
public PotionSoulSnare()
|
||||
{
|
||||
super(EffectType.NEUTRAL, 0xFFFFFF);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package wayoftime.bloodmagic.recipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import wayoftime.bloodmagic.common.recipe.BloodMagicRecipeType;
|
||||
import wayoftime.bloodmagic.common.registries.BloodMagicRecipeSerializers;
|
||||
|
||||
public class IRecipeAlchemyArray extends RecipeAlchemyArray
|
||||
{
|
||||
public IRecipeAlchemyArray(ResourceLocation id, ResourceLocation texture, Ingredient baseIngredient, Ingredient addedIngredient, ItemStack result)
|
||||
{
|
||||
super(id, texture, baseIngredient, addedIngredient, result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<RecipeAlchemyArray> getSerializer()
|
||||
{
|
||||
return BloodMagicRecipeSerializers.ARRAY.getRecipeSerializer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeType<RecipeAlchemyArray> getType()
|
||||
{
|
||||
return BloodMagicRecipeType.ARRAY;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package wayoftime.bloodmagic.recipe;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
|
||||
import wayoftime.bloodmagic.common.recipe.BloodMagicRecipeType;
|
||||
import wayoftime.bloodmagic.common.registries.BloodMagicRecipeSerializers;
|
||||
|
||||
public class IRecipeBloodAltar extends RecipeBloodAltar
|
||||
{
|
||||
public IRecipeBloodAltar(ResourceLocation id, Ingredient input, ItemStack output, int minimumTier, int syphon, int consumeRate, int drainRate)
|
||||
{
|
||||
super(id, input, output, minimumTier, syphon, consumeRate, drainRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<RecipeBloodAltar> getSerializer()
|
||||
{
|
||||
return BloodMagicRecipeSerializers.ALTAR.getRecipeSerializer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeType<RecipeBloodAltar> getType()
|
||||
{
|
||||
return BloodMagicRecipeType.ALTAR;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package wayoftime.bloodmagic.recipe;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
|
||||
import wayoftime.bloodmagic.common.recipe.BloodMagicRecipeType;
|
||||
import wayoftime.bloodmagic.common.registries.BloodMagicRecipeSerializers;
|
||||
|
||||
public class IRecipeTartaricForge extends RecipeTartaricForge
|
||||
{
|
||||
public IRecipeTartaricForge(ResourceLocation id, @Nonnull List<Ingredient> input, @Nonnull ItemStack output, @Nonnegative double minimumSouls, @Nonnegative double soulDrain)
|
||||
{
|
||||
super(id, input, output, minimumSouls, soulDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<RecipeTartaricForge> getSerializer()
|
||||
{
|
||||
return BloodMagicRecipeSerializers.TARTARIC.getRecipeSerializer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeType<RecipeTartaricForge> getType()
|
||||
{
|
||||
return BloodMagicRecipeType.TARTARICFORGE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
package wayoftime.bloodmagic.tile.contailer;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.IIntArray;
|
||||
import net.minecraft.util.IntArray;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.tile.TileSoulForge;
|
||||
import wayoftime.bloodmagic.will.IDemonWill;
|
||||
import wayoftime.bloodmagic.will.IDemonWillGem;
|
||||
|
||||
public class ContainerSoulForge extends Container
|
||||
{
|
||||
public final IInventory tileForge;
|
||||
public final IIntArray data;
|
||||
|
||||
// public ContainerSoulForge(InventoryPlayer inventoryPlayer, IInventory tileForge)
|
||||
// {
|
||||
// this.tileForge = tileForge;
|
||||
//
|
||||
// }
|
||||
|
||||
public ContainerSoulForge(int windowId, PlayerInventory playerInventory, PacketBuffer extraData)
|
||||
{
|
||||
this((TileSoulForge) playerInventory.player.world.getTileEntity(extraData.readBlockPos()), new IntArray(5), windowId, playerInventory);
|
||||
}
|
||||
|
||||
public ContainerSoulForge(@Nullable TileSoulForge tile, IIntArray data, int windowId, PlayerInventory playerInventory)
|
||||
{
|
||||
super(BloodMagicBlocks.SOUL_FORGE_CONTAINER.get(), windowId);
|
||||
this.tileForge = tile;
|
||||
this.setup(playerInventory, tile);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setup(PlayerInventory inventory, IInventory tileForge)
|
||||
{
|
||||
this.addSlot(new Slot(tileForge, 0, 8, 15));
|
||||
this.addSlot(new Slot(tileForge, 1, 80, 15));
|
||||
this.addSlot(new Slot(tileForge, 2, 8, 87));
|
||||
this.addSlot(new Slot(tileForge, 3, 80, 87));
|
||||
this.addSlot(new SlotSoul(tileForge, TileSoulForge.soulSlot, 152, 51));
|
||||
this.addSlot(new SlotOutput(tileForge, TileSoulForge.outputSlot, 44, 51));
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
for (int j = 0; j < 9; j++)
|
||||
{
|
||||
addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 123 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
addSlot(new Slot(inventory, i, 8 + i * 18, 181));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(PlayerEntity playerIn, int index)
|
||||
{
|
||||
ItemStack itemstack = ItemStack.EMPTY;
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (index == 5)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 6, 6 + 36, true))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onSlotChange(itemstack1, itemstack);
|
||||
} else if (index > 5)
|
||||
{
|
||||
if (itemstack1.getItem() instanceof IDemonWill || itemstack1.getItem() instanceof IDemonWillGem)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, 4, 5, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(itemstack1, 0, 4, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(itemstack1, 6, 42, false))
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == 0)
|
||||
{
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getCount() == itemstack.getCount())
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
slot.onTake(playerIn, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(PlayerEntity playerIn)
|
||||
{
|
||||
return this.tileForge.isUsableByPlayer(playerIn);
|
||||
}
|
||||
|
||||
private class SlotSoul extends Slot
|
||||
{
|
||||
public SlotSoul(IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
return itemStack.getItem() instanceof IDemonWillGem || itemStack.getItem() instanceof IDemonWill;
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotOutput extends Slot
|
||||
{
|
||||
public SlotOutput(IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
super(inventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
99
src/main/java/wayoftime/bloodmagic/will/DemonWillHolder.java
Normal file
99
src/main/java/wayoftime/bloodmagic/will/DemonWillHolder.java
Normal file
|
@ -0,0 +1,99 @@
|
|||
package wayoftime.bloodmagic.will;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
||||
public class DemonWillHolder
|
||||
{
|
||||
public HashMap<EnumDemonWillType, Double> willMap = new HashMap<>();
|
||||
|
||||
public double addWill(EnumDemonWillType type, double amount, double max)
|
||||
{
|
||||
double current = 0;
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
current = willMap.get(type);
|
||||
}
|
||||
|
||||
double added = Math.min(max - current, amount);
|
||||
addWill(type, amount);
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
public void addWill(EnumDemonWillType type, double amount)
|
||||
{
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
willMap.put(type, amount + willMap.get(type));
|
||||
} else
|
||||
{
|
||||
willMap.put(type, amount);
|
||||
}
|
||||
}
|
||||
|
||||
public double drainWill(EnumDemonWillType type, double amount)
|
||||
{
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
double current = willMap.get(type);
|
||||
double reduced = Math.min(current, amount);
|
||||
|
||||
if (reduced >= current)
|
||||
{
|
||||
willMap.remove(type);
|
||||
} else
|
||||
{
|
||||
willMap.put(type, current - reduced);
|
||||
}
|
||||
|
||||
return reduced;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getWill(EnumDemonWillType type)
|
||||
{
|
||||
if (willMap.containsKey(type))
|
||||
{
|
||||
return willMap.get(type);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void readFromNBT(CompoundNBT tag, String key)
|
||||
{
|
||||
CompoundNBT willTag = tag.getCompound(key);
|
||||
|
||||
willMap.clear();
|
||||
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
double amount = willTag.getDouble("EnumWill" + type.name());
|
||||
if (amount > 0)
|
||||
{
|
||||
willMap.put(type, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(CompoundNBT tag, String key)
|
||||
{
|
||||
CompoundNBT willTag = new CompoundNBT();
|
||||
for (Entry<EnumDemonWillType, Double> entry : willMap.entrySet())
|
||||
{
|
||||
willTag.putDouble("EnumWill" + entry.getKey().name(), entry.getValue());
|
||||
}
|
||||
|
||||
tag.put(key, willTag);
|
||||
}
|
||||
|
||||
public void clearWill()
|
||||
{
|
||||
willMap.clear();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package wayoftime.bloodmagic.will;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public enum EnumDemonWillType implements IStringSerializable
|
||||
{
|
||||
DEFAULT("default"),
|
||||
CORROSIVE("corrosive"),
|
||||
DESTRUCTIVE("destructive"),
|
||||
VENGEFUL("vengeful"),
|
||||
STEADFAST("steadfast");
|
||||
|
||||
public final String name;
|
||||
|
||||
EnumDemonWillType(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString()
|
||||
{
|
||||
return this.toString();
|
||||
}
|
||||
}
|
45
src/main/java/wayoftime/bloodmagic/will/IDemonWill.java
Normal file
45
src/main/java/wayoftime/bloodmagic/will/IDemonWill.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package wayoftime.bloodmagic.will;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IDemonWill
|
||||
{
|
||||
/**
|
||||
* Obtains the amount of Will an ItemStack contains.
|
||||
*
|
||||
* @param willStack - The stack to retrieve the Will from
|
||||
* @return - The amount of Will an ItemStack contains
|
||||
*/
|
||||
double getWill(EnumDemonWillType type, ItemStack willStack);
|
||||
|
||||
/**
|
||||
* Sets the amount of Will in a given ItemStack.
|
||||
*
|
||||
* @param willStack - The ItemStack of the Will
|
||||
* @param will - The amount of will to set the stack to
|
||||
* @return True if successfully set.
|
||||
*/
|
||||
boolean setWill(EnumDemonWillType type, ItemStack willStack, double will);
|
||||
|
||||
/**
|
||||
* Drains the demonic will from the willStack. If all of the will is drained,
|
||||
* the willStack will be removed.
|
||||
*
|
||||
* @param willStack - The ItemStack of the will
|
||||
* @param drainAmount - The amount of Will to drain
|
||||
* @return The amount of will drained.
|
||||
*/
|
||||
double drainWill(EnumDemonWillType type, ItemStack willStack, double drainAmount);
|
||||
|
||||
/**
|
||||
* Creates a new ItemStack with the specified number of will. Implementation
|
||||
* should respect the number requested.
|
||||
*
|
||||
* @param meta - The meta of the ItemStack to create
|
||||
* @param number - The amount of Will to create the Stack with.
|
||||
* @return - An ItemStack with the set amount of Will
|
||||
*/
|
||||
ItemStack createWill(double number);
|
||||
|
||||
EnumDemonWillType getType(ItemStack stack);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue