Topic category: Help with Minecraft modding (Java Edition)
MCreator generates the unlocked code by itself and gives an error. It's like it's going against itself. Here's the text:
import com.roman.newvanillaitems.procedures.HammerProcedureProcedure;
import com.roman.newvanillaitems.init.VanillaModBlocks;
import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMultimap;
public class EmeraldHammerItem extends Item {
public EmeraldHammerItem() {
super(new Item.Properties().durability(1245));
}
@Override
public float getDestroySpeed(ItemStack itemstack, BlockState blockstate) {
return List.of(Blocks.POINTED_DRIPSTONE, Blocks.GLASS, Blocks.TINTED_GLASS, Blocks.WHITE_STAINED_GLASS, Blocks.ORANGE_STAINED_GLASS, Blocks.MAGENTA_STAINED_GLASS, Blocks.LIGHT_BLUE_STAINED_GLASS, Blocks.YELLOW_STAINED_GLASS,
Blocks.LIME_STAINED_GLASS, Blocks.PINK_STAINED_GLASS, Blocks.GRAY_STAINED_GLASS, Blocks.LIGHT_GRAY_STAINED_GLASS, Blocks.CYAN_STAINED_GLASS, Blocks.PURPLE_STAINED_GLASS, Blocks.BLUE_STAINED_GLASS, Blocks.BROWN_STAINED_GLASS,
Blocks.GREEN_STAINED_GLASS, Blocks.RED_STAINED_GLASS, Blocks.BLACK_STAINED_GLASS, Blocks.GLASS_PANE, Blocks.WHITE_STAINED_GLASS_PANE, Blocks.ORANGE_STAINED_GLASS_PANE, Blocks.MAGENTA_STAINED_GLASS_PANE,
Blocks.LIGHT_BLUE_STAINED_GLASS_PANE, Blocks.YELLOW_STAINED_GLASS_PANE, Blocks.LIME_STAINED_GLASS_PANE, Blocks.PINK_STAINED_GLASS_PANE, Blocks.GRAY_STAINED_GLASS_PANE, Blocks.LIGHT_GRAY_STAINED_GLASS_PANE,
Blocks.CYAN_STAINED_GLASS_PANE, Blocks.PURPLE_STAINED_GLASS_PANE, Blocks.BLUE_STAINED_GLASS_PANE, Blocks.BROWN_STAINED_GLASS_PANE, Blocks.GREEN_STAINED_GLASS_PANE, Blocks.RED_STAINED_GLASS_PANE, Blocks.BLACK_STAINED_GLASS_PANE,
Blocks.BRICKS, Blocks.PACKED_MUD, Blocks.MUD_BRICKS, VanillaModBlocks.BAMBOO_DOOR.get(), VanillaModBlocks.BAMBOO_TRAPDOOR.get(), Blocks.OAK_DOOR, Blocks.SPRUCE_DOOR, Blocks.BIRCH_DOOR, Blocks.JUNGLE_DOOR, Blocks.ACACIA_DOOR,
Blocks.DARK_OAK_DOOR, Blocks.CRIMSON_DOOR, Blocks.WARPED_DOOR, Blocks.MANGROVE_DOOR, Blocks.OAK_TRAPDOOR, Blocks.SPRUCE_TRAPDOOR, Blocks.BIRCH_TRAPDOOR, Blocks.JUNGLE_TRAPDOOR, Blocks.ACACIA_TRAPDOOR, Blocks.DARK_OAK_TRAPDOOR,
Blocks.CRIMSON_TRAPDOOR, Blocks.WARPED_TRAPDOOR, Blocks.MANGROVE_TRAPDOOR, Blocks.COBBLESTONE, Blocks.MOSSY_COBBLESTONE, Blocks.MOSSY_COBBLESTONE_STAIRS, Blocks.MOSSY_COBBLESTONE_SLAB, Blocks.COBBLESTONE_STAIRS,
Blocks.INFESTED_COBBLESTONE, Blocks.COBBLESTONE_SLAB, Blocks.COBBLESTONE_WALL, Blocks.MOSSY_COBBLESTONE_WALL, Blocks.LADDER, Blocks.NETHERRACK, Blocks.POLISHED_BLACKSTONE_BRICKS, Blocks.CRACKED_POLISHED_BLACKSTONE_BRICKS,
Blocks.POLISHED_BLACKSTONE_BRICK_SLAB, Blocks.POLISHED_BLACKSTONE_BRICK_STAIRS, Blocks.POLISHED_BLACKSTONE_BRICK_WALL, Blocks.STONE_BRICK_STAIRS, Blocks.STONE_BRICKS, Blocks.STONE_BRICK_WALL, Blocks.MOSSY_STONE_BRICKS,
Blocks.MOSSY_STONE_BRICK_STAIRS, Blocks.MOSSY_STONE_BRICK_SLAB, Blocks.MOSSY_STONE_BRICK_WALL, Blocks.CRACKED_STONE_BRICKS, Blocks.CHISELED_STONE_BRICKS, Blocks.END_STONE_BRICKS, Blocks.END_STONE_BRICK_STAIRS,
Blocks.END_STONE_BRICK_SLAB, Blocks.END_STONE_BRICK_WALL, Blocks.INFESTED_STONE_BRICKS, Blocks.INFESTED_MOSSY_STONE_BRICKS, Blocks.INFESTED_CRACKED_STONE_BRICKS, Blocks.INFESTED_CHISELED_STONE_BRICKS, Blocks.STONE_BRICK_SLAB,
Blocks.DEEPSLATE, Blocks.COBBLED_DEEPSLATE, Blocks.COBBLED_DEEPSLATE_STAIRS, Blocks.COBBLED_DEEPSLATE_SLAB, Blocks.COBBLED_DEEPSLATE_WALL, Blocks.POLISHED_DEEPSLATE, Blocks.POLISHED_DEEPSLATE_STAIRS, Blocks.POLISHED_DEEPSLATE_SLAB,
Blocks.POLISHED_DEEPSLATE_WALL, Blocks.DEEPSLATE_TILES, Blocks.DEEPSLATE_TILE_STAIRS, Blocks.DEEPSLATE_TILE_SLAB, Blocks.DEEPSLATE_TILE_WALL, Blocks.DEEPSLATE_BRICKS, Blocks.DEEPSLATE_BRICK_STAIRS, Blocks.DEEPSLATE_BRICK_SLAB,
Blocks.DEEPSLATE_BRICK_WALL, Blocks.CHISELED_DEEPSLATE, Blocks.CRACKED_DEEPSLATE_BRICKS, Blocks.CRACKED_DEEPSLATE_TILES, Blocks.END_STONE, VanillaModBlocks.ICE_BRICKS.get(), Blocks.ICE, Blocks.PACKED_ICE, Blocks.FROSTED_ICE)
.contains(blockstate.getBlock()) ? 10.5 : 1f;
}
@Override
public boolean mineBlock(ItemStack itemstack, Level world, BlockState blockstate, BlockPos pos, LivingEntity entity) {
itemstack.hurtAndBreak(1, entity, i -> i.broadcastBreakEvent(EquipmentSlot.MAINHAND));
HammerProcedureProcedure.execute(world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
@Override
public boolean hurtEnemy(ItemStack itemstack, LivingEntity entity, LivingEntity sourceentity) {
itemstack.hurtAndBreak(2, entity, i -> i.broadcastBreakEvent(EquipmentSlot.MAINHAND));
return true;
}
@Override
public int getEnchantmentValue() {
return 15;
}
@Override
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot equipmentSlot) {
if (equipmentSlot == EquipmentSlot.MAINHAND) {
ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
builder.putAll(super.getDefaultAttributeModifiers(equipmentSlot));
builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Tool modifier", 6.5f, AttributeModifier.Operation.ADDITION));
builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Tool modifier", -3.4, AttributeModifier.Operation.ADDITION));
return builder.build();
}
return super.getDefaultAttributeModifiers(equipmentSlot);
}
}
Executing Gradle task: build
Build info: MCreator 2023.3.35319, forge-1.20.1, 64-bit, 16261 MB, Windows 11, JVM 17.0.7, JAVA_HOME: C:\Users\Roman\Desktop\New_Vanilla_Items\MCreator20233\jdk, started on: 2023-09-01-19:51:44
> Configure project :
The code of this workspace uses official obfuscation mappings provided by Mojang. These mappings fall under their associated license you should be fully aware of.
(c) 2020 Microsoft Corporation. These mappings are provided "as-is" and you bear the risk of using them. You may copy and use the mappings for development purposes,
but you may not redistribute the mappings complete and unmodified. Microsoft makes no warranties, express or implied, with respect to the mappings provided here.
Use and modification of this document or the source code (in any form) of Minecraft: Java Edition is governed by the Minecraft End User License Agreement available
at https://account.mojang.com/documents/minecraft_eula.
> Task :compileJava FAILED
C:\Users\Roman\MCreatorWorkspaces\new-vanilla-itemss\src\main\java\com\roman\newvanillaitems\item\EmeraldHammerItem.java:46: error: incompatible types: possible lossy conversion from double to float .contains(blockstate.getBlock()) ? 10.5 : 1f;
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
1 actionable task: 1 executed
BUILD FAILED
Task completed in 6 seconds
Please open bug report at https://github.com/MCreator/MCreator/issues and include workspace