finished sky tools

This commit is contained in:
Ellpeck 2020-05-13 17:57:31 +02:00
parent 6473bb81d0
commit b4cc78e19f
18 changed files with 308 additions and 26 deletions

View file

@ -21,6 +21,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;
@ -79,7 +80,7 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
new PacketParticles(this.ritualPos.getX(), this.ritualPos.getY(), this.ritualPos.getZ(), PacketParticles.Type.TR_GOLD_POWDER));
if (this.timer >= this.recipe.time) {
this.recurseTreeDestruction(this.ritualPos, this.ritualPos);
recurseTreeDestruction(this.world, this.ritualPos, this.ritualPos, true, false);
Multiblocks.TREE_RITUAL.forEach(this.ritualPos, 'G', (pos, matcher) -> {
this.world.setBlockState(pos, Blocks.AIR.getDefaultState());
return true;
@ -127,10 +128,10 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
}
private void recurseTreeDestruction(BlockPos pos, BlockPos start) {
public static void recurseTreeDestruction(World world, BlockPos pos, BlockPos start, boolean includeLeaves, boolean drop) {
if (Math.abs(pos.getX() - start.getX()) >= 6
|| Math.abs(pos.getZ() - start.getZ()) >= 6
|| Math.abs(pos.getY() - start.getY()) >= 16) {
|| Math.abs(pos.getY() - start.getY()) >= 32) {
return;
}
@ -138,12 +139,16 @@ public class TileEntityWoodStand extends TileEntityImpl implements ITickableTile
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
BlockPos offset = pos.add(x, y, z);
BlockState state = this.world.getBlockState(offset);
if (state.getBlock() instanceof LogBlock || state.getBlock() instanceof LeavesBlock) {
this.world.setBlockState(offset, Blocks.AIR.getDefaultState());
PacketHandler.sendToAllAround(this.world, this.pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR));
this.recurseTreeDestruction(offset, start);
BlockState state = world.getBlockState(offset);
if (state.getBlock() instanceof LogBlock || includeLeaves && state.getBlock() instanceof LeavesBlock) {
if (drop) {
world.destroyBlock(offset, true);
} else {
// in this case we don't want the particles, so we can't use destroyBlock
world.setBlockState(offset, Blocks.AIR.getDefaultState());
PacketHandler.sendToAllAround(world, pos, 32, new PacketParticles(offset.getX(), offset.getY(), offset.getZ(), PacketParticles.Type.TR_DISAPPEAR));
}
recurseTreeDestruction(world, offset, start, includeLeaves, drop);
}
}
}

View file

@ -47,7 +47,7 @@ public class ItemArmor extends ArmorItem implements IModItem {
for (int i = 0; i < 4; i++) {
EquipmentSlotType slot = EquipmentSlotType.values()[i + 2];
ItemStack stack = entity.getItemStackFromSlot(slot);
if (stack.isEmpty() || stack.getItem() != set[i])
if (stack.getItem() != set[i] && (slot != EquipmentSlotType.CHEST || stack.getItem() != Items.ELYTRA))
return false;
}
return true;

View file

@ -2,17 +2,21 @@ package de.ellpeck.naturesaura.items.tools;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.tiles.TileEntityWoodStand;
import de.ellpeck.naturesaura.data.ItemModelGenerator;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.reg.ICustomItemModel;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.block.BlockState;
import net.minecraft.block.LogBlock;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import javax.annotation.Nullable;
@ -33,17 +37,28 @@ public class ItemAxe extends AxeItem implements IModItem, ICustomItemModel {
@Override
public float getDestroySpeed(ItemStack stack, BlockState state) {
if (this == ModItems.INFUSED_IRON_AXE && state.getMaterial() == Material.LEAVES) {
if (state.getMaterial() == Material.LEAVES) {
return this.efficiency;
} else {
return super.getDestroySpeed(stack, state);
}
}
@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, PlayerEntity player) {
if (itemstack.getItem() == ModItems.SKY_AXE) {
if (player.world.getBlockState(pos).getBlock() instanceof LogBlock) {
TileEntityWoodStand.recurseTreeDestruction(player.world, pos, pos, false, true);
return true;
}
}
return false;
}
@Nullable
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) {
return Helper.makeRechargeProvider(stack, true);
return Helper.makeRechargeProvider(stack, true);
}
@Override

View file

@ -76,7 +76,7 @@ public class ItemHoe extends HoeItem implements IModItem, ICustomItemModel {
success |= super.onItemUse(newContext) == ActionResultType.SUCCESS;
}
}
return success ? ActionResultType.SUCCESS : ActionResultType.FAIL;
return success ? ActionResultType.SUCCESS : ActionResultType.PASS;
}
return super.onItemUse(context);
}

View file

@ -11,6 +11,8 @@ import de.ellpeck.naturesaura.reg.ICustomItemModel;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemStack;
@ -20,6 +22,7 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
@ -65,6 +68,24 @@ public class ItemPickaxe extends PickaxeItem implements IModItem, ICustomItemMod
return ActionResultType.PASS;
}
@Override
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (this == ModItems.SKY_PICKAXE) {
if (!(entityIn instanceof PlayerEntity))
return;
if (!isSelected || worldIn.isRemote)
return;
AxisAlignedBB bounds = new AxisAlignedBB(entityIn.getPosition()).grow(3.5F);
for (ItemEntity item : worldIn.getEntitiesWithinAABB(ItemEntity.class, bounds)) {
// only pick up freshly dropped items
if (item.getAge() >= 5)
continue;
item.setPickupDelay(0);
item.onCollideWithPlayer((PlayerEntity) entityIn);
}
}
}
@Nullable
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable CompoundNBT nbt) {

View file

@ -7,20 +7,17 @@ import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.reg.ICustomItemModel;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.IItemTier;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.item.ShovelItem;
import net.minecraft.item.*;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
@ -37,12 +34,12 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel
@Override
public ActionResultType onItemUse(ItemUseContext context) {
World world = context.getWorld();
PlayerEntity player = context.getPlayer();
ItemStack stack = player.getHeldItem(context.getHand());
BlockPos pos = context.getPos();
BlockState state = world.getBlockState(pos);
if (this == ModItems.INFUSED_IRON_SHOVEL) {
PlayerEntity player = context.getPlayer();
World world = context.getWorld();
BlockPos pos = context.getPos();
ItemStack stack = player.getHeldItem(context.getHand());
BlockState state = world.getBlockState(pos);
int damage = 0;
if (state.getBlock() == Blocks.DIRT) {
if (world.getBlockState(pos.up()).getMaterial() == Material.AIR) {
@ -74,6 +71,20 @@ public class ItemShovel extends ShovelItem implements IModItem, ICustomItemModel
stack.damageItem(damage, player, playerEntity -> playerEntity.sendBreakAnimation(context.getHand()));
return ActionResultType.SUCCESS;
}
} else if (this == ModItems.SKY_SHOVEL) {
if (this.getDestroySpeed(stack, state) <= 1)
return super.onItemUse(context);
Hand otherHand = context.getHand() == Hand.MAIN_HAND ? Hand.OFF_HAND : Hand.MAIN_HAND;
ItemStack other = player.getHeldItem(otherHand);
if (other.isEmpty() || !(other.getItem() instanceof BlockItem))
return super.onItemUse(context);
world.removeBlock(pos, false);
TileEntity tile = state.hasTileEntity() ? world.getTileEntity(pos) : null;
Block.spawnDrops(state, world, pos, tile, null, ItemStack.EMPTY);
ItemUseContext newContext = new ItemUseContext(player, otherHand, new BlockRayTraceResult(context.getHitVec(), context.getFace(), context.getPos(), context.isInside()));
other.onItemUse(newContext);
stack.damageItem(1, player, p -> p.sendBreakAnimation(context.getHand()));
return ActionResultType.SUCCESS;
}
return ActionResultType.PASS;
}

View file

@ -88,6 +88,15 @@
"item.naturesaura.farming_stencil": "Farming Stencil",
"item.naturesaura.bottle_two_the_rebottling": "Bottle and Cork",
"item.naturesaura.sky_ingot": "Ingot of the Skies",
"item.naturesaura.sky_pickaxe": "Skyseeker's Pickaxe",
"item.naturesaura.sky_axe": "Skyseeker's Handaxe",
"item.naturesaura.sky_shovel": "Skyseeker's Shovel",
"item.naturesaura.sky_sword": "Skyseeker's Blade",
"item.naturesaura.sky_hoe": "Skyseeker's Hoe",
"item.naturesaura.sky_helmet": "Skyseeker's Headwear",
"item.naturesaura.sky_chest": "Skyseeker's Chestplate",
"item.naturesaura.sky_pants": "Skyseeker's Leggings",
"item.naturesaura.sky_shoes": "Skyseeker's Shoes",
"item.naturesaura.calling_spirit": "Spirit of Calling",
"item.naturesaura.birth_spirit": "Spirit of Birthing",
"item.naturesaura.infused_iron_helmet": "Botanist's Headwear",

View file

@ -0,0 +1,22 @@
{
"name": "Skyseeker's Armor",
"icon": "naturesaura:sky_chest",
"category": "items",
"advancement": "naturesaura:sky_ingot",
"pages": [
{
"type": "text",
"text": "Botanists may feel like the Gods when wearing $(thing)Skyseeker's armor$(). Not only can it be repaired like its $(l:items/infused_iron_armor)infused counterpart$(), it also provides a $(thing)set bonus$(): When wearing every piece of the armor (or swapping the chestplate for an $(item)Elytra$()), the wearer's $(thing)movement speed$() will be increased. Additionally, their ability to $(thing)step up$() onto blocks will be heightened, removing their requirement to jump as often."
},
{
"type": "crafting",
"recipe": "naturesaura:sky_helmet",
"recipe2": "naturesaura:sky_chest"
},
{
"type": "crafting",
"recipe": "naturesaura:sky_pants",
"recipe2": "naturesaura:sky_shoes"
}
]
}

View file

@ -0,0 +1,36 @@
{
"name": "Skyseeker's Tools",
"icon": "naturesaura:sky_pickaxe",
"category": "items",
"advancement": "naturesaura:sky_ingot",
"pages": [
{
"type": "text",
"text": "The Gods' power is obviously immense and may not ever be understood by magical botanists. However, a very simple way to get a small taste of it are $(item)Skyseeker's tools$(). While also functioning as regular tools, they each have an additional $(thing)special ability$() that sets them apart from their $(item)diamond$() counterparts.$(br)Additionally, these tools can be $(thing)repaired$() in the same way as $(l:items/infused_iron_tools)Botanist's tools$()."
},
{
"type": "crafting",
"text": "The $(item)Skyseeker's Pickaxe$() causes any items that were mined to immediately enter the user's inventory, removing the chance of precious diamonds plummeting into lava below.",
"recipe": "naturesaura:sky_pickaxe"
},
{
"type": "crafting",
"text": "The $(item)Skyseeker's Handaxe$() is very efficient at chopping $(thing)trees$(), doing so in one fell swoop.",
"recipe": "naturesaura:sky_axe"
},
{
"type": "crafting",
"text": "The $(item)Skyseeker's Shovel$() makes creating varied paths a lot easier: When holding any $(thing)blocks$() in the off-hand, using the shovel will cause the targeted block to be $(thing)replaced$() with the held block.",
"recipe": "naturesaura:sky_shovel"
},
{
"type": "crafting",
"text": "The $(item)Skyseeker's Hoe$() helps farmers twofold: For one, it tills a $(thing)bigger area$() of ground. Additionally, destroying a piece of $(item)tall grass$() causes all other bush-like blocks in a rather big area to be destroyed with it.",
"recipe": "naturesaura:sky_hoe"
}, {
"type": "crafting",
"text": "The $(item)Skyseeker's Blade$() is an excellent way of dealing with monsters: When attacked, they will be briefly inflicted with the $(item)Levitation$() effect, causing them to rise up into the sky and plummet back down a short while later.",
"recipe": "naturesaura:sky_sword"
}
]
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"AA",
"AS",
" S"
],
"key": {
"A": {
"item": "naturesaura:sky_ingot"
},
"S": {
"item": "naturesaura:ancient_stick"
}
},
"result": {
"item": "naturesaura:sky_axe"
}
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"ASA",
"AAA",
"AAA"
],
"key": {
"A": {
"item": "naturesaura:sky_ingot"
},
"S": {
"item": "naturesaura:ancient_stick"
}
},
"result": {
"item": "naturesaura:sky_chest"
}
}

View file

@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"AAA",
"ASA"
],
"key": {
"A": {
"item": "naturesaura:sky_ingot"
},
"S": {
"item": "naturesaura:ancient_stick"
}
},
"result": {
"item": "naturesaura:sky_helmet"
}
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"AA",
" S",
" S"
],
"key": {
"A": {
"item": "naturesaura:sky_ingot"
},
"S": {
"item": "naturesaura:ancient_stick"
}
},
"result": {
"item": "naturesaura:sky_hoe"
}
}

View file

@ -0,0 +1,16 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"AAA",
"A A",
"A A"
],
"key": {
"A": {
"item": "naturesaura:sky_ingot"
}
},
"result": {
"item": "naturesaura:sky_pants"
}
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"AAA",
" S ",
" S "
],
"key": {
"A": {
"item": "naturesaura:sky_ingot"
},
"S": {
"item": "naturesaura:ancient_stick"
}
},
"result": {
"item": "naturesaura:sky_pickaxe"
}
}

View file

@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"A A",
"A A"
],
"key": {
"A": {
"item": "naturesaura:sky_ingot"
}
},
"result": {
"item": "naturesaura:sky_shoes"
}
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"A",
"S",
"S"
],
"key": {
"A": {
"item": "naturesaura:sky_ingot"
},
"S": {
"item": "naturesaura:ancient_stick"
}
},
"result": {
"item": "naturesaura:sky_shovel"
}
}

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"A",
"A",
"S"
],
"key": {
"A": {
"item": "naturesaura:sky_ingot"
},
"S": {
"item": "naturesaura:ancient_stick"
}
},
"result": {
"item": "naturesaura:sky_sword"
}
}