Creation of 1.16.3 branch
Initial publishing of the 1.16.3 branch of the mod. A lot of systems are missing (such as Rituals and Living Armour), but enough is present for a decent Alpha release.
This commit is contained in:
parent
0e02b983f1
commit
d617911d7a
1662 changed files with 18791 additions and 85075 deletions
|
@ -1,124 +1,233 @@
|
|||
package WayofTime.bloodmagic;
|
||||
package wayoftime.bloodmagic;
|
||||
|
||||
import WayofTime.bloodmagic.api.BloodMagicPlugin;
|
||||
import WayofTime.bloodmagic.api.IBloodMagicPlugin;
|
||||
import WayofTime.bloodmagic.core.registry.OrbRegistry;
|
||||
import WayofTime.bloodmagic.ritual.RitualManager;
|
||||
import WayofTime.bloodmagic.client.gui.GuiHandler;
|
||||
import WayofTime.bloodmagic.command.CommandBloodMagic;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.meteor.MeteorConfigHandler;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.proxy.CommonProxy;
|
||||
import WayofTime.bloodmagic.registry.*;
|
||||
import WayofTime.bloodmagic.structures.ModDungeons;
|
||||
import WayofTime.bloodmagic.util.PluginUtil;
|
||||
import WayofTime.bloodmagic.util.handler.IMCHandler;
|
||||
import com.google.common.collect.Lists;
|
||||
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.launchwrapper.Launch;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
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.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.*;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
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.GeneratorItemModels;
|
||||
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.tile.TileAlchemyArray;
|
||||
import wayoftime.bloodmagic.tile.TileAltar;
|
||||
import wayoftime.bloodmagic.tile.TileSoulForge;
|
||||
import wayoftime.bloodmagic.util.handler.event.GenericHandler;
|
||||
import wayoftime.bloodmagic.util.handler.event.WillHandler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@Mod("bloodmagic")
|
||||
//@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class BloodMagic
|
||||
{
|
||||
public static final String MODID = "bloodmagic";
|
||||
// Directly reference a log4j logger.
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Mod(modid = BloodMagic.MODID, name = BloodMagic.NAME, version = BloodMagic.VERSION, dependencies = BloodMagic.DEPEND, guiFactory = "WayofTime.bloodmagic.client.gui.GuiBloodMagicConfig$Factory")
|
||||
public class BloodMagic {
|
||||
public static final String MODID = "bloodmagic";
|
||||
public static final String NAME = "Blood Magic: Alchemical Wizardry";
|
||||
public static final String VERSION = "@VERSION@";
|
||||
public static final String DEPEND = "required-after:guideapi;";
|
||||
public static final boolean IS_DEV = (Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||
public static final List<Pair<IBloodMagicPlugin, BloodMagicPlugin>> PLUGINS = Lists.newArrayList();
|
||||
public static final RitualManager RITUAL_MANAGER = new RitualManager(new Configuration(new File(Loader.instance().getConfigDir(), MODID + "/" + "rituals.cfg")));
|
||||
public static final ItemGroup TAB_BM = new ItemGroup(MODID + ".creativeTab") {
|
||||
@Override
|
||||
public ItemStack createIcon() {
|
||||
return OrbRegistry.getOrbStack(RegistrarBloodMagic.ORB_WEAK);
|
||||
}
|
||||
};
|
||||
public static ItemGroup TAB_TOMES = new ItemGroup(MODID + ".creativeTabTome") {
|
||||
@Override
|
||||
public ItemStack createIcon() {
|
||||
return new ItemStack(RegistrarBloodMagicItems.UPGRADE_TOME);
|
||||
}
|
||||
private static Gson GSON = null;
|
||||
|
||||
@Override
|
||||
public boolean hasSearchBar() {
|
||||
return true;
|
||||
}
|
||||
}.setNoTitle().setBackgroundImageName("item_search.png");
|
||||
public static final BloodMagicPacketHandler packetHandler = new BloodMagicPacketHandler();
|
||||
|
||||
@SidedProxy(serverSide = "WayofTime.bloodmagic.proxy.CommonProxy", clientSide = "WayofTime.bloodmagic.proxy.ClientProxy")
|
||||
public static CommonProxy proxy;
|
||||
@Mod.Instance(BloodMagic.MODID)
|
||||
public static BloodMagic instance;
|
||||
public BloodMagic()
|
||||
{
|
||||
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
||||
static {
|
||||
FluidRegistry.enableUniversalBucket();
|
||||
}
|
||||
modBus.addListener(this::setup);
|
||||
modBus.addListener(this::onLoadComplete);
|
||||
|
||||
private File configDir;
|
||||
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);
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
configDir = new File(event.getModConfigurationDirectory(), "bloodmagic");
|
||||
BloodMagicRecipeSerializers.RECIPE_SERIALIZERS.register(modBus);
|
||||
|
||||
PLUGINS.addAll(PluginUtil.gatherPlugins(event.getAsmData()));
|
||||
PluginUtil.injectAPIInstances(PluginUtil.gatherInjections(event.getAsmData()));
|
||||
// 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);
|
||||
|
||||
ModTranquilityHandlers.init();
|
||||
ModDungeons.init();
|
||||
RITUAL_MANAGER.discover(event.getAsmData());
|
||||
modBus.addGenericListener(Fluid.class, this::registerFluids);
|
||||
modBus.addGenericListener(TileEntityType.class, this::registerTileEntityTypes);
|
||||
modBus.addGenericListener(IRecipeSerializer.class, this::registerRecipes);
|
||||
modBus.addGenericListener(Effect.class, BloodMagicPotions::registerPotions);
|
||||
|
||||
proxy.preInit();
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.register(new GenericHandler());
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
BloodMagicPacketHandler.init();
|
||||
MinecraftForge.EVENT_BUS.register(new WillHandler());
|
||||
// MinecraftForge.EVENT_BUS.register(new BloodMagicBlocks());
|
||||
// MinecraftForge.EVENT_BUS.addListener(this::commonSetup);
|
||||
|
||||
PluginUtil.handlePluginStep(PluginUtil.RegistrationStep.PLUGIN_REGISTER);
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
ModRecipes.init();
|
||||
ModRituals.initHarvestHandlers();
|
||||
ModRituals.initCuttingFluids();
|
||||
MeteorConfigHandler.init(new File(configDir, "meteors"));
|
||||
ModArmourTrackers.init();
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(BloodMagic.instance, new GuiHandler());
|
||||
ModCorruptionBlocks.init();
|
||||
private void registerRecipes(RegistryEvent.Register<IRecipeSerializer<?>> event)
|
||||
{
|
||||
System.out.println("Registering IngredientBloodOrb Serializer.");
|
||||
CraftingHelper.register(IngredientBloodOrb.NAME, IngredientBloodOrb.Serializer.INSTANCE);
|
||||
|
||||
proxy.init();
|
||||
}
|
||||
// event.getRegistry().registerAll(
|
||||
// new SewingRecipe.Serializer().setRegistryName("sewing")
|
||||
// );
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
ModRecipes.addCompressionHandlers();
|
||||
public static ResourceLocation rl(String name)
|
||||
{
|
||||
return new ResourceLocation(BloodMagic.MODID, name);
|
||||
}
|
||||
|
||||
proxy.postInit();
|
||||
}
|
||||
public void registerFluids(RegistryEvent.Register<Fluid> event)
|
||||
{
|
||||
|
||||
@Mod.EventHandler
|
||||
public void modMapping(FMLModIdMappingEvent event) {
|
||||
}
|
||||
|
||||
}
|
||||
public void onLoadComplete(FMLLoadCompleteEvent event)
|
||||
{
|
||||
OrbRegistry.tierMap.put(BloodMagicItems.ORB_WEAK.get().getTier(), new ItemStack(BloodMagicItems.WEAK_BLOOD_ORB.get()));
|
||||
BloodMagicCorePlugin.INSTANCE.register(BloodMagicAPI.INSTANCE);
|
||||
|
||||
@Mod.EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
event.registerServerCommand(new CommandBloodMagic());
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onIMCRecieved(FMLInterModComms.IMCEvent event) {
|
||||
IMCHandler.handleIMC(event);
|
||||
}
|
||||
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"));
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
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,90 +1,135 @@
|
|||
package WayofTime.bloodmagic;
|
||||
package wayoftime.bloodmagic;
|
||||
|
||||
import WayofTime.bloodmagic.meteor.MeteorConfigHandler;
|
||||
import net.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.ConfigManager;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Config(modid = BloodMagic.MODID, name = BloodMagic.MODID + "/" + BloodMagic.MODID, category = "")
|
||||
@Mod.EventBusSubscriber(modid = BloodMagic.MODID)
|
||||
public class ConfigHandler {
|
||||
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();
|
||||
// @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,;
|
||||
// }
|
||||
// }
|
||||
|
||||
@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,33 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.iface.IAlchemyArray;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class AlchemyArrayEffect {
|
||||
public final String key;
|
||||
|
||||
public AlchemyArrayEffect(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public abstract boolean update(TileEntity tile, int ticksActive);
|
||||
|
||||
public abstract void writeToNBT(CompoundNBT tag);
|
||||
|
||||
public abstract void readFromNBT(CompoundNBT tag);
|
||||
|
||||
public abstract AlchemyArrayEffect getNewCopy();
|
||||
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, BlockState state, Entity entity) {
|
||||
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.vecmath.Vector2d;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.monster.MonsterEntity;
|
||||
import net.minecraft.entity.projectile.ArrowEntity;
|
||||
import net.minecraft.item.ArrowItem;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
|
||||
public class AlchemyArrayEffectArrowTurret extends AlchemyArrayEffect {
|
||||
public MobEntity target;
|
||||
public int arrowTimer;
|
||||
public static final int ARROW_WINDUP = 50;
|
||||
private int lastChestSlot = -1;
|
||||
|
||||
private double pitch = 0;
|
||||
private double lastPitch = 0;
|
||||
private double yaw = 0;
|
||||
private double lastYaw = 0;
|
||||
|
||||
public AlchemyArrayEffectArrowTurret(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
BlockPos pos = tile.getPos();
|
||||
World world = tile.getWorld();
|
||||
|
||||
BlockPos chestPos = pos.down();
|
||||
TileEntity chestTile = world.getTileEntity(chestPos);
|
||||
if (chestTile == null) {
|
||||
return false;
|
||||
}
|
||||
IItemHandler itemHandler = Utils.getInventory(chestTile, Direction.UP);
|
||||
if (itemHandler == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack arrowStack = new ItemStack(Items.AIR);
|
||||
if (lastChestSlot >= 0 && lastChestSlot < itemHandler.getSlots()) {
|
||||
ItemStack testStack = itemHandler.extractItem(lastChestSlot, 1, true);
|
||||
if (testStack.isEmpty() || !(testStack.getItem() instanceof ArrowItem)) {
|
||||
lastChestSlot = -1;
|
||||
} else {
|
||||
arrowStack = testStack;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastChestSlot < 0) {
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||
ItemStack testStack = itemHandler.extractItem(i, 1, true);
|
||||
if (!testStack.isEmpty() && testStack.getItem() instanceof ArrowItem) {
|
||||
arrowStack = testStack;
|
||||
lastChestSlot = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (lastChestSlot < 0) {
|
||||
return false; //No arrows in the chest. Welp!
|
||||
}
|
||||
|
||||
if (canFireOnMob(world, pos, target)) {
|
||||
Vector2d pitchYaw = getPitchYaw(pos, target);
|
||||
lastPitch = pitch;
|
||||
lastYaw = yaw;
|
||||
pitch = pitchYaw.x;
|
||||
yaw = pitchYaw.y;
|
||||
arrowTimer++;
|
||||
|
||||
if (arrowTimer >= ARROW_WINDUP) {
|
||||
// ItemStack arrowStack = new ItemStack(Items.ARROW);
|
||||
fireOnTarget(world, pos, arrowStack, target);
|
||||
if (!world.isRemote) {
|
||||
itemHandler.extractItem(lastChestSlot, 1, false);
|
||||
}
|
||||
arrowTimer = 0;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
target = null;
|
||||
arrowTimer = -1;
|
||||
}
|
||||
|
||||
List<MonsterEntity> mobsInRange = world.getEntitiesWithinAABB(MonsterEntity.class, getBounds(pos));
|
||||
|
||||
for (MonsterEntity entity : mobsInRange) {
|
||||
if (canFireOnMob(world, pos, entity))// && isMobInFilter(ent))
|
||||
{
|
||||
target = entity;
|
||||
arrowTimer = 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
arrowTimer = -1;
|
||||
target = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public double getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public double getLastPitch() {
|
||||
return lastPitch;
|
||||
}
|
||||
|
||||
public double getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public double getLastYaw() {
|
||||
return lastYaw;
|
||||
}
|
||||
|
||||
public void fireOnTarget(World world, BlockPos pos, ItemStack arrowStack, MobEntity targetMob) {
|
||||
float vel = 3f;
|
||||
double damage = 2;
|
||||
if (!world.isRemote) {
|
||||
if (arrowStack.getItem() instanceof ArrowItem) {
|
||||
// ItemArrow arrow = (ItemArrow) arrowStack.getItem();
|
||||
// EntityArrow entityarrow = arrow.createArrow(world, arrowStack, targetMob);
|
||||
ArrowEntity entityarrow = new ArrowEntity(world);
|
||||
entityarrow.setPotionEffect(arrowStack);
|
||||
entityarrow.posX = pos.getX() + 0.5;
|
||||
entityarrow.posY = pos.getY() + 0.5;
|
||||
entityarrow.posZ = pos.getZ() + 0.5;
|
||||
|
||||
double d0 = targetMob.posX - (pos.getX() + 0.5);
|
||||
double d1 = targetMob.posY + targetMob.height - (pos.getY() + 0.5);
|
||||
double d2 = targetMob.posZ - (pos.getZ() + 0.5);
|
||||
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
|
||||
entityarrow.setDamage(damage);
|
||||
entityarrow.shoot(d0, d1 + d3 * 0.05, d2, vel, 0);
|
||||
world.spawnEntity(entityarrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector2d getPitchYaw(BlockPos pos, Entity entityIn) {
|
||||
if (entityIn == null) {
|
||||
return new Vector2d(0, 0);
|
||||
}
|
||||
|
||||
double distanceX = entityIn.posX - (pos.getX() + 0.5);
|
||||
double distanceY = entityIn.posY + (double) entityIn.getEyeHeight() - (pos.getY() + 0.5);
|
||||
double distanceZ = entityIn.posZ - (pos.getZ() + 0.5);
|
||||
double radialDistance = Math.sqrt(distanceX * distanceX + distanceZ * distanceZ);
|
||||
double yaw = Math.atan2(-distanceX, distanceZ) * 180 / Math.PI;
|
||||
double pitch = -Math.atan2(distanceY, radialDistance) * 180 / Math.PI;
|
||||
|
||||
return new Vector2d(pitch, yaw);
|
||||
}
|
||||
|
||||
public boolean canEntityBeSeen(World world, BlockPos pos, Entity entityIn) {
|
||||
return world.rayTraceBlocks(new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), new Vec3d(entityIn.posX, entityIn.posY + (double) entityIn.getEyeHeight(), entityIn.posZ), false, true, false) == null;
|
||||
}
|
||||
|
||||
public boolean canFireOnMob(World world, BlockPos pos, Entity entityIn) {
|
||||
return entityIn != null && !entityIn.isDead && entityIn.getDistanceSqToCenter(pos) <= getRange() * getRange() && entityIn.getDistanceSqToCenter(pos) >= getMinRange() * getMinRange() && canEntityBeSeen(world, pos, entityIn);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBounds(BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).grow(getRange(), getRange(), getRange());
|
||||
}
|
||||
|
||||
public float getRange() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
public float getMinRange() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectArrowTurret(key);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,393 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.fakePlayer.FakePlayerBM;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.ai.goal.Goal;
|
||||
import net.minecraft.entity.ai.goal.GoalSelector;
|
||||
import net.minecraft.entity.ai.goal.GoalSelector.EntityAITaskEntry;
|
||||
import net.minecraft.entity.monster.*;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.pathfinding.Path;
|
||||
import net.minecraft.pathfinding.PathFinder;
|
||||
import net.minecraft.pathfinding.WalkNodeProcessor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Credits for the initial code go to Crazy Pants of EIO.
|
||||
*/
|
||||
public class AlchemyArrayEffectAttractor extends AlchemyArrayEffect {
|
||||
private FakePlayer target;
|
||||
private Set<MobEntity> tracking = new HashSet<>();
|
||||
|
||||
private int counter = 0;
|
||||
private int maxMobsAttracted = 10000;
|
||||
|
||||
private int cooldown = 50;
|
||||
|
||||
public AlchemyArrayEffectAttractor(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
if (tile.getWorld().isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockPos pos = tile.getPos();
|
||||
counter++;
|
||||
if (counter < 10) {
|
||||
for (MobEntity ent : tracking) {
|
||||
onEntityTick(pos, ent);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
counter = 0;
|
||||
|
||||
World world = tile.getWorld();
|
||||
|
||||
Set<MobEntity> trackingThisTick = new HashSet<>();
|
||||
List<MobEntity> entsInBounds = world.getEntitiesWithinAABB(MobEntity.class, getBounds(pos));
|
||||
|
||||
for (MobEntity ent : entsInBounds) {
|
||||
if (!ent.isDead)// && isMobInFilter(ent))
|
||||
{
|
||||
double x = (pos.getX() + 0.5D - ent.posX);
|
||||
double y = (pos.getY() + 1D - ent.posY);
|
||||
double z = (pos.getZ() + 0.5D - ent.posZ);
|
||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||
|
||||
if (distance < 2 && tracking.contains(ent)) {
|
||||
setEntityCooldown(pos, ent, cooldown);
|
||||
removeAssignedAITask(pos, ent);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!canEntityBeTracked(pos, ent)) {
|
||||
// System.out.println("Cooldown: " + getEntityCooldown(pos, ent));
|
||||
decrementEntityCooldown(pos, ent);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tracking.contains(ent)) {
|
||||
trackingThisTick.add(ent);
|
||||
onEntityTick(pos, ent);
|
||||
} else if (tracking.size() < maxMobsAttracted && trackMob(pos, ent)) {
|
||||
trackingThisTick.add(ent);
|
||||
onTracked(ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (MobEntity e : tracking) {
|
||||
if (!trackingThisTick.contains(e)) {
|
||||
onUntracked(e);
|
||||
}
|
||||
}
|
||||
tracking.clear();
|
||||
tracking = trackingThisTick;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEntityBeTracked(BlockPos pos, MobEntity entity) {
|
||||
return getEntityCooldown(pos, entity) <= 0;
|
||||
}
|
||||
|
||||
private String getPosKey(BlockPos pos) {
|
||||
return "BMAttractor:" + pos;
|
||||
}
|
||||
|
||||
public int getEntityCooldown(BlockPos pos, MobEntity entity) {
|
||||
return entity.getEntityData().getInteger(getPosKey(pos));
|
||||
}
|
||||
|
||||
public void setEntityCooldown(BlockPos pos, MobEntity entity, int cooldown) {
|
||||
entity.getEntityData().setInteger(getPosKey(pos), cooldown);
|
||||
}
|
||||
|
||||
public void decrementEntityCooldown(BlockPos pos, MobEntity entity) {
|
||||
int cooldown = getEntityCooldown(pos, entity);
|
||||
if (cooldown > 0) {
|
||||
setEntityCooldown(pos, entity, cooldown - 1);
|
||||
}
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBounds(BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange());
|
||||
}
|
||||
|
||||
public float getRange() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
private void onUntracked(MobEntity e) {
|
||||
if (e instanceof EndermanEntity) {
|
||||
e.getEntityData().setBoolean("BM:tracked", false);
|
||||
}
|
||||
}
|
||||
|
||||
private void onTracked(MobEntity e) {
|
||||
if (e instanceof EndermanEntity) {
|
||||
e.getEntityData().setBoolean("BM:tracked", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void onEntityTick(BlockPos pos, MobEntity ent) {
|
||||
if (ent instanceof SlimeEntity) {
|
||||
ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F);
|
||||
} else if (ent instanceof SilverfishEntity) {
|
||||
if (counter < 10) {
|
||||
return;
|
||||
}
|
||||
SilverfishEntity sf = (SilverfishEntity) ent;
|
||||
Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange());
|
||||
sf.getNavigator().setPath(pathentity, sf.getAIMoveSpeed());
|
||||
} else if (ent instanceof BlazeEntity) {
|
||||
double x = (pos.getX() + 0.5D - ent.posX);
|
||||
double y = (pos.getY() + 1D - ent.posY);
|
||||
double z = (pos.getZ() + 0.5D - ent.posZ);
|
||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||
if (distance > 1.25) {
|
||||
double speed = 0.01;
|
||||
ent.motionX += x / distance * speed;
|
||||
if (y > 0) {
|
||||
ent.motionY += (0.3 - ent.motionY) * 0.3;
|
||||
}
|
||||
ent.motionZ += z / distance * speed;
|
||||
}
|
||||
} else if (ent instanceof ZombiePigmanEntity || ent instanceof SpiderEntity) {
|
||||
forceMove(pos, ent);
|
||||
// ent.setAttackTarget(target);
|
||||
} else if (ent instanceof EndermanEntity) {
|
||||
ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos));
|
||||
}
|
||||
}
|
||||
|
||||
private void forceMove(BlockPos pos, MobEntity ent) {
|
||||
double x = (pos.getX() + 0.5D - ent.posX);
|
||||
double y = (pos.getY() + 1D - ent.posY);
|
||||
double z = (pos.getZ() + 0.5D - ent.posZ);
|
||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||
if (distance > 2) {
|
||||
MonsterEntity mod = (MonsterEntity) ent;
|
||||
mod.faceEntity(getTarget(ent.getEntityWorld(), pos), 180, 0);
|
||||
mod.getMoveHelper().strafe(0, 0.3f);
|
||||
if (mod.posY < pos.getY()) {
|
||||
mod.setJumping(true);
|
||||
} else {
|
||||
mod.setJumping(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Path getPathEntityToEntity(Entity entity, Entity targetEntity, float range) {
|
||||
int targX = MathHelper.floor(targetEntity.posX);
|
||||
int targY = MathHelper.floor(targetEntity.posY + 1.0D);
|
||||
int targZ = MathHelper.floor(targetEntity.posZ);
|
||||
|
||||
PathFinder pf = new PathFinder(new WalkNodeProcessor());
|
||||
return pf.findPath(targetEntity.getEntityWorld(), (MobEntity) entity, new BlockPos(targX, targY, targZ), range);
|
||||
}
|
||||
|
||||
private boolean trackMob(BlockPos pos, MobEntity ent) {
|
||||
//TODO: Figure out if this crud is needed
|
||||
if (useSetTarget(ent)) {
|
||||
ent.setAttackTarget(getTarget(ent.getEntityWorld(), pos));
|
||||
return true;
|
||||
} else if (useSpecialCase(ent)) {
|
||||
return applySpecialCase(pos, ent);
|
||||
} else {
|
||||
return attractUsingAITask(pos, ent);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean useSetTarget(MobEntity ent) {
|
||||
return ent instanceof ZombiePigmanEntity || ent instanceof SpiderEntity || ent instanceof SilverfishEntity;
|
||||
}
|
||||
|
||||
public void removeAssignedAITask(BlockPos pos, MobEntity ent) {
|
||||
Set<EntityAITaskEntry> entries = ent.tasks.taskEntries;
|
||||
Goal remove = null;
|
||||
for (EntityAITaskEntry entry : entries) {
|
||||
if (entry.action instanceof AttractTask) {
|
||||
AttractTask at = (AttractTask) entry.action;
|
||||
if (at.coord.equals(pos)) {
|
||||
remove = entry.action;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (remove != null) {
|
||||
ent.tasks.removeTask(remove);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean attractUsingAITask(BlockPos pos, MobEntity ent) {
|
||||
tracking.add(ent);
|
||||
Set<EntityAITaskEntry> entries = ent.tasks.taskEntries;
|
||||
// boolean hasTask = false;
|
||||
Goal remove = null;
|
||||
// boolean isTracked;
|
||||
for (EntityAITaskEntry entry : entries) {
|
||||
if (entry.action instanceof AttractTask) {
|
||||
AttractTask at = (AttractTask) entry.action;
|
||||
if (at.coord.equals(pos) || !at.shouldExecute()) {
|
||||
remove = entry.action;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (remove != null) {
|
||||
ent.tasks.removeTask(remove);
|
||||
}
|
||||
|
||||
cancelCurrentTasks(ent);
|
||||
ent.tasks.addTask(0, new AttractTask(ent, getTarget(ent.getEntityWorld(), pos), pos));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cancelCurrentTasks(MobEntity ent) {
|
||||
Iterator<EntityAITaskEntry> iterator = ent.tasks.taskEntries.iterator();
|
||||
|
||||
List<GoalSelector.EntityAITaskEntry> currentTasks = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
EntityAITaskEntry entityaitaskentry = iterator.next();
|
||||
if (entityaitaskentry != null) {
|
||||
if (entityaitaskentry.action instanceof AttractTask) {
|
||||
continue;
|
||||
}
|
||||
|
||||
currentTasks.add(entityaitaskentry);
|
||||
}
|
||||
}
|
||||
// Only available way to stop current execution is to remove all current
|
||||
// tasks, then re-add them
|
||||
for (EntityAITaskEntry task : currentTasks) {
|
||||
ent.tasks.removeTask(task.action);
|
||||
ent.tasks.addTask(task.priority, task.action);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean applySpecialCase(BlockPos pos, MobEntity ent) {
|
||||
if (ent instanceof SlimeEntity) {
|
||||
ent.faceEntity(getTarget(ent.getEntityWorld(), pos), 10.0F, 20.0F);
|
||||
// ent.setAttackTarget(getTarget(ent.worldObj, pos));
|
||||
return true;
|
||||
} else if (ent instanceof SilverfishEntity) {
|
||||
SilverfishEntity es = (SilverfishEntity) ent;
|
||||
Path pathentity = getPathEntityToEntity(ent, getTarget(ent.getEntityWorld(), pos), getRange());
|
||||
es.getNavigator().setPath(pathentity, es.getAIMoveSpeed());
|
||||
return true;
|
||||
} else if (ent instanceof BlazeEntity) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean useSpecialCase(MobEntity ent) {
|
||||
return ent instanceof SlimeEntity || ent instanceof SilverfishEntity || ent instanceof BlazeEntity;
|
||||
}
|
||||
|
||||
public FakePlayer getTarget(World world, BlockPos pos) {
|
||||
if (target == null) {
|
||||
// System.out.println("...Hi? " + pos);
|
||||
target = new Target(world, pos);
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectAttractor(key);
|
||||
}
|
||||
|
||||
private static class AttractTask extends Goal {
|
||||
private MobEntity mob;
|
||||
private BlockPos coord;
|
||||
private FakePlayer target;
|
||||
private int updatesSincePathing;
|
||||
|
||||
private boolean started = false;
|
||||
|
||||
private AttractTask(MobEntity mob, FakePlayer target, BlockPos coord) {
|
||||
this.mob = mob;
|
||||
this.coord = coord;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
boolean res = false;
|
||||
//TODO:
|
||||
TileEntity te = mob.getEntityWorld().getTileEntity(coord);
|
||||
if (te instanceof TileAlchemyArray) {
|
||||
res = true;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTask() {
|
||||
started = false;
|
||||
updatesSincePathing = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInterruptible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask() {
|
||||
if (!started || updatesSincePathing > 20) {
|
||||
started = true;
|
||||
int speed = 1;
|
||||
// mob.getNavigator().setAvoidsWater(false);
|
||||
boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed);
|
||||
if (!res) {
|
||||
mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed);
|
||||
}
|
||||
updatesSincePathing = 0;
|
||||
} else {
|
||||
updatesSincePathing++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class Target extends FakePlayerBM {
|
||||
public Target(World world, BlockPos pos) {
|
||||
super(world, pos, new GameProfile(null, BloodMagic.MODID + "ArrayAttractor" + ":" + pos));
|
||||
posY += 1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer;
|
||||
import net.minecraft.entity.effect.LightningBoltEntity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AlchemyArrayEffectBinding extends AlchemyArrayEffectCrafting {
|
||||
public AlchemyArrayEffectBinding(String key, ItemStack outputStack) {
|
||||
super(key, outputStack, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
if (ticksActive >= 50 && ticksActive <= 250) {
|
||||
// TODO: Find a way to spawn lightning from only the server side -
|
||||
// does not render when just spawned on server, not client.
|
||||
this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive);
|
||||
}
|
||||
|
||||
if (tile.getWorld().isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ticksActive >= 300) {
|
||||
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().spawnEntity(outputEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive) {
|
||||
if (ticksActive % 50 == 0) {
|
||||
int circle = ticksActive / 50 - 1;
|
||||
float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive);
|
||||
float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive);
|
||||
|
||||
double dispX = distance * Math.sin(angle);
|
||||
double dispZ = -distance * Math.cos(angle);
|
||||
|
||||
LightningBoltEntity lightning = new LightningBoltEntity(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ, true);
|
||||
world.spawnEntity(lightning);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
//EMPTY
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectBinding(key, outputStack);
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.iface.IAlchemyArray;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AlchemyArrayEffectBounce extends AlchemyArrayEffect {
|
||||
public AlchemyArrayEffectBounce(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, BlockState state, Entity entity) {
|
||||
if (entity.isSneaking()) {
|
||||
entity.fallDistance = 0;
|
||||
} else if (entity.motionY < 0.0D) {
|
||||
entity.motionY = -entity.motionY;
|
||||
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
entity.motionY *= 0.8D;
|
||||
}
|
||||
|
||||
entity.fallDistance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectBounce(key);
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
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.toString() + tickLimit, outputStack, tickLimit);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCrafting(String key, ItemStack outputStack, int tickLimit) {
|
||||
super(key);
|
||||
this.outputStack = outputStack;
|
||||
this.tickLimit = tickLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity 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().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(key, outputStack, tickLimit);
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class AlchemyArrayEffectCraftingNew extends AlchemyArrayEffect {
|
||||
|
||||
private final RecipeAlchemyArray recipe;
|
||||
|
||||
public AlchemyArrayEffectCraftingNew(RecipeAlchemyArray recipe) {
|
||||
this(recipe.getOutput().toString() + 200, recipe);
|
||||
}
|
||||
|
||||
public AlchemyArrayEffectCraftingNew(String key, RecipeAlchemyArray recipeAlchemyArray) {
|
||||
super(key);
|
||||
|
||||
this.recipe = recipeAlchemyArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
if (tile.getWorld().isRemote)
|
||||
return false;
|
||||
|
||||
if (ticksActive >= 200) {
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
ItemStack output = recipe.getOutput().copy();
|
||||
|
||||
ItemEntity outputEntity = new ItemEntity(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
|
||||
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 AlchemyArrayEffectCraftingNew(key, recipe);
|
||||
}
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FurnaceBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.FurnaceTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AlchemyArrayEffectFurnaceFuel extends AlchemyArrayEffect {
|
||||
static double radius = 10;
|
||||
static int burnTicksAdded = 401; //Set to +1 more than it needs to be due to a hacky method - basically done so that the array doesn't double dip your health if you only add one item.
|
||||
|
||||
public AlchemyArrayEffectFurnaceFuel(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
BlockPos pos = tile.getPos();
|
||||
World world = tile.getWorld();
|
||||
PlayerEntity sacrifice = null;
|
||||
|
||||
for (Direction face : Direction.VALUES) {
|
||||
BlockPos furnacePos = pos.offset(face);
|
||||
Block block = world.getBlockState(furnacePos).getBlock();
|
||||
if (block != Blocks.FURNACE) //This will only work vanilla furnaces. No others!
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
TileEntity bottomTile = world.getTileEntity(furnacePos);
|
||||
if (bottomTile instanceof FurnaceTileEntity) {
|
||||
FurnaceTileEntity furnaceTile = (FurnaceTileEntity) bottomTile;
|
||||
if (canFurnaceSmelt(furnaceTile) && !furnaceTile.isBurning()) {
|
||||
if (sacrifice == null || sacrifice.isDead) {
|
||||
AxisAlignedBB bb = new AxisAlignedBB(pos).grow(radius);
|
||||
List<PlayerEntity> playerList = world.getEntitiesWithinAABB(PlayerEntity.class, bb);
|
||||
for (PlayerEntity player : playerList) {
|
||||
if (!player.isDead) {
|
||||
sacrifice = player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sacrifice == null || sacrifice.isDead) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (addFuelTime(furnaceTile, world, furnacePos, burnTicksAdded)) {
|
||||
if (!sacrifice.capabilities.isCreativeMode) {
|
||||
sacrifice.hurtResistantTime = 0;
|
||||
sacrifice.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 1.0F); //No.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean addFuelTime(FurnaceTileEntity furnaceTile, World world, BlockPos furnacePos, int cookTime) {
|
||||
furnaceTile.setField(0, cookTime);
|
||||
FurnaceBlock.setState(true, world, furnacePos);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean canFurnaceSmelt(FurnaceTileEntity furnaceTile) {
|
||||
ItemStack burnStack = furnaceTile.getStackInSlot(0);
|
||||
if (burnStack.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
ItemStack resultStack = FurnaceRecipes.instance().getSmeltingResult(burnStack);
|
||||
|
||||
if (resultStack.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
ItemStack finishStack = furnaceTile.getStackInSlot(2);
|
||||
|
||||
if (finishStack.isEmpty()) {
|
||||
return true;
|
||||
} else if (!finishStack.isItemEqual(resultStack)) {
|
||||
return false;
|
||||
} else if (finishStack.getCount() + resultStack.getCount() <= furnaceTile.getInventoryStackLimit() && finishStack.getCount() + resultStack.getCount() <= finishStack.getMaxStackSize()) // Forge fix: make furnace respect stack sizes in furnace recipes
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return finishStack.getCount() + resultStack.getCount() <= resultStack.getMaxStackSize(); // Forge fix: make furnace respect stack sizes in furnace recipes
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectFurnaceFuel(key);
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import WayofTime.bloodmagic.event.TeleposeEvent;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
|
||||
public class AlchemyArrayEffectLaputa extends AlchemyArrayEffect {
|
||||
public static final int TELEPOSE_DELAY = 4;
|
||||
|
||||
private BlockPos currentPos = BlockPos.ORIGIN;
|
||||
|
||||
private int radius = -1;
|
||||
private int teleportHeightOffset = 5;
|
||||
|
||||
public AlchemyArrayEffectLaputa(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
if (ticksActive >= 100) {
|
||||
World world = tile.getWorld();
|
||||
|
||||
if (radius == -1) {
|
||||
((TileAlchemyArray) tile).setItemDrop(false);
|
||||
radius = getRandomRadius(world.rand);
|
||||
teleportHeightOffset = getRandomHeightOffset(world.rand);
|
||||
currentPos = new BlockPos(-radius, -radius, -radius);
|
||||
}
|
||||
|
||||
BlockPos pos = tile.getPos();
|
||||
if (world.isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int j = -radius;
|
||||
int i = -radius;
|
||||
int k = -radius;
|
||||
|
||||
if (currentPos != null) {
|
||||
j = currentPos.getY();
|
||||
i = currentPos.getX();
|
||||
k = currentPos.getZ();
|
||||
}
|
||||
int checks = 0;
|
||||
int maxChecks = 100;
|
||||
|
||||
while (j <= radius) {
|
||||
while (i <= radius) {
|
||||
while (k <= radius) {
|
||||
if (i == 0 && j == 0 && k == 0) {
|
||||
k++;
|
||||
continue;
|
||||
}
|
||||
|
||||
checks++;
|
||||
if (checks >= maxChecks) {
|
||||
this.currentPos = new BlockPos(i, j, k);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (checkIfSphere(radius, i, j, k)) {
|
||||
BlockPos newPos = pos.add(i, j, k);
|
||||
BlockPos offsetPos = newPos.up(teleportHeightOffset);
|
||||
BlockState state = world.getBlockState(newPos);
|
||||
|
||||
TeleposeEvent event = new TeleposeEvent(world, newPos, world, offsetPos);
|
||||
if (state.getBlockHardness(world, newPos) > 0 && !MinecraftForge.EVENT_BUS.post(event) && Utils.swapLocations(event.initalWorld, event.initialBlockPos, event.finalWorld, event.finalBlockPos)) {
|
||||
k++;
|
||||
this.currentPos = new BlockPos(i, j, k);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
k++;
|
||||
}
|
||||
i++;
|
||||
k = -radius;
|
||||
}
|
||||
j++;
|
||||
i = -radius;
|
||||
this.currentPos = new BlockPos(i, j, k);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkIfSphere(float radius, float xOff, float yOff, float zOff) {
|
||||
float possOffset = 0.5f;
|
||||
return xOff * xOff + yOff * yOff + zOff * zOff <= ((radius + possOffset) * (radius + possOffset));
|
||||
}
|
||||
|
||||
public int getRandomRadius(Random rand) {
|
||||
return rand.nextInt(5) + 4;
|
||||
}
|
||||
|
||||
public int getRandomHeightOffset(Random rand) {
|
||||
return radius * 2 + 1 + rand.nextInt(5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
tag.putInt("radius", radius);
|
||||
tag.putInt("teleportHeightOffset", teleportHeightOffset);
|
||||
tag.putInt(Constants.NBT.X_COORD, currentPos.getX());
|
||||
tag.putInt(Constants.NBT.Y_COORD, currentPos.getY());
|
||||
tag.putInt(Constants.NBT.Z_COORD, currentPos.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
radius = tag.getInt("radius");
|
||||
teleportHeightOffset = tag.getInt("teleportHeightOffset");
|
||||
currentPos = new BlockPos(tag.getInt(Constants.NBT.X_COORD), tag.getInt(Constants.NBT.Y_COORD), tag.getInt(Constants.NBT.Z_COORD));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectLaputa(key);
|
||||
}
|
||||
}
|
|
@ -1,202 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
import WayofTime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.impl.recipe.RecipeSacrificeCraft;
|
||||
import WayofTime.bloodmagic.ritual.AreaDescriptor;
|
||||
import WayofTime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
|
||||
public class AlchemyArrayEffectMobSacrifice extends AlchemyArrayEffect {
|
||||
public static final AreaDescriptor itemDescriptor = new AreaDescriptor.Rectangle(new BlockPos(-5, -5, -5), 11);
|
||||
public static final AreaDescriptor mobDescriptor = new AreaDescriptor.Rectangle(new BlockPos(-5, -5, -5), 11);
|
||||
public int craftTime = 0;
|
||||
public static final int REQUIRED_CRAFT_TIME = 200;
|
||||
|
||||
public AlchemyArrayEffectMobSacrifice(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
World world = tile.getWorld();
|
||||
if (world.isRemote && ticksActive < 200 && ticksActive > 40) {
|
||||
BlockPos pos = tile.getPos();
|
||||
Random rand = world.rand;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
double d0 = (double) pos.getX() + 0.5D + (rand.nextDouble() - 0.5D) * 2.5D;
|
||||
double d1 = (double) pos.getY() + 0.2D + (rand.nextDouble() - 0.5D) * 0.2D;
|
||||
double d2 = (double) pos.getZ() + 0.5D + (rand.nextDouble() - 0.5D) * 2.5D;
|
||||
world.spawnParticle(EnumParticleTypes.SPELL_MOB, d0, d1, d2, 1D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
//We need to do the check on both sides to correctly do particles.
|
||||
|
||||
if (ticksActive >= 200) {
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
List<ItemEntity> itemList = world.getEntitiesWithinAABB(ItemEntity.class, itemDescriptor.getAABB(pos));
|
||||
|
||||
List<ItemStack> inputList = new ArrayList<ItemStack>();
|
||||
|
||||
for (ItemEntity entityItem : itemList) {
|
||||
if (entityItem.isDead || entityItem.getItem().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
inputList.add(entityItem.getItem().copy());
|
||||
}
|
||||
|
||||
if (inputList.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (inputList.size() == 1) //TODO: Test if it is a something that can be filled with Soul Breath
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RecipeSacrificeCraft recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getSacrificeCraft(inputList);
|
||||
if (recipe != null) {
|
||||
double healthRequired = recipe.getHealthRequired();
|
||||
double healthAvailable = 0;
|
||||
|
||||
List<LivingEntity> livingEntities = world.getEntitiesWithinAABB(LivingEntity.class, mobDescriptor.getAABB(pos));
|
||||
for (LivingEntity living : livingEntities) {
|
||||
double health = getEffectiveHealth(living);
|
||||
if (health > 0) {
|
||||
healthAvailable += health;
|
||||
}
|
||||
}
|
||||
|
||||
if (healthAvailable < healthRequired) {
|
||||
craftTime = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
craftTime++;
|
||||
|
||||
if (craftTime >= REQUIRED_CRAFT_TIME) {
|
||||
if (!world.isRemote) {
|
||||
for (LivingEntity living : livingEntities) {
|
||||
double health = getEffectiveHealth(living);
|
||||
if (healthAvailable > 0 && health > 0) {
|
||||
healthAvailable -= health;
|
||||
living.getEntityWorld().playSound(null, living.posX, living.posY, living.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (living.getEntityWorld().rand.nextFloat() - living.getEntityWorld().rand.nextFloat()) * 0.8F);
|
||||
living.setHealth(-1);
|
||||
living.onDeath(DamageSourceBloodMagic.INSTANCE);
|
||||
}
|
||||
|
||||
if (healthAvailable <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemEntity itemEntity : itemList) {
|
||||
itemEntity.getItem().setCount(itemEntity.getItem().getCount() - 1);
|
||||
if (itemEntity.getItem().isEmpty()) //TODO: Check container
|
||||
{
|
||||
itemEntity.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
world.spawnEntity(new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 2.5, pos.getZ() + 0.5, recipe.getOutput()));
|
||||
craftTime = 0;
|
||||
}
|
||||
} else {
|
||||
if (world.isRemote) {
|
||||
Vec3d spawnPosition = new Vec3d(pos.getX() + 0.5, pos.getY() + 2.5, pos.getZ() + 0.5);
|
||||
for (ItemEntity itemEntity : itemList) {
|
||||
ItemStack stack = itemEntity.getItem();
|
||||
double velocityFactor = 0.1;
|
||||
|
||||
Vec3d itemPosition = new Vec3d(itemEntity.posX, itemEntity.posY + 0.5, itemEntity.posZ);
|
||||
Vec3d velVec1 = new Vec3d((world.rand.nextDouble() - 0.5) * velocityFactor, (world.rand.nextDouble() - 0.5) * velocityFactor, (world.rand.nextDouble() - 0.5) * velocityFactor);
|
||||
// Vec3d velVec2 = new Vec3d((world.rand.nextDouble() - 0.5) * velocityFactor, (world.rand.nextDouble()) * velocityFactor, (world.rand.nextDouble() - 0.5) * velocityFactor);
|
||||
|
||||
// vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
|
||||
// if (this.world instanceof WorldServer) //Forge: Fix MC-2518 spawnParticle is nooped on server, need to use server specific variant
|
||||
// ((WorldServer)this.world).spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.x, vec3d1.y, vec3d1.z, 0, vec3d.x, vec3d.y + 0.05D, vec3d.z, 0.0D, Item.getIdFromItem(stack.getItem()), stack.getMetadata());
|
||||
// else //Fix the fact that spawning ItemCrack uses TWO arguments.
|
||||
world.spawnParticle(EnumParticleTypes.ITEM_CRACK, itemPosition.x + (spawnPosition.x - itemPosition.x) * craftTime / REQUIRED_CRAFT_TIME, itemPosition.y + (spawnPosition.y - itemPosition.y) * craftTime / REQUIRED_CRAFT_TIME, itemPosition.z + (spawnPosition.z - itemPosition.z) * craftTime / REQUIRED_CRAFT_TIME, velVec1.x, velVec1.y, velVec1.z, Item.getIdFromItem(stack.getItem()), stack.getMetadata());
|
||||
// world.spawnParticle(EnumParticleTypes.ITEM_CRACK, spawnPosition.x, spawnPosition.y, spawnPosition.z, velVec2.x, velVec2.y, velVec2.z, Item.getIdFromItem(stack.getItem()), stack.getMetadata());
|
||||
}
|
||||
|
||||
for (LivingEntity living : livingEntities) {
|
||||
double health = getEffectiveHealth(living);
|
||||
if (health <= 0) {
|
||||
continue;
|
||||
}
|
||||
double d0 = (double) living.posX + (world.rand.nextDouble() - 0.5D) * 0.5D;
|
||||
double d1 = (double) living.posY + 0.5D + (world.rand.nextDouble() - 0.5D) * 1D;
|
||||
double d2 = (double) living.posZ + (world.rand.nextDouble() - 0.5D) * 0.5D;
|
||||
world.spawnParticle(EnumParticleTypes.SPELL_MOB, d0, d1, d2, 1D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Future-proofing in case I want to make different mobs give different effective health
|
||||
public double getEffectiveHealth(LivingEntity living) {
|
||||
if (living == null)
|
||||
return 0;
|
||||
|
||||
if (!living.isNonBoss())
|
||||
return 0;
|
||||
|
||||
if (living instanceof PlayerEntity)
|
||||
return 0;
|
||||
|
||||
if (living.isChild() && !(living instanceof IMob))
|
||||
return 0;
|
||||
|
||||
if (living.isDead || living.getHealth() < 0.5F)
|
||||
return 0;
|
||||
|
||||
EntityEntry entityEntry = EntityRegistry.getEntry(living.getClass());
|
||||
if (entityEntry == null)
|
||||
return 0;
|
||||
|
||||
return living.getHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectMobSacrifice(key);
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.iface.IAlchemyArray;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AlchemyArrayEffectMovement extends AlchemyArrayEffect {
|
||||
public AlchemyArrayEffectMovement(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, BlockState state, Entity entity) {
|
||||
double motionY = 0.5;
|
||||
double motionYGlowstoneMod = 0.05;
|
||||
double speed = 1.5;
|
||||
double speedRedstoneMod = 0.15;
|
||||
|
||||
Direction direction = array.getRotation();
|
||||
TileAlchemyArray tileArray = (TileAlchemyArray) array;
|
||||
|
||||
motionY += motionYGlowstoneMod * (tileArray.getStackInSlot(0).getCount() - 1);
|
||||
speed += speedRedstoneMod * (tileArray.getStackInSlot(1).getCount() - 1);
|
||||
|
||||
entity.motionY = motionY;
|
||||
entity.fallDistance = 0;
|
||||
|
||||
switch (direction) {
|
||||
case NORTH:
|
||||
entity.motionX = 0;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = -speed;
|
||||
break;
|
||||
|
||||
case SOUTH:
|
||||
entity.motionX = 0;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = speed;
|
||||
break;
|
||||
|
||||
case WEST:
|
||||
entity.motionX = -speed;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = 0;
|
||||
break;
|
||||
|
||||
case EAST:
|
||||
entity.motionX = speed;
|
||||
entity.motionY = motionY;
|
||||
entity.motionZ = 0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectMovement(key);
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.iface.ISigil;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class AlchemyArrayEffectSigil extends AlchemyArrayEffect {
|
||||
private final ISigil sigil;
|
||||
|
||||
public AlchemyArrayEffectSigil(String key, ISigil sigil) {
|
||||
super(key);
|
||||
this.sigil = sigil;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
//TODO: Need particles.
|
||||
if (sigil.hasArrayEffect()) {
|
||||
sigil.performArrayEffect(tile.getWorld(), tile.getPos());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectSigil(key, sigil);
|
||||
}
|
||||
}
|
|
@ -1,186 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import com.google.common.base.Predicate;
|
||||
import net.minecraft.entity.MobEntity;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.ai.goal.GoalSelector;
|
||||
import net.minecraft.entity.ai.goal.GoalSelector.EntityAITaskEntry;
|
||||
import net.minecraft.entity.ai.goal.Goal;
|
||||
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
|
||||
import net.minecraft.entity.monster.MonsterEntity;
|
||||
import net.minecraft.entity.monster.SkeletonEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Credits for the initial code go to Crazy Pants of EIO.
|
||||
*/
|
||||
public class AlchemyArrayEffectSkeletonTurret extends AlchemyArrayEffect {
|
||||
public static Predicate<MonsterEntity> checkSkeleton = input -> !(input instanceof SkeletonEntity);
|
||||
private SkeletonEntity turret;
|
||||
|
||||
public AlchemyArrayEffectSkeletonTurret(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
// if (tile.getWorld().isRemote)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
if (turret != null && !turret.isDead) {
|
||||
double x = (pos.getX() + 0.5D - turret.posX);
|
||||
double y = (pos.getY() + 1D - turret.posY);
|
||||
double z = (pos.getZ() + 0.5D - turret.posZ);
|
||||
double distance = Math.sqrt(x * x + y * y + z * z);
|
||||
|
||||
if (distance < 2) {
|
||||
// turret.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 100, 100));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
World world = tile.getWorld();
|
||||
|
||||
List<SkeletonEntity> skeletonsInRange = world.getEntitiesWithinAABB(SkeletonEntity.class, getBounds(pos));
|
||||
|
||||
for (SkeletonEntity entity : skeletonsInRange) {
|
||||
if (!entity.isDead)// && isMobInFilter(ent))
|
||||
{
|
||||
modifyAITargetTasks(entity);
|
||||
turret = entity;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBounds(BlockPos pos) {
|
||||
return new AxisAlignedBB(pos).expand(getRange(), getRange(), getRange());
|
||||
}
|
||||
|
||||
public float getRange() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// private void onUntracked(EntityLiving e)
|
||||
// {
|
||||
// e.getEntityData().setBoolean("BM:tracked", false);
|
||||
// }
|
||||
//
|
||||
// private void onTracked(EntityLiving e)
|
||||
// {
|
||||
// e.getEntityData().setBoolean("BM:tracked", true);
|
||||
// }
|
||||
|
||||
private boolean modifyAITargetTasks(SkeletonEntity entity) {
|
||||
cancelCurrentTargetTasks(entity);
|
||||
|
||||
// entity.setCombatTask();
|
||||
entity.targetTasks.addTask(1, new NearestAttackableTargetGoal(entity, MonsterEntity.class, 10, true, false, checkSkeleton));
|
||||
entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0);
|
||||
entity.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).setBaseValue(1);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cancelCurrentTargetTasks(MobEntity entity) {
|
||||
Iterator<EntityAITaskEntry> iterator = entity.targetTasks.taskEntries.iterator();
|
||||
|
||||
List<GoalSelector.EntityAITaskEntry> currentTasks = new ArrayList<>();
|
||||
while (iterator.hasNext()) {
|
||||
EntityAITaskEntry entityaitaskentry = iterator.next();
|
||||
if (entityaitaskentry != null)// && entityaitaskentry.action instanceof EntityAITarget)
|
||||
{
|
||||
currentTasks.add(entityaitaskentry);
|
||||
}
|
||||
}
|
||||
|
||||
for (EntityAITaskEntry task : currentTasks) {
|
||||
entity.targetTasks.removeTask(task.action);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectSkeletonTurret(key);
|
||||
}
|
||||
|
||||
private static class AttractTask extends Goal {
|
||||
private MobEntity mob;
|
||||
private BlockPos coord;
|
||||
private FakePlayer target;
|
||||
private int updatesSincePathing;
|
||||
|
||||
private boolean started = false;
|
||||
|
||||
private AttractTask(MobEntity mob, FakePlayer target, BlockPos coord) {
|
||||
this.mob = mob;
|
||||
this.coord = coord;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
boolean res = false;
|
||||
//TODO:
|
||||
TileEntity te = mob.getEntityWorld().getTileEntity(coord);
|
||||
if (te instanceof TileAlchemyArray) {
|
||||
res = true;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTask() {
|
||||
started = false;
|
||||
updatesSincePathing = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInterruptible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTask() {
|
||||
if (!started || updatesSincePathing > 20) {
|
||||
started = true;
|
||||
int speed = 1;
|
||||
// mob.getNavigator().setAvoidsWater(false);
|
||||
boolean res = mob.getNavigator().tryMoveToEntityLiving(target, speed);
|
||||
if (!res) {
|
||||
mob.getNavigator().tryMoveToXYZ(target.posX, target.posY + 1, target.posZ, speed);
|
||||
}
|
||||
updatesSincePathing = 0;
|
||||
} else {
|
||||
updatesSincePathing++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.iface.IAlchemyArray;
|
||||
|
||||
public class AlchemyArrayEffectSpike extends AlchemyArrayEffect {
|
||||
public AlchemyArrayEffectSpike(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, BlockState state, Entity entity) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
entity.attackEntityFrom(DamageSource.CACTUS, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectSpike(key);
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.network.play.server.SUpdateHealthPacket;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.iface.IAlchemyArray;
|
||||
|
||||
public class AlchemyArrayEffectTeleport extends AlchemyArrayEffect {
|
||||
public static final int MAX_SEARCH = 20;
|
||||
public static final int TELEPORT_DELAY = 40;
|
||||
|
||||
public AlchemyArrayEffectTeleport(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, BlockState state, Entity entity) {
|
||||
Direction direction = array.getRotation();
|
||||
|
||||
teleportEntityInDirection(world, pos, entity, direction);
|
||||
}
|
||||
|
||||
public void teleportEntityInDirection(World world, BlockPos currentPos, Entity entity, Direction direction) {
|
||||
if (entity != null && entity.timeUntilPortal <= 0) {
|
||||
for (int i = 1; i <= MAX_SEARCH; i++) {
|
||||
BlockPos offsetPos = currentPos.offset(direction, i);
|
||||
Block testBlock = world.getBlockState(offsetPos).getBlock();
|
||||
if (testBlock == RegistrarBloodMagicBlocks.ALCHEMY_ARRAY) {
|
||||
int x = offsetPos.getX();
|
||||
int y = offsetPos.getY();
|
||||
int z = offsetPos.getZ();
|
||||
|
||||
entity.getEntityWorld().playSound(x, y, z, SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.AMBIENT, 1.0F, 1.0F, false);
|
||||
entity.timeUntilPortal = TELEPORT_DELAY;
|
||||
if (!world.isRemote) {
|
||||
if (entity instanceof PlayerEntity) {
|
||||
ServerPlayerEntity player = (ServerPlayerEntity) entity;
|
||||
|
||||
player.setPositionAndUpdate(x + 0.5, y + 0.5, z + 0.5);
|
||||
player.getEntityWorld().updateEntityWithOptionalForce(player, false);
|
||||
player.connection.sendPacket(new SUpdateHealthPacket(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel()));
|
||||
|
||||
} else {
|
||||
ServerWorld worldServer = (ServerWorld) entity.getEntityWorld();
|
||||
|
||||
entity.setPosition(x + 0.5, y + 0.5, z + 0.5);
|
||||
worldServer.resetUpdateEntityTick();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectTeleport(key);
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.iface.IAlchemyArray;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class AlchemyArrayEffectUpdraft extends AlchemyArrayEffect {
|
||||
public AlchemyArrayEffectUpdraft(String key) {
|
||||
super(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(IAlchemyArray array, World world, BlockPos pos, BlockState state, Entity entity) {
|
||||
double motionY = 1;
|
||||
double motionYGlowstoneMod = 0.1;
|
||||
double motionYFeatherMod = 0.05;
|
||||
|
||||
entity.fallDistance = 0;
|
||||
TileAlchemyArray tileArray = (TileAlchemyArray) array;
|
||||
motionY += motionYGlowstoneMod * (tileArray.getStackInSlot(0).getCount() - 1); // Glowstone Dust
|
||||
motionY += motionYFeatherMod * (tileArray.getStackInSlot(1).getCount() - 1); // Feathers
|
||||
|
||||
entity.motionY = motionY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlchemyArrayEffect getNewCopy() {
|
||||
return new AlchemyArrayEffectUpdraft(key);
|
||||
}
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class AlchemyCircleRenderer {
|
||||
public final ResourceLocation arrayResource;
|
||||
public float offsetFromFace = -0.9f;
|
||||
|
||||
public AlchemyCircleRenderer() {
|
||||
this(new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/SightSigil.png"));
|
||||
}
|
||||
|
||||
public AlchemyCircleRenderer(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) * Math.pow((craftTime - 5) / 35f, 3));
|
||||
} else {
|
||||
return -0.4f;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
|
||||
if (!(tile instanceof TileAlchemyArray)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileAlchemyArray tileArray = (TileAlchemyArray) tile;
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder wr = tessellator.getBuffer();
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
// float rot = (float)(this.worldObj.provider.getWorldTime() % (360 /
|
||||
// this.rotationspeed) * this.rotationspeed) + this.rotationspeed * f;
|
||||
float rot = getRotation(craftTime);
|
||||
float secondaryRot = getSecondaryRotation(craftTime);
|
||||
|
||||
float size = 1.0F * getSizeModifier(craftTime);
|
||||
|
||||
// Bind the texture to the circle
|
||||
Minecraft.getInstance().renderEngine.bindTexture(arrayResource);
|
||||
|
||||
GlStateManager.disableCull();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
|
||||
GlStateManager.translate(x, y, z);
|
||||
|
||||
// Specify which face this "circle" is located on
|
||||
Direction sideHit = Direction.UP;
|
||||
Direction rotation = tileArray.getRotation();
|
||||
|
||||
GlStateManager.translate(sideHit.getXOffset() * offsetFromFace, sideHit.getYOffset() * offsetFromFace, sideHit.getZOffset() * offsetFromFace);
|
||||
|
||||
switch (sideHit) {
|
||||
case DOWN:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(-90.0f, 1, 0, 0);
|
||||
break;
|
||||
case EAST:
|
||||
GlStateManager.rotate(-90.0f, 0, 1, 0);
|
||||
GlStateManager.translate(0, 0, -1);
|
||||
break;
|
||||
case NORTH:
|
||||
break;
|
||||
case SOUTH:
|
||||
GlStateManager.rotate(180.0f, 0, 1, 0);
|
||||
GlStateManager.translate(-1, 0, -1);
|
||||
break;
|
||||
case UP:
|
||||
GlStateManager.translate(0, 1, 0);
|
||||
GlStateManager.rotate(90.0f, 1, 0, 0);
|
||||
break;
|
||||
case WEST:
|
||||
GlStateManager.translate(0, 0, 1);
|
||||
GlStateManager.rotate(90.0f, 0, 1, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
|
||||
GlStateManager.rotate(rotation.getHorizontalAngle() + 180, 0, 0, 1);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.rotate(rot, 0, 0, 1);
|
||||
GlStateManager.rotate(secondaryRot, 1, 0, 0);
|
||||
GlStateManager.rotate(secondaryRot * 0.45812f, 0, 0, 1);
|
||||
double var31 = 0.0D;
|
||||
double var33 = 1.0D;
|
||||
double var35 = 0;
|
||||
double var37 = 1;
|
||||
|
||||
GlStateManager.color(1f, 1f, 1f, 1f);
|
||||
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
// wr.setBrightness(200);
|
||||
wr.pos(size / 2f, size / 2f, 0.0D).tex(var33, var37).endVertex();
|
||||
wr.pos(size / 2f, -size / 2f, 0.0D).tex(var33, var35).endVertex();
|
||||
wr.pos(-size / 2f, -size / 2f, 0.0D).tex(var31, var35).endVertex();
|
||||
wr.pos(-size / 2f, size / 2f, 0.0D).tex(var31, var37).endVertex();
|
||||
tessellator.draw();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
// GlStateManager.depthMask(true);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableCull();
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
|
@ -1,55 +1,62 @@
|
|||
package WayofTime.bloodmagic.altar;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* 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 BlockPos getOffset()
|
||||
{
|
||||
return offset;
|
||||
}
|
||||
|
||||
public boolean isUpgradeSlot() {
|
||||
return upgradeSlot;
|
||||
}
|
||||
public boolean isUpgradeSlot()
|
||||
{
|
||||
return upgradeSlot;
|
||||
}
|
||||
|
||||
public ComponentType getComponent() {
|
||||
return component;
|
||||
}
|
||||
public ComponentType getComponent()
|
||||
{
|
||||
return component;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,149 +1,172 @@
|
|||
package WayofTime.bloodmagic.altar;
|
||||
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
package wayoftime.bloodmagic.altar;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
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));
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
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);
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
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());
|
||||
}
|
||||
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 <= 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)));
|
||||
}
|
||||
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);
|
||||
|
||||
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 = -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 = -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 = -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)));
|
||||
}
|
||||
|
||||
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(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));
|
||||
|
||||
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 = -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 = -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());
|
||||
}
|
||||
}
|
||||
};
|
||||
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)));
|
||||
}
|
||||
|
||||
public static final int MAXTIERS = ConfigHandler.general.enableTierSixEvenThoughThereIsNoContent ? values().length : values().length - 1;
|
||||
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));
|
||||
|
||||
private List<AltarComponent> altarComponents;
|
||||
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());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AltarTier() {
|
||||
this.altarComponents = Lists.newArrayList();
|
||||
public static final int MAXTIERS = values().length;
|
||||
|
||||
buildComponents(altarComponents::add);
|
||||
}
|
||||
private List<AltarComponent> altarComponents;
|
||||
|
||||
public abstract void buildComponents(Consumer<AltarComponent> components);
|
||||
AltarTier()
|
||||
{
|
||||
this.altarComponents = Lists.newArrayList();
|
||||
|
||||
public int toInt() {
|
||||
return ordinal() + 1;
|
||||
}
|
||||
buildComponents(altarComponents::add);
|
||||
}
|
||||
|
||||
public List<AltarComponent> getAltarComponents() {
|
||||
return altarComponents;
|
||||
}
|
||||
}
|
||||
public abstract void buildComponents(Consumer<AltarComponent> components);
|
||||
|
||||
public int toInt()
|
||||
{
|
||||
return ordinal() + 1;
|
||||
}
|
||||
|
||||
public List<AltarComponent> getAltarComponents()
|
||||
{
|
||||
return altarComponents;
|
||||
}
|
||||
}
|
|
@ -1,24 +1,29 @@
|
|||
package WayofTime.bloodmagic.altar;
|
||||
|
||||
import WayofTime.bloodmagic.block.enums.BloodRuneType;
|
||||
import com.google.common.collect.Maps;
|
||||
package wayoftime.bloodmagic.altar;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class AltarUpgrade {
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
private final EnumMap<BloodRuneType, Integer> upgradeLevels;
|
||||
import wayoftime.bloodmagic.block.enums.BloodRuneType;
|
||||
|
||||
public AltarUpgrade() {
|
||||
this.upgradeLevels = Maps.newEnumMap(BloodRuneType.class);
|
||||
}
|
||||
public class AltarUpgrade
|
||||
{
|
||||
|
||||
public AltarUpgrade upgrade(BloodRuneType rune) {
|
||||
upgradeLevels.compute(rune, (r, l) -> l == null ? 1 : l + 1);
|
||||
return this;
|
||||
}
|
||||
private final EnumMap<BloodRuneType, Integer> upgradeLevels;
|
||||
|
||||
public int getLevel(BloodRuneType rune) {
|
||||
return upgradeLevels.getOrDefault(rune, 0);
|
||||
}
|
||||
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,86 +1,99 @@
|
|||
package WayofTime.bloodmagic.altar;
|
||||
package wayoftime.bloodmagic.altar;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.block.BlockBloodRune;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
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 org.apache.commons.lang3.tuple.Pair;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.common.block.BlockBloodRune;
|
||||
import wayoftime.bloodmagic.tile.TileAltar;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
public class AltarUtil
|
||||
{
|
||||
|
||||
public class AltarUtil {
|
||||
@Nonnull
|
||||
public static AltarTier getTier(World world, BlockPos pos)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (!(tile instanceof TileAltar))
|
||||
return AltarTier.ONE;
|
||||
|
||||
@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);
|
||||
|
||||
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 (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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
List<BlockState> validStates = BloodMagicAPI.INSTANCE.getComponentStates(component.getComponent());
|
||||
if (!validStates.contains(worldState))
|
||||
return lastCheck;
|
||||
}
|
||||
lastCheck = tier;
|
||||
}
|
||||
|
||||
lastCheck = tier;
|
||||
}
|
||||
return lastCheck;
|
||||
}
|
||||
|
||||
return lastCheck;
|
||||
}
|
||||
@Nonnull
|
||||
public static AltarUpgrade getUpgrades(World world, BlockPos pos, AltarTier currentTier)
|
||||
{
|
||||
AltarUpgrade upgrades = new AltarUpgrade();
|
||||
|
||||
@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;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
BlockPos componentPos = pos.add(component.getOffset());
|
||||
BlockState state = world.getBlockState(componentPos);
|
||||
if (state.getBlock() instanceof BlockBloodRune)
|
||||
upgrades.upgrade(((BlockBloodRune) state.getBlock()).getBloodRune(world, componentPos, state));
|
||||
}
|
||||
return upgrades;
|
||||
}
|
||||
|
||||
return upgrades;
|
||||
}
|
||||
@Nullable
|
||||
public static Pair<BlockPos, ComponentType> getFirstMissingComponent(World world, BlockPos pos, int altarTier)
|
||||
{
|
||||
if (altarTier >= AltarTier.MAXTIERS)
|
||||
return null;
|
||||
|
||||
@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;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
List<BlockState> validStates = BloodMagicAPI.INSTANCE.getComponentStates(component.getComponent());
|
||||
if (!validStates.contains(worldState))
|
||||
return Pair.of(componentPos, component.getComponent());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,27 +1,25 @@
|
|||
package WayofTime.bloodmagic.altar;
|
||||
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 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;
|
||||
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);
|
||||
}
|
||||
ComponentType()
|
||||
{
|
||||
this.key = BASE + name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
public String getKey()
|
||||
{
|
||||
return key;
|
||||
}
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
package WayofTime.bloodmagic.altar;
|
||||
package wayoftime.bloodmagic.altar;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface IAltarComponent {
|
||||
@Nullable
|
||||
ComponentType getType(World world, BlockState state, BlockPos pos);
|
||||
}
|
||||
public interface IAltarComponent
|
||||
{
|
||||
@Nullable
|
||||
ComponentType getType(World world, BlockState state, BlockPos pos);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package WayofTime.bloodmagic.altar;
|
||||
|
||||
/**
|
||||
* Any item that implements this interface will not be pulled into the Altar on
|
||||
* right click.
|
||||
*/
|
||||
public interface IAltarManipulator {
|
||||
}
|
|
@ -1,54 +1,55 @@
|
|||
package WayofTime.bloodmagic.altar;
|
||||
package wayoftime.bloodmagic.altar;
|
||||
|
||||
public interface IBloodAltar {
|
||||
int getCapacity();
|
||||
public interface IBloodAltar
|
||||
{
|
||||
int getCapacity();
|
||||
|
||||
int getCurrentBlood();
|
||||
int getCurrentBlood();
|
||||
|
||||
AltarTier getTier();
|
||||
AltarTier getTier();
|
||||
|
||||
int getProgress();
|
||||
int getProgress();
|
||||
|
||||
float getSacrificeMultiplier();
|
||||
float getSacrificeMultiplier();
|
||||
|
||||
float getSelfSacrificeMultiplier();
|
||||
float getSelfSacrificeMultiplier();
|
||||
|
||||
float getOrbMultiplier();
|
||||
float getOrbMultiplier();
|
||||
|
||||
float getDislocationMultiplier();
|
||||
float getDislocationMultiplier();
|
||||
|
||||
float getConsumptionMultiplier();
|
||||
float getConsumptionMultiplier();
|
||||
|
||||
float getConsumptionRate();
|
||||
float getConsumptionRate();
|
||||
|
||||
int getChargingRate();
|
||||
int getChargingRate();
|
||||
|
||||
int getChargingFrequency();
|
||||
int getChargingFrequency();
|
||||
|
||||
int getTotalCharge();
|
||||
int getTotalCharge();
|
||||
|
||||
int getLiquidRequired();
|
||||
int getLiquidRequired();
|
||||
|
||||
int getBufferCapacity();
|
||||
int getBufferCapacity();
|
||||
|
||||
void sacrificialDaggerCall(int amount, boolean isSacrifice);
|
||||
void sacrificialDaggerCall(int amount, boolean isSacrifice);
|
||||
|
||||
void startCycle();
|
||||
void startCycle();
|
||||
|
||||
void checkTier();
|
||||
void checkTier();
|
||||
|
||||
boolean isActive();
|
||||
boolean isActive();
|
||||
|
||||
void setActive();
|
||||
void setActive();
|
||||
|
||||
int fillMainTank(int amount);
|
||||
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);
|
||||
/**
|
||||
* 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,83 +1,101 @@
|
|||
package WayofTime.bloodmagic.api.impl;
|
||||
package wayoftime.bloodmagic.api.impl;
|
||||
|
||||
import WayofTime.bloodmagic.api.IBloodMagicAPI;
|
||||
import WayofTime.bloodmagic.altar.ComponentType;
|
||||
import WayofTime.bloodmagic.util.BMLog;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.block.BlockState;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class BloodMagicAPI implements IBloodMagicAPI {
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public static final BloodMagicAPI INSTANCE = new BloodMagicAPI();
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
private final BloodMagicBlacklist blacklist;
|
||||
private final BloodMagicRecipeRegistrar recipeRegistrar;
|
||||
private final BloodMagicValueManager valueManager;
|
||||
private final Multimap<ComponentType, BlockState> altarComponents;
|
||||
import net.minecraft.block.BlockState;
|
||||
import wayoftime.bloodmagic.altar.ComponentType;
|
||||
import wayoftime.bloodmagic.api.IBloodMagicAPI;
|
||||
import wayoftime.bloodmagic.util.BMLog;
|
||||
|
||||
public BloodMagicAPI() {
|
||||
this.blacklist = new BloodMagicBlacklist();
|
||||
this.recipeRegistrar = new BloodMagicRecipeRegistrar();
|
||||
this.valueManager = new BloodMagicValueManager();
|
||||
this.altarComponents = ArrayListMultimap.create();
|
||||
}
|
||||
public class BloodMagicAPI implements IBloodMagicAPI
|
||||
{
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BloodMagicBlacklist getBlacklist() {
|
||||
return blacklist;
|
||||
}
|
||||
public static final BloodMagicAPI INSTANCE = new BloodMagicAPI();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BloodMagicRecipeRegistrar getRecipeRegistrar() {
|
||||
return recipeRegistrar;
|
||||
}
|
||||
// private final BloodMagicBlacklist blacklist;
|
||||
private final BloodMagicRecipeRegistrar recipeRegistrar;
|
||||
// private final BloodMagicValueManager valueManager;
|
||||
private final Multimap<ComponentType, BlockState> altarComponents;
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BloodMagicValueManager getValueManager() {
|
||||
return valueManager;
|
||||
}
|
||||
public BloodMagicAPI()
|
||||
{
|
||||
// this.blacklist = new BloodMagicBlacklist();
|
||||
this.recipeRegistrar = new BloodMagicRecipeRegistrar();
|
||||
// this.valueManager = new BloodMagicValueManager();
|
||||
this.altarComponents = ArrayListMultimap.create();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public BloodMagicBlacklist getBlacklist()
|
||||
// {
|
||||
// return blacklist;
|
||||
// }
|
||||
//
|
||||
@Nonnull
|
||||
@Override
|
||||
public BloodMagicRecipeRegistrar getRecipeRegistrar()
|
||||
{
|
||||
return recipeRegistrar;
|
||||
}
|
||||
//
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public BloodMagicValueManager getValueManager()
|
||||
// {
|
||||
// return valueManager;
|
||||
// }
|
||||
|
||||
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 registerAltarComponent(@Nonnull BlockState state, @Nonnull String componentType)
|
||||
{
|
||||
ComponentType component = null;
|
||||
for (ComponentType type : ComponentType.VALUES)
|
||||
{
|
||||
if (type.name().equalsIgnoreCase(componentType))
|
||||
{
|
||||
component = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@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("Registered {} as a {} altar component.", state, componentType);
|
||||
altarComponents.put(component, state);
|
||||
} else
|
||||
BMLog.API.warn("Invalid Altar component type: {}.", componentType);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public List<BlockState> getComponentStates(ComponentType component) {
|
||||
return (List<BlockState>) altarComponents.get(component);
|
||||
}
|
||||
}
|
||||
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,106 +0,0 @@
|
|||
package WayofTime.bloodmagic.api.impl;
|
||||
|
||||
import WayofTime.bloodmagic.api.IBloodMagicBlacklist;
|
||||
import WayofTime.bloodmagic.util.BMLog;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Set;
|
||||
|
||||
public class BloodMagicBlacklist implements IBloodMagicBlacklist {
|
||||
|
||||
private final Set<BlockState> teleposer;
|
||||
private final Set<ResourceLocation> teleposerEntities;
|
||||
private final Set<BlockState> transposition;
|
||||
private final Set<BlockState> greenGrove;
|
||||
private final Set<ResourceLocation> sacrifice;
|
||||
|
||||
public BloodMagicBlacklist() {
|
||||
this.teleposer = Sets.newHashSet();
|
||||
this.teleposerEntities = Sets.newHashSet();
|
||||
this.transposition = Sets.newHashSet();
|
||||
this.greenGrove = Sets.newHashSet();
|
||||
this.sacrifice = Sets.newHashSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTeleposer(@Nonnull BlockState state) {
|
||||
if (!teleposer.contains(state)) {
|
||||
BMLog.API_VERBOSE.info("Blacklist: Added {} to the Teleposer blacklist.", state);
|
||||
teleposer.add(state);
|
||||
}
|
||||
}
|
||||
|
||||
public void addTeleposer(@Nonnull Block block) {
|
||||
for (BlockState state : block.getBlockState().getValidStates())
|
||||
addTeleposer(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTeleposer(@Nonnull ResourceLocation entityId) {
|
||||
if (!teleposerEntities.contains(entityId)) {
|
||||
BMLog.API_VERBOSE.info("Blacklist: Added {} to the Teleposer blacklist.", entityId);
|
||||
teleposerEntities.add(entityId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTransposition(@Nonnull BlockState state) {
|
||||
if (!transposition.contains(state)) {
|
||||
BMLog.API_VERBOSE.info("Blacklist: Added {} to the Transposition blacklist.", state);
|
||||
transposition.add(state);
|
||||
}
|
||||
}
|
||||
|
||||
public void addTransposition(@Nonnull Block block) {
|
||||
for (BlockState state : block.getBlockState().getValidStates())
|
||||
addTransposition(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGreenGrove(@Nonnull BlockState state) {
|
||||
if (!greenGrove.contains(state)) {
|
||||
BMLog.API_VERBOSE.info("Blacklist: Added {} to the Green Grove blacklist.", state);
|
||||
greenGrove.add(state);
|
||||
}
|
||||
}
|
||||
|
||||
public void addGreenGrove(@Nonnull Block block) {
|
||||
for (BlockState state : block.getBlockState().getValidStates())
|
||||
addGreenGrove(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWellOfSuffering(@Nonnull ResourceLocation entityId) {
|
||||
if (!sacrifice.contains(entityId)) {
|
||||
BMLog.API_VERBOSE.info("Blacklist: Added {} to the Well of Suffering blacklist.", entityId);
|
||||
sacrifice.add(entityId);
|
||||
}
|
||||
}
|
||||
|
||||
// Internal use getters
|
||||
|
||||
public Set<BlockState> getTeleposer() {
|
||||
return ImmutableSet.copyOf(teleposer);
|
||||
}
|
||||
|
||||
public Set<ResourceLocation> getTeleposerEntities() {
|
||||
return ImmutableSet.copyOf(teleposerEntities);
|
||||
}
|
||||
|
||||
public Set<BlockState> getTransposition() {
|
||||
return ImmutableSet.copyOf(transposition);
|
||||
}
|
||||
|
||||
public Set<BlockState> getGreenGrove() {
|
||||
return ImmutableSet.copyOf(greenGrove);
|
||||
}
|
||||
|
||||
public Set<ResourceLocation> getSacrifice() {
|
||||
return ImmutableSet.copyOf(sacrifice);
|
||||
}
|
||||
}
|
|
@ -1,144 +1,29 @@
|
|||
package WayofTime.bloodmagic.api.impl;
|
||||
package wayoftime.bloodmagic.api.impl;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.altar.ComponentType;
|
||||
import WayofTime.bloodmagic.api.BloodMagicPlugin;
|
||||
import WayofTime.bloodmagic.api.IBloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.IBloodMagicPlugin;
|
||||
import WayofTime.bloodmagic.api.IBloodMagicRecipeRegistrar;
|
||||
import WayofTime.bloodmagic.block.BlockBloodRune;
|
||||
import WayofTime.bloodmagic.block.BlockDecorative;
|
||||
import WayofTime.bloodmagic.block.enums.BloodRuneType;
|
||||
import WayofTime.bloodmagic.block.enums.EnumDecorative;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicRecipes;
|
||||
import WayofTime.bloodmagic.incense.EnumTranquilityType;
|
||||
import WayofTime.bloodmagic.incense.TranquilityStack;
|
||||
import WayofTime.bloodmagic.util.StateUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.altar.ComponentType;
|
||||
import wayoftime.bloodmagic.api.IBloodMagicAPI;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
|
||||
@BloodMagicPlugin
|
||||
public class BloodMagicCorePlugin implements IBloodMagicPlugin {
|
||||
public class BloodMagicCorePlugin
|
||||
{
|
||||
public static final BloodMagicCorePlugin INSTANCE = new BloodMagicCorePlugin();
|
||||
|
||||
@Override
|
||||
public void register(IBloodMagicAPI apiInterface) {
|
||||
BloodMagicAPI api = (BloodMagicAPI) apiInterface;
|
||||
// Add forced blacklistings
|
||||
api.getBlacklist().addTeleposer(RegistrarBloodMagicBlocks.INPUT_ROUTING_NODE);
|
||||
api.getBlacklist().addTransposition(RegistrarBloodMagicBlocks.INPUT_ROUTING_NODE);
|
||||
api.getBlacklist().addTeleposer(RegistrarBloodMagicBlocks.OUTPUT_ROUTING_NODE);
|
||||
api.getBlacklist().addTransposition(RegistrarBloodMagicBlocks.OUTPUT_ROUTING_NODE);
|
||||
api.getBlacklist().addTeleposer(RegistrarBloodMagicBlocks.ITEM_ROUTING_NODE);
|
||||
api.getBlacklist().addTransposition(RegistrarBloodMagicBlocks.ITEM_ROUTING_NODE);
|
||||
api.getBlacklist().addTeleposer(RegistrarBloodMagicBlocks.MASTER_ROUTING_NODE);
|
||||
api.getBlacklist().addTransposition(RegistrarBloodMagicBlocks.MASTER_ROUTING_NODE);
|
||||
api.getBlacklist().addTeleposer(RegistrarBloodMagicBlocks.DEMON_CRYSTAL);
|
||||
api.getBlacklist().addTransposition(RegistrarBloodMagicBlocks.DEMON_CRYSTAL);
|
||||
api.getBlacklist().addTeleposer(RegistrarBloodMagicBlocks.INVERSION_PILLAR);
|
||||
api.getBlacklist().addTransposition(RegistrarBloodMagicBlocks.INVERSION_PILLAR);
|
||||
api.getBlacklist().addWellOfSuffering(new ResourceLocation("armor_stand"));
|
||||
api.getBlacklist().addWellOfSuffering(new ResourceLocation(BloodMagic.MODID, "sentient_specter"));
|
||||
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());
|
||||
|
||||
api.getValueManager().setSacrificialValue(new ResourceLocation("armor_stand"), 0);
|
||||
api.getValueManager().setSacrificialValue(new ResourceLocation(BloodMagic.MODID, "sentient_specter"), 0);
|
||||
|
||||
api.getValueManager().setTranquility(Blocks.LAVA, new TranquilityStack(EnumTranquilityType.LAVA, 1.2D));
|
||||
api.getValueManager().setTranquility(Blocks.FLOWING_LAVA, new TranquilityStack(EnumTranquilityType.LAVA, 1.2D));
|
||||
api.getValueManager().setTranquility(Blocks.WATER, new TranquilityStack(EnumTranquilityType.WATER, 1.0D));
|
||||
api.getValueManager().setTranquility(Blocks.FLOWING_WATER, new TranquilityStack(EnumTranquilityType.WATER, 1.0D));
|
||||
api.getValueManager().setTranquility(RegistrarBloodMagicBlocks.LIFE_ESSENCE, new TranquilityStack(EnumTranquilityType.WATER, 1.5D));
|
||||
api.getValueManager().setTranquility(Blocks.NETHERRACK, new TranquilityStack(EnumTranquilityType.FIRE, 0.5D));
|
||||
api.getValueManager().setTranquility(Blocks.DIRT, new TranquilityStack(EnumTranquilityType.EARTHEN, 0.25D));
|
||||
api.getValueManager().setTranquility(Blocks.FARMLAND, new TranquilityStack(EnumTranquilityType.EARTHEN, 1.0D));
|
||||
api.getValueManager().setTranquility(Blocks.POTATOES, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
|
||||
api.getValueManager().setTranquility(Blocks.CARROTS, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
|
||||
api.getValueManager().setTranquility(Blocks.WHEAT, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
|
||||
api.getValueManager().setTranquility(Blocks.NETHER_WART, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
|
||||
api.getValueManager().setTranquility(Blocks.BEETROOTS, new TranquilityStack(EnumTranquilityType.CROP, 1.0D));
|
||||
|
||||
handleConfigValues(api);
|
||||
|
||||
// Add standard blocks for altar components
|
||||
api.registerAltarComponent(Blocks.GLOWSTONE.getDefaultState(), ComponentType.GLOWSTONE.name());
|
||||
api.registerAltarComponent(Blocks.SEA_LANTERN.getDefaultState(), ComponentType.GLOWSTONE.name());
|
||||
api.registerAltarComponent(Blocks.BEACON.getDefaultState(), ComponentType.BEACON.name());
|
||||
|
||||
BlockDecorative decorative = (BlockDecorative) RegistrarBloodMagicBlocks.DECORATIVE_BRICK;
|
||||
api.registerAltarComponent(decorative.getDefaultState().withProperty(decorative.getProperty(), EnumDecorative.BLOODSTONE_BRICK), ComponentType.BLOODSTONE.name());
|
||||
api.registerAltarComponent(decorative.getDefaultState().withProperty(decorative.getProperty(), EnumDecorative.BLOODSTONE_TILE), ComponentType.BLOODSTONE.name());
|
||||
if (ConfigHandler.general.enableTierSixEvenThoughThereIsNoContent) {
|
||||
api.registerAltarComponent(decorative.getDefaultState().withProperty(decorative.getProperty(), EnumDecorative.CRYSTAL_BRICK), ComponentType.CRYSTAL.name());
|
||||
api.registerAltarComponent(decorative.getDefaultState().withProperty(decorative.getProperty(), EnumDecorative.CRYSTAL_TILE), ComponentType.CRYSTAL.name());
|
||||
}
|
||||
|
||||
BlockBloodRune bloodRune = (BlockBloodRune) RegistrarBloodMagicBlocks.BLOOD_RUNE;
|
||||
for (BloodRuneType runeType : BloodRuneType.values())
|
||||
api.registerAltarComponent(bloodRune.getDefaultState().withProperty(bloodRune.getProperty(), runeType), ComponentType.BLOODRUNE.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRecipes(IBloodMagicRecipeRegistrar recipeRegistrar) {
|
||||
RegistrarBloodMagicRecipes.registerAltarRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
RegistrarBloodMagicRecipes.registerAlchemyTableRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
RegistrarBloodMagicRecipes.registerTartaricForgeRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
RegistrarBloodMagicRecipes.registerAlchemyArrayRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
RegistrarBloodMagicRecipes.registerSacrificeCraftRecipes((BloodMagicRecipeRegistrar) recipeRegistrar);
|
||||
}
|
||||
|
||||
private static void handleConfigValues(BloodMagicAPI api) {
|
||||
for (String value : ConfigHandler.values.sacrificialValues) {
|
||||
String[] split = value.split(";");
|
||||
if (split.length != 2) // Not valid format
|
||||
continue;
|
||||
|
||||
api.getValueManager().setSacrificialValue(new ResourceLocation(split[0]), Integer.parseInt(split[1]));
|
||||
}
|
||||
|
||||
for (String value : ConfigHandler.blacklist.teleposer) {
|
||||
EntityEntry entityEntry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(value));
|
||||
if (entityEntry == null) { // It's not an entity (or at least not a valid one), so let's try a block.
|
||||
String[] blockData = value.split("\\[");
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockData[0]));
|
||||
if (block == Blocks.AIR || block == null) // Not a valid block either
|
||||
continue;
|
||||
|
||||
if (blockData.length > 1) { // We have properties listed, so let's build a state.
|
||||
api.getBlacklist().addTeleposer(StateUtil.parseState(value));
|
||||
continue;
|
||||
}
|
||||
|
||||
api.getBlacklist().addTeleposer(block);
|
||||
continue;
|
||||
}
|
||||
|
||||
api.getBlacklist().addTeleposer(entityEntry.getRegistryName());
|
||||
}
|
||||
|
||||
for (String value : ConfigHandler.blacklist.transposer) {
|
||||
String[] blockData = value.split("\\[");
|
||||
Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockData[0]));
|
||||
if (block == Blocks.AIR || block == null) // Not a valid block
|
||||
continue;
|
||||
|
||||
if (blockData.length > 1) { // We have properties listed, so let's build a state.
|
||||
api.getBlacklist().addTeleposer(StateUtil.parseState(value));
|
||||
continue;
|
||||
}
|
||||
|
||||
api.getBlacklist().addTeleposer(block);
|
||||
}
|
||||
|
||||
for (String value : ConfigHandler.blacklist.wellOfSuffering) {
|
||||
EntityEntry entityEntry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(value));
|
||||
if (entityEntry == null) // Not a valid entity
|
||||
continue;
|
||||
|
||||
api.getBlacklist().addWellOfSuffering(entityEntry.getRegistryName());
|
||||
}
|
||||
}
|
||||
}
|
||||
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,357 +1,448 @@
|
|||
package WayofTime.bloodmagic.api.impl;
|
||||
package wayoftime.bloodmagic.api.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import WayofTime.bloodmagic.api.IBloodMagicRecipeRegistrar;
|
||||
import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray;
|
||||
import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable;
|
||||
import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
|
||||
import WayofTime.bloodmagic.api.impl.recipe.RecipeSacrificeCraft;
|
||||
import WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge;
|
||||
import WayofTime.bloodmagic.core.recipe.IngredientBloodOrb;
|
||||
import WayofTime.bloodmagic.orb.IBloodOrb;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
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.");
|
||||
|
||||
altarRecipes.add(new RecipeBloodAltar(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(@Nonnull ItemStack input) {
|
||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
||||
if (input.isEmpty())
|
||||
return null;
|
||||
|
||||
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(@Nonnull List<ItemStack> input) {
|
||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
||||
if (input.isEmpty())
|
||||
return null;
|
||||
|
||||
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.apply(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;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public RecipeAlchemyArray getAlchemyArray(@Nonnull ItemStack input, @Nonnull ItemStack catalyst) {
|
||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
||||
if (input.isEmpty())
|
||||
return null;
|
||||
|
||||
for (RecipeAlchemyArray recipe : alchemyArrayRecipes)
|
||||
if (recipe.getInput().test(input) && recipe.getCatalyst().test(catalyst))
|
||||
return recipe;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<RecipeBloodAltar> getAltarRecipes() {
|
||||
return ImmutableSet.copyOf(altarRecipes);
|
||||
}
|
||||
|
||||
public Set<RecipeAlchemyTable> getAlchemyRecipes() {
|
||||
return ImmutableSet.copyOf(alchemyRecipes);
|
||||
}
|
||||
|
||||
public Set<RecipeTartaricForge> getTartaricForgeRecipes() {
|
||||
return ImmutableSet.copyOf(tartaricForgeRecipes);
|
||||
}
|
||||
|
||||
public Set<RecipeAlchemyArray> getAlchemyArrayRecipes() {
|
||||
return ImmutableSet.copyOf(alchemyArrayRecipes);
|
||||
}
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.api.IBloodMagicRecipeRegistrar;
|
||||
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;
|
||||
}
|
||||
|
||||
// @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,62 +0,0 @@
|
|||
package WayofTime.bloodmagic.api.impl;
|
||||
|
||||
import WayofTime.bloodmagic.api.IBloodMagicValueManager;
|
||||
import WayofTime.bloodmagic.incense.EnumTranquilityType;
|
||||
import WayofTime.bloodmagic.incense.TranquilityStack;
|
||||
import WayofTime.bloodmagic.util.BMLog;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Map;
|
||||
|
||||
public class BloodMagicValueManager implements IBloodMagicValueManager {
|
||||
|
||||
private final Map<ResourceLocation, Integer> sacrificial;
|
||||
private final Map<BlockState, TranquilityStack> tranquility;
|
||||
|
||||
public BloodMagicValueManager() {
|
||||
this.sacrificial = Maps.newHashMap();
|
||||
this.tranquility = Maps.newHashMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSacrificialValue(@Nonnull ResourceLocation entityId, int value) {
|
||||
BMLog.API_VERBOSE.info("Value Manager: Set sacrificial value of {} to {}.", entityId, value);
|
||||
sacrificial.put(entityId, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTranquility(@Nonnull BlockState state, @Nonnull String tranquilityType, double value) {
|
||||
EnumTranquilityType tranquility = null;
|
||||
for (EnumTranquilityType type : EnumTranquilityType.values()) {
|
||||
if (type.name().equalsIgnoreCase(tranquilityType)) {
|
||||
tranquility = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tranquility != null) {
|
||||
BMLog.API_VERBOSE.info("Value Manager: Set tranquility value of {} to {} @ {}", state, tranquilityType, value);
|
||||
this.tranquility.put(state, new TranquilityStack(tranquility, value));
|
||||
} else BMLog.API.warn("Invalid tranquility type: {}.", tranquilityType);
|
||||
}
|
||||
|
||||
public void setTranquility(Block block, TranquilityStack tranquilityStack) {
|
||||
for (BlockState state : block.getBlockState().getValidStates()) {
|
||||
BMLog.API_VERBOSE.info("Value Manager: Set tranquility value of {} to {} @ {}", state, tranquilityStack.type, tranquilityStack.value);
|
||||
tranquility.put(state, tranquilityStack);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<ResourceLocation, Integer> getSacrificial() {
|
||||
return ImmutableMap.copyOf(sacrificial);
|
||||
}
|
||||
|
||||
public Map<BlockState, TranquilityStack> getTranquility() {
|
||||
return ImmutableMap.copyOf(tranquility);
|
||||
}
|
||||
}
|
|
@ -1,53 +1,87 @@
|
|||
package WayofTime.bloodmagic.api.impl.recipe;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
package wayoftime.bloodmagic.api.impl.recipe;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class RecipeAlchemyArray {
|
||||
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;
|
||||
|
||||
@Nonnull
|
||||
private final Ingredient input;
|
||||
@Nonnull
|
||||
private final Ingredient catalyst;
|
||||
@Nonnull
|
||||
private final ItemStack output;
|
||||
@Nonnull
|
||||
private final ResourceLocation circleTexture;
|
||||
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;
|
||||
|
||||
public RecipeAlchemyArray(@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.");
|
||||
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;
|
||||
}
|
||||
|
||||
this.input = input;
|
||||
this.catalyst = catalyst;
|
||||
this.output = output;
|
||||
this.circleTexture = circleTexture == null ? new ResourceLocation(BloodMagic.MODID, "textures/models/AlchemyArrays/WIPArray.png") : circleTexture;
|
||||
}
|
||||
@Nonnull
|
||||
public final ResourceLocation getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public Ingredient getInput() {
|
||||
return input;
|
||||
}
|
||||
@Nonnull
|
||||
public final ResourceLocation getTexture()
|
||||
{
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public Ingredient getCatalyst() {
|
||||
return catalyst;
|
||||
}
|
||||
@Nonnull
|
||||
public final Ingredient getBaseInput()
|
||||
{
|
||||
return baseInput;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
@Nonnull
|
||||
public final Ingredient getAddedInput()
|
||||
{
|
||||
return addedInput;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ResourceLocation getCircleTexture() {
|
||||
return circleTexture;
|
||||
}
|
||||
@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,59 +0,0 @@
|
|||
package WayofTime.bloodmagic.api.impl.recipe;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RecipeAlchemyTable {
|
||||
|
||||
@Nonnull
|
||||
private final NonNullList<Ingredient> input;
|
||||
@Nonnull
|
||||
private final ItemStack output;
|
||||
@Nonnegative
|
||||
private final int syphon;
|
||||
@Nonnegative
|
||||
private final int ticks;
|
||||
@Nonnegative
|
||||
private final int minimumTier;
|
||||
|
||||
public RecipeAlchemyTable(@Nonnull NonNullList<Ingredient> input, @Nonnull ItemStack output, int syphon, int ticks, int minimumTier) {
|
||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
||||
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.");
|
||||
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.syphon = syphon;
|
||||
this.ticks = ticks;
|
||||
this.minimumTier = minimumTier;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final NonNullList<Ingredient> getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public final int getSyphon() {
|
||||
return syphon;
|
||||
}
|
||||
|
||||
public final int getTicks() {
|
||||
return ticks;
|
||||
}
|
||||
|
||||
public final int getMinimumTier() {
|
||||
return minimumTier;
|
||||
}
|
||||
}
|
|
@ -1,72 +1,104 @@
|
|||
package WayofTime.bloodmagic.api.impl.recipe;
|
||||
|
||||
import WayofTime.bloodmagic.altar.AltarTier;
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
package wayoftime.bloodmagic.api.impl.recipe;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RecipeBloodAltar {
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
@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;
|
||||
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 RecipeBloodAltar(@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(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.");
|
||||
public abstract class RecipeBloodAltar extends BloodMagicRecipe
|
||||
{
|
||||
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.minimumTier = AltarTier.values()[minimumTier];
|
||||
this.syphon = syphon;
|
||||
this.consumeRate = consumeRate;
|
||||
this.drainRate = drainRate;
|
||||
}
|
||||
@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;
|
||||
|
||||
@Nonnull
|
||||
public final Ingredient getInput() {
|
||||
return input;
|
||||
}
|
||||
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.");
|
||||
|
||||
@Nonnull
|
||||
public final ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.minimumTier = AltarTier.values()[minimumTier];
|
||||
this.syphon = syphon;
|
||||
this.consumeRate = consumeRate;
|
||||
this.drainRate = drainRate;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public AltarTier getMinimumTier() {
|
||||
return minimumTier;
|
||||
}
|
||||
@Nonnull
|
||||
public final Ingredient getInput()
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
@Nonnegative
|
||||
public final int getSyphon() {
|
||||
return syphon;
|
||||
}
|
||||
@Override
|
||||
public final NonNullList<Ingredient> getIngredients()
|
||||
{
|
||||
NonNullList<Ingredient> list = NonNullList.create();
|
||||
list.add(getInput());
|
||||
return list;
|
||||
}
|
||||
|
||||
@Nonnegative
|
||||
public final int getConsumeRate() {
|
||||
return consumeRate;
|
||||
}
|
||||
@Nonnull
|
||||
public final ItemStack getOutput()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
@Nonnegative
|
||||
public final int getDrainRate() {
|
||||
return drainRate;
|
||||
}
|
||||
}
|
||||
@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,43 +0,0 @@
|
|||
package WayofTime.bloodmagic.api.impl.recipe;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RecipeSacrificeCraft {
|
||||
@Nonnull
|
||||
private final NonNullList<Ingredient> input;
|
||||
@Nonnull
|
||||
private final ItemStack output;
|
||||
@Nonnegative
|
||||
private final double healthRequired;
|
||||
|
||||
public RecipeSacrificeCraft(@Nonnull NonNullList<Ingredient> input, @Nonnull ItemStack output, @Nonnegative double healthRequired) {
|
||||
Preconditions.checkNotNull(input, "input cannot be null.");
|
||||
Preconditions.checkNotNull(output, "output cannot be null.");
|
||||
Preconditions.checkArgument(healthRequired >= 0, "healthRequired cannot be negative.");
|
||||
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.healthRequired = healthRequired;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final NonNullList<Ingredient> getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
|
||||
@Nonnegative
|
||||
public final double getHealthRequired() {
|
||||
return healthRequired;
|
||||
}
|
||||
}
|
|
@ -1,53 +1,77 @@
|
|||
package WayofTime.bloodmagic.api.impl.recipe;
|
||||
package wayoftime.bloodmagic.api.impl.recipe;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RecipeTartaricForge {
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
@Nonnull
|
||||
private final NonNullList<Ingredient> input;
|
||||
@Nonnull
|
||||
private final ItemStack output;
|
||||
@Nonnegative
|
||||
private final double minimumSouls;
|
||||
@Nonnegative
|
||||
private final double soulDrain;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public RecipeTartaricForge(@Nonnull NonNullList<Ingredient> input, @Nonnull ItemStack output, @Nonnegative double minimumSouls, @Nonnegative double soulDrain) {
|
||||
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.");
|
||||
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;
|
||||
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.minimumSouls = minimumSouls;
|
||||
this.soulDrain = 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.");
|
||||
|
||||
@Nonnull
|
||||
public final NonNullList<Ingredient> getInput() {
|
||||
return input;
|
||||
}
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.minimumSouls = minimumSouls;
|
||||
this.soulDrain = soulDrain;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final ItemStack getOutput() {
|
||||
return output;
|
||||
}
|
||||
@Nonnull
|
||||
public final List<Ingredient> getInput()
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
@Nonnegative
|
||||
public final double getMinimumSouls() {
|
||||
return minimumSouls;
|
||||
}
|
||||
@Nonnull
|
||||
public final ItemStack getOutput()
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
@Nonnegative
|
||||
public final double getSoulDrain() {
|
||||
return soulDrain;
|
||||
}
|
||||
}
|
||||
@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,166 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectMovement;
|
||||
import WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffectUpdraft;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
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.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockAlchemyArray extends Block {
|
||||
protected static final AxisAlignedBB ARRAY_AABB = new AxisAlignedBB(0, 0, 0, 1, 0.1, 1);
|
||||
|
||||
public BlockAlchemyArray() {
|
||||
super(Material.CLOTH);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".alchemyArray");
|
||||
setHardness(0.1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_) {
|
||||
// No-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(World world, BlockPos pos, BlockState state, Entity entity) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileAlchemyArray) {
|
||||
((TileAlchemyArray) tile).onEntityCollidedWithBlock(state, entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return ARRAY_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.INVISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
TileAlchemyArray array = (TileAlchemyArray) world.getTileEntity(pos);
|
||||
|
||||
if (array == null)
|
||||
return false;
|
||||
if (player.isSneaking() && array.rotateCooldown == 0) {
|
||||
array.setRotation(array.getRotation().rotateY());
|
||||
array.rotateCooldown = 5;
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack playerItem = player.getHeldItem(hand);
|
||||
|
||||
if (!playerItem.isEmpty()) {
|
||||
if (array.getStackInSlot(0).isEmpty()) {
|
||||
Utils.insertItemToTile(array, player, 0);
|
||||
} else if (!array.getStackInSlot(0).isEmpty()) {
|
||||
Utils.insertItemToTile(array, player, 1);
|
||||
array.attemptCraft();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
if (array.arrayEffect instanceof AlchemyArrayEffectMovement && (playerItem.getItem() == Items.REDSTONE || playerItem.getItem() == Items.FEATHER)
|
||||
|| array.arrayEffect instanceof AlchemyArrayEffectUpdraft && (playerItem.getItem() == Items.FEATHER || playerItem.getItem() == Items.GLOWSTONE_DUST)) {
|
||||
for (int i = 0; i < array.getSizeInventory(); i++) {
|
||||
ItemStack stack = array.getStackInSlot(i);
|
||||
if (ItemStack.areItemsEqual(stack, playerItem)) {
|
||||
if (stack.getCount() < 127) {
|
||||
stack.setCount(stack.getCount() + 1);
|
||||
playerItem.shrink(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, World world, BlockPos pos, PlayerEntity player) {
|
||||
return new ItemStack(RegistrarBloodMagicItems.ARCANE_ASHES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random random) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, BlockState blockState) {
|
||||
TileAlchemyArray alchemyArray = (TileAlchemyArray) world.getTileEntity(blockPos);
|
||||
if (alchemyArray != null)
|
||||
alchemyArray.dropItems();
|
||||
|
||||
super.breakBlock(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileAlchemyArray();
|
||||
}
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockAlchemyTable;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyTable;
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockAlchemyTable extends Block implements IBMBlock {
|
||||
public static final PropertyBool INVISIBLE = PropertyBool.create("invisible");
|
||||
public static final PropertyEnum<Direction> DIRECTION = PropertyEnum.create("direction", Direction.class);
|
||||
private static final AxisAlignedBB BODY = new AxisAlignedBB(0, 0, 0, 16 / 16F, 13 / 16F, 16 / 16F);
|
||||
|
||||
public BlockAlchemyTable() {
|
||||
super(Material.ROCK);
|
||||
// this.setDefaultState(this.blockState.getBaseState().withProperty(DIRECTION, EnumFacing.DOWN).withProperty(INVISIBLE, false));
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".alchemyTable");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 0);
|
||||
|
||||
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockState state, BlockRenderLayer layer) {
|
||||
return layer == BlockRenderLayer.CUTOUT_MIPPED || layer == BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getActualState(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileAlchemyTable) {
|
||||
return state.withProperty(INVISIBLE, ((TileAlchemyTable) tile).isInvisible()).withProperty(DIRECTION, ((TileAlchemyTable) tile).getDirection());
|
||||
}
|
||||
|
||||
return state.withProperty(INVISIBLE, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, DIRECTION, INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
BlockPos position = pos;
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileAlchemyTable) {
|
||||
if (((TileAlchemyTable) tile).isSlave()) {
|
||||
position = ((TileAlchemyTable) tile).getConnectedPos();
|
||||
tile = world.getTileEntity(position);
|
||||
if (!(tile instanceof TileAlchemyTable)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.openGui(BloodMagic.instance, Constants.Gui.ALCHEMY_TABLE_GUI, world, position.getX(), position.getY(), position.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, BlockState blockState) {
|
||||
TileAlchemyTable tile = (TileAlchemyTable) world.getTileEntity(pos);
|
||||
if (tile != null && !tile.isSlave()) {
|
||||
tile.dropItems();
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileAlchemyTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
TileAlchemyTable tile = (TileAlchemyTable) world.getTileEntity(pos);
|
||||
if (tile != null) {
|
||||
BlockPos connectedPos = tile.getConnectedPos();
|
||||
TileEntity connectedTile = world.getTileEntity(connectedPos);
|
||||
if (!(connectedTile instanceof TileAlchemyTable && ((TileAlchemyTable) connectedTile).getConnectedPos().equals(pos))) {
|
||||
this.breakBlock(world, pos, state);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new ItemBlockAlchemyTable(this);
|
||||
}
|
||||
}
|
|
@ -1,224 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.altar.AltarUtil;
|
||||
import WayofTime.bloodmagic.altar.ComponentType;
|
||||
import WayofTime.bloodmagic.altar.IAltarManipulator;
|
||||
import WayofTime.bloodmagic.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.data.Binding;
|
||||
import WayofTime.bloodmagic.core.data.SoulNetwork;
|
||||
import WayofTime.bloodmagic.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.iface.IBindable;
|
||||
import WayofTime.bloodmagic.iface.IDocumentedBlock;
|
||||
import WayofTime.bloodmagic.orb.BloodOrb;
|
||||
import WayofTime.bloodmagic.orb.IBloodOrb;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.NetworkHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockAltar extends Block implements IVariantProvider, IDocumentedBlock, IBMBlock {
|
||||
public static final PropertyBool POWERED = PropertyBool.create("powered");
|
||||
private static final AxisAlignedBB BODY = new AxisAlignedBB(0, 0, 0, 16 / 16F, 12 / 16F, 16 / 16F);
|
||||
|
||||
public BlockAltar() {
|
||||
super(Material.ROCK);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(POWERED, false));
|
||||
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".altar");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 1);
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(BlockState state, World world, BlockPos pos) {
|
||||
if (world.isRemote)
|
||||
return 0;
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileAltar) {
|
||||
TileAltar altar = (TileAltar) tile;
|
||||
ItemStack orbStack = altar.getStackInSlot(0);
|
||||
|
||||
if (world.getBlockState(pos.down()).getBlock() instanceof BlockDecorative) {
|
||||
if (orbStack.getItem() instanceof IBloodOrb && orbStack.getItem() instanceof IBindable) {
|
||||
BloodOrb orb = ((IBloodOrb) orbStack.getItem()).getOrb(orbStack);
|
||||
Binding binding = ((IBindable) orbStack.getItem()).getBinding(orbStack);
|
||||
if (orb != null && binding != null) {
|
||||
SoulNetwork soulNetwork = NetworkHelper.getSoulNetwork(binding);
|
||||
|
||||
int maxEssence = orb.getCapacity();
|
||||
int currentEssence = soulNetwork.getCurrentEssence();
|
||||
int level = currentEssence * 15 / maxEssence;
|
||||
return Math.min(15, level) % 16;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int maxEssence = altar.getCapacity();
|
||||
int currentEssence = altar.getCurrentBlood();
|
||||
int level = currentEssence * 15 / maxEssence;
|
||||
return Math.min(15, level) % 16;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
TileAltar altar = (TileAltar) world.getTileEntity(pos);
|
||||
|
||||
if (altar == null || player.isSneaking())
|
||||
return false;
|
||||
|
||||
ItemStack playerItem = player.getHeldItem(hand);
|
||||
|
||||
if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) {
|
||||
playerItem.getItem().onItemRightClick(world, player, hand);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Utils.insertItemToTile(altar, player))
|
||||
altar.startCycle();
|
||||
else
|
||||
altar.setActive();
|
||||
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, BlockState blockState) {
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile instanceof TileAltar)
|
||||
((TileAltar) tile).dropItems();
|
||||
|
||||
super.breakBlock(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileAltar();
|
||||
}
|
||||
|
||||
// IDocumentedBlock
|
||||
|
||||
@Override
|
||||
public List<ITextComponent> getDocumentation(PlayerEntity player, World world, BlockPos pos, BlockState state) {
|
||||
List<ITextComponent> docs = new ArrayList<>();
|
||||
IBloodAltar altar = ((IBloodAltar) world.getTileEntity(pos));
|
||||
Pair<BlockPos, ComponentType> missingBlock = AltarUtil.getFirstMissingComponent(world, pos, altar.getTier().toInt());
|
||||
if (missingBlock != null)
|
||||
docs.add(new TranslationTextComponent("chat.bloodmagic.altar.nextTier", new TranslationTextComponent(missingBlock.getRight().getKey()), Utils.prettifyBlockPosString(missingBlock.getLeft())));
|
||||
|
||||
return docs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new BlockItem(this);
|
||||
}
|
||||
|
||||
/* Redstone code, taken from BlockLever */
|
||||
|
||||
public int getWeakPower(BlockState blockState, IBlockAccess blockAccess, BlockPos pos, Direction side) {
|
||||
return blockState.getValue(POWERED) ? 15 : 0;
|
||||
}
|
||||
|
||||
public int getStrongPower(BlockState blockState, IBlockAccess blockAccess, BlockPos pos, Direction side) {
|
||||
if (!blockState.getValue(POWERED)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canProvidePower(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(POWERED, meta > 0);
|
||||
}
|
||||
|
||||
public int getMetaFromState(BlockState state) {
|
||||
return state.getValue(POWERED) ? 1 : 0;
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, POWERED);
|
||||
}
|
||||
|
||||
public BlockState getStateForPlacement(World worldIn, BlockPos pos, Direction facing, float hitX, float hitY, float hitZ, int meta, LivingEntity placer) {
|
||||
|
||||
return this.getDefaultState().withProperty(POWERED, false);
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import net.minecraft.block.Block;
|
||||
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.client.particle.ParticleManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockBloodLight extends Block {
|
||||
protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.4, 0.4, 0.4, 0.6, 0.6, 0.6);
|
||||
|
||||
public BlockBloodLight() {
|
||||
super(Material.CLOTH);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".bloodLight");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return AABB;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(BlockState blockState, IBlockAccess worldIn, BlockPos pos) {
|
||||
return NULL_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(BlockState state) {
|
||||
return 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager) {
|
||||
if (world.getBlockState(pos).getBlock() == this) {
|
||||
Random random = new Random();
|
||||
particleManager.spawnEffectParticle(EnumParticleTypes.REDSTONE.getParticleID(), pos.getX() + 0.5D + random.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + random.nextGaussian() / 8, 0, 0, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) {
|
||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||
|
||||
if (rand.nextInt(3) != 0) {
|
||||
world.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 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.spawnParticle(EnumParticleTypes.REDSTONE, pos.getX() + 0.5D + rand.nextGaussian() / 8, pos.getY() + 0.5D, pos.getZ() + 0.5D + rand.nextGaussian() / 8, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.block.enums.BloodRuneType;
|
||||
import WayofTime.bloodmagic.iface.IBloodRune;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
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.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockBloodRune extends BlockEnum<BloodRuneType> implements IBloodRune {
|
||||
|
||||
public BlockBloodRune() {
|
||||
super(Material.ROCK, BloodRuneType.class);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".rune.");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BloodRuneType getBloodRune(IBlockAccess world, BlockPos pos, BlockState state) {
|
||||
return state.getValue(getProperty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag tooltipFlag) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.decoration.safe"));
|
||||
super.addInformation(stack, world, tooltip, tooltipFlag);
|
||||
}
|
||||
}
|
|
@ -1,195 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockInteger;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockBloodTank;
|
||||
import WayofTime.bloodmagic.tile.TileBloodTank;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.BlockState;
|
||||
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.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockBloodTank extends BlockInteger implements IVariantProvider, IBMBlock {
|
||||
public static final AxisAlignedBB BOX = new AxisAlignedBB(0.25, 0, 0.25, 0.75, 0.8, 0.75);
|
||||
|
||||
public BlockBloodTank() {
|
||||
super(Material.IRON, TileBloodTank.CAPACITIES.length - 1, "tier");
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".bloodTank");
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.GLASS);
|
||||
setHarvestLevel("pickaxe", 1);
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setLightOpacity(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return BOX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.CUTOUT_MIPPED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable TileEntity tile, ItemStack stack) {
|
||||
super.harvestBlock(world, player, pos, state, tile, stack);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest) {
|
||||
return willHarvest || super.removedByPlayer(state, world, pos, player, willHarvest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos blockPos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
boolean success = FluidUtil.interactWithFluidHandler(player, hand, world, blockPos, side);
|
||||
if (success) {
|
||||
world.checkLight(blockPos);
|
||||
world.updateComparatorOutputLevel(blockPos, this);
|
||||
world.markAndNotifyBlock(blockPos, world.getChunk(blockPos), state, state, 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World worldIn, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
this.dropBlockAsItem(worldIn, pos, state, 0);
|
||||
super.onBlockHarvested(worldIn, pos, state, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState blockState, int fortune) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileBloodTank) {
|
||||
TileBloodTank bloodTank = (TileBloodTank) tile;
|
||||
ItemStack drop = new ItemStack(this, 1, bloodTank.getBlockMetadata());
|
||||
CompoundNBT fluidTag = new CompoundNBT();
|
||||
|
||||
if (bloodTank.getTank().getFluid() != null) {
|
||||
bloodTank.getTank().getFluid().writeToNBT(fluidTag);
|
||||
CompoundNBT dropTag = new CompoundNBT();
|
||||
dropTag.put("Fluid", fluidTag);
|
||||
drop.setTagCompound(dropTag);
|
||||
}
|
||||
|
||||
drops.add(drop);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState blockState, LivingEntity placer, ItemStack stack) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileBloodTank) {
|
||||
TileBloodTank bloodTank = (TileBloodTank) tile;
|
||||
CompoundNBT tag = stack.getTagCompound();
|
||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("Fluid")) {
|
||||
FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tag.getCompound("Fluid"));
|
||||
bloodTank.getTank().setFluid(fluidStack);
|
||||
}
|
||||
}
|
||||
|
||||
world.checkLight(pos);
|
||||
world.updateComparatorOutputLevel(pos, this);
|
||||
world.markAndNotifyBlock(pos, world.getChunk(pos), blockState, blockState, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileBloodTank) {
|
||||
FluidStack fluidStack = ((TileBloodTank) tile).getTank().getFluid();
|
||||
return fluidStack == null || fluidStack.amount <= 0 ? 0 : fluidStack.getFluid().getLuminosity(fluidStack);
|
||||
}
|
||||
|
||||
return super.getLightValue(state, world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, World world, BlockPos pos, PlayerEntity player) {
|
||||
return new ItemStack(this, 1, getMetaFromState(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(BlockState state, World world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileBloodTank)
|
||||
return ((TileBloodTank) tile).getComparatorOutput();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World worldIn, BlockState blockState) {
|
||||
return new TileBloodTank(getMetaFromState(blockState));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new ItemBlockBloodTank(this);
|
||||
}
|
||||
|
||||
// IVariantProvider
|
||||
|
||||
@Override
|
||||
public void gatherVariants(@Nonnull Int2ObjectMap<String> variants) {
|
||||
for (int i = 0; i < TileBloodTank.CAPACITIES.length; i++)
|
||||
variants.put(i, "inventory");
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.block.enums.EnumDecorative;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
public class BlockDecorative extends BlockEnum<EnumDecorative> {
|
||||
public BlockDecorative() {
|
||||
super(Material.ROCK, EnumDecorative.class);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(ItemGroup tab, NonNullList<ItemStack> subBlocks) {
|
||||
for (EnumDecorative type : EnumDecorative.values()) {
|
||||
if (!ConfigHandler.general.enableTierSixEvenThoughThereIsNoContent && (type == EnumDecorative.CRYSTAL_TILE || type == EnumDecorative.CRYSTAL_BRICK))
|
||||
continue;
|
||||
subBlocks.add(new ItemStack(this, 1, type.ordinal()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public class BlockDemonBase<E extends Enum<E> & IStringSerializable> extends BlockEnum<E> implements IVariantProvider {
|
||||
public BlockDemonBase(String baseName, Class<E> enumClass) {
|
||||
super(Material.ROCK, enumClass);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + "." + baseName + ".");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
}
|
|
@ -1,172 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.soul.IDemonWillGem;
|
||||
import WayofTime.bloodmagic.soul.IDiscreteDemonWill;
|
||||
import WayofTime.bloodmagic.tile.TileDemonCrucible;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import com.google.common.collect.Lists;
|
||||
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.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockDemonCrucible extends Block implements IVariantProvider, IBMBlock {
|
||||
protected static final AxisAlignedBB BODY = new AxisAlignedBB(2 / 16F, 7 / 16F, 2 / 16F, 14 / 16F, 15 / 16F, 14 / 16F);
|
||||
private static final AxisAlignedBB[] ARMS = {
|
||||
new AxisAlignedBB(5 / 16F, 13 / 16F, 0 / 16F, 11 / 16F, 25 / 16F, 2 / 16F), // N
|
||||
new AxisAlignedBB(14 / 16F, 13 / 16F, 5 / 16F, 16 / 16F, 25 / 16F, 11 / 16F), // E
|
||||
new AxisAlignedBB(5 / 16F, 13 / 16F, 14 / 16F, 11 / 16F, 25 / 16F, 16 / 16F), // S
|
||||
new AxisAlignedBB(0 / 16F, 13 / 16F, 5 / 16F, 2 / 16F, 25 / 16F, 11 / 16F) // W
|
||||
};
|
||||
private static final AxisAlignedBB[] FEET = {
|
||||
new AxisAlignedBB(10 / 16F, 0F, 2 / 16F, 14 / 16F, 7 / 16F, 6 / 16F), // NE
|
||||
new AxisAlignedBB(10 / 16F, 0F, 10 / 16F, 14 / 16F, 7 / 16F, 14 / 16F), // SE
|
||||
new AxisAlignedBB(2 / 16F, 0F, 10 / 16F, 6 / 16F, 7 / 16F, 14 / 16F), // SW
|
||||
new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 6 / 16F, 7 / 16F, 6 / 16F) // NW
|
||||
};
|
||||
|
||||
|
||||
public BlockDemonCrucible() {
|
||||
super(Material.ROCK);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".demonCrucible");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 0);
|
||||
|
||||
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
|
||||
}
|
||||
|
||||
private static List<AxisAlignedBB> getCollisionBoxList(BlockState state) {
|
||||
ArrayList<AxisAlignedBB> collBox = new ArrayList<>(Arrays.asList(ARMS));
|
||||
collBox.add(BODY);
|
||||
collBox.addAll(Arrays.asList(FEET));
|
||||
return collBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
TileDemonCrucible crucible = (TileDemonCrucible) world.getTileEntity(pos);
|
||||
|
||||
if (crucible == null || player.isSneaking())
|
||||
return false;
|
||||
|
||||
if (!heldItem.isEmpty()) {
|
||||
if (!(heldItem.getItem() instanceof IDiscreteDemonWill) && !(heldItem.getItem() instanceof IDemonWillGem)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Utils.insertItemToTile(crucible, player);
|
||||
|
||||
world.notifyBlockUpdate(pos, state, state, 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, BlockState blockState) {
|
||||
TileDemonCrucible tile = (TileDemonCrucible) world.getTileEntity(blockPos);
|
||||
if (tile != null)
|
||||
tile.dropItems();
|
||||
|
||||
super.breakBlock(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileDemonCrucible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new BlockItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
List<RayTraceResult> list = Lists.newArrayList();
|
||||
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos))) {
|
||||
list.add(this.rayTrace(pos, start, end, axisalignedbb));
|
||||
}
|
||||
|
||||
RayTraceResult rayTrace = null;
|
||||
double d1 = 0.0D;
|
||||
|
||||
for (RayTraceResult raytraceresult : list) {
|
||||
if (raytraceresult != null) {
|
||||
double d0 = raytraceresult.hitVec.squareDistanceTo(end);
|
||||
|
||||
if (d0 > d1) {
|
||||
rayTrace = raytraceresult;
|
||||
d1 = d0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rayTrace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean bool) {
|
||||
state = this.getActualState(state, worldIn, pos);
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) {
|
||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,368 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.ItemDemonCrystal;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockDemonCrystal;
|
||||
import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.tile.TileDemonCrystal;
|
||||
import com.google.common.collect.Lists;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockDemonCrystal extends Block implements IBMBlock, IVariantProvider {
|
||||
|
||||
public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 6);
|
||||
public static final PropertyEnum<EnumDemonWillType> TYPE = PropertyEnum.create("type", EnumDemonWillType.class);
|
||||
public static final PropertyEnum<Direction> ATTACHED = PropertyEnum.create("attached", Direction.class);
|
||||
private static final EnumMap<Direction, AxisAlignedBB> bounds = new EnumMap<>(Direction.class);
|
||||
|
||||
// Bounding / Collision boxes
|
||||
private static final AxisAlignedBB[] UP = {
|
||||
new AxisAlignedBB(6 / 16F, 0, 5 / 16F, 10 / 16F, 13 / 16F, 9 / 16F),
|
||||
new AxisAlignedBB(7 / 16F, 0, 0, 13 / 16F, 6 / 16F, 5 / 16F),
|
||||
new AxisAlignedBB(9 / 16F, 0, 9 / 16F, 13 / 16F, 5 / 16F, 14 / 16F),
|
||||
new AxisAlignedBB(2 / 16F, 0, 1 / 16F, 7 / 16F, 6 / 16F, 7 / 16F),
|
||||
new AxisAlignedBB(5 / 16F, 0, 9 / 16F, 9 / 16F, 7 / 16F, 15 / 16F),
|
||||
new AxisAlignedBB(0, 0, 7 / 16F, 6 / 16F, 6 / 16F, 10 / 16F),
|
||||
new AxisAlignedBB(10 / 16F, 0, 6 / 16F, 15 / 16F, 6 / 16F, 9 / 16F)
|
||||
};
|
||||
private static final AxisAlignedBB[] DOWN = {
|
||||
new AxisAlignedBB(6 / 16F, 3 / 16F, 7 / 16F, 10 / 16F, 16 / 16F, 11 / 16F),
|
||||
new AxisAlignedBB(7 / 16F, 10 / 16F, 11 / 16F, 13 / 16F, 16 / 16F, 16 / 16F),
|
||||
new AxisAlignedBB(9 / 16F, 11 / 16F, 2 / 16F, 13 / 16F, 16 / 16F, 7 / 16F),
|
||||
new AxisAlignedBB(2 / 16F, 9 / 16F, 11 / 16F, 7 / 16F, 16 / 16F, 15 / 16F),
|
||||
new AxisAlignedBB(5 / 16F, 9 / 16F, 1 / 16F, 9 / 16F, 16 / 16F, 7 / 16F),
|
||||
new AxisAlignedBB(0, 10 / 16F, 6 / 16F, 6 / 16F, 16 / 16F, 9 / 16F),
|
||||
new AxisAlignedBB(10 / 16F, 11 / 16F, 7 / 16F, 15 / 16F, 16 / 16F, 10 / 16F)
|
||||
};
|
||||
private static final AxisAlignedBB[] NORTH = {
|
||||
new AxisAlignedBB(6 / 16F, 5 / 16F, 3 / 16F, 10 / 16F, 9 / 16F, 16 / 16F),
|
||||
new AxisAlignedBB(9 / 16F, 0, 6 / 16F, 13 / 16F, 5 / 16F, 16 / 16F),
|
||||
new AxisAlignedBB(8 / 16F, 9 / 16F, 11 / 16F, 13 / 16F, 14 / 16F, 16 / 16F),
|
||||
new AxisAlignedBB(2 / 16F, 1 / 16F, 9 / 16F, 7 / 16F, 7 / 16F, 16 / 16F),
|
||||
new AxisAlignedBB(5 / 16F, 9 / 16F, 9 / 16F, 9 / 16F, 15 / 16F, 16 / 16F),
|
||||
new AxisAlignedBB(0, 7 / 16F, 10 / 16F, 6 / 16F, 10 / 16F, 16 / 16F),
|
||||
new AxisAlignedBB(10 / 16F, 7 / 16F, 10 / 16F, 15 / 16F, 9 / 16F, 15 / 16F),
|
||||
};
|
||||
private static final AxisAlignedBB[] SOUTH = {
|
||||
new AxisAlignedBB(6 / 16F, 7 / 16F, 0 / 16F, 10 / 16F, 11 / 16F, 13 / 16F),
|
||||
new AxisAlignedBB(7 / 16F, 11 / 16F, 0, 13 / 16F, 16 / 16F, 6 / 16F),
|
||||
new AxisAlignedBB(8 / 16F, 2 / 16F, 9 / 16F, 13 / 16F, 7 / 16F, 14 / 16F),
|
||||
new AxisAlignedBB(2 / 16F, 9 / 16F, 1 / 16F, 7 / 16F, 14 / 16F, 7 / 16F),
|
||||
new AxisAlignedBB(5 / 16F, 1 / 16F, 9 / 16F, 9 / 16F, 7 / 16F, 9 / 16F),
|
||||
new AxisAlignedBB(0, 6 / 16F, 1 / 16F, 6 / 16F, 9 / 16F, 7 / 16F),
|
||||
new AxisAlignedBB(10 / 16F, 8 / 16F, 1 / 16F, 15 / 16F, 10 / 16F, 6 / 16F)
|
||||
};
|
||||
private static final AxisAlignedBB[] EAST = {
|
||||
new AxisAlignedBB(0, 6 / 16F, 5 / 16F, 13 / 16F, 10 / 16F, 9 / 16F),
|
||||
new AxisAlignedBB(0, 3 / 16F, 0, 6 / 16F, 9 / 16F, 5 / 16F),
|
||||
new AxisAlignedBB(0 / 16F, 3 / 16F, 9 / 16F, 5 / 16F, 8 / 16F, 14 / 16F),
|
||||
new AxisAlignedBB(1 / 16F, 9 / 16F, 1 / 16F, 7 / 16F, 13 / 16F, 7 / 16F),
|
||||
new AxisAlignedBB(1 / 16F, 0, 9 / 16F, 7 / 16F, 11 / 16F, 15 / 16F),
|
||||
new AxisAlignedBB(0, 10 / 16F, 7 / 16F, 6 / 16F, 16 / 16F, 10 / 16F),
|
||||
new AxisAlignedBB(0, 1 / 16F, 6 / 16F, 5 / 16F, 6 / 16F, 9 / 16F)
|
||||
};
|
||||
private static final AxisAlignedBB[] WEST = {
|
||||
new AxisAlignedBB(3 / 16F, 6 / 16F, 5 / 16F, 16 / 16F, 10 / 16F, 9 / 16F),
|
||||
new AxisAlignedBB(9 / 16F, 7 / 16F, 0, 16 / 16F, 12 / 16F, 5 / 16F),
|
||||
new AxisAlignedBB(11 / 16F, 4 / 16F, 9 / 16F, 16 / 16F, 13 / 16F, 14 / 16F),
|
||||
new AxisAlignedBB(9 / 16F, 3 / 16F, 1 / 16F, 16 / 16F, 8 / 16F, 7 / 16F),
|
||||
new AxisAlignedBB(9 / 16F, 6 / 16F, 9 / 16F, 16 / 16F, 8 / 16F, 15 / 16F),
|
||||
new AxisAlignedBB(10 / 16F, 1 / 16F, 7 / 16F, 16 / 16F, 6 / 16F, 10 / 16F),
|
||||
new AxisAlignedBB(10 / 16F, 6 / 16F, 6 / 16F, 15 / 16F, 15 / 16F, 9 / 16F)
|
||||
};
|
||||
|
||||
public BlockDemonCrystal() {
|
||||
super(Material.ROCK);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumDemonWillType.DEFAULT).withProperty(ATTACHED, Direction.UP));
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".demonCrystal.");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackDropped(EnumDemonWillType type, int crystalNumber) {
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
stack = EnumDemonWillType.CORROSIVE.getStack();
|
||||
break;
|
||||
case DEFAULT:
|
||||
stack = EnumDemonWillType.DEFAULT.getStack();
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
stack = EnumDemonWillType.DESTRUCTIVE.getStack();
|
||||
break;
|
||||
case STEADFAST:
|
||||
stack = EnumDemonWillType.STEADFAST.getStack();
|
||||
break;
|
||||
case VENGEFUL:
|
||||
stack = EnumDemonWillType.VENGEFUL.getStack();
|
||||
break;
|
||||
}
|
||||
|
||||
stack.setCount(crystalNumber);
|
||||
return stack;
|
||||
}
|
||||
|
||||
// collects a sublist from 0 to age for the collision boxes
|
||||
private static List<AxisAlignedBB> getCollisionBoxList(BlockState state) {
|
||||
int age = state.getValue(BlockDemonCrystal.AGE) + 1;
|
||||
switch (state.getValue(BlockDemonCrystal.ATTACHED)) {
|
||||
case DOWN:
|
||||
return Arrays.asList(DOWN).subList(0, age);
|
||||
case NORTH:
|
||||
return Arrays.asList(NORTH).subList(0, age);
|
||||
case SOUTH:
|
||||
return Arrays.asList(SOUTH).subList(0, age);
|
||||
case WEST:
|
||||
return Arrays.asList(WEST).subList(0, age);
|
||||
case EAST:
|
||||
return Arrays.asList(EAST).subList(0, age);
|
||||
case UP:
|
||||
default:
|
||||
return Arrays.asList(UP).subList(0, age);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
TileEntity tile = source.getTileEntity(pos);
|
||||
if (tile != null)
|
||||
state = getActualState(state, tile.getWorld(), pos);
|
||||
switch (state.getValue(ATTACHED)) {
|
||||
case DOWN:
|
||||
return DOWN[0];
|
||||
case NORTH:
|
||||
return NORTH[0];
|
||||
case SOUTH:
|
||||
return SOUTH[0];
|
||||
case EAST:
|
||||
return EAST[0];
|
||||
case WEST:
|
||||
return WEST[0];
|
||||
case UP:
|
||||
default:
|
||||
return UP[0];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
if (!world.isRemote) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileDemonCrystal) {
|
||||
TileDemonCrystal crystal = (TileDemonCrystal) tile;
|
||||
boolean isCreative = player.capabilities.isCreativeMode;
|
||||
boolean holdsCrystal = player.getHeldItem(hand).getItem() instanceof ItemDemonCrystal;
|
||||
|
||||
if (PlayerDemonWillHandler.getTotalDemonWill(EnumDemonWillType.DEFAULT, player) > 1024 && !(holdsCrystal && isCreative)) {
|
||||
crystal.dropSingleCrystal();
|
||||
|
||||
}
|
||||
if (!crystal.getWorld().isRemote && isCreative && holdsCrystal) {
|
||||
if (crystal.crystalCount < 7) {
|
||||
crystal.internalCounter = 0;
|
||||
if (crystal.progressToNextCrystal > 0)
|
||||
crystal.progressToNextCrystal--;
|
||||
crystal.crystalCount++;
|
||||
crystal.markDirty();
|
||||
crystal.notifyUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileDemonCrystal) {
|
||||
EnumDemonWillType type = state.getValue(TYPE);
|
||||
int number = ((TileDemonCrystal) tile).getCrystalCount();
|
||||
|
||||
drops.add(getItemStackDropped(type, number));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getActualState(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileDemonCrystal) {
|
||||
TileDemonCrystal crystal = (TileDemonCrystal) tile;
|
||||
state = state.withProperty(AGE, crystal.getCrystalCountForRender());
|
||||
state = state.withProperty(ATTACHED, crystal.getPlacement());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(BlockState state, World world, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileDemonCrystal) {
|
||||
TileDemonCrystal crystal = (TileDemonCrystal) tile;
|
||||
Direction placement = crystal.getPlacement();
|
||||
BlockPos offsetPos = pos.offset(placement.getOpposite());
|
||||
BlockState offsetState = world.getBlockState(offsetPos);
|
||||
|
||||
if (!offsetState.isSideSolid(world, offsetPos, placement))
|
||||
world.destroyBlock(pos, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide(World world, BlockPos pos, Direction side) {
|
||||
BlockPos offsetPos = pos.offset(side.getOpposite());
|
||||
BlockState offsetState = world.getBlockState(offsetPos);
|
||||
|
||||
return offsetState.isSideSolid(world, offsetPos, side) && this.canPlaceBlockAt(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(ItemGroup creativeTabs, NonNullList<ItemStack> list) {
|
||||
for (EnumDemonWillType willType : EnumDemonWillType.values())
|
||||
list.add(new ItemStack(this, 1, willType.ordinal()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void harvestBlock(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable TileEntity tile, ItemStack stack) {
|
||||
super.harvestBlock(world, player, pos, state, tile, stack);
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(BlockState state, World world, BlockPos pos, PlayerEntity player, boolean willHarvest) {
|
||||
return willHarvest || super.removedByPlayer(state, world, pos, player, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(TYPE, EnumDemonWillType.values()[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
|
||||
return state.getValue(TYPE).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, TYPE, AGE, ATTACHED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileDemonCrystal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new ItemBlockDemonCrystal(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(@Nonnull Int2ObjectMap<String> variants) {
|
||||
for (EnumDemonWillType willType : EnumDemonWillType.values())
|
||||
variants.put(willType.ordinal(), "age=3,attached=up,type=" + willType.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
List<RayTraceResult> list = Lists.newArrayList();
|
||||
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos))) {
|
||||
list.add(this.rayTrace(pos, start, end, axisalignedbb));
|
||||
}
|
||||
|
||||
RayTraceResult rayTrace = null;
|
||||
double d1 = 0.0D;
|
||||
|
||||
for (RayTraceResult raytraceresult : list) {
|
||||
if (raytraceresult != null) {
|
||||
double d0 = raytraceresult.hitVec.squareDistanceTo(end);
|
||||
|
||||
if (d0 > d1) {
|
||||
rayTrace = raytraceresult;
|
||||
d1 = d0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rayTrace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean bool) {
|
||||
state = this.getActualState(state, worldIn, pos);
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) {
|
||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.TileDemonCrystallizer;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ContainerBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockDemonCrystallizer extends ContainerBlock implements IVariantProvider, IBMBlock {
|
||||
public BlockDemonCrystallizer() {
|
||||
super(Material.ROCK);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".demonCrystallizer");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 0);
|
||||
|
||||
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(BlockState state, IBlockAccess world, BlockPos pos, Direction side) {
|
||||
return side == Direction.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileDemonCrystallizer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(@Nonnull Int2ObjectMap<String> variants) {
|
||||
variants.put(0, "normal");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new BlockItem(this);
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.block.enums.EnumSubWillType;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public class BlockDemonLight extends BlockEnum<EnumSubWillType> {
|
||||
public BlockDemonLight() {
|
||||
super(Material.ROCK, EnumSubWillType.class);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".demonlight.");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
setLightLevel(1);
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnumPillar;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockDemonPillarBase<E extends Enum<E> & IStringSerializable> extends BlockEnumPillar<E> {
|
||||
public BlockDemonPillarBase(String baseName, Material materialIn, Class<E> enumClass) {
|
||||
super(materialIn, enumClass);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + "." + baseName + ".");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(@Nonnull Int2ObjectMap<String> variants) {
|
||||
Direction.Axis[] axis = new Direction.Axis[]{Direction.Axis.Y, Direction.Axis.X, Direction.Axis.Z};
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < this.getTypes().length; j++)
|
||||
variants.put(i * 5 + j, "axis=" + axis[i] + ",type=" + this.getTypes()[j]);
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnumPillarCap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockDemonPillarCapBase<E extends Enum<E> & IStringSerializable> extends BlockEnumPillarCap<E> {
|
||||
public BlockDemonPillarCapBase(String baseName, Material materialIn, Class<E> enumClass) {
|
||||
super(materialIn, enumClass);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + "." + baseName + ".");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(@Nonnull Int2ObjectMap<String> variants) {
|
||||
for (int i = 0; i < Direction.values().length; i++)
|
||||
for (int j = 0; j < this.getTypes().length; j++)
|
||||
variants.put(i * 2 + j, "facing=" + Direction.values()[i] + ",type=" + this.getTypes()[j]);
|
||||
}
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.TileDemonPylon;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ContainerBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockDemonPylon extends ContainerBlock implements IBMBlock, IVariantProvider {
|
||||
protected static final AxisAlignedBB BODY = new AxisAlignedBB(2 / 16F, 7 / 16F, 2 / 16F, 14 / 16F, 20 / 16F, 14 / 16F);
|
||||
private static final AxisAlignedBB[] FEET = {
|
||||
new AxisAlignedBB(10 / 16F, 0F, 2 / 16F, 14 / 16F, 7 / 16F, 6 / 16F), // NE
|
||||
new AxisAlignedBB(10 / 16F, 0F, 10 / 16F, 14 / 16F, 7 / 16F, 14 / 16F), // SE
|
||||
new AxisAlignedBB(2 / 16F, 0F, 10 / 16F, 6 / 16F, 7 / 16F, 14 / 16F), // SW
|
||||
new AxisAlignedBB(2 / 16F, 0F, 2 / 16F, 6 / 16F, 7 / 16F, 6 / 16F) // NW
|
||||
};
|
||||
private static final AxisAlignedBB[] ARMS = {};
|
||||
|
||||
public BlockDemonPylon() {
|
||||
super(Material.ROCK);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".demonPylon");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 0);
|
||||
|
||||
// setBlockBounds(0.3F, 0F, 0.3F, 0.72F, 1F, 0.72F);
|
||||
}
|
||||
|
||||
private static List<AxisAlignedBB> getCollisionBoxList(BlockState state) {
|
||||
ArrayList<AxisAlignedBB> collBox = new ArrayList<>(Arrays.asList(ARMS));
|
||||
collBox.add(BODY);
|
||||
collBox.addAll(Arrays.asList(FEET));
|
||||
return collBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return BODY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileDemonPylon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new BlockItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
List<RayTraceResult> list = Lists.newArrayList();
|
||||
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos))) {
|
||||
list.add(this.rayTrace(pos, start, end, axisalignedbb));
|
||||
}
|
||||
|
||||
RayTraceResult rayTrace = null;
|
||||
double d1 = 0.0D;
|
||||
|
||||
for (RayTraceResult raytraceresult : list) {
|
||||
if (raytraceresult != null) {
|
||||
double d0 = raytraceresult.hitVec.squareDistanceTo(end);
|
||||
|
||||
if (d0 > d1) {
|
||||
rayTrace = raytraceresult;
|
||||
d1 = d0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rayTrace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean bool) {
|
||||
state = this.getActualState(state, worldIn, pos);
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) {
|
||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnumStairs;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public class BlockDemonStairsBase<E extends Enum<E> & IStringSerializable> extends BlockEnumStairs<E> {
|
||||
public BlockDemonStairsBase(String baseName, Material materialIn, Class<E> enumClass) {
|
||||
super(materialIn, enumClass);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + "." + baseName + ".");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(Int2ObjectMap<String> variants) {
|
||||
for (int i = 0; i < this.getTypes().length; i++)
|
||||
variants.put(i, "facing=south,half=bottom,shape=straight,type=" + this.getTypes()[i]);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnumWall;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
public class BlockDemonWallBase<E extends Enum<E> & IStringSerializable> extends BlockEnumWall<E> {
|
||||
public BlockDemonWallBase(String baseName, Material materialIn, Class<E> enumClass) {
|
||||
super(materialIn, enumClass);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + "." + baseName + ".");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(Int2ObjectMap<String> variants) {
|
||||
for (int i = 0; i < this.getTypes().length; i++)
|
||||
variants.put(i, "east=true,north=false,south=false,type=" + this.getTypes()[i] + ",up=true,west=true");
|
||||
}
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockInteger;
|
||||
import WayofTime.bloodmagic.ritual.IMasterRitualStone;
|
||||
import WayofTime.bloodmagic.ritual.portal.LocationsHandler;
|
||||
import WayofTime.bloodmagic.teleport.PortalLocation;
|
||||
import WayofTime.bloodmagic.teleport.TeleportQueue;
|
||||
import WayofTime.bloodmagic.teleport.Teleports;
|
||||
import WayofTime.bloodmagic.tile.TileDimensionalPortal;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockDimensionalPortal extends BlockInteger {
|
||||
protected static final AxisAlignedBB AABB_0 = new AxisAlignedBB(0.0D, 0.0D, 0.375D, 1.0D, 1.0D, 0.625D);
|
||||
protected static final AxisAlignedBB AABB_1 = new AxisAlignedBB(0.375D, 0.0D, 0.0D, 0.625D, 1.0D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_DEFAULT = new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 1.0D, 0.625D);
|
||||
|
||||
public BlockDimensionalPortal() {
|
||||
super(Material.PORTAL, 2);
|
||||
setTranslationKey(BloodMagic.MODID + ".dimensionalPortal");
|
||||
setBlockUnbreakable();
|
||||
setResistance(2000);
|
||||
setLightOpacity(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isFullCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return 12;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollision(World world, BlockPos pos, BlockState blockState, Entity entity) {
|
||||
if (!world.isRemote && world.getTileEntity(pos) instanceof TileDimensionalPortal) {
|
||||
TileDimensionalPortal tile = (TileDimensionalPortal) world.getTileEntity(pos);
|
||||
|
||||
if (LocationsHandler.getLocationsHandler() != null) {
|
||||
ArrayList<PortalLocation> linkedLocations = LocationsHandler.getLocationsHandler().getLinkedLocations(tile.portalID);
|
||||
|
||||
if (linkedLocations != null && !linkedLocations.isEmpty() && linkedLocations.size() > 1) {
|
||||
if (world.getTileEntity(tile.getMasterStonePos()) != null && world.getTileEntity(tile.getMasterStonePos()) instanceof IMasterRitualStone) {
|
||||
IMasterRitualStone masterRitualStone = (IMasterRitualStone) world.getTileEntity(tile.getMasterStonePos());
|
||||
if (linkedLocations.get(0).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) {
|
||||
PortalLocation portal = linkedLocations.get(1);
|
||||
if (portal.getDimension() == world.provider.getDimension()) {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), false));
|
||||
} else {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), world, portal.getDimension(), false));
|
||||
}
|
||||
} else if (linkedLocations.get(1).equals(new PortalLocation(masterRitualStone.getBlockPos().up(), world.provider.getDimension()))) {
|
||||
PortalLocation portal = linkedLocations.get(0);
|
||||
if (portal.getDimension() == world.provider.getDimension()) {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), false));
|
||||
} else {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(portal.getX(), portal.getY(), portal.getZ(), entity, masterRitualStone.getOwner(), world, portal.getDimension(), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
int meta = state.getBlock().getMetaFromState(state);
|
||||
if (meta == 0) {
|
||||
return AABB_0;
|
||||
} else if (meta == 1) {
|
||||
return AABB_1;
|
||||
} else {
|
||||
return AABB_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// @Override
|
||||
// public void setBlockBoundsForItemRender()
|
||||
// {
|
||||
// setBlockBounds(0f, 0f, 0.375f, 1f, 1f, 0.625f);
|
||||
// }
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) {
|
||||
this.spawnParticles(world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileDimensionalPortal();
|
||||
}
|
||||
|
||||
private void spawnParticles(World world, int x, int y, int z) {
|
||||
Random random = world.rand;
|
||||
double d0 = 0.0625D;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
double particleX = (double) ((float) x + random.nextFloat());
|
||||
double particleY = (double) ((float) y + random.nextFloat());
|
||||
double particleZ = (double) ((float) z + random.nextFloat());
|
||||
if (i == 0 && !world.getBlockState(new BlockPos(x, y + 1, z)).isOpaqueCube()) {
|
||||
particleY = (double) (y + 1) + d0;
|
||||
}
|
||||
if (i == 1 && !world.getBlockState(new BlockPos(x, y - 1, z)).isOpaqueCube()) {
|
||||
particleY = (double) y - d0;
|
||||
}
|
||||
if (i == 2 && !world.getBlockState(new BlockPos(x, y, z + 1)).isOpaqueCube()) {
|
||||
particleZ = (double) (z + 1) + d0;
|
||||
}
|
||||
if (i == 3 && !world.getBlockState(new BlockPos(x, y, z - 1)).isOpaqueCube()) {
|
||||
particleZ = (double) z - d0;
|
||||
}
|
||||
if (i == 4 && !world.getBlockState(new BlockPos(x + 1, y, z)).isOpaqueCube()) {
|
||||
particleX = (double) (x + 1) + d0;
|
||||
}
|
||||
if (i == 5 && !world.getBlockState(new BlockPos(x - 1, y, z)).isOpaqueCube()) {
|
||||
particleX = (double) x - d0;
|
||||
}
|
||||
if (particleX < (double) x || particleX > (double) (x + 1) || particleY < 0.0D || particleY > (double) (y + 1) || particleZ < (double) z || particleZ > (double) (z + 1)) {
|
||||
world.spawnParticle(EnumParticleTypes.REDSTONE, particleX, particleY, particleZ, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.TileIncenseAltar;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockIncenseAltar extends Block implements IVariantProvider, IBMBlock {
|
||||
protected static final AxisAlignedBB AABB = new AxisAlignedBB(5 / 16F, 0F, 5 / 16F, 12 / 16F, 1F, 11 / 16F);
|
||||
|
||||
public BlockIncenseAltar() {
|
||||
super(Material.ROCK);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".incenseAltar");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, BlockState blockState) {
|
||||
TileIncenseAltar TileIncenseAltar = (TileIncenseAltar) world.getTileEntity(blockPos);
|
||||
if (TileIncenseAltar != null)
|
||||
TileIncenseAltar.dropItems();
|
||||
|
||||
super.breakBlock(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileIncenseAltar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new BlockItem(this);
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
import WayofTime.bloodmagic.tile.routing.TileInputRoutingNode;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockInputRoutingNode extends BlockRoutingNode {
|
||||
public BlockInputRoutingNode() {
|
||||
super();
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".inputRouting");
|
||||
}
|
||||
|
||||
@Override
|
||||
//TODO: Combine BlockInputRoutingNode and BlockInputRoutingNode so they have the same superclass
|
||||
public void breakBlock(World world, BlockPos pos, BlockState state) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileInputRoutingNode) {
|
||||
((TileInputRoutingNode) tile).removeAllConnections();
|
||||
((TileInputRoutingNode) tile).dropItems();
|
||||
}
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
if (world.getTileEntity(pos) instanceof TileInputRoutingNode) {
|
||||
player.openGui(BloodMagic.instance, Constants.Gui.ROUTING_NODE_GUI, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileInputRoutingNode();
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.block.enums.EnumSubWillType;
|
||||
import WayofTime.bloodmagic.tile.TileInversionPillar;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockInversionPillar extends BlockEnum<EnumSubWillType> {
|
||||
public BlockInversionPillar() {
|
||||
super(Material.ROCK, EnumSubWillType.class);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".inversionpillar.");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, BlockState blockState) {
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile instanceof TileInversionPillar) {
|
||||
TileInversionPillar tilePillar = (TileInversionPillar) world.getTileEntity(blockPos);
|
||||
tilePillar.removePillarFromMap();
|
||||
}
|
||||
|
||||
super.breakBlock(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getActualState(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return super.getActualState(state, world, pos).withProperty(Properties.StaticProperty, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(Int2ObjectMap<String> variants) {
|
||||
for (int i = 0; i < this.getTypes().length; i++)
|
||||
variants.put(i, "static=false,type=" + this.getTypes()[i]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileInversionPillar(state.getValue(getProperty()).getType());
|
||||
}
|
||||
|
||||
protected BlockStateContainer createStateContainer() {
|
||||
return new BlockStateContainer.Builder(this).add(getProperty(), Properties.StaticProperty).add(Properties.AnimationProperty).build();
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.block.enums.EnumInversionCap;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BlockInversionPillarEnd extends BlockEnum<EnumInversionCap> implements IVariantProvider {
|
||||
public BlockInversionPillarEnd() {
|
||||
super(Material.ROCK, EnumInversionCap.class);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".inversionpillarend.");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(Int2ObjectMap<String> variants) {
|
||||
for (int i = 0; i < this.getTypes().length; i++)
|
||||
variants.put(i, "type=" + this.getTypes()[i]);
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.tile.routing.TileItemRoutingNode;
|
||||
import WayofTime.bloodmagic.tile.routing.TileRoutingNode;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockItemRoutingNode extends BlockRoutingNode {
|
||||
public BlockItemRoutingNode() {
|
||||
super();
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".itemRouting");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, BlockState state) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileRoutingNode) {
|
||||
((TileRoutingNode) tile).removeAllConnections();
|
||||
}
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileItemRoutingNode();
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.BlockFluidClassic;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class BlockLifeEssence extends BlockFluidClassic {
|
||||
private static final Fluid LIFE_ESSENCE = new FluidLifeEssence();
|
||||
|
||||
public BlockLifeEssence() {
|
||||
super(LIFE_ESSENCE, Material.WATER);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".fluid.lifeEssence");
|
||||
getLifeEssence().setBlock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDisplace(IBlockAccess world, BlockPos blockPos) {
|
||||
return !world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isLiquid() && super.canDisplace(world, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displaceIfPossible(World world, BlockPos blockPos) {
|
||||
return !world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isLiquid() && super.displaceIfPossible(world, blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.SOLID;
|
||||
}
|
||||
|
||||
public static Fluid getLifeEssence() {
|
||||
return LIFE_ESSENCE;
|
||||
}
|
||||
|
||||
public static class FluidLifeEssence extends Fluid {
|
||||
|
||||
public FluidLifeEssence() {
|
||||
super("lifeEssence", new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceStill"), new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceFlowing"));
|
||||
|
||||
setDensity(2000);
|
||||
setViscosity(2000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return Color.RED.getRGB();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedName(FluidStack fluidStack) {
|
||||
return TextHelper.localize("tile.bloodmagic.fluid.lifeEssence.name");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockMasterRoutingNode extends BlockRoutingNode {
|
||||
public BlockMasterRoutingNode() {
|
||||
super();
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".masterRouting");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileMasterRoutingNode();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
// {
|
||||
// if (world.getTileEntity(pos) instanceof TileMasterRoutingNode)
|
||||
// {
|
||||
// player.openGui(BloodMagic.instance, Constants.Gui.MASTER_ROUTING_NODE_GUI, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
}
|
|
@ -1,227 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.altar.ComponentType;
|
||||
import WayofTime.bloodmagic.altar.IAltarComponent;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.block.enums.EnumMimic;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.tile.TileMimic;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.item.block.ItemBlockMimic;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockMimic extends BlockEnum<EnumMimic> implements IAltarComponent {
|
||||
public static final int sentientMimicMeta = 4;
|
||||
|
||||
public BlockMimic() {
|
||||
super(Material.ROCK, EnumMimic.class);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".mimic.");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHarvestLevel("pickaxe", 0);
|
||||
setLightOpacity(15);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
switch (this.getMetaFromState(state)) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
TileMimic tileMimic = (TileMimic) world.getTileEntity(pos);
|
||||
if (tileMimic != null && !tileMimic.getStackInSlot(0).isEmpty()) {
|
||||
Block mimicBlock = Block.getBlockFromItem(tileMimic.getStackInSlot(0).getItem());
|
||||
if (mimicBlock == Blocks.AIR) {
|
||||
return FULL_BLOCK_AABB;
|
||||
}
|
||||
BlockState mimicState = tileMimic.getReplacedState();
|
||||
if (mimicBlock != this) {
|
||||
return mimicState.getCollisionBoundingBox(world, pos);
|
||||
}
|
||||
} else {
|
||||
return FULL_BLOCK_AABB;
|
||||
}
|
||||
case 0:
|
||||
default:
|
||||
return NULL_AABB;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getSelectedBoundingBox(BlockState state, World world, BlockPos pos) {
|
||||
TileMimic tileMimic = (TileMimic) world.getTileEntity(pos);
|
||||
if (tileMimic != null && !tileMimic.getStackInSlot(0).isEmpty()) {
|
||||
Block mimicBlock = Block.getBlockFromItem(tileMimic.getStackInSlot(0).getItem());
|
||||
if (mimicBlock == Blocks.AIR) {
|
||||
return FULL_BLOCK_AABB;
|
||||
}
|
||||
BlockState mimicState = tileMimic.getReplacedState();
|
||||
if (mimicBlock != this) {
|
||||
return mimicState.getSelectedBoundingBox(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
return FULL_BLOCK_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightOpacity(BlockState state) {
|
||||
switch (this.getMetaFromState(state)) {
|
||||
case 2:
|
||||
case 4:
|
||||
return 0;
|
||||
default:
|
||||
return this.lightOpacity;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(BlockState state) {
|
||||
switch (this.getMetaFromState(state)) {
|
||||
case 3:
|
||||
return 15;
|
||||
default:
|
||||
return this.lightValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
if (state.getBlock() == this) {
|
||||
return super.getMetaFromState(state);
|
||||
}
|
||||
|
||||
return state.getBlock().getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
TileMimic mimic = (TileMimic) world.getTileEntity(pos);
|
||||
|
||||
return mimic != null && mimic.onBlockActivated(world, pos, state, player, hand, player.getHeldItem(hand), side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getActualState(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileMimic) {
|
||||
TileMimic mimic = (TileMimic) tile;
|
||||
ItemStack stack = mimic.getStackInSlot(0);
|
||||
if (stack.getItem() instanceof BlockItem) {
|
||||
Block block = ((BlockItem) stack.getItem()).getBlock();
|
||||
BlockState mimicState = mimic.getReplacedState();
|
||||
if (block != this) {
|
||||
if (block.getRenderType(mimicState) == BlockRenderType.ENTITYBLOCK_ANIMATED) {
|
||||
return RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState(); //Small and invisible-ish, basically this is returned in order to not render over the animated block (TESR)
|
||||
}
|
||||
|
||||
return block.getActualState(mimicState, world, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockState state, BlockRenderLayer layer) {
|
||||
return layer == BlockRenderLayer.CUTOUT_MIPPED || layer == BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, BlockState blockState) {
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile instanceof TileMimic) {
|
||||
TileMimic TileMimic = (TileMimic) world.getTileEntity(blockPos);
|
||||
if (TileMimic != null)
|
||||
TileMimic.dropItems();
|
||||
}
|
||||
|
||||
super.breakBlock(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileMimic();
|
||||
}
|
||||
|
||||
// IAltarComponent
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ComponentType getType(World world, BlockState state, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileMimic) {
|
||||
TileMimic mimic = (TileMimic) tile;
|
||||
ItemStack stack = mimic.getStackInSlot(0);
|
||||
if (stack.getItem() instanceof BlockItem) {
|
||||
Block block = ((BlockItem) stack.getItem()).getBlock();
|
||||
if (block instanceof IAltarComponent) {
|
||||
return ((IAltarComponent) block).getType(world, mimic.getReplacedState(), pos);
|
||||
} else {
|
||||
for (ComponentType altarComponent : ComponentType.values())
|
||||
if (block == Utils.getBlockForComponent(altarComponent))
|
||||
return altarComponent;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new ItemBlockMimic(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
import WayofTime.bloodmagic.tile.routing.TileOutputRoutingNode;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockOutputRoutingNode extends BlockRoutingNode {
|
||||
public BlockOutputRoutingNode() {
|
||||
super();
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".outputRouting");
|
||||
}
|
||||
|
||||
@Override
|
||||
//TODO: Combine BlockOutputRoutingNode and BlockInputRoutingNode so they have the same superclass
|
||||
public void breakBlock(World world, BlockPos pos, BlockState state) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileOutputRoutingNode) {
|
||||
((TileOutputRoutingNode) tile).removeAllConnections();
|
||||
((TileOutputRoutingNode) tile).dropItems();
|
||||
}
|
||||
super.breakBlock(world, pos, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
if (world.getTileEntity(pos) instanceof TileOutputRoutingNode) {
|
||||
player.openGui(BloodMagic.instance, Constants.Gui.ROUTING_NODE_GUI, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileOutputRoutingNode();
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.block.enums.EnumPath;
|
||||
import WayofTime.bloodmagic.incense.IIncensePath;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
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.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockPath extends BlockEnum<EnumPath> implements IIncensePath {
|
||||
|
||||
public BlockPath() {
|
||||
super(Material.ROCK, EnumPath.class);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".path.");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.STONE);
|
||||
|
||||
setHarvestLevel("axe", 0, getDefaultState().withProperty(getProperty(), EnumPath.WOOD));
|
||||
setHarvestLevel("axe", 0, getDefaultState().withProperty(getProperty(), EnumPath.WOODTILE));
|
||||
setHarvestLevel("pickaxe", 0, getDefaultState().withProperty(getProperty(), EnumPath.STONE));
|
||||
setHarvestLevel("pickaxe", 0, getDefaultState().withProperty(getProperty(), EnumPath.STONETILE));
|
||||
setHarvestLevel("pickaxe", 0, getDefaultState().withProperty(getProperty(), EnumPath.WORNSTONE));
|
||||
setHarvestLevel("pickaxe", 0, getDefaultState().withProperty(getProperty(), EnumPath.WORNSTONETILE));
|
||||
setHarvestLevel("pickaxe", 3, getDefaultState().withProperty(getProperty(), EnumPath.OBSIDIAN));
|
||||
setHarvestLevel("pickaxe", 3, getDefaultState().withProperty(getProperty(), EnumPath.OBSIDIANTILE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag tooltipFlag) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.decoration.safe"));
|
||||
super.addInformation(stack, world, tooltip, tooltipFlag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getMaterial(BlockState state) {
|
||||
EnumPath path = state.getValue(getProperty());
|
||||
if (path.equals(EnumPath.WOOD) || path.equals(EnumPath.WOODTILE))
|
||||
return Material.WOOD;
|
||||
else
|
||||
return Material.ROCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoundType getSoundType(BlockState state, World world, BlockPos pos, @Nullable Entity entity) {
|
||||
EnumPath path = state.getValue(getProperty());
|
||||
if (path.equals(EnumPath.WOOD) || path.equals(EnumPath.WOODTILE))
|
||||
return SoundType.WOOD;
|
||||
else
|
||||
return super.getSoundType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevelOfPath(World world, BlockPos pos, BlockState state) {
|
||||
switch (this.getMetaFromState(state)) {
|
||||
case 0:
|
||||
case 1:
|
||||
return 2;
|
||||
case 2:
|
||||
case 3:
|
||||
return 4;
|
||||
case 4:
|
||||
case 5:
|
||||
return 6;
|
||||
case 6:
|
||||
case 7:
|
||||
return 8;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.TilePhantomBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockPhantom extends Block implements IVariantProvider {
|
||||
public BlockPhantom() {
|
||||
super(Material.CLOTH);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".phantom");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(BlockState state, IBlockAccess world, BlockPos pos, Direction side) {
|
||||
return world.getBlockState(pos.offset(side)) != state || state.getBlock() != this && super.shouldSideBeRendered(state, world, pos, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TilePhantomBlock(20);
|
||||
}
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.event.RitualEvent;
|
||||
import WayofTime.bloodmagic.iface.IBindable;
|
||||
import WayofTime.bloodmagic.ritual.imperfect.IImperfectRitualStone;
|
||||
import WayofTime.bloodmagic.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual;
|
||||
import WayofTime.bloodmagic.util.helper.RitualHelper;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.block.enums.EnumRitualController;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
|
||||
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
||||
import amerifrance.guideapi.api.IGuideLinked;
|
||||
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.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockRitualController extends BlockEnum<EnumRitualController> implements IGuideLinked {
|
||||
|
||||
public BlockRitualController() {
|
||||
super(Material.ROCK, EnumRitualController.class);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".stone.ritual.");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (state.getValue(getProperty()) != EnumRitualController.IMPERFECT && tile instanceof TileMasterRitualStone) {
|
||||
if (heldItem.getItem() == RegistrarBloodMagicItems.ACTIVATION_CRYSTAL) {
|
||||
if (((IBindable) heldItem.getItem()).getBinding(heldItem) == null)
|
||||
return false;
|
||||
|
||||
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 (state.getValue(getProperty()) == EnumRitualController.INVERTED)
|
||||
((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);
|
||||
}
|
||||
}
|
||||
} else if (state.getValue(getProperty()) == EnumRitualController.IMPERFECT && tile instanceof TileImperfectRitualStone) {
|
||||
BlockState ritualBlock = world.getBlockState(pos.up());
|
||||
ImperfectRitual ritual = BloodMagic.RITUAL_MANAGER.getImperfectRitual(ritualBlock);
|
||||
if (ritual == null)
|
||||
return false;
|
||||
|
||||
RitualEvent.ImperfectRitualActivatedEvent event = new RitualEvent.ImperfectRitualActivatedEvent((IImperfectRitualStone) tile, player, ritual);
|
||||
return !MinecraftForge.EVENT_BUS.post(event) && ((TileImperfectRitualStone) tile).performRitual(world, pos, ritual, player);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHarvested(World world, BlockPos pos, BlockState state, PlayerEntity player) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (getMetaFromState(state) == 0 && tile instanceof TileMasterRitualStone)
|
||||
((TileMasterRitualStone) tile).stopRitual(Ritual.BreakType.BREAK_MRS);
|
||||
}
|
||||
|
||||
@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(World world, BlockState state) {
|
||||
return state.getValue(getProperty()) != EnumRitualController.IMPERFECT ? new TileMasterRitualStone() : new TileImperfectRitualStone();
|
||||
}
|
||||
|
||||
// IGuideLinked
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceLocation getLinkedEntry(World world, BlockPos pos, PlayerEntity player, ItemStack stack) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state.getValue(getProperty()).equals(EnumRitualController.MASTER)) {
|
||||
TileMasterRitualStone mrs = (TileMasterRitualStone) world.getTileEntity(pos);
|
||||
if (mrs == null || mrs.getCurrentRitual() == null)
|
||||
return null;
|
||||
else
|
||||
return new ResourceLocation("bloodmagic", "ritual_" + mrs.getCurrentRitual().getName());
|
||||
} else if (state.getValue(getProperty()).equals(EnumRitualController.IMPERFECT)) {
|
||||
ImperfectRitual imperfectRitual = BloodMagic.RITUAL_MANAGER.getImperfectRitual(world.getBlockState(pos.up()));
|
||||
if (imperfectRitual != null)
|
||||
return new ResourceLocation("bloodmagic", "ritual_" + imperfectRitual.getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ritual.EnumRuneType;
|
||||
import WayofTime.bloodmagic.ritual.IRitualStone;
|
||||
import WayofTime.bloodmagic.block.base.BlockEnum;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockRitualStone extends BlockEnum<EnumRuneType> implements IRitualStone {
|
||||
public BlockRitualStone() {
|
||||
super(Material.ROCK, EnumRuneType.class);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".ritualStone.");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setSoundType(SoundType.STONE);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag tooltipFlag) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.decoration.safe"));
|
||||
super.addInformation(stack, world, tooltip, tooltipFlag);
|
||||
}
|
||||
|
||||
@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 runeType == this.getTypes()[getMetaFromState(world.getBlockState(pos))];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRuneType(World world, BlockPos pos, EnumRuneType runeType) {
|
||||
int meta = runeType.ordinal();
|
||||
BlockState newState = RegistrarBloodMagicBlocks.RITUAL_STONE.getStateFromMeta(meta);
|
||||
world.setBlockState(pos, newState);
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode;
|
||||
import WayofTime.bloodmagic.tile.routing.TileRoutingNode;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockRoutingNode extends Block implements IBMBlock, IVariantProvider {
|
||||
public static final PropertyBool UP = PropertyBool.create("up");
|
||||
public static final PropertyBool DOWN = PropertyBool.create("down");
|
||||
public static final PropertyBool NORTH = PropertyBool.create("north");
|
||||
public static final PropertyBool EAST = PropertyBool.create("east");
|
||||
public static final PropertyBool SOUTH = PropertyBool.create("south");
|
||||
public static final PropertyBool WEST = PropertyBool.create("west");
|
||||
protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.378F, 0.378F, 0.378F, 0.625F, 0.625F, 0.625F);
|
||||
|
||||
public BlockRoutingNode() {
|
||||
super(Material.ROCK);
|
||||
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setHarvestLevel("pickaxe", 2);
|
||||
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(DOWN, false).withProperty(UP, false).withProperty(NORTH, false).withProperty(EAST, false).withProperty(SOUTH, false).withProperty(WEST, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(BlockState state, IBlockAccess world, BlockPos pos, Direction side) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderInLayer(BlockState state, BlockRenderLayer layer) {
|
||||
return layer == BlockRenderLayer.CUTOUT_MIPPED || layer == BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the BlockState into the correct metadata value
|
||||
*/
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getActualState(BlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
return state.withProperty(UP, this.shouldConnect(state, worldIn, pos.up(), Direction.DOWN)).withProperty(DOWN, this.shouldConnect(state, worldIn, pos.down(), Direction.UP)).withProperty(NORTH, this.shouldConnect(state, worldIn, pos.north(), Direction.SOUTH)).withProperty(EAST, this.shouldConnect(state, worldIn, pos.east(), Direction.WEST)).withProperty(SOUTH, this.shouldConnect(state, worldIn, pos.south(), Direction.NORTH)).withProperty(WEST, this.shouldConnect(state, worldIn, pos.west(), Direction.EAST));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, UP, DOWN, NORTH, EAST, WEST, SOUTH);
|
||||
}
|
||||
|
||||
public boolean shouldConnect(BlockState state, IBlockAccess world, BlockPos pos, Direction attachedSide) {
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
return block.getMaterial(blockState).isOpaque() && blockState.isFullCube();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos pos, BlockState blockState) {
|
||||
if (!world.isRemote) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileRoutingNode) {
|
||||
((TileRoutingNode) tile).removeAllConnections();
|
||||
} else if (tile instanceof TileMasterRoutingNode) {
|
||||
((TileMasterRoutingNode) tile).removeAllConnections();
|
||||
}
|
||||
}
|
||||
|
||||
super.breakBlock(world, pos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new BlockItem(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(@Nonnull Int2ObjectMap<String> variants) {
|
||||
variants.put(0, "inventory");
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.tile.TileSoulForge;
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
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.BlockItem;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockSoulForge extends Block implements IVariantProvider, IBMBlock {
|
||||
protected static final AxisAlignedBB AABB = new AxisAlignedBB(0.06F, 0.0F, 0.06F, 0.94F, 0.75F, 0.94F);
|
||||
|
||||
public BlockSoulForge() {
|
||||
super(Material.IRON);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".soulForge");
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
setSoundType(SoundType.METAL);
|
||||
setHarvestLevel("pickaxe", 1);
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
if (world.getTileEntity(pos) instanceof TileSoulForge)
|
||||
player.openGui(BloodMagic.instance, Constants.Gui.SOUL_FORGE_GUI, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, BlockState blockState) {
|
||||
TileSoulForge tileSoulForge = (TileSoulForge) world.getTileEntity(blockPos);
|
||||
if (tileSoulForge != null)
|
||||
tileSoulForge.dropItems();
|
||||
|
||||
super.breakBlock(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileSoulForge();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new BlockItem(this);
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.tile.TileSpectralBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockSpectral extends Block {
|
||||
protected static final AxisAlignedBB AABB = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
|
||||
|
||||
public BlockSpectral() {
|
||||
super(Material.CLOTH);
|
||||
|
||||
setTranslationKey(BloodMagic.MODID + ".spectral");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNormalCube(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean causesSuffocation(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.TRANSLUCENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return ConfigHandler.client.invisibleSpectralBlocks ? BlockRenderType.INVISIBLE : BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean shouldSideBeRendered(BlockState state, IBlockAccess world, BlockPos pos, Direction side) {
|
||||
return world.getBlockState(pos.offset(side)) != state || state.getBlock() != this && super.shouldSideBeRendered(state, world, pos, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity, boolean bool) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int quantityDropped(Random par1Random) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReplaceable(IBlockAccess worldIn, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir(BlockState state, IBlockAccess world, BlockPos blockPos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, BlockState state) {
|
||||
return new TileSpectralBlock();
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.command.sub.SubCommandTeleposer;
|
||||
import WayofTime.bloodmagic.item.ItemTelepositionFocus;
|
||||
import WayofTime.bloodmagic.tile.TileTeleposer;
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
import net.minecraft.block.ContainerBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockTeleposer extends ContainerBlock implements IVariantProvider, IBMBlock {
|
||||
public BlockTeleposer() {
|
||||
super(Material.ROCK);
|
||||
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setTranslationKey(BloodMagic.MODID + ".teleposer");
|
||||
setHardness(2.0F);
|
||||
setResistance(5.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRenderType getRenderType(BlockState state) {
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, Direction side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack playerItem = player.getHeldItem(hand);
|
||||
|
||||
if (playerItem.getItem() instanceof ItemTelepositionFocus)
|
||||
((ItemTelepositionFocus) playerItem.getItem()).setBlockPos(playerItem, world, pos);
|
||||
else if (world.getTileEntity(pos) instanceof TileTeleposer)
|
||||
player.openGui(BloodMagic.instance, Constants.Gui.TELEPOSER_GUI, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, BlockPos blockPos, BlockState blockState) {
|
||||
TileTeleposer tileTeleposer = (TileTeleposer) world.getTileEntity(blockPos);
|
||||
if (tileTeleposer != null) {
|
||||
tileTeleposer.dropItems();
|
||||
SubCommandTeleposer.teleposerSet.remove(tileTeleposer);
|
||||
}
|
||||
|
||||
super.breakBlock(world, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileTeleposer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new BlockItem(this);
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package WayofTime.bloodmagic.block;
|
||||
|
||||
import net.minecraft.item.BlockItem;
|
||||
|
||||
public interface IBMBlock {
|
||||
|
||||
BlockItem getItem();
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.base;
|
||||
|
||||
import WayofTime.bloodmagic.block.IBMBlock;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.block.base.ItemBlockEnum;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockEnum<E extends Enum<E> & IStringSerializable> extends Block implements IBMBlock, IVariantProvider {
|
||||
private final E[] types;
|
||||
private final PropertyEnum<E> property;
|
||||
private final BlockStateContainer realStateContainer;
|
||||
|
||||
public BlockEnum(Material material, Class<E> enumClass, String propName) {
|
||||
super(material);
|
||||
|
||||
this.types = enumClass.getEnumConstants();
|
||||
this.property = PropertyEnum.create(propName, enumClass);
|
||||
this.realStateContainer = createStateContainer();
|
||||
setDefaultState(getBlockState().getBaseState());
|
||||
}
|
||||
|
||||
public BlockEnum(Material material, Class<E> enumClass) {
|
||||
this(material, enumClass, "type");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer.Builder(this).build(); // Blank to avoid crashes
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BlockStateContainer getBlockState() {
|
||||
return realStateContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(property, types[meta]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
return state.getValue(property).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(BlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(ItemGroup tab, NonNullList<ItemStack> subBlocks) {
|
||||
for (E type : types)
|
||||
subBlocks.add(new ItemStack(this, 1, type.ordinal()));
|
||||
}
|
||||
|
||||
protected BlockStateContainer createStateContainer() {
|
||||
return new BlockStateContainer.Builder(this).add(property).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockItem getItem() {
|
||||
return new ItemBlockEnum<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherVariants(@Nonnull Int2ObjectMap<String> variants) {
|
||||
if (getItem() == null)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < types.length; i++)
|
||||
variants.put(i, getProperty().getName() + "=" + types[i].name());
|
||||
}
|
||||
|
||||
public E[] getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public PropertyEnum<E> getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public BlockStateContainer getRealStateContainer() {
|
||||
return realStateContainer;
|
||||
}
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.base;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.RotatedPillarBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
public class BlockEnumPillar<E extends Enum<E> & IStringSerializable> extends BlockEnum<E> {
|
||||
public BlockEnumPillar(Material material, Class<E> enumClass, String propName) {
|
||||
super(material, enumClass, propName);
|
||||
}
|
||||
|
||||
public BlockEnumPillar(Material material, Class<E> enumClass) {
|
||||
this(material, enumClass, "type");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createStateContainer() {
|
||||
return new BlockStateContainer.Builder(this).add(getProperty(), RotatedPillarBlock.AXIS).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
BlockState state = getBlockState().getBaseState().withProperty(this.getProperty(), getTypes()[meta % 5]);
|
||||
|
||||
switch (meta / 5) {
|
||||
case 0:
|
||||
state = state.withProperty(RotatedPillarBlock.AXIS, Direction.Axis.Y);
|
||||
break;
|
||||
case 1:
|
||||
state = state.withProperty(RotatedPillarBlock.AXIS, Direction.Axis.X);
|
||||
break;
|
||||
case 2:
|
||||
state = state.withProperty(RotatedPillarBlock.AXIS, Direction.Axis.Z);
|
||||
break;
|
||||
default:
|
||||
state.withProperty(RotatedPillarBlock.AXIS, Direction.Axis.Y);
|
||||
break;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, World world, BlockPos pos, PlayerEntity player) {
|
||||
return new ItemStack(this, 1, damageDropped(state));
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
int i = ArrayUtils.indexOf(getTypes(), state.getValue(getProperty()));
|
||||
|
||||
switch (state.getValue(RotatedPillarBlock.AXIS)) {
|
||||
case X:
|
||||
i = i + 5;
|
||||
break;
|
||||
case Z:
|
||||
i = i + 10;
|
||||
break;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World world, BlockPos pos, Direction axis) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
for (IProperty<?> prop : state.getProperties().keySet()) {
|
||||
if (prop == RotatedPillarBlock.AXIS) {
|
||||
world.setBlockState(pos, state.cycleProperty(prop));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState withRotation(BlockState state, Rotation rot) {
|
||||
switch (rot) {
|
||||
case COUNTERCLOCKWISE_90:
|
||||
case CLOCKWISE_90:
|
||||
switch (state.getValue(RotatedPillarBlock.AXIS)) {
|
||||
case X:
|
||||
return state.withProperty(RotatedPillarBlock.AXIS, Direction.Axis.Z);
|
||||
case Z:
|
||||
return state.withProperty(RotatedPillarBlock.AXIS, Direction.Axis.X);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getSilkTouchDrop(BlockState state) {
|
||||
return new ItemStack(this, 1, damageDropped(state));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(World world, BlockPos pos, Direction facing, float hitX, float hitY, float hitZ, int meta, LivingEntity placer, Hand hand) {
|
||||
return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand).withProperty(RotatedPillarBlock.AXIS, facing.getAxis());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(BlockState state) {
|
||||
return super.getMetaFromState(state);
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.base;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
public class BlockEnumPillarCap<E extends Enum<E> & IStringSerializable> extends BlockEnum<E> {
|
||||
public static final PropertyDirection FACING = PropertyDirection.create("facing");
|
||||
|
||||
public BlockEnumPillarCap(Material material, Class<E> enumClass, String propName) {
|
||||
super(material, enumClass, propName);
|
||||
}
|
||||
|
||||
public BlockEnumPillarCap(Material material, Class<E> enumClass) {
|
||||
this(material, enumClass, "type");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createStateContainer() {
|
||||
return new BlockStateContainer.Builder(this).add(getProperty(), FACING).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
BlockState state = getBlockState().getBaseState().withProperty(this.getProperty(), getTypes()[meta % 2]);
|
||||
return state.withProperty(FACING, Direction.byIndex(meta / 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
int i = ArrayUtils.indexOf(getTypes(), state.getValue(getProperty()));
|
||||
return i + 2 * state.getValue(FACING).getIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, World world, BlockPos pos, PlayerEntity player) {
|
||||
return new ItemStack(this, 1, damageDropped(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState withRotation(BlockState state, Rotation rot) {
|
||||
return state.withProperty(FACING, rot.rotate(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState withMirror(BlockState state, Mirror mirrorIn) {
|
||||
return state.withRotation(mirrorIn.toRotation(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getSilkTouchDrop(BlockState state) {
|
||||
return new ItemStack(this, 1, damageDropped(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(World world, BlockPos pos, Direction facing, float hitX, float hitY, float hitZ, int meta, LivingEntity placer, Hand hand) {
|
||||
return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand).withProperty(FACING, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(BlockState state) {
|
||||
return super.getMetaFromState(state);
|
||||
}
|
||||
}
|
|
@ -1,343 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.base;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.StairsBlock;
|
||||
import net.minecraft.block.StairsBlock.EnumHalf;
|
||||
import net.minecraft.block.StairsBlock.EnumShape;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockEnumStairs<E extends Enum<E> & IStringSerializable> extends BlockEnum<E> {
|
||||
public static final PropertyDirection FACING = HorizontalBlock.FACING;
|
||||
|
||||
protected static final AxisAlignedBB AABB_SLAB_TOP = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_QTR_TOP_WEST = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 0.5D, 1.0D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_QTR_TOP_EAST = new AxisAlignedBB(0.5D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_QTR_TOP_NORTH = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 0.5D);
|
||||
protected static final AxisAlignedBB AABB_QTR_TOP_SOUTH = new AxisAlignedBB(0.0D, 0.5D, 0.5D, 1.0D, 1.0D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_OCT_TOP_NW = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 0.5D, 1.0D, 0.5D);
|
||||
protected static final AxisAlignedBB AABB_OCT_TOP_NE = new AxisAlignedBB(0.5D, 0.5D, 0.0D, 1.0D, 1.0D, 0.5D);
|
||||
protected static final AxisAlignedBB AABB_OCT_TOP_SW = new AxisAlignedBB(0.0D, 0.5D, 0.5D, 0.5D, 1.0D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_OCT_TOP_SE = new AxisAlignedBB(0.5D, 0.5D, 0.5D, 1.0D, 1.0D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_SLAB_BOTTOM = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_QTR_BOT_WEST = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.5D, 0.5D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_QTR_BOT_EAST = new AxisAlignedBB(0.5D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_QTR_BOT_NORTH = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 0.5D);
|
||||
protected static final AxisAlignedBB AABB_QTR_BOT_SOUTH = new AxisAlignedBB(0.0D, 0.0D, 0.5D, 1.0D, 0.5D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_OCT_BOT_NW = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.5D, 0.5D, 0.5D);
|
||||
protected static final AxisAlignedBB AABB_OCT_BOT_NE = new AxisAlignedBB(0.5D, 0.0D, 0.0D, 1.0D, 0.5D, 0.5D);
|
||||
protected static final AxisAlignedBB AABB_OCT_BOT_SW = new AxisAlignedBB(0.0D, 0.0D, 0.5D, 0.5D, 0.5D, 1.0D);
|
||||
protected static final AxisAlignedBB AABB_OCT_BOT_SE = new AxisAlignedBB(0.5D, 0.0D, 0.5D, 1.0D, 0.5D, 1.0D);
|
||||
|
||||
public BlockEnumStairs(Material material, Class<E> enumClass, String propName) {
|
||||
super(material, enumClass, propName);
|
||||
}
|
||||
|
||||
public BlockEnumStairs(Material material, Class<E> enumClass) {
|
||||
this(material, enumClass, "type");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createStateContainer() {
|
||||
return new BlockStateContainer.Builder(this).add(getProperty(), FACING, StairsBlock.HALF, StairsBlock.SHAPE).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCollisionBoxToList(BlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean bool) {
|
||||
state = this.getActualState(state, worldIn, pos);
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state)) {
|
||||
addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(World world, BlockPos pos, Direction facing, float hitX, float hitY, float hitZ, int meta, LivingEntity placer, Hand hand) {
|
||||
BlockState state = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand);
|
||||
state = state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(StairsBlock.SHAPE, StairsBlock.EnumShape.STRAIGHT);
|
||||
return facing != Direction.DOWN && (facing == Direction.UP || (double) hitY <= 0.5D) ? state.withProperty(StairsBlock.HALF, StairsBlock.EnumHalf.BOTTOM) : state.withProperty(StairsBlock.HALF, StairsBlock.EnumHalf.TOP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayTraceResult collisionRayTrace(BlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) {
|
||||
List<RayTraceResult> list = Lists.newArrayList();
|
||||
|
||||
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos))) {
|
||||
list.add(this.rayTrace(pos, start, end, axisalignedbb));
|
||||
}
|
||||
|
||||
RayTraceResult rayTrace = null;
|
||||
double d1 = 0.0D;
|
||||
|
||||
for (RayTraceResult raytraceresult : list) {
|
||||
if (raytraceresult != null) {
|
||||
double d0 = raytraceresult.hitVec.squareDistanceTo(end);
|
||||
|
||||
if (d0 > d1) {
|
||||
rayTrace = raytraceresult;
|
||||
d1 = d0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rayTrace;
|
||||
}
|
||||
|
||||
// Meta looks like: {1|11|1} = {HALF|FACING|TYPE}
|
||||
@Override
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
BlockState state = getBlockState().getBaseState().withProperty(StairsBlock.HALF, (meta & 8) > 0 ? StairsBlock.EnumHalf.TOP : StairsBlock.EnumHalf.BOTTOM);
|
||||
state = state.withProperty(FACING, Direction.byIndex(5 - (meta & 6) / 2)).withProperty(this.getProperty(), getTypes()[meta % 2]);
|
||||
return state;
|
||||
}
|
||||
|
||||
// Meta looks like: {1|11|1} = {HALF|FACING|TYPE}
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
int i = 0;
|
||||
|
||||
if (state.getValue(StairsBlock.HALF) == StairsBlock.EnumHalf.TOP) {
|
||||
i |= 4;
|
||||
}
|
||||
|
||||
i = i | 5 - state.getValue(FACING).getIndex();
|
||||
return i * 2 + ArrayUtils.indexOf(getTypes(), state.getValue(getProperty()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getActualState(BlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
return state.withProperty(StairsBlock.SHAPE, getStairsShape(state, worldIn, pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState withRotation(BlockState state, Rotation rot) {
|
||||
return state.withProperty(FACING, rot.rotate(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public BlockState withMirror(BlockState state, Mirror mirrorIn) {
|
||||
Direction facing = state.getValue(FACING);
|
||||
StairsBlock.EnumShape stairShape = state.getValue(StairsBlock.SHAPE);
|
||||
|
||||
switch (mirrorIn) {
|
||||
case LEFT_RIGHT:
|
||||
|
||||
if (facing.getAxis() == Direction.Axis.Z) {
|
||||
switch (stairShape) {
|
||||
case OUTER_LEFT:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(StairsBlock.SHAPE, StairsBlock.EnumShape.OUTER_RIGHT);
|
||||
case OUTER_RIGHT:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(StairsBlock.SHAPE, StairsBlock.EnumShape.OUTER_LEFT);
|
||||
case INNER_RIGHT:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(StairsBlock.SHAPE, StairsBlock.EnumShape.INNER_LEFT);
|
||||
case INNER_LEFT:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(StairsBlock.SHAPE, StairsBlock.EnumShape.INNER_RIGHT);
|
||||
default:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case FRONT_BACK:
|
||||
|
||||
if (facing.getAxis() == Direction.Axis.X) {
|
||||
switch (stairShape) {
|
||||
case OUTER_LEFT:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(StairsBlock.SHAPE, StairsBlock.EnumShape.OUTER_RIGHT);
|
||||
case OUTER_RIGHT:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(StairsBlock.SHAPE, StairsBlock.EnumShape.OUTER_LEFT);
|
||||
case INNER_RIGHT:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(StairsBlock.SHAPE, StairsBlock.EnumShape.INNER_RIGHT);
|
||||
case INNER_LEFT:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(StairsBlock.SHAPE, StairsBlock.EnumShape.INNER_LEFT);
|
||||
case STRAIGHT:
|
||||
return state.withRotation(Rotation.CLOCKWISE_180);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.withMirror(state, mirrorIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getSilkTouchDrop(BlockState state) {
|
||||
return new ItemStack(this, 1, damageDropped(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(BlockState state) {
|
||||
return super.getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getPickBlock(BlockState state, RayTraceResult target, World world, BlockPos pos, PlayerEntity player) {
|
||||
return new ItemStack(this, 1, damageDropped(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSideBlockRendering(BlockState state, IBlockAccess world, BlockPos pos, Direction face) {
|
||||
if (ForgeModContainer.disableStairSlabCulling)
|
||||
return super.doesSideBlockRendering(state, world, pos, face);
|
||||
|
||||
if (state.isOpaqueCube())
|
||||
return true;
|
||||
|
||||
state = this.getActualState(state, world, pos);
|
||||
|
||||
EnumHalf half = state.getValue(StairsBlock.HALF);
|
||||
Direction side = state.getValue(FACING);
|
||||
EnumShape shape = state.getValue(StairsBlock.SHAPE);
|
||||
if (face == Direction.UP)
|
||||
return half == EnumHalf.TOP;
|
||||
if (face == Direction.DOWN)
|
||||
return half == EnumHalf.BOTTOM;
|
||||
if (shape == EnumShape.OUTER_LEFT || shape == EnumShape.OUTER_RIGHT)
|
||||
return false;
|
||||
if (face == side)
|
||||
return true;
|
||||
if (shape == EnumShape.INNER_LEFT && face.rotateY() == side)
|
||||
return true;
|
||||
if (shape == EnumShape.INNER_RIGHT && face.rotateYCCW() == side)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<AxisAlignedBB> getCollisionBoxList(BlockState state) {
|
||||
List<AxisAlignedBB> list = Lists.newArrayList();
|
||||
boolean flag = state.getValue(StairsBlock.HALF) == StairsBlock.EnumHalf.TOP;
|
||||
list.add(flag ? AABB_SLAB_TOP : AABB_SLAB_BOTTOM);
|
||||
StairsBlock.EnumShape stairShape = state.getValue(StairsBlock.SHAPE);
|
||||
|
||||
if (stairShape == StairsBlock.EnumShape.STRAIGHT || stairShape == StairsBlock.EnumShape.INNER_LEFT || stairShape == StairsBlock.EnumShape.INNER_RIGHT) {
|
||||
list.add(getCollQuarterBlock(state));
|
||||
}
|
||||
|
||||
if (stairShape != StairsBlock.EnumShape.STRAIGHT) {
|
||||
list.add(getCollEighthBlock(state));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static AxisAlignedBB getCollQuarterBlock(BlockState state) {
|
||||
boolean flag = state.getValue(StairsBlock.HALF) == StairsBlock.EnumHalf.TOP;
|
||||
|
||||
switch (state.getValue(FACING)) {
|
||||
case NORTH:
|
||||
default:
|
||||
return flag ? AABB_QTR_BOT_NORTH : AABB_QTR_TOP_NORTH;
|
||||
case SOUTH:
|
||||
return flag ? AABB_QTR_BOT_SOUTH : AABB_QTR_TOP_SOUTH;
|
||||
case WEST:
|
||||
return flag ? AABB_QTR_BOT_WEST : AABB_QTR_TOP_WEST;
|
||||
case EAST:
|
||||
return flag ? AABB_QTR_BOT_EAST : AABB_QTR_TOP_EAST;
|
||||
}
|
||||
}
|
||||
|
||||
private static AxisAlignedBB getCollEighthBlock(BlockState state) {
|
||||
Direction facing = state.getValue(FACING);
|
||||
Direction newFacing;
|
||||
|
||||
switch (state.getValue(StairsBlock.SHAPE)) {
|
||||
case OUTER_LEFT:
|
||||
default:
|
||||
newFacing = facing;
|
||||
break;
|
||||
case OUTER_RIGHT:
|
||||
newFacing = facing.rotateY();
|
||||
break;
|
||||
case INNER_RIGHT:
|
||||
newFacing = facing.getOpposite();
|
||||
break;
|
||||
case INNER_LEFT:
|
||||
newFacing = facing.rotateYCCW();
|
||||
}
|
||||
|
||||
boolean isTop = state.getValue(StairsBlock.HALF) == StairsBlock.EnumHalf.TOP;
|
||||
|
||||
switch (newFacing) {
|
||||
case NORTH:
|
||||
default:
|
||||
return isTop ? AABB_OCT_BOT_NW : AABB_OCT_TOP_NW;
|
||||
case SOUTH:
|
||||
return isTop ? AABB_OCT_BOT_SE : AABB_OCT_TOP_SE;
|
||||
case WEST:
|
||||
return isTop ? AABB_OCT_BOT_SW : AABB_OCT_TOP_SW;
|
||||
case EAST:
|
||||
return isTop ? AABB_OCT_BOT_NE : AABB_OCT_TOP_NE;
|
||||
}
|
||||
}
|
||||
|
||||
private static StairsBlock.EnumShape getStairsShape(BlockState state, IBlockAccess world, BlockPos pos) {
|
||||
Direction facing = state.getValue(FACING);
|
||||
BlockState offsetState = world.getBlockState(pos.offset(facing));
|
||||
|
||||
if (isBlockStairs(offsetState) && state.getValue(StairsBlock.HALF) == offsetState.getValue(StairsBlock.HALF)) {
|
||||
Direction offsetFacing = offsetState.getValue(FACING);
|
||||
|
||||
if (offsetFacing.getAxis() != state.getValue(FACING).getAxis() && isDifferentStairs(state, world, pos, offsetFacing.getOpposite())) {
|
||||
if (offsetFacing == facing.rotateYCCW()) {
|
||||
return StairsBlock.EnumShape.OUTER_LEFT;
|
||||
}
|
||||
|
||||
return StairsBlock.EnumShape.OUTER_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
BlockState oppositeOffsetState = world.getBlockState(pos.offset(facing.getOpposite()));
|
||||
|
||||
if (isBlockStairs(oppositeOffsetState) && state.getValue(StairsBlock.HALF) == oppositeOffsetState.getValue(StairsBlock.HALF)) {
|
||||
Direction oppositeOffsetFacing = oppositeOffsetState.getValue(FACING);
|
||||
|
||||
if (oppositeOffsetFacing.getAxis() != (state.getValue(FACING)).getAxis() && isDifferentStairs(state, world, pos, oppositeOffsetFacing)) {
|
||||
if (oppositeOffsetFacing == facing.rotateYCCW()) {
|
||||
return StairsBlock.EnumShape.INNER_LEFT;
|
||||
}
|
||||
|
||||
return StairsBlock.EnumShape.INNER_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
return StairsBlock.EnumShape.STRAIGHT;
|
||||
}
|
||||
|
||||
private static boolean isDifferentStairs(BlockState state, IBlockAccess world, BlockPos pos, Direction facing) {
|
||||
BlockState offsetState = world.getBlockState(pos.offset(facing));
|
||||
return !isBlockStairs(offsetState) || offsetState.getValue(FACING) != state.getValue(FACING) || offsetState.getValue(StairsBlock.HALF) != state.getValue(StairsBlock.HALF);
|
||||
}
|
||||
|
||||
public static boolean isBlockStairs(BlockState state) {
|
||||
return state.getBlock() instanceof StairsBlock || state.getBlock() instanceof BlockEnumStairs;
|
||||
}
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.base;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FenceGateBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockEnumWall<E extends Enum<E> & IStringSerializable> extends BlockEnum<E> {
|
||||
public static final PropertyBool UP = PropertyBool.create("up");
|
||||
public static final PropertyBool NORTH = PropertyBool.create("north");
|
||||
public static final PropertyBool EAST = PropertyBool.create("east");
|
||||
public static final PropertyBool SOUTH = PropertyBool.create("south");
|
||||
public static final PropertyBool WEST = PropertyBool.create("west");
|
||||
protected static final AxisAlignedBB[] AABB_BY_INDEX = new AxisAlignedBB[]{new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 0.75D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.3125D, 0.0D, 0.0D, 0.6875D, 0.875D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.75D, 1.0D, 1.0D),
|
||||
new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.3125D, 1.0D, 0.875D, 0.6875D), new AxisAlignedBB(0.0D, 0.0D, 0.25D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.25D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.75D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D)};
|
||||
protected static final AxisAlignedBB[] CLIP_AABB_BY_INDEX = new AxisAlignedBB[]{AABB_BY_INDEX[0].setMaxY(1.5D), AABB_BY_INDEX[1].setMaxY(1.5D), AABB_BY_INDEX[2].setMaxY(1.5D), AABB_BY_INDEX[3].setMaxY(1.5D), AABB_BY_INDEX[4].setMaxY(1.5D), AABB_BY_INDEX[5].setMaxY(1.5D), AABB_BY_INDEX[6].setMaxY(1.5D), AABB_BY_INDEX[7].setMaxY(1.5D), AABB_BY_INDEX[8].setMaxY(1.5D), AABB_BY_INDEX[9].setMaxY(1.5D), AABB_BY_INDEX[10].setMaxY(1.5D), AABB_BY_INDEX[11].setMaxY(1.5D), AABB_BY_INDEX[12].setMaxY(1.5D), AABB_BY_INDEX[13].setMaxY(1.5D), AABB_BY_INDEX[14].setMaxY(1.5D),
|
||||
AABB_BY_INDEX[15].setMaxY(1.5D)};
|
||||
|
||||
// Most of this is copied from BlockWall - if there is an issue when porting, look there first.
|
||||
public BlockEnumWall(Material material, Class<E> enumClass, String propName) {
|
||||
super(material, enumClass, propName);
|
||||
}
|
||||
|
||||
public BlockEnumWall(Material material, Class<E> enumClass) {
|
||||
this(material, enumClass, "type");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createStateContainer() {
|
||||
return new BlockStateContainer.Builder(this).add(getProperty(), UP, NORTH, EAST, SOUTH, WEST).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(BlockState state, IBlockAccess source, BlockPos pos) {
|
||||
state = state.getActualState(source, pos);
|
||||
return AABB_BY_INDEX[getAABBIndex(state)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(BlockState blockState, IBlockAccess worldIn, BlockPos pos) {
|
||||
blockState = blockState.getActualState(worldIn, pos);
|
||||
return CLIP_AABB_BY_INDEX[getAABBIndex(blockState)];
|
||||
}
|
||||
|
||||
public boolean isFullCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPassable(IBlockAccess worldIn, BlockPos pos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos) {
|
||||
BlockState worldState = worldIn.getBlockState(pos);
|
||||
Block block = worldState.getBlock();
|
||||
return block != Blocks.BARRIER && (!(block != this && !(block instanceof FenceGateBlock)) || ((worldState.getMaterial().isOpaque() && worldState.isFullCube()) && worldState.getMaterial() != Material.GOURD));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean shouldSideBeRendered(BlockState blockState, IBlockAccess blockAccess, BlockPos pos, Direction side) {
|
||||
return side != Direction.DOWN || super.shouldSideBeRendered(blockState, blockAccess, pos, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getActualState(BlockState state, IBlockAccess worldIn, BlockPos pos) {
|
||||
boolean canNorth = this.canConnectTo(worldIn, pos.north());
|
||||
boolean canEast = this.canConnectTo(worldIn, pos.east());
|
||||
boolean canSouth = this.canConnectTo(worldIn, pos.south());
|
||||
boolean canWest = this.canConnectTo(worldIn, pos.west());
|
||||
boolean flag4 = canNorth && !canEast && canSouth && !canWest || !canNorth && canEast && !canSouth && canWest;
|
||||
return state.withProperty(UP, !flag4 || !worldIn.isAirBlock(pos.up())).withProperty(NORTH, canNorth).withProperty(EAST, canEast).withProperty(SOUTH, canSouth).withProperty(WEST, canWest);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getSilkTouchDrop(BlockState state) {
|
||||
return new ItemStack(this, 1, damageDropped(state));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(BlockState state) {
|
||||
return super.getMetaFromState(state);
|
||||
}
|
||||
|
||||
private static int getAABBIndex(BlockState state) {
|
||||
int i = 0;
|
||||
|
||||
if (state.getValue(NORTH)) {
|
||||
i |= 1 << Direction.NORTH.getHorizontalIndex();
|
||||
}
|
||||
|
||||
if (state.getValue(EAST)) {
|
||||
i |= 1 << Direction.EAST.getHorizontalIndex();
|
||||
}
|
||||
|
||||
if (state.getValue(SOUTH)) {
|
||||
i |= 1 << Direction.SOUTH.getHorizontalIndex();
|
||||
}
|
||||
|
||||
if (state.getValue(WEST)) {
|
||||
i |= 1 << Direction.WEST.getHorizontalIndex();
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.base;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
||||
/**
|
||||
* Creates a block that has multiple meta-based states.
|
||||
* <p>
|
||||
* These states will be numbered 0 through {@code maxMeta}.
|
||||
*/
|
||||
public class BlockInteger extends Block {
|
||||
private final int maxMeta;
|
||||
private final PropertyInteger property;
|
||||
private final BlockStateContainer realStateContainer;
|
||||
|
||||
public BlockInteger(Material material, int maxMeta, String propName) {
|
||||
super(material);
|
||||
|
||||
this.maxMeta = maxMeta;
|
||||
this.property = PropertyInteger.create(propName, 0, maxMeta);
|
||||
this.realStateContainer = createStateContainer();
|
||||
setDefaultState(getBlockState().getBaseState());
|
||||
}
|
||||
|
||||
public BlockInteger(Material material, int maxMeta) {
|
||||
this(material, maxMeta, "meta");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer.Builder(this).build(); // Blank to avoid crashes
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BlockStateContainer getBlockState() {
|
||||
return realStateContainer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateFromMeta(int meta) {
|
||||
return getDefaultState().withProperty(property, meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(BlockState state) {
|
||||
return state.getValue(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(BlockState state) {
|
||||
return getMetaFromState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(ItemGroup tab, NonNullList<ItemStack> subBlocks) {
|
||||
for (int i = 0; i < maxMeta; i++)
|
||||
subBlocks.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
protected BlockStateContainer createStateContainer() {
|
||||
return new BlockStateContainer.Builder(this).add(property).build();
|
||||
}
|
||||
|
||||
public int getMaxMeta() {
|
||||
return maxMeta;
|
||||
}
|
||||
|
||||
public PropertyInteger getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public BlockStateContainer getRealStateContainer() {
|
||||
return realStateContainer;
|
||||
}
|
||||
}
|
|
@ -1,29 +1,28 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
package wayoftime.bloodmagic.block.enums;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum BloodRuneType implements IStringSerializable {
|
||||
BLANK,
|
||||
SPEED,
|
||||
EFFICIENCY,
|
||||
SACRIFICE,
|
||||
SELF_SACRIFICE,
|
||||
DISPLACEMENT,
|
||||
CAPACITY,
|
||||
AUGMENTED_CAPACITY,
|
||||
ORB,
|
||||
ACCELERATION,
|
||||
CHARGING;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
public enum BloodRuneType implements IStringSerializable
|
||||
{
|
||||
BLANK, SPEED, EFFICIENCY, SACRIFICE, SELF_SACRIFICE, DISPLACEMENT, CAPACITY, AUGMENTED_CAPACITY, ORB, ACCELERATION,
|
||||
CHARGING;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* getName()
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getString()
|
||||
{
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumDecorative implements IStringSerializable {
|
||||
BLOODSTONE_TILE,
|
||||
BLOODSTONE_BRICK,
|
||||
CRYSTAL_TILE,
|
||||
CRYSTAL_BRICK;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return toString();
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumDemonBlock1 implements IStringSerializable {
|
||||
BRICK1_RAW,
|
||||
BRICK1_CORROSIVE,
|
||||
BRICK1_DESTRUCTIVE,
|
||||
BRICK1_VENGEFUL,
|
||||
BRICK1_STEADFAST;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumDemonBlock2 implements IStringSerializable {
|
||||
SMALLBRICK_RAW,
|
||||
SMALLBRICK_CORROSIVE,
|
||||
SMALLBRICK_DESTRUCTIVE,
|
||||
SMALLBRICK_VENGEFUL,
|
||||
SMALLBRICK_STEADFAST,
|
||||
TILE_RAW,
|
||||
TILE_CORROSIVE,
|
||||
TILE_DESTRUCTIVE,
|
||||
TILE_VENGEFUL,
|
||||
TILE_STEADFAST,
|
||||
TILESPECIAL_RAW,
|
||||
TILESPECIAL_CORROSIVE,
|
||||
TILESPECIAL_DESTRUCTIVE,
|
||||
TILESPECIAL_VENGEFUL,
|
||||
TILESPECIAL_STEADFAST;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumDemonBlock3 implements IStringSerializable {
|
||||
STONE_RAW,
|
||||
STONE_CORROSIVE,
|
||||
STONE_DESTRUCTIVE,
|
||||
STONE_VENGEFUL,
|
||||
STONE_STEADFAST,
|
||||
POLISHED_RAW,
|
||||
POLISHED_CORROSIVE,
|
||||
POLISHED_DESTRUCTIVE,
|
||||
POLISHED_VENGEFUL,
|
||||
POLISHED_STEADFAST,
|
||||
METAL_RAW,
|
||||
METAL_CORROSIVE,
|
||||
METAL_DESTRUCTIVE,
|
||||
METAL_VENGEFUL,
|
||||
METAL_STEADFAST;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumInversionCap implements IStringSerializable {
|
||||
RAW_BOTTOM,
|
||||
RAW_TOP,
|
||||
CORROSIVE_BOTTOM,
|
||||
CORROSIVE_TOP,
|
||||
DESTRUCTIVE_BOTTOM,
|
||||
DESTRUCTIVE_TOP,
|
||||
VENGEFUL_BOTTOM,
|
||||
VENGEFUL_TOP,
|
||||
STEADFAST_BOTTOM,
|
||||
STEADFAST_TOP;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumMimic implements IStringSerializable {
|
||||
NOHITBOX,
|
||||
SOLIDOPAQUE,
|
||||
SOLIDCLEAR,
|
||||
SOLIDLIGHT,
|
||||
SENTIENT;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumPath implements IStringSerializable {
|
||||
WOOD,
|
||||
WOODTILE,
|
||||
STONE,
|
||||
STONETILE,
|
||||
WORNSTONE,
|
||||
WORNSTONETILE,
|
||||
OBSIDIAN,
|
||||
OBSIDIANTILE;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumRitualController implements IStringSerializable {
|
||||
MASTER,
|
||||
IMPERFECT,
|
||||
INVERTED,
|
||||
;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumSubWillType implements IStringSerializable {
|
||||
RAW,
|
||||
CORROSIVE,
|
||||
DESTRUCTIVE,
|
||||
VENGEFUL,
|
||||
STEADFAST;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
public EnumDemonWillType getType() {
|
||||
String name = name();
|
||||
|
||||
if (this == RAW)
|
||||
name = EnumDemonWillType.DEFAULT.name();
|
||||
|
||||
return EnumDemonWillType.valueOf(name);
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumSubWillType1 implements IStringSerializable {
|
||||
RAW,
|
||||
CORROSIVE;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumSubWillType2 implements IStringSerializable {
|
||||
DESTRUCTIVE,
|
||||
VENGEFUL;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumSubWillType3 implements IStringSerializable {
|
||||
STEADFAST;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package WayofTime.bloodmagic.block.enums;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum EnumWillWall implements IStringSerializable {
|
||||
BRICK_RAW,
|
||||
BRICK_CORROSIVE,
|
||||
BRICK_DESTRUCTIVE,
|
||||
BRICK_VENGEFUL,
|
||||
BRICK_STEADFAST,
|
||||
SMALLBRICK_RAW,
|
||||
SMALLBRICK_CORROSIVE,
|
||||
SMALLBRICK_DESTRUCTIVE,
|
||||
SMALLBRICK_VENGEFUL,
|
||||
SMALLBRICK_STEADFAST,
|
||||
LARGE_RAW,
|
||||
LARGE_CORROSIVE,
|
||||
LARGE_DESTRUCTIVE,
|
||||
LARGE_VENGEFUL,
|
||||
LARGE_STEADFAST;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package WayofTime.bloodmagic.client;
|
||||
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Provides a custom {@link ItemMeshDefinition} for automatic registration of
|
||||
* renders.
|
||||
*/
|
||||
public interface IMeshProvider {
|
||||
/**
|
||||
* Gets the custom ItemMeshDefinition to use for the item.
|
||||
*
|
||||
* @return - the custom ItemMeshDefinition to use for the item.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
ItemMeshDefinition getMeshDefinition();
|
||||
|
||||
/**
|
||||
* Gathers all possible variants for this item
|
||||
*/
|
||||
void gatherVariants(Consumer<String> variants);
|
||||
|
||||
/**
|
||||
* If a custom ResourceLocation is required, return it here.
|
||||
* <p>
|
||||
* Can be null if unneeded.
|
||||
*
|
||||
* @return - The custom ResourceLocation
|
||||
*/
|
||||
@Nullable
|
||||
default ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package WayofTime.bloodmagic.client;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface IVariantProvider {
|
||||
|
||||
default void gatherVariants(@Nonnull Int2ObjectMap<String> variants) {
|
||||
variants.put(0, this instanceof Block ? "normal" : "inventory");
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package WayofTime.bloodmagic.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class Sprite {
|
||||
|
||||
private final ResourceLocation textureLocation;
|
||||
private final int textureX;
|
||||
private final int textureY;
|
||||
private final int textureWidth;
|
||||
private final int textureHeight;
|
||||
|
||||
public Sprite(ResourceLocation textureLocation, int textureX, int textureY, int textureWidth, int textureHeight) {
|
||||
this.textureLocation = textureLocation;
|
||||
this.textureX = textureX;
|
||||
this.textureY = textureY;
|
||||
this.textureWidth = textureWidth;
|
||||
this.textureHeight = textureHeight;
|
||||
}
|
||||
|
||||
public ResourceLocation getTextureLocation() {
|
||||
return textureLocation;
|
||||
}
|
||||
|
||||
public int getTextureX() {
|
||||
return textureX;
|
||||
}
|
||||
|
||||
public int getTextureY() {
|
||||
return textureY;
|
||||
}
|
||||
|
||||
public int getTextureWidth() {
|
||||
return textureWidth;
|
||||
}
|
||||
|
||||
public int getTextureHeight() {
|
||||
return textureHeight;
|
||||
}
|
||||
|
||||
public void draw(int x, int y) {
|
||||
Minecraft.getInstance().renderEngine.bindTexture(textureLocation);
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
buffer.pos((double) x, (double) (y + getTextureHeight()), 1.0F).tex((double) ((float) (getTextureX()) * f), (double) ((float) (getTextureY() + getTextureHeight()) * f1)).endVertex();
|
||||
buffer.pos((double) (x + getTextureWidth()), (double) (y + getTextureHeight()), 1.0F).tex((double) ((float) (getTextureX() + getTextureWidth()) * f), (double) ((float) (getTextureY() + getTextureHeight()) * f1)).endVertex();
|
||||
buffer.pos((double) (x + getTextureWidth()), (double) (y), 1.0F).tex((double) ((float) (getTextureX() + getTextureWidth()) * f), (double) ((float) (getTextureY()) * f1)).endVertex();
|
||||
buffer.pos((double) x, (double) (y), 1.0F).tex((double) ((float) (getTextureX()) * f), (double) ((float) (getTextureY()) * f1)).endVertex();
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package WayofTime.bloodmagic.client.gui;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyTable;
|
||||
import WayofTime.bloodmagic.tile.container.ContainerAlchemyTable;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAlchemyTable extends ContainerScreen {
|
||||
public IInventory tileTable;
|
||||
|
||||
public GuiAlchemyTable(PlayerInventory playerInventory, IInventory tileTable) {
|
||||
super(new ContainerAlchemyTable(playerInventory, tileTable));
|
||||
this.tileTable = tileTable;
|
||||
this.xSize = 176;
|
||||
this.ySize = 205;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
this.fontRenderer.drawString(TextHelper.localize("tile.bloodmagic.alchemyTable.name"), 8, 5, 4210752);
|
||||
this.fontRenderer.drawString(TextHelper.localize("container.inventory"), 8, 111, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
ResourceLocation soulForgeGuiTextures = new ResourceLocation(BloodMagic.MODID + ":textures/gui/alchemyTable.png");
|
||||
this.mc.getTextureManager().bindTexture(soulForgeGuiTextures);
|
||||
int i = (this.width - this.xSize) / 2;
|
||||
int j = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int l = this.getCookProgressScaled(90);
|
||||
this.drawTexturedModalRect(i + 115, j + 14 + 90 - l, 176, 90 - l, 18, l);
|
||||
|
||||
for (int slotId = 0; slotId < 6; slotId++) {
|
||||
if (!((TileAlchemyTable) tileTable).isInputSlotAccessible(slotId)) {
|
||||
Slot slot = this.inventorySlots.getSlot(slotId);
|
||||
|
||||
this.drawTexturedModalRect(i + slot.xPos, j + slot.yPos, 195, 1, 16, 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getCookProgressScaled(int scale) {
|
||||
double progress = ((TileAlchemyTable) tileTable).getProgressForGui();
|
||||
return (int) (progress * scale);
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package WayofTime.bloodmagic.client.gui;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.client.hud.ConfigEntryEditHUD;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.fml.client.IModGuiFactory;
|
||||
import net.minecraftforge.fml.client.config.DummyConfigElement;
|
||||
import net.minecraftforge.fml.client.config.GuiConfig;
|
||||
import net.minecraftforge.fml.client.config.IConfigElement;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class GuiBloodMagicConfig extends GuiConfig {
|
||||
|
||||
public GuiBloodMagicConfig(Screen parentScreen) {
|
||||
super(parentScreen, getElements(), BloodMagic.MODID, false, false, BloodMagic.NAME);
|
||||
}
|
||||
|
||||
public static List<IConfigElement> getElements() {
|
||||
List<IConfigElement> elements = Lists.newArrayList();
|
||||
|
||||
elements.addAll(ConfigElement.from(ConfigHandler.class).getChildElements());
|
||||
elements.add(new ConfigElement(BloodMagic.RITUAL_MANAGER.getConfig().getCategory("rituals")));
|
||||
if (Minecraft.getInstance().world != null)
|
||||
elements.add(new DummyElementEditHUD(BloodMagic.NAME, "config." + BloodMagic.MODID + ".edit_hud"));
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
public static class DummyElementEditHUD extends DummyConfigElement.DummyCategoryElement {
|
||||
|
||||
public DummyElementEditHUD(String name, String langKey) {
|
||||
super(name, langKey, Collections.emptyList(), ConfigEntryEditHUD.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Factory implements IModGuiFactory {
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasConfigGui() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Screen createConfigGui(Screen parentScreen) {
|
||||
return new GuiBloodMagicConfig(parentScreen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package WayofTime.bloodmagic.client.gui;
|
||||
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
import WayofTime.bloodmagic.item.inventory.ContainerHolding;
|
||||
import WayofTime.bloodmagic.item.inventory.InventoryHolding;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyTable;
|
||||
import WayofTime.bloodmagic.tile.TileSoulForge;
|
||||
import WayofTime.bloodmagic.tile.TileTeleposer;
|
||||
import WayofTime.bloodmagic.tile.container.*;
|
||||
import WayofTime.bloodmagic.tile.routing.TileFilteredRoutingNode;
|
||||
import WayofTime.bloodmagic.tile.routing.TileMasterRoutingNode;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
switch (id) {
|
||||
case Constants.Gui.TELEPOSER_GUI:
|
||||
return new ContainerTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos));
|
||||
case Constants.Gui.SOUL_FORGE_GUI:
|
||||
return new ContainerSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos));
|
||||
case Constants.Gui.ROUTING_NODE_GUI:
|
||||
return new ContainerItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos));
|
||||
case Constants.Gui.MASTER_ROUTING_NODE_GUI:
|
||||
return new ContainerMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos));
|
||||
case Constants.Gui.ALCHEMY_TABLE_GUI:
|
||||
return new ContainerAlchemyTable(player.inventory, (TileAlchemyTable) world.getTileEntity(pos));
|
||||
case Constants.Gui.SIGIL_HOLDING_GUI:
|
||||
return new ContainerHolding(player, new InventoryHolding(player.getHeldItemMainhand()));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, PlayerEntity player, World world, int x, int y, int z) {
|
||||
if (world instanceof ClientWorld) {
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
switch (id) {
|
||||
case Constants.Gui.TELEPOSER_GUI:
|
||||
return new GuiTeleposer(player.inventory, (TileTeleposer) world.getTileEntity(pos));
|
||||
case Constants.Gui.SOUL_FORGE_GUI:
|
||||
return new GuiSoulForge(player.inventory, (TileSoulForge) world.getTileEntity(pos));
|
||||
case Constants.Gui.ROUTING_NODE_GUI:
|
||||
return new GuiItemRoutingNode(player.inventory, (TileFilteredRoutingNode) world.getTileEntity(pos));
|
||||
case Constants.Gui.MASTER_ROUTING_NODE_GUI:
|
||||
return new GuiMasterRoutingNode(player.inventory, (TileMasterRoutingNode) world.getTileEntity(pos));
|
||||
case Constants.Gui.ALCHEMY_TABLE_GUI:
|
||||
return new GuiAlchemyTable(player.inventory, (TileAlchemyTable) world.getTileEntity(pos));
|
||||
case Constants.Gui.SIGIL_HOLDING_GUI:
|
||||
return new GuiHolding(player, new InventoryHolding(player.getHeldItemMainhand()));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue