Life Essence
This commit is contained in:
parent
cb3412bc84
commit
09ff96fe03
|
@ -6,10 +6,13 @@ import WayofTime.alchemicalWizardry.registry.ModEntities;
|
|||
import WayofTime.alchemicalWizardry.registry.ModItems;
|
||||
import WayofTime.alchemicalWizardry.registry.ModPotions;
|
||||
import WayofTime.alchemicalWizardry.proxy.CommonProxy;
|
||||
import WayofTime.alchemicalWizardry.util.handler.EventHandler;
|
||||
import WayofTime.alchemicalWizardry.util.helper.InventoryRenderHelper;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.SidedProxy;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
|
@ -31,7 +34,7 @@ public class AlchemicalWizardry {
|
|||
@SidedProxy(serverSide = "WayofTime.alchemicalWizardry.proxy.CommonProxy", clientSide = "WayofTime.alchemicalWizardry.proxy.ClientProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@Mod.Instance
|
||||
@Mod.Instance(MODID)
|
||||
public static AlchemicalWizardry instance;
|
||||
|
||||
public static CreativeTabs tabBloodMagic = new CreativeTabs(MODID + ".creativeTab") {
|
||||
|
@ -50,12 +53,16 @@ public class AlchemicalWizardry {
|
|||
configDir = new File(event.getModConfigurationDirectory(), "BloodMagic");
|
||||
ConfigHandler.init(new File(getConfigDir(), "BloodMagic.cfg"));
|
||||
|
||||
proxy.preInit();
|
||||
EventHandler eventHandler = new EventHandler();
|
||||
FMLCommonHandler.instance().bus().register(eventHandler);
|
||||
MinecraftForge.EVENT_BUS.register(eventHandler);
|
||||
|
||||
ModItems.init();
|
||||
ModBlocks.init();
|
||||
ModItems.init();
|
||||
ModPotions.init();
|
||||
ModEntities.init();
|
||||
|
||||
proxy.preInit();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
|
|
|
@ -7,20 +7,25 @@ import lombok.Getter;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
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.*;
|
||||
|
||||
public class BlockLifeEssence extends BlockFluidClassic {
|
||||
|
||||
@Getter(AccessLevel.PUBLIC)
|
||||
private static Fluid lifeEssence = new FluidLifeEssence("lifeEssence");
|
||||
@Getter
|
||||
private static Fluid lifeEssence = new FluidLifeEssence();
|
||||
|
||||
public BlockLifeEssence() {
|
||||
super(lifeEssence, Material.water);
|
||||
|
||||
setUnlocalizedName(AlchemicalWizardry.MODID + ".fluid.lifeEssence");
|
||||
|
||||
lifeEssence.setBlock(this);
|
||||
AlchemicalWizardryAPI.setLifeEssence(lifeEssence);
|
||||
}
|
||||
|
@ -37,8 +42,8 @@ public class BlockLifeEssence extends BlockFluidClassic {
|
|||
|
||||
public static class FluidLifeEssence extends Fluid {
|
||||
|
||||
public FluidLifeEssence(String fluidName) {
|
||||
super(fluidName, new ResourceLocation(AlchemicalWizardry.DOMAIN + "lifeEssenceStill"), new ResourceLocation(AlchemicalWizardry.DOMAIN + "lifeEssenceFlowing"));
|
||||
public FluidLifeEssence() {
|
||||
super("lifeEssence", new ResourceLocation(AlchemicalWizardry.DOMAIN + "blocks/lifeEssenceStill"), new ResourceLocation(AlchemicalWizardry.DOMAIN + "blocks/lifeEssenceFlowing"));
|
||||
|
||||
setDensity(2000);
|
||||
setViscosity(2000);
|
||||
|
@ -46,12 +51,12 @@ public class BlockLifeEssence extends BlockFluidClassic {
|
|||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0xEEEEEE;
|
||||
return Color.WHITE.getRGB();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedName(FluidStack fluidStack) {
|
||||
return "Life Essence";
|
||||
return StatCollector.translateToLocal("tile.AlchemicalWizardry.fluid.lifeEssence.name");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package WayofTime.alchemicalWizardry.item;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.registry.ModBlocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemBucket;
|
||||
|
||||
public class ItemBucketEssence extends ItemBucket {
|
||||
|
||||
public ItemBucketEssence() {
|
||||
super(ModBlocks.lifeEssence);
|
||||
|
||||
setUnlocalizedName(AlchemicalWizardry.MODID + ".bucket.lifeEssence");
|
||||
setContainerItem(Items.bucket);
|
||||
setCreativeTab(AlchemicalWizardry.tabBloodMagic);
|
||||
}
|
||||
}
|
|
@ -7,7 +7,8 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
@Override
|
||||
public void preInit() {
|
||||
|
||||
ModBlocks.initRenders();
|
||||
ModItems.initRenders();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,7 +18,6 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
@Override
|
||||
public void postInit() {
|
||||
ModItems.initRenders();
|
||||
ModBlocks.initRenders();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ public class ModBlocks {
|
|||
|
||||
public static void initRenders() {
|
||||
InventoryRenderHelper renderHelper = AlchemicalWizardry.instance.getRenderHelper();
|
||||
|
||||
renderHelper.fluidRender(lifeEssence);
|
||||
}
|
||||
|
||||
private static Block registerBlock(Block block, Class<? extends ItemBlock> itemBlock, String name) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import WayofTime.alchemicalWizardry.api.AlchemicalWizardryAPI;
|
|||
import WayofTime.alchemicalWizardry.api.orb.BloodOrb;
|
||||
import WayofTime.alchemicalWizardry.api.registry.OrbRegistry;
|
||||
import WayofTime.alchemicalWizardry.item.ItemBloodOrb;
|
||||
import WayofTime.alchemicalWizardry.item.ItemBucketEssence;
|
||||
import WayofTime.alchemicalWizardry.item.sigil.ItemSigilDivination;
|
||||
import WayofTime.alchemicalWizardry.util.helper.InventoryRenderHelper;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -21,6 +22,8 @@ public class ModItems {
|
|||
public static BloodOrb orbArchmage;
|
||||
public static BloodOrb orbTranscendent;
|
||||
|
||||
public static Item bucketEssence;
|
||||
|
||||
public static Item sigilDivination;
|
||||
|
||||
public static void init() {
|
||||
|
@ -39,6 +42,8 @@ public class ModItems {
|
|||
orbTranscendent = new BloodOrb("transcendent", 6, 30000000);
|
||||
OrbRegistry.registerOrb(orbTranscendent);
|
||||
|
||||
bucketEssence = registerItem(new ItemBucketEssence());
|
||||
|
||||
sigilDivination = registerItem(new ItemSigilDivination());
|
||||
}
|
||||
|
||||
|
@ -52,6 +57,10 @@ public class ModItems {
|
|||
OrbRegistry.registerOrbTexture(orbMaster, AlchemicalWizardry.DOMAIN + "ItemBloodOrbMaster");
|
||||
OrbRegistry.registerOrbTexture(orbArchmage, AlchemicalWizardry.DOMAIN + "ItemBloodOrbArchmage");
|
||||
OrbRegistry.registerOrbTexture(orbTranscendent, AlchemicalWizardry.DOMAIN + "ItemBloodOrbTranscendent");
|
||||
|
||||
renderHelper.itemRender(bucketEssence);
|
||||
|
||||
renderHelper.itemRender(sigilDivination);
|
||||
}
|
||||
|
||||
private static Item registerItem(Item item, String name) {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package WayofTime.alchemicalWizardry.util.handler;
|
||||
|
||||
import WayofTime.alchemicalWizardry.registry.ModBlocks;
|
||||
import WayofTime.alchemicalWizardry.registry.ModItems;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBucketFill(FillBucketEvent event) {
|
||||
if (event.current.getItem() != Items.bucket)
|
||||
return;
|
||||
|
||||
ItemStack result = null;
|
||||
|
||||
Block block = event.world.getBlockState(event.target.getBlockPos()).getBlock();
|
||||
|
||||
if (block != null && (block.equals(ModBlocks.lifeEssence)) && block.getMetaFromState(event.world.getBlockState(event.target.getBlockPos())) == 0) {
|
||||
event.world.setBlockToAir(event.target.getBlockPos());
|
||||
result = new ItemStack(ModItems.bucketEssence);
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
return;
|
||||
|
||||
event.result = result;
|
||||
event.setResult(Event.Result.ALLOW);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,17 @@
|
|||
package WayofTime.alchemicalWizardry.util.helper;
|
||||
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraft.client.resources.model.ModelBakery;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
/**
|
||||
* @author <a href="https://github.com/TehNut">TehNut</a>
|
||||
|
@ -85,6 +89,30 @@ public class InventoryRenderHelper {
|
|||
});
|
||||
}
|
||||
|
||||
public void itemRenderToggle(Item item, String name) {
|
||||
itemRender(item, 0, name + "_deactivated");
|
||||
itemRender(item, 1, name + "_activated");
|
||||
}
|
||||
|
||||
public void fluidRender(Block block) {
|
||||
|
||||
final Block toRender = block;
|
||||
|
||||
ModelBakery.addVariantName(InventoryRenderHelper.getItemFromBlock(block));
|
||||
ModelLoader.setCustomMeshDefinition(InventoryRenderHelper.getItemFromBlock(block), new ItemMeshDefinition() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
return new ModelResourceLocation(AlchemicalWizardry.DOMAIN + toRender.getClass().getSimpleName(), "fluid");
|
||||
}
|
||||
});
|
||||
ModelLoader.setCustomStateMapper(block, new StateMapperBase() {
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
return new ModelResourceLocation(domain + toRender.getClass().getSimpleName(), "fluid");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param block - Block to get Item of
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"forge_marker": 1,
|
||||
"variants": {
|
||||
"fluid": {
|
||||
"model": "forge:fluid",
|
||||
"custom": { "fluid": "lifeessence" }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,8 @@ item.AlchemicalWizardry.bindable.activationCrystal.creative.name=Creative Activa
|
|||
item.AlchemicalWizardry.dagger.name=Sacrificial Dagger
|
||||
item.AlchemicalWizardry.dagger.creative.name=Creative Sacrificial Dagger
|
||||
|
||||
item.AlchemicalWizardry.bucket.lifeEssence.name=Bucket of Life
|
||||
|
||||
item.AlchemicalWizardry.scribe.water.name=Water Scribing Tools
|
||||
item.AlchemicalWizardry.scribe.fire.name=Fire Scribing Tools
|
||||
item.AlchemicalWizardry.scribe.earth.name=Earth Scribing Tools
|
||||
|
@ -54,6 +56,9 @@ item.AlchemicalWizardry.sigil.bloodLight.name=Sigil of the Blood Lamp
|
|||
item.AlchemicalWizardry.sigil.compression.name=Sigil of Compression
|
||||
item.AlchemicalWizardry.sigil.divination.name=Divination Sigil
|
||||
|
||||
# Blocks
|
||||
tile.AlchemicalWizardry.fluid.lifeEssence.name=Life Essence
|
||||
|
||||
# Tooltips
|
||||
tooltip.AlchemicalWizardry.orb.desc=Stores raw Life Essence
|
||||
tooltip.AlchemicalWizardry.orb.owner=Added by: %s
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent":"alchemicalwizardry:item/ItemModelBase",
|
||||
"textures": {
|
||||
"layer0":"alchemicalwizardry:items/LifeBucket"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue