Attempt to try to fix the 1.16.3's branch having multiple 'wayoftime' folders.
This commit is contained in:
parent
c159828248
commit
6b4145a67c
|
@ -1,249 +0,0 @@
|
||||||
package wayoftime.bloodmagic;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.data.DataGenerator;
|
|
||||||
import net.minecraft.fluid.Fluid;
|
|
||||||
import net.minecraft.item.ItemGroup;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
|
||||||
import net.minecraft.potion.Effect;
|
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
|
||||||
import net.minecraftforge.event.RegistryEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
|
|
||||||
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
|
|
||||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|
||||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
|
||||||
import wayoftime.bloodmagic.api.impl.BloodMagicCorePlugin;
|
|
||||||
import wayoftime.bloodmagic.client.ClientEvents;
|
|
||||||
import wayoftime.bloodmagic.client.render.entity.BloodLightRenderer;
|
|
||||||
import wayoftime.bloodmagic.client.render.entity.SoulSnareRenderer;
|
|
||||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
|
||||||
import wayoftime.bloodmagic.common.data.GeneratorBaseRecipes;
|
|
||||||
import wayoftime.bloodmagic.common.data.GeneratorBlockStates;
|
|
||||||
import wayoftime.bloodmagic.common.data.GeneratorBlockTags;
|
|
||||||
import wayoftime.bloodmagic.common.data.GeneratorItemModels;
|
|
||||||
import wayoftime.bloodmagic.common.data.GeneratorItemTags;
|
|
||||||
import wayoftime.bloodmagic.common.data.GeneratorLanguage;
|
|
||||||
import wayoftime.bloodmagic.common.data.GeneratorLootTable;
|
|
||||||
import wayoftime.bloodmagic.common.data.recipe.BloodMagicRecipeProvider;
|
|
||||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
|
||||||
import wayoftime.bloodmagic.common.registries.BloodMagicEntityTypes;
|
|
||||||
import wayoftime.bloodmagic.common.registries.BloodMagicRecipeSerializers;
|
|
||||||
import wayoftime.bloodmagic.core.recipe.IngredientBloodOrb;
|
|
||||||
import wayoftime.bloodmagic.core.registry.OrbRegistry;
|
|
||||||
import wayoftime.bloodmagic.network.BloodMagicPacketHandler;
|
|
||||||
import wayoftime.bloodmagic.potion.BloodMagicPotions;
|
|
||||||
import wayoftime.bloodmagic.ritual.RitualManager;
|
|
||||||
import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
|
|
||||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
|
||||||
import wayoftime.bloodmagic.tile.TileAltar;
|
|
||||||
import wayoftime.bloodmagic.tile.TileMasterRitualStone;
|
|
||||||
import wayoftime.bloodmagic.tile.TileSoulForge;
|
|
||||||
import wayoftime.bloodmagic.util.handler.event.GenericHandler;
|
|
||||||
import wayoftime.bloodmagic.util.handler.event.WillHandler;
|
|
||||||
|
|
||||||
@Mod("bloodmagic")
|
|
||||||
//@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
||||||
public class BloodMagic
|
|
||||||
{
|
|
||||||
public static final String MODID = "bloodmagic";
|
|
||||||
// Directly reference a log4j logger.
|
|
||||||
public static final Logger LOGGER = LogManager.getLogger();
|
|
||||||
|
|
||||||
private static Gson GSON = null;
|
|
||||||
|
|
||||||
public static final BloodMagicPacketHandler packetHandler = new BloodMagicPacketHandler();
|
|
||||||
public static final RitualManager RITUAL_MANAGER = new RitualManager();
|
|
||||||
|
|
||||||
public BloodMagic()
|
|
||||||
{
|
|
||||||
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
|
||||||
|
|
||||||
modBus.addListener(this::setup);
|
|
||||||
modBus.addListener(this::onLoadComplete);
|
|
||||||
|
|
||||||
BloodMagicBlocks.BLOCKS.register(modBus);
|
|
||||||
BloodMagicItems.ITEMS.register(modBus);
|
|
||||||
// RegistrarBloodMagic.BLOOD_ORBS.createAndRegister(modBus, "bloodorbs");
|
|
||||||
BloodMagicItems.BLOOD_ORBS.createAndRegister(modBus, "bloodorbs");
|
|
||||||
BloodMagicItems.BASICITEMS.register(modBus);
|
|
||||||
BloodMagicBlocks.BASICBLOCKS.register(modBus);
|
|
||||||
BloodMagicBlocks.FLUIDS.register(modBus);
|
|
||||||
BloodMagicBlocks.CONTAINERS.register(modBus);
|
|
||||||
BloodMagicEntityTypes.ENTITY_TYPES.register(modBus);
|
|
||||||
|
|
||||||
BloodMagicRecipeSerializers.RECIPE_SERIALIZERS.register(modBus);
|
|
||||||
|
|
||||||
// Register the setup method for modloading
|
|
||||||
modBus.addListener(this::setup);
|
|
||||||
// Register the enqueueIMC method for modloading
|
|
||||||
modBus.addListener(this::enqueueIMC);
|
|
||||||
// Register the processIMC method for modloading
|
|
||||||
modBus.addListener(this::processIMC);
|
|
||||||
// Register the doClientStuff method for modloading
|
|
||||||
modBus.addListener(this::doClientStuff);
|
|
||||||
modBus.addListener(this::gatherData);
|
|
||||||
|
|
||||||
modBus.addGenericListener(Fluid.class, this::registerFluids);
|
|
||||||
modBus.addGenericListener(TileEntityType.class, this::registerTileEntityTypes);
|
|
||||||
modBus.addGenericListener(IRecipeSerializer.class, this::registerRecipes);
|
|
||||||
modBus.addGenericListener(Effect.class, BloodMagicPotions::registerPotions);
|
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new GenericHandler());
|
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(new WillHandler());
|
|
||||||
// MinecraftForge.EVENT_BUS.register(new BloodMagicBlocks());
|
|
||||||
// MinecraftForge.EVENT_BUS.addListener(this::commonSetup);
|
|
||||||
|
|
||||||
// Register ourselves for server and other game events we are interested in
|
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerRecipes(RegistryEvent.Register<IRecipeSerializer<?>> event)
|
|
||||||
{
|
|
||||||
// System.out.println("Registering IngredientBloodOrb Serializer.");
|
|
||||||
CraftingHelper.register(IngredientBloodOrb.NAME, IngredientBloodOrb.Serializer.INSTANCE);
|
|
||||||
|
|
||||||
// event.getRegistry().registerAll(
|
|
||||||
// new SewingRecipe.Serializer().setRegistryName("sewing")
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ResourceLocation rl(String name)
|
|
||||||
{
|
|
||||||
return new ResourceLocation(BloodMagic.MODID, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerFluids(RegistryEvent.Register<Fluid> event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onLoadComplete(FMLLoadCompleteEvent event)
|
|
||||||
{
|
|
||||||
OrbRegistry.tierMap.put(BloodMagicItems.ORB_WEAK.get().getTier(), new ItemStack(BloodMagicItems.WEAK_BLOOD_ORB.get()));
|
|
||||||
OrbRegistry.tierMap.put(BloodMagicItems.ORB_APPRENTICE.get().getTier(), new ItemStack(BloodMagicItems.APPRENTICE_BLOOD_ORB.get()));
|
|
||||||
OrbRegistry.tierMap.put(BloodMagicItems.ORB_MAGICIAN.get().getTier(), new ItemStack(BloodMagicItems.MAGICIAN_BLOOD_ORB.get()));
|
|
||||||
OrbRegistry.tierMap.put(BloodMagicItems.ORB_MASTER.get().getTier(), new ItemStack(BloodMagicItems.MASTER_BLOOD_ORB.get()));
|
|
||||||
BloodMagicCorePlugin.INSTANCE.register(BloodMagicAPI.INSTANCE);
|
|
||||||
RITUAL_MANAGER.discover();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerTileEntityTypes(RegistryEvent.Register<TileEntityType<?>> event)
|
|
||||||
{
|
|
||||||
LOGGER.info("Attempting to register Tile Entities");
|
|
||||||
event.getRegistry().register(TileEntityType.Builder.create(TileAltar::new, BloodMagicBlocks.BLOOD_ALTAR.get()).build(null).setRegistryName("altar"));
|
|
||||||
event.getRegistry().register(TileEntityType.Builder.create(TileAlchemyArray::new, BloodMagicBlocks.ALCHEMY_ARRAY.get()).build(null).setRegistryName("alchemyarray"));
|
|
||||||
event.getRegistry().register(TileEntityType.Builder.create(TileSoulForge::new, BloodMagicBlocks.SOUL_FORGE.get()).build(null).setRegistryName("soulforge"));
|
|
||||||
event.getRegistry().register(TileEntityType.Builder.create(TileMasterRitualStone::new, BloodMagicBlocks.MASTER_RITUAL_STONE.get()).build(null).setRegistryName("masterritualstone"));
|
|
||||||
event.getRegistry().register(TileEntityType.Builder.create(TileAlchemicalReactionChamber::new, BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()).build(null).setRegistryName("alchemicalreactionchamber"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public void gatherData(GatherDataEvent event)
|
|
||||||
{
|
|
||||||
// GSON = new GsonBuilder().registerTypeAdapter(Variant.class, new Variant.Deserializer()).registerTypeAdapter(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer()).registerTypeAdapter(ItemTransformVec3f.class, new ItemTransformVec3f.Deserializer()).create();
|
|
||||||
|
|
||||||
DataGenerator gen = event.getGenerator();
|
|
||||||
|
|
||||||
// if(event.includeClient())
|
|
||||||
{
|
|
||||||
ItemModelProvider itemModels = new GeneratorItemModels(gen, event.getExistingFileHelper());
|
|
||||||
gen.addProvider(itemModels);
|
|
||||||
gen.addProvider(new GeneratorBlockStates(gen, itemModels.existingFileHelper));
|
|
||||||
gen.addProvider(new GeneratorLanguage(gen));
|
|
||||||
gen.addProvider(new BloodMagicRecipeProvider(gen));
|
|
||||||
gen.addProvider(new GeneratorBaseRecipes(gen));
|
|
||||||
gen.addProvider(new GeneratorLootTable(gen));
|
|
||||||
|
|
||||||
GeneratorBlockTags bmBlockTags = new GeneratorBlockTags(gen, event.getExistingFileHelper());
|
|
||||||
gen.addProvider(bmBlockTags);
|
|
||||||
gen.addProvider(new GeneratorItemTags(gen, bmBlockTags, event.getExistingFileHelper()));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setup(final FMLCommonSetupEvent event)
|
|
||||||
{
|
|
||||||
// some preinit code
|
|
||||||
// LOGGER.info("HELLO FROM PREINIT");
|
|
||||||
// LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
|
|
||||||
packetHandler.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doClientStuff(final FMLClientSetupEvent event)
|
|
||||||
{
|
|
||||||
// do something that can only be done on the client
|
|
||||||
// LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
|
|
||||||
ClientEvents.registerContainerScreens();
|
|
||||||
|
|
||||||
RenderingRegistry.registerEntityRenderingHandler(BloodMagicEntityTypes.SNARE.getEntityType(), SoulSnareRenderer::new);
|
|
||||||
RenderingRegistry.registerEntityRenderingHandler(BloodMagicEntityTypes.BLOOD_LIGHT.getEntityType(), BloodLightRenderer::new);
|
|
||||||
ClientEvents.registerItemModelProperties(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void enqueueIMC(final InterModEnqueueEvent event)
|
|
||||||
{
|
|
||||||
// some example code to dispatch IMC to another mod
|
|
||||||
// InterModComms.sendTo("examplemod", "helloworld", () -> {
|
|
||||||
// LOGGER.info("Hello world from the MDK");
|
|
||||||
// return "Hello world";
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processIMC(final InterModProcessEvent event)
|
|
||||||
{
|
|
||||||
// some example code to receive and process InterModComms from other mods
|
|
||||||
// LOGGER.info("Got IMC {}", event.getIMCStream().map(m -> m.getMessageSupplier().get()).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onServerStarting(FMLServerStartingEvent event)
|
|
||||||
{
|
|
||||||
// do something when the server starts
|
|
||||||
// LOGGER.info("HELLO from server starting");
|
|
||||||
}
|
|
||||||
|
|
||||||
// You can use EventBusSubscriber to automatically subscribe events on the
|
|
||||||
// contained class (this is subscribing to the MOD
|
|
||||||
// Event bus for receiving Registry Events)
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
||||||
public static class RegistryEvents
|
|
||||||
{
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent)
|
|
||||||
{
|
|
||||||
// register a new block here
|
|
||||||
// LOGGER.info("HELLO from Register Block");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom ItemGroup TAB
|
|
||||||
public static final ItemGroup TAB = new ItemGroup("bloodmagictab")
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public ItemStack createIcon()
|
|
||||||
{
|
|
||||||
return new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,135 +0,0 @@
|
||||||
package wayoftime.bloodmagic;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID)
|
|
||||||
public class ConfigHandler
|
|
||||||
{
|
|
||||||
// Most of this stuff is commented out because a proper replacement for the
|
|
||||||
// ConfigHandler is not yet implemented.
|
|
||||||
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "General settings" })
|
|
||||||
// public static ConfigGeneral general = new ConfigGeneral();
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Blacklist options for various features" })
|
|
||||||
// public static ConfigBlacklist blacklist = new ConfigBlacklist();
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Value modifiers for various features" })
|
|
||||||
// public static ConfigValues values = new ConfigValues();
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Settings that only pertain to the client" })
|
|
||||||
// public static ConfigClient client = new ConfigClient();
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Compatibility settings" })
|
|
||||||
// public static ConfigCompat compat = new ConfigCompat();
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event)
|
|
||||||
// {
|
|
||||||
// if (event.getModID().equals(BloodMagic.MODID))
|
|
||||||
// {
|
|
||||||
// ConfigManager.sync(event.getModID(), Config.Type.INSTANCE); // Sync config values
|
|
||||||
// BloodMagic.RITUAL_MANAGER.syncConfig();
|
|
||||||
// MeteorConfigHandler.handleMeteors(false); // Reload meteors
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static class ConfigGeneral
|
|
||||||
// {
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Enables extra information to be printed to the log.", "Warning: May drastically increase log size." })
|
|
||||||
// public boolean enableDebugLogging = false;
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Enables extra information to be printed to the log." })
|
|
||||||
// public boolean enableAPILogging = false;
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Enables extra information to be printed to the log.", "Warning: May drastically increase log size." })
|
|
||||||
// public boolean enableVerboseAPILogging = false;
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Enables tier 6 related registrations. This is for pack makers." })
|
|
||||||
// @Config.RequiresMcRestart
|
|
||||||
// public boolean enableTierSixEvenThoughThereIsNoContent = false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static class ConfigBlacklist
|
|
||||||
// {
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Stops listed blocks and entities from being teleposed.",
|
|
||||||
// "Use the registry name of the block or entity. Vanilla objects do not require the modid.",
|
|
||||||
// "If a block is specified, you can list the variants to only blacklist a given state." })
|
|
||||||
// public String[] teleposer =
|
|
||||||
// { "bedrock", "mob_spawner" };
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Stops listed blocks from being transposed.",
|
|
||||||
// "Use the registry name of the block. Vanilla blocks do not require the modid." })
|
|
||||||
// public String[] transposer =
|
|
||||||
// { "bedrock", "mob_spawner" };
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Stops the listed entities from being used in the Well of Suffering.",
|
|
||||||
// "Use the registry name of the entity. Vanilla entities do not require the modid." })
|
|
||||||
// public String[] wellOfSuffering =
|
|
||||||
// {};
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static class ConfigValues
|
|
||||||
// {
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Declares the amount of LP gained per HP sacrificed for the given entity.",
|
|
||||||
// "Setting the value to 0 will blacklist it.",
|
|
||||||
// "Use the registry name of the entity followed by a ';' and then the value you want.",
|
|
||||||
// "Vanilla entities do not require the modid." })
|
|
||||||
// public String[] sacrificialValues =
|
|
||||||
// { "villager;100", "slime;15", "enderman;10", "cow;100", "chicken;100", "horse;100", "sheep;100", "wolf;100",
|
|
||||||
// "ocelot;100", "pig;100", "rabbit;100" };
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Amount of LP the Coat of Arms should provide for each damage dealt." })
|
|
||||||
// @Config.RangeInt(min = 0, max = 100)
|
|
||||||
// public int coatOfArmsConversion = 20;
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Amount of LP the Sacrificial Dagger should provide for each damage dealt." })
|
|
||||||
// @Config.RangeInt(min = 0, max = 10000)
|
|
||||||
// public int sacrificialDaggerConversion = 100;
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Will rewrite any default meteor types with new versions.",
|
|
||||||
// "Disable this if you want any of your changes to stay, or do not want default meteor types regenerated." })
|
|
||||||
// public boolean shouldResyncMeteors = true;
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Should mobs that die through the Well of Suffering Ritual drop items?" })
|
|
||||||
// public boolean wellOfSufferingDrops = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static class ConfigClient
|
|
||||||
// {
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Always render the beams between routing nodes.",
|
|
||||||
// "If disabled, the beams will only render while the Node Router is held." })
|
|
||||||
// public boolean alwaysRenderRoutingLines = false;
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "Completely hide spectral blocks from view.", "If disabled, a transparent block will be displayed." })
|
|
||||||
// public boolean invisibleSpectralBlocks = true;
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "When cycling through slots, the Sigil of Holding will skip over empty slots and move to the next occupied one.",
|
|
||||||
// "If disabled, it will behave identically to the default hotbar." })
|
|
||||||
// public boolean sigilHoldingSkipsEmptySlots = false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static class ConfigCompat
|
|
||||||
// {
|
|
||||||
// @Config.Comment(
|
|
||||||
// { "The display mode to use when looking at a Blood Altar.", "ALWAYS - Always display information.",
|
|
||||||
// "SIGIL_HELD - Only display information when a Divination or Seers sigil is held in either hand.",
|
|
||||||
// "SIGIL_CONTAINED - Only display information when a Divination or Seers sigil is somewhere in the inventory." })
|
|
||||||
// public AltarDisplayMode wailaAltarDisplayMode = AltarDisplayMode.SIGIL_HELD;
|
|
||||||
//
|
|
||||||
// public enum AltarDisplayMode
|
|
||||||
// {
|
|
||||||
// ALWAYS, SIGIL_HELD, SIGIL_CONTAINED,;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static class values
|
|
||||||
{
|
|
||||||
public static int sacrificialDaggerConversion = 100;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
package wayoftime.bloodmagic.altar;
|
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for building the altar structure.
|
|
||||||
*/
|
|
||||||
public class AltarComponent
|
|
||||||
{
|
|
||||||
private final BlockPos offset;
|
|
||||||
private final ComponentType component;
|
|
||||||
private boolean upgradeSlot;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a component location for the altar.
|
|
||||||
*
|
|
||||||
* @param offset - Where the block should be in relation to the Altar
|
|
||||||
* @param component - The type of Component the location should contain
|
|
||||||
*/
|
|
||||||
public AltarComponent(BlockPos offset, ComponentType component)
|
|
||||||
{
|
|
||||||
this.offset = offset;
|
|
||||||
this.component = component;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use for setting a location at which there must be a block, but the type of
|
|
||||||
* block does not matter.
|
|
||||||
*
|
|
||||||
* @param offset - Where the block should be in relation to the Altar
|
|
||||||
*/
|
|
||||||
public AltarComponent(BlockPos offset)
|
|
||||||
{
|
|
||||||
this(offset, ComponentType.NOTAIR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the location to an upgrade slot.
|
|
||||||
*
|
|
||||||
* @return the current instance for further use.
|
|
||||||
*/
|
|
||||||
public AltarComponent setUpgradeSlot()
|
|
||||||
{
|
|
||||||
this.upgradeSlot = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockPos getOffset()
|
|
||||||
{
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUpgradeSlot()
|
|
||||||
{
|
|
||||||
return upgradeSlot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentType getComponent()
|
|
||||||
{
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,172 +0,0 @@
|
||||||
package wayoftime.bloodmagic.altar;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
public enum AltarTier
|
|
||||||
{
|
|
||||||
ONE()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void buildComponents(Consumer<AltarComponent> components)
|
|
||||||
{
|
|
||||||
// Nada
|
|
||||||
}
|
|
||||||
},
|
|
||||||
TWO()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void buildComponents(Consumer<AltarComponent> components)
|
|
||||||
{
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(1, -1, -1), ComponentType.BLOODRUNE));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-1, -1, 1), ComponentType.BLOODRUNE));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(0, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(1, -1, 1), ComponentType.BLOODRUNE));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
THREE()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void buildComponents(Consumer<AltarComponent> components)
|
|
||||||
{
|
|
||||||
// Doesn't pull from tier 2 because upgrades slots are different
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(0, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(1, -1, -1), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(1, -1, 0), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(0, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(1, -1, 1), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-3, -1, -3)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-3, 0, -3)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(3, -1, -3)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(3, 0, -3)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-3, -1, 3)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-3, 0, 3)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(3, -1, 3)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(3, 0, 3)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-3, 1, -3), ComponentType.GLOWSTONE));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(3, 1, -3), ComponentType.GLOWSTONE));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-3, 1, 3), ComponentType.GLOWSTONE));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(3, 1, 3), ComponentType.GLOWSTONE));
|
|
||||||
|
|
||||||
for (int i = -2; i <= 2; i++)
|
|
||||||
{
|
|
||||||
components.accept(new AltarComponent(new BlockPos(3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-3, -2, i), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(i, -2, 3), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(i, -2, -3), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
FOUR()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void buildComponents(Consumer<AltarComponent> components)
|
|
||||||
{
|
|
||||||
THREE.getAltarComponents().forEach(components);
|
|
||||||
|
|
||||||
for (int i = -3; i <= 3; i++)
|
|
||||||
{
|
|
||||||
components.accept(new AltarComponent(new BlockPos(5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-5, -3, i), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(i, -3, 5), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(i, -3, -5), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = -2; i <= 1; i++)
|
|
||||||
{
|
|
||||||
components.accept(new AltarComponent(new BlockPos(5, i, 5)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(5, i, -5)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-5, i, -5)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-5, i, 5)));
|
|
||||||
}
|
|
||||||
|
|
||||||
components.accept(new AltarComponent(new BlockPos(5, 2, 5), ComponentType.BLOODSTONE));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(5, 2, -5), ComponentType.BLOODSTONE));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-5, 2, -5), ComponentType.BLOODSTONE));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-5, 2, 5), ComponentType.BLOODSTONE));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
FIVE()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void buildComponents(Consumer<AltarComponent> components)
|
|
||||||
{
|
|
||||||
FOUR.getAltarComponents().forEach(components);
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-8, -3, 8), ComponentType.BEACON));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-8, -3, -8), ComponentType.BEACON));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(8, -3, -8), ComponentType.BEACON));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(8, -3, 8), ComponentType.BEACON));
|
|
||||||
|
|
||||||
for (int i = -6; i <= 6; i++)
|
|
||||||
{
|
|
||||||
components.accept(new AltarComponent(new BlockPos(8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-8, -4, i), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(i, -4, 8), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(i, -4, -8), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
SIX()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void buildComponents(Consumer<AltarComponent> components)
|
|
||||||
{
|
|
||||||
FIVE.getAltarComponents().forEach(components);
|
|
||||||
|
|
||||||
for (int i = -4; i <= 2; i++)
|
|
||||||
{
|
|
||||||
components.accept(new AltarComponent(new BlockPos(11, i, 11)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-11, i, -11)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(11, i, -11)));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-11, i, 11)));
|
|
||||||
}
|
|
||||||
|
|
||||||
components.accept(new AltarComponent(new BlockPos(11, 3, 11), ComponentType.CRYSTAL));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-11, 3, -11), ComponentType.CRYSTAL));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(11, 3, -11), ComponentType.CRYSTAL));
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-11, 3, 11), ComponentType.CRYSTAL));
|
|
||||||
|
|
||||||
for (int i = -9; i <= 9; i++)
|
|
||||||
{
|
|
||||||
components.accept(new AltarComponent(new BlockPos(11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(-11, -5, i), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(i, -5, 11), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
components.accept(new AltarComponent(new BlockPos(i, -5, -11), ComponentType.BLOODRUNE).setUpgradeSlot());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static final int MAXTIERS = values().length;
|
|
||||||
|
|
||||||
private List<AltarComponent> altarComponents;
|
|
||||||
|
|
||||||
AltarTier()
|
|
||||||
{
|
|
||||||
this.altarComponents = Lists.newArrayList();
|
|
||||||
|
|
||||||
buildComponents(altarComponents::add);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void buildComponents(Consumer<AltarComponent> components);
|
|
||||||
|
|
||||||
public int toInt()
|
|
||||||
{
|
|
||||||
return ordinal() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<AltarComponent> getAltarComponents()
|
|
||||||
{
|
|
||||||
return altarComponents;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package wayoftime.bloodmagic.altar;
|
|
||||||
|
|
||||||
import java.util.EnumMap;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
import wayoftime.bloodmagic.block.enums.BloodRuneType;
|
|
||||||
|
|
||||||
public class AltarUpgrade
|
|
||||||
{
|
|
||||||
|
|
||||||
private final EnumMap<BloodRuneType, Integer> upgradeLevels;
|
|
||||||
|
|
||||||
public AltarUpgrade()
|
|
||||||
{
|
|
||||||
this.upgradeLevels = Maps.newEnumMap(BloodRuneType.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AltarUpgrade upgrade(BloodRuneType rune)
|
|
||||||
{
|
|
||||||
upgradeLevels.compute(rune, (r, l) -> l == null ? 1 : l + 1);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLevel(BloodRuneType rune)
|
|
||||||
{
|
|
||||||
return upgradeLevels.getOrDefault(rune, 0);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
package wayoftime.bloodmagic.altar;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
|
||||||
import wayoftime.bloodmagic.common.block.BlockBloodRune;
|
|
||||||
import wayoftime.bloodmagic.tile.TileAltar;
|
|
||||||
|
|
||||||
public class AltarUtil
|
|
||||||
{
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public static AltarTier getTier(World world, BlockPos pos)
|
|
||||||
{
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
|
||||||
if (!(tile instanceof TileAltar))
|
|
||||||
return AltarTier.ONE;
|
|
||||||
|
|
||||||
AltarTier lastCheck = AltarTier.ONE;
|
|
||||||
for (AltarTier tier : AltarTier.values())
|
|
||||||
{
|
|
||||||
for (AltarComponent component : tier.getAltarComponents())
|
|
||||||
{
|
|
||||||
BlockPos componentPos = pos.add(component.getOffset());
|
|
||||||
BlockState worldState = world.getBlockState(componentPos);
|
|
||||||
|
|
||||||
if (worldState.getBlock() instanceof IAltarComponent)
|
|
||||||
if (((IAltarComponent) worldState.getBlock()).getType(world, worldState, componentPos) == component.getComponent())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (component.getComponent() == ComponentType.NOTAIR && worldState.getMaterial() != Material.AIR
|
|
||||||
&& !worldState.getMaterial().isLiquid())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
List<BlockState> validStates = BloodMagicAPI.INSTANCE.getComponentStates(component.getComponent());
|
|
||||||
if (!validStates.contains(worldState))
|
|
||||||
return lastCheck;
|
|
||||||
}
|
|
||||||
|
|
||||||
lastCheck = tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastCheck;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public static AltarUpgrade getUpgrades(World world, BlockPos pos, AltarTier currentTier)
|
|
||||||
{
|
|
||||||
AltarUpgrade upgrades = new AltarUpgrade();
|
|
||||||
|
|
||||||
for (AltarComponent component : currentTier.getAltarComponents())
|
|
||||||
{
|
|
||||||
if (!component.isUpgradeSlot() || component.getComponent() != ComponentType.BLOODRUNE)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BlockPos componentPos = pos.add(component.getOffset());
|
|
||||||
BlockState state = world.getBlockState(componentPos);
|
|
||||||
if (state.getBlock() instanceof BlockBloodRune)
|
|
||||||
upgrades.upgrade(((BlockBloodRune) state.getBlock()).getBloodRune(world, componentPos));
|
|
||||||
}
|
|
||||||
|
|
||||||
return upgrades;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static Pair<BlockPos, ComponentType> getFirstMissingComponent(World world, BlockPos pos, int altarTier)
|
|
||||||
{
|
|
||||||
if (altarTier >= AltarTier.MAXTIERS)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
for (AltarTier tier : AltarTier.values())
|
|
||||||
{
|
|
||||||
for (AltarComponent component : tier.getAltarComponents())
|
|
||||||
{
|
|
||||||
BlockPos componentPos = pos.add(component.getOffset());
|
|
||||||
BlockState worldState = world.getBlockState(componentPos);
|
|
||||||
if (component.getComponent() == ComponentType.NOTAIR && worldState.getMaterial() != Material.AIR
|
|
||||||
&& !worldState.getMaterial().isLiquid())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
List<BlockState> validStates = BloodMagicAPI.INSTANCE.getComponentStates(component.getComponent());
|
|
||||||
if (!validStates.contains(worldState))
|
|
||||||
return Pair.of(componentPos, component.getComponent());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,816 +0,0 @@
|
||||||
package wayoftime.bloodmagic.altar;
|
|
||||||
|
|
||||||
import com.google.common.base.Enums;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.particles.ParticleTypes;
|
|
||||||
import net.minecraft.particles.RedstoneParticleData;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.server.ServerWorld;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import net.minecraftforge.fluids.FluidAttributes;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
|
||||||
import net.minecraftforge.fluids.capability.templates.FluidTank;
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
import wayoftime.bloodmagic.api.event.BloodMagicCraftedEvent;
|
|
||||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
|
||||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
|
|
||||||
import wayoftime.bloodmagic.block.enums.BloodRuneType;
|
|
||||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
|
||||||
import wayoftime.bloodmagic.core.data.Binding;
|
|
||||||
import wayoftime.bloodmagic.iface.IBindable;
|
|
||||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
|
||||||
import wayoftime.bloodmagic.orb.IBloodOrb;
|
|
||||||
import wayoftime.bloodmagic.tile.TileAltar;
|
|
||||||
import wayoftime.bloodmagic.util.Constants;
|
|
||||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
|
||||||
|
|
||||||
public class BloodAltar// implements IFluidHandler
|
|
||||||
{
|
|
||||||
|
|
||||||
public boolean isActive;
|
|
||||||
|
|
||||||
protected FluidStack fluidOutput = new FluidStack(BloodMagicBlocks.LIFE_ESSENCE_FLUID.get(), 0); // TODO: Fix
|
|
||||||
protected FluidStack fluidInput = new FluidStack(BloodMagicBlocks.LIFE_ESSENCE_FLUID.get(), 0);
|
|
||||||
|
|
||||||
protected FluidTank tank = new FluidTank(FluidAttributes.BUCKET_VOLUME);
|
|
||||||
|
|
||||||
private final LazyOptional<IFluidHandler> holder = LazyOptional.of(() -> tank);
|
|
||||||
|
|
||||||
private TileAltar tileAltar;
|
|
||||||
private int internalCounter = 0;
|
|
||||||
private AltarTier altarTier = AltarTier.ONE;
|
|
||||||
private AltarUpgrade upgrade;
|
|
||||||
private int capacity = FluidAttributes.BUCKET_VOLUME * 10;
|
|
||||||
private FluidStack fluid = new FluidStack(BloodMagicBlocks.LIFE_ESSENCE_FLUID.get(), 0);
|
|
||||||
private int liquidRequired; // mB
|
|
||||||
private boolean canBeFilled;
|
|
||||||
private int consumptionRate;
|
|
||||||
private int drainRate;
|
|
||||||
private float consumptionMultiplier;
|
|
||||||
private float efficiencyMultiplier;
|
|
||||||
private float sacrificeEfficiencyMultiplier;
|
|
||||||
private float selfSacrificeEfficiencyMultiplier;
|
|
||||||
private float capacityMultiplier = 1;
|
|
||||||
private float orbCapacityMultiplier;
|
|
||||||
private float dislocationMultiplier;
|
|
||||||
private int accelerationUpgrades;
|
|
||||||
private boolean isUpgraded;
|
|
||||||
private boolean isResultBlock;
|
|
||||||
private int bufferCapacity = FluidAttributes.BUCKET_VOLUME;
|
|
||||||
private int progress;
|
|
||||||
private int lockdownDuration;
|
|
||||||
private int demonBloodDuration;
|
|
||||||
private int totalCharge = 0; // TODO save
|
|
||||||
private int chargingRate = 0;
|
|
||||||
private int chargingFrequency = 0;
|
|
||||||
private int maxCharge = 0;
|
|
||||||
private int cooldownAfterCrafting = 60;
|
|
||||||
private RecipeBloodAltar recipe;
|
|
||||||
private AltarTier currentTierDisplayed = AltarTier.ONE;
|
|
||||||
|
|
||||||
public BloodAltar(TileAltar tileAltar)
|
|
||||||
{
|
|
||||||
this.tileAltar = tileAltar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readFromNBT(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
if (!tagCompound.contains(Constants.NBT.EMPTY))
|
|
||||||
{
|
|
||||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound);
|
|
||||||
|
|
||||||
if (fluid != null)
|
|
||||||
{
|
|
||||||
setMainFluid(new FluidStack(BloodMagicBlocks.LIFE_ESSENCE_FLUID.get(), fluid.getAmount()));
|
|
||||||
// setMainFluid(fluid);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
// setMainFluid(new FluidStack(BloodMagicBlocks.LIFE_ESSENCE_FLUID.get(), fluid.getAmount()));
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack fluidOut = new FluidStack(BloodMagicBlocks.LIFE_ESSENCE_FLUID.get(), tagCompound.getInt(Constants.NBT.OUTPUT_AMOUNT));
|
|
||||||
setOutputFluid(fluidOut);
|
|
||||||
|
|
||||||
FluidStack fluidIn = new FluidStack(BloodMagicBlocks.LIFE_ESSENCE_FLUID.get(), tagCompound.getInt(Constants.NBT.INPUT_AMOUNT));
|
|
||||||
setInputFluid(fluidIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
internalCounter = tagCompound.getInt("internalCounter");
|
|
||||||
altarTier = Enums.getIfPresent(AltarTier.class, tagCompound.getString(Constants.NBT.ALTAR_TIER)).or(AltarTier.ONE);
|
|
||||||
isActive = tagCompound.getBoolean(Constants.NBT.ALTAR_ACTIVE);
|
|
||||||
liquidRequired = tagCompound.getInt(Constants.NBT.ALTAR_LIQUID_REQ);
|
|
||||||
canBeFilled = tagCompound.getBoolean(Constants.NBT.ALTAR_FILLABLE);
|
|
||||||
isUpgraded = tagCompound.getBoolean(Constants.NBT.ALTAR_UPGRADED);
|
|
||||||
consumptionRate = tagCompound.getInt(Constants.NBT.ALTAR_CONSUMPTION_RATE);
|
|
||||||
drainRate = tagCompound.getInt(Constants.NBT.ALTAR_DRAIN_RATE);
|
|
||||||
consumptionMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_CONSUMPTION_MULTIPLIER);
|
|
||||||
efficiencyMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_EFFICIENCY_MULTIPLIER);
|
|
||||||
selfSacrificeEfficiencyMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_SELF_SACRIFICE_MULTIPLIER);
|
|
||||||
sacrificeEfficiencyMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_SACRIFICE_MULTIPLIER);
|
|
||||||
capacityMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_CAPACITY_MULTIPLIER);
|
|
||||||
orbCapacityMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_ORB_CAPACITY_MULTIPLIER);
|
|
||||||
dislocationMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_DISLOCATION_MULTIPLIER);
|
|
||||||
capacity = tagCompound.getInt(Constants.NBT.ALTAR_CAPACITY);
|
|
||||||
bufferCapacity = tagCompound.getInt(Constants.NBT.ALTAR_BUFFER_CAPACITY);
|
|
||||||
progress = tagCompound.getInt(Constants.NBT.ALTAR_PROGRESS);
|
|
||||||
isResultBlock = tagCompound.getBoolean(Constants.NBT.ALTAR_IS_RESULT_BLOCK);
|
|
||||||
lockdownDuration = tagCompound.getInt(Constants.NBT.ALTAR_LOCKDOWN_DURATION);
|
|
||||||
accelerationUpgrades = tagCompound.getInt(Constants.NBT.ALTAR_ACCELERATION_UPGRADES);
|
|
||||||
demonBloodDuration = tagCompound.getInt(Constants.NBT.ALTAR_DEMON_BLOOD_DURATION);
|
|
||||||
cooldownAfterCrafting = tagCompound.getInt(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING);
|
|
||||||
chargingRate = tagCompound.getInt(Constants.NBT.ALTAR_CHARGE_RATE);
|
|
||||||
chargingFrequency = tagCompound.getInt(Constants.NBT.ALTAR_CHARGE_FREQUENCY);
|
|
||||||
totalCharge = tagCompound.getInt(Constants.NBT.ALTAR_TOTAL_CHARGE);
|
|
||||||
maxCharge = tagCompound.getInt(Constants.NBT.ALTAR_MAX_CHARGE);
|
|
||||||
currentTierDisplayed = Enums.getIfPresent(AltarTier.class, tagCompound.getString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED)).or(AltarTier.ONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writeToNBT(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (fluid != null)
|
|
||||||
fluid.writeToNBT(tagCompound);
|
|
||||||
else
|
|
||||||
tagCompound.putString(Constants.NBT.EMPTY, "");
|
|
||||||
|
|
||||||
if (fluidOutput != null)
|
|
||||||
tagCompound.putInt(Constants.NBT.OUTPUT_AMOUNT, fluidOutput.getAmount());
|
|
||||||
|
|
||||||
if (fluidInput != null)
|
|
||||||
tagCompound.putInt(Constants.NBT.INPUT_AMOUNT, fluidInput.getAmount());
|
|
||||||
|
|
||||||
tagCompound.putInt("internalCounter", internalCounter);
|
|
||||||
tagCompound.putString(Constants.NBT.ALTAR_TIER, altarTier.name());
|
|
||||||
tagCompound.putBoolean(Constants.NBT.ALTAR_ACTIVE, isActive);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_LIQUID_REQ, liquidRequired);
|
|
||||||
tagCompound.putBoolean(Constants.NBT.ALTAR_FILLABLE, canBeFilled);
|
|
||||||
tagCompound.putBoolean(Constants.NBT.ALTAR_UPGRADED, isUpgraded);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_CONSUMPTION_RATE, consumptionRate);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_DRAIN_RATE, drainRate);
|
|
||||||
tagCompound.putFloat(Constants.NBT.ALTAR_CONSUMPTION_MULTIPLIER, consumptionMultiplier);
|
|
||||||
tagCompound.putFloat(Constants.NBT.ALTAR_EFFICIENCY_MULTIPLIER, efficiencyMultiplier);
|
|
||||||
tagCompound.putFloat(Constants.NBT.ALTAR_SACRIFICE_MULTIPLIER, sacrificeEfficiencyMultiplier);
|
|
||||||
tagCompound.putFloat(Constants.NBT.ALTAR_SELF_SACRIFICE_MULTIPLIER, selfSacrificeEfficiencyMultiplier);
|
|
||||||
tagCompound.putBoolean(Constants.NBT.ALTAR_IS_RESULT_BLOCK, isResultBlock);
|
|
||||||
tagCompound.putFloat(Constants.NBT.ALTAR_CAPACITY_MULTIPLIER, capacityMultiplier);
|
|
||||||
tagCompound.putFloat(Constants.NBT.ALTAR_ORB_CAPACITY_MULTIPLIER, orbCapacityMultiplier);
|
|
||||||
tagCompound.putFloat(Constants.NBT.ALTAR_DISLOCATION_MULTIPLIER, dislocationMultiplier);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_CAPACITY, capacity);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_PROGRESS, progress);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_BUFFER_CAPACITY, bufferCapacity);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_LOCKDOWN_DURATION, lockdownDuration);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_ACCELERATION_UPGRADES, accelerationUpgrades);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_DEMON_BLOOD_DURATION, demonBloodDuration);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING, cooldownAfterCrafting);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_CHARGE_RATE, chargingRate);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_CHARGE_FREQUENCY, chargingFrequency);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_TOTAL_CHARGE, totalCharge);
|
|
||||||
tagCompound.putInt(Constants.NBT.ALTAR_MAX_CHARGE, maxCharge);
|
|
||||||
tagCompound.putString(Constants.NBT.ALTAR_CURRENT_TIER_DISPLAYED, currentTierDisplayed.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startCycle()
|
|
||||||
{
|
|
||||||
if (tileAltar.getWorld() != null)
|
|
||||||
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
|
||||||
|
|
||||||
checkTier();
|
|
||||||
|
|
||||||
// Temporary thing to test the recipes.
|
|
||||||
// fluid.setAmount(10000);
|
|
||||||
// this.setMainFluid(new FluidStack(BloodMagicBlocks.LIFE_ESSENCE_FLUID.get(), 10000));
|
|
||||||
|
|
||||||
if ((fluid == null || fluid.getAmount() <= 0) && totalCharge <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!isActive)
|
|
||||||
progress = 0;
|
|
||||||
|
|
||||||
ItemStack input = tileAltar.getStackInSlot(0);
|
|
||||||
|
|
||||||
if (!input.isEmpty())
|
|
||||||
{
|
|
||||||
// Do recipes
|
|
||||||
RecipeBloodAltar recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getBloodAltar(tileAltar.getWorld(), input);
|
|
||||||
if (recipe != null)
|
|
||||||
{
|
|
||||||
if (recipe.getMinimumTier().ordinal() <= altarTier.ordinal())
|
|
||||||
{
|
|
||||||
this.isActive = true;
|
|
||||||
this.recipe = recipe;
|
|
||||||
this.liquidRequired = recipe.getSyphon();
|
|
||||||
this.consumptionRate = recipe.getConsumeRate();
|
|
||||||
this.drainRate = recipe.getDrainRate();
|
|
||||||
this.canBeFilled = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (input.getItem() instanceof IBloodOrb)
|
|
||||||
{
|
|
||||||
this.isActive = true;
|
|
||||||
this.canBeFilled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isActive = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update()
|
|
||||||
{
|
|
||||||
// World world = tileAltar.getWorld();
|
|
||||||
//
|
|
||||||
// RecipeBloodAltar recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getBloodAltar(world, new ItemStack(Items.DIAMOND));
|
|
||||||
//
|
|
||||||
// if (recipe != null)
|
|
||||||
// {
|
|
||||||
// System.out.println("Found a recipe!");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// List<RecipeBloodAltar> altarRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALTAR);
|
|
||||||
//
|
|
||||||
// System.out.println("There are currently " + altarRecipes.size() + " Altar Recipes loaded.");
|
|
||||||
//
|
|
||||||
World world = tileAltar.getWorld();
|
|
||||||
BlockPos pos = tileAltar.getPos();
|
|
||||||
|
|
||||||
if (world.isRemote)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Used instead of the world time for checks that do not happen every tick
|
|
||||||
internalCounter++;
|
|
||||||
|
|
||||||
if (lockdownDuration > 0)
|
|
||||||
lockdownDuration--;
|
|
||||||
|
|
||||||
if (internalCounter % 20 == 0)
|
|
||||||
{
|
|
||||||
for (Direction facing : Direction.values())
|
|
||||||
{
|
|
||||||
BlockPos newPos = pos.offset(facing);
|
|
||||||
BlockState block = world.getBlockState(newPos);
|
|
||||||
block.getBlock().onNeighborChange(block, world, newPos, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (internalCounter % (Math.max(20 - this.accelerationUpgrades, 1)) == 0)
|
|
||||||
{
|
|
||||||
int syphonMax = (int) (20 * this.dislocationMultiplier);
|
|
||||||
int fluidInputted;
|
|
||||||
int fluidOutputted;
|
|
||||||
fluidInputted = Math.min(syphonMax, -this.fluid.getAmount() + capacity);
|
|
||||||
fluidInputted = Math.min(this.fluidInput.getAmount(), fluidInputted);
|
|
||||||
this.fluid.setAmount(this.fluid.getAmount() + fluidInputted);
|
|
||||||
this.fluidInput.setAmount(this.fluidInput.getAmount() - fluidInputted);
|
|
||||||
fluidOutputted = Math.min(syphonMax, this.bufferCapacity - this.fluidOutput.getAmount());
|
|
||||||
fluidOutputted = Math.min(this.fluid.getAmount(), fluidOutputted);
|
|
||||||
this.fluidOutput.setAmount(this.fluidOutput.getAmount() + fluidOutputted);
|
|
||||||
this.fluid.setAmount(this.fluid.getAmount() - fluidOutputted);
|
|
||||||
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (internalCounter % this.getChargingFrequency() == 0 && !this.isActive)
|
|
||||||
{
|
|
||||||
// int chargeInputted = Math.min(chargingRate, this.fluid.getAmount());
|
|
||||||
// chargeInputted = Math.min(chargeInputted, maxCharge - totalCharge);
|
|
||||||
// totalCharge += chargeInputted;
|
|
||||||
// this.fluid.setAmount(this.fluid.getAmount() - chargeInputted);
|
|
||||||
// tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (internalCounter % 100 == 0 && (this.isActive || this.cooldownAfterCrafting <= 0))
|
|
||||||
startCycle();
|
|
||||||
|
|
||||||
updateAltar();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateAltar()
|
|
||||||
{
|
|
||||||
// System.out.println("Updating altar.");
|
|
||||||
if (!isActive)
|
|
||||||
{
|
|
||||||
if (cooldownAfterCrafting > 0)
|
|
||||||
cooldownAfterCrafting--;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!canBeFilled && recipe == null)
|
|
||||||
{
|
|
||||||
startCycle();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack input = tileAltar.getStackInSlot(0);
|
|
||||||
|
|
||||||
if (input.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
World world = tileAltar.getWorld();
|
|
||||||
BlockPos pos = tileAltar.getPos();
|
|
||||||
|
|
||||||
if (world.isRemote)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!canBeFilled)
|
|
||||||
{
|
|
||||||
boolean hasOperated = false;
|
|
||||||
int stackSize = input.getCount();
|
|
||||||
|
|
||||||
if (totalCharge > 0)
|
|
||||||
{
|
|
||||||
int chargeDrained = Math.min(liquidRequired * stackSize - progress, totalCharge);
|
|
||||||
|
|
||||||
totalCharge -= chargeDrained;
|
|
||||||
progress += chargeDrained;
|
|
||||||
hasOperated = true;
|
|
||||||
}
|
|
||||||
if (fluid != null && fluid.getAmount() >= 1)
|
|
||||||
{
|
|
||||||
// int liquidDrained = Math.min((int) (altarTier.ordinal() >= 1
|
|
||||||
// ? consumptionRate * (1 + consumptionMultiplier)
|
|
||||||
// : consumptionRate), fluid.getAmount());
|
|
||||||
int liquidDrained = Math.min((int) (consumptionRate * (1 + consumptionMultiplier)), fluid.getAmount());
|
|
||||||
|
|
||||||
if (liquidDrained > (liquidRequired * stackSize - progress))
|
|
||||||
liquidDrained = liquidRequired * stackSize - progress;
|
|
||||||
|
|
||||||
fluid.setAmount(fluid.getAmount() - liquidDrained);
|
|
||||||
progress += liquidDrained;
|
|
||||||
|
|
||||||
hasOperated = true;
|
|
||||||
|
|
||||||
if (internalCounter % 4 == 0 && world instanceof ServerWorld)
|
|
||||||
{
|
|
||||||
ServerWorld server = (ServerWorld) world;
|
|
||||||
// server.spawnParticle(ParticleTypes.SPLASH, (double) pos.getX()
|
|
||||||
// + worldIn.rand.nextDouble(), (double) (pos.getY() + 1), (double) pos.getZ()
|
|
||||||
// + worldIn.rand.nextDouble(), 1, 0.0D, 0.0D, 0.0D, 1.0D);
|
|
||||||
server.spawnParticle(RedstoneParticleData.REDSTONE_DUST, pos.getX() + 0.5, pos.getY()
|
|
||||||
+ 1.0, pos.getZ() + 0.5, 1, 0.2, 0.0, 0.2, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (!hasOperated && progress > 0)
|
|
||||||
{
|
|
||||||
progress -= (int) (efficiencyMultiplier * drainRate);
|
|
||||||
|
|
||||||
if (internalCounter % 2 == 0 && world instanceof ServerWorld)
|
|
||||||
{
|
|
||||||
ServerWorld server = (ServerWorld) world;
|
|
||||||
server.spawnParticle(ParticleTypes.LARGE_SMOKE, pos.getX() + 0.5, pos.getY() + 1, pos.getZ()
|
|
||||||
+ 0.5, 1, 0.1, 0, 0.1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasOperated)
|
|
||||||
{
|
|
||||||
if (progress >= liquidRequired * stackSize)
|
|
||||||
{
|
|
||||||
ItemStack result = ItemHandlerHelper.copyStackWithSize(recipe.getOutput(), stackSize);
|
|
||||||
|
|
||||||
BloodMagicCraftedEvent.Altar event = new BloodMagicCraftedEvent.Altar(result, input.copy());
|
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
|
||||||
tileAltar.setInventorySlotContents(0, event.getOutput());
|
|
||||||
progress = 0;
|
|
||||||
|
|
||||||
if (world instanceof ServerWorld)
|
|
||||||
{
|
|
||||||
ServerWorld server = (ServerWorld) world;
|
|
||||||
server.spawnParticle(RedstoneParticleData.REDSTONE_DUST, pos.getX() + 0.5, pos.getY()
|
|
||||||
+ 1, pos.getZ() + 0.5, 40, 0.3, 0, 0.3, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.cooldownAfterCrafting = 30;
|
|
||||||
this.isActive = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
ItemStack contained = tileAltar.getStackInSlot(0);
|
|
||||||
|
|
||||||
if (contained.isEmpty() || !(contained.getItem() instanceof IBloodOrb)
|
|
||||||
|| !(contained.getItem() instanceof IBindable))
|
|
||||||
return;
|
|
||||||
|
|
||||||
BloodOrb orb = ((IBloodOrb) contained.getItem()).getOrb(contained);
|
|
||||||
Binding binding = ((IBindable) contained.getItem()).getBinding(contained);
|
|
||||||
|
|
||||||
if (binding == null || orb == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (fluid != null && fluid.getAmount() >= 1)
|
|
||||||
{
|
|
||||||
// int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2
|
|
||||||
// ? orb.getFillRate() * (1 + consumptionMultiplier)
|
|
||||||
// : orb.getFillRate()), fluid.getAmount());
|
|
||||||
int liquidDrained = Math.min((int) (orb.getFillRate()
|
|
||||||
* (1 + consumptionMultiplier)), fluid.getAmount());
|
|
||||||
int drain = NetworkHelper.getSoulNetwork(binding).add(liquidDrained, (int) (orb.getCapacity()
|
|
||||||
* this.orbCapacityMultiplier));
|
|
||||||
fluid.setAmount(fluid.getAmount() - drain);
|
|
||||||
|
|
||||||
if (drain > 0 && internalCounter % 4 == 0 && world instanceof ServerWorld)
|
|
||||||
{
|
|
||||||
ServerWorld server = (ServerWorld) world;
|
|
||||||
server.spawnParticle(ParticleTypes.WITCH, pos.getX() + 0.5, pos.getY() + 1, pos.getZ()
|
|
||||||
+ 0.5, 1, 0, 0, 0, 0.001);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkTier()
|
|
||||||
{
|
|
||||||
AltarTier tier = AltarUtil.getTier(tileAltar.getWorld(), tileAltar.getPos());
|
|
||||||
this.altarTier = tier;
|
|
||||||
|
|
||||||
upgrade = AltarUtil.getUpgrades(tileAltar.getWorld(), tileAltar.getPos(), tier);
|
|
||||||
|
|
||||||
if (tier.equals(currentTierDisplayed))
|
|
||||||
currentTierDisplayed = AltarTier.ONE;
|
|
||||||
|
|
||||||
if (tier.equals(AltarTier.ONE))
|
|
||||||
{
|
|
||||||
upgrade = null;
|
|
||||||
isUpgraded = false;
|
|
||||||
this.consumptionMultiplier = 0;
|
|
||||||
this.efficiencyMultiplier = 1;
|
|
||||||
this.sacrificeEfficiencyMultiplier = 0;
|
|
||||||
this.selfSacrificeEfficiencyMultiplier = 0;
|
|
||||||
this.capacityMultiplier = 1;
|
|
||||||
this.orbCapacityMultiplier = 1;
|
|
||||||
this.dislocationMultiplier = 1;
|
|
||||||
this.accelerationUpgrades = 0;
|
|
||||||
this.chargingFrequency = 20;
|
|
||||||
this.chargingRate = 0;
|
|
||||||
this.maxCharge = 0;
|
|
||||||
this.totalCharge = 0;
|
|
||||||
return;
|
|
||||||
} else if (!tier.equals(AltarTier.ONE))
|
|
||||||
{
|
|
||||||
this.isUpgraded = true;
|
|
||||||
this.accelerationUpgrades = upgrade.getLevel(BloodRuneType.ACCELERATION);
|
|
||||||
this.consumptionMultiplier = (float) (0.20 * upgrade.getLevel(BloodRuneType.SPEED));
|
|
||||||
this.efficiencyMultiplier = (float) Math.pow(0.85, upgrade.getLevel(BloodRuneType.EFFICIENCY));
|
|
||||||
this.sacrificeEfficiencyMultiplier = (float) (0.10 * upgrade.getLevel(BloodRuneType.SACRIFICE));
|
|
||||||
this.selfSacrificeEfficiencyMultiplier = (float) (0.10 * upgrade.getLevel(BloodRuneType.SELF_SACRIFICE));
|
|
||||||
this.capacityMultiplier = (float) ((1 * Math.pow(1.10, upgrade.getLevel(BloodRuneType.AUGMENTED_CAPACITY)))
|
|
||||||
+ 0.20 * upgrade.getLevel(BloodRuneType.CAPACITY));
|
|
||||||
this.dislocationMultiplier = (float) (Math.pow(1.2, upgrade.getLevel(BloodRuneType.DISPLACEMENT)));
|
|
||||||
this.orbCapacityMultiplier = (float) (1 + 0.02 * upgrade.getLevel(BloodRuneType.ORB));
|
|
||||||
this.chargingFrequency = Math.max(20 - accelerationUpgrades, 1);
|
|
||||||
this.chargingRate = (int) (10 * upgrade.getLevel(BloodRuneType.CHARGING) * (1 + consumptionMultiplier / 2));
|
|
||||||
this.maxCharge = (int) (FluidAttributes.BUCKET_VOLUME * Math.max(0.5 * capacityMultiplier, 1)
|
|
||||||
* upgrade.getLevel(BloodRuneType.CHARGING));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.capacity = (int) (FluidAttributes.BUCKET_VOLUME * 10 * capacityMultiplier);
|
|
||||||
this.bufferCapacity = (int) (FluidAttributes.BUCKET_VOLUME * 1 * capacityMultiplier);
|
|
||||||
|
|
||||||
if (this.fluid.getAmount() > this.capacity)
|
|
||||||
this.fluid.setAmount(this.capacity);
|
|
||||||
if (this.fluidOutput.getAmount() > this.bufferCapacity)
|
|
||||||
this.fluidOutput.setAmount(this.bufferCapacity);
|
|
||||||
if (this.fluidInput.getAmount() > this.bufferCapacity)
|
|
||||||
this.fluidInput.setAmount(this.bufferCapacity);
|
|
||||||
if (this.totalCharge > this.maxCharge)
|
|
||||||
this.totalCharge = this.maxCharge;
|
|
||||||
|
|
||||||
tileAltar.getWorld().notifyBlockUpdate(tileAltar.getPos(), tileAltar.getWorld().getBlockState(tileAltar.getPos()), tileAltar.getWorld().getBlockState(tileAltar.getPos()), 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int fillMainTank(int amount)
|
|
||||||
{
|
|
||||||
int filledAmount = Math.min(capacity - fluid.getAmount(), amount);
|
|
||||||
fluid.setAmount(fluid.getAmount() + filledAmount);
|
|
||||||
|
|
||||||
return filledAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sacrificialDaggerCall(int amount, boolean isSacrifice)
|
|
||||||
{
|
|
||||||
if (this.lockdownDuration > 0)
|
|
||||||
{
|
|
||||||
int amt = (int) Math.min(bufferCapacity
|
|
||||||
- fluidInput.getAmount(), (isSacrifice ? 1 + sacrificeEfficiencyMultiplier
|
|
||||||
: 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
|
||||||
fluidInput.setAmount(fluidInput.getAmount() + amt);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
fluid.setAmount((int) (fluid.getAmount()
|
|
||||||
+ Math.min(capacity - fluid.getAmount(), (isSacrifice ? 1 + sacrificeEfficiencyMultiplier
|
|
||||||
: 1 + selfSacrificeEfficiencyMultiplier) * amount)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMainFluid(FluidStack fluid)
|
|
||||||
{
|
|
||||||
this.fluid = fluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOutputFluid(FluidStack fluid)
|
|
||||||
{
|
|
||||||
this.fluidOutput = fluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInputFluid(FluidStack fluid)
|
|
||||||
{
|
|
||||||
this.fluidInput = fluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AltarUpgrade getUpgrade()
|
|
||||||
{
|
|
||||||
return upgrade;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpgrade(AltarUpgrade upgrade)
|
|
||||||
{
|
|
||||||
this.upgrade = upgrade;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCapacity()
|
|
||||||
{
|
|
||||||
return capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FluidStack getFluid()
|
|
||||||
{
|
|
||||||
return fluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFluidAmount()
|
|
||||||
{
|
|
||||||
return fluid.getAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCurrentBlood()
|
|
||||||
{
|
|
||||||
return getFluidAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AltarTier getTier()
|
|
||||||
{
|
|
||||||
return altarTier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTier(AltarTier tier)
|
|
||||||
{
|
|
||||||
this.altarTier = tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getProgress()
|
|
||||||
{
|
|
||||||
return progress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getSacrificeMultiplier()
|
|
||||||
{
|
|
||||||
return sacrificeEfficiencyMultiplier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getSelfSacrificeMultiplier()
|
|
||||||
{
|
|
||||||
return selfSacrificeEfficiencyMultiplier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getOrbMultiplier()
|
|
||||||
{
|
|
||||||
return orbCapacityMultiplier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getDislocationMultiplier()
|
|
||||||
{
|
|
||||||
return dislocationMultiplier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getConsumptionMultiplier()
|
|
||||||
{
|
|
||||||
return consumptionMultiplier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getConsumptionRate()
|
|
||||||
{
|
|
||||||
return consumptionRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLiquidRequired()
|
|
||||||
{
|
|
||||||
return liquidRequired;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBufferCapacity()
|
|
||||||
{
|
|
||||||
return bufferCapacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setCurrentTierDisplayed(AltarTier altarTier)
|
|
||||||
{
|
|
||||||
if (currentTierDisplayed == altarTier)
|
|
||||||
return false;
|
|
||||||
else
|
|
||||||
currentTierDisplayed = altarTier;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addToDemonBloodDuration(int dur)
|
|
||||||
{
|
|
||||||
this.demonBloodDuration += dur;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasDemonBlood()
|
|
||||||
{
|
|
||||||
return this.demonBloodDuration > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void decrementDemonBlood()
|
|
||||||
{
|
|
||||||
this.demonBloodDuration = Math.max(0, this.demonBloodDuration - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive()
|
|
||||||
{
|
|
||||||
// if (tileAltar.getStackInSlot(0).isEmpty())
|
|
||||||
// {
|
|
||||||
// isActive = false;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isActive()
|
|
||||||
{
|
|
||||||
return isActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void requestPauseAfterCrafting(int amount)
|
|
||||||
{
|
|
||||||
if (this.isActive)
|
|
||||||
{
|
|
||||||
this.cooldownAfterCrafting = amount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChargingRate()
|
|
||||||
{
|
|
||||||
return chargingRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotalCharge()
|
|
||||||
{
|
|
||||||
return totalCharge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChargingFrequency()
|
|
||||||
{
|
|
||||||
return chargingFrequency == 0 ? 1 : chargingFrequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int fill(FluidStack resource, boolean doFill)
|
|
||||||
{
|
|
||||||
if (resource == null || resource.getFluid() != BloodMagicBlocks.LIFE_ESSENCE_FLUID.get())
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!doFill)
|
|
||||||
{
|
|
||||||
if (fluidInput == null)
|
|
||||||
{
|
|
||||||
return Math.min(bufferCapacity, resource.getAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fluidInput.isFluidEqual(resource))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.min(bufferCapacity - fluidInput.getAmount(), resource.getAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fluidInput == null)
|
|
||||||
{
|
|
||||||
fluidInput = new FluidStack(resource, Math.min(bufferCapacity, resource.getAmount()));
|
|
||||||
|
|
||||||
return fluidInput.getAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fluidInput.isFluidEqual(resource))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int filled = bufferCapacity - fluidInput.getAmount();
|
|
||||||
|
|
||||||
if (resource.getAmount() < filled)
|
|
||||||
{
|
|
||||||
fluidInput.setAmount(fluidInput.getAmount() + resource.getAmount());
|
|
||||||
filled = resource.getAmount();
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
fluidInput.setAmount(bufferCapacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FluidStack drain(FluidStack resource, boolean doDrain)
|
|
||||||
{
|
|
||||||
if (resource == null || !resource.isFluidEqual(fluidOutput))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return drain(resource.getAmount(), doDrain);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FluidStack drain(int maxDrain, boolean doDrain)
|
|
||||||
{
|
|
||||||
if (fluidOutput == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
int drained = maxDrain;
|
|
||||||
if (fluidOutput.getAmount() < drained)
|
|
||||||
{
|
|
||||||
drained = fluidOutput.getAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
FluidStack stack = new FluidStack(fluidOutput, drained);
|
|
||||||
if (doDrain)
|
|
||||||
{
|
|
||||||
fluidOutput.setAmount(fluidOutput.getAmount() - drained);
|
|
||||||
}
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public IFluidTankProperties[] getTankProperties()
|
|
||||||
// {
|
|
||||||
// return new IFluidTankProperties[]
|
|
||||||
// { new FluidTankPropertiesWrapper(new FluidTank(fluid, capacity)) };
|
|
||||||
// }
|
|
||||||
|
|
||||||
public AltarTier getCurrentTierDisplayed()
|
|
||||||
{
|
|
||||||
return currentTierDisplayed;
|
|
||||||
}
|
|
||||||
|
|
||||||
static class VariableSizeFluidHandler implements IFluidHandler
|
|
||||||
{
|
|
||||||
BloodAltar altar;
|
|
||||||
|
|
||||||
VariableSizeFluidHandler(BloodAltar altar)
|
|
||||||
{
|
|
||||||
this.altar = altar;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTanks()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidStack getFluidInTank(int tank)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTankCapacity(int tank)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFluidValid(int tank, FluidStack stack)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int fill(FluidStack resource, FluidAction action)
|
|
||||||
{
|
|
||||||
return altar.fill(resource, action == FluidAction.EXECUTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(FluidStack resource, FluidAction action)
|
|
||||||
{
|
|
||||||
return altar.drain(resource, action == FluidAction.EXECUTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(int maxDrain, FluidAction action)
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package wayoftime.bloodmagic.altar;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List of different components used to construct different tiers of altars.
|
|
||||||
*/
|
|
||||||
public enum ComponentType
|
|
||||||
{
|
|
||||||
GLOWSTONE, BLOODSTONE, BEACON, BLOODRUNE, CRYSTAL, NOTAIR;
|
|
||||||
|
|
||||||
public static final ComponentType[] VALUES = values();
|
|
||||||
private static final String BASE = "chat.bloodmagic.altar.comp.";
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
ComponentType()
|
|
||||||
{
|
|
||||||
this.key = BASE + name().toLowerCase(Locale.ENGLISH);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey()
|
|
||||||
{
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package wayoftime.bloodmagic.altar;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public interface IAltarComponent
|
|
||||||
{
|
|
||||||
@Nullable
|
|
||||||
ComponentType getType(World world, BlockState state, BlockPos pos);
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
package wayoftime.bloodmagic.altar;
|
|
||||||
|
|
||||||
public interface IBloodAltar
|
|
||||||
{
|
|
||||||
int getCapacity();
|
|
||||||
|
|
||||||
int getCurrentBlood();
|
|
||||||
|
|
||||||
AltarTier getTier();
|
|
||||||
|
|
||||||
int getProgress();
|
|
||||||
|
|
||||||
float getSacrificeMultiplier();
|
|
||||||
|
|
||||||
float getSelfSacrificeMultiplier();
|
|
||||||
|
|
||||||
float getOrbMultiplier();
|
|
||||||
|
|
||||||
float getDislocationMultiplier();
|
|
||||||
|
|
||||||
float getConsumptionMultiplier();
|
|
||||||
|
|
||||||
float getConsumptionRate();
|
|
||||||
|
|
||||||
int getChargingRate();
|
|
||||||
|
|
||||||
int getChargingFrequency();
|
|
||||||
|
|
||||||
int getTotalCharge();
|
|
||||||
|
|
||||||
int getLiquidRequired();
|
|
||||||
|
|
||||||
int getBufferCapacity();
|
|
||||||
|
|
||||||
void sacrificialDaggerCall(int amount, boolean isSacrifice);
|
|
||||||
|
|
||||||
void startCycle();
|
|
||||||
|
|
||||||
void checkTier();
|
|
||||||
|
|
||||||
boolean isActive();
|
|
||||||
|
|
||||||
void setActive();
|
|
||||||
|
|
||||||
int fillMainTank(int amount);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will set the altar to initiate a cooldown cycle after it crafts before
|
|
||||||
* starting to craft again, giving the user time to interact with the altar.
|
|
||||||
* This can only be set while the altar is not active.
|
|
||||||
*
|
|
||||||
* @param cooldown - How long the cooldown should last
|
|
||||||
*/
|
|
||||||
void requestPauseAfterCrafting(int cooldown);
|
|
||||||
}
|
|
|
@ -1,101 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.impl;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import wayoftime.bloodmagic.altar.ComponentType;
|
|
||||||
import wayoftime.bloodmagic.api.IBloodMagicAPI;
|
|
||||||
import wayoftime.bloodmagic.util.BMLog;
|
|
||||||
|
|
||||||
public class BloodMagicAPI implements IBloodMagicAPI
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final BloodMagicAPI INSTANCE = new BloodMagicAPI();
|
|
||||||
|
|
||||||
// private final BloodMagicBlacklist blacklist;
|
|
||||||
private final BloodMagicRecipeRegistrar recipeRegistrar;
|
|
||||||
// private final BloodMagicValueManager valueManager;
|
|
||||||
private final Multimap<ComponentType, BlockState> altarComponents;
|
|
||||||
|
|
||||||
public BloodMagicAPI()
|
|
||||||
{
|
|
||||||
// this.blacklist = new BloodMagicBlacklist();
|
|
||||||
this.recipeRegistrar = new BloodMagicRecipeRegistrar();
|
|
||||||
// this.valueManager = new BloodMagicValueManager();
|
|
||||||
this.altarComponents = ArrayListMultimap.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Nonnull
|
|
||||||
// @Override
|
|
||||||
// public BloodMagicBlacklist getBlacklist()
|
|
||||||
// {
|
|
||||||
// return blacklist;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public BloodMagicRecipeRegistrar getRecipeRegistrar()
|
|
||||||
{
|
|
||||||
return recipeRegistrar;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// @Nonnull
|
|
||||||
// @Override
|
|
||||||
// public BloodMagicValueManager getValueManager()
|
|
||||||
// {
|
|
||||||
// return valueManager;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerAltarComponent(@Nonnull BlockState state, @Nonnull String componentType)
|
|
||||||
{
|
|
||||||
ComponentType component = null;
|
|
||||||
for (ComponentType type : ComponentType.VALUES)
|
|
||||||
{
|
|
||||||
if (type.name().equalsIgnoreCase(componentType))
|
|
||||||
{
|
|
||||||
component = type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component != null)
|
|
||||||
{
|
|
||||||
BMLog.API_VERBOSE.info("Registered {} as a {} altar component.", state, componentType);
|
|
||||||
altarComponents.put(component, state);
|
|
||||||
} else
|
|
||||||
BMLog.API.warn("Invalid Altar component type: {}.", componentType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unregisterAltarComponent(@Nonnull BlockState state, @Nonnull String componentType)
|
|
||||||
{
|
|
||||||
ComponentType component = null;
|
|
||||||
for (ComponentType type : ComponentType.VALUES)
|
|
||||||
{
|
|
||||||
if (type.name().equalsIgnoreCase(componentType))
|
|
||||||
{
|
|
||||||
component = type;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component != null)
|
|
||||||
{
|
|
||||||
BMLog.API_VERBOSE.info("Unregistered {} from being a {} altar component.", state, componentType);
|
|
||||||
altarComponents.remove(component, state);
|
|
||||||
} else
|
|
||||||
BMLog.API.warn("Invalid Altar component type: {}.", componentType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public List<BlockState> getComponentStates(ComponentType component)
|
|
||||||
{
|
|
||||||
return (List<BlockState>) altarComponents.get(component);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.impl;
|
|
||||||
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import wayoftime.bloodmagic.altar.ComponentType;
|
|
||||||
import wayoftime.bloodmagic.api.IBloodMagicAPI;
|
|
||||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
|
||||||
|
|
||||||
public class BloodMagicCorePlugin
|
|
||||||
{
|
|
||||||
public static final BloodMagicCorePlugin INSTANCE = new BloodMagicCorePlugin();
|
|
||||||
|
|
||||||
public void register(IBloodMagicAPI apiInterface)
|
|
||||||
{
|
|
||||||
apiInterface.registerAltarComponent(Blocks.GLOWSTONE.getDefaultState(), ComponentType.GLOWSTONE.name());
|
|
||||||
apiInterface.registerAltarComponent(Blocks.SEA_LANTERN.getDefaultState(), ComponentType.GLOWSTONE.name());
|
|
||||||
apiInterface.registerAltarComponent(Blocks.BEACON.getDefaultState(), ComponentType.BEACON.name());
|
|
||||||
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.BLANK_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.SPEED_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.SACRIFICE_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.SELF_SACRIFICE_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.DISPLACEMENT_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.CAPACITY_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.AUGMENTED_CAPACITY_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.ORB_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.ACCELERATION_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
apiInterface.registerAltarComponent(BloodMagicBlocks.CHARGING_RUNE.get().getDefaultState(), ComponentType.BLOODRUNE.name());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,484 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.impl;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import wayoftime.bloodmagic.api.IBloodMagicRecipeRegistrar;
|
|
||||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
|
|
||||||
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.BloodMagicRecipeType;
|
|
||||||
|
|
||||||
public class BloodMagicRecipeRegistrar implements IBloodMagicRecipeRegistrar
|
|
||||||
{
|
|
||||||
|
|
||||||
// private final Set<RecipeBloodAltar> altarRecipes;
|
|
||||||
// private final Set<RecipeAlchemyTable> alchemyRecipes;
|
|
||||||
// private final Set<RecipeTartaricForge> tartaricForgeRecipes;
|
|
||||||
// private final Set<RecipeAlchemyArray> alchemyArrayRecipes;
|
|
||||||
// private final Set<RecipeSacrificeCraft> sacrificeCraftRecipes;
|
|
||||||
|
|
||||||
public BloodMagicRecipeRegistrar()
|
|
||||||
{
|
|
||||||
// this.altarRecipes = Sets.newHashSet();
|
|
||||||
// this.alchemyRecipes = Sets.newHashSet();
|
|
||||||
// this.tartaricForgeRecipes = Sets.newHashSet();
|
|
||||||
// this.alchemyArrayRecipes = Sets.newHashSet();
|
|
||||||
// this.sacrificeCraftRecipes = Sets.newHashSet();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void addBloodAltar(@Nonnull Ingredient input, @Nonnull ItemStack output, @Nonnegative int minimumTier,
|
|
||||||
// @Nonnegative int syphon, @Nonnegative int consumeRate, @Nonnegative int drainRate)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
// Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
// Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
|
|
||||||
// Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
|
|
||||||
// Preconditions.checkArgument(consumeRate >= 0, "consumeRate cannot be negative.");
|
|
||||||
// Preconditions.checkArgument(drainRate >= 0, "drainRate cannot be negative.");
|
|
||||||
//
|
|
||||||
// // TODO: Got to adda ResourceLocation argument.
|
|
||||||
// altarRecipes.add(new IRecipeBloodAltar(null, input, output, minimumTier, syphon, consumeRate, drainRate));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean removeBloodAltar(@Nonnull ItemStack input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// return altarRecipes.remove(getBloodAltar(input));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks,
|
|
||||||
// @Nonnegative int minimumTier, @Nonnull Ingredient... input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
// Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
|
|
||||||
// Preconditions.checkArgument(ticks >= 0, "ticks cannot be negative.");
|
|
||||||
// Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
|
|
||||||
// alchemyRecipes.add(new RecipeAlchemyTable(inputs, output, syphon, ticks, minimumTier));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void addAlchemyTable(@Nonnull ItemStack output, @Nonnegative int syphon, @Nonnegative int ticks,
|
|
||||||
// @Nonnegative int minimumTier, @Nonnull Object... input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
// Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
|
|
||||||
// Preconditions.checkArgument(ticks >= 0, "ticks cannot be negative.");
|
|
||||||
// Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// List<Ingredient> ingredients = Lists.newArrayList();
|
|
||||||
// for (Object object : input)
|
|
||||||
// {
|
|
||||||
// if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb)
|
|
||||||
// {
|
|
||||||
// ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ingredients.add(CraftingHelper.getIngredient(object));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// addAlchemyTable(output, syphon, ticks, minimumTier, ingredients.toArray(new Ingredient[0]));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void addAlchemyTable(RecipeAlchemyTable recipe)
|
|
||||||
// {
|
|
||||||
// alchemyRecipes.add(recipe);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean removeAlchemyTable(@Nonnull ItemStack... input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "inputs cannot be null.");
|
|
||||||
//
|
|
||||||
// for (ItemStack stack : input) Preconditions.checkNotNull(stack, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// return alchemyRecipes.remove(getAlchemyTable(Lists.newArrayList(input)));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void addTartaricForge(@Nonnull ItemStack output, @Nonnegative double minimumSouls,
|
|
||||||
// @Nonnegative double soulDrain, @Nonnull Ingredient... input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
// Preconditions.checkArgument(minimumSouls >= 0, "minimumSouls cannot be negative.");
|
|
||||||
// Preconditions.checkArgument(soulDrain >= 0, "soulDrain cannot be negative.");
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
|
|
||||||
// tartaricForgeRecipes.add(new RecipeTartaricForge(inputs, output, minimumSouls, soulDrain));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean removeTartaricForge(@Nonnull ItemStack... input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "inputs cannot be null.");
|
|
||||||
//
|
|
||||||
// for (ItemStack stack : input) Preconditions.checkNotNull(stack, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// return tartaricForgeRecipes.remove(getTartaricForge(Lists.newArrayList(input)));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void addTartaricForge(@Nonnull ItemStack output, @Nonnegative double minimumSouls,
|
|
||||||
// @Nonnegative double soulDrain, @Nonnull Object... input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
// Preconditions.checkArgument(minimumSouls >= 0, "minimumSouls cannot be negative.");
|
|
||||||
// Preconditions.checkArgument(soulDrain >= 0, "soulDrain cannot be negative.");
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// List<Ingredient> ingredients = Lists.newArrayList();
|
|
||||||
// for (Object object : input)
|
|
||||||
// {
|
|
||||||
// if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb)
|
|
||||||
// {
|
|
||||||
// ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ingredients.add(CraftingHelper.getIngredient(object));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// addTartaricForge(output, minimumSouls, soulDrain, ingredients.toArray(new Ingredient[0]));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void addAlchemyArray(@Nonnull Ingredient input, @Nonnull Ingredient catalyst, @Nonnull ItemStack output,
|
|
||||||
// @Nullable ResourceLocation circleTexture)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
// Preconditions.checkNotNull(catalyst, "catalyst cannot be null.");
|
|
||||||
// Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
//
|
|
||||||
// alchemyArrayRecipes.add(new RecipeAlchemyArray(input, catalyst, output, circleTexture));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean removeAlchemyArray(@Nonnull ItemStack input, @Nonnull ItemStack catalyst)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
// Preconditions.checkNotNull(catalyst, "catalyst cannot be null.");
|
|
||||||
//
|
|
||||||
// return alchemyArrayRecipes.remove(getAlchemyArray(input, catalyst));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void addAlchemyArray(@Nonnull ItemStack input, @Nonnull ItemStack catalyst, @Nonnull ItemStack output,
|
|
||||||
// @Nullable ResourceLocation circleTexture)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
// Preconditions.checkNotNull(catalyst, "catalyst cannot be null.");
|
|
||||||
// Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
//
|
|
||||||
// addAlchemyArray(Ingredient.fromStacks(input), Ingredient.fromStacks(catalyst), output, circleTexture);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void addSacrificeCraft(@Nonnull ItemStack output, @Nonnegative double healthRequired,
|
|
||||||
// @Nonnull Object... input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
// Preconditions.checkArgument(healthRequired >= 0, "healthRequired cannot be negative.");
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// List<Ingredient> ingredients = Lists.newArrayList();
|
|
||||||
// for (Object object : input)
|
|
||||||
// {
|
|
||||||
// if (object instanceof ItemStack && ((ItemStack) object).getItem() instanceof IBloodOrb)
|
|
||||||
// {
|
|
||||||
// ingredients.add(new IngredientBloodOrb(((IBloodOrb) ((ItemStack) object).getItem()).getOrb((ItemStack) object)));
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ingredients.add(CraftingHelper.getIngredient(object));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// addSacrificeCraft(output, healthRequired, ingredients.toArray(new Ingredient[0]));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean removeSacrificeCraft(@Nonnull ItemStack... input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "inputs cannot be null.");
|
|
||||||
//
|
|
||||||
// for (ItemStack stack : input) Preconditions.checkNotNull(stack, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// return sacrificeCraftRecipes.remove(getSacrificeCraft(Lists.newArrayList(input)));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void addSacrificeCraft(@Nonnull ItemStack output, @Nonnegative double healthRequired,
|
|
||||||
// @Nonnull Ingredient... input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
// Preconditions.checkArgument(healthRequired >= 0, "healthRequired cannot be negative.");
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
//
|
|
||||||
// NonNullList<Ingredient> inputs = NonNullList.from(Ingredient.EMPTY, input);
|
|
||||||
// sacrificeCraftRecipes.add(new RecipeSacrificeCraft(inputs, output, healthRequired));
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public RecipeBloodAltar getBloodAltar(World world, @Nonnull ItemStack input)
|
|
||||||
{
|
|
||||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
if (input.isEmpty())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
List<RecipeBloodAltar> altarRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALTAR);
|
|
||||||
|
|
||||||
for (RecipeBloodAltar recipe : altarRecipes) if (recipe.getInput().test(input))
|
|
||||||
return recipe;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RecipeARC getARC(World world, @Nonnull ItemStack input, @Nonnull ItemStack arcToolInput, @Nonnull FluidStack inputFluid)
|
|
||||||
{
|
|
||||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
Preconditions.checkNotNull(arcToolInput, "tool cannot be null.");
|
|
||||||
if (input.isEmpty() || arcToolInput.isEmpty())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
List<RecipeARC> arcRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARC);
|
|
||||||
|
|
||||||
for (RecipeARC recipe : arcRecipes)
|
|
||||||
{
|
|
||||||
if (recipe.getInput().test(input) && recipe.getTool().test(arcToolInput))
|
|
||||||
{
|
|
||||||
if (recipe.getFluidIngredient() == null)
|
|
||||||
{
|
|
||||||
return recipe;
|
|
||||||
} else if (recipe.getFluidIngredient().test(inputFluid))
|
|
||||||
{
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if (input.isEmpty())
|
|
||||||
// return null;
|
|
||||||
//
|
|
||||||
// List<RecipeBloodAltar> altarRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALTAR);
|
|
||||||
//
|
|
||||||
// for (RecipeBloodAltar recipe : altarRecipes) if (recipe.getInput().test(input))
|
|
||||||
// return recipe;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Nullable
|
|
||||||
// public RecipeAlchemyTable getAlchemyTable(@Nonnull List<ItemStack> input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
// if (input.isEmpty())
|
|
||||||
// return null;
|
|
||||||
//
|
|
||||||
// mainLoop: for (RecipeAlchemyTable recipe : alchemyRecipes)
|
|
||||||
// {
|
|
||||||
// if (recipe.getInput().size() != input.size())
|
|
||||||
// continue;
|
|
||||||
//
|
|
||||||
// List<Ingredient> recipeInput = new ArrayList<>(recipe.getInput());
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < input.size(); i++)
|
|
||||||
// {
|
|
||||||
// boolean matched = false;
|
|
||||||
// for (int j = 0; j < recipeInput.size(); j++)
|
|
||||||
// {
|
|
||||||
// Ingredient ingredient = recipeInput.get(j);
|
|
||||||
// if (ingredient.apply(input.get(i)))
|
|
||||||
// {
|
|
||||||
// matched = true;
|
|
||||||
// recipeInput.remove(j);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!matched)
|
|
||||||
// continue mainLoop;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return recipe;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
@Nullable
|
|
||||||
public RecipeTartaricForge getTartaricForge(World world, @Nonnull List<ItemStack> input)
|
|
||||||
{
|
|
||||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
if (input.isEmpty())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
List<RecipeTartaricForge> tartaricForgeRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.TARTARICFORGE);
|
|
||||||
mainLoop: for (RecipeTartaricForge recipe : tartaricForgeRecipes)
|
|
||||||
{
|
|
||||||
if (recipe.getInput().size() != input.size())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
List<Ingredient> recipeInput = new ArrayList<>(recipe.getInput());
|
|
||||||
|
|
||||||
for (int i = 0; i < input.size(); i++)
|
|
||||||
{
|
|
||||||
boolean matched = false;
|
|
||||||
for (int j = 0; j < recipeInput.size(); j++)
|
|
||||||
{
|
|
||||||
Ingredient ingredient = recipeInput.get(j);
|
|
||||||
if (ingredient.test(input.get(i)))
|
|
||||||
{
|
|
||||||
matched = true;
|
|
||||||
recipeInput.remove(j);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!matched)
|
|
||||||
continue mainLoop;
|
|
||||||
}
|
|
||||||
|
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// @Nullable
|
|
||||||
// public RecipeSacrificeCraft getSacrificeCraft(@Nonnull List<ItemStack> input)
|
|
||||||
// {
|
|
||||||
// Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
// if (input.isEmpty())
|
|
||||||
// return null;
|
|
||||||
//
|
|
||||||
// mainLoop: for (RecipeSacrificeCraft recipe : sacrificeCraftRecipes)
|
|
||||||
// {
|
|
||||||
// if (recipe.getInput().size() != input.size())
|
|
||||||
// continue;
|
|
||||||
//
|
|
||||||
// List<Ingredient> recipeInput = new ArrayList<>(recipe.getInput());
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < input.size(); i++)
|
|
||||||
// {
|
|
||||||
// boolean matched = false;
|
|
||||||
// for (int j = 0; j < recipeInput.size(); j++)
|
|
||||||
// {
|
|
||||||
// Ingredient ingredient = recipeInput.get(j);
|
|
||||||
// if (ingredient.apply(input.get(i)))
|
|
||||||
// {
|
|
||||||
// matched = true;
|
|
||||||
// recipeInput.remove(j);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!matched)
|
|
||||||
// continue mainLoop;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return recipe;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param world
|
|
||||||
* @param input
|
|
||||||
* @param catalyst
|
|
||||||
* @return If false and the recipe is nonnull, it is a partial match. If true,
|
|
||||||
* the returned recipe is a full match.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public Pair<Boolean, RecipeAlchemyArray> getAlchemyArray(World world, @Nonnull ItemStack input, @Nonnull ItemStack catalyst)
|
|
||||||
{
|
|
||||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
if (input.isEmpty())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
List<RecipeAlchemyArray> altarRecipes = world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARRAY);
|
|
||||||
|
|
||||||
RecipeAlchemyArray partialMatch = null;
|
|
||||||
for (RecipeAlchemyArray recipe : altarRecipes)
|
|
||||||
{
|
|
||||||
if (recipe.getBaseInput().test(input))
|
|
||||||
{
|
|
||||||
if (recipe.getAddedInput().test(catalyst))
|
|
||||||
{
|
|
||||||
return Pair.of(true, recipe);
|
|
||||||
} else if (partialMatch == null)
|
|
||||||
{
|
|
||||||
partialMatch = recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Pair.of(false, partialMatch);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<RecipeBloodAltar> getAltarRecipes(World world)
|
|
||||||
{
|
|
||||||
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ALTAR));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<RecipeTartaricForge> getTartaricForgeRecipes(World world)
|
|
||||||
{
|
|
||||||
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.TARTARICFORGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<RecipeAlchemyArray> getAlchemyArrayRecipes(World world)
|
|
||||||
{
|
|
||||||
return ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARRAY));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<RecipeAlchemyArray> getCraftingAlchemyArrayRecipes(World world)
|
|
||||||
{
|
|
||||||
Set<RecipeAlchemyArray> recipes = Set.copyOf(world.getRecipeManager().getRecipesForType(BloodMagicRecipeType.ARRAY));
|
|
||||||
Set<RecipeAlchemyArray> copyRecipes = Set.of();
|
|
||||||
for (RecipeAlchemyArray recipe : recipes)
|
|
||||||
{
|
|
||||||
if (!recipe.getOutput().isEmpty())
|
|
||||||
{
|
|
||||||
copyRecipes.add(recipe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return copyRecipes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public Set<RecipeAlchemyTable> getAlchemyRecipes()
|
|
||||||
// {
|
|
||||||
// return ImmutableSet.copyOf(alchemyRecipes);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Set<RecipeTartaricForge> getTartaricForgeRecipes()
|
|
||||||
// {
|
|
||||||
// return ImmutableSet.copyOf(tartaricForgeRecipes);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public Set<RecipeAlchemyArray> getAlchemyArrayRecipes()
|
|
||||||
// {
|
|
||||||
// return ImmutableSet.copyOf(alchemyArrayRecipes);
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,87 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.impl.recipe;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public abstract class RecipeAlchemyArray extends BloodMagicRecipe
|
|
||||||
{
|
|
||||||
private final ResourceLocation id;
|
|
||||||
private final ResourceLocation texture;
|
|
||||||
@Nonnull
|
|
||||||
private final Ingredient baseInput;
|
|
||||||
@Nonnull
|
|
||||||
private final Ingredient addedInput;
|
|
||||||
@Nonnull
|
|
||||||
private final ItemStack output;
|
|
||||||
|
|
||||||
protected RecipeAlchemyArray(ResourceLocation id, ResourceLocation texture, @Nonnull Ingredient baseIngredient, @Nonnull Ingredient addedIngredient, @Nonnull ItemStack result)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
this.id = id;
|
|
||||||
this.texture = texture;
|
|
||||||
this.baseInput = baseIngredient;
|
|
||||||
this.addedInput = addedIngredient;
|
|
||||||
this.output = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final ResourceLocation getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final ResourceLocation getTexture()
|
|
||||||
{
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final Ingredient getBaseInput()
|
|
||||||
{
|
|
||||||
return baseInput;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final Ingredient getAddedInput()
|
|
||||||
{
|
|
||||||
return addedInput;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final NonNullList<Ingredient> getIngredients()
|
|
||||||
{
|
|
||||||
NonNullList<Ingredient> list = NonNullList.create();
|
|
||||||
list.add(getBaseInput());
|
|
||||||
list.add(getAddedInput());
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final ItemStack getOutput()
|
|
||||||
{
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
if (texture != null)
|
|
||||||
{
|
|
||||||
buffer.writeBoolean(true);
|
|
||||||
buffer.writeResourceLocation(texture);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
buffer.writeBoolean(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
baseInput.write(buffer);
|
|
||||||
addedInput.write(buffer);
|
|
||||||
buffer.writeItemStack(output);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,103 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.impl.recipe;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnegative;
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import wayoftime.bloodmagic.altar.AltarTier;
|
|
||||||
|
|
||||||
public abstract class RecipeBloodAltar extends BloodMagicRecipe
|
|
||||||
{
|
|
||||||
@Nonnull
|
|
||||||
private final Ingredient input;
|
|
||||||
@Nonnull
|
|
||||||
private final ItemStack output;
|
|
||||||
@Nonnull
|
|
||||||
private final AltarTier minimumTier;
|
|
||||||
@Nonnegative
|
|
||||||
private final int syphon;
|
|
||||||
@Nonnegative
|
|
||||||
private final int consumeRate;
|
|
||||||
@Nonnegative
|
|
||||||
private final int drainRate;
|
|
||||||
|
|
||||||
public RecipeBloodAltar(ResourceLocation id, @Nonnull Ingredient input, @Nonnull ItemStack output, @Nonnegative int minimumTier, @Nonnegative int syphon, @Nonnegative int consumeRate, @Nonnegative int drainRate)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
Preconditions.checkArgument(minimumTier >= 0, "minimumTier cannot be negative.");
|
|
||||||
Preconditions.checkArgument(minimumTier <= AltarTier.MAXTIERS, "minimumTier cannot be higher than max tier");
|
|
||||||
Preconditions.checkArgument(syphon >= 0, "syphon cannot be negative.");
|
|
||||||
Preconditions.checkArgument(consumeRate >= 0, "consumeRate cannot be negative.");
|
|
||||||
Preconditions.checkArgument(drainRate >= 0, "drain cannot be negative.");
|
|
||||||
|
|
||||||
this.input = input;
|
|
||||||
this.output = output;
|
|
||||||
this.minimumTier = AltarTier.values()[minimumTier];
|
|
||||||
this.syphon = syphon;
|
|
||||||
this.consumeRate = consumeRate;
|
|
||||||
this.drainRate = drainRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final Ingredient getInput()
|
|
||||||
{
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final NonNullList<Ingredient> getIngredients()
|
|
||||||
{
|
|
||||||
NonNullList<Ingredient> list = NonNullList.create();
|
|
||||||
list.add(getInput());
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final ItemStack getOutput()
|
|
||||||
{
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public AltarTier getMinimumTier()
|
|
||||||
{
|
|
||||||
return minimumTier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnegative
|
|
||||||
public final int getSyphon()
|
|
||||||
{
|
|
||||||
return syphon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnegative
|
|
||||||
public final int getConsumeRate()
|
|
||||||
{
|
|
||||||
return consumeRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnegative
|
|
||||||
public final int getDrainRate()
|
|
||||||
{
|
|
||||||
return drainRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
input.write(buffer);
|
|
||||||
buffer.writeItemStack(output);
|
|
||||||
buffer.writeInt(minimumTier.ordinal());
|
|
||||||
buffer.writeInt(syphon);
|
|
||||||
buffer.writeInt(consumeRate);
|
|
||||||
buffer.writeInt(drainRate);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.impl.recipe;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnegative;
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
public abstract class RecipeTartaricForge extends BloodMagicRecipe
|
|
||||||
{
|
|
||||||
@Nonnull
|
|
||||||
private final List<Ingredient> input;
|
|
||||||
@Nonnull
|
|
||||||
private final ItemStack output;
|
|
||||||
@Nonnegative
|
|
||||||
private final double minimumSouls;
|
|
||||||
@Nonnegative
|
|
||||||
private final double soulDrain;
|
|
||||||
|
|
||||||
public RecipeTartaricForge(ResourceLocation id, @Nonnull List<Ingredient> input, @Nonnull ItemStack output, @Nonnegative double minimumSouls, @Nonnegative double soulDrain)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
|
||||||
Preconditions.checkNotNull(output, "output cannot be null.");
|
|
||||||
Preconditions.checkArgument(minimumSouls >= 0, "minimumSouls cannot be negative.");
|
|
||||||
Preconditions.checkArgument(soulDrain >= 0, "soulDrain cannot be negative.");
|
|
||||||
|
|
||||||
this.input = input;
|
|
||||||
this.output = output;
|
|
||||||
this.minimumSouls = minimumSouls;
|
|
||||||
this.soulDrain = soulDrain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final List<Ingredient> getInput()
|
|
||||||
{
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final ItemStack getOutput()
|
|
||||||
{
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnegative
|
|
||||||
public final double getMinimumSouls()
|
|
||||||
{
|
|
||||||
return minimumSouls;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnegative
|
|
||||||
public final double getSoulDrain()
|
|
||||||
{
|
|
||||||
return soulDrain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
buffer.writeInt(input.size());
|
|
||||||
for (int i = 0; i < input.size(); i++)
|
|
||||||
{
|
|
||||||
input.get(i).write(buffer);
|
|
||||||
}
|
|
||||||
buffer.writeItemStack(output);
|
|
||||||
buffer.writeDouble(minimumSouls);
|
|
||||||
buffer.writeDouble(soulDrain);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package wayoftime.bloodmagic.block.enums;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import net.minecraft.util.IStringSerializable;
|
|
||||||
|
|
||||||
public enum BloodRuneType implements IStringSerializable
|
|
||||||
{
|
|
||||||
BLANK, SPEED, EFFICIENCY, SACRIFICE, SELF_SACRIFICE, DISPLACEMENT, CAPACITY, AUGMENTED_CAPACITY, ORB, ACCELERATION,
|
|
||||||
CHARGING;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name().toLowerCase(Locale.ENGLISH);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getName()
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getString()
|
|
||||||
{
|
|
||||||
return this.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package wayoftime.bloodmagic.client.render.block;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import wayoftime.bloodmagic.client.render.alchemyarray.AlchemyArrayRenderer;
|
|
||||||
import wayoftime.bloodmagic.core.registry.AlchemyArrayRendererRegistry;
|
|
||||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
|
||||||
|
|
||||||
public class RenderAlchemyArray extends TileEntityRenderer<TileAlchemyArray>
|
|
||||||
{
|
|
||||||
public static final AlchemyArrayRenderer arrayRenderer = new AlchemyArrayRenderer();
|
|
||||||
|
|
||||||
public RenderAlchemyArray(TileEntityRendererDispatcher rendererDispatcherIn)
|
|
||||||
{
|
|
||||||
super(rendererDispatcherIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(TileAlchemyArray tileArray, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn)
|
|
||||||
{
|
|
||||||
ItemStack inputStack = tileArray.getStackInSlot(0);
|
|
||||||
ItemStack catalystStack = tileArray.getStackInSlot(1);
|
|
||||||
// arrayRenderer.renderAt(tileArray, 0, 0, 0, tileArray.activeCounter
|
|
||||||
// + partialTicks, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
|
||||||
|
|
||||||
AlchemyArrayRenderer renderer = AlchemyArrayRendererRegistry.getRenderer(tileArray.getWorld(), inputStack, catalystStack);
|
|
||||||
if (renderer == null)
|
|
||||||
{
|
|
||||||
renderer = AlchemyArrayRendererRegistry.DEFAULT_RENDERER;
|
|
||||||
}
|
|
||||||
|
|
||||||
renderer.renderAt(tileArray, 0, 0, 0, tileArray.activeCounter
|
|
||||||
+ partialTicks, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
|
||||||
// arrayRenderer.renderAt(tileArray, 0, 0, 0, 0, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
|
||||||
|
|
||||||
// if (tileAltar.getCurrentTierDisplayed() != AltarTier.ONE)
|
|
||||||
// renderHologram(tileAltar, tileAltar.getCurrentTierDisplayed(), partialTicks);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,279 +0,0 @@
|
||||||
package wayoftime.bloodmagic.client.render.block;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.Atlases;
|
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|
||||||
import net.minecraft.client.renderer.ItemRenderer;
|
|
||||||
import net.minecraft.client.renderer.RenderHelper;
|
|
||||||
import net.minecraft.client.renderer.model.IBakedModel;
|
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.fluid.Fluid;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.vector.Vector3f;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer;
|
|
||||||
import wayoftime.bloodmagic.client.render.BloodMagicRenderer.Model3D;
|
|
||||||
import wayoftime.bloodmagic.client.render.RenderResizableCuboid;
|
|
||||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
|
||||||
import wayoftime.bloodmagic.tile.TileAltar;
|
|
||||||
|
|
||||||
public class RenderAltar extends TileEntityRenderer<TileAltar>
|
|
||||||
{
|
|
||||||
public RenderAltar(TileEntityRendererDispatcher rendererDispatcherIn)
|
|
||||||
{
|
|
||||||
super(rendererDispatcherIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final float MIN_HEIGHT = 0.499f;
|
|
||||||
private static final float MAX_HEIGHT = 0.745f;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(TileAltar tileAltar, float partialTicks, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn)
|
|
||||||
{
|
|
||||||
ItemStack inputStack = tileAltar.getStackInSlot(0);
|
|
||||||
|
|
||||||
float level = ((float) tileAltar.getCurrentBlood()) / (float) tileAltar.getCapacity();
|
|
||||||
|
|
||||||
this.renderItem(inputStack, tileAltar, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
|
||||||
|
|
||||||
renderFluid(level, matrixStack, buffer, combinedLightIn, combinedOverlayIn);
|
|
||||||
|
|
||||||
// if (tileAltar.getCurrentTierDisplayed() != AltarTier.ONE)
|
|
||||||
// renderHologram(tileAltar, tileAltar.getCurrentTierDisplayed(), partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderFluid(float fluidLevel, MatrixStack matrixStack, IRenderTypeBuffer renderer, int combinedLightIn, int combinedOverlayIn)
|
|
||||||
{
|
|
||||||
Fluid fluid = BloodMagicBlocks.LIFE_ESSENCE_FLUID.get();
|
|
||||||
FluidStack fluidStack = new FluidStack(fluid, 1000);
|
|
||||||
|
|
||||||
FluidRenderData data = new FluidRenderData(fluidStack);
|
|
||||||
matrixStack.push();
|
|
||||||
|
|
||||||
Model3D model = getFluidModel(fluidLevel, data);
|
|
||||||
IVertexBuilder buffer = renderer.getBuffer(Atlases.getTranslucentCullBlockType());
|
|
||||||
|
|
||||||
// matrixStack.translate(data.loca, y, z);
|
|
||||||
// int glow = data.calculateGlowLight(0);
|
|
||||||
RenderResizableCuboid.INSTANCE.renderCube(model, matrixStack, buffer, data.getColorARGB(1), combinedLightIn, combinedOverlayIn);
|
|
||||||
|
|
||||||
matrixStack.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
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) * Math.pow((craftTime - 5) / 35f, 3));
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
return -0.4f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderItem(ItemStack stack, TileAltar tileAltar, MatrixStack matrixStack, IRenderTypeBuffer buffer, int combinedLightIn, int combinedOverlayIn)
|
|
||||||
{
|
|
||||||
matrixStack.push();
|
|
||||||
Minecraft mc = Minecraft.getInstance();
|
|
||||||
ItemRenderer itemRenderer = mc.getItemRenderer();
|
|
||||||
if (!stack.isEmpty())
|
|
||||||
{
|
|
||||||
matrixStack.translate(0.5, 1, 0.5);
|
|
||||||
matrixStack.push();
|
|
||||||
|
|
||||||
float rotation = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
|
|
||||||
|
|
||||||
matrixStack.rotate(Vector3f.YP.rotationDegrees(rotation));
|
|
||||||
matrixStack.scale(0.5F, 0.5F, 0.5F);
|
|
||||||
RenderHelper.enableStandardItemLighting();
|
|
||||||
IBakedModel ibakedmodel = itemRenderer.getItemModelWithOverrides(stack, tileAltar.getWorld(), (LivingEntity) null);
|
|
||||||
itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.FIXED, true, matrixStack, buffer, combinedLightIn, combinedOverlayIn, ibakedmodel); // renderItem
|
|
||||||
RenderHelper.disableStandardItemLighting();
|
|
||||||
|
|
||||||
matrixStack.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
matrixStack.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Model3D getFluidModel(float fluidLevel, FluidRenderData data)
|
|
||||||
{
|
|
||||||
Model3D model = new BloodMagicRenderer.Model3D();
|
|
||||||
model.setTexture(data.getTexture());
|
|
||||||
model.minX = 0.1;
|
|
||||||
model.minY = MIN_HEIGHT;
|
|
||||||
model.minZ = 0.1;
|
|
||||||
model.maxX = 0.9;
|
|
||||||
model.maxY = (MAX_HEIGHT - MIN_HEIGHT) * fluidLevel + MIN_HEIGHT;
|
|
||||||
model.maxZ = 0.9;
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FluidRenderData
|
|
||||||
{
|
|
||||||
public BlockPos location;
|
|
||||||
|
|
||||||
public int height;
|
|
||||||
public int length;
|
|
||||||
public int width;
|
|
||||||
|
|
||||||
public final FluidStack fluidType;
|
|
||||||
|
|
||||||
public FluidRenderData(FluidStack fluidType)
|
|
||||||
{
|
|
||||||
this.fluidType = fluidType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextureAtlasSprite getTexture()
|
|
||||||
{
|
|
||||||
return Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidType.getFluid().getAttributes().getStillTexture());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGaseous()
|
|
||||||
{
|
|
||||||
return fluidType.getFluid().getAttributes().isGaseous(fluidType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getColorARGB(float scale)
|
|
||||||
{
|
|
||||||
return fluidType.getFluid().getAttributes().getColor(fluidType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int calculateGlowLight(int light)
|
|
||||||
{
|
|
||||||
return light;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
int code = super.hashCode();
|
|
||||||
code = 31 * code + fluidType.getFluid().getRegistryName().hashCode();
|
|
||||||
if (fluidType.hasTag())
|
|
||||||
{
|
|
||||||
code = 31 * code + fluidType.getTag().hashCode();
|
|
||||||
}
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object data)
|
|
||||||
{
|
|
||||||
return super.equals(data) && data instanceof FluidRenderData
|
|
||||||
&& fluidType.isFluidEqual(((FluidRenderData) data).fluidType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// private void renderHologram(TileAltar altar, AltarTier tier, float partialTicks)
|
|
||||||
// {
|
|
||||||
// EntityPlayerSP player = Minecraft.getMinecraft().player;
|
|
||||||
// World world = player.world;
|
|
||||||
//
|
|
||||||
// if (tier == AltarTier.ONE)
|
|
||||||
// return;
|
|
||||||
//
|
|
||||||
// GlStateManager.pushMatrix();
|
|
||||||
// GlStateManager.enableBlend();
|
|
||||||
// GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
// GlStateManager.color(1F, 1F, 1F, 0.6125F);
|
|
||||||
//
|
|
||||||
// BlockPos vec3, vX;
|
|
||||||
// vec3 = altar.getPos();
|
|
||||||
// double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
|
|
||||||
// double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
|
|
||||||
// double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
|
|
||||||
//
|
|
||||||
// for (AltarComponent altarComponent : tier.getAltarComponents())
|
|
||||||
// {
|
|
||||||
// vX = vec3.add(altarComponent.getOffset());
|
|
||||||
// double minX = vX.getX() - posX;
|
|
||||||
// double minY = vX.getY() - posY;
|
|
||||||
// double minZ = vX.getZ() - posZ;
|
|
||||||
//
|
|
||||||
// if (!world.getBlockState(vX).isOpaqueCube())
|
|
||||||
// {
|
|
||||||
// TextureAtlasSprite texture = null;
|
|
||||||
//
|
|
||||||
// switch (altarComponent.getComponent())
|
|
||||||
// {
|
|
||||||
// case BLOODRUNE:
|
|
||||||
// texture = ClientHandler.blankBloodRune;
|
|
||||||
// break;
|
|
||||||
// case NOTAIR:
|
|
||||||
// texture = ClientHandler.stoneBrick;
|
|
||||||
// break;
|
|
||||||
// case GLOWSTONE:
|
|
||||||
// texture = ClientHandler.glowstone;
|
|
||||||
// break;
|
|
||||||
// case BLOODSTONE:
|
|
||||||
// texture = ClientHandler.bloodStoneBrick;
|
|
||||||
// break;
|
|
||||||
// case BEACON:
|
|
||||||
// texture = ClientHandler.beacon;
|
|
||||||
// break;
|
|
||||||
// case CRYSTAL:
|
|
||||||
// texture = ClientHandler.crystalCluster;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// RenderFakeBlocks.drawFakeBlock(texture, minX, minY, minZ);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// GlStateManager.popMatrix();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static void setGLColorFromInt(int color)
|
|
||||||
// {
|
|
||||||
// float red = (color >> 16 & 0xFF) / 255.0F;
|
|
||||||
// float green = (color >> 8 & 0xFF) / 255.0F;
|
|
||||||
// float blue = (color & 0xFF) / 255.0F;
|
|
||||||
//
|
|
||||||
// GlStateManager.color(red, green, blue, 1.0F);
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,62 +0,0 @@
|
||||||
package wayoftime.bloodmagic.compat.jei;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import mezz.jei.api.IModPlugin;
|
|
||||||
import mezz.jei.api.JeiPlugin;
|
|
||||||
import mezz.jei.api.helpers.IJeiHelpers;
|
|
||||||
import mezz.jei.api.registration.IRecipeCatalystRegistration;
|
|
||||||
import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
|
||||||
import mezz.jei.api.registration.IRecipeRegistration;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
|
||||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
|
||||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
|
||||||
import wayoftime.bloodmagic.compat.jei.altar.BloodAltarRecipeCategory;
|
|
||||||
import wayoftime.bloodmagic.compat.jei.array.AlchemyArrayCraftingCategory;
|
|
||||||
import wayoftime.bloodmagic.compat.jei.forge.TartaricForgeRecipeCategory;
|
|
||||||
|
|
||||||
@JeiPlugin
|
|
||||||
public class BloodMagicJEIPlugin implements IModPlugin
|
|
||||||
{
|
|
||||||
public static IJeiHelpers jeiHelper;
|
|
||||||
|
|
||||||
private static final ResourceLocation ID = BloodMagic.rl("jei_plugin");
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration)
|
|
||||||
{
|
|
||||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.SOUL_FORGE.get()), TartaricForgeRecipeCategory.UID);
|
|
||||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()), BloodAltarRecipeCategory.UID);
|
|
||||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicItems.ARCANE_ASHES.get()), AlchemyArrayCraftingCategory.UID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerCategories(IRecipeCategoryRegistration registration)
|
|
||||||
{
|
|
||||||
jeiHelper = registration.getJeiHelpers();
|
|
||||||
registration.addRecipeCategories(new TartaricForgeRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
|
||||||
registration.addRecipeCategories(new BloodAltarRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
|
||||||
registration.addRecipeCategories(new AlchemyArrayCraftingCategory(registration.getJeiHelpers().getGuiHelper()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerRecipes(IRecipeRegistration registration)
|
|
||||||
{
|
|
||||||
ClientWorld world = Objects.requireNonNull(Minecraft.getInstance().world);
|
|
||||||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getTartaricForgeRecipes(world), TartaricForgeRecipeCategory.UID);
|
|
||||||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAltarRecipes(world), BloodAltarRecipeCategory.UID);
|
|
||||||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyArrayRecipes(world), AlchemyArrayCraftingCategory.UID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getPluginUid()
|
|
||||||
{
|
|
||||||
return ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,172 +0,0 @@
|
||||||
package wayoftime.bloodmagic.compat.jei.forge;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
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.item.crafting.Ingredient;
|
|
||||||
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.RecipeTartaricForge;
|
|
||||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
|
||||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
|
||||||
import wayoftime.bloodmagic.util.ChatUtil;
|
|
||||||
import wayoftime.bloodmagic.util.Constants;
|
|
||||||
import wayoftime.bloodmagic.util.helper.TextHelper;
|
|
||||||
|
|
||||||
public class TartaricForgeRecipeCategory implements IRecipeCategory<RecipeTartaricForge>
|
|
||||||
{
|
|
||||||
private static final int OUTPUT_SLOT = 0;
|
|
||||||
private static final int GEM_SLOT = 1;
|
|
||||||
private static final int INPUT_SLOT = 2;
|
|
||||||
public static final ResourceLocation UID = BloodMagic.rl(Constants.Compat.JEI_CATEGORY_SOULFORGE);
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final IDrawable background;
|
|
||||||
private final IDrawable icon;
|
|
||||||
// @Nonnull
|
|
||||||
// private final ICraftingGridHelper craftingGridHelper;
|
|
||||||
|
|
||||||
public TartaricForgeRecipeCategory(IGuiHelper guiHelper)
|
|
||||||
{
|
|
||||||
icon = guiHelper.createDrawableIngredient(new ItemStack(BloodMagicBlocks.SOUL_FORGE.get()));
|
|
||||||
background = guiHelper.createDrawable(BloodMagic.rl("gui/jei/soulforge.png"), 0, 0, 100, 40);
|
|
||||||
// craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public ResourceLocation getUid()
|
|
||||||
{
|
|
||||||
return UID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ITextComponent> getTooltipStrings(RecipeTartaricForge recipe, double mouseX, double mouseY)
|
|
||||||
{
|
|
||||||
List<ITextComponent> tooltip = Lists.newArrayList();
|
|
||||||
if (mouseX >= 40 && mouseX <= 60 && mouseY >= 21 && mouseY <= 34)
|
|
||||||
{
|
|
||||||
tooltip.add(new TranslationTextComponent("jei.bloodmagic.recipe.minimumsouls", ChatUtil.DECIMAL_FORMAT.format(recipe.getMinimumSouls())));
|
|
||||||
tooltip.add(new TranslationTextComponent("jei.bloodmagic.recipe.soulsdrained", ChatUtil.DECIMAL_FORMAT.format(recipe.getSoulDrain())));
|
|
||||||
}
|
|
||||||
return tooltip;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public String getTitle()
|
|
||||||
{
|
|
||||||
return TextHelper.localize("jei.bloodmagic.recipe.soulforge");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public IDrawable getBackground()
|
|
||||||
{
|
|
||||||
return background;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public IDrawable getIcon()
|
|
||||||
{
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeTartaricForge recipe, @Nonnull IIngredients ingredients)
|
|
||||||
{
|
|
||||||
List<ItemStack> validGems = Lists.newArrayList();
|
|
||||||
for (DefaultWill will : DefaultWill.values())
|
|
||||||
{
|
|
||||||
if (will.minSouls >= recipe.getMinimumSouls())
|
|
||||||
{
|
|
||||||
validGems.add(will.willStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
|
||||||
|
|
||||||
guiItemStacks.init(OUTPUT_SLOT, false, 73, 13);
|
|
||||||
|
|
||||||
guiItemStacks.init(GEM_SLOT, true, 42, 0);
|
|
||||||
|
|
||||||
for (int y = 0; y < 2; ++y)
|
|
||||||
{
|
|
||||||
for (int x = 0; x < 2; ++x)
|
|
||||||
{
|
|
||||||
int index = INPUT_SLOT + x + (y * 2);
|
|
||||||
guiItemStacks.init(index, true, x * 18, y * 18);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
guiItemStacks.set(GEM_SLOT, validGems);
|
|
||||||
guiItemStacks.set(OUTPUT_SLOT, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
|
|
||||||
guiItemStacks.set(ingredients);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<? extends RecipeTartaricForge> getRecipeClass()
|
|
||||||
{
|
|
||||||
return RecipeTartaricForge.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setIngredients(RecipeTartaricForge recipe, IIngredients ingredients)
|
|
||||||
{
|
|
||||||
List<ItemStack> validGems = Lists.newArrayList();
|
|
||||||
for (DefaultWill will : DefaultWill.values())
|
|
||||||
{
|
|
||||||
if (will.minSouls >= recipe.getMinimumSouls())
|
|
||||||
{
|
|
||||||
validGems.add(will.willStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack[] validGemStacks = new ItemStack[validGems.size()];
|
|
||||||
for (int i = 0; i < validGemStacks.length; i++)
|
|
||||||
{
|
|
||||||
validGemStacks[i] = validGems.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Ingredient> ingList = Lists.newArrayList();
|
|
||||||
ingList.add(Ingredient.fromStacks(validGemStacks));
|
|
||||||
ingList.addAll(recipe.getInput());
|
|
||||||
|
|
||||||
ingredients.setInputIngredients(ingList);
|
|
||||||
ingredients.setOutput(VanillaTypes.ITEM, recipe.getOutput());
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum DefaultWill
|
|
||||||
{
|
|
||||||
SOUL(new ItemStack(BloodMagicItems.MONSTER_SOUL_RAW.get()), 64),
|
|
||||||
PETTY(new ItemStack(BloodMagicItems.PETTY_GEM.get()), 64),
|
|
||||||
LESSER(new ItemStack(BloodMagicItems.LESSER_GEM.get()), 256),
|
|
||||||
COMMON(new ItemStack(BloodMagicItems.COMMON_GEM.get()), 1024);
|
|
||||||
// GREATER(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 3), 4096),
|
|
||||||
// GRAND(new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, 4), 16384);
|
|
||||||
|
|
||||||
public final ItemStack willStack;
|
|
||||||
public final double minSouls;
|
|
||||||
|
|
||||||
DefaultWill(ItemStack willStack, double minSouls)
|
|
||||||
{
|
|
||||||
this.willStack = willStack;
|
|
||||||
this.minSouls = minSouls;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package wayoftime.bloodmagic.core;
|
|
||||||
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID)
|
|
||||||
public class RegistrarBloodMagic
|
|
||||||
{
|
|
||||||
private RegistrarBloodMagic()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static final BloodOrbDeferredRegister BLOOD_ORBS = new BloodOrbDeferredRegister(BloodMagic.MODID);
|
|
||||||
//
|
|
||||||
// public static final BloodOrbRegistryObject<BloodOrb> ORB_WEAK = BLOOD_ORBS.register("weakbloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "weakbloodorb"), 0, 5000, 10));
|
|
||||||
|
|
||||||
// public static IForgeRegistry<BloodOrb> BLOOD_ORBS = new RegistryBuilder<BloodOrb>().setName(new ResourceLocation(BloodMagic.MODID, "blood_orb")).setIDRange(0, Short.MAX_VALUE).setType(BloodOrb.class).addCallback((IForgeRegistry.AddCallback<BloodOrb>) (
|
|
||||||
// owner, stage, id, obj,
|
|
||||||
// oldObj) -> OrbRegistry.tierMap.put(obj.getTier(), OrbRegistry.getOrbStack(obj))).create();
|
|
||||||
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void onRegistryCreation(RegistryEvent.NewRegistry event)
|
|
||||||
// {
|
|
||||||
// System.out.println("Testification3");
|
|
||||||
// BLOOD_ORBS = new RegistryBuilder<BloodOrb>().setName(new ResourceLocation(BloodMagic.MODID, "blood_orb")).setIDRange(0, Short.MAX_VALUE).setType(BloodOrb.class).addCallback((IForgeRegistry.AddCallback<BloodOrb>) (
|
|
||||||
// owner, stage, id, obj,
|
|
||||||
// oldObj) -> OrbRegistry.tierMap.put(obj.getTier(), OrbRegistry.getOrbStack(obj))).create();
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,71 +0,0 @@
|
||||||
package wayoftime.bloodmagic.core;
|
|
||||||
|
|
||||||
import wayoftime.bloodmagic.api.impl.BloodMagicRecipeRegistrar;
|
|
||||||
|
|
||||||
public class RegistrarBloodMagicRecipes
|
|
||||||
{
|
|
||||||
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
|
|
||||||
// for (int i = 0; i < ItemSoulGem.names.length; i++) {
|
|
||||||
// for (EnumDemonWillType willType : EnumDemonWillType.values()) {
|
|
||||||
// ItemStack baseGemStack = new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, i);
|
|
||||||
// ItemStack newGemStack = new ItemStack(RegistrarBloodMagicItems.SOUL_GEM, 1, i);
|
|
||||||
//
|
|
||||||
// ((ItemSoulGem) RegistrarBloodMagicItems.SOUL_GEM).setCurrentType(willType, newGemStack);
|
|
||||||
// ShapelessOreRecipe shapeless = new ShapelessOreRecipe(new ResourceLocation(BloodMagic.MODID, "soul_gem"), newGemStack, baseGemStack, willType.getStack());
|
|
||||||
// event.getRegistry().register(shapeless.setRegistryName("soul_gem_" + willType.getName()));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// OreDictionary.registerOre("dustIron", ComponentTypes.SAND_IRON.getStack());
|
|
||||||
// OreDictionary.registerOre("dustGold", ComponentTypes.SAND_GOLD.getStack());
|
|
||||||
// OreDictionary.registerOre("dustCoal", ComponentTypes.SAND_COAL.getStack());
|
|
||||||
//
|
|
||||||
// PluginUtil.handlePluginStep(PluginUtil.RegistrationStep.RECIPE_REGISTER);
|
|
||||||
//
|
|
||||||
// RegistrarBloodMagicItems.SOUL_TOOL_MATERIAL.setRepairItem(EnumDemonWillType.DEFAULT.getStack());
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static void registerAltarRecipes(BloodMagicRecipeRegistrar registrar)
|
|
||||||
{
|
|
||||||
// Ingredient d;
|
|
||||||
// ONE
|
|
||||||
// registrar.addBloodAltar(new OreIngredient("gemDiamond"), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_WEAK), AltarTier.ONE.ordinal(), 2000, 2, 1);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// // SIX
|
|
||||||
// if (ConfigHandler.general.enableTierSixEvenThoughThereIsNoContent)
|
|
||||||
// {
|
|
||||||
// registrar.addBloodAltar(Ingredient.fromStacks(new ItemStack(RegistrarBloodMagicBlocks.DECORATIVE_BRICK, 1, 2)), OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_TRANSCENDENT), AltarTier.SIX.ordinal(), 200000, 100, 200);
|
|
||||||
// registrar.addBloodAltar(new OreIngredient("glowstone"), EnumRuneType.DAWN.getStack(), AltarTier.SIX.ordinal(), 200000, 100, 200);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package wayoftime.bloodmagic.core.data;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.nbt.ListNBT;
|
|
||||||
import net.minecraft.world.storage.WorldSavedData;
|
|
||||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
|
||||||
|
|
||||||
public class BMWorldSavedData extends WorldSavedData
|
|
||||||
{
|
|
||||||
public static final String ID = "BloodMagic-SoulNetworks";
|
|
||||||
|
|
||||||
private Map<UUID, SoulNetwork> soulNetworks = new HashMap<>();
|
|
||||||
|
|
||||||
public BMWorldSavedData(String id)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BMWorldSavedData()
|
|
||||||
{
|
|
||||||
this(ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoulNetwork getNetwork(PlayerEntity player)
|
|
||||||
{
|
|
||||||
return getNetwork(PlayerHelper.getUUIDFromPlayer(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoulNetwork getNetwork(UUID playerId)
|
|
||||||
{
|
|
||||||
if (!soulNetworks.containsKey(playerId))
|
|
||||||
soulNetworks.put(playerId, SoulNetwork.newEmpty(playerId).setParent(this));
|
|
||||||
return soulNetworks.get(playerId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
ListNBT networkData = tagCompound.getList("networkData", 10);
|
|
||||||
|
|
||||||
for (int i = 0; i < networkData.size(); i++)
|
|
||||||
{
|
|
||||||
CompoundNBT data = networkData.getCompound(i);
|
|
||||||
SoulNetwork network = SoulNetwork.fromNBT(data);
|
|
||||||
network.setParent(this);
|
|
||||||
soulNetworks.put(network.getPlayerId(), network);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT write(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
ListNBT networkData = new ListNBT();
|
|
||||||
for (SoulNetwork soulNetwork : soulNetworks.values())
|
|
||||||
networkData.add(soulNetwork.serializeNBT());
|
|
||||||
|
|
||||||
tagCompound.put("networkData", networkData);
|
|
||||||
|
|
||||||
return tagCompound;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
package wayoftime.bloodmagic.core.data;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.nbt.INBT;
|
|
||||||
import net.minecraft.nbt.NBTUtil;
|
|
||||||
import net.minecraftforge.common.util.INBTSerializable;
|
|
||||||
|
|
||||||
public class Binding implements INBTSerializable<CompoundNBT>
|
|
||||||
{
|
|
||||||
private UUID uuid;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public Binding(UUID uuid, String name)
|
|
||||||
{
|
|
||||||
this.uuid = uuid;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Binding()
|
|
||||||
{
|
|
||||||
// No-op
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT serializeNBT()
|
|
||||||
{
|
|
||||||
CompoundNBT tag = new CompoundNBT();
|
|
||||||
// tag.put("id", NBTUtil.writeUniqueId(uuid));
|
|
||||||
tag.put("id", NBTUtil.func_240626_a_(uuid));
|
|
||||||
tag.putString("name", name);
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserializeNBT(CompoundNBT nbt)
|
|
||||||
{
|
|
||||||
this.uuid = NBTUtil.readUniqueId(nbt.get("id"));
|
|
||||||
this.name = nbt.getString("name");
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getOwnerId()
|
|
||||||
{
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Binding setOwnerId(UUID uuid)
|
|
||||||
{
|
|
||||||
this.uuid = uuid;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOwnerName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Binding setOwnerName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static Binding fromStack(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (!stack.hasTag()) // Definitely hasn't been bound yet.
|
|
||||||
return null;
|
|
||||||
|
|
||||||
INBT bindingTag = stack.getTag().get("binding");
|
|
||||||
if (bindingTag == null || bindingTag.getId() != 10) // Make sure it's both a tag compound and that it has actual
|
|
||||||
// data.
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Binding binding = new Binding();
|
|
||||||
binding.deserializeNBT((CompoundNBT) bindingTag);
|
|
||||||
return binding;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "Binding{" + "uuid=" + uuid + ", name='" + name + '\'' + '}';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,293 +0,0 @@
|
||||||
package wayoftime.bloodmagic.core.data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.common.collect.EvictingQueue;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.potion.EffectInstance;
|
|
||||||
import net.minecraft.potion.Effects;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.common.util.INBTSerializable;
|
|
||||||
import wayoftime.bloodmagic.event.SoulNetworkEvent;
|
|
||||||
import wayoftime.bloodmagic.util.BMLog;
|
|
||||||
import wayoftime.bloodmagic.util.BooleanResult;
|
|
||||||
import wayoftime.bloodmagic.util.DamageSourceBloodMagic;
|
|
||||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
|
||||||
|
|
||||||
public class SoulNetwork implements INBTSerializable<CompoundNBT>
|
|
||||||
{
|
|
||||||
|
|
||||||
private final Queue<SoulTicket> ticketHistory;
|
|
||||||
private BMWorldSavedData parent;
|
|
||||||
private PlayerEntity cachedPlayer;
|
|
||||||
private UUID playerId;
|
|
||||||
private int currentEssence;
|
|
||||||
private int orbTier;
|
|
||||||
|
|
||||||
private SoulNetwork()
|
|
||||||
{
|
|
||||||
// No-op - For creation via NBT only
|
|
||||||
ticketHistory = EvictingQueue.create(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
ticketHistory.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int add(SoulTicket ticket, int maximum)
|
|
||||||
{
|
|
||||||
SoulNetworkEvent.Fill event = new SoulNetworkEvent.Fill(this, ticket, maximum);
|
|
||||||
if (MinecraftForge.EVENT_BUS.post(event))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int currEss = getCurrentEssence();
|
|
||||||
|
|
||||||
if (currEss >= event.getMaximum())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int newEss = Math.min(event.getMaximum(), currEss + event.getTicket().getAmount());
|
|
||||||
setCurrentEssence(newEss);
|
|
||||||
|
|
||||||
if (ticketHistory.contains(ticket))
|
|
||||||
ticketHistory.remove(ticket); // "Pops" the existing ticket to the top of the queue
|
|
||||||
|
|
||||||
ticketHistory.add(ticket);
|
|
||||||
|
|
||||||
return newEss - currEss;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated For future proofing, use {@link #add(SoulTicket, int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public int add(int toAdd, int maximum)
|
|
||||||
{
|
|
||||||
return add(new SoulTicket(toAdd), maximum);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #add(SoulTicket, int)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public int addLifeEssence(int toAdd, int maximum)
|
|
||||||
{
|
|
||||||
return add(toAdd, maximum);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int syphon(SoulTicket ticket)
|
|
||||||
{
|
|
||||||
return syphon(ticket, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int syphon(SoulTicket ticket, boolean skipEvent)
|
|
||||||
{
|
|
||||||
SoulNetworkEvent.Syphon event = new SoulNetworkEvent.Syphon(this, ticket);
|
|
||||||
if (!skipEvent && MinecraftForge.EVENT_BUS.post(event))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int syphon = event.getTicket().getAmount();
|
|
||||||
if (getCurrentEssence() >= syphon)
|
|
||||||
{
|
|
||||||
setCurrentEssence(getCurrentEssence() - syphon);
|
|
||||||
if (ticketHistory.contains(ticket))
|
|
||||||
ticketHistory.remove(ticket);
|
|
||||||
|
|
||||||
ticketHistory.add(ticket);
|
|
||||||
return syphon;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated For future proofing, use {@link #syphon(SoulTicket)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public int syphon(int amount)
|
|
||||||
{
|
|
||||||
return syphon(new SoulTicket(amount));
|
|
||||||
}
|
|
||||||
|
|
||||||
public BooleanResult<Integer> syphonAndDamage(PlayerEntity user, SoulTicket ticket)
|
|
||||||
{
|
|
||||||
if (user.getEntityWorld().isRemote)
|
|
||||||
return BooleanResult.newResult(false, 0);
|
|
||||||
|
|
||||||
SoulNetworkEvent.Syphon.User event = new SoulNetworkEvent.Syphon.User(this, ticket, user);
|
|
||||||
|
|
||||||
if (MinecraftForge.EVENT_BUS.post(event))
|
|
||||||
return BooleanResult.newResult(false, 0);
|
|
||||||
|
|
||||||
int drainAmount = syphon(event.getTicket(), true);
|
|
||||||
|
|
||||||
if (drainAmount <= 0 || event.shouldDamage())
|
|
||||||
hurtPlayer(user, event.getTicket().getAmount());
|
|
||||||
|
|
||||||
if (ticketHistory.contains(ticket))
|
|
||||||
ticketHistory.remove(ticket);
|
|
||||||
|
|
||||||
ticketHistory.add(ticket);
|
|
||||||
|
|
||||||
return BooleanResult.newResult(true, event.getTicket().getAmount());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #syphonAndDamage(PlayerEntity, SoulTicket)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public boolean syphonAndDamage(PlayerEntity user, int amount)
|
|
||||||
{
|
|
||||||
return syphonAndDamage(user, new SoulTicket(amount)).isSuccess();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void causeNausea()
|
|
||||||
{
|
|
||||||
if (getPlayer() != null)
|
|
||||||
getPlayer().addPotionEffect(new EffectInstance(Effects.NAUSEA, 99));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated - Please use {@link #causeNausea()}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void causeNauseaToPlayer()
|
|
||||||
{
|
|
||||||
causeNausea();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void hurtPlayer(PlayerEntity user, float syphon)
|
|
||||||
{
|
|
||||||
if (user != null)
|
|
||||||
{
|
|
||||||
if (syphon < 100 && syphon > 0)
|
|
||||||
{
|
|
||||||
if (!user.isCreative())
|
|
||||||
{
|
|
||||||
user.hurtResistantTime = 0;
|
|
||||||
user.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 1.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (syphon >= 100)
|
|
||||||
{
|
|
||||||
if (!user.isCreative())
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ((syphon + 99) / 100); i++)
|
|
||||||
{
|
|
||||||
user.hurtResistantTime = 0;
|
|
||||||
user.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 1.0F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void markDirty()
|
|
||||||
{
|
|
||||||
if (getParent() != null)
|
|
||||||
getParent().markDirty();
|
|
||||||
else
|
|
||||||
BMLog.DEFAULT.error("A SoulNetwork was created, but a parent was not set to allow saving.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public PlayerEntity getPlayer()
|
|
||||||
{
|
|
||||||
if (cachedPlayer == null)
|
|
||||||
cachedPlayer = PlayerHelper.getPlayerFromUUID(playerId);
|
|
||||||
|
|
||||||
return cachedPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BMWorldSavedData getParent()
|
|
||||||
{
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoulNetwork setParent(BMWorldSavedData parent)
|
|
||||||
{
|
|
||||||
this.parent = parent;
|
|
||||||
markDirty();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerEntity getCachedPlayer()
|
|
||||||
{
|
|
||||||
return cachedPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getPlayerId()
|
|
||||||
{
|
|
||||||
return playerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCurrentEssence()
|
|
||||||
{
|
|
||||||
return currentEssence;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoulNetwork setCurrentEssence(int currentEssence)
|
|
||||||
{
|
|
||||||
this.currentEssence = currentEssence;
|
|
||||||
markDirty();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOrbTier()
|
|
||||||
{
|
|
||||||
return orbTier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoulNetwork setOrbTier(int orbTier)
|
|
||||||
{
|
|
||||||
this.orbTier = orbTier;
|
|
||||||
markDirty();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SoulTicket> getTicketHistory()
|
|
||||||
{
|
|
||||||
return ImmutableList.copyOf(ticketHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
// INBTSerializable
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT serializeNBT()
|
|
||||||
{
|
|
||||||
CompoundNBT tagCompound = new CompoundNBT();
|
|
||||||
tagCompound.putString("playerId", getPlayerId().toString());
|
|
||||||
tagCompound.putInt("currentEssence", getCurrentEssence());
|
|
||||||
tagCompound.putInt("orbTier", getOrbTier());
|
|
||||||
return tagCompound;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserializeNBT(CompoundNBT nbt)
|
|
||||||
{
|
|
||||||
this.playerId = UUID.fromString(nbt.getString("playerId"));
|
|
||||||
this.currentEssence = nbt.getInt("currentEssence");
|
|
||||||
this.orbTier = nbt.getInt("orbTier");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoulNetwork fromNBT(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
SoulNetwork soulNetwork = new SoulNetwork();
|
|
||||||
soulNetwork.deserializeNBT(tagCompound);
|
|
||||||
return soulNetwork;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoulNetwork newEmpty(UUID uuid)
|
|
||||||
{
|
|
||||||
SoulNetwork network = new SoulNetwork();
|
|
||||||
network.playerId = uuid;
|
|
||||||
return network;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,104 +0,0 @@
|
||||||
package wayoftime.bloodmagic.core.data;
|
|
||||||
|
|
||||||
import net.minecraft.command.ICommandSource;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
public class SoulTicket
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final ITextComponent EMPTY = new StringTextComponent("");
|
|
||||||
|
|
||||||
private final ITextComponent description;
|
|
||||||
private final int amount;
|
|
||||||
|
|
||||||
public SoulTicket(ITextComponent description, int amount)
|
|
||||||
{
|
|
||||||
this.description = description;
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoulTicket(int amount)
|
|
||||||
{
|
|
||||||
this(EMPTY, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSyphon()
|
|
||||||
{
|
|
||||||
return amount < 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITextComponent getDescription()
|
|
||||||
{
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAmount()
|
|
||||||
{
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return A description in the format block|dimensionID|pos
|
|
||||||
*/
|
|
||||||
public static SoulTicket block(World world, BlockPos pos, int amount)
|
|
||||||
{
|
|
||||||
// func_234923_W_() = getDimension
|
|
||||||
return new SoulTicket(new StringTextComponent("block|" + world.getDimensionKey().getRegistryName() + "|"
|
|
||||||
+ pos.toLong()), amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return A description in the format item|item registry
|
|
||||||
* name|dimensionID|entityName|entityPos
|
|
||||||
*/
|
|
||||||
public static SoulTicket item(ItemStack itemStack, World world, Entity entity, int amount)
|
|
||||||
{
|
|
||||||
return new SoulTicket(new StringTextComponent("item|" + itemStack.getItem().getRegistryName() + "|"
|
|
||||||
+ world.getDimensionKey().getRegistryName() + "|" + entity.getCachedUniqueIdString()), amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return A description in the format item|item registry name|dimensionID|pos
|
|
||||||
*/
|
|
||||||
public static SoulTicket item(ItemStack itemStack, World world, BlockPos pos, int amount)
|
|
||||||
{
|
|
||||||
return new SoulTicket(new StringTextComponent("item|" + itemStack.getItem().getRegistryName() + "|"
|
|
||||||
+ world.getDimensionKey().getRegistryName() + "|" + pos.toLong()), amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return A description in the format item|item registry name|dimensionID
|
|
||||||
*/
|
|
||||||
public static SoulTicket item(ItemStack itemStack, int amount)
|
|
||||||
{
|
|
||||||
return new SoulTicket(new StringTextComponent("item|" + itemStack.getItem().getRegistryName()), amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoulTicket command(ICommandSource sender, String command, int amount)
|
|
||||||
{
|
|
||||||
return new SoulTicket(new StringTextComponent("command|" + command + "|" + sender.toString()), amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO maybe make it check the amount??
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o)
|
|
||||||
{
|
|
||||||
if (this == o)
|
|
||||||
return true;
|
|
||||||
if (o instanceof SoulTicket)
|
|
||||||
return ((SoulTicket) o).getDescription().equals(description);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
return description.hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,83 +0,0 @@
|
||||||
package wayoftime.bloodmagic.core.recipe;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.util.JSONUtils;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.common.crafting.IIngredientSerializer;
|
|
||||||
import net.minecraftforge.common.crafting.VanillaIngredientSerializer;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
import wayoftime.bloodmagic.core.registry.OrbRegistry;
|
|
||||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
|
||||||
|
|
||||||
public class IngredientBloodOrb extends Ingredient
|
|
||||||
{
|
|
||||||
public static final ResourceLocation NAME = new ResourceLocation(BloodMagic.MODID, "bloodorb");
|
|
||||||
|
|
||||||
public final int orbTier;
|
|
||||||
|
|
||||||
public static IngredientBloodOrb fromTier(int orbTier)
|
|
||||||
{
|
|
||||||
return new IngredientBloodOrb(orbTier);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IngredientBloodOrb fromOrb(BloodOrb orb)
|
|
||||||
{
|
|
||||||
return new IngredientBloodOrb(orb.getTier());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IngredientBloodOrb(int orbTier)
|
|
||||||
{
|
|
||||||
super(Stream.of(new ItemList(orbTier)));
|
|
||||||
this.orbTier = orbTier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public net.minecraftforge.common.crafting.IIngredientSerializer<? extends Ingredient> getSerializer()
|
|
||||||
{
|
|
||||||
return Serializer.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ItemList implements IItemList
|
|
||||||
{
|
|
||||||
private final int orbTier;
|
|
||||||
|
|
||||||
public ItemList(int orbTier)
|
|
||||||
{
|
|
||||||
this.orbTier = orbTier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ItemStack> getStacks()
|
|
||||||
{
|
|
||||||
List<ItemStack> orbGet = OrbRegistry.getOrbsDownToTier(orbTier);
|
|
||||||
|
|
||||||
return orbGet;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonObject serialize()
|
|
||||||
{
|
|
||||||
JsonObject object = new JsonObject();
|
|
||||||
object.addProperty("type", NAME.toString());
|
|
||||||
object.addProperty("orb_tier", orbTier);
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Serializer extends VanillaIngredientSerializer
|
|
||||||
{
|
|
||||||
public static final IIngredientSerializer<? extends Ingredient> INSTANCE = new Serializer();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Ingredient parse(JsonObject json)
|
|
||||||
{
|
|
||||||
return new IngredientBloodOrb(JSONUtils.getInt(json, "orb_tier"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
package wayoftime.bloodmagic.core.registry;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap;
|
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
import wayoftime.bloodmagic.altar.AltarTier;
|
|
||||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is only for those who wish to add a basic {@link BloodOrb}. If you need
|
|
||||||
* custom handling, you will need your own item class.
|
|
||||||
*/
|
|
||||||
public class OrbRegistry
|
|
||||||
{
|
|
||||||
public static ArrayListMultimap<Integer, ItemStack> tierMap = ArrayListMultimap.create();
|
|
||||||
private static List<BloodOrb> orbs = new ArrayList<>();
|
|
||||||
|
|
||||||
public static List<ItemStack> getOrbsForTier(int tier)
|
|
||||||
{
|
|
||||||
if (getTierMap().containsKey(tier))
|
|
||||||
return getTierMap().get(tier);
|
|
||||||
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ItemStack> getOrbsUpToTier(int tier)
|
|
||||||
{
|
|
||||||
List<ItemStack> ret = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 1; i <= tier; i++) ret.addAll(getOrbsForTier(i));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ItemStack> getOrbsDownToTier(int tier)
|
|
||||||
{
|
|
||||||
List<ItemStack> ret = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = AltarTier.MAXTIERS; i >= tier; i--) ret.addAll(getOrbsForTier(i));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack getOrbStack(BloodOrb orb)
|
|
||||||
{
|
|
||||||
Item orbItem = ForgeRegistries.ITEMS.getValue(orb.getResourceLocation());
|
|
||||||
if (orbItem == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return new ItemStack(orbItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayListMultimap<Integer, ItemStack> getTierMap()
|
|
||||||
{
|
|
||||||
return ArrayListMultimap.create(tierMap);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
package wayoftime.bloodmagic.entity.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.entity.EntityType;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.projectile.ProjectileHelper;
|
|
||||||
import net.minecraft.entity.projectile.ProjectileItemEntity;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.network.IPacket;
|
|
||||||
import net.minecraft.particles.IParticleData;
|
|
||||||
import net.minecraft.particles.ItemParticleData;
|
|
||||||
import net.minecraft.particles.ParticleTypes;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
|
||||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
|
||||||
import wayoftime.bloodmagic.common.registries.BloodMagicEntityTypes;
|
|
||||||
|
|
||||||
public class EntityBloodLight extends ProjectileItemEntity
|
|
||||||
{
|
|
||||||
public EntityBloodLight(EntityType<EntityBloodLight> p_i50159_1_, World p_i50159_2_)
|
|
||||||
{
|
|
||||||
super(p_i50159_1_, p_i50159_2_);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityBloodLight(World worldIn, LivingEntity throwerIn)
|
|
||||||
{
|
|
||||||
super(BloodMagicEntityTypes.BLOOD_LIGHT.getEntityType(), throwerIn, worldIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityBloodLight(World worldIn, double x, double y, double z)
|
|
||||||
{
|
|
||||||
super(BloodMagicEntityTypes.BLOOD_LIGHT.getEntityType(), x, y, z, worldIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Item getDefaultItem()
|
|
||||||
{
|
|
||||||
return BloodMagicItems.REAGENT_BLOOD_LIGHT.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPacket<?> createSpawnPacket()
|
|
||||||
{
|
|
||||||
return NetworkHooks.getEntitySpawningPacket(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick()
|
|
||||||
{
|
|
||||||
super.tick();
|
|
||||||
RayTraceResult raytraceresult = ProjectileHelper.func_234618_a_(this, this::func_230298_a_);
|
|
||||||
// boolean flag = false;
|
|
||||||
if (raytraceresult.getType() == RayTraceResult.Type.BLOCK)
|
|
||||||
{
|
|
||||||
BlockPos blockpos = ((BlockRayTraceResult) raytraceresult).getPos().offset(((BlockRayTraceResult) raytraceresult).getFace());
|
|
||||||
BlockState blockstate = this.world.getBlockState(blockpos);
|
|
||||||
if (blockstate.isAir())
|
|
||||||
{
|
|
||||||
this.getEntityWorld().setBlockState(blockpos, BloodMagicBlocks.BLOOD_LIGHT.get().getDefaultState());
|
|
||||||
this.setDead();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected float getGravityVelocity()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private IParticleData makeParticle()
|
|
||||||
{
|
|
||||||
ItemStack itemstack = this.func_213882_k();
|
|
||||||
return (IParticleData) (itemstack.isEmpty() ? ParticleTypes.LAVA
|
|
||||||
: new ItemParticleData(ParticleTypes.ITEM, itemstack));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler for {@link World#setEntityState}
|
|
||||||
*/
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public void handleStatusUpdate(byte id)
|
|
||||||
{
|
|
||||||
if (id == 3)
|
|
||||||
{
|
|
||||||
IParticleData iparticledata = this.makeParticle();
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
{
|
|
||||||
this.world.addParticle(iparticledata, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D, 0.0D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,94 +0,0 @@
|
||||||
package wayoftime.bloodmagic.entity.projectile;
|
|
||||||
|
|
||||||
import net.minecraft.entity.EntityType;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.projectile.ProjectileItemEntity;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.network.IPacket;
|
|
||||||
import net.minecraft.particles.IParticleData;
|
|
||||||
import net.minecraft.particles.ItemParticleData;
|
|
||||||
import net.minecraft.particles.ParticleTypes;
|
|
||||||
import net.minecraft.potion.EffectInstance;
|
|
||||||
import net.minecraft.util.DamageSource;
|
|
||||||
import net.minecraft.util.math.EntityRayTraceResult;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
|
||||||
import wayoftime.bloodmagic.common.registries.BloodMagicEntityTypes;
|
|
||||||
import wayoftime.bloodmagic.potion.BloodMagicPotions;
|
|
||||||
|
|
||||||
public class EntitySoulSnare extends ProjectileItemEntity
|
|
||||||
{
|
|
||||||
public EntitySoulSnare(EntityType<EntitySoulSnare> p_i50159_1_, World p_i50159_2_)
|
|
||||||
{
|
|
||||||
super(p_i50159_1_, p_i50159_2_);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntitySoulSnare(World worldIn, LivingEntity throwerIn)
|
|
||||||
{
|
|
||||||
super(BloodMagicEntityTypes.SNARE.getEntityType(), throwerIn, worldIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntitySoulSnare(World worldIn, double x, double y, double z)
|
|
||||||
{
|
|
||||||
super(BloodMagicEntityTypes.SNARE.getEntityType(), x, y, z, worldIn);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Item getDefaultItem()
|
|
||||||
{
|
|
||||||
return BloodMagicItems.SOUL_SNARE.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IPacket<?> createSpawnPacket()
|
|
||||||
{
|
|
||||||
return NetworkHooks.getEntitySpawningPacket(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the arrow hits an entity
|
|
||||||
*/
|
|
||||||
protected void onEntityHit(EntityRayTraceResult result)
|
|
||||||
{
|
|
||||||
if (result.getEntity() == this.func_234616_v_() || this.ticksExisted < 2 || getEntityWorld().isRemote)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (result.getEntity() instanceof LivingEntity)
|
|
||||||
{
|
|
||||||
((LivingEntity) result.getEntity()).addPotionEffect(new EffectInstance(BloodMagicPotions.SOUL_SNARE, 300, 0));
|
|
||||||
|
|
||||||
result.getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.func_234616_v_()), (float) 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setDead();
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
private IParticleData makeParticle()
|
|
||||||
{
|
|
||||||
ItemStack itemstack = this.func_213882_k();
|
|
||||||
return (IParticleData) (itemstack.isEmpty() ? ParticleTypes.ITEM_SNOWBALL
|
|
||||||
: new ItemParticleData(ParticleTypes.ITEM, itemstack));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler for {@link World#setEntityState}
|
|
||||||
*/
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public void handleStatusUpdate(byte id)
|
|
||||||
{
|
|
||||||
if (id == 3)
|
|
||||||
{
|
|
||||||
IParticleData iparticledata = this.makeParticle();
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
|
||||||
{
|
|
||||||
this.world.addParticle(iparticledata, this.getPosX(), this.getPosY(), this.getPosZ(), 0.0D, 0.0D, 0.0D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package wayoftime.bloodmagic.event;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.eventbus.api.Cancelable;
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
|
|
||||||
@Cancelable
|
|
||||||
public class ItemBindEvent extends Event
|
|
||||||
{
|
|
||||||
private final PlayerEntity player;
|
|
||||||
private final ItemStack itemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This event is called whenever a player attempts to bind a
|
|
||||||
* {@link wayoftime.bloodmagic.iface.IBindable} item.
|
|
||||||
*
|
|
||||||
* @param player The player doing the binding
|
|
||||||
* @param itemStack The {@link ItemStack} that the player is binding
|
|
||||||
* <p>
|
|
||||||
* This event is {@link Cancelable}.<br>
|
|
||||||
*/
|
|
||||||
public ItemBindEvent(PlayerEntity player, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
this.player = player;
|
|
||||||
this.itemStack = itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerEntity getNewOwner()
|
|
||||||
{
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getBindingStack()
|
|
||||||
{
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
package wayoftime.bloodmagic.event;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraftforge.eventbus.api.Cancelable;
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
|
|
||||||
@Cancelable
|
|
||||||
public class SacrificeKnifeUsedEvent extends Event
|
|
||||||
{
|
|
||||||
public final PlayerEntity player;
|
|
||||||
public final int healthDrained;
|
|
||||||
public int lpAdded;
|
|
||||||
public boolean shouldDrainHealth;
|
|
||||||
public boolean shouldFillAltar;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This event is called whenever a player attempts to use a
|
|
||||||
* {@link WayofTime.bloodmagic.item.ItemSacrificialDagger} to self-sacrifice
|
|
||||||
* near an altar.
|
|
||||||
*
|
|
||||||
* @param player The player doing the sacrificing
|
|
||||||
* @param shouldDrainHealth Determines whether or not health is lost
|
|
||||||
* @param shouldFillAltar Determines whether or not an altar should be filled
|
|
||||||
* @param hp Amount of health lost
|
|
||||||
* @param lpAdded Amount of LP added to the altar
|
|
||||||
* <p>
|
|
||||||
* This event is {@link Cancelable}.<br>
|
|
||||||
*/
|
|
||||||
public SacrificeKnifeUsedEvent(PlayerEntity player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp, int lpAdded)
|
|
||||||
{
|
|
||||||
this.player = player;
|
|
||||||
this.shouldDrainHealth = shouldDrainHealth;
|
|
||||||
this.shouldFillAltar = shouldFillAltar;
|
|
||||||
this.healthDrained = hp;
|
|
||||||
this.lpAdded = lpAdded;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,116 +0,0 @@
|
||||||
package wayoftime.bloodmagic.event;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.eventbus.api.Cancelable;
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
import wayoftime.bloodmagic.core.data.SoulNetwork;
|
|
||||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
|
||||||
|
|
||||||
public class SoulNetworkEvent extends Event
|
|
||||||
{
|
|
||||||
private final SoulNetwork network;
|
|
||||||
private SoulTicket ticket;
|
|
||||||
|
|
||||||
public SoulNetworkEvent(SoulNetwork network, SoulTicket ticket)
|
|
||||||
{
|
|
||||||
this.network = network;
|
|
||||||
this.ticket = ticket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoulNetwork getNetwork()
|
|
||||||
{
|
|
||||||
return network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SoulTicket getTicket()
|
|
||||||
{
|
|
||||||
return ticket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTicket(SoulTicket ticket)
|
|
||||||
{
|
|
||||||
this.ticket = ticket;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cancelable
|
|
||||||
public static class Syphon extends SoulNetworkEvent
|
|
||||||
{
|
|
||||||
private boolean shouldDamage;
|
|
||||||
|
|
||||||
public Syphon(SoulNetwork network, SoulTicket ticket)
|
|
||||||
{
|
|
||||||
super(network, ticket);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldDamage()
|
|
||||||
{
|
|
||||||
return shouldDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setShouldDamage(boolean shouldDamage)
|
|
||||||
{
|
|
||||||
this.shouldDamage = shouldDamage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Item extends Syphon
|
|
||||||
{
|
|
||||||
|
|
||||||
private final ItemStack stack;
|
|
||||||
|
|
||||||
public Item(SoulNetwork network, SoulTicket ticket, ItemStack stack)
|
|
||||||
{
|
|
||||||
super(network, ticket);
|
|
||||||
|
|
||||||
this.stack = stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getStack()
|
|
||||||
{
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class User extends Syphon
|
|
||||||
{
|
|
||||||
|
|
||||||
private final PlayerEntity user;
|
|
||||||
|
|
||||||
public User(SoulNetwork network, SoulTicket ticket, PlayerEntity user)
|
|
||||||
{
|
|
||||||
super(network, ticket);
|
|
||||||
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerEntity getUser()
|
|
||||||
{
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cancelable
|
|
||||||
public static class Fill extends SoulNetworkEvent
|
|
||||||
{
|
|
||||||
|
|
||||||
private int maximum;
|
|
||||||
|
|
||||||
public Fill(SoulNetwork network, SoulTicket ticket, int maximum)
|
|
||||||
{
|
|
||||||
super(network, ticket);
|
|
||||||
|
|
||||||
this.maximum = maximum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaximum()
|
|
||||||
{
|
|
||||||
return maximum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaximum(int maximum)
|
|
||||||
{
|
|
||||||
this.maximum = maximum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,30 +0,0 @@
|
||||||
package wayoftime.bloodmagic.iface;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import wayoftime.bloodmagic.util.Constants;
|
|
||||||
|
|
||||||
public interface IActivatable
|
|
||||||
{
|
|
||||||
|
|
||||||
default boolean getActivated(ItemStack stack)
|
|
||||||
{
|
|
||||||
return !stack.isEmpty() && stack.hasTag() && stack.getTag().getBoolean(Constants.NBT.ACTIVATED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
default ItemStack setActivatedState(ItemStack stack, boolean activated)
|
|
||||||
{
|
|
||||||
if (!stack.isEmpty())
|
|
||||||
{
|
|
||||||
if (!stack.hasTag())
|
|
||||||
stack.setTag(new CompoundNBT());
|
|
||||||
|
|
||||||
stack.getTag().putBoolean(Constants.NBT.ACTIVATED, activated);
|
|
||||||
}
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package wayoftime.bloodmagic.iface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Any item that implements this interface will not be pulled into the Altar on
|
|
||||||
* right click.
|
|
||||||
*/
|
|
||||||
public interface IAltarReader
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package wayoftime.bloodmagic.iface;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import wayoftime.bloodmagic.core.data.Binding;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implement this interface on any Item that can be bound to a player.
|
|
||||||
*/
|
|
||||||
public interface IBindable
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Gets an object that stores who this item is bound to.
|
|
||||||
* <p>
|
|
||||||
* If the item is not bound, this will be null.
|
|
||||||
*
|
|
||||||
* @param stack - The owned ItemStack
|
|
||||||
* @return - The binding object
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
default Binding getBinding(ItemStack stack)
|
|
||||||
{
|
|
||||||
Binding binding = Binding.fromStack(stack);
|
|
||||||
return !stack.isEmpty() && binding != null ? binding : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the player attempts to bind the item.
|
|
||||||
*
|
|
||||||
* @param player - The Player attempting to bind the item
|
|
||||||
* @param stack - The ItemStack to attempt binding
|
|
||||||
* @return If binding was successful.
|
|
||||||
*/
|
|
||||||
default boolean onBind(PlayerEntity player, ItemStack stack)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package wayoftime.bloodmagic.iface;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import wayoftime.bloodmagic.block.enums.BloodRuneType;
|
|
||||||
|
|
||||||
public interface IBloodRune
|
|
||||||
{
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
BloodRuneType getBloodRune(World world, BlockPos pos);
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package wayoftime.bloodmagic.iface;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
|
||||||
|
|
||||||
public interface IMultiWillTool
|
|
||||||
{
|
|
||||||
EnumDemonWillType getCurrentType(ItemStack stack);
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package wayoftime.bloodmagic.iface;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import wayoftime.bloodmagic.common.item.ItemSigil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for all {@link ItemSigil} <b>EXCEPT</b> Sigils of Holdings.
|
|
||||||
*/
|
|
||||||
public interface ISigil
|
|
||||||
{
|
|
||||||
|
|
||||||
default boolean performArrayEffect(World world, BlockPos pos)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
default boolean hasArrayEffect()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Holding
|
|
||||||
{
|
|
||||||
@Nonnull
|
|
||||||
ItemStack getHeldItem(ItemStack holdingStack, PlayerEntity player);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package wayoftime.bloodmagic.network;
|
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.fml.network.simple.SimpleChannel;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
import wayoftime.bloodmagic.util.ChatUtil;
|
|
||||||
|
|
||||||
public class BloodMagicPacketHandler extends BasePacketHandler
|
|
||||||
{
|
|
||||||
// public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(new ResourceLocation(BloodMagic.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
|
|
||||||
public static final SimpleChannel INSTANCE = createChannel(new ResourceLocation(BloodMagic.MODID, "main"));
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize()
|
|
||||||
{
|
|
||||||
registerServerToClient(ChatUtil.PacketNoSpamChat.class, ChatUtil.PacketNoSpamChat::encode, ChatUtil.PacketNoSpamChat::decode, ChatUtil.PacketNoSpamChat::handle);
|
|
||||||
// INSTANCE.registerMessage(id, messageType, encoder, decoder, messageConsumer);
|
|
||||||
// INSTANCE.registerMessage(ChatUtil.PacketNoSpamChat.Handler.class, ChatUtil.PacketNoSpamChat.class, 0, Side.CLIENT);
|
|
||||||
// INSTANCE.registerMessage(ItemRouterButtonPacketProcessor.class, ItemRouterButtonPacketProcessor.class, 1, Side.SERVER);
|
|
||||||
// INSTANCE.registerMessage(PlayerVelocityPacketProcessor.class, PlayerVelocityPacketProcessor.class, 2, Side.CLIENT);
|
|
||||||
// INSTANCE.registerMessage(PlayerFallDistancePacketProcessor.class, PlayerFallDistancePacketProcessor.class, 3, Side.SERVER);
|
|
||||||
// INSTANCE.registerMessage(SigilHoldingPacketProcessor.class, SigilHoldingPacketProcessor.class, 4, Side.SERVER);
|
|
||||||
// INSTANCE.registerMessage(KeyProcessor.class, KeyProcessor.class, 5, Side.SERVER);
|
|
||||||
// INSTANCE.registerMessage(DemonAuraPacketProcessor.class, DemonAuraPacketProcessor.class, 6, Side.CLIENT);
|
|
||||||
// INSTANCE.registerMessage(ItemRouterAmountPacketProcessor.class, ItemRouterAmountPacketProcessor.class, 7, Side.SERVER);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SimpleChannel getChannel()
|
|
||||||
{
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static void sendToAllAround(IMessage message, TileEntity te, int range)
|
|
||||||
// {
|
|
||||||
// INSTANCE.sendToAllAround(message, new NetworkRegistry.TargetPoint(te.getWorld().provider.getDimension(), te.getPos().getX(), te.getPos().getY(), te.getPos().getZ(), range));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void sendToAllAround(IMessage message, TileEntity te)
|
|
||||||
// {
|
|
||||||
// sendToAllAround(message, te, 64);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public static void sendTo(IMessage message, EntityPlayerMP player)
|
|
||||||
// {
|
|
||||||
// INSTANCE.sendTo(message, player);
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
package wayoftime.bloodmagic.orb;
|
|
||||||
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Refactoring of the original BloodOrb. BloodOrbs are no longer registered due
|
|
||||||
* to The Flattening.
|
|
||||||
*/
|
|
||||||
public class BloodOrb extends net.minecraftforge.registries.ForgeRegistryEntry<BloodOrb>
|
|
||||||
{
|
|
||||||
private final ResourceLocation name;
|
|
||||||
private final int tier;
|
|
||||||
private final int capacity;
|
|
||||||
private final int fillRate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A base object for BloodOrbs. A bit cleaner than the old way through
|
|
||||||
* EnergyItems.
|
|
||||||
*
|
|
||||||
* @param name - A name for the Orb. Gets put into an unlocalized name.
|
|
||||||
* @param tier - The tier of the Orb.
|
|
||||||
* @param capacity - The max amount of LP the Orb can store.
|
|
||||||
* @param fillRate - The amount of LP per tick the Altar can fill the network
|
|
||||||
* with.
|
|
||||||
*/
|
|
||||||
public BloodOrb(ResourceLocation name, int tier, int capacity, int fillRate)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
this.tier = tier;
|
|
||||||
this.capacity = capacity;
|
|
||||||
this.fillRate = fillRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResourceLocation getResourceLocation()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTier()
|
|
||||||
{
|
|
||||||
return tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCapacity()
|
|
||||||
{
|
|
||||||
return capacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFillRate()
|
|
||||||
{
|
|
||||||
return fillRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
// return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + ", owner="
|
|
||||||
// + getRegistryName() + '}';
|
|
||||||
return "BloodOrb{" + "name='" + name + '\'' + ", tier=" + tier + ", capacity=" + capacity + '}';
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
package wayoftime.bloodmagic.orb;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
|
|
||||||
public interface IBloodOrb
|
|
||||||
{
|
|
||||||
@Nullable
|
|
||||||
BloodOrb getOrb(ItemStack stack);
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package wayoftime.bloodmagic.potion;
|
|
||||||
|
|
||||||
import net.minecraft.potion.Effect;
|
|
||||||
import net.minecraft.potion.EffectType;
|
|
||||||
|
|
||||||
public class PotionBloodMagic extends Effect
|
|
||||||
{
|
|
||||||
public PotionBloodMagic(EffectType typeIn, int liquidColorIn)
|
|
||||||
{
|
|
||||||
super(typeIn, liquidColorIn);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,152 +0,0 @@
|
||||||
package wayoftime.bloodmagic.tile;
|
|
||||||
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.tileentity.ITickableTileEntity;
|
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraftforge.registries.ObjectHolder;
|
|
||||||
import wayoftime.bloodmagic.common.alchemyarray.AlchemyArrayEffect;
|
|
||||||
import wayoftime.bloodmagic.core.registry.AlchemyArrayRegistry;
|
|
||||||
import wayoftime.bloodmagic.util.Constants;
|
|
||||||
|
|
||||||
public class TileAlchemyArray extends TileInventory implements ITickableTileEntity
|
|
||||||
{
|
|
||||||
@ObjectHolder("bloodmagic:alchemyarray")
|
|
||||||
public static TileEntityType<TileAlchemyArray> TYPE;
|
|
||||||
|
|
||||||
public boolean isActive = false;
|
|
||||||
public int activeCounter = 0;
|
|
||||||
public Direction rotation = Direction.byHorizontalIndex(0);
|
|
||||||
public int rotateCooldown = 0;
|
|
||||||
|
|
||||||
private String key = "";
|
|
||||||
public AlchemyArrayEffect arrayEffect;
|
|
||||||
private boolean doDropIngredients = true;
|
|
||||||
|
|
||||||
public TileAlchemyArray(TileEntityType<?> type)
|
|
||||||
{
|
|
||||||
super(type, 2, "alchemyarray");
|
|
||||||
// this.bloodAltar = new BloodAltar(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileAlchemyArray()
|
|
||||||
{
|
|
||||||
this(TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserialize(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
super.deserialize(tagCompound);
|
|
||||||
this.isActive = tagCompound.getBoolean("isActive");
|
|
||||||
this.activeCounter = tagCompound.getInt("activeCounter");
|
|
||||||
this.key = tagCompound.getString("stringKey");
|
|
||||||
if (!tagCompound.contains("doDropIngredients")) // Check if the array is old
|
|
||||||
{
|
|
||||||
this.doDropIngredients = true;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
this.doDropIngredients = tagCompound.getBoolean("doDropIngredients");
|
|
||||||
}
|
|
||||||
this.rotation = Direction.byHorizontalIndex(tagCompound.getInt(Constants.NBT.DIRECTION));
|
|
||||||
|
|
||||||
CompoundNBT arrayTag = tagCompound.getCompound("arrayTag");
|
|
||||||
// arrayEffect = AlchemyArrayRegistry.getEffect(world, this.getStackInSlot(0), this.getStackInSlot(1));
|
|
||||||
if (arrayEffect != null)
|
|
||||||
{
|
|
||||||
arrayEffect.readFromNBT(arrayTag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT serialize(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
super.serialize(tagCompound);
|
|
||||||
tagCompound.putBoolean("isActive", isActive);
|
|
||||||
tagCompound.putInt("activeCounter", activeCounter);
|
|
||||||
tagCompound.putString("stringKey", "".equals(key) ? "empty" : key.toString());
|
|
||||||
tagCompound.putBoolean("doDropIngredients", doDropIngredients);
|
|
||||||
tagCompound.putInt(Constants.NBT.DIRECTION, rotation.getHorizontalIndex());
|
|
||||||
|
|
||||||
CompoundNBT arrayTag = new CompoundNBT();
|
|
||||||
if (arrayEffect != null)
|
|
||||||
{
|
|
||||||
arrayEffect.writeToNBT(arrayTag);
|
|
||||||
}
|
|
||||||
tagCompound.put("arrayTag", arrayTag);
|
|
||||||
|
|
||||||
return tagCompound;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick()
|
|
||||||
{
|
|
||||||
// System.out.println("Active counter: " + this.activeCounter);
|
|
||||||
if (isActive && attemptCraft())
|
|
||||||
{
|
|
||||||
activeCounter++;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
isActive = false;
|
|
||||||
doDropIngredients = true;
|
|
||||||
activeCounter = 0;
|
|
||||||
arrayEffect = null;
|
|
||||||
key = "empty";
|
|
||||||
}
|
|
||||||
if (rotateCooldown > 0)
|
|
||||||
rotateCooldown--;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean attemptCraft()
|
|
||||||
{
|
|
||||||
if (arrayEffect != null)
|
|
||||||
{
|
|
||||||
isActive = true;
|
|
||||||
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
AlchemyArrayEffect effect = AlchemyArrayRegistry.getEffect(world, this.getStackInSlot(0), this.getStackInSlot(1));
|
|
||||||
if (effect == null)
|
|
||||||
{
|
|
||||||
// key = effect.i
|
|
||||||
return false;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
arrayEffect = effect;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arrayEffect != null)
|
|
||||||
{
|
|
||||||
isActive = true;
|
|
||||||
if (arrayEffect.update(this, this.activeCounter))
|
|
||||||
{
|
|
||||||
this.decrStackSize(0, 1);
|
|
||||||
this.decrStackSize(1, 1);
|
|
||||||
this.getWorld().setBlockState(getPos(), Blocks.AIR.getDefaultState());
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
public Direction getRotation()
|
|
||||||
{
|
|
||||||
return rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRotation(Direction rotation)
|
|
||||||
{
|
|
||||||
this.rotation = rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
|
|
||||||
{
|
|
||||||
return slot == 0 || slot == 1;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,227 +0,0 @@
|
||||||
package wayoftime.bloodmagic.tile;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.tileentity.ITickableTileEntity;
|
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
|
||||||
import net.minecraftforge.registries.ObjectHolder;
|
|
||||||
import wayoftime.bloodmagic.altar.AltarTier;
|
|
||||||
import wayoftime.bloodmagic.altar.BloodAltar;
|
|
||||||
import wayoftime.bloodmagic.altar.IBloodAltar;
|
|
||||||
|
|
||||||
public class TileAltar extends TileInventory implements IBloodAltar, ITickableTileEntity
|
|
||||||
{
|
|
||||||
@ObjectHolder("bloodmagic:altar")
|
|
||||||
public static TileEntityType<TileAltar> TYPE;
|
|
||||||
private BloodAltar bloodAltar;
|
|
||||||
|
|
||||||
public TileAltar(TileEntityType<?> type)
|
|
||||||
{
|
|
||||||
super(type, 1, "altar");
|
|
||||||
this.bloodAltar = new BloodAltar(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileAltar()
|
|
||||||
{
|
|
||||||
this(TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserialize(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
super.deserialize(tagCompound);
|
|
||||||
|
|
||||||
CompoundNBT altarTag = tagCompound.getCompound("bloodAltar");
|
|
||||||
|
|
||||||
this.bloodAltar.readFromNBT(altarTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT serialize(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
super.serialize(tagCompound);
|
|
||||||
|
|
||||||
CompoundNBT altarTag = new CompoundNBT();
|
|
||||||
this.bloodAltar.writeToNBT(altarTag);
|
|
||||||
|
|
||||||
tagCompound.put("bloodAltar", altarTag);
|
|
||||||
return tagCompound;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick()
|
|
||||||
{
|
|
||||||
bloodAltar.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sacrificialDaggerCall(int amount, boolean isSacrifice)
|
|
||||||
{
|
|
||||||
bloodAltar.sacrificialDaggerCall(amount, isSacrifice);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int slot, ItemStack itemstack)
|
|
||||||
{
|
|
||||||
return slot == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCapacity()
|
|
||||||
{
|
|
||||||
return bloodAltar.getCapacity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getCurrentBlood()
|
|
||||||
{
|
|
||||||
return bloodAltar.getCurrentBlood();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AltarTier getTier()
|
|
||||||
{
|
|
||||||
return bloodAltar.getTier();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getProgress()
|
|
||||||
{
|
|
||||||
return bloodAltar.getProgress();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getSacrificeMultiplier()
|
|
||||||
{
|
|
||||||
return bloodAltar.getSacrificeMultiplier();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getSelfSacrificeMultiplier()
|
|
||||||
{
|
|
||||||
return bloodAltar.getSelfSacrificeMultiplier();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getOrbMultiplier()
|
|
||||||
{
|
|
||||||
return bloodAltar.getOrbMultiplier();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getDislocationMultiplier()
|
|
||||||
{
|
|
||||||
return bloodAltar.getDislocationMultiplier();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getConsumptionMultiplier()
|
|
||||||
{
|
|
||||||
return bloodAltar.getConsumptionMultiplier();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getConsumptionRate()
|
|
||||||
{
|
|
||||||
return bloodAltar.getConsumptionRate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLiquidRequired()
|
|
||||||
{
|
|
||||||
return bloodAltar.getLiquidRequired();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBufferCapacity()
|
|
||||||
{
|
|
||||||
return bloodAltar.getBufferCapacity();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startCycle()
|
|
||||||
{
|
|
||||||
bloodAltar.startCycle();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void checkTier()
|
|
||||||
{
|
|
||||||
bloodAltar.checkTier();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void requestPauseAfterCrafting(int cooldown)
|
|
||||||
{
|
|
||||||
bloodAltar.requestPauseAfterCrafting(cooldown);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isActive()
|
|
||||||
{
|
|
||||||
return bloodAltar.isActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int fillMainTank(int amount)
|
|
||||||
{
|
|
||||||
return bloodAltar.fillMainTank(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActive()
|
|
||||||
{
|
|
||||||
bloodAltar.setActive();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getChargingRate()
|
|
||||||
{
|
|
||||||
return bloodAltar.getChargingRate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTotalCharge()
|
|
||||||
{
|
|
||||||
return bloodAltar.getTotalCharge();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getChargingFrequency()
|
|
||||||
{
|
|
||||||
return bloodAltar.getChargingFrequency();
|
|
||||||
}
|
|
||||||
|
|
||||||
public AltarTier getCurrentTierDisplayed()
|
|
||||||
{
|
|
||||||
return bloodAltar.getCurrentTierDisplayed();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setCurrentTierDisplayed(AltarTier altarTier)
|
|
||||||
{
|
|
||||||
return bloodAltar.setCurrentTierDisplayed(altarTier);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing)
|
|
||||||
// {
|
|
||||||
// if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return super.hasCapability(capability, facing);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @SuppressWarnings("unchecked")
|
|
||||||
// @Override
|
|
||||||
// public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing)
|
|
||||||
// {
|
|
||||||
// if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
|
||||||
// {
|
|
||||||
// return (T) bloodAltar;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return super.getCapability(capability, facing);
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,317 +0,0 @@
|
||||||
package wayoftime.bloodmagic.tile;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
|
||||||
import net.minecraft.inventory.InventoryHelper;
|
|
||||||
import net.minecraft.inventory.ItemStackHelper;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
import net.minecraftforge.items.wrapper.InvWrapper;
|
|
||||||
import net.minecraftforge.items.wrapper.SidedInvWrapper;
|
|
||||||
import wayoftime.bloodmagic.tile.base.TileBase;
|
|
||||||
|
|
||||||
public class TileInventory extends TileBase implements IInventory
|
|
||||||
{
|
|
||||||
protected int[] syncedSlots = new int[0];
|
|
||||||
protected NonNullList<ItemStack> inventory;
|
|
||||||
LazyOptional<IItemHandler> handlerDown;
|
|
||||||
LazyOptional<IItemHandler> handlerUp;
|
|
||||||
LazyOptional<IItemHandler> handlerNorth;
|
|
||||||
LazyOptional<IItemHandler> handlerSouth;
|
|
||||||
LazyOptional<IItemHandler> handlerWest;
|
|
||||||
LazyOptional<IItemHandler> handlerEast;
|
|
||||||
private int size;
|
|
||||||
|
|
||||||
// IInventory
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public TileInventory(TileEntityType<?> type, int size, String name)
|
|
||||||
{
|
|
||||||
super(type);
|
|
||||||
this.inventory = NonNullList.withSize(size, ItemStack.EMPTY);
|
|
||||||
this.size = size;
|
|
||||||
this.name = name;
|
|
||||||
initializeItemHandlers();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isSyncedSlot(int slot)
|
|
||||||
{
|
|
||||||
for (int s : this.syncedSlots)
|
|
||||||
{
|
|
||||||
if (s == slot)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserialize(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
super.deserialize(tagCompound);
|
|
||||||
|
|
||||||
this.inventory = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY);
|
|
||||||
|
|
||||||
ItemStackHelper.loadAllItems(tagCompound, this.inventory);
|
|
||||||
|
|
||||||
// ListNBT tags = tagCompound.getList("Items", 10);
|
|
||||||
// inventory = NonNullList.withSize(size, ItemStack.EMPTY);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < tags.size(); i++)
|
|
||||||
// {
|
|
||||||
// if (!isSyncedSlot(i))
|
|
||||||
// {
|
|
||||||
// CompoundNBT data = tags.getCompoundTagAt(i);
|
|
||||||
// byte j = data.getByte("Slot");
|
|
||||||
//
|
|
||||||
// if (j >= 0 && j < inventory.size())
|
|
||||||
// {
|
|
||||||
// inventory.set(j, new ItemStack(data)); // No matter how much an i looks like a j, it is not one.
|
|
||||||
// // They are drastically different characters and cause
|
|
||||||
// // drastically different things to happen. Apparently I
|
|
||||||
// // didn't know this at one point. - TehNut
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT serialize(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
super.serialize(tagCompound);
|
|
||||||
|
|
||||||
ItemStackHelper.saveAllItems(tagCompound, this.inventory);
|
|
||||||
// NBTTagList tags = new NBTTagList();
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < inventory.size(); i++)
|
|
||||||
// {
|
|
||||||
// if ((!inventory.get(i).isEmpty()) && !isSyncedSlot(i))
|
|
||||||
// {
|
|
||||||
// CompoundNBT data = new CompoundNBT();
|
|
||||||
// data.putByte("Slot", (byte) i);
|
|
||||||
// inventory.get(i).write(data);
|
|
||||||
// tags.appendTag(data);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// tagCompound.setTag("Items", tags);
|
|
||||||
return tagCompound;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dropItems()
|
|
||||||
{
|
|
||||||
InventoryHelper.dropInventoryItems(getWorld(), getPos(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSizeInventory()
|
|
||||||
{
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getStackInSlot(int index)
|
|
||||||
{
|
|
||||||
return inventory.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack decrStackSize(int index, int count)
|
|
||||||
{
|
|
||||||
if (!getStackInSlot(index).isEmpty())
|
|
||||||
{
|
|
||||||
if (!getWorld().isRemote)
|
|
||||||
getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3);
|
|
||||||
|
|
||||||
if (getStackInSlot(index).getCount() <= count)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = inventory.get(index);
|
|
||||||
inventory.set(index, ItemStack.EMPTY);
|
|
||||||
markDirty();
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack itemStack = inventory.get(index).split(count);
|
|
||||||
markDirty();
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack removeStackFromSlot(int slot)
|
|
||||||
{
|
|
||||||
if (!inventory.get(slot).isEmpty())
|
|
||||||
{
|
|
||||||
ItemStack itemStack = inventory.get(slot);
|
|
||||||
setInventorySlotContents(slot, ItemStack.EMPTY);
|
|
||||||
return itemStack;
|
|
||||||
}
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
|
||||||
{
|
|
||||||
inventory.set(slot, stack);
|
|
||||||
if (!stack.isEmpty() && stack.getCount() > getInventoryStackLimit())
|
|
||||||
stack.setCount(getInventoryStackLimit());
|
|
||||||
markDirty();
|
|
||||||
if (!getWorld().isRemote)
|
|
||||||
getWorld().notifyBlockUpdate(getPos(), getWorld().getBlockState(getPos()), getWorld().getBlockState(getPos()), 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getInventoryStackLimit()
|
|
||||||
{
|
|
||||||
return 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openInventory(PlayerEntity player)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void closeInventory(PlayerEntity player)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// IWorldNameable
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public int getField(int id)
|
|
||||||
// {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setField(int id, int value)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int getFieldCount()
|
|
||||||
// {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear()
|
|
||||||
{
|
|
||||||
this.inventory = NonNullList.withSize(size, ItemStack.EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty()
|
|
||||||
{
|
|
||||||
for (ItemStack stack : inventory) if (!stack.isEmpty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isUsableByPlayer(PlayerEntity player)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public String getName()
|
|
||||||
// {
|
|
||||||
// return TextHelper.localize("tile.bloodmagic." + name + ".name");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean hasCustomName()
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public ITextComponent getDisplayName()
|
|
||||||
// {
|
|
||||||
// return new TextComponentString(getName());
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected void initializeItemHandlers()
|
|
||||||
{
|
|
||||||
if (this instanceof ISidedInventory)
|
|
||||||
{
|
|
||||||
handlerDown = LazyOptional.of(() -> new SidedInvWrapper((ISidedInventory) this, Direction.DOWN));
|
|
||||||
handlerUp = LazyOptional.of(() -> new SidedInvWrapper((ISidedInventory) this, Direction.UP));
|
|
||||||
handlerNorth = LazyOptional.of(() -> new SidedInvWrapper((ISidedInventory) this, Direction.NORTH));
|
|
||||||
handlerSouth = LazyOptional.of(() -> new SidedInvWrapper((ISidedInventory) this, Direction.SOUTH));
|
|
||||||
handlerWest = LazyOptional.of(() -> new SidedInvWrapper((ISidedInventory) this, Direction.WEST));
|
|
||||||
handlerEast = LazyOptional.of(() -> new SidedInvWrapper((ISidedInventory) this, Direction.EAST));
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
handlerDown = LazyOptional.of(() -> new InvWrapper(this));
|
|
||||||
handlerUp = handlerDown;
|
|
||||||
handlerNorth = handlerDown;
|
|
||||||
handlerSouth = handlerDown;
|
|
||||||
handlerWest = handlerDown;
|
|
||||||
handlerEast = handlerDown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing)
|
|
||||||
{
|
|
||||||
if (facing != null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
|
||||||
{
|
|
||||||
switch (facing)
|
|
||||||
{
|
|
||||||
case DOWN:
|
|
||||||
return handlerDown.cast();
|
|
||||||
case EAST:
|
|
||||||
return handlerEast.cast();
|
|
||||||
case NORTH:
|
|
||||||
return handlerNorth.cast();
|
|
||||||
case SOUTH:
|
|
||||||
return handlerSouth.cast();
|
|
||||||
case UP:
|
|
||||||
return handlerUp.cast();
|
|
||||||
case WEST:
|
|
||||||
return handlerWest.cast();
|
|
||||||
}
|
|
||||||
} else if (facing == null && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
|
|
||||||
{
|
|
||||||
return handlerDown.cast();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.getCapability(capability, facing);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public boolean hasCapability(Capability<?> capability, Direction facing)
|
|
||||||
// {
|
|
||||||
// return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,379 +0,0 @@
|
||||||
package wayoftime.bloodmagic.tile;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
|
||||||
import net.minecraft.inventory.container.Container;
|
|
||||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.tileentity.ITickableTileEntity;
|
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
|
||||||
import net.minecraft.util.IIntArray;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
import net.minecraftforge.registries.ObjectHolder;
|
|
||||||
import wayoftime.bloodmagic.api.event.BloodMagicCraftedEvent;
|
|
||||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
|
||||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
|
|
||||||
import wayoftime.bloodmagic.tile.contailer.ContainerSoulForge;
|
|
||||||
import wayoftime.bloodmagic.util.Constants;
|
|
||||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
|
||||||
import wayoftime.bloodmagic.will.IDemonWill;
|
|
||||||
import wayoftime.bloodmagic.will.IDemonWillConduit;
|
|
||||||
import wayoftime.bloodmagic.will.IDemonWillGem;
|
|
||||||
|
|
||||||
public class TileSoulForge extends TileInventory
|
|
||||||
implements ITickableTileEntity, INamedContainerProvider, IDemonWillConduit
|
|
||||||
{
|
|
||||||
@ObjectHolder("bloodmagic:soulforge")
|
|
||||||
public static TileEntityType<TileSoulForge> TYPE;
|
|
||||||
|
|
||||||
public static final int ticksRequired = 100;
|
|
||||||
public static final double worldWillTransferRate = 1;
|
|
||||||
|
|
||||||
public static final int soulSlot = 4;
|
|
||||||
public static final int outputSlot = 5;
|
|
||||||
|
|
||||||
// Input slots are from 0 to 3.
|
|
||||||
|
|
||||||
public int burnTime = 0;
|
|
||||||
|
|
||||||
public TileSoulForge(TileEntityType<?> type)
|
|
||||||
{
|
|
||||||
super(type, 6, "soulforge");
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileSoulForge()
|
|
||||||
{
|
|
||||||
this(TYPE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deserialize(CompoundNBT tag)
|
|
||||||
{
|
|
||||||
super.deserialize(tag);
|
|
||||||
|
|
||||||
burnTime = tag.getInt(Constants.NBT.SOUL_FORGE_BURN);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundNBT serialize(CompoundNBT tag)
|
|
||||||
{
|
|
||||||
super.serialize(tag);
|
|
||||||
|
|
||||||
tag.putInt(Constants.NBT.SOUL_FORGE_BURN, burnTime);
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final IIntArray TileData = new IIntArray()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public int get(int index)
|
|
||||||
{
|
|
||||||
switch (index)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return burnTime;
|
|
||||||
case 1:
|
|
||||||
return ticksRequired;
|
|
||||||
case 2:
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Invalid index: " + index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(int index, int value)
|
|
||||||
{
|
|
||||||
throw new IllegalStateException("Cannot set values through IIntArray");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size()
|
|
||||||
{
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick()
|
|
||||||
{
|
|
||||||
if (!hasSoulGemOrSoul())
|
|
||||||
{
|
|
||||||
burnTime = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
double soulsInGem = getWill(EnumDemonWillType.DEFAULT);
|
|
||||||
|
|
||||||
List<ItemStack> inputList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; i++) if (!getStackInSlot(i).isEmpty())
|
|
||||||
inputList.add(getStackInSlot(i));
|
|
||||||
|
|
||||||
RecipeTartaricForge recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getTartaricForge(world, inputList);
|
|
||||||
if (recipe != null && (soulsInGem >= recipe.getMinimumSouls() || burnTime > 0))
|
|
||||||
{
|
|
||||||
if (canCraft(recipe))
|
|
||||||
{
|
|
||||||
burnTime++;
|
|
||||||
|
|
||||||
if (burnTime == ticksRequired)
|
|
||||||
{
|
|
||||||
if (!getWorld().isRemote)
|
|
||||||
{
|
|
||||||
double requiredSouls = recipe.getSoulDrain();
|
|
||||||
if (requiredSouls > 0)
|
|
||||||
{
|
|
||||||
if (!getWorld().isRemote && soulsInGem >= recipe.getMinimumSouls())
|
|
||||||
{
|
|
||||||
consumeSouls(EnumDemonWillType.DEFAULT, requiredSouls);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!getWorld().isRemote && soulsInGem >= recipe.getMinimumSouls())
|
|
||||||
craftItem(recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
burnTime = 0;
|
|
||||||
} else if (burnTime > ticksRequired + 10)
|
|
||||||
{
|
|
||||||
burnTime = 0;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
burnTime = 0;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
burnTime = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean canCraft(RecipeTartaricForge recipe)
|
|
||||||
{
|
|
||||||
if (recipe == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ItemStack currentOutputStack = getStackInSlot(outputSlot);
|
|
||||||
if (recipe.getOutput().isEmpty())
|
|
||||||
return false;
|
|
||||||
if (currentOutputStack.isEmpty())
|
|
||||||
return true;
|
|
||||||
if (!currentOutputStack.isItemEqual(recipe.getOutput()))
|
|
||||||
return false;
|
|
||||||
int result = currentOutputStack.getCount() + recipe.getOutput().getCount();
|
|
||||||
return result <= getInventoryStackLimit() && result <= currentOutputStack.getMaxStackSize();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void craftItem(RecipeTartaricForge recipe)
|
|
||||||
{
|
|
||||||
if (this.canCraft(recipe))
|
|
||||||
{
|
|
||||||
ItemStack currentOutputStack = getStackInSlot(outputSlot);
|
|
||||||
|
|
||||||
List<ItemStack> inputList = new ArrayList<>();
|
|
||||||
for (int i = 0; i < 4; i++) if (!getStackInSlot(i).isEmpty())
|
|
||||||
inputList.add(getStackInSlot(i).copy());
|
|
||||||
|
|
||||||
BloodMagicCraftedEvent.SoulForge event = new BloodMagicCraftedEvent.SoulForge(recipe.getOutput().copy(), inputList.toArray(new ItemStack[0]));
|
|
||||||
MinecraftForge.EVENT_BUS.post(event);
|
|
||||||
|
|
||||||
if (currentOutputStack.isEmpty())
|
|
||||||
{
|
|
||||||
setInventorySlotContents(outputSlot, event.getOutput());
|
|
||||||
} else if (ItemHandlerHelper.canItemStacksStack(currentOutputStack, event.getOutput()))
|
|
||||||
{
|
|
||||||
currentOutputStack.grow(event.getOutput().getCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
consumeInventory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_)
|
|
||||||
{
|
|
||||||
assert world != null;
|
|
||||||
return new ContainerSoulForge(this, TileData, p_createMenu_1_, p_createMenu_2_);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ITextComponent getDisplayName()
|
|
||||||
{
|
|
||||||
return new StringTextComponent("Hellfire Forge");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSoulGemOrSoul()
|
|
||||||
{
|
|
||||||
ItemStack soulStack = getStackInSlot(soulSlot);
|
|
||||||
|
|
||||||
if (!soulStack.isEmpty())
|
|
||||||
{
|
|
||||||
if (soulStack.getItem() instanceof IDemonWill || soulStack.getItem() instanceof IDemonWillGem)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getProgressForGui()
|
|
||||||
{
|
|
||||||
return ((double) burnTime) / ticksRequired;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getWill(EnumDemonWillType type)
|
|
||||||
{
|
|
||||||
ItemStack soulStack = getStackInSlot(soulSlot);
|
|
||||||
|
|
||||||
if (soulStack != null)
|
|
||||||
{
|
|
||||||
if (soulStack.getItem() instanceof IDemonWill
|
|
||||||
&& ((IDemonWill) soulStack.getItem()).getType(soulStack) == type)
|
|
||||||
{
|
|
||||||
IDemonWill soul = (IDemonWill) soulStack.getItem();
|
|
||||||
return soul.getWill(type, soulStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (soulStack.getItem() instanceof IDemonWillGem)
|
|
||||||
{
|
|
||||||
IDemonWillGem soul = (IDemonWillGem) soulStack.getItem();
|
|
||||||
return soul.getWill(type, soulStack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double consumeSouls(EnumDemonWillType type, double requested)
|
|
||||||
{
|
|
||||||
ItemStack soulStack = getStackInSlot(soulSlot);
|
|
||||||
|
|
||||||
if (soulStack != null)
|
|
||||||
{
|
|
||||||
if (soulStack.getItem() instanceof IDemonWill
|
|
||||||
&& ((IDemonWill) soulStack.getItem()).getType(soulStack) == type)
|
|
||||||
{
|
|
||||||
IDemonWill soul = (IDemonWill) soulStack.getItem();
|
|
||||||
double souls = soul.drainWill(type, soulStack, requested);
|
|
||||||
if (soul.getWill(type, soulStack) <= 0)
|
|
||||||
{
|
|
||||||
setInventorySlotContents(soulSlot, ItemStack.EMPTY);
|
|
||||||
}
|
|
||||||
return souls;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (soulStack.getItem() instanceof IDemonWillGem)
|
|
||||||
{
|
|
||||||
IDemonWillGem soul = (IDemonWillGem) soulStack.getItem();
|
|
||||||
return soul.drainWill(type, soulStack, requested, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void consumeInventory()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
ItemStack inputStack = getStackInSlot(i);
|
|
||||||
if (!inputStack.isEmpty())
|
|
||||||
{
|
|
||||||
if (inputStack.getItem().hasContainerItem(inputStack))
|
|
||||||
{
|
|
||||||
setInventorySlotContents(i, inputStack.getItem().getContainerItem(inputStack));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
inputStack.shrink(1);
|
|
||||||
if (inputStack.isEmpty())
|
|
||||||
{
|
|
||||||
setInventorySlotContents(i, ItemStack.EMPTY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWeight()
|
|
||||||
{
|
|
||||||
return 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill)
|
|
||||||
{
|
|
||||||
if (amount <= 0)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!canFill(type))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack stack = this.getStackInSlot(soulSlot);
|
|
||||||
if (stack.isEmpty() || !(stack.getItem() instanceof IDemonWillGem))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDemonWillGem willGem = (IDemonWillGem) stack.getItem();
|
|
||||||
return willGem.fillWill(type, stack, amount, doFill);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain)
|
|
||||||
{
|
|
||||||
ItemStack stack = this.getStackInSlot(soulSlot);
|
|
||||||
if (stack.isEmpty() || !(stack.getItem() instanceof IDemonWillGem))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDemonWillGem willGem = (IDemonWillGem) stack.getItem();
|
|
||||||
|
|
||||||
double drained = amount;
|
|
||||||
double current = willGem.getWill(type, stack);
|
|
||||||
if (current < drained)
|
|
||||||
{
|
|
||||||
drained = current;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doDrain)
|
|
||||||
{
|
|
||||||
drained = willGem.drainWill(type, stack, drained, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return drained;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canFill(EnumDemonWillType type)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canDrain(EnumDemonWillType type)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getCurrentWill(EnumDemonWillType type)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,138 +0,0 @@
|
||||||
package wayoftime.bloodmagic.tile.base;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.network.NetworkManager;
|
|
||||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.tileentity.TileEntityType;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Base tile class.
|
|
||||||
* <p>
|
|
||||||
* Handles data syncing and core data writing/reading.
|
|
||||||
*/
|
|
||||||
public abstract class TileBase extends TileEntity
|
|
||||||
{
|
|
||||||
public TileBase(TileEntityType<?> type)
|
|
||||||
{
|
|
||||||
super(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* read method
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public final void read(BlockState state, CompoundNBT compound)
|
|
||||||
{
|
|
||||||
super.read(state, compound);
|
|
||||||
deserializeBase(compound);
|
|
||||||
deserialize(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final CompoundNBT write(CompoundNBT compound)
|
|
||||||
{
|
|
||||||
super.write(compound);
|
|
||||||
serializeBase(compound);
|
|
||||||
return serialize(compound);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by {@link #func_230337_a_(BlockState, CompoundNBT)}
|
|
||||||
* <p>
|
|
||||||
* Internal data (such as coordinates) are handled for you. Just read the data
|
|
||||||
* you need.
|
|
||||||
*
|
|
||||||
* @param tagCompound - The tag compound to read from
|
|
||||||
*/
|
|
||||||
public void deserialize(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Package private method for reading base data from the tag compound.
|
|
||||||
*
|
|
||||||
* @param tagCompound - The tag compound to read from
|
|
||||||
* @see TileTicking
|
|
||||||
*/
|
|
||||||
void deserializeBase(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by {@link #writeToNBT(CompoundNBT)}
|
|
||||||
* <p>
|
|
||||||
* Internal data (such as coordinates) are handled for you. Just read the data
|
|
||||||
* you need.
|
|
||||||
*
|
|
||||||
* @param tagCompound - The tag compound to write to.
|
|
||||||
* @return the modified tag compound
|
|
||||||
*/
|
|
||||||
public CompoundNBT serialize(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
return tagCompound;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Package private method for writing base data to the tag compound.
|
|
||||||
*
|
|
||||||
* @param tagCompound - The tag compound to write to.
|
|
||||||
* @return the modified tag compound
|
|
||||||
* @see TileTicking
|
|
||||||
*/
|
|
||||||
CompoundNBT serializeBase(CompoundNBT tagCompound)
|
|
||||||
{
|
|
||||||
return tagCompound;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void notifyUpdate()
|
|
||||||
{
|
|
||||||
BlockState state = getWorld().getBlockState(getPos());
|
|
||||||
getWorld().notifyBlockUpdate(getPos(), state, state, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// // Data syncing
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean shouldRefresh(World world, BlockPos pos, BlockState oldState, BlockState newState)
|
|
||||||
// {
|
|
||||||
// return oldState.getBlock() != newState.getBlock();
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final SUpdateTileEntityPacket getUpdatePacket()
|
|
||||||
{
|
|
||||||
return new SUpdateTileEntityPacket(getPos(), -999, getUpdateTag());
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public void handleUpdateTag(BlockState state, CompoundNBT tag)
|
|
||||||
// {
|
|
||||||
// read(state, tag);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public final void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt)
|
|
||||||
{
|
|
||||||
super.onDataPacket(net, pkt);
|
|
||||||
handleUpdateTag(getBlockState(), pkt.getNbtCompound());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final CompoundNBT getUpdateTag()
|
|
||||||
{
|
|
||||||
return write(new CompoundNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void handleUpdateTag(BlockState state, CompoundNBT tag)
|
|
||||||
{
|
|
||||||
read(state, tag);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,79 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
|
|
||||||
public enum BMLog
|
|
||||||
{
|
|
||||||
|
|
||||||
DEFAULT(BloodMagic.MODID)
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
boolean enabled()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
DEBUG()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
boolean enabled()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
// return ConfigHandler.general.enableDebugLogging;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
API()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
boolean enabled()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
// return ConfigHandler.general.enableAPILogging;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
API_VERBOSE()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
boolean enabled()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
// return ConfigHandler.general.enableVerboseAPILogging;
|
|
||||||
}
|
|
||||||
},;
|
|
||||||
|
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
BMLog(String logName)
|
|
||||||
{
|
|
||||||
logger = LogManager.getLogger(logName);
|
|
||||||
}
|
|
||||||
|
|
||||||
BMLog()
|
|
||||||
{
|
|
||||||
logger = LogManager.getLogger(BloodMagic.MODID + "|" + WordUtils.capitalizeFully(name().replace("_", " ")));
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract boolean enabled();
|
|
||||||
|
|
||||||
public void info(String input, Object... args)
|
|
||||||
{
|
|
||||||
if (enabled())
|
|
||||||
logger.info(input, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void error(String input, Object... args)
|
|
||||||
{
|
|
||||||
if (enabled())
|
|
||||||
logger.error(input, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void warn(String input, Object... args)
|
|
||||||
{
|
|
||||||
if (enabled())
|
|
||||||
logger.warn(input, args);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util;
|
|
||||||
|
|
||||||
public class BooleanResult<T>
|
|
||||||
{
|
|
||||||
private final boolean result;
|
|
||||||
private final T value;
|
|
||||||
|
|
||||||
private BooleanResult(boolean result, T value)
|
|
||||||
{
|
|
||||||
this.result = result;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSuccess()
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T getValue()
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> BooleanResult<T> newResult(boolean success, T value)
|
|
||||||
{
|
|
||||||
return new BooleanResult<>(success, value);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,270 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.NewChatGui;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
import net.minecraft.util.Util;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
|
||||||
import net.minecraftforge.fml.network.NetworkEvent.Context;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
import wayoftime.bloodmagic.util.helper.TextHelper;
|
|
||||||
|
|
||||||
public class ChatUtil
|
|
||||||
{
|
|
||||||
private static final int DELETION_ID = 2525277;
|
|
||||||
private static int lastAdded;
|
|
||||||
public static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###,###.##");
|
|
||||||
|
|
||||||
private static void sendNoSpamMessages(ITextComponent[] messages)
|
|
||||||
{
|
|
||||||
NewChatGui chat = Minecraft.getInstance().ingameGUI.getChatGUI();
|
|
||||||
// Minecraft.getMinecraft().ingameGUI.getChatGUI();
|
|
||||||
// for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++)
|
|
||||||
// {
|
|
||||||
// chat.
|
|
||||||
//// chat.deleteChatLine(i);
|
|
||||||
// }
|
|
||||||
for (int i = 0; i < messages.length; i++)
|
|
||||||
{
|
|
||||||
chat.printChatMessage(messages[i]);
|
|
||||||
// chat.printChatMessageWithOptionalDeletion(messages[i], DELETION_ID + i);
|
|
||||||
}
|
|
||||||
lastAdded = DELETION_ID + messages.length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a standard {@link TextComponentString} for the given {@link String} .
|
|
||||||
*
|
|
||||||
* @param s The string to wrap.
|
|
||||||
* @return An {@link ITextComponent} containing the string.
|
|
||||||
*/
|
|
||||||
public static ITextComponent wrap(String s)
|
|
||||||
{
|
|
||||||
return new StringTextComponent(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #wrap(String)
|
|
||||||
*/
|
|
||||||
public static ITextComponent[] wrap(String... s)
|
|
||||||
{
|
|
||||||
ITextComponent[] ret = new ITextComponent[s.length];
|
|
||||||
for (int i = 0; i < ret.length; i++)
|
|
||||||
{
|
|
||||||
ret[i] = wrap(s[i]);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a translatable chat component for the given string and format args.
|
|
||||||
*
|
|
||||||
* @param s The string to format
|
|
||||||
* @param args The args to apply to the format
|
|
||||||
*/
|
|
||||||
public static ITextComponent wrapFormatted(String s, Object... args)
|
|
||||||
{
|
|
||||||
return new TranslationTextComponent(s, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simply sends the passed lines to the player in a chat message.
|
|
||||||
*
|
|
||||||
* @param player The player to send the chat to
|
|
||||||
* @param lines The lines to send
|
|
||||||
*/
|
|
||||||
public static void sendChat(PlayerEntity player, String... lines)
|
|
||||||
{
|
|
||||||
sendChat(player, wrap(lines));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Localizes the lines before sending them.
|
|
||||||
*
|
|
||||||
* @see #sendChat(EntityPlayer, String...)
|
|
||||||
*/
|
|
||||||
public static void sendChatUnloc(PlayerEntity player, String... unlocLines)
|
|
||||||
{
|
|
||||||
sendChat(player, TextHelper.localizeAll(unlocLines));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends all passed chat components to the player.
|
|
||||||
*
|
|
||||||
* @param player The player to send the chat lines to.
|
|
||||||
* @param lines The {@link ITextComponent chat components} to send.yes
|
|
||||||
*/
|
|
||||||
public static void sendChat(PlayerEntity player, ITextComponent... lines)
|
|
||||||
{
|
|
||||||
for (ITextComponent c : lines)
|
|
||||||
{
|
|
||||||
// BloodMagic.packetHandler.send
|
|
||||||
player.sendMessage(c, Util.DUMMY_UUID);
|
|
||||||
// player.sendMessage(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Localizes the strings before sending them.
|
|
||||||
*
|
|
||||||
* @see #sendNoSpamClient(String...)
|
|
||||||
*/
|
|
||||||
public static void sendNoSpamClientUnloc(String... unlocLines)
|
|
||||||
{
|
|
||||||
sendNoSpamClient(TextHelper.localizeAll(unlocLines));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as {@link #sendNoSpamClient(ITextComponent...)}, but wraps the Strings
|
|
||||||
* automatically.
|
|
||||||
*
|
|
||||||
* @param lines The chat lines to send
|
|
||||||
* @see #wrap(String)
|
|
||||||
*/
|
|
||||||
public static void sendNoSpamClient(String... lines)
|
|
||||||
{
|
|
||||||
sendNoSpamClient(wrap(lines));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Skips the packet sending, unsafe to call on servers.
|
|
||||||
*
|
|
||||||
* @see #sendNoSpam(ServerPlayerEntity, ITextComponent...)
|
|
||||||
*/
|
|
||||||
public static void sendNoSpamClient(ITextComponent... lines)
|
|
||||||
{
|
|
||||||
sendNoSpamMessages(lines);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Localizes the strings before sending them.
|
|
||||||
*
|
|
||||||
* @see #sendNoSpam(EntityPlayer, String...)
|
|
||||||
*/
|
|
||||||
public static void sendNoSpamUnloc(PlayerEntity player, String... unlocLines)
|
|
||||||
{
|
|
||||||
sendNoSpam(player, TextHelper.localizeAll(unlocLines));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #wrap(String)
|
|
||||||
* @see #sendNoSpam(EntityPlayer, ITextComponent...)
|
|
||||||
*/
|
|
||||||
public static void sendNoSpam(PlayerEntity player, String... lines)
|
|
||||||
{
|
|
||||||
sendNoSpam(player, wrap(lines));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* First checks if the player is instanceof {@link ServerPlayerEntity} before
|
|
||||||
* casting.
|
|
||||||
*
|
|
||||||
* @see #sendNoSpam(ServerPlayerEntity, ITextComponent...)
|
|
||||||
*/
|
|
||||||
public static void sendNoSpam(PlayerEntity player, ITextComponent... lines)
|
|
||||||
{
|
|
||||||
if (player instanceof ServerPlayerEntity)
|
|
||||||
{
|
|
||||||
sendNoSpam((ServerPlayerEntity) player, lines);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Localizes the strings before sending them.
|
|
||||||
*
|
|
||||||
* @see #sendNoSpam(ServerPlayerEntity, String...)
|
|
||||||
*/
|
|
||||||
public static void sendNoSpamUnloc(ServerPlayerEntity player, String... unlocLines)
|
|
||||||
{
|
|
||||||
sendNoSpam(player, TextHelper.localizeAll(unlocLines));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see #wrap(String)
|
|
||||||
* @see #sendNoSpam(ServerPlayerEntity, ITextComponent...)
|
|
||||||
*/
|
|
||||||
public static void sendNoSpam(ServerPlayerEntity player, String... lines)
|
|
||||||
{
|
|
||||||
sendNoSpam(player, wrap(lines));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a chat message to the client, deleting past messages also sent via this
|
|
||||||
* method.
|
|
||||||
* <p>
|
|
||||||
* Credit to RWTema for the idea
|
|
||||||
*
|
|
||||||
* @param player The player to send the chat message to
|
|
||||||
* @param lines The chat lines to send.
|
|
||||||
*/
|
|
||||||
public static void sendNoSpam(ServerPlayerEntity player, ITextComponent... lines)
|
|
||||||
{
|
|
||||||
if (lines.length > 0)
|
|
||||||
BloodMagic.packetHandler.sendTo(new PacketNoSpamChat(lines), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author tterrag1098
|
|
||||||
* <p>
|
|
||||||
* Ripped from EnderCore (and slightly altered)
|
|
||||||
*/
|
|
||||||
public static class PacketNoSpamChat
|
|
||||||
{
|
|
||||||
private ITextComponent[] chatLines;
|
|
||||||
|
|
||||||
public PacketNoSpamChat()
|
|
||||||
{
|
|
||||||
chatLines = new ITextComponent[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private PacketNoSpamChat(ITextComponent... lines)
|
|
||||||
{
|
|
||||||
// this is guaranteed to be >1 length by accessing methods
|
|
||||||
this.chatLines = lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void encode(PacketNoSpamChat pkt, PacketBuffer buf)
|
|
||||||
{
|
|
||||||
buf.writeInt(pkt.chatLines.length);
|
|
||||||
for (ITextComponent c : pkt.chatLines)
|
|
||||||
{
|
|
||||||
// ByteBufUtils.writeUTF8String(buf, ITextComponent.Serializer.componentToJson(c));
|
|
||||||
buf.writeString(ITextComponent.Serializer.toJson(c));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PacketNoSpamChat decode(PacketBuffer buf)
|
|
||||||
{
|
|
||||||
PacketNoSpamChat pkt = new PacketNoSpamChat(new ITextComponent[buf.readInt()]);
|
|
||||||
for (int i = 0; i < pkt.chatLines.length; i++)
|
|
||||||
{
|
|
||||||
// pkt.chatLines[i] = ITextComponent.Serializer.jsonToComponent(ByteBufUtils.readUTF8String(buf));
|
|
||||||
pkt.chatLines[i] = ITextComponent.Serializer.getComponentFromJsonLenient(buf.readString());
|
|
||||||
}
|
|
||||||
return pkt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void handle(PacketNoSpamChat message, Supplier<Context> context)
|
|
||||||
{
|
|
||||||
context.get().enqueueWork(() -> sendNoSpamMessages(message.chatLines));
|
|
||||||
context.get().setPacketHandled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static class Handler implements IMessageHandler<PacketNoSpamChat, IMessage>
|
|
||||||
// {
|
|
||||||
// @Override
|
|
||||||
// public IMessage onMessage(final PacketNoSpamChat message, MessageContext ctx)
|
|
||||||
// {
|
|
||||||
// Minecraft.getMinecraft().addScheduledTask(() -> sendNoSpamMessages(message.chatLines));
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,180 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util;
|
|
||||||
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
|
|
||||||
public class Constants
|
|
||||||
{
|
|
||||||
public static final String SPEED_RUNE = "speed_rune";
|
|
||||||
|
|
||||||
public static class NBT
|
|
||||||
{
|
|
||||||
public static final String OWNER_UUID = "ownerUUID";
|
|
||||||
public static final String OWNER_NAME = "ownerNAME";
|
|
||||||
public static final String USES = "uses";
|
|
||||||
public static final String ACTIVATED = "activated";
|
|
||||||
public static final String UNUSABLE = "unusable";
|
|
||||||
public static final String SACRIFICE = "sacrifice";
|
|
||||||
public static final String DIMENSION_ID = "dimensionId";
|
|
||||||
public static final String X_COORD = "xCoord";
|
|
||||||
public static final String Y_COORD = "yCoord";
|
|
||||||
public static final String Z_COORD = "zCoord";
|
|
||||||
public static final String PORTAL_LOCATION = "portalLocation";
|
|
||||||
public static final String ORB_TIER = "orbTier";
|
|
||||||
public static final String CURRENT_ESSENCE = "currentEssence";
|
|
||||||
public static final String CURRENT_RITUAL = "currentRitual";
|
|
||||||
public static final String CURRENT_RITUAL_TAG = "currentRitualTag";
|
|
||||||
public static final String IS_RUNNING = "isRunning";
|
|
||||||
public static final String IS_REDSTONED = "isStoned";
|
|
||||||
public static final String RUNTIME = "runtime";
|
|
||||||
public static final String DIRECTION = "direction";
|
|
||||||
public static final String REAGENT_TANKS = "reagentTanks";
|
|
||||||
public static final String CURRENT_INCENSE = "BM:CurrentIncense";
|
|
||||||
public static final String MAX_INCENSE = "BM:MaxIncenseFromLastAltar";
|
|
||||||
public static final String HAS_MAX_INCENSE = "BM:CurrentIsMaxIncense";
|
|
||||||
public static final String CURRENT_PURITY = "BM:CurrentPurity";
|
|
||||||
public static final String EMPTY = "Empty";
|
|
||||||
public static final String OUTPUT_AMOUNT = "outputAmount";
|
|
||||||
public static final String INPUT_AMOUNT = "inputAmount";
|
|
||||||
public static final String STORED_LP = "storedLP";
|
|
||||||
public static final String RITUAL_READER = "ritualReaderState";
|
|
||||||
public static final String ITEMS = "Items";
|
|
||||||
public static final String SLOT = "Slot";
|
|
||||||
|
|
||||||
public static final String ALTAR = "bloodAltar";
|
|
||||||
public static final String ALTAR_TIER = "upgradeLevel";
|
|
||||||
public static final String ALTAR_ACTIVE = "isActive";
|
|
||||||
public static final String ALTAR_LIQUID_REQ = "liquidRequired";
|
|
||||||
public static final String ALTAR_FILLABLE = "fillable";
|
|
||||||
public static final String ALTAR_UPGRADED = "isUpgraded";
|
|
||||||
public static final String ALTAR_CONSUMPTION_RATE = "consumptionRate";
|
|
||||||
public static final String ALTAR_DRAIN_RATE = "drainRate";
|
|
||||||
public static final String ALTAR_CONSUMPTION_MULTIPLIER = "consumptionMultiplier";
|
|
||||||
public static final String ALTAR_EFFICIENCY_MULTIPLIER = "efficiencyMultiplier";
|
|
||||||
public static final String ALTAR_SELF_SACRIFICE_MULTIPLIER = "selfSacrificeMultiplier";
|
|
||||||
public static final String ALTAR_SACRIFICE_MULTIPLIER = "sacrificeMultiplier";
|
|
||||||
public static final String ALTAR_CAPACITY_MULTIPLIER = "capacityMultiplier";
|
|
||||||
public static final String ALTAR_ORB_CAPACITY_MULTIPLIER = "orbCapacityMultiplier";
|
|
||||||
public static final String ALTAR_DISLOCATION_MULTIPLIER = "dislocationMultiplier";
|
|
||||||
public static final String ALTAR_CAPACITY = "capacity";
|
|
||||||
public static final String ALTAR_BUFFER_CAPACITY = "bufferCapacity";
|
|
||||||
public static final String ALTAR_PROGRESS = "progress";
|
|
||||||
public static final String ALTAR_IS_RESULT_BLOCK = "isResultBlock";
|
|
||||||
public static final String ALTAR_LOCKDOWN_DURATION = "lockdownDuration";
|
|
||||||
public static final String ALTAR_ACCELERATION_UPGRADES = "accelerationUpgrades";
|
|
||||||
public static final String ALTAR_DEMON_BLOOD_DURATION = "demonBloodDuration";
|
|
||||||
public static final String ALTAR_COOLDOWN_AFTER_CRAFTING = "cooldownAfterCrafting";
|
|
||||||
public static final String ALTAR_TOTAL_CHARGE = "totalCharge";
|
|
||||||
public static final String ALTAR_MAX_CHARGE = "maxCharge";
|
|
||||||
public static final String ALTAR_CHARGE_RATE = "chargeRate";
|
|
||||||
public static final String ALTAR_CHARGE_FREQUENCY = "chargeFrequency";
|
|
||||||
public static final String ALTAR_CURRENT_TIER_DISPLAYED = "currentTierDisplayed";
|
|
||||||
|
|
||||||
public static final String ALTARMAKER_CURRENT_TIER = "currentTier";
|
|
||||||
|
|
||||||
public static final String PROJECTILE_TICKS_IN_AIR = "projectileTicksInAir";
|
|
||||||
public static final String PROJECTILE_MAX_TICKS_IN_AIR = "projectileMaxTicksInAir";
|
|
||||||
|
|
||||||
public static final String TICKS_REMAINING = "ticksRemaining";
|
|
||||||
public static final String CONTAINED_BLOCK_NAME = "containedBlockName";
|
|
||||||
public static final String CONTAINED_BLOCK_META = "containedBlockMeta";
|
|
||||||
public static final String CONTAINED_TILE_ENTITY = "containedTileEntity";
|
|
||||||
|
|
||||||
public static final String PREVIOUS_INPUT = "previousInput";
|
|
||||||
|
|
||||||
public static final String LIVING_ARMOUR = "livingArmour";
|
|
||||||
|
|
||||||
public static final String CHARGE_TIME = "chargeTime";
|
|
||||||
public static final String HELD_DOWN = "heldDown";
|
|
||||||
|
|
||||||
public static final String UPGRADE_POISON_TIMER = "poisonTimer";
|
|
||||||
public static final String UPGRADE_FIRE_TIMER = "fireTimer";
|
|
||||||
|
|
||||||
public static final String SOULS = "souls";
|
|
||||||
public static final String SOUL_SWORD_DAMAGE = "soulSwordDamage";
|
|
||||||
public static final String SOUL_SWORD_ACTIVE_DRAIN = "soulSwordActiveDrain";
|
|
||||||
public static final String SOUL_SWORD_DROP = "soulSwordDrop";
|
|
||||||
public static final String SOUL_SWORD_STATIC_DROP = "soulSwordStaticDrop";
|
|
||||||
public static final String SOUL_SWORD_HEALTH = "soulSwordHealth";
|
|
||||||
public static final String SOUL_SWORD_ATTACK_SPEED = "soulSwordAttackSpeed";
|
|
||||||
public static final String SOUL_SWORD_SPEED = "soulSwordSpeed";
|
|
||||||
public static final String SOUL_SWORD_DIG_SPEED = "soulSwordDigSpeed";
|
|
||||||
public static final String WILL_TYPE = "demonWillType";
|
|
||||||
|
|
||||||
public static final String SOUL_FORGE_BURN = "burnTime";
|
|
||||||
public static final String SOUL_FORGE_CONSUMED = "consumedSouls";
|
|
||||||
|
|
||||||
public static final String ARC_PROGRESS = "progress";
|
|
||||||
|
|
||||||
public static final String ROUTING_MASTER = "master";
|
|
||||||
public static final String ROUTING_CONNECTION = "connections";
|
|
||||||
public static final String ROUTING_PRIORITY = "prioritiesPeople";
|
|
||||||
public static final String ROUTING_MASTER_GENERAL = "generalList";
|
|
||||||
public static final String ROUTING_MASTER_INPUT = "inputList";
|
|
||||||
public static final String ROUTING_MASTER_OUTPUT = "outputList";
|
|
||||||
|
|
||||||
public static final String GHOST_STACK_SIZE = "stackSize";
|
|
||||||
|
|
||||||
public static final String ITEM_INVENTORY = "itemInventory";
|
|
||||||
|
|
||||||
public static final String BLOCKPOS_CONNECTION = "connections";
|
|
||||||
|
|
||||||
public static final String CURRENT_SIGIL = "currentSigil";
|
|
||||||
public static final String MOST_SIG = "mostSig";
|
|
||||||
public static final String LEAST_SIG = "leastSig";
|
|
||||||
public static final String COLOR = "color";
|
|
||||||
|
|
||||||
public static final String POTION_AUGMENT_LENGHT = "length:";
|
|
||||||
public static final String POTION_AUGMENT_STRENGTH = "strength:";
|
|
||||||
public static final String POTION_IMPURITY = "impurity";
|
|
||||||
|
|
||||||
public static final String TANK = "tank";
|
|
||||||
|
|
||||||
public static final String BREATH = "breath";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class JSON
|
|
||||||
{
|
|
||||||
public static final String INPUT = "input";
|
|
||||||
public static final String TOOL = "tool";
|
|
||||||
public static final String BASEINPUT = "baseinput";
|
|
||||||
public static final String ADDEDINPUT = "addedinput";
|
|
||||||
public static final String ADDEDOUTPUT = "addedoutput";
|
|
||||||
public static final String OUTPUT = "output";
|
|
||||||
public static final String ITEM = "item";
|
|
||||||
public static final String COUNT = "count";
|
|
||||||
public static final String NBT = "nbt";
|
|
||||||
public static final String TAG = "tag";
|
|
||||||
public static final String TYPE = "type";
|
|
||||||
public static final String TEXTURE = "texture";
|
|
||||||
public static final String CONDITIONS = "conditions";
|
|
||||||
public static final String CHANCE = "chance";
|
|
||||||
public static final String FLUID = "fluid";
|
|
||||||
public static final String AMOUNT = "amount";
|
|
||||||
public static final String INPUT_FLUID = "inputfluid";
|
|
||||||
public static final String OUTPUT_FLUID = "outputfluid";
|
|
||||||
|
|
||||||
public static final String ALTAR_TIER = Constants.NBT.ALTAR_TIER;
|
|
||||||
public static final String ALTAR_SYPHON = "altarSyphon";
|
|
||||||
public static final String ALTAR_CONSUMPTION_RATE = Constants.NBT.ALTAR_CONSUMPTION_RATE;
|
|
||||||
public static final String ALTAR_DRAIN_RATE = Constants.NBT.ALTAR_DRAIN_RATE;
|
|
||||||
|
|
||||||
public static final String TARTARIC_DRAIN = "drain";
|
|
||||||
public static final String TARTARIC_MINIMUM = "minimumDrain";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Compat
|
|
||||||
{
|
|
||||||
public static final String JEI_CATEGORY_ALTAR = "altar";
|
|
||||||
public static final String JEI_CATEGORY_BINDING = "binding";
|
|
||||||
public static final String JEI_CATEGORY_ALCHEMYARRAY = "alchemyarray";
|
|
||||||
public static final String JEI_CATEGORY_SOULFORGE = "soulforge";
|
|
||||||
public static final String JEI_CATEGORY_ALCHEMYTABLE = "alchemytable";
|
|
||||||
public static final String JEI_CATEGORY_ARMOURDOWNGRADE = "armourdowngrade";
|
|
||||||
|
|
||||||
public static final String WAILA_CONFIG_ALTAR = BloodMagic.MODID + ".bloodaltar";
|
|
||||||
public static final String WAILA_CONFIG_TELEPOSER = BloodMagic.MODID + ".teleposer";
|
|
||||||
public static final String WAILA_CONFIG_RITUAL = BloodMagic.MODID + ".ritualController";
|
|
||||||
public static final String WAILA_CONFIG_ARRAY = BloodMagic.MODID + ".array";
|
|
||||||
public static final String WAILA_CONFIG_BLOOD_TANK = BloodMagic.MODID + ".bloodTank";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util;
|
|
||||||
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.util.DamageSource;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
|
||||||
|
|
||||||
public class DamageSourceBloodMagic extends DamageSource
|
|
||||||
{
|
|
||||||
public static final DamageSourceBloodMagic INSTANCE = new DamageSourceBloodMagic();
|
|
||||||
|
|
||||||
public DamageSourceBloodMagic()
|
|
||||||
{
|
|
||||||
super("bloodMagic");
|
|
||||||
|
|
||||||
setDamageBypassesArmor();
|
|
||||||
setDamageIsAbsolute();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ITextComponent getDeathMessage(LivingEntity livingBase)
|
|
||||||
{
|
|
||||||
return new TranslationTextComponent("chat.bloodmagic.damageSource", livingBase.getName());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,448 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.Blocks;
|
|
||||||
import net.minecraft.block.FlowingFluidBlock;
|
|
||||||
import net.minecraft.block.NetherPortalBlock;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.inventory.IInventory;
|
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.potion.Effects;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.SoundCategory;
|
|
||||||
import net.minecraft.util.SoundEvents;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.util.LazyOptional;
|
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
import net.minecraftforge.items.IItemHandler;
|
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
|
||||||
import wayoftime.bloodmagic.tile.TileInventory;
|
|
||||||
|
|
||||||
public class Utils
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @param tile - The {@link TileInventory} to input the item to
|
|
||||||
* @param player - The player to take the item from.
|
|
||||||
* @return {@code true} if the ItemStack is inserted, {@code false} otherwise
|
|
||||||
* @see #insertItemToTile(TileInventory, PlayerEntity, int)
|
|
||||||
*/
|
|
||||||
public static boolean insertItemToTile(TileInventory tile, PlayerEntity player)
|
|
||||||
{
|
|
||||||
return insertItemToTile(tile, player, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for inserting an ItemStack with a stacksize of 1 to a tile's inventory
|
|
||||||
* at slot 0
|
|
||||||
* <p/>
|
|
||||||
* EG: Block Altar
|
|
||||||
*
|
|
||||||
* @param tile - The {@link TileInventory} to input the item to
|
|
||||||
* @param player - The player to take the item from.
|
|
||||||
* @param slot - The slot to attempt to insert to
|
|
||||||
* @return {@code true} if the ItemStack is inserted, {@code false} otherwise
|
|
||||||
*/
|
|
||||||
public static boolean insertItemToTile(TileInventory tile, PlayerEntity player, int slot)
|
|
||||||
{
|
|
||||||
ItemStack slotStack = tile.getStackInSlot(slot);
|
|
||||||
if (slotStack.isEmpty() && !player.getHeldItemMainhand().isEmpty())
|
|
||||||
{
|
|
||||||
ItemStack input = player.getHeldItemMainhand().copy();
|
|
||||||
input.setCount(1);
|
|
||||||
player.getHeldItemMainhand().shrink(1);
|
|
||||||
tile.setInventorySlotContents(slot, input);
|
|
||||||
return true;
|
|
||||||
} else if (!slotStack.isEmpty() && player.getHeldItemMainhand().isEmpty())
|
|
||||||
{
|
|
||||||
ItemHandlerHelper.giveItemToPlayer(player, slotStack);
|
|
||||||
tile.clear();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toFancyCasing(String input)
|
|
||||||
{
|
|
||||||
return String.valueOf(input.charAt(0)).toUpperCase(Locale.ENGLISH) + input.substring(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isImmuneToFireDamage(LivingEntity entity)
|
|
||||||
{
|
|
||||||
return entity.isImmuneToFire() || entity.isPotionActive(Effects.FIRE_RESISTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isBlockLiquid(BlockState state)
|
|
||||||
{
|
|
||||||
return (state instanceof IFluidBlock || state.getMaterial().isLiquid());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isFlowingLiquid(World world, BlockPos pos, BlockState state)
|
|
||||||
{
|
|
||||||
Block block = state.getBlock();
|
|
||||||
return ((block instanceof IFluidBlock && Math.abs(((IFluidBlock) block).getFilledPercentage(world, pos)) == 1)
|
|
||||||
|| (block instanceof FlowingFluidBlock
|
|
||||||
&& !((FlowingFluidBlock) block).getFluidState(state).isSource()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean spawnStackAtBlock(World world, BlockPos pos, @Nullable Direction pushDirection, ItemStack stack)
|
|
||||||
{
|
|
||||||
BlockPos spawnPos = new BlockPos(pos);
|
|
||||||
|
|
||||||
double velX = 0;
|
|
||||||
double velY = 0;
|
|
||||||
double velZ = 0;
|
|
||||||
double velocity = 0.15D;
|
|
||||||
if (pushDirection != null)
|
|
||||||
{
|
|
||||||
spawnPos = spawnPos.offset(pushDirection);
|
|
||||||
|
|
||||||
switch (pushDirection)
|
|
||||||
{
|
|
||||||
case DOWN:
|
|
||||||
{
|
|
||||||
velY = -velocity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UP:
|
|
||||||
{
|
|
||||||
velY = velocity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case NORTH:
|
|
||||||
{
|
|
||||||
velZ = -velocity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SOUTH:
|
|
||||||
{
|
|
||||||
velZ = velocity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WEST:
|
|
||||||
{
|
|
||||||
velX = -velocity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case EAST:
|
|
||||||
{
|
|
||||||
velX = velocity;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double posX = spawnPos.getX() + 0.5;
|
|
||||||
double posY = spawnPos.getY() + 0.5;
|
|
||||||
double posZ = spawnPos.getZ() + 0.5;
|
|
||||||
|
|
||||||
ItemEntity entityItem = new ItemEntity(world, posX, posY, posZ, stack);
|
|
||||||
entityItem.setMotion(velX, velY, velZ);
|
|
||||||
|
|
||||||
entityItem.setItem(stack);
|
|
||||||
return world.addEntity(entityItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean swapLocations(World initialWorld, BlockPos initialPos, World finalWorld, BlockPos finalPos)
|
|
||||||
{
|
|
||||||
return swapLocations(initialWorld, initialPos, finalWorld, finalPos, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean swapLocations(World initialWorld, BlockPos initialPos, World finalWorld, BlockPos finalPos, boolean playSound)
|
|
||||||
{
|
|
||||||
TileEntity initialTile = initialWorld.getTileEntity(initialPos);
|
|
||||||
TileEntity finalTile = finalWorld.getTileEntity(finalPos);
|
|
||||||
CompoundNBT initialTag = new CompoundNBT();
|
|
||||||
CompoundNBT finalTag = new CompoundNBT();
|
|
||||||
if (initialTile != null)
|
|
||||||
initialTile.write(initialTag);
|
|
||||||
if (finalTile != null)
|
|
||||||
finalTile.write(finalTag);
|
|
||||||
|
|
||||||
BlockState initialState = initialWorld.getBlockState(initialPos);
|
|
||||||
BlockState finalState = finalWorld.getBlockState(finalPos);
|
|
||||||
|
|
||||||
if ((initialState.getBlock().equals(Blocks.AIR) && finalState.getBlock().equals(Blocks.AIR))
|
|
||||||
|| initialState.getBlock() instanceof NetherPortalBlock
|
|
||||||
|| finalState.getBlock() instanceof NetherPortalBlock)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (playSound)
|
|
||||||
{
|
|
||||||
initialWorld.playSound(initialPos.getX(), initialPos.getY(), initialPos.getZ(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false);
|
|
||||||
finalWorld.playSound(finalPos.getX(), finalPos.getY(), finalPos.getZ(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally, we get to do something! (CLEARING TILES)
|
|
||||||
if (finalState.getBlock().hasTileEntity(finalState))
|
|
||||||
finalWorld.removeTileEntity(finalPos);
|
|
||||||
if (initialState.getBlock().hasTileEntity(initialState))
|
|
||||||
initialWorld.removeTileEntity(initialPos);
|
|
||||||
|
|
||||||
// TILES CLEARED
|
|
||||||
BlockState initialBlockState = initialWorld.getBlockState(initialPos);
|
|
||||||
BlockState finalBlockState = finalWorld.getBlockState(finalPos);
|
|
||||||
finalWorld.setBlockState(finalPos, initialBlockState, 3);
|
|
||||||
|
|
||||||
if (initialTile != null)
|
|
||||||
{
|
|
||||||
// TileEntity newTileInitial = TileEntity.create(finalWorld, initialTag);
|
|
||||||
TileEntity newTileInitial = TileEntity.readTileEntity(finalBlockState, initialTag);
|
|
||||||
|
|
||||||
finalWorld.setTileEntity(finalPos, newTileInitial);
|
|
||||||
// newTileInitial.setPos(finalPos);
|
|
||||||
newTileInitial.setWorldAndPos(finalWorld, finalPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
initialWorld.setBlockState(initialPos, finalBlockState, 3);
|
|
||||||
|
|
||||||
if (finalTile != null)
|
|
||||||
{
|
|
||||||
// TileEntity newTileFinal = TileEntity.create(initialWorld, finalTag);
|
|
||||||
TileEntity newTileFinal = TileEntity.readTileEntity(initialBlockState, finalTag);
|
|
||||||
|
|
||||||
initialWorld.setTileEntity(initialPos, newTileFinal);
|
|
||||||
// newTileFinal.setPos(initialPos);
|
|
||||||
newTileFinal.setWorldAndPos(initialWorld, initialPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
initialWorld.notifyNeighborsOfStateChange(initialPos, finalState.getBlock());
|
|
||||||
finalWorld.notifyNeighborsOfStateChange(finalPos, initialState.getBlock());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack insertStackIntoTile(ItemStack stack, TileEntity tile, Direction dir)
|
|
||||||
{
|
|
||||||
LazyOptional<IItemHandler> capability = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir);
|
|
||||||
if (capability.isPresent())
|
|
||||||
{
|
|
||||||
IItemHandler handler = capability.resolve().get();
|
|
||||||
|
|
||||||
return insertStackIntoTile(stack, handler);
|
|
||||||
} else if (tile instanceof IInventory)
|
|
||||||
{
|
|
||||||
return insertStackIntoInventory(stack, (IInventory) tile, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack insertStackIntoTile(ItemStack stack, IItemHandler handler)
|
|
||||||
{
|
|
||||||
int numberOfSlots = handler.getSlots();
|
|
||||||
|
|
||||||
ItemStack copyStack = stack.copy();
|
|
||||||
|
|
||||||
for (int slot = 0; slot < numberOfSlots; slot++)
|
|
||||||
{
|
|
||||||
copyStack = handler.insertItem(slot, copyStack, false);
|
|
||||||
if (copyStack.isEmpty())
|
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return copyStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getNumberOfFreeSlots(TileEntity tile, Direction dir)
|
|
||||||
{
|
|
||||||
int slots = 0;
|
|
||||||
|
|
||||||
LazyOptional<IItemHandler> capability = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir);
|
|
||||||
if (capability.isPresent())
|
|
||||||
{
|
|
||||||
IItemHandler handler = capability.resolve().get();
|
|
||||||
|
|
||||||
for (int i = 0; i < handler.getSlots(); i++)
|
|
||||||
{
|
|
||||||
if (handler.getStackInSlot(i).isEmpty())
|
|
||||||
{
|
|
||||||
slots++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (tile instanceof IInventory)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ((IInventory) tile).getSizeInventory(); i++)
|
|
||||||
{
|
|
||||||
if (((IInventory) tile).getStackInSlot(i).isEmpty())
|
|
||||||
{
|
|
||||||
slots++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return slots;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack insertStackIntoInventory(ItemStack stack, IInventory inventory, Direction dir)
|
|
||||||
{
|
|
||||||
if (stack.isEmpty())
|
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean[] canBeInserted = new boolean[inventory.getSizeInventory()];
|
|
||||||
|
|
||||||
if (inventory instanceof ISidedInventory)
|
|
||||||
{
|
|
||||||
int[] array = ((ISidedInventory) inventory).getSlotsForFace(dir);
|
|
||||||
for (int in : array)
|
|
||||||
{
|
|
||||||
canBeInserted[in] = inventory.isItemValidForSlot(in, stack)
|
|
||||||
&& ((ISidedInventory) inventory).canInsertItem(in, stack, dir);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
for (int i = 0; i < canBeInserted.length; i++)
|
|
||||||
{
|
|
||||||
canBeInserted[i] = inventory.isItemValidForSlot(i, stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
|
||||||
{
|
|
||||||
if (!canBeInserted[i])
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack[] combinedStacks = combineStacks(stack, inventory.getStackInSlot(i));
|
|
||||||
stack = combinedStacks[0];
|
|
||||||
inventory.setInventorySlotContents(i, combinedStacks[1]);
|
|
||||||
|
|
||||||
if (stack.isEmpty())
|
|
||||||
{
|
|
||||||
return ItemStack.EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canInsertStackFullyIntoInventory(ItemStack stack, IInventory inventory, Direction dir, boolean fillToLimit, int limit)
|
|
||||||
{
|
|
||||||
if (stack.isEmpty())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int itemsLeft = stack.getCount();
|
|
||||||
|
|
||||||
boolean[] canBeInserted = new boolean[inventory.getSizeInventory()];
|
|
||||||
|
|
||||||
if (inventory instanceof ISidedInventory)
|
|
||||||
{
|
|
||||||
int[] array = ((ISidedInventory) inventory).getSlotsForFace(dir);
|
|
||||||
for (int in : array)
|
|
||||||
{
|
|
||||||
canBeInserted[in] = inventory.isItemValidForSlot(in, stack)
|
|
||||||
&& ((ISidedInventory) inventory).canInsertItem(in, stack, dir);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
for (int i = 0; i < canBeInserted.length; i++)
|
|
||||||
{
|
|
||||||
canBeInserted[i] = inventory.isItemValidForSlot(i, stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int numberMatching = 0;
|
|
||||||
|
|
||||||
if (fillToLimit)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
|
||||||
{
|
|
||||||
if (!canBeInserted[i])
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack invStack = inventory.getStackInSlot(i);
|
|
||||||
|
|
||||||
if (!invStack.isEmpty() && ItemHandlerHelper.canItemStacksStack(stack, invStack))
|
|
||||||
{
|
|
||||||
numberMatching += invStack.getCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fillToLimit && limit < stack.getCount() + numberMatching)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
|
||||||
{
|
|
||||||
if (!canBeInserted[i])
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemStack invStack = inventory.getStackInSlot(i);
|
|
||||||
boolean canCombine = ItemHandlerHelper.canItemStacksStack(stack, invStack);
|
|
||||||
if (canCombine)
|
|
||||||
{
|
|
||||||
if (invStack.isEmpty())
|
|
||||||
{
|
|
||||||
itemsLeft = 0;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
itemsLeft -= (invStack.getMaxStackSize() - invStack.getCount());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemsLeft <= 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param stack1 Stack that is placed into a slot
|
|
||||||
* @param stack2 Slot content that stack1 is placed into
|
|
||||||
* @return Stacks after stacking
|
|
||||||
*/
|
|
||||||
public static ItemStack[] combineStacks(ItemStack stack1, ItemStack stack2)
|
|
||||||
{
|
|
||||||
ItemStack[] returned = new ItemStack[2];
|
|
||||||
|
|
||||||
if (ItemHandlerHelper.canItemStacksStack(stack1, stack2))
|
|
||||||
{
|
|
||||||
int transferedAmount = stack2.isEmpty() ? stack1.getCount()
|
|
||||||
: Math.min(stack2.getMaxStackSize() - stack2.getCount(), stack1.getCount());
|
|
||||||
if (transferedAmount > 0)
|
|
||||||
{
|
|
||||||
ItemStack copyStack = stack1.split(transferedAmount);
|
|
||||||
if (stack2.isEmpty())
|
|
||||||
{
|
|
||||||
stack2 = copyStack;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
stack2.grow(transferedAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
returned[0] = stack1;
|
|
||||||
returned[1] = stack2;
|
|
||||||
|
|
||||||
return returned;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,73 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util.handler.event;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
import wayoftime.bloodmagic.core.data.Binding;
|
|
||||||
import wayoftime.bloodmagic.core.data.SoulNetwork;
|
|
||||||
import wayoftime.bloodmagic.event.ItemBindEvent;
|
|
||||||
import wayoftime.bloodmagic.iface.IBindable;
|
|
||||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
|
||||||
import wayoftime.bloodmagic.orb.IBloodOrb;
|
|
||||||
import wayoftime.bloodmagic.util.helper.BindableHelper;
|
|
||||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
|
||||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
||||||
public class GenericHandler
|
|
||||||
{
|
|
||||||
// Handles binding of IBindable's as well as setting a player's highest orb tier
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onInteract(PlayerInteractEvent.RightClickItem event)
|
|
||||||
{
|
|
||||||
if (event.getWorld().isRemote)
|
|
||||||
return;
|
|
||||||
|
|
||||||
PlayerEntity player = event.getPlayer();
|
|
||||||
|
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ItemStack held = event.getItemStack();
|
|
||||||
if (!held.isEmpty() && held.getItem() instanceof IBindable)
|
|
||||||
{ // Make sure it's bindable
|
|
||||||
IBindable bindable = (IBindable) held.getItem();
|
|
||||||
Binding binding = bindable.getBinding(held);
|
|
||||||
if (binding == null)
|
|
||||||
{ // If the binding is null, let's create one
|
|
||||||
if (bindable.onBind(player, held))
|
|
||||||
{
|
|
||||||
ItemBindEvent toPost = new ItemBindEvent(player, held);
|
|
||||||
if (MinecraftForge.EVENT_BUS.post(toPost)) // Allow cancellation of binding
|
|
||||||
return;
|
|
||||||
|
|
||||||
BindableHelper.applyBinding(held, player); // Bind item to the player
|
|
||||||
}
|
|
||||||
// If the binding exists, we'll check if the player's name has changed since
|
|
||||||
// they last used it and update that if so.
|
|
||||||
} else if (binding.getOwnerId().equals(player.getGameProfile().getId())
|
|
||||||
&& !binding.getOwnerName().equals(player.getGameProfile().getName()))
|
|
||||||
{
|
|
||||||
binding.setOwnerName(player.getGameProfile().getName());
|
|
||||||
BindableHelper.applyBinding(held, binding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!held.isEmpty() && held.getItem() instanceof IBloodOrb)
|
|
||||||
{
|
|
||||||
IBloodOrb bloodOrb = (IBloodOrb) held.getItem();
|
|
||||||
SoulNetwork network = NetworkHelper.getSoulNetwork(player);
|
|
||||||
|
|
||||||
BloodOrb orb = bloodOrb.getOrb(held);
|
|
||||||
if (orb == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (orb.getTier() > network.getOrbTier())
|
|
||||||
network.setOrbTier(orb.getTier());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,115 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util.handler.event;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.MobEntity;
|
|
||||||
import net.minecraft.entity.item.ItemEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.potion.EffectInstance;
|
|
||||||
import net.minecraft.util.DamageSource;
|
|
||||||
import net.minecraft.world.Difficulty;
|
|
||||||
import net.minecraftforge.event.entity.living.LivingDropsEvent;
|
|
||||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
|
||||||
import wayoftime.bloodmagic.potion.BloodMagicPotions;
|
|
||||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
|
||||||
import wayoftime.bloodmagic.will.IDemonWill;
|
|
||||||
import wayoftime.bloodmagic.will.IDemonWillWeapon;
|
|
||||||
import wayoftime.bloodmagic.will.PlayerDemonWillHandler;
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
|
||||||
public class WillHandler
|
|
||||||
{
|
|
||||||
private static final HashMap<Integer, Integer> SERVER_TICKS = new HashMap<>();
|
|
||||||
|
|
||||||
// Adds Will to player
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onItemPickup(EntityItemPickupEvent event)
|
|
||||||
{
|
|
||||||
ItemStack stack = event.getItem().getItem();
|
|
||||||
if (stack.getItem() instanceof IDemonWill)
|
|
||||||
{
|
|
||||||
PlayerEntity player = event.getPlayer();
|
|
||||||
EnumDemonWillType pickupType = ((IDemonWill) stack.getItem()).getType(stack);
|
|
||||||
ItemStack remainder = PlayerDemonWillHandler.addDemonWill(player, stack);
|
|
||||||
|
|
||||||
if (remainder == null || ((IDemonWill) stack.getItem()).getWill(pickupType, stack) < 0.0001
|
|
||||||
|| PlayerDemonWillHandler.isDemonWillFull(pickupType, player))
|
|
||||||
{
|
|
||||||
stack.setCount(0);
|
|
||||||
event.setResult(Event.Result.ALLOW);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void onEntityAttacked(LivingDeathEvent event)
|
|
||||||
// {
|
|
||||||
// if (event.getSource() instanceof EntityDamageSourceIndirect)
|
|
||||||
// {
|
|
||||||
// Entity sourceEntity = event.getSource().getImmediateSource();
|
|
||||||
//
|
|
||||||
// if (sourceEntity instanceof EntitySentientArrow)
|
|
||||||
// {
|
|
||||||
// ((EntitySentientArrow) sourceEntity).reimbursePlayer(event.getEntityLiving(), event.getEntityLiving().getMaxHealth());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Add/Drop Demon Will for Player
|
|
||||||
@SubscribeEvent
|
|
||||||
public void onLivingDrops(LivingDropsEvent event)
|
|
||||||
{
|
|
||||||
LivingEntity attackedEntity = event.getEntityLiving();
|
|
||||||
DamageSource source = event.getSource();
|
|
||||||
Entity entity = source.getTrueSource();
|
|
||||||
|
|
||||||
if (attackedEntity.isPotionActive(BloodMagicPotions.SOUL_SNARE) && (attackedEntity instanceof MobEntity
|
|
||||||
|| attackedEntity.getEntityWorld().getDifficulty() == Difficulty.PEACEFUL))
|
|
||||||
{
|
|
||||||
EffectInstance eff = attackedEntity.getActivePotionEffect(BloodMagicPotions.SOUL_SNARE);
|
|
||||||
int lvl = eff.getAmplifier();
|
|
||||||
|
|
||||||
double amountOfSouls = attackedEntity.getEntityWorld().rand.nextDouble() * (lvl + 1) * (lvl + 1) * 4 + 1;
|
|
||||||
ItemStack soulStack = ((IDemonWill) BloodMagicItems.MONSTER_SOUL_RAW.get()).createWill(amountOfSouls);
|
|
||||||
event.getDrops().add(new ItemEntity(attackedEntity.getEntityWorld(), attackedEntity.getPosX(), attackedEntity.getPosY(), attackedEntity.getPosZ(), soulStack));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity != null && entity instanceof PlayerEntity)
|
|
||||||
{
|
|
||||||
PlayerEntity player = (PlayerEntity) entity;
|
|
||||||
ItemStack heldStack = player.getHeldItemMainhand();
|
|
||||||
if (heldStack.getItem() instanceof IDemonWillWeapon && !player.getEntityWorld().isRemote)
|
|
||||||
{
|
|
||||||
IDemonWillWeapon demonWillWeapon = (IDemonWillWeapon) heldStack.getItem();
|
|
||||||
List<ItemStack> droppedSouls = demonWillWeapon.getRandomDemonWillDrop(attackedEntity, player, heldStack, event.getLootingLevel());
|
|
||||||
if (!droppedSouls.isEmpty())
|
|
||||||
{
|
|
||||||
ItemStack remainder;
|
|
||||||
for (ItemStack willStack : droppedSouls)
|
|
||||||
{
|
|
||||||
remainder = PlayerDemonWillHandler.addDemonWill(player, willStack);
|
|
||||||
|
|
||||||
if (!remainder.isEmpty())
|
|
||||||
{
|
|
||||||
EnumDemonWillType pickupType = ((IDemonWill) remainder.getItem()).getType(remainder);
|
|
||||||
if (((IDemonWill) remainder.getItem()).getWill(pickupType, remainder) >= 0.0001)
|
|
||||||
{
|
|
||||||
event.getDrops().add(new ItemEntity(attackedEntity.getEntityWorld(), attackedEntity.getPosX(), attackedEntity.getPosY(), attackedEntity.getPosZ(), remainder));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.container.detectAndSendChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util.helper;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import wayoftime.bloodmagic.core.data.Binding;
|
|
||||||
import wayoftime.bloodmagic.event.ItemBindEvent;
|
|
||||||
import wayoftime.bloodmagic.util.Constants;
|
|
||||||
|
|
||||||
public class BindableHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
public static void applyBinding(ItemStack stack, PlayerEntity player)
|
|
||||||
{
|
|
||||||
Binding binding = new Binding(player.getGameProfile().getId(), player.getGameProfile().getName());
|
|
||||||
applyBinding(stack, binding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void applyBinding(ItemStack stack, Binding binding)
|
|
||||||
{
|
|
||||||
if (!stack.hasTag())
|
|
||||||
stack.setTag(new CompoundNBT());
|
|
||||||
|
|
||||||
stack.getTag().put("binding", binding.serializeNBT());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Owner Name of the item without checking if it is already bound. Also
|
|
||||||
* bypasses {@link ItemBindEvent}.
|
|
||||||
*
|
|
||||||
* @param stack - The ItemStack to bind
|
|
||||||
* @param ownerName - The username to bind the ItemStack to
|
|
||||||
*/
|
|
||||||
public static void setItemOwnerName(ItemStack stack, String ownerName)
|
|
||||||
{
|
|
||||||
stack = NBTHelper.checkNBT(stack);
|
|
||||||
|
|
||||||
stack.getTag().putString(Constants.NBT.OWNER_NAME, ownerName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Owner UUID of the item without checking if it is already bound. Also
|
|
||||||
* bypasses {@link ItemBindEvent}.
|
|
||||||
*
|
|
||||||
* @param stack - The ItemStack to bind
|
|
||||||
* @param ownerUUID - The UUID to bind the ItemStack to
|
|
||||||
*/
|
|
||||||
public static void setItemOwnerUUID(ItemStack stack, String ownerUUID)
|
|
||||||
{
|
|
||||||
stack = NBTHelper.checkNBT(stack);
|
|
||||||
|
|
||||||
stack.getTag().putString(Constants.NBT.OWNER_UUID, ownerUUID);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util.helper;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
|
|
||||||
public class NBTHelper
|
|
||||||
{
|
|
||||||
public static ItemStack checkNBT(ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.getTag() == null)
|
|
||||||
stack.setTag(new CompoundNBT());
|
|
||||||
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,180 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util.helper;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.world.storage.DimensionSavedDataManager;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
|
||||||
import wayoftime.bloodmagic.core.data.BMWorldSavedData;
|
|
||||||
import wayoftime.bloodmagic.core.data.Binding;
|
|
||||||
import wayoftime.bloodmagic.core.data.SoulNetwork;
|
|
||||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
|
||||||
import wayoftime.bloodmagic.core.registry.OrbRegistry;
|
|
||||||
import wayoftime.bloodmagic.event.SoulNetworkEvent;
|
|
||||||
import wayoftime.bloodmagic.iface.IBindable;
|
|
||||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
|
||||||
import wayoftime.bloodmagic.orb.IBloodOrb;
|
|
||||||
|
|
||||||
public class NetworkHelper
|
|
||||||
{
|
|
||||||
@Nullable
|
|
||||||
private static BMWorldSavedData dataHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the SoulNetwork for the player.
|
|
||||||
*
|
|
||||||
* @param uuid - The UUID of the SoulNetwork owner - this is UUID.toString().
|
|
||||||
* @return - The SoulNetwork for the given name.
|
|
||||||
*/
|
|
||||||
public static SoulNetwork getSoulNetwork(String uuid)
|
|
||||||
{
|
|
||||||
if (dataHandler == null)
|
|
||||||
{
|
|
||||||
if (ServerLifecycleHooks.getCurrentServer() == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
DimensionSavedDataManager savedData = ServerLifecycleHooks.getCurrentServer().func_241755_D_().getSavedData();
|
|
||||||
dataHandler = savedData.getOrCreate(() -> new BMWorldSavedData(), BMWorldSavedData.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dataHandler.getNetwork(UUID.fromString(uuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param uuid - The Player's Mojang UUID
|
|
||||||
* @see NetworkHelper#getSoulNetwork(String)
|
|
||||||
*/
|
|
||||||
public static SoulNetwork getSoulNetwork(UUID uuid)
|
|
||||||
{
|
|
||||||
return getSoulNetwork(uuid.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player - The Player
|
|
||||||
* @see NetworkHelper#getSoulNetwork(String)
|
|
||||||
*/
|
|
||||||
public static SoulNetwork getSoulNetwork(PlayerEntity player)
|
|
||||||
{
|
|
||||||
return getSoulNetwork(PlayerHelper.getUUIDFromPlayer(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoulNetwork getSoulNetwork(Binding binding)
|
|
||||||
{
|
|
||||||
return getSoulNetwork(binding.getOwnerId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current orb tier of the SoulNetwork.
|
|
||||||
*
|
|
||||||
* @param soulNetwork - SoulNetwork to get the tier of.
|
|
||||||
* @return - The Orb tier of the given SoulNetwork
|
|
||||||
*/
|
|
||||||
public static int getCurrentMaxOrb(SoulNetwork soulNetwork)
|
|
||||||
{
|
|
||||||
return soulNetwork.getOrbTier();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMaximumForTier(int tier)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (tier > OrbRegistry.getTierMap().size() || tier < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
for (ItemStack orbStack : OrbRegistry.getOrbsForTier(tier))
|
|
||||||
{
|
|
||||||
BloodOrb orb = ((IBloodOrb) orbStack.getItem()).getOrb(orbStack);
|
|
||||||
if (orb.getCapacity() > ret)
|
|
||||||
ret = orb.getCapacity();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Syphon
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Syphons from the player and damages them if there was not enough stored LP.
|
|
||||||
* <p>
|
|
||||||
* Handles null-checking the player for you.
|
|
||||||
*
|
|
||||||
* @param soulNetwork - SoulNetwork to syphon from
|
|
||||||
* @param user - User of the item.
|
|
||||||
* @param toSyphon - Amount of LP to syphon
|
|
||||||
* @return - Whether the action should be performed.
|
|
||||||
* @deprecated Use {@link #getSoulNetwork(PlayerEntity)} and
|
|
||||||
* {@link SoulNetwork#syphonAndDamage$(PlayerEntity, SoulTicket)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static boolean syphonAndDamage(SoulNetwork soulNetwork, PlayerEntity user, int toSyphon)
|
|
||||||
{
|
|
||||||
|
|
||||||
// if (soulNetwork.getNewOwner() == null)
|
|
||||||
// {
|
|
||||||
// soulNetwork.syphon(toSyphon);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
return soulNetwork.syphonAndDamage(user, toSyphon);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Syphons a player from within a container.
|
|
||||||
*
|
|
||||||
* @param stack - ItemStack in the Container.
|
|
||||||
* @param ticket - SoulTicket to syphon
|
|
||||||
* @return - If the syphon was successful.
|
|
||||||
*/
|
|
||||||
public static boolean syphonFromContainer(ItemStack stack, SoulTicket ticket)
|
|
||||||
{
|
|
||||||
if (!(stack.getItem() instanceof IBindable))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Binding binding = ((IBindable) stack.getItem()).getBinding(stack);
|
|
||||||
if (binding == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SoulNetwork network = getSoulNetwork(binding);
|
|
||||||
SoulNetworkEvent.Syphon.Item event = new SoulNetworkEvent.Syphon.Item(network, ticket, stack);
|
|
||||||
|
|
||||||
return !MinecraftForge.EVENT_BUS.post(event) && network.syphon(event.getTicket(), true) >= ticket.getAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the ItemStack has a user to be syphoned from.
|
|
||||||
*
|
|
||||||
* @param stack - ItemStack to check
|
|
||||||
* @param toSyphon - Amount of LP to syphon
|
|
||||||
* @return - If syphoning is possible
|
|
||||||
*/
|
|
||||||
public static boolean canSyphonFromContainer(ItemStack stack, int toSyphon)
|
|
||||||
{
|
|
||||||
if (!(stack.getItem() instanceof IBindable))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Binding binding = ((IBindable) stack.getItem()).getBinding(stack);
|
|
||||||
if (binding == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
SoulNetwork network = getSoulNetwork(binding);
|
|
||||||
return network.getCurrentEssence() >= toSyphon;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the orb tier of the SoulNetwork to the given orb. Will not set if the
|
|
||||||
* given tier is lower than the current tier.
|
|
||||||
*
|
|
||||||
* @param soulNetwork - SoulNetwork to set the orb tier of
|
|
||||||
* @param maxOrb - Tier of orb to set to
|
|
||||||
*/
|
|
||||||
public static void setMaxOrb(SoulNetwork soulNetwork, int maxOrb)
|
|
||||||
{
|
|
||||||
soulNetwork.setOrbTier(Math.max(maxOrb, soulNetwork.getOrbTier()));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util.helper;
|
|
||||||
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
public class NumeralHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final TreeMap<Integer, String> romanNumerals = new TreeMap<Integer, String>();
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
romanNumerals.put(1000, "M");
|
|
||||||
romanNumerals.put(900, "CM");
|
|
||||||
romanNumerals.put(500, "D");
|
|
||||||
romanNumerals.put(400, "CD");
|
|
||||||
romanNumerals.put(100, "C");
|
|
||||||
romanNumerals.put(90, "XC");
|
|
||||||
romanNumerals.put(50, "L");
|
|
||||||
romanNumerals.put(40, "XL");
|
|
||||||
romanNumerals.put(10, "X");
|
|
||||||
romanNumerals.put(9, "IX");
|
|
||||||
romanNumerals.put(5, "V");
|
|
||||||
romanNumerals.put(4, "IV");
|
|
||||||
romanNumerals.put(1, "I");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toRoman(int arabic)
|
|
||||||
{
|
|
||||||
int convert = romanNumerals.floorKey(arabic);
|
|
||||||
if (arabic == convert)
|
|
||||||
return romanNumerals.get(convert);
|
|
||||||
|
|
||||||
return romanNumerals.get(convert) + toRoman(arabic - convert);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util.helper;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraftforge.common.UsernameCache;
|
|
||||||
import net.minecraftforge.common.util.FakePlayer;
|
|
||||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
|
||||||
|
|
||||||
public class PlayerHelper
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A list of all known fake players that do not extend FakePlayer.
|
|
||||||
* <p>
|
|
||||||
* Will be added to as needed.
|
|
||||||
*/
|
|
||||||
private static final ArrayList<String> knownFakePlayers = Lists.newArrayList();
|
|
||||||
|
|
||||||
public static PlayerEntity getPlayerFromId(UUID uuid)
|
|
||||||
{
|
|
||||||
// TODO: Need to find a reliable way to get whether the side is Client or Server
|
|
||||||
// if (FMLCommonHandler.instance().)
|
|
||||||
// return null;
|
|
||||||
//
|
|
||||||
// World w;
|
|
||||||
// Dist d;
|
|
||||||
//
|
|
||||||
// if(ServerLifecycleHooks.getCurrentServer().get)
|
|
||||||
|
|
||||||
return ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayerByUUID(uuid);
|
|
||||||
|
|
||||||
// return FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerEntity getPlayerFromUUID(UUID uuid)
|
|
||||||
{
|
|
||||||
return getPlayerFromId(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UUID getUUIDFromPlayer(PlayerEntity player)
|
|
||||||
{
|
|
||||||
return player.getGameProfile().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getUsernameFromUUID(UUID uuid)
|
|
||||||
{
|
|
||||||
return UsernameCache.getLastKnownUsername(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether or not the given player is an "actual" player
|
|
||||||
*
|
|
||||||
* @param player - The player in question
|
|
||||||
* @return If the player is fake or not
|
|
||||||
*/
|
|
||||||
public static boolean isFakePlayer(PlayerEntity player)
|
|
||||||
{
|
|
||||||
return player instanceof FakePlayer
|
|
||||||
|| (player != null && knownFakePlayers.contains(player.getClass().getCanonicalName()));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,160 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util.helper;
|
|
||||||
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.potion.Potion;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
|
||||||
import wayoftime.bloodmagic.ConfigHandler;
|
|
||||||
import wayoftime.bloodmagic.altar.IBloodAltar;
|
|
||||||
import wayoftime.bloodmagic.event.SacrificeKnifeUsedEvent;
|
|
||||||
|
|
||||||
public class PlayerSacrificeHelper
|
|
||||||
{
|
|
||||||
public static float scalingOfSacrifice = 1f;
|
|
||||||
public static int soulFrayDuration = 400;
|
|
||||||
public static Potion soulFrayId;
|
|
||||||
|
|
||||||
public static double getPlayerIncense(PlayerEntity player)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
// return IncenseHelper.getCurrentIncense(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setPlayerIncense(PlayerEntity player, double amount)
|
|
||||||
{
|
|
||||||
// IncenseHelper.setCurrentIncense(player, amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean incrementIncense(PlayerEntity player, double min, double incenseAddition, double increment)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
// double amount = getPlayerIncense(player);
|
|
||||||
// if (amount < min || amount >= incenseAddition)
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// amount = amount + Math.min(increment, incenseAddition - amount);
|
|
||||||
// setPlayerIncense(player, amount);
|
|
||||||
//
|
|
||||||
// if (amount == incenseAddition)
|
|
||||||
// {
|
|
||||||
// IncenseHelper.setMaxIncense(player, incenseAddition);
|
|
||||||
// }
|
|
||||||
// // System.out.println("Amount of incense: " + amount + ", Increment: " +
|
|
||||||
// // increment);
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sacrifices a player's health while the player is under the influence of
|
|
||||||
* incense
|
|
||||||
*
|
|
||||||
* @param player - The player sacrificing
|
|
||||||
* @return Whether or not the health sacrificing succeeded
|
|
||||||
*/
|
|
||||||
public static boolean sacrificePlayerHealth(PlayerEntity player)
|
|
||||||
{
|
|
||||||
// if (player.isPotionActive(soulFrayId))
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
double amount = getPlayerIncense(player);
|
|
||||||
|
|
||||||
if (amount >= 0)
|
|
||||||
{
|
|
||||||
float health = player.getHealth();
|
|
||||||
float maxHealth = player.getMaxHealth();
|
|
||||||
|
|
||||||
if (health > maxHealth / 10.0)
|
|
||||||
{
|
|
||||||
float sacrificedHealth = health - maxHealth / 10.0f;
|
|
||||||
int lpAdded = (int) (sacrificedHealth * ConfigHandler.values.sacrificialDaggerConversion
|
|
||||||
* getModifier(amount));
|
|
||||||
|
|
||||||
IBloodAltar altar = getAltar(player.getEntityWorld(), player.getPosition());
|
|
||||||
if (altar != null)
|
|
||||||
{
|
|
||||||
SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, (int) sacrificedHealth, lpAdded);
|
|
||||||
if (MinecraftForge.EVENT_BUS.post(evt))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
altar.sacrificialDaggerCall(evt.lpAdded, false);
|
|
||||||
altar.startCycle();
|
|
||||||
|
|
||||||
player.setHealth(maxHealth / 10.0f);
|
|
||||||
setPlayerIncense(player, 0);
|
|
||||||
// player.addPotionEffect(new PotionEffect(RegistrarBloodMagic.SOUL_FRAY, soulFrayDuration));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getModifier(double amount)
|
|
||||||
{
|
|
||||||
return 1 + amount * scalingOfSacrifice;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the nearest {@link IBloodAltar} and attempts to fill it
|
|
||||||
*
|
|
||||||
* @param world - The world
|
|
||||||
* @param sacrificingEntity - The entity having the sacrifice done on (can be
|
|
||||||
* {@link PlayerEntity} for self-sacrifice)
|
|
||||||
* @param amount - The amount of which the altar should be filled
|
|
||||||
* @param isSacrifice - Whether this is a Sacrifice or a Self-Sacrifice
|
|
||||||
* @return Whether the altar is found and (attempted) filled
|
|
||||||
*/
|
|
||||||
public static boolean findAndFillAltar(World world, LivingEntity sacrificingEntity, int amount, boolean isSacrifice)
|
|
||||||
{
|
|
||||||
IBloodAltar altarEntity = getAltar(world, sacrificingEntity.getPosition());
|
|
||||||
|
|
||||||
if (altarEntity == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
altarEntity.sacrificialDaggerCall(amount, isSacrifice);
|
|
||||||
altarEntity.startCycle();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the nearest {@link IBloodAltar}
|
|
||||||
*
|
|
||||||
* @param world - The world
|
|
||||||
* @param blockPos - The position of where the check should be in (in a 2 block
|
|
||||||
* radius from this)
|
|
||||||
* @return The nearest altar, if no altar is found, then this will return null
|
|
||||||
*/
|
|
||||||
public static IBloodAltar getAltar(World world, BlockPos blockPos)
|
|
||||||
{
|
|
||||||
TileEntity tileEntity;
|
|
||||||
|
|
||||||
for (int x = -2; x <= 2; x++)
|
|
||||||
{
|
|
||||||
for (int y = -2; y <= 1; y++)
|
|
||||||
{
|
|
||||||
for (int z = -2; z <= 2; z++)
|
|
||||||
{
|
|
||||||
tileEntity = world.getTileEntity(blockPos.add(x, y, z));
|
|
||||||
|
|
||||||
if (tileEntity instanceof IBloodAltar)
|
|
||||||
{
|
|
||||||
return (IBloodAltar) tileEntity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,77 +0,0 @@
|
||||||
package wayoftime.bloodmagic.util.helper;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
|
||||||
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
|
|
||||||
public class TextHelper
|
|
||||||
{
|
|
||||||
public static String getFormattedText(String string)
|
|
||||||
{
|
|
||||||
return string.replaceAll("&", "\u00A7");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String localize(String input, Object... format)
|
|
||||||
{
|
|
||||||
return I18n.format(input, format);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String localizeEffect(String input, Object... format)
|
|
||||||
{
|
|
||||||
return getFormattedText(localize(input, format));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] localizeAll(String[] input)
|
|
||||||
{
|
|
||||||
String[] ret = new String[input.length];
|
|
||||||
for (int i = 0; i < input.length; i++)
|
|
||||||
ret[i] = localize(input[i]);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] localizeAllEffect(String[] input)
|
|
||||||
{
|
|
||||||
String[] ret = new String[input.length];
|
|
||||||
for (int i = 0; i < input.length; i++)
|
|
||||||
ret[i] = localizeEffect(input[i]);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<String> localizeAll(List<String> input)
|
|
||||||
{
|
|
||||||
ArrayList<String> ret = new ArrayList<>(input.size());
|
|
||||||
for (int i = 0; i < input.size(); i++)
|
|
||||||
ret.add(i, localize(input.get(i)));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<String> localizeAllEffect(List<String> input)
|
|
||||||
{
|
|
||||||
ArrayList<String> ret = new ArrayList<>(input.size());
|
|
||||||
for (int i = 0; i < input.size(); i++)
|
|
||||||
ret.add(i, localizeEffect(input.get(i)));
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] cutLongString(String string, int characters)
|
|
||||||
{
|
|
||||||
return WordUtils.wrap(string, characters, "/cut", false).split("/cut");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] cutLongString(String string)
|
|
||||||
{
|
|
||||||
return cutLongString(string, 30);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean canTranslate(String key)
|
|
||||||
{
|
|
||||||
return I18n.hasKey(key);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,80 +0,0 @@
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
|
@ -1,129 +0,0 @@
|
||||||
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 com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
||||||
|
|
||||||
import net.minecraft.fluid.Fluid;
|
|
||||||
import net.minecraft.fluid.Fluids;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.ShapedRecipe;
|
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
|
||||||
import net.minecraft.nbt.JsonToNBT;
|
|
||||||
import net.minecraft.util.JSONUtils;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import net.minecraftforge.registries.ForgeRegistries;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FluidStack getFluidStack(@Nonnull JsonObject json, @Nonnull String key)
|
|
||||||
{
|
|
||||||
validateKey(json, key);
|
|
||||||
return deserializeFluid(JSONUtils.getJsonObject(json, key));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FluidStack deserializeFluid(@Nonnull JsonObject json)
|
|
||||||
{
|
|
||||||
if (!json.has(Constants.JSON.AMOUNT))
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Expected to receive a amount that is greater than zero");
|
|
||||||
}
|
|
||||||
JsonElement count = json.get(Constants.JSON.AMOUNT);
|
|
||||||
if (!JSONUtils.isNumber(count))
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Expected amount to be a number greater than zero.");
|
|
||||||
}
|
|
||||||
int amount = count.getAsJsonPrimitive().getAsInt();
|
|
||||||
if (amount < 1)
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Expected amount to be greater than zero.");
|
|
||||||
}
|
|
||||||
ResourceLocation resourceLocation = new ResourceLocation(JSONUtils.getString(json, Constants.JSON.FLUID));
|
|
||||||
Fluid fluid = ForgeRegistries.FLUIDS.getValue(resourceLocation);
|
|
||||||
if (fluid == null || fluid == Fluids.EMPTY)
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Invalid fluid type '" + resourceLocation + "'");
|
|
||||||
}
|
|
||||||
CompoundNBT nbt = null;
|
|
||||||
if (json.has(Constants.JSON.NBT))
|
|
||||||
{
|
|
||||||
JsonElement jsonNBT = json.get(Constants.JSON.NBT);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (jsonNBT.isJsonObject())
|
|
||||||
{
|
|
||||||
nbt = JsonToNBT.getTagFromJson(GSON.toJson(jsonNBT));
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
nbt = JsonToNBT.getTagFromJson(JSONUtils.getString(jsonNBT, Constants.JSON.NBT));
|
|
||||||
}
|
|
||||||
} catch (CommandSyntaxException e)
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Invalid NBT entry for fluid '" + resourceLocation + "'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new FluidStack(fluid, amount, nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JsonElement serializeFluidStack(@Nonnull FluidStack stack)
|
|
||||||
{
|
|
||||||
JsonObject json = new JsonObject();
|
|
||||||
json.addProperty(Constants.JSON.FLUID, stack.getFluid().getRegistryName().toString());
|
|
||||||
json.addProperty(Constants.JSON.AMOUNT, stack.getAmount());
|
|
||||||
if (stack.hasTag())
|
|
||||||
{
|
|
||||||
json.addProperty(Constants.JSON.NBT, stack.getTag().toString());
|
|
||||||
}
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,385 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.event.recipes;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
|
|
||||||
import net.minecraft.fluid.Fluid;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
import net.minecraft.tags.FluidTags;
|
|
||||||
import net.minecraft.tags.ITag;
|
|
||||||
import net.minecraft.tags.TagCollectionManager;
|
|
||||||
import net.minecraft.util.JSONUtils;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import wayoftime.bloodmagic.api.SerializerHelper;
|
|
||||||
import wayoftime.bloodmagic.util.Constants;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Thiakil on 12/07/2019.
|
|
||||||
*/
|
|
||||||
public abstract class FluidStackIngredient implements InputIngredient<FluidStack>
|
|
||||||
{
|
|
||||||
|
|
||||||
public static FluidStackIngredient from(@Nonnull Fluid instance, int amount)
|
|
||||||
{
|
|
||||||
return from(new FluidStack(instance, amount));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FluidStackIngredient from(@Nonnull FluidStack instance)
|
|
||||||
{
|
|
||||||
return new Single(instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FluidStackIngredient from(@Nonnull ITag<Fluid> fluidTag, int minAmount)
|
|
||||||
{
|
|
||||||
return new Tagged(fluidTag, minAmount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FluidStackIngredient read(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
// TODO: Allow supporting serialization of different types than just the ones we
|
|
||||||
// implement?
|
|
||||||
IngredientType type = buffer.readEnumValue(IngredientType.class);
|
|
||||||
if (type == IngredientType.SINGLE)
|
|
||||||
{
|
|
||||||
return Single.read(buffer);
|
|
||||||
} else if (type == IngredientType.TAGGED)
|
|
||||||
{
|
|
||||||
return Tagged.read(buffer);
|
|
||||||
}
|
|
||||||
return Multi.read(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FluidStackIngredient deserialize(@Nullable JsonElement json)
|
|
||||||
{
|
|
||||||
if (json == null || json.isJsonNull())
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Ingredient cannot be null");
|
|
||||||
}
|
|
||||||
if (json.isJsonArray())
|
|
||||||
{
|
|
||||||
JsonArray jsonArray = json.getAsJsonArray();
|
|
||||||
int size = jsonArray.size();
|
|
||||||
if (size == 0)
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Ingredient array cannot be empty, at least one ingredient must be defined");
|
|
||||||
} else if (size > 1)
|
|
||||||
{
|
|
||||||
FluidStackIngredient[] ingredients = new FluidStackIngredient[size];
|
|
||||||
for (int i = 0; i < size; i++)
|
|
||||||
{
|
|
||||||
// Read all the ingredients
|
|
||||||
ingredients[i] = deserialize(jsonArray.get(i));
|
|
||||||
}
|
|
||||||
return createMulti(ingredients);
|
|
||||||
}
|
|
||||||
// If we only have a single element, just set our json as that so that we don't
|
|
||||||
// have to use Multi for efficiency reasons
|
|
||||||
json = jsonArray.get(0);
|
|
||||||
}
|
|
||||||
if (!json.isJsonObject())
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Expected fluid to be object or array of objects");
|
|
||||||
}
|
|
||||||
JsonObject jsonObject = json.getAsJsonObject();
|
|
||||||
if (jsonObject.has(Constants.JSON.FLUID) && jsonObject.has(Constants.JSON.TAG))
|
|
||||||
{
|
|
||||||
throw new JsonParseException("An ingredient entry is either a tag or an fluid, not both");
|
|
||||||
} else if (jsonObject.has(Constants.JSON.FLUID))
|
|
||||||
{
|
|
||||||
return from(SerializerHelper.deserializeFluid(jsonObject));
|
|
||||||
} else if (jsonObject.has(Constants.JSON.TAG))
|
|
||||||
{
|
|
||||||
if (!jsonObject.has(Constants.JSON.AMOUNT))
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Expected to receive a amount that is greater than zero");
|
|
||||||
}
|
|
||||||
JsonElement count = jsonObject.get(Constants.JSON.AMOUNT);
|
|
||||||
if (!JSONUtils.isNumber(count))
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Expected amount to be a number greater than zero.");
|
|
||||||
}
|
|
||||||
int amount = count.getAsJsonPrimitive().getAsInt();
|
|
||||||
if (amount < 1)
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Expected amount to be greater than zero.");
|
|
||||||
}
|
|
||||||
ResourceLocation resourceLocation = new ResourceLocation(JSONUtils.getString(jsonObject, Constants.JSON.TAG));
|
|
||||||
ITag<Fluid> tag = TagCollectionManager.getManager().getFluidTags().get(resourceLocation);
|
|
||||||
if (tag == null)
|
|
||||||
{
|
|
||||||
throw new JsonSyntaxException("Unknown fluid tag '" + resourceLocation + "'");
|
|
||||||
}
|
|
||||||
return from(tag, amount);
|
|
||||||
}
|
|
||||||
throw new JsonSyntaxException("Expected to receive a resource location representing either a tag or a fluid.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FluidStackIngredient createMulti(FluidStackIngredient... ingredients)
|
|
||||||
{
|
|
||||||
if (ingredients.length == 0)
|
|
||||||
{
|
|
||||||
// TODO: Throw error
|
|
||||||
} else if (ingredients.length == 1)
|
|
||||||
{
|
|
||||||
return ingredients[0];
|
|
||||||
}
|
|
||||||
List<FluidStackIngredient> cleanedIngredients = new ArrayList<>();
|
|
||||||
for (FluidStackIngredient ingredient : ingredients)
|
|
||||||
{
|
|
||||||
if (ingredient instanceof Multi)
|
|
||||||
{
|
|
||||||
// Don't worry about if our inner ingredients are multi as well, as if this is
|
|
||||||
// the only external method for
|
|
||||||
// creating a multi ingredient, then we are certified they won't be of a higher
|
|
||||||
// depth
|
|
||||||
cleanedIngredients.addAll(Arrays.asList(((Multi) ingredient).ingredients));
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
cleanedIngredients.add(ingredient);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// There should be more than a single fluid or we would have split out earlier
|
|
||||||
return new Multi(cleanedIngredients.toArray(new FluidStackIngredient[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Single extends FluidStackIngredient
|
|
||||||
{
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final FluidStack fluidInstance;
|
|
||||||
|
|
||||||
public Single(@Nonnull FluidStack fluidInstance)
|
|
||||||
{
|
|
||||||
this.fluidInstance = Objects.requireNonNull(fluidInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(@Nonnull FluidStack fluidStack)
|
|
||||||
{
|
|
||||||
return testType(fluidStack) && fluidStack.getAmount() >= fluidInstance.getAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean testType(@Nonnull FluidStack fluidStack)
|
|
||||||
{
|
|
||||||
return Objects.requireNonNull(fluidStack).isFluidEqual(fluidInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public FluidStack getMatchingInstance(@Nonnull FluidStack fluidStack)
|
|
||||||
{
|
|
||||||
return test(fluidStack) ? fluidInstance : FluidStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public List<FluidStack> getRepresentations()
|
|
||||||
{
|
|
||||||
return Collections.singletonList(fluidInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
buffer.writeEnumValue(IngredientType.SINGLE);
|
|
||||||
fluidInstance.writeToPacket(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize()
|
|
||||||
{
|
|
||||||
JsonObject json = new JsonObject();
|
|
||||||
json.addProperty(Constants.JSON.AMOUNT, fluidInstance.getAmount());
|
|
||||||
json.addProperty(Constants.JSON.FLUID, fluidInstance.getFluid().getRegistryName().toString());
|
|
||||||
if (fluidInstance.hasTag())
|
|
||||||
{
|
|
||||||
json.addProperty(Constants.JSON.NBT, fluidInstance.getTag().toString());
|
|
||||||
}
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Single read(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
return new Single(FluidStack.readFromPacket(buffer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Tagged extends FluidStackIngredient
|
|
||||||
{
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final ITag<Fluid> tag;
|
|
||||||
private final int amount;
|
|
||||||
|
|
||||||
public Tagged(@Nonnull ITag<Fluid> tag, int amount)
|
|
||||||
{
|
|
||||||
this.tag = tag;
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(@Nonnull FluidStack fluidStack)
|
|
||||||
{
|
|
||||||
return testType(fluidStack) && fluidStack.getAmount() >= amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean testType(@Nonnull FluidStack fluidStack)
|
|
||||||
{
|
|
||||||
return Objects.requireNonNull(fluidStack).getFluid().isIn(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public FluidStack getMatchingInstance(@Nonnull FluidStack fluidStack)
|
|
||||||
{
|
|
||||||
if (test(fluidStack))
|
|
||||||
{
|
|
||||||
// Our fluid is in the tag so we make a new stack with the given amount
|
|
||||||
return new FluidStack(fluidStack, amount);
|
|
||||||
}
|
|
||||||
return FluidStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public List<FluidStack> getRepresentations()
|
|
||||||
{
|
|
||||||
// TODO: Can this be cached some how
|
|
||||||
List<FluidStack> representations = new ArrayList<>();
|
|
||||||
for (Fluid fluid : TagResolverHelper.getRepresentations(tag))
|
|
||||||
{
|
|
||||||
representations.add(new FluidStack(fluid, amount));
|
|
||||||
}
|
|
||||||
return representations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
buffer.writeEnumValue(IngredientType.TAGGED);
|
|
||||||
buffer.writeResourceLocation(TagCollectionManager.getManager().getFluidTags().getValidatedIdFromTag(tag));
|
|
||||||
buffer.writeVarInt(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize()
|
|
||||||
{
|
|
||||||
JsonObject json = new JsonObject();
|
|
||||||
json.addProperty(Constants.JSON.AMOUNT, amount);
|
|
||||||
json.addProperty(Constants.JSON.TAG, TagCollectionManager.getManager().getFluidTags().getValidatedIdFromTag(tag).toString());
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Tagged read(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
return new Tagged(FluidTags.makeWrapperTag(buffer.readResourceLocation().toString()), buffer.readVarInt());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Multi extends FluidStackIngredient
|
|
||||||
{
|
|
||||||
|
|
||||||
private final FluidStackIngredient[] ingredients;
|
|
||||||
|
|
||||||
protected Multi(@Nonnull FluidStackIngredient... ingredients)
|
|
||||||
{
|
|
||||||
this.ingredients = ingredients;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(@Nonnull FluidStack stack)
|
|
||||||
{
|
|
||||||
return Arrays.stream(ingredients).anyMatch(ingredient -> ingredient.test(stack));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean testType(@Nonnull FluidStack stack)
|
|
||||||
{
|
|
||||||
return Arrays.stream(ingredients).anyMatch(ingredient -> ingredient.testType(stack));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public FluidStack getMatchingInstance(@Nonnull FluidStack stack)
|
|
||||||
{
|
|
||||||
for (FluidStackIngredient ingredient : ingredients)
|
|
||||||
{
|
|
||||||
FluidStack matchingInstance = ingredient.getMatchingInstance(stack);
|
|
||||||
if (!matchingInstance.isEmpty())
|
|
||||||
{
|
|
||||||
return matchingInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return FluidStack.EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public List<FluidStack> getRepresentations()
|
|
||||||
{
|
|
||||||
List<FluidStack> representations = new ArrayList<>();
|
|
||||||
for (FluidStackIngredient ingredient : ingredients)
|
|
||||||
{
|
|
||||||
representations.addAll(ingredient.getRepresentations());
|
|
||||||
}
|
|
||||||
return representations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
buffer.writeEnumValue(IngredientType.MULTI);
|
|
||||||
buffer.writeVarInt(ingredients.length);
|
|
||||||
for (FluidStackIngredient ingredient : ingredients)
|
|
||||||
{
|
|
||||||
ingredient.write(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public JsonElement serialize()
|
|
||||||
{
|
|
||||||
JsonArray json = new JsonArray();
|
|
||||||
for (FluidStackIngredient ingredient : ingredients)
|
|
||||||
{
|
|
||||||
json.add(ingredient.serialize());
|
|
||||||
}
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FluidStackIngredient read(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
FluidStackIngredient[] ingredients = new FluidStackIngredient[buffer.readVarInt()];
|
|
||||||
for (int i = 0; i < ingredients.length; i++)
|
|
||||||
{
|
|
||||||
ingredients[i] = FluidStackIngredient.read(buffer);
|
|
||||||
}
|
|
||||||
return createMulti(ingredients);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum IngredientType
|
|
||||||
{
|
|
||||||
SINGLE,
|
|
||||||
TAGGED,
|
|
||||||
MULTI
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.event.recipes;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
|
|
||||||
public interface InputIngredient<TYPE> extends Predicate<TYPE>
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Evaluates this predicate on the given argument, ignoring any size data.
|
|
||||||
*
|
|
||||||
* @param type the input argument
|
|
||||||
*
|
|
||||||
* @return {@code true} if the input argument matches the predicate, otherwise
|
|
||||||
* {@code false}
|
|
||||||
*/
|
|
||||||
boolean testType(@Nonnull TYPE type);
|
|
||||||
|
|
||||||
TYPE getMatchingInstance(TYPE type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Primarily for JEI, a list of valid instances of the type
|
|
||||||
*
|
|
||||||
* @return List (empty means no valid registrations found and recipe is to be
|
|
||||||
* hidden)
|
|
||||||
*
|
|
||||||
* @apiNote Do not modify any of the values returned by the representations
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
List<TYPE> getRepresentations();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes this ingredient to a PacketBuffer.
|
|
||||||
*
|
|
||||||
* @param buffer The buffer to write to.
|
|
||||||
*/
|
|
||||||
void write(PacketBuffer buffer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Serializes this ingredient to a JsonElement
|
|
||||||
*
|
|
||||||
* @return JsonElement representation of this ingredient.
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
JsonElement serialize();
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.event.recipes;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.tags.ITag;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Copied from Mekanism, including the author's rant about tags.
|
|
||||||
*/
|
|
||||||
public class TagResolverHelper
|
|
||||||
{
|
|
||||||
|
|
||||||
public static <TYPE> List<TYPE> getRepresentations(ITag<TYPE> tag)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return tag.getAllElements();
|
|
||||||
} catch (IllegalStateException e)
|
|
||||||
{
|
|
||||||
// Why do tags have to be such an annoyance in 1.16
|
|
||||||
// This is needed so that we can ensure we give JEI an empty list of
|
|
||||||
// representations
|
|
||||||
// instead of crashing on the first run, as recipes get "initialized" before
|
|
||||||
// tags are
|
|
||||||
// done initializing, and we don't want to spam the log with errors. JEI and
|
|
||||||
// things
|
|
||||||
// still work fine regardless of this
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,145 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.impl.recipe;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
|
||||||
import net.minecraft.network.PacketBuffer;
|
|
||||||
import net.minecraft.util.NonNullList;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
import wayoftime.bloodmagic.api.event.recipes.FluidStackIngredient;
|
|
||||||
|
|
||||||
public abstract class RecipeARC extends BloodMagicRecipe
|
|
||||||
{
|
|
||||||
public static final int MAX_RANDOM_OUTPUTS = 3;
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private final Ingredient input;
|
|
||||||
@Nonnull
|
|
||||||
private final Ingredient arc_tool;
|
|
||||||
private final FluidStackIngredient inputFluid;
|
|
||||||
@Nonnull
|
|
||||||
private final ItemStack output;
|
|
||||||
private final FluidStack outputFluid;
|
|
||||||
|
|
||||||
private final List<Pair<ItemStack, Double>> addedItems;
|
|
||||||
|
|
||||||
protected RecipeARC(ResourceLocation id, Ingredient input, Ingredient arc_tool, FluidStackIngredient inputFluid, ItemStack output, FluidStack outputFluid)
|
|
||||||
{
|
|
||||||
this(id, input, arc_tool, inputFluid, output, new ArrayList<Pair<ItemStack, Double>>(), outputFluid);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected RecipeARC(ResourceLocation id, Ingredient input, Ingredient arc_tool, FluidStackIngredient inputFluid, ItemStack output, List<Pair<ItemStack, Double>> addedItems, FluidStack outputFluid)
|
|
||||||
{
|
|
||||||
super(id);
|
|
||||||
this.input = input;
|
|
||||||
this.arc_tool = arc_tool;
|
|
||||||
this.inputFluid = inputFluid;
|
|
||||||
this.output = output;
|
|
||||||
this.addedItems = addedItems;
|
|
||||||
this.outputFluid = outputFluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RecipeARC addRandomOutput(ItemStack stack, double chance)
|
|
||||||
{
|
|
||||||
if (addedItems.size() >= MAX_RANDOM_OUTPUTS)
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
addedItems.add(Pair.of(stack, chance));
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final Ingredient getInput()
|
|
||||||
{
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public final Ingredient getTool()
|
|
||||||
{
|
|
||||||
return arc_tool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final FluidStackIngredient getFluidIngredient()
|
|
||||||
{
|
|
||||||
return inputFluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final FluidStack getFluidOutput()
|
|
||||||
{
|
|
||||||
return outputFluid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final NonNullList<Ingredient> getIngredients()
|
|
||||||
{
|
|
||||||
NonNullList<Ingredient> list = NonNullList.create();
|
|
||||||
list.add(getInput());
|
|
||||||
list.add(getTool());
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ItemStack> getAllListedOutputs()
|
|
||||||
{
|
|
||||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
|
||||||
|
|
||||||
list.add(output.copy());
|
|
||||||
for (Pair<ItemStack, Double> pair : addedItems)
|
|
||||||
{
|
|
||||||
list.add(pair.getLeft().copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ItemStack> getAllOutputs(Random rand)
|
|
||||||
{
|
|
||||||
List<ItemStack> list = new ArrayList<ItemStack>();
|
|
||||||
|
|
||||||
list.add(output.copy());
|
|
||||||
for (Pair<ItemStack, Double> pair : addedItems)
|
|
||||||
{
|
|
||||||
if (rand.nextDouble() < pair.getRight())
|
|
||||||
list.add(pair.getLeft().copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(PacketBuffer buffer)
|
|
||||||
{
|
|
||||||
input.write(buffer);
|
|
||||||
arc_tool.write(buffer);
|
|
||||||
buffer.writeItemStack(output);
|
|
||||||
buffer.writeInt(addedItems.size());
|
|
||||||
for (Pair<ItemStack, Double> pair : addedItems)
|
|
||||||
{
|
|
||||||
buffer.writeItemStack(pair.getLeft());
|
|
||||||
buffer.writeDouble(pair.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.writeBoolean(inputFluid != null);
|
|
||||||
if (inputFluid != null)
|
|
||||||
{
|
|
||||||
inputFluid.write(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.writeBoolean(outputFluid != null);
|
|
||||||
if (outputFluid != null)
|
|
||||||
{
|
|
||||||
outputFluid.writeToPacket(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
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()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.text;
|
|
||||||
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
|
|
||||||
public interface IHasTextComponent
|
|
||||||
{
|
|
||||||
ITextComponent getTextComponent();
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
package wayoftime.bloodmagic.api.text;
|
|
||||||
|
|
||||||
public interface IHasTranslationKey
|
|
||||||
{
|
|
||||||
String getTranslationKey();
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package wayoftime.bloodmagic.block.enums;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import net.minecraft.util.IStringSerializable;
|
|
||||||
|
|
||||||
//TODO: Will want to probably discontinue this due to The Flattening
|
|
||||||
public enum EnumRitualController implements IStringSerializable
|
|
||||||
{
|
|
||||||
MASTER, IMPERFECT, INVERTED,;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return name().toLowerCase(Locale.ENGLISH);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getString()
|
|
||||||
{
|
|
||||||
return this.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
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.ScreenAlchemicalReactionChamber;
|
|
||||||
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);
|
|
||||||
ScreenManager.registerFactory(BloodMagicBlocks.ARC_CONTAINER.get(), ScreenAlchemicalReactionChamber::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;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,104 +0,0 @@
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,168 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,167 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,114 +0,0 @@
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package wayoftime.bloodmagic.client.render.block;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
|
|
||||||
public class RenderFakeBlocks
|
|
||||||
{
|
|
||||||
public static void drawFakeBlock(TextureAtlasSprite texture, double minX, double minY, double minZ)
|
|
||||||
{
|
|
||||||
if (texture == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
double maxX = minX + 1;
|
|
||||||
double maxY = minY + 1;
|
|
||||||
double maxZ = minZ + 1;
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
|
||||||
BufferBuilder wr = tessellator.getBuffer();
|
|
||||||
|
|
||||||
Minecraft.getInstance().getAtlasSpriteGetter(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(texture.getName());
|
|
||||||
|
|
||||||
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
|
||||||
|
|
||||||
float texMinU = texture.getMinU();
|
|
||||||
float texMinV = texture.getMinV();
|
|
||||||
float texMaxU = texture.getMaxU();
|
|
||||||
float texMaxV = texture.getMaxV();
|
|
||||||
|
|
||||||
wr.pos(minX, minY, minZ).tex(texMinU, texMinV).endVertex();
|
|
||||||
wr.pos(maxX, minY, minZ).tex(texMaxU, texMinV).endVertex();
|
|
||||||
wr.pos(maxX, minY, maxZ).tex(texMaxU, texMaxV).endVertex();
|
|
||||||
wr.pos(minX, minY, maxZ).tex(texMinU, texMaxV).endVertex();
|
|
||||||
|
|
||||||
wr.pos(minX, maxY, maxZ).tex(texMinU, texMaxV).endVertex();
|
|
||||||
wr.pos(maxX, maxY, maxZ).tex(texMaxU, texMaxV).endVertex();
|
|
||||||
wr.pos(maxX, maxY, minZ).tex(texMaxU, texMinV).endVertex();
|
|
||||||
wr.pos(minX, maxY, minZ).tex(texMinU, texMinV).endVertex();
|
|
||||||
|
|
||||||
wr.pos(maxX, minY, minZ).tex(texMinU, texMaxV).endVertex();
|
|
||||||
wr.pos(minX, minY, minZ).tex(texMaxU, texMaxV).endVertex();
|
|
||||||
wr.pos(minX, maxY, minZ).tex(texMaxU, texMinV).endVertex();
|
|
||||||
wr.pos(maxX, maxY, minZ).tex(texMinU, texMinV).endVertex();
|
|
||||||
|
|
||||||
wr.pos(minX, minY, maxZ).tex(texMinU, texMaxV).endVertex();
|
|
||||||
wr.pos(maxX, minY, maxZ).tex(texMaxU, texMaxV).endVertex();
|
|
||||||
wr.pos(maxX, maxY, maxZ).tex(texMaxU, texMinV).endVertex();
|
|
||||||
wr.pos(minX, maxY, maxZ).tex(texMinU, texMinV).endVertex();
|
|
||||||
|
|
||||||
wr.pos(minX, minY, minZ).tex(texMinU, texMaxV).endVertex();
|
|
||||||
wr.pos(minX, minY, maxZ).tex(texMaxU, texMaxV).endVertex();
|
|
||||||
wr.pos(minX, maxY, maxZ).tex(texMaxU, texMinV).endVertex();
|
|
||||||
wr.pos(minX, maxY, minZ).tex(texMinU, texMinV).endVertex();
|
|
||||||
|
|
||||||
wr.pos(maxX, minY, maxZ).tex(texMinU, texMaxV).endVertex();
|
|
||||||
wr.pos(maxX, minY, minZ).tex(texMaxU, texMaxV).endVertex();
|
|
||||||
wr.pos(maxX, maxY, minZ).tex(texMaxU, texMinV).endVertex();
|
|
||||||
wr.pos(maxX, maxY, maxZ).tex(texMinU, texMinV).endVertex();
|
|
||||||
|
|
||||||
tessellator.draw();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,107 +0,0 @@
|
||||||
package wayoftime.bloodmagic.client.screens;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.util.text.ITextComponent;
|
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
|
||||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
|
|
||||||
import wayoftime.bloodmagic.tile.contailer.ContainerAlchemicalReactionChamber;
|
|
||||||
import wayoftime.bloodmagic.util.handler.event.ClientHandler;
|
|
||||||
|
|
||||||
public class ScreenAlchemicalReactionChamber extends ScreenBase<ContainerAlchemicalReactionChamber>
|
|
||||||
{
|
|
||||||
private static final ResourceLocation background = new ResourceLocation(BloodMagic.MODID, "textures/gui/arc_gui.png");
|
|
||||||
public TileAlchemicalReactionChamber tileARC;
|
|
||||||
|
|
||||||
public ScreenAlchemicalReactionChamber(ContainerAlchemicalReactionChamber container, PlayerInventory playerInventory, ITextComponent title)
|
|
||||||
{
|
|
||||||
super(container, playerInventory, title);
|
|
||||||
tileARC = container.tileARC;
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
super.render(stack, mouseX, mouseY, partialTicks);
|
|
||||||
List<ITextComponent> tooltip = new ArrayList<>();
|
|
||||||
// FluidTank inputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 2);
|
|
||||||
// inputTank.fill(new FluidStack(Fluids.WATER, 1000), FluidAction.EXECUTE);
|
|
||||||
|
|
||||||
ClientHandler.handleGuiTank(stack, tileARC.inputTank, this.guiLeft + 8, this.guiTop
|
|
||||||
+ 40, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), tooltip);
|
|
||||||
ClientHandler.handleGuiTank(stack, tileARC.outputTank, this.guiLeft + 152, this.guiTop
|
|
||||||
+ 15, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), tooltip);
|
|
||||||
|
|
||||||
if (!tooltip.isEmpty())
|
|
||||||
GuiUtils.drawHoveringText(stack, tooltip, mouseX, mouseY, width, height, -1, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
@Override
|
|
||||||
protected void drawGuiContainerForegroundLayer(MatrixStack stack, int mouseX, int mouseY)
|
|
||||||
{
|
|
||||||
this.font.func_243248_b(stack, new TranslationTextComponent("tile.bloodmagic.arc.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);
|
|
||||||
|
|
||||||
// FluidTank inputTank = new FluidTank(FluidAttributes.BUCKET_VOLUME * 2);
|
|
||||||
// inputTank.fill(new FluidStack(Fluids.WATER, 1000), FluidAction.EXECUTE);
|
|
||||||
|
|
||||||
ClientHandler.handleGuiTank(stack, tileARC.inputTank, this.guiLeft + 8, this.guiTop
|
|
||||||
+ 40, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), null);
|
|
||||||
ClientHandler.handleGuiTank(stack, tileARC.outputTank, this.guiLeft + 152, this.guiTop
|
|
||||||
+ 15, 16, 63, 194, 1, 16, 63, mouseX, mouseY, background.toString(), null);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,153 +0,0 @@
|
||||||
package wayoftime.bloodmagic.client.utils;
|
|
||||||
|
|
||||||
import java.util.OptionalDouble;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|
||||||
import net.minecraft.client.renderer.RenderState;
|
|
||||||
import net.minecraft.client.renderer.RenderState.AlphaState;
|
|
||||||
import net.minecraft.client.renderer.RenderState.CullState;
|
|
||||||
import net.minecraft.client.renderer.RenderState.FogState;
|
|
||||||
import net.minecraft.client.renderer.RenderState.LightmapState;
|
|
||||||
import net.minecraft.client.renderer.RenderState.LineState;
|
|
||||||
import net.minecraft.client.renderer.RenderState.ShadeModelState;
|
|
||||||
import net.minecraft.client.renderer.RenderState.TextureState;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
import net.minecraft.inventory.container.PlayerContainer;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
|
|
||||||
public class BMRenderTypes
|
|
||||||
{
|
|
||||||
public static final RenderType SOLID_FULLBRIGHT;
|
|
||||||
public static final RenderType TRANSLUCENT_LINES;
|
|
||||||
public static final RenderType LINES;
|
|
||||||
public static final RenderType TRANSLUCENT_TRIANGLES;
|
|
||||||
public static final RenderType TRANSLUCENT_POSITION_COLOR;
|
|
||||||
public static final RenderType TRANSLUCENT_NO_DEPTH;
|
|
||||||
public static final RenderType CHUNK_MARKER;
|
|
||||||
public static final RenderType VEIN_MARKER;
|
|
||||||
public static final RenderType POSITION_COLOR_TEX_LIGHTMAP;
|
|
||||||
public static final RenderType POSITION_COLOR_LIGHTMAP;
|
|
||||||
public static final RenderType ITEM_DAMAGE_BAR;
|
|
||||||
protected static final RenderState.ShadeModelState SHADE_ENABLED = new RenderState.ShadeModelState(true);
|
|
||||||
protected static final RenderState.TextureState BLOCK_SHEET_MIPPED = new RenderState.TextureState(AtlasTexture.LOCATION_BLOCKS_TEXTURE, false, true);
|
|
||||||
protected static final RenderState.LightmapState LIGHTMAP_DISABLED = new RenderState.LightmapState(false);
|
|
||||||
protected static final RenderState.TransparencyState TRANSLUCENT_TRANSPARENCY = new RenderState.TransparencyState("translucent_transparency", () -> {
|
|
||||||
RenderSystem.enableBlend();
|
|
||||||
RenderSystem.defaultBlendFunc();
|
|
||||||
}, RenderSystem::disableBlend);
|
|
||||||
protected static final RenderState.TransparencyState NO_TRANSPARENCY = new RenderState.TransparencyState("no_transparency", RenderSystem::disableBlend, () -> {
|
|
||||||
});
|
|
||||||
protected static final RenderState.DepthTestState DEPTH_ALWAYS = new RenderState.DepthTestState("", GL11.GL_ALWAYS);
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
RenderType.State fullbrightSolidState = RenderType.State.getBuilder().shadeModel(SHADE_ENABLED).lightmap(LIGHTMAP_DISABLED).texture(BLOCK_SHEET_MIPPED).build(true);
|
|
||||||
SOLID_FULLBRIGHT = RenderType.makeType(BloodMagic.MODID + ":block_fullbright", DefaultVertexFormats.BLOCK, GL11.GL_QUADS, 256, fullbrightSolidState);
|
|
||||||
RenderType.State translucentNoDepthState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).line(new LineState(OptionalDouble.of(2))).texture(new TextureState()).depthTest(DEPTH_ALWAYS).build(false);
|
|
||||||
RenderType.State translucentNoTextureState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).texture(new TextureState()).build(false);
|
|
||||||
TRANSLUCENT_LINES = RenderType.makeType(BloodMagic.MODID + ":translucent_lines", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 256, translucentNoDepthState);
|
|
||||||
LINES = RenderType.makeType(BloodMagic.MODID + ":lines", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 256, RenderType.State.getBuilder().build(false));
|
|
||||||
TRANSLUCENT_TRIANGLES = RenderType.makeType(BloodMagic.MODID + ":translucent_triangle_fan", DefaultVertexFormats.POSITION_COLOR, GL11.GL_TRIANGLES, 256, translucentNoDepthState);
|
|
||||||
TRANSLUCENT_POSITION_COLOR = RenderType.makeType(BloodMagic.MODID + ":translucent_pos_color", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256, translucentNoTextureState);
|
|
||||||
TRANSLUCENT_NO_DEPTH = RenderType.makeType(BloodMagic.MODID + ":translucent_no_depth", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256, translucentNoDepthState);
|
|
||||||
RenderType.State chunkMarkerState = RenderType.State.getBuilder().texture(new TextureState()).transparency(TRANSLUCENT_TRANSPARENCY).cull(new CullState(false)).shadeModel(new ShadeModelState(true)).line(new LineState(OptionalDouble.of(5))).build(false);
|
|
||||||
CHUNK_MARKER = RenderType.makeType(BloodMagic.MODID + ":chunk_marker", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 256, chunkMarkerState);
|
|
||||||
VEIN_MARKER = RenderType.makeType(BloodMagic.MODID + ":vein_marker", DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINE_LOOP, 256, chunkMarkerState);
|
|
||||||
POSITION_COLOR_TEX_LIGHTMAP = RenderType.makeType(BloodMagic.MODID + ":pos_color_tex_lightmap", DefaultVertexFormats.POSITION_COLOR_TEX_LIGHTMAP, GL11.GL_QUADS, 256, RenderType.State.getBuilder().texture(new TextureState(PlayerContainer.LOCATION_BLOCKS_TEXTURE, false, false)).lightmap(new LightmapState(true)).build(false));
|
|
||||||
POSITION_COLOR_LIGHTMAP = RenderType.makeType(BloodMagic.MODID + ":pos_color_lightmap", DefaultVertexFormats.POSITION_COLOR_LIGHTMAP, GL11.GL_QUADS, 256, RenderType.State.getBuilder().texture(new TextureState()).lightmap(new LightmapState(true)).build(false));
|
|
||||||
ITEM_DAMAGE_BAR = RenderType.makeType(BloodMagic.MODID + ":item_damage_bar", DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256, RenderType.State.getBuilder().depthTest(DEPTH_ALWAYS).texture(new TextureState()).alpha(new AlphaState(0)).transparency(NO_TRANSPARENCY).build(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RenderType getGui(ResourceLocation texture)
|
|
||||||
{
|
|
||||||
return RenderType.makeType("gui_" + texture, DefaultVertexFormats.POSITION_COLOR_TEX, GL11.GL_QUADS, 256, RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).alpha(new AlphaState(0.5F)).build(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RenderType getLines(float lineWidth)
|
|
||||||
{
|
|
||||||
return RenderType.makeType("lines_color_pos_" + lineWidth, DefaultVertexFormats.POSITION_COLOR, GL11.GL_LINES, 256, RenderType.State.getBuilder().line(new LineState(OptionalDouble.of(lineWidth))).texture(new TextureState()).build(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RenderType getPoints(float pointSize)
|
|
||||||
{
|
|
||||||
// Not really a fog state, but using it like this makes using RenderType.State
|
|
||||||
// with custom states possible
|
|
||||||
FogState setPointSize = new FogState(BloodMagic.MODID + ":pointsize_" + pointSize, () -> GL11.glPointSize(pointSize), () -> {
|
|
||||||
GL11.glPointSize(1);
|
|
||||||
});
|
|
||||||
return RenderType.makeType("point_pos_color_" + pointSize, DefaultVertexFormats.POSITION_COLOR, GL11.GL_POINTS, 256, RenderType.State.getBuilder().fog(setPointSize).texture(new TextureState()).build(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RenderType getPositionTex(ResourceLocation texture)
|
|
||||||
{
|
|
||||||
return RenderType.makeType(BloodMagic.MODID + ":pos_tex_" + texture, DefaultVertexFormats.POSITION_TEX, GL11.GL_QUADS, 256, RenderType.State.getBuilder().texture(new TextureState(texture, false, false)).build(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RenderType getFullbrightTranslucent(ResourceLocation resourceLocation)
|
|
||||||
{
|
|
||||||
RenderType.State glState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY).texture(new TextureState(resourceLocation, false, false)).lightmap(new LightmapState(false)).build(false);
|
|
||||||
return RenderType.makeType("BloodMagic:fullbright_translucent_" + resourceLocation, DefaultVertexFormats.BLOCK, GL11.GL_QUADS, 256, glState);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IRenderTypeBuffer wrapWithStencil(IRenderTypeBuffer in, Consumer<IVertexBuilder> setupStencilArea, String name, int ref)
|
|
||||||
{
|
|
||||||
return wrapWithAdditional(in, "stencil_" + name + "_" + ref, () -> {
|
|
||||||
GL11.glEnable(GL11.GL_STENCIL_TEST);
|
|
||||||
RenderSystem.colorMask(false, false, false, false);
|
|
||||||
RenderSystem.depthMask(false);
|
|
||||||
GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
|
|
||||||
GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
|
|
||||||
|
|
||||||
GL11.glStencilMask(0xFF);
|
|
||||||
RenderSystem.clear(GL11.GL_STENCIL_BUFFER_BIT, true);
|
|
||||||
RenderSystem.disableTexture();
|
|
||||||
Tessellator tes = Tessellator.getInstance();
|
|
||||||
BufferBuilder bb = tes.getBuffer();
|
|
||||||
bb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
|
|
||||||
setupStencilArea.accept(bb);
|
|
||||||
tes.draw();
|
|
||||||
RenderSystem.enableTexture();
|
|
||||||
RenderSystem.colorMask(true, true, true, true);
|
|
||||||
RenderSystem.depthMask(true);
|
|
||||||
GL11.glStencilMask(0x00);
|
|
||||||
GL11.glStencilFunc(GL11.GL_EQUAL, ref, 0xFF);
|
|
||||||
}, () -> GL11.glDisable(GL11.GL_STENCIL_TEST));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IRenderTypeBuffer disableLighting(IRenderTypeBuffer in)
|
|
||||||
{
|
|
||||||
return wrapWithAdditional(in, "no_lighting", RenderSystem::disableLighting, () -> {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IRenderTypeBuffer disableCull(IRenderTypeBuffer in)
|
|
||||||
{
|
|
||||||
return wrapWithAdditional(in, "no_cull", RenderSystem::disableCull, RenderSystem::enableCull);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IRenderTypeBuffer wrapWithAdditional(IRenderTypeBuffer in, String name, Runnable setup, Runnable teardown)
|
|
||||||
{
|
|
||||||
return type -> {
|
|
||||||
return in.getBuffer(new RenderType(BloodMagic.MODID + ":" + type + "_" + name, type.getVertexFormat(), type.getDrawMode(), type.getBufferSize(), type.isUseDelegate(), false, () -> {
|
|
||||||
type.setupRenderState();
|
|
||||||
setup.run();
|
|
||||||
}, () -> {
|
|
||||||
teardown.run();
|
|
||||||
type.clearRenderState();
|
|
||||||
})
|
|
||||||
{
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,162 +0,0 @@
|
||||||
package wayoftime.bloodmagic.common.block;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.HorizontalBlock;
|
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
import net.minecraft.block.material.Material;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
||||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.state.BooleanProperty;
|
|
||||||
import net.minecraft.state.DirectionProperty;
|
|
||||||
import net.minecraft.state.StateContainer;
|
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
|
||||||
import net.minecraft.tileentity.AbstractFurnaceTileEntity;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
|
||||||
import net.minecraft.util.ActionResultType;
|
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.Hand;
|
|
||||||
import net.minecraft.util.Mirror;
|
|
||||||
import net.minecraft.util.Rotation;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
|
||||||
import net.minecraft.world.IBlockReader;
|
|
||||||
import net.minecraft.world.IWorld;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
import wayoftime.bloodmagic.tile.TileAlchemicalReactionChamber;
|
|
||||||
|
|
||||||
public class BlockAlchemicalReactionChamber extends Block
|
|
||||||
{
|
|
||||||
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
|
||||||
public static final BooleanProperty LIT = BlockStateProperties.LIT;
|
|
||||||
|
|
||||||
public BlockAlchemicalReactionChamber()
|
|
||||||
{
|
|
||||||
super(Properties.create(Material.ROCK).hardnessAndResistance(2.0F, 5.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2).sound(SoundType.STONE));
|
|
||||||
this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH).with(LIT, Boolean.valueOf(false)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTileEntity(BlockState state)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world)
|
|
||||||
{
|
|
||||||
return new TileAlchemicalReactionChamber();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
|
|
||||||
{
|
|
||||||
TileAlchemicalReactionChamber arc = (TileAlchemicalReactionChamber) world.getTileEntity(blockPos);
|
|
||||||
if (arc != null)
|
|
||||||
arc.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 TileAlchemicalReactionChamber)
|
|
||||||
{
|
|
||||||
((TileAlchemicalReactionChamber) tileentity).dropItems();
|
|
||||||
worldIn.updateComparatorOutputLevel(pos, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onReplaced(state, worldIn, pos, newState, isMoving);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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 TileAlchemicalReactionChamber))
|
|
||||||
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 BlockState getStateForPlacement(BlockItemUseContext context)
|
|
||||||
{
|
|
||||||
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by ItemBlocks after a block is set in the world, to allow post-place
|
|
||||||
* logic
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.hasDisplayName())
|
|
||||||
{
|
|
||||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
|
||||||
if (tileentity instanceof AbstractFurnaceTileEntity)
|
|
||||||
{
|
|
||||||
((AbstractFurnaceTileEntity) tileentity).setCustomName(stack.getDisplayName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the blockstate with the given rotation from the passed blockstate. If
|
|
||||||
* inapplicable, returns the passed blockstate.
|
|
||||||
*
|
|
||||||
* @deprecated call via {@link IBlockState#withRotation(Rotation)} whenever
|
|
||||||
* possible. Implementing/overriding is fine.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public BlockState rotate(BlockState state, Rotation rot)
|
|
||||||
{
|
|
||||||
return state.with(FACING, rot.rotate(state.get(FACING)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the blockstate with the given mirror of the passed blockstate. If
|
|
||||||
* inapplicable, returns the passed blockstate.
|
|
||||||
*
|
|
||||||
* @deprecated call via {@link IBlockState#withMirror(Mirror)} whenever
|
|
||||||
* possible. Implementing/overriding is fine.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public BlockState mirror(BlockState state, Mirror mirrorIn)
|
|
||||||
{
|
|
||||||
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
|
|
||||||
{
|
|
||||||
builder.add(FACING, LIT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean eventReceived(BlockState state, World worldIn, BlockPos pos, int id, int param)
|
|
||||||
{
|
|
||||||
super.eventReceived(state, worldIn, pos, id, param);
|
|
||||||
TileEntity tileentity = worldIn.getTileEntity(pos);
|
|
||||||
return tileentity == null ? false : tileentity.receiveClientEvent(id, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,112 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,100 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,130 +0,0 @@
|
||||||
package wayoftime.bloodmagic.common.block;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
import net.minecraft.block.SoundType;
|
|
||||||
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.Direction;
|
|
||||||
import net.minecraft.util.Hand;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
|
||||||
import net.minecraft.util.text.TranslationTextComponent;
|
|
||||||
import net.minecraft.world.Explosion;
|
|
||||||
import net.minecraft.world.IBlockReader;
|
|
||||||
import net.minecraft.world.IWorld;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.common.ToolType;
|
|
||||||
import wayoftime.bloodmagic.BloodMagic;
|
|
||||||
import wayoftime.bloodmagic.common.item.ItemActivationCrystal;
|
|
||||||
import wayoftime.bloodmagic.iface.IBindable;
|
|
||||||
import wayoftime.bloodmagic.ritual.Ritual;
|
|
||||||
import wayoftime.bloodmagic.tile.TileMasterRitualStone;
|
|
||||||
import wayoftime.bloodmagic.util.helper.RitualHelper;
|
|
||||||
|
|
||||||
public class BlockMasterRitualStone extends Block
|
|
||||||
{
|
|
||||||
public final boolean isInverted;
|
|
||||||
|
|
||||||
public BlockMasterRitualStone(boolean isInverted)
|
|
||||||
{
|
|
||||||
super(Properties.create(Material.ROCK).sound(SoundType.STONE).hardnessAndResistance(2.0F, 5.0F).harvestTool(ToolType.PICKAXE).harvestLevel(2));
|
|
||||||
this.isInverted = isInverted;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult)
|
|
||||||
{
|
|
||||||
ItemStack heldItem = player.getHeldItem(hand);
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
|
||||||
|
|
||||||
if (tile instanceof TileMasterRitualStone)
|
|
||||||
{
|
|
||||||
if (heldItem.getItem() instanceof ItemActivationCrystal)
|
|
||||||
{
|
|
||||||
if (((IBindable) heldItem.getItem()).getBinding(heldItem) == null)
|
|
||||||
return ActionResultType.FAIL;
|
|
||||||
|
|
||||||
String key = RitualHelper.getValidRitual(world, pos);
|
|
||||||
if (!key.isEmpty())
|
|
||||||
{
|
|
||||||
Ritual ritual = BloodMagic.RITUAL_MANAGER.getRitual(key);
|
|
||||||
if (ritual != null)
|
|
||||||
{
|
|
||||||
Direction direction = RitualHelper.getDirectionOfRitual(world, pos, ritual);
|
|
||||||
// TODO: Give a message stating that this ritual is not a valid ritual.
|
|
||||||
if (direction != null && RitualHelper.checkValidRitual(world, pos, ritual, direction))
|
|
||||||
{
|
|
||||||
if (((TileMasterRitualStone) tile).activateRitual(heldItem, player, BloodMagic.RITUAL_MANAGER.getRitual(key)))
|
|
||||||
{
|
|
||||||
((TileMasterRitualStone) tile).setDirection(direction);
|
|
||||||
if (isInverted)
|
|
||||||
((TileMasterRitualStone) tile).setInverted(true);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notvalid"), true);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notvalid"), true);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
player.sendStatusMessage(new TranslationTextComponent("chat.bloodmagic.ritual.notvalid"), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ActionResultType.FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerDestroy(IWorld world, BlockPos blockPos, BlockState blockState)
|
|
||||||
{
|
|
||||||
TileMasterRitualStone tile = (TileMasterRitualStone) world.getTileEntity(blockPos);
|
|
||||||
if (tile != null)
|
|
||||||
((TileMasterRitualStone) tile).stopRitual(Ritual.BreakType.BREAK_MRS);
|
|
||||||
|
|
||||||
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 tile = worldIn.getTileEntity(pos);
|
|
||||||
if (tile instanceof TileMasterRitualStone)
|
|
||||||
{
|
|
||||||
((TileMasterRitualStone) tile).stopRitual(Ritual.BreakType.BREAK_MRS);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.onReplaced(state, worldIn, pos, newState, isMoving);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExplosionDestroy(World world, BlockPos pos, Explosion explosion)
|
|
||||||
{
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
|
||||||
|
|
||||||
if (tile instanceof TileMasterRitualStone)
|
|
||||||
((TileMasterRitualStone) tile).stopRitual(Ritual.BreakType.EXPLOSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasTileEntity(BlockState state)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TileEntity createTileEntity(BlockState state, IBlockReader world)
|
|
||||||
{
|
|
||||||
return new TileMasterRitualStone();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
package wayoftime.bloodmagic.common.block;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
|
||||||
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.ritual.EnumRuneType;
|
|
||||||
import wayoftime.bloodmagic.ritual.IRitualStone;
|
|
||||||
|
|
||||||
public class BlockRitualStone extends Block implements IRitualStone
|
|
||||||
{
|
|
||||||
private final EnumRuneType type;
|
|
||||||
|
|
||||||
public BlockRitualStone(EnumRuneType type)
|
|
||||||
{
|
|
||||||
super(Properties.create(Material.ROCK).hardnessAndResistance(2.0F, 5.0F).sound(SoundType.STONE).harvestTool(ToolType.PICKAXE).harvestLevel(2));
|
|
||||||
this.type = 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Override
|
|
||||||
// public int damageDropped(BlockState state)
|
|
||||||
// {
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean canSilkHarvest(World world, BlockPos pos, BlockState state, PlayerEntity player)
|
|
||||||
// {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType)
|
|
||||||
{
|
|
||||||
return type.equals(runeType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setRuneType(World world, BlockPos pos, EnumRuneType runeType)
|
|
||||||
{
|
|
||||||
Block runeBlock = this;
|
|
||||||
switch (runeType)
|
|
||||||
{
|
|
||||||
case AIR:
|
|
||||||
runeBlock = BloodMagicBlocks.AIR_RITUAL_STONE.get();
|
|
||||||
break;
|
|
||||||
case BLANK:
|
|
||||||
runeBlock = BloodMagicBlocks.BLANK_RITUAL_STONE.get();
|
|
||||||
break;
|
|
||||||
case DAWN:
|
|
||||||
runeBlock = BloodMagicBlocks.DAWN_RITUAL_STONE.get();
|
|
||||||
break;
|
|
||||||
case DUSK:
|
|
||||||
runeBlock = BloodMagicBlocks.DUSK_RITUAL_STONE.get();
|
|
||||||
break;
|
|
||||||
case EARTH:
|
|
||||||
runeBlock = BloodMagicBlocks.EARTH_RITUAL_STONE.get();
|
|
||||||
break;
|
|
||||||
case FIRE:
|
|
||||||
runeBlock = BloodMagicBlocks.FIRE_RITUAL_STONE.get();
|
|
||||||
break;
|
|
||||||
case WATER:
|
|
||||||
runeBlock = BloodMagicBlocks.WATER_RITUAL_STONE.get();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockState newState = runeBlock.getDefaultState();
|
|
||||||
world.setBlockState(pos, newState);
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue