Search in sources :

Example 1 with ShovelItem

use of net.minecraft.item.ShovelItem in project endergetic by team-abnormals.

the class EntityEvents method rightClickBlock.

@SubscribeEvent
public static void rightClickBlock(RightClickBlock event) {
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    BlockState state = world.getBlockState(pos);
    PlayerEntity player = event.getPlayer();
    ItemStack stack = event.getItemStack();
    Item item = stack.getItem();
    Hand hand = event.getHand();
    if (event.getFace() != Direction.DOWN && item instanceof ShovelItem && !player.isSpectator()) {
        BlockState newState = state.is(EEBlocks.POISMOSS.get()) ? EEBlocks.POISMOSS_PATH.get().defaultBlockState() : state.is(EEBlocks.EUMUS_POISMOSS.get()) ? EEBlocks.EUMUS_POISMOSS_PATH.get().defaultBlockState() : null;
        if (newState != null && world.isEmptyBlock(pos.above())) {
            world.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
            world.setBlock(pos, newState, 11);
            event.getItemStack().hurtAndBreak(1, player, (damage) -> damage.broadcastBreakEvent(hand));
            event.setCancellationResult(ActionResultType.sidedSuccess(world.isClientSide()));
            event.setCanceled(true);
        }
    }
}
Also used : Item(net.minecraft.item.Item) BolloomBalloonItem(com.minecraftabnormals.endergetic.common.items.BolloomBalloonItem) ShovelItem(net.minecraft.item.ShovelItem) BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) ShovelItem(net.minecraft.item.ShovelItem) ServerWorld(net.minecraft.world.server.ServerWorld) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) Hand(net.minecraft.util.Hand) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ClientPlayerEntity(net.minecraft.client.entity.player.ClientPlayerEntity) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with ShovelItem

use of net.minecraft.item.ShovelItem in project Moonfix by Kingdom-of-Moon.

the class ClientPlayerInteractionManagerMixin method interactBlock.

// makes log strips and grass path actions be ignored unless if player is pressing sneak
@Inject(at = @At("HEAD"), method = "interactBlock", cancellable = true)
private void interactBlock(ClientPlayerEntity player, ClientWorld world, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable<ActionResult> cir) {
    if (player.isSneaking())
        return;
    Item item = player.getStackInHand(hand).getItem();
    BlockState block = world.getBlockState(hitResult.getBlockPos());
    boolean path = (boolean) ConfigManager.Config.DIRT_PATH.value && item instanceof ShovelItem && ShovelItemAccessor.getPathStates().containsKey(block.getBlock());
    boolean stripped = (boolean) ConfigManager.Config.STRIPPED_LOGS.value && item instanceof AxeItem && AxeItemAccessor.getStrippedBlocks().containsKey(block.getBlock());
    if (path || stripped) {
        cir.setReturnValue(ActionResult.PASS);
        cir.cancel();
    }
}
Also used : Item(net.minecraft.item.Item) ShovelItem(net.minecraft.item.ShovelItem) AxeItem(net.minecraft.item.AxeItem) BlockState(net.minecraft.block.BlockState) ShovelItem(net.minecraft.item.ShovelItem) AxeItem(net.minecraft.item.AxeItem) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 3 with ShovelItem

use of net.minecraft.item.ShovelItem in project Terracraft by SimplyCmd.

the class ItemRegistry method register.

public static void register() {
    magic_mirror = new SimpleItem(ID("magic_mirror"), new MirrorItem(new FabricItemSettings().group(ItemGroup.MISC).maxCount(1))).defaultItemModel();
    grenade = new SimpleItem(ID("grenade"), new GrenadeThrowableItem(new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
    flaming_arrow = new SimpleItem(ID("flaming_arrow"), new FlamingArrowItem()).defaultItemModel();
    soul_fire_arrow = new SimpleItem(ID("soul_fire_arrow"), new FlamingArrowItem()).defaultItemModel();
    slap_hand = new SimpleItem(ID("slap_hand"), new SlapHandItem()).defaultItemModel();
    wand_of_sparking = new SimpleItem(ID("wand_of_sparking"), new WandOfSparkingItem(new FabricItemSettings().group(ItemGroup.COMBAT).maxCount(1).maxDamage(250))).defaultItemModel();
    heart = new SimpleItem(ID("heart"), new HeartItem()).defaultItemModel();
    umbrella = new SimpleItem(ID("umbrella"), new UmbrellaItem());
    sickle = new SimpleItem(ID("sickle"), new SickleItem()).defaultItemModel();
    daybloom = new SimpleItem(ID("daybloom"), new Item(new FabricItemSettings().group(ItemGroup.MATERIALS)));
    daybloom_seeds = new SimpleItem(ID("daybloom_seeds"), new AliasedBlockItem(BlockRegistry.daybloom.getBlock(), new FabricItemSettings().group(ItemGroup.MISC)));
    blue_berries = new SimpleItem(ID("blue_berries"), new AliasedBlockItem(BlockRegistry.blue_berry_bush.getBlock(), new FabricItemSettings().group(ItemGroup.MISC)));
    platinum_coin = new SimpleItem(ID("platinum_coin"), new CoinItem(new Value(1, 0, 0, 0), null)).defaultItemModel();
    gold_coin = new SimpleItem(ID("gold_coin"), new CoinItem(new Value(0, 1, 0, 0), ItemRegistry.platinum_coin.getItem())).defaultItemModel();
    silver_coin = new SimpleItem(ID("silver_coin"), new CoinItem(new Value(0, 0, 1, 0), ItemRegistry.gold_coin.getItem())).defaultItemModel();
    copper_coin = new SimpleItem(ID("copper_coin"), new CoinItem(new Value(0, 0, 0, 1), ItemRegistry.silver_coin.getItem())).defaultItemModel();
    cactus_helmet = new SimpleItem(ID("cactus_helmet"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.HEAD, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
    cactus_chestplate = new SimpleItem(ID("cactus_chestplate"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.CHEST, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
    cactus_leggings = new SimpleItem(ID("cactus_leggings"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.LEGS, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
    cactus_boots = new SimpleItem(ID("cactus_boots"), new ArmorItem(ArmorMaterials.CACTUS, EquipmentSlot.FEET, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
    cactus_sword = new SimpleItem(ID("cactus_sword"), new SwordItem(ToolMaterials.CACTUS, 3, -2.4F, new FabricItemSettings().group(ItemGroup.COMBAT))).defaultItemModel();
    cactus_shovel = new SimpleItem(ID("cactus_shovel"), new ShovelItem(ToolMaterials.CACTUS, 1.5F, -3.0F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
    cactus_pickaxe = new SimpleItem(ID("cactus_pickaxe"), new PickaxeItem(ToolMaterials.CACTUS, 1, -2.8F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
    cactus_axe = new SimpleItem(ID("cactus_axe"), new AxeItem(ToolMaterials.CACTUS, 6.0F, -3.2F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
    cactus_hoe = new SimpleItem(ID("cactus_hoe"), new HoeItem(ToolMaterials.CACTUS, 0, -3.0F, new FabricItemSettings().group(ItemGroup.TOOLS))).defaultItemModel();
}
Also used : FabricItemSettings(net.fabricmc.fabric.api.item.v1.FabricItemSettings) AliasedBlockItem(net.minecraft.item.AliasedBlockItem) SwordItem(net.minecraft.item.SwordItem) Item(net.minecraft.item.Item) AliasedBlockItem(net.minecraft.item.AliasedBlockItem) ShovelItem(net.minecraft.item.ShovelItem) SwordItem(net.minecraft.item.SwordItem) SimpleItem(com.simplycmd.featherlib.registry.SimpleItem) ArmorItem(net.minecraft.item.ArmorItem) ArmorItem(net.minecraft.item.ArmorItem) ShovelItem(net.minecraft.item.ShovelItem) SimpleItem(com.simplycmd.featherlib.registry.SimpleItem)

Aggregations

Item (net.minecraft.item.Item)3 ShovelItem (net.minecraft.item.ShovelItem)3 BlockState (net.minecraft.block.BlockState)2 BolloomBalloonItem (com.minecraftabnormals.endergetic.common.items.BolloomBalloonItem)1 SimpleItem (com.simplycmd.featherlib.registry.SimpleItem)1 FabricItemSettings (net.fabricmc.fabric.api.item.v1.FabricItemSettings)1 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 AliasedBlockItem (net.minecraft.item.AliasedBlockItem)1 ArmorItem (net.minecraft.item.ArmorItem)1 AxeItem (net.minecraft.item.AxeItem)1 ItemStack (net.minecraft.item.ItemStack)1 SwordItem (net.minecraft.item.SwordItem)1 Hand (net.minecraft.util.Hand)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 ServerWorld (net.minecraft.world.server.ServerWorld)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1