mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
finish the bucket of whateveritscalled
This commit is contained in:
parent
da6a4c4145
commit
48a48d277f
5 changed files with 99 additions and 7 deletions
|
@ -1,8 +1,10 @@
|
|||
package de.ellpeck.naturesaura;
|
||||
|
||||
import baubles.api.BaublesApi;
|
||||
import de.ellpeck.naturesaura.aura.Capabilities;
|
||||
import de.ellpeck.naturesaura.aura.item.IAuraRecharge;
|
||||
import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl;
|
||||
import de.ellpeck.naturesaura.compat.Compat;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -19,6 +21,7 @@ import net.minecraftforge.common.capabilities.Capability;
|
|||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -150,4 +153,31 @@ public final class Helper {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean extractAuraFromPlayer(EntityPlayer player, int amount, boolean simulate) {
|
||||
if (Compat.baubles) {
|
||||
IItemHandler baubles = BaublesApi.getBaublesHandler(player);
|
||||
for (int i = 0; i < baubles.getSlots(); i++) {
|
||||
ItemStack stack = baubles.getStackInSlot(i);
|
||||
if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) {
|
||||
amount -= stack.getCapability(Capabilities.auraContainer, null).drainAura(amount, simulate);
|
||||
if (amount <= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack stack = player.inventory.getStackInSlot(i);
|
||||
if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) {
|
||||
amount -= stack.getCapability(Capabilities.auraContainer, null).drainAura(amount, simulate);
|
||||
if (amount <= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package de.ellpeck.naturesaura.items;
|
||||
|
||||
import de.ellpeck.naturesaura.Helper;
|
||||
import de.ellpeck.naturesaura.NaturesAura;
|
||||
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -19,6 +21,8 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem {
|
|||
|
||||
public ItemColorChanger() {
|
||||
super("color_changer");
|
||||
this.setMaxStackSize(1);
|
||||
|
||||
this.addPropertyOverride(new ResourceLocation(NaturesAura.MOD_ID, "fill_mode"),
|
||||
(stack, worldIn, entityIn) -> isFillMode(stack) ? 1F : 0F);
|
||||
this.addPropertyOverride(new ResourceLocation(NaturesAura.MOD_ID, "has_color"),
|
||||
|
@ -44,22 +48,30 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem {
|
|||
EnumDyeColor stored = getStoredColor(stack);
|
||||
if (player.isSneaking()) {
|
||||
if (stored != color) {
|
||||
world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||
SoundEvents.ITEM_BUCKET_FILL, SoundCategory.PLAYERS, 0.65F, 1F);
|
||||
if (!world.isRemote)
|
||||
storeColor(stack, color);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (stored != null && stored != color) {
|
||||
if (!world.isRemote) {
|
||||
world.setBlockState(pos, state.withProperty(prop, stored));
|
||||
if (Helper.extractAuraFromPlayer(player, 10, world.isRemote)) {
|
||||
if (firstColor == null) {
|
||||
world.playSound(player, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5,
|
||||
SoundEvents.ITEM_BUCKET_EMPTY, SoundCategory.PLAYERS, 0.65F, 1F);
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
world.setBlockState(pos, state.withProperty(prop, stored));
|
||||
|
||||
if (isFillMode(stack)) {
|
||||
for (EnumFacing off : EnumFacing.VALUES) {
|
||||
changeOrCopyColor(player, stack, world, pos.offset(off), color);
|
||||
if (isFillMode(stack)) {
|
||||
for (EnumFacing off : EnumFacing.VALUES) {
|
||||
changeOrCopyColor(player, stack, world, pos.offset(off), color);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +84,7 @@ public class ItemColorChanger extends ItemImpl implements IColorProvidingItem {
|
|||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
|
||||
ItemStack stack = playerIn.getHeldItem(handIn);
|
||||
if (playerIn.isSneaking() && getStoredColor(stack) != null) {
|
||||
worldIn.playSound(playerIn, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ITEM_BUCKET_FILL_LAVA, SoundCategory.PLAYERS, 0.65F, 1F);
|
||||
if (!worldIn.isRemote) {
|
||||
setFillMode(stack, !isFillMode(stack));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ item.naturesaura.infused_iron_sword.name=Botanist's Blade
|
|||
item.naturesaura.infused_iron_hoe.name=Botanist's Hoe
|
||||
item.naturesaura.ancient_stick.name=Ancient Wood Rod
|
||||
item.naturesaura.aura_cache.name=Aura Cache
|
||||
item.naturesaura.color_changer.name=Bucket of Infinite Colors
|
||||
item.naturesaura.color_changer.name=Bucket of Infinite Color
|
||||
|
||||
container.naturesaura.tree_ritual.name=Ritual of the Forest
|
||||
container.naturesaura.altar.name=Natural Altar Infusion
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "Bucket of Infinite Color",
|
||||
"icon": "naturesaura:color_changer",
|
||||
"category": "naturesaura:items",
|
||||
"advancement": "naturesaura:infused_materials",
|
||||
"pages": [
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Using $(thing)colors$() as a means of making buildings look nice is a recognized technique among builders. However, sometimes it can be difficult to find all the colors one requires. The $(item)Bucket of Infinite Colors$(), merely using the three primary shades of the world, can create any color so long as it came in contact with them, and then tranfer it onto any dyeable block."
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "To use the bucket, simply sneak and interact with any dyeable block. To then transfer that color onto a block, simply interact with it.$(br)Sneaking and interacting with the item itself will cause it to switch into $(thing)fill mode$(), meaning that, upon dyeing a block, all surrounding blocks with the same color will also be changed.$(br)Of course, this comes with the cost of some $(thing)Aura$(), which needs to be supplied in the form of an $(l:naturesaura:items/aura_cache)Aura Cache$() in one's inventory."
|
||||
},
|
||||
{
|
||||
"type": "crafting",
|
||||
"text": "Creating the $(item)Bucket of Infinite Color$()",
|
||||
"recipe": "naturesaura:color_changer"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"type": "forge:ore_shaped",
|
||||
"pattern": [
|
||||
"RYB",
|
||||
"I I",
|
||||
" I "
|
||||
],
|
||||
"key": {
|
||||
"I": {
|
||||
"item": "naturesaura:infused_iron"
|
||||
},
|
||||
"R": {
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "dyeRed"
|
||||
},
|
||||
"Y": {
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "dyeYellow"
|
||||
},
|
||||
"B": {
|
||||
"type": "forge:ore_dict",
|
||||
"ore": "dyeBlue"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "naturesaura:color_changer"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue