Add Portable Stonecutter
This commit is contained in:
parent
728e3282f6
commit
91756ff5fc
4 changed files with 66 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ package com.oitsjustjose.headdons;
|
|||
|
||||
import cofh.thermal.lib.common.ThermalAugmentRules;
|
||||
import com.oitsjustjose.headdons.common.Item.CustomIntegralComponent;
|
||||
import com.oitsjustjose.headdons.common.Item.PortableStoneCutterItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
|
@ -25,5 +26,7 @@ public class Registry {
|
|||
ThermalAugmentRules.flagUniqueAugment(item);
|
||||
return item;
|
||||
});
|
||||
|
||||
ITEM_REGISTRY.register("portable_stonecutter", PortableStoneCutterItem::new);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
package com.oitsjustjose.headdons.common.Item;
|
||||
|
||||
import com.oitsjustjose.headdons.Constants;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResultHolder;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.SimpleMenuProvider;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.inventory.StonecutterMenu;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class PortableStoneCutterItem extends Item {
|
||||
private static final Component CONTAINER_TITLE = new TranslatableComponent("container." + Constants.MODID + ".portable_stonecutter");
|
||||
|
||||
public PortableStoneCutterItem() {
|
||||
super(new Item.Properties().stacksTo(1).tab(CreativeModeTab.TAB_DECORATIONS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level level, @NotNull Player player, @NotNull InteractionHand hand) {
|
||||
if (!level.isClientSide()) {
|
||||
player.openMenu(getMenuProvider(level, player.getOnPos()));
|
||||
player.awardStat(Stats.INTERACT_WITH_STONECUTTER);
|
||||
player.swing(hand);
|
||||
}
|
||||
return InteractionResultHolder.success(player.getItemInHand(hand));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MenuProvider getMenuProvider(Level level, BlockPos pos) {
|
||||
return new SimpleMenuProvider((p_57074_, inv, player) -> {
|
||||
return new PortableStonecutterMenu(p_57074_, inv, ContainerLevelAccess.create(level, pos));
|
||||
}, CONTAINER_TITLE);
|
||||
}
|
||||
|
||||
private static class PortableStonecutterMenu extends StonecutterMenu {
|
||||
public PortableStonecutterMenu(int unk, Inventory inv, ContainerLevelAccess acc) {
|
||||
super(unk, inv, acc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(@NotNull Player ignored) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.oitsjustjose.headdons.common.events;
|
|||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.TieredItem;
|
||||
import net.minecraft.world.level.storage.loot.LootContext;
|
||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
|
@ -19,6 +20,7 @@ public class DaveBlockBreakEvent {
|
|||
if (event.getPlayer().isCreative()) return;
|
||||
if (!Objects.requireNonNull(block.getRegistryName()).getNamespace().equals("davebuildingmod")) return;
|
||||
if (!(event.getWorld() instanceof ServerLevel serverLevel)) return;
|
||||
if (stack.getItem() instanceof TieredItem) return;
|
||||
|
||||
// Only force the drop if the block drop is broken in the first place
|
||||
if (!block.canHarvestBlock(event.getState(), serverLevel, event.getPos(), event.getPlayer())) {
|
||||
|
|
|
|||
|
|
@ -4,5 +4,7 @@
|
|||
"item.headdons.ostrum_integral_components": "Ostrum Integral Components",
|
||||
"item.headdons.calorite_integral_components.desc": "§6Improves base attributes. Other augments may be more effective as a result.§r",
|
||||
"item.headdons.desh_integral_components.desc": "§6Improves base attributes. Other augments may be more effective as a result.§r",
|
||||
"item.headdons.ostrum_integral_components.desc": "§6Improves base attributes. Other augments may be more effective as a result.§r"
|
||||
"item.headdons.ostrum_integral_components.desc": "§6Improves base attributes. Other augments may be more effective as a result.§r",
|
||||
"item.headdons.portable_stonecutter": "Portable Stonecutter",
|
||||
"container.headdons.portable_stonecutter": "Portable Stonecutter"
|
||||
}
|
||||
Loading…
Reference in a new issue