diff --git a/pom.xml b/pom.xml index d236c05..a4e9bd1 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ UTF-8 5.7.1 - 2.13.1 + 2.13.2 3.18.1 @@ -42,7 +42,7 @@ org.projectlombok lombok - 1.18.22 + 1.18.24 provided @@ -81,7 +81,7 @@ com.fasterxml.jackson.core jackson-databind - ${jackson.version} + 2.13.2.2 com.fasterxml.jackson.dataformat @@ -103,13 +103,19 @@ com.google.guava guava - 29.0-jre + 30.0-android + + + org.checkerframework + checker-compat-qual + + - com.nukkitx - math - 1.1.1 + org.cloudburstmc.math + immutable + 2.0 @@ -138,9 +144,15 @@ org.projectlombok lombok - 1.18.22 + 1.18.24 + + -Xmaxerrs + 1000 + -Xmaxwarns + 2000 + diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index bfff087..d61f6b5 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -10,7 +10,7 @@ requires static javax.inject; requires java.desktop; requires static lombok; - requires com.nukkitx.math; + requires org.cloudburstmc.math.immutable; requires org.slf4j; exports org.cloudburstmc.api; @@ -21,6 +21,7 @@ exports org.cloudburstmc.api.blockentity; exports org.cloudburstmc.api.command; exports org.cloudburstmc.api.crafting; + exports org.cloudburstmc.api.data; exports org.cloudburstmc.api.enchantment; exports org.cloudburstmc.api.enchantment.behavior; exports org.cloudburstmc.api.entity; @@ -57,5 +58,7 @@ exports org.cloudburstmc.api.potion; exports org.cloudburstmc.api.registry; exports org.cloudburstmc.api.util; + exports org.cloudburstmc.api.util.behavior; exports org.cloudburstmc.api.util.data; -} \ No newline at end of file + exports org.cloudburstmc.api.inventory.screen; +} diff --git a/src/main/java/org/cloudburstmc/api/block/Block.java b/src/main/java/org/cloudburstmc/api/block/Block.java index 3e6c5d5..dd9894f 100644 --- a/src/main/java/org/cloudburstmc/api/block/Block.java +++ b/src/main/java/org/cloudburstmc/api/block/Block.java @@ -1,10 +1,11 @@ package org.cloudburstmc.api.block; -import com.nukkitx.math.vector.Vector3i; -import com.nukkitx.math.vector.Vector4i; import org.cloudburstmc.api.level.Level; import org.cloudburstmc.api.level.chunk.Chunk; import org.cloudburstmc.api.util.Direction; +import org.cloudburstmc.api.util.behavior.BehaviorCollection; +import org.cloudburstmc.math.vector.Vector3i; +import org.cloudburstmc.math.vector.Vector4i; public interface Block extends BlockSnapshot { @@ -18,6 +19,10 @@ public interface Block extends BlockSnapshot { Vector3i getPosition(); + BehaviorCollection getBehaviors(); + + int getBrightness(); + default int getX() { return getPosition().getX(); } @@ -34,102 +39,10 @@ default Block up() { return getSide(Direction.UP, 1); } - default Block up(int step) { - return getSide(Direction.UP, step); - } - - default Block down() { - return getSide(Direction.DOWN, 1); - } - - default Block down(int step) { - return getSide(Direction.DOWN, step); - } - - default Block north() { - return getSide(Direction.NORTH, 1); - } - - default Block north(int step) { - return getSide(Direction.NORTH, step); - } - - default Block east() { - return getSide(Direction.EAST, 1); - } - - default Block east(int step) { - return getSide(Direction.EAST, step); - } - - default Block south() { - return getSide(Direction.SOUTH, 1); - } - - default Block south(int step) { - return getSide(Direction.SOUTH, step); - } - - default Block west() { - return getSide(Direction.WEST, 1); - } - - default Block west(int step) { - return getSide(Direction.WEST, step); - } - default Block getSide(Direction face) { return getSide(face, 1); } - default BlockState upState() { - return getSideState(Direction.UP, 1); - } - - default BlockState upState(int step) { - return getSideState(Direction.UP, step); - } - - default BlockState downState() { - return getSideState(Direction.DOWN, 1); - } - - default BlockState downState(int step) { - return getSideState(Direction.DOWN, step); - } - - default BlockState northState() { - return getSideState(Direction.NORTH, 1); - } - - default BlockState northState(int step) { - return getSideState(Direction.NORTH, step); - } - - default BlockState eastState() { - return getSideState(Direction.EAST, 1); - } - - default BlockState eastState(int step) { - return getSideState(Direction.EAST, step); - } - - default BlockState southState() { - return getSideState(Direction.SOUTH, 1); - } - - default BlockState southState(int step) { - return getSideState(Direction.SOUTH, step); - } - - default BlockState westState() { - return getSideState(Direction.WEST, 1); - } - - default BlockState westState(int step) { - return getSideState(Direction.WEST, step); - } - default BlockState getSideState(Direction face) { return getSideState(face, 1); } diff --git a/src/main/java/org/cloudburstmc/api/block/BlockBehaviors.java b/src/main/java/org/cloudburstmc/api/block/BlockBehaviors.java new file mode 100644 index 0000000..6dd2e3a --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/BlockBehaviors.java @@ -0,0 +1,163 @@ +package org.cloudburstmc.api.block; + +import org.cloudburstmc.api.block.behavior.*; +import org.cloudburstmc.api.block.material.MaterialType; +import org.cloudburstmc.api.blockentity.BlockEntityType; +import org.cloudburstmc.api.data.BehaviorKey; +import org.cloudburstmc.api.data.DataKey; +import org.cloudburstmc.api.util.Identifier; + +import java.util.Optional; + +public final class BlockBehaviors { + + private BlockBehaviors() { + } + + public static final BehaviorKey GET_DESCRIPTION_ID = DataKey.behavior(Identifier.fromString("get_description_id"), DescriptionBlockBehavior.class, DescriptionBlockBehavior.Executor.class); + + public static final BehaviorKey GET_BOUNDING_BOX = DataKey.behavior(Identifier.fromString("get_bounding_box"), AABBBlockBehavior.class, AABBBlockBehavior.Executor.class); + + public static final BehaviorKey CAN_BE_SILK_TOUCHED = DataKey.behavior(Identifier.fromString("can_be_silk_touched"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey CAN_BE_USED_IN_COMMANDS = DataKey.behavior(Identifier.fromString("can_be_used_in_commands"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey CAN_CONTAIN_LIQUID = DataKey.behavior(Identifier.fromString("can_contain_liquid"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey CAN_SPAWN_ON = DataKey.behavior(Identifier.fromString("can_spawn_on"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey CAN_BE_USED = DataKey.behavior(Identifier.fromString("can_be_used"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey GET_FRICTION = DataKey.behavior(Identifier.fromString("get_friction"), FloatBlockBehavior.class, FloatBlockBehavior.Executor.class); + + public static final BehaviorKey GET_HARDNESS = DataKey.behavior(Identifier.fromString("get_hardness"), FloatBlockBehavior.class, FloatBlockBehavior.Executor.class); + + public static final BehaviorKey GET_BURN_ODDS = DataKey.behavior(Identifier.fromString("get_burn_odds"), IntBlockBehavior.class, IntBlockBehavior.Executor.class); + + public static final BehaviorKey GET_FLAME_ODDS = DataKey.behavior(Identifier.fromString("get_flame_odds"), IntBlockBehavior.class, IntBlockBehavior.Executor.class); + + public static final BehaviorKey GET_GRAVITY = DataKey.behavior(Identifier.fromString("get_gravity"), FloatBlockBehavior.class, FloatBlockBehavior.Executor.class); + + public static final BehaviorKey GET_THICKNESS = DataKey.behavior(Identifier.fromString("get_thickness"), FloatBlockBehavior.class, FloatBlockBehavior.Executor.class); + + public static final BehaviorKey GET_DESTROY_SPEED = DataKey.behavior(Identifier.fromString("get_destroy_speed"), FloatBlockBehavior.class, FloatBlockBehavior.Executor.class); + + public static final BehaviorKey GET_EXPERIENCE_DROP = DataKey.behavior(Identifier.fromString("get_experience_drop"), ExpBlockBehavior.class, ExpBlockBehavior.Executor.class); + +// public static final BehaviorKey, FloatBlockBehavior.Executor> GET_EXPLOSION_RESISTANCE = DataKey.behavior(Identifier.fromString("get_explosion_resistance"), ToFloatTriFunction.class, FloatBlockBehavior.Executor.class); + +// public static final BehaviorKey, ItemStack> GET_SILK_TOUCH_ITEM_STACK = DataKey.behavior(Identifier.fromString("get_silk_touch_item_stack"), BiFunction.class, ItemStack.class); + +// public static final BehaviorKey, BasicBlockBehavior.Executor> GET_STRIPPED_BLOCK = DataKey.behavior(Identifier.fromString("get_stripped_block"), BasicBlockBehavior.class, BasicBlockBehavior.Executor.class); + + public static final BehaviorKey>>, GenericBlockBehavior.Executor>>> GET_BLOCK_ENTITY = DataKey.behavior(Identifier.fromString("get_block_entity"), GenericBlockBehavior.class, GenericBlockBehavior.Executor.class); + + public static final BehaviorKey MAY_PICK = DataKey.behavior(Identifier.fromString("may_pick"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey MAY_PLACE = DataKey.behavior(Identifier.fromString("may_place"), MayPlaceBlockBehavior.class, MayPlaceBlockBehavior.Executor.class); + + public static final BehaviorKey MAY_PLACE_ON = DataKey.behavior(Identifier.fromString("may_place_on"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey ON_DESTROY = DataKey.behavior(Identifier.fromString("on_destroy"), PlayerBlockBehavior.class, PlayerBlockBehavior.Executor.class); + + public static final BehaviorKey POST_DESTROY = DataKey.behavior(Identifier.fromString("post_destroy"), PlayerBlockBehavior.class, PlayerBlockBehavior.Executor.class); + + public static final BehaviorKey ON_NEIGHBOUR_CHANGED = DataKey.behavior(Identifier.fromString("on_neighbour_changed"), NeighborBlockBehavior.class, NeighborBlockBehavior.Executor.class); + + public static final BehaviorKey ON_FALL_ON = DataKey.behavior(Identifier.fromString("on_fall_on"), FallOnBlockBehavior.class, FallOnBlockBehavior.Executor.class); + + public static final BehaviorKey ON_LIGHTNING_HIT = DataKey.behavior(Identifier.fromString("on_lightning_hit"), ComplexBlockBehavior.class, ComplexBlockBehavior.Executor.class); + + public static final BehaviorKey ON_PLACE = DataKey.behavior(Identifier.fromString("on_place"), PlaceBlockBehavior.class, PlaceBlockBehavior.Executor.class); + + public static final BehaviorKey ON_PROJECTILE_HIT = DataKey.behavior(Identifier.fromString("on_projectile_hit"), EntityBlockBehavior.class, EntityBlockBehavior.Executor.class); + + public static final BehaviorKey ON_REDSTONE_UPDATE = DataKey.behavior(Identifier.fromString("on_redstone_update"), ComplexBlockBehavior.class, ComplexBlockBehavior.Executor.class); + + public static final BehaviorKey ON_REMOVE = DataKey.behavior(Identifier.fromString("on_remove"), ComplexBlockBehavior.class, ComplexBlockBehavior.Executor.class); + + public static final BehaviorKey ON_RANDOM_TICK = DataKey.behavior(Identifier.fromString("on_random_tick"), TickBlockBehavior.class, TickBlockBehavior.Executor.class); + + public static final BehaviorKey CAN_RANDOM_TICK = DataKey.behavior(Identifier.fromString("can_random_tick"), Boolean.class); + + public static final BehaviorKey ON_TICK = DataKey.behavior(Identifier.fromString("on_tick"), TickBlockBehavior.class, TickBlockBehavior.Executor.class); + + public static final BehaviorKey USE = DataKey.behavior(Identifier.fromString("use"), UseBlockBehavior.class, UseBlockBehavior.Executor.class); + + public static final BehaviorKey ON_STAND_ON = DataKey.behavior(Identifier.fromString("on_stand_on"), EntityBlockBehavior.class, EntityBlockBehavior.Executor.class); + + public static final BehaviorKey ON_STEP_ON = DataKey.behavior(Identifier.fromString("on_step_on"), EntityBlockBehavior.class, EntityBlockBehavior.Executor.class); + + public static final BehaviorKey ON_STEP_OFF = DataKey.behavior(Identifier.fromString("on_step_off"), EntityBlockBehavior.class, EntityBlockBehavior.Executor.class); + + public static final BehaviorKey GET_MATERIAL = DataKey.behavior(Identifier.fromString("get_material"), MaterialType.class, MaterialType.class); + + public static final BehaviorKey GET_SILK_TOUCH_RESOURCE = DataKey.behavior(Identifier.fromString("get_silk_touch_resource"), ResourceBlockBehavior.class, ResourceBlockBehavior.Executor.class); + + public static final BehaviorKey DROP_RESOURCE = DataKey.behavior(Identifier.fromString("drop_resource"), DropResourceBlockBehavior.class, DropResourceBlockBehavior.Executor.class); + + public static final BehaviorKey SPAWN_RESOURCES = DataKey.behavior(Identifier.fromString("spawn_resources"), SpawnResourcesBlockBehavior.class, SpawnResourcesBlockBehavior.Executor.class); + + public static final BehaviorKey GET_RESOURCE = DataKey.behavior(Identifier.fromString("get_resource"), ResourceBlockBehavior.class, ResourceBlockBehavior.Executor.class); + + public static final BehaviorKey GET_RESOURCE_COUNT = DataKey.behavior(Identifier.fromString("get_resource_count"), ResourceCountBlockBehavior.class, ResourceCountBlockBehavior.Executor.class); + + public static final BehaviorKey GET_TRANSLUCENCY = DataKey.behavior(Identifier.fromString("get_translucency"), Float.class); + + public static final BehaviorKey IS_SOLID = DataKey.behavior(Identifier.fromString("is_solid"), Boolean.class); + + public static final BehaviorKey IS_LIQUID = DataKey.behavior(Identifier.fromString("is_liquid"), Boolean.class); + + public static final BehaviorKey USES_WATERLOGGING = DataKey.behavior(Identifier.fromString("uses_waterlogging"), Boolean.class); + + public static final BehaviorKey IS_TOP_SOLID = DataKey.behavior(Identifier.fromString("is_top_solid"), Boolean.class); + + public static final BehaviorKey IS_STAIRS = DataKey.behavior(Identifier.fromString("is_stairs"), Boolean.class); + + public static final BehaviorKey IS_SLAB = DataKey.behavior(Identifier.fromString("is_slab"), Boolean.class); + + public static final BehaviorKey IS_REPLACEABLE = DataKey.behavior(Identifier.fromString("is_replaceable"), Boolean.class); + + public static final BehaviorKey IS_SUPER_HOT = DataKey.behavior(Identifier.fromString("is_super_hot"), Boolean.class); + + public static final BehaviorKey IS_FLAMMABLE = DataKey.behavior(Identifier.fromString("is_flammable"), Boolean.class); + + public static final BehaviorKey GET_COLOR = DataKey.behavior(Identifier.fromString("get_color"), ColorBlockBehavior.class, ColorBlockBehavior.Executor.class); + + public static final BehaviorKey GET_LIGHT = DataKey.behavior(Identifier.fromString("get_light"), Integer.class); + + public static final BehaviorKey IS_ALWAYS_DESTROYABLE = DataKey.behavior(Identifier.fromString("is_always_destroyable"), Boolean.class); + + public static final BehaviorKey GET_TICK_DELAY = DataKey.behavior(Identifier.fromString("get_tick_delay"), Integer.class); + + public static final BehaviorKey CAN_SURVIVE = DataKey.behavior(Identifier.fromString("can_survive"), SurviveBlockBehavior.class, SurviveBlockBehavior.Executor.class); + + public static final BehaviorKey CHECK_ALIVE = DataKey.behavior(Identifier.fromString("check_alive"), ComplexBlockBehavior.class, ComplexBlockBehavior.Executor.class); + + public static final BehaviorKey IS_FLOODABLE = DataKey.behavior(Identifier.fromString("is_floodable"), Boolean.class); + + public static final BehaviorKey CAN_INSTATICK = DataKey.behavior(Identifier.fromString("is_instaticking"), Boolean.class); + + public static final BehaviorKey CAN_SLIDE = DataKey.behavior(Identifier.fromString("can_slide"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey IS_FREE_TO_FALL = DataKey.behavior(Identifier.fromString("is_free_to_fall"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey START_FALLING = DataKey.behavior(Identifier.fromString("start_falling"), ComplexBlockBehavior.class, ComplexBlockBehavior.Executor.class); + + public static final BehaviorKey GET_LIQUID_HEIGHT = DataKey.behavior(Identifier.fromString("get_fluid_height"), FloatBlockBehavior.class, FloatBlockBehavior.Executor.class); + + public static final BehaviorKey GET_RESISTANCE = DataKey.behavior(Identifier.fromString("get_resistance"), Float.class); + + public static final BehaviorKey ON_ENTITY_COLLIDE = DataKey.behavior(Identifier.fromString("on_entity_collide"), EntityBlockBehavior.class, EntityBlockBehavior.Executor.class); + + public static final BehaviorKey GET_FILTERED_LIGHT = DataKey.behavior(Identifier.fromString("get_filtered_light"), Integer.class, Integer.class); + + public static final BehaviorKey CAN_DAMAGE_ITEM = DataKey.behavior(Identifier.fromString("can_damage_item"), Boolean.class); + + public static final BehaviorKey GET_MAP_COLOR = DataKey.behavior(Identifier.fromString("get_map_color"), MapColorBehavior.class, MapColorBehavior.Executor.class); + + public static final BehaviorKey CAN_PASS_THROUGH = DataKey.behavior(Identifier.fromString("can_pass_through"), BooleanBlockStateBehavior.class, BooleanBlockStateBehavior.Executor.class); + + public static final BehaviorKey IS_BREAKABLE = DataKey.behavior(Identifier.fromString("is_breakable"), CanBreakBlockBehavior.class, CanBreakBlockBehavior.Executor.class); + +} diff --git a/src/main/java/org/cloudburstmc/api/block/BlockState.java b/src/main/java/org/cloudburstmc/api/block/BlockState.java index c4cbf7a..bff7834 100644 --- a/src/main/java/org/cloudburstmc/api/block/BlockState.java +++ b/src/main/java/org/cloudburstmc/api/block/BlockState.java @@ -1,7 +1,6 @@ package org.cloudburstmc.api.block; import com.google.common.collect.ImmutableMap; -import org.cloudburstmc.api.block.behavior.BlockBehavior; import org.cloudburstmc.api.block.trait.BlockTrait; import org.cloudburstmc.api.block.trait.BooleanBlockTrait; import org.cloudburstmc.api.block.trait.IntegerBlockTrait; @@ -18,20 +17,10 @@ public class BlockState { private final BlockType type; private final Map, Comparable> traits; private Map, BlockState[]> blockStates; - private BlockBehavior behavior; public BlockState(BlockType type, Map, Comparable> traits) { - this(type, traits, null); - } - - public BlockState(BlockType type, Map, Comparable> traits, BlockBehavior behavior) { this.type = type; this.traits = traits; - this.behavior = behavior; - } - - public void setBehavior(BlockBehavior behavior) { - this.behavior = behavior; } public BlockType getType() { @@ -104,10 +93,6 @@ public String toString() { return builder.toString(); } - public BlockBehavior getBehavior() { - return this.behavior; - } - public BlockState toggleTrait(BooleanBlockTrait trait) { return this.blockStates.get(trait)[trait.getIndex(!((Boolean) this.traits.get(trait)))]; } diff --git a/src/main/java/org/cloudburstmc/api/block/BlockStates.java b/src/main/java/org/cloudburstmc/api/block/BlockStates.java index 4a831ff..ef96ba4 100644 --- a/src/main/java/org/cloudburstmc/api/block/BlockStates.java +++ b/src/main/java/org/cloudburstmc/api/block/BlockStates.java @@ -287,7 +287,6 @@ public class BlockStates { public static final BlockState WOODEN_STAIRS = BlockTypes.WOODEN_STAIRS.getDefaultState(); public static final BlockState WOODEN_TRAPDOOR = BlockTypes.WOODEN_TRAPDOOR.getDefaultState(); public static final BlockState WOOL = BlockTypes.WOOL.getDefaultState(); - public static final BlockState MANGROVE_LEAVES = BlockTypes.MANGROVE_LEAVES.getDefaultState(); public static final BlockState MANGROVE_PROPAGULE = BlockTypes.MANGROVE_PROPAGULE.getDefaultState(); public static final BlockState MANGROVE_ROOTS = BlockTypes.MANGROVE_ROOTS.getDefaultState(); public static final BlockState MUDDY_MANGROVE_ROOTS = BlockTypes.MUDDY_MANGROVE_ROOTS.getDefaultState(); diff --git a/src/main/java/org/cloudburstmc/api/block/BlockType.java b/src/main/java/org/cloudburstmc/api/block/BlockType.java index 69af521..7c7d6aa 100644 --- a/src/main/java/org/cloudburstmc/api/block/BlockType.java +++ b/src/main/java/org/cloudburstmc/api/block/BlockType.java @@ -3,13 +3,9 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import org.checkerframework.checker.nullness.qual.Nullable; import org.cloudburstmc.api.block.trait.BlockTrait; -import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.item.ItemKeys; import org.cloudburstmc.api.item.ItemType; -import org.cloudburstmc.api.item.TierType; -import org.cloudburstmc.api.item.ToolType; -import org.cloudburstmc.api.util.AxisAlignedBB; import org.cloudburstmc.api.util.Identifier; import java.util.*; @@ -19,15 +15,14 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -public final class BlockType implements ItemType { +public final class BlockType extends ItemType { - private final Identifier id; private final Set> traits; private final List states; private final BlockState defaultState; private BlockType(Identifier id, BlockTrait[] traits) { - this.id = id; + super(id, Collections.singleton(ItemKeys.BLOCK_STATE)); this.traits = ImmutableSet.copyOf(traits); this.states = getPermutations(this, traits); @@ -45,10 +40,6 @@ private BlockType(Identifier id, BlockTrait[] traits) { } } - public Identifier getId() { - return id; - } - public Set> getTraits() { return traits; } @@ -65,10 +56,20 @@ public void forEachPermutation(Consumer action) { this.states.forEach(action); } + private static final BlockTrait[] EMPTY = new BlockTrait[0]; + + public static BlockType of(Identifier id) { + return of(id, EMPTY); + } + public static BlockType of(Identifier id, BlockTrait... traits) { checkNotNull(id, "id"); checkNotNull(traits, "traits"); + if (traits == EMPTY) { + return new BlockType(id, EMPTY); + } + // Check for duplicate block traits. LinkedHashSet> traitSet = new LinkedHashSet<>(); Collections.addAll(traitSet, traits); @@ -130,129 +131,6 @@ private static List getPermutations(BlockType type, BlockTrait[] return states.build(); } - @Override - public boolean isBlock() { - return true; - } - - @Override - public boolean isPlaceable() { - return true; - } - - //TODO - move a lot of this to block/item behavior classes? - public boolean blocksMotion() { - return this != BlockTypes.AIR; - } - - public boolean blocksWater() { - return true; - } - - public boolean isFloodable() { - return false; - } - - public boolean isReplaceable() { - return false; - } - - public boolean isTransparent() { - return BlockCategories.inCategory(this, BlockCategory.TRANSPARENT); - } - - public int getTranslucency() { - return 0; - } - - public int getFilterLevel() { - return 0; - } - - public boolean isSolid() { - return BlockCategories.inCategory(this, BlockCategory.SOLID); - } - - public boolean isDiggable() { - return false; - } - - public int getBurnChance() { - return 0; - } - - public int getBurnAbility() { - return 0; - } - - public float getHardness() { - return 0f; - } - - public float getFriction() { - return 0f; - } - - public float getResistance() { - return 0f; - } - - @Nullable - @Override - public BlockType getBlock() { - return this; - } - - @Nullable - @Override - public Class getMetadataClass() { - return null; - } - - @Override - public int getMaximumStackSize() { - return 64; - } - - @Override - public ItemStack createItem(int amount, Object... metadata) { - return null; // TODO - Need to inject an Item or Block Registry? Or make ItemStack not an interface so we can create a new instance? - } - - @Nullable - @Override - public ToolType getToolType() { - return null; - } - - @Nullable - @Override - public TierType getTierType() { - return null; - } - - public AxisAlignedBB getBoundingBox() { - return null; - //TODO - } - - // Move these to BlockBehavior instead? - public boolean isPowerSource() { - return false; - } - - public boolean canBeSilkTouched() { - return true; - } - - public boolean waterlogsSource() { - return false; - } - - public boolean breaksFlowing() { - return false; - } - @Override public String toString() { return getId().toString(); diff --git a/src/main/java/org/cloudburstmc/api/block/BlockTypes.java b/src/main/java/org/cloudburstmc/api/block/BlockTypes.java index 856ba18..ac9d371 100644 --- a/src/main/java/org/cloudburstmc/api/block/BlockTypes.java +++ b/src/main/java/org/cloudburstmc/api/block/BlockTypes.java @@ -337,7 +337,6 @@ public class BlockTypes { public static final BlockType PEARLESCENT_FROGLIGHT = BlockType.of(BlockIds.PEARLESCENT_FROGLIGHT, BlockTraits.AXIS); public static final BlockType VERDANT_FROGLIGHT = BlockType.of(BlockIds.VERDANT_FROGLIGHT, BlockTraits.AXIS); public static final BlockType OCHRE_FROGLIGHT = BlockType.of(BlockIds.OCHRE_FROGLIGHT, BlockTraits.AXIS); - public static final BlockType MANGROVE_LEAVES = BlockType.of(BlockIds.MANGROVE_LEAVES, BlockTraits.IS_PERSISTENT, BlockTraits.HAS_UPDATE); public static final BlockType MANGROVE_PROPAGULE = BlockType.of(BlockIds.MANGROVE_PROPAGULE, BlockTraits.IS_HANGING, BlockTraits.PROPAGULE_STAGE); public static final BlockType MANGROVE_ROOTS = BlockType.of(BlockIds.MANGROVE_ROOTS); public static final BlockType MUDDY_MANGROVE_ROOTS = BlockType.of(BlockIds.MUDDY_MANGROVE_ROOTS, BlockTraits.AXIS); diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/AABBBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/AABBBlockBehavior.java new file mode 100644 index 0000000..8900bbf --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/AABBBlockBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.util.AxisAlignedBB; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface AABBBlockBehavior { + + AxisAlignedBB getBoundingBox(Behavior behavior, BlockState state); + + @FunctionalInterface + interface Executor { + AxisAlignedBB execute(BlockState state); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/BlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/BlockBehavior.java deleted file mode 100644 index 7d7a9b4..0000000 --- a/src/main/java/org/cloudburstmc/api/block/behavior/BlockBehavior.java +++ /dev/null @@ -1,317 +0,0 @@ -package org.cloudburstmc.api.block.behavior; - -import com.nukkitx.math.vector.Vector3f; -import com.nukkitx.math.vector.Vector3i; -import org.cloudburstmc.api.block.Block; -import org.cloudburstmc.api.block.BlockState; -import org.cloudburstmc.api.entity.Entity; -import org.cloudburstmc.api.item.ItemStack; -import org.cloudburstmc.api.item.TierType; -import org.cloudburstmc.api.item.ToolType; -import org.cloudburstmc.api.player.Player; -import org.cloudburstmc.api.util.AxisAlignedBB; -import org.cloudburstmc.api.util.Direction; -import org.cloudburstmc.api.util.data.BlockColor; - -import static org.cloudburstmc.api.block.BlockStates.AIR; - -public abstract class BlockBehavior { - - public boolean canHarvestWithHand(BlockState state) { //used for calculating breaking time - var type = state.getType(); - return type.isDiggable() && type.getToolType() == null && type.getTierType() == null; - } - - public boolean isBreakable(BlockState state, ItemStack item) { - return state.getType().isDiggable(); - } - - public int tickRate() { - return 10; - } - - public int onUpdate(Block block, int type) { - return 0; - } - - public boolean onActivate(Block block, ItemStack item) { - return this.onActivate(block, item, null); - } - - public boolean onActivate(Block block, ItemStack item, Player player) { - return false; - } - - public int getBurnChance(BlockState state) { - return state.getType().getBurnChance(); - } - - public int getBurnAbility(BlockState state) { - return state.getType().getBurnAbility(); - } - - public ToolType getToolType(BlockState state) { - return state.getType().getToolType(); - } - - public TierType getMinimalTier(BlockState state) { - return state.getType().getTierType(); - } - - public boolean checkTool(BlockState state, ItemStack item) { - var toolType = getToolType(state); - var tier = getMinimalTier(state); - - var type = item.getType(); - if (toolType != null && type.getToolType() != toolType) { - return false; - } - - if (tier == null) { - return true; - } - - return type.getTierType() != null && type.getTierType().compareTo(tier) >= 0; - } - - public int getLightLevel(Block block) { - return 0; - } - - public boolean canBePlaced() { - return true; - } - - public boolean canBeReplaced(Block block) { - return block.getState() - .getType() - .isReplaceable(); - } - - public boolean isTransparent(BlockState state) { - var type = state.getType(); - return type.isTransparent() || type.getTranslucency() > 0; - } - - public boolean isSolid(BlockState state) { - return state.getType().isSolid(); - } - - public boolean isLiquid() { - return false; - } - - public int getFilterLevel(BlockState state) { - return state.getType().getFilterLevel(); - } - - public boolean canBeActivated(Block block) { - return false; - } - - public boolean hasEntityCollision() { - return false; - } - - public boolean canPassThrough(BlockState state) { - return !state.getType().blocksMotion(); - } - - public boolean canBePushed() { - return true; - } - - public boolean hasComparatorInputOverride(BlockState state) { - //return state.getType().hasComparatorSignal(); - return false; - } - - public int getComparatorInputOverride(Block block) { - return 0; - } - - public boolean canBeClimbed() { - return false; - } - - public BlockColor getColor(Block block) { - return BlockColor.VOID_BLOCK_COLOR; - } - - public boolean canBeFlooded(BlockState state) { - var type = state.getType(); - return type.isFloodable() || !type.blocksWater(); - } - - public boolean place(ItemStack item, Block block, Block target, Direction face, Vector3f clickPos, Player player) { - return placeBlock(block, item); - } - - public boolean placeBlock(Block block, ItemStack item) { - return placeBlock(block, item, true); - } - - public boolean placeBlock(Block block, ItemStack item, boolean update) { - return placeBlock(block, item.getBehavior().getBlock(item), update); - } - - public boolean placeBlock(Block block, BlockState newState) { - return placeBlock(block, newState, true); - } - - public abstract boolean placeBlock(Block block, BlockState newState, boolean update); - - public boolean onBreak(Block block, ItemStack item) { - return removeBlock(block, true); - } - - final protected boolean removeBlock(Block block) { - return removeBlock(block, true); - } - - final public boolean removeBlock(Block block, boolean update) { - BlockState state; - - if (block.isWaterlogged()) { - state = block.getExtra(); - - block.setExtra(AIR, true, false); - } else { - state = AIR; - } - - return block.getLevel().setBlockState(block.getPosition(), state, true, update); - } - - public boolean onBreak(Block block, ItemStack item, Player player) { - return onBreak(block, item); - } - - public float getHardness(BlockState blockState) { - return blockState.getType().getHardness(); - } - - public String getDescriptionId(BlockState state) { - return "tile." + state.getType().getId().getName() + ".name"; - } - - public float getResistance(BlockState blockState) { - return blockState.getType().getResistance(); - } - - public float getFrictionFactor(BlockState blockState) { - return blockState.getType().getFriction(); - } - - public Vector3f addVelocityToEntity(Block block, Vector3f vector, Entity entity) { - return vector; - } - - public ItemStack[] getDrops(Block block, ItemStack hand) { - if (checkTool(block.getState(), hand)) { - return new ItemStack[]{ - this.toItem(block) - }; - } else { - return new ItemStack[0]; - } - } - - public abstract float getBreakTime(BlockState state, ItemStack item, Player player); - - public boolean canBeBrokenWith(BlockState state, ItemStack item) { - return this.getHardness(state) != -1; - } - - public boolean collidesWithBB(Block block, AxisAlignedBB bb) { - return collidesWithBB(block, bb, false); - } - - public boolean collidesWithBB(Block block, AxisAlignedBB bb, boolean collisionBB) { - AxisAlignedBB bb1 = collisionBB ? this.getCollisionBoxes(block.getPosition(), block.getState()) : this.getBoundingBox(block); - return bb1 != null && bb.intersectsWith(bb1); - } - - public void onEntityCollide(Block block, Entity entity) { - - } - - public AxisAlignedBB getBoundingBox(BlockState state) { - return getBoundingBox(null, state); - } - - public final AxisAlignedBB getBoundingBox(Block block) { - return getBoundingBox(block.getPosition(), block.getState()); - } - - public AxisAlignedBB getBoundingBox(Vector3i pos, BlockState state) { - var type = state.getType(); - - AxisAlignedBB bb = type.getBoundingBox(); - - if (bb != null && pos != null) { - bb = bb.offset(pos); - } - - return bb; - } - - public final AxisAlignedBB getCollisionBoxes(Block block) { - return getCollisionBoxes(block.getPosition(), block.getState()); - } - - public AxisAlignedBB getCollisionBoxes(Vector3i pos, BlockState state) { - return getBoundingBox(pos, state); - } - - public String getSaveId() { - String name = getClass().getName(); - return name.substring(16); - } - - public int getWeakPower(Block block, Direction face) { - return 0; - } - - public int getStrongPower(Block block, Direction side) { - return 0; - } - - public boolean isPowerSource(Block block) { - return block.getState().getType().isPowerSource(); - } - - public int getDropExp() { - return 0; - } - - public boolean isNormalBlock(Block block) { - var state = block.getState(); - return !isTransparent(state) && isSolid(state) && !isPowerSource(block); - } - - public BlockBehavior clone() { - try { - return (BlockBehavior) super.clone(); - } catch (CloneNotSupportedException e) { - throw new IllegalStateException(e); - } - } - - public ItemStack toItem(Block block) { - return block.getState().getType().createItem(); - } - - public boolean canSilkTouch(BlockState state) { - return state.getType().canBeSilkTouched(); - } - - public boolean canWaterlogSource(BlockState state) { - return state.getType().waterlogsSource(); - } - - public boolean canWaterlogFlowing(BlockState state) { - var type = state.getType(); - return !type.breaksFlowing() && !type.blocksWater(); - } -} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/BooleanBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/BooleanBlockBehavior.java new file mode 100644 index 0000000..72985be --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/BooleanBlockBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface BooleanBlockBehavior { + + boolean test(Behavior behavior, Block block); + + @FunctionalInterface + interface Executor { + boolean execute(Block block); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/BooleanBlockStateBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/BooleanBlockStateBehavior.java new file mode 100644 index 0000000..42b98f6 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/BooleanBlockStateBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface BooleanBlockStateBehavior { + + boolean test(Behavior behavior, BlockState block); + + @FunctionalInterface + interface Executor { + boolean execute(BlockState block); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/CanBreakBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/CanBreakBlockBehavior.java new file mode 100644 index 0000000..20ca077 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/CanBreakBlockBehavior.java @@ -0,0 +1,16 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.Direction; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface CanBreakBlockBehavior { + + boolean canBreak(Behavior behavior, Block block, ItemStack item); + + @FunctionalInterface + interface Executor { + boolean execute(Block block, ItemStack item); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/ColorBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/ColorBlockBehavior.java new file mode 100644 index 0000000..b5ed891 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/ColorBlockBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.behavior.Behavior; +import org.cloudburstmc.api.util.data.BlockColor; + +public interface ColorBlockBehavior { + + BlockColor execute(Behavior behavior, Block block); + + @FunctionalInterface + interface Executor { + BlockColor execute(Block block); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/ComplexBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/ComplexBlockBehavior.java new file mode 100644 index 0000000..560b30a --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/ComplexBlockBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface ComplexBlockBehavior { + + void execute(Behavior behavior, Block block); + + @FunctionalInterface + interface Executor { + void execute(Block block); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/DescriptionBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/DescriptionBlockBehavior.java new file mode 100644 index 0000000..1b66862 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/DescriptionBlockBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface DescriptionBlockBehavior { + + String getDescription(Behavior behavior, BlockState state); + + @FunctionalInterface + interface Executor { + String execute(BlockState state); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/DropResourceBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/DropResourceBlockBehavior.java new file mode 100644 index 0000000..eb235a5 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/DropResourceBlockBehavior.java @@ -0,0 +1,17 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.entity.misc.DroppedItem; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface DropResourceBlockBehavior { + + DroppedItem dropResource(Behavior behavior, Block block, ItemStack itemStack); + + @FunctionalInterface + interface Executor { + + DroppedItem execute(Block block, ItemStack itemStack); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/EntityBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/EntityBlockBehavior.java new file mode 100644 index 0000000..f978fc9 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/EntityBlockBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.entity.Entity; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface EntityBlockBehavior { + + void execute(Behavior behavior, Block block, Entity entity); + + @FunctionalInterface + interface Executor { + void execute(Block block, Entity entity); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/ExpBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/ExpBlockBehavior.java new file mode 100644 index 0000000..4045e21 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/ExpBlockBehavior.java @@ -0,0 +1,16 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.util.behavior.Behavior; + +import java.util.random.RandomGenerator; + +public interface ExpBlockBehavior { + + int getExperience(Behavior behavior, BlockState state, RandomGenerator random); + + @FunctionalInterface + interface Executor { + int execute(BlockState state, RandomGenerator random); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/FallOnBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/FallOnBlockBehavior.java new file mode 100644 index 0000000..02b63a9 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/FallOnBlockBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.entity.Entity; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface FallOnBlockBehavior { + + void onFallOn(Behavior behavior, Block block, Entity entity); + + @FunctionalInterface + interface Executor { + void execute(Block block, Entity entity); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/FloatBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/FloatBlockBehavior.java new file mode 100644 index 0000000..c2d4d4d --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/FloatBlockBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface FloatBlockBehavior { + + float getProperty(Behavior behavior, BlockState state); + + @FunctionalInterface + interface Executor { + float execute(BlockState state); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/GenericBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/GenericBlockBehavior.java new file mode 100644 index 0000000..ab07a07 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/GenericBlockBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface GenericBlockBehavior { + + void execute(Behavior> behavior, Block block); + + @FunctionalInterface + interface Executor { + void execute(Block block); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/IntBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/IntBlockBehavior.java new file mode 100644 index 0000000..eae506d --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/IntBlockBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface IntBlockBehavior { + + int getProperty(Behavior behavior, BlockState state); + + @FunctionalInterface + interface Executor { + int execute(BlockState state); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/MapColorBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/MapColorBehavior.java new file mode 100644 index 0000000..9a6afa8 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/MapColorBehavior.java @@ -0,0 +1,17 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.behavior.Behavior; + +import java.awt.*; + +public interface MapColorBehavior { + + Color getMapColor(Behavior behavior, Block block); + + @FunctionalInterface + interface Executor { + + Color execute(Block block); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/MayPlaceBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/MayPlaceBlockBehavior.java new file mode 100644 index 0000000..ca4c42d --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/MayPlaceBlockBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.Direction; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface MayPlaceBlockBehavior { + + boolean mayPlace(Behavior behavior, Block block, Direction direction); + + @FunctionalInterface + interface Executor { + boolean execute(Block block, Direction direction); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/NeighborBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/NeighborBlockBehavior.java new file mode 100644 index 0000000..d2c72b7 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/NeighborBlockBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface NeighborBlockBehavior { + + void onNeighborChanged(Behavior behavior, Block block, Block neighbor); + + @FunctionalInterface + interface Executor { + void executor(Block block, Block neighbor); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/PlaceBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/PlaceBlockBehavior.java new file mode 100644 index 0000000..9e90d0e --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/PlaceBlockBehavior.java @@ -0,0 +1,21 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.player.Player; +import org.cloudburstmc.api.util.Direction; +import org.cloudburstmc.api.util.behavior.Behavior; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.math.vector.Vector3i; + +public interface PlaceBlockBehavior { + + boolean execute(Behavior behavior, BlockState blockState, Player player, + Vector3i blockPosition, Direction face, Vector3f clickPosition); + + @FunctionalInterface + interface Executor { + + boolean execute(BlockState blockState, Player player, Vector3i blockPosition, Direction face, + Vector3f clickPosition); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/PlayerBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/PlayerBlockBehavior.java new file mode 100644 index 0000000..631bd04 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/PlayerBlockBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.player.Player; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface PlayerBlockBehavior { + + void execute(Behavior behavior, Block block, Player player); + + @FunctionalInterface + interface Executor { + void execute(Block block, Player player); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/ResourceBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/ResourceBlockBehavior.java new file mode 100644 index 0000000..64416ae --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/ResourceBlockBehavior.java @@ -0,0 +1,17 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +import java.util.random.RandomGenerator; + +public interface ResourceBlockBehavior { + + ItemStack getResource(Behavior behavior, Block block, RandomGenerator random, int bonusLevel); + + @FunctionalInterface + interface Executor { + ItemStack execute(Block block, RandomGenerator random, int bonusLevel); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/ResourceCountBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/ResourceCountBlockBehavior.java new file mode 100644 index 0000000..489f253 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/ResourceCountBlockBehavior.java @@ -0,0 +1,16 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.behavior.Behavior; + +import java.util.random.RandomGenerator; + +public interface ResourceCountBlockBehavior { + + int getResourceCount(Behavior behavior, Block block, RandomGenerator random, int bonusLevel); + + @FunctionalInterface + interface Executor { + int execute(Block block, RandomGenerator random, int bonusLevel); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/SpawnResourcesBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/SpawnResourcesBlockBehavior.java new file mode 100644 index 0000000..3e286d8 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/SpawnResourcesBlockBehavior.java @@ -0,0 +1,18 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +import java.util.random.RandomGenerator; + +public interface SpawnResourcesBlockBehavior { + + void spawnResource(Behavior behavior, Block block, RandomGenerator random, ItemStack tool, int bonusLootLevel); + + @FunctionalInterface + interface Executor { + + void execute(Block block, RandomGenerator random, ItemStack tool, int bonusLootLevel); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/SurviveBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/SurviveBlockBehavior.java new file mode 100644 index 0000000..3748b58 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/SurviveBlockBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface SurviveBlockBehavior { + + boolean canSurvive(Behavior behavior, Block block); + + @FunctionalInterface + interface Executor { + boolean execute(Block block); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/TickBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/TickBlockBehavior.java new file mode 100644 index 0000000..45db9bd --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/TickBlockBehavior.java @@ -0,0 +1,16 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.util.behavior.Behavior; + +import java.util.random.RandomGenerator; + +public interface TickBlockBehavior { + + void onTick(Behavior behavior, Block block, RandomGenerator random); + + @FunctionalInterface + interface Executor { + void execute(Block block, RandomGenerator random); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/behavior/UseBlockBehavior.java b/src/main/java/org/cloudburstmc/api/block/behavior/UseBlockBehavior.java new file mode 100644 index 0000000..48d72f7 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/block/behavior/UseBlockBehavior.java @@ -0,0 +1,16 @@ +package org.cloudburstmc.api.block.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.player.Player; +import org.cloudburstmc.api.util.Direction; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface UseBlockBehavior { + + boolean use(Behavior behavior, Block block, Player player, Direction direction); + + @FunctionalInterface + interface Executor { + boolean execute(Block block, Player player, Direction direction); + } +} diff --git a/src/main/java/org/cloudburstmc/api/block/material/MaterialTypes.java b/src/main/java/org/cloudburstmc/api/block/material/MaterialTypes.java index d79dd6a..ef1864f 100644 --- a/src/main/java/org/cloudburstmc/api/block/material/MaterialTypes.java +++ b/src/main/java/org/cloudburstmc/api/block/material/MaterialTypes.java @@ -84,5 +84,9 @@ public class MaterialTypes { public static MaterialType DECORATION_FLAMMABLE = MaterialType.builder().translucency(1.0f).alwaysDestroyable().blockingPrecipitation().flammable().build(); - public static MaterialType ANY = MaterialType.builder().alwaysDestroyable().blockingPrecipitation().solid().build(); + public static MaterialType DECORATION_SOLID = MaterialType.builder().blockingPrecipitation().solid().blockingMotion().build(); + + public static MaterialType DRIPSTONE = MaterialType.builder().blockingPrecipitation().solid().blockingMotion().build(); + + public static MaterialType SCULK = MaterialType.builder().blockingPrecipitation().solid().blockingMotion().build(); } diff --git a/src/main/java/org/cloudburstmc/api/blockentity/BlockEntity.java b/src/main/java/org/cloudburstmc/api/blockentity/BlockEntity.java index 69a2a1e..de65b66 100644 --- a/src/main/java/org/cloudburstmc/api/blockentity/BlockEntity.java +++ b/src/main/java/org/cloudburstmc/api/blockentity/BlockEntity.java @@ -1,11 +1,11 @@ package org.cloudburstmc.api.blockentity; -import com.nukkitx.math.vector.Vector3i; import org.checkerframework.checker.nullness.qual.Nullable; import org.cloudburstmc.api.block.Block; import org.cloudburstmc.api.block.BlockState; import org.cloudburstmc.api.level.Level; import org.cloudburstmc.api.player.Player; +import org.cloudburstmc.math.vector.Vector3i; public interface BlockEntity { diff --git a/src/main/java/org/cloudburstmc/api/blockentity/BlockEntityFactory.java b/src/main/java/org/cloudburstmc/api/blockentity/BlockEntityFactory.java index 0aca999..9a558a2 100644 --- a/src/main/java/org/cloudburstmc/api/blockentity/BlockEntityFactory.java +++ b/src/main/java/org/cloudburstmc/api/blockentity/BlockEntityFactory.java @@ -1,7 +1,7 @@ package org.cloudburstmc.api.blockentity; -import com.nukkitx.math.vector.Vector3i; import org.cloudburstmc.api.level.chunk.Chunk; +import org.cloudburstmc.math.vector.Vector3i; public interface BlockEntityFactory { diff --git a/src/main/java/org/cloudburstmc/api/data/BehaviorKey.java b/src/main/java/org/cloudburstmc/api/data/BehaviorKey.java new file mode 100644 index 0000000..d5e5851 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/data/BehaviorKey.java @@ -0,0 +1,52 @@ +package org.cloudburstmc.api.data; + +import org.cloudburstmc.api.util.Identifier; + +import java.util.function.Function; + +public final class BehaviorKey implements DataKey { + + private final Identifier id; + private final Class functionType; + private final Class executorType; + + BehaviorKey(Identifier id, Class functionType, Class executorType) { + this.id = id; + this.functionType = functionType; + this.executorType = executorType; + } + + @Override + public Identifier getId() { + return id; + } + + @Override + public Class getType() { + return functionType; + } + + @Override + public Class getMutableType() { + return executorType; + } + + public Class getExecutorType() { + return executorType; + } + + @Override + public Function getImmutableFunction() { + throw new UnsupportedOperationException(); + } + + @Override + public Function getMutableFunction() { + throw new UnsupportedOperationException(); + } + + @Override + public String toString() { + return id.toString(); + } +} diff --git a/src/main/java/org/cloudburstmc/api/data/DataKey.java b/src/main/java/org/cloudburstmc/api/data/DataKey.java new file mode 100644 index 0000000..57ab9a7 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/data/DataKey.java @@ -0,0 +1,56 @@ +package org.cloudburstmc.api.data; + +import org.cloudburstmc.api.util.Identifier; + +import java.util.function.Function; + +import static com.google.common.base.Preconditions.checkNotNull; + +public sealed interface DataKey permits BehaviorKey, ListDataKey, SimpleDataKey, MapDataKey { + + @SuppressWarnings("unchecked") + static SimpleDataKey simple(Identifier id, Class type) { + checkNotNull(id, "id"); + checkNotNull(type, "type"); + return new SimpleDataKey<>(id, (Class) type); + } + + static ListDataKey list(Identifier id, Class type) { + checkNotNull(id, "id"); + checkNotNull(type, "type"); + return new ListDataKey<>(id, type); + } + + static MapDataKey map(Identifier id, Class keyType, Class valueType) { + checkNotNull(id, "id"); + checkNotNull(keyType, "keyType"); + checkNotNull(valueType, "valueType"); + return new MapDataKey<>(id, keyType, valueType); + } + + static BehaviorKey behavior(Identifier id, Class type) { + return behavior(id, type, type); + } + + @SuppressWarnings("unchecked") + static BehaviorKey behavior(Identifier id, Class functionType, Class returnType) { + checkNotNull(id, "id"); + checkNotNull(functionType, "functionType"); + checkNotNull(returnType, "returnType"); + return new BehaviorKey<>(id, (Class) functionType, (Class) returnType); + } + + Identifier getId(); + + Class getType(); + + Class getMutableType(); + + Function getImmutableFunction(); + + Function getMutableFunction(); + + default T getDefaultValue() { + return null; + } +} diff --git a/src/main/java/org/cloudburstmc/api/data/DataStore.java b/src/main/java/org/cloudburstmc/api/data/DataStore.java new file mode 100644 index 0000000..26beb82 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/data/DataStore.java @@ -0,0 +1,6 @@ +package org.cloudburstmc.api.data; + +public interface DataStore { + + T get(DataKey key); +} diff --git a/src/main/java/org/cloudburstmc/api/data/ListDataKey.java b/src/main/java/org/cloudburstmc/api/data/ListDataKey.java new file mode 100644 index 0000000..e53e409 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/data/ListDataKey.java @@ -0,0 +1,50 @@ +package org.cloudburstmc.api.data; + +import com.google.common.collect.ImmutableList; +import org.cloudburstmc.api.util.Identifier; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +@SuppressWarnings({"unchecked", "rawtypes"}) +public final class ListDataKey implements DataKey, List> { + + private final Identifier id; + private final Class type; + + ListDataKey(Identifier id, Class type) { + this.id = id; + this.type = type; + } + + @Override + public Identifier getId() { + return id; + } + + @Override + public Class> getType() { + return (Class) ImmutableList.class; + } + + @Override + public Class> getMutableType() { + return (Class) List.class; + } + + @Override + public Function, List> getImmutableFunction() { + return ImmutableList::copyOf; + } + + @Override + public Function, List> getMutableFunction() { + return ArrayList::new; + } + + @Override + public List getDefaultValue() { + return ImmutableList.of(); + } +} diff --git a/src/main/java/org/cloudburstmc/api/data/MapDataKey.java b/src/main/java/org/cloudburstmc/api/data/MapDataKey.java new file mode 100644 index 0000000..9d6e78b --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/data/MapDataKey.java @@ -0,0 +1,52 @@ +package org.cloudburstmc.api.data; + +import com.google.common.collect.ImmutableMap; +import org.cloudburstmc.api.util.Identifier; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; + +@SuppressWarnings({"unchecked", "rawtypes"}) +public final class MapDataKey implements DataKey, Map> { + + private final Identifier id; + private final Class keyType; + private final Class valueType; + + MapDataKey(Identifier id, Class keyType, Class valueType) { + this.id = id; + this.keyType = keyType; + this.valueType = valueType; + } + + @Override + public Identifier getId() { + return id; + } + + @Override + public Class> getType() { + return (Class) ImmutableMap.class; + } + + @Override + public Class> getMutableType() { + return (Class) Map.class; + } + + @Override + public Function, Map> getImmutableFunction() { + return ImmutableMap::copyOf; + } + + @Override + public Function, Map> getMutableFunction() { + return HashMap::new; + } + + @Override + public Map getDefaultValue() { + return ImmutableMap.of(); + } +} diff --git a/src/main/java/org/cloudburstmc/api/data/SimpleDataKey.java b/src/main/java/org/cloudburstmc/api/data/SimpleDataKey.java new file mode 100644 index 0000000..7643d1f --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/data/SimpleDataKey.java @@ -0,0 +1,41 @@ +package org.cloudburstmc.api.data; + +import org.cloudburstmc.api.util.Identifier; + +import java.util.function.Function; + +public final class SimpleDataKey implements DataKey { + + private final Identifier id; + private final Class type; + + SimpleDataKey(Identifier id, Class type) { + this.id = id; + this.type = type; + } + + @Override + public Identifier getId() { + return id; + } + + @Override + public Class getType() { + return type; + } + + @Override + public Class getMutableType() { + return type; + } + + @Override + public Function getImmutableFunction() { + return Function.identity(); + } + + @Override + public Function getMutableFunction() { + return Function.identity(); + } +} diff --git a/src/main/java/org/cloudburstmc/api/enchantment/Enchantment.java b/src/main/java/org/cloudburstmc/api/enchantment/Enchantment.java new file mode 100644 index 0000000..2d0f446 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/enchantment/Enchantment.java @@ -0,0 +1,4 @@ +package org.cloudburstmc.api.enchantment; + +public record Enchantment(EnchantmentType type, int level) { +} diff --git a/src/main/java/org/cloudburstmc/api/enchantment/EnchantmentBehaviors.java b/src/main/java/org/cloudburstmc/api/enchantment/EnchantmentBehaviors.java new file mode 100644 index 0000000..490978f --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/enchantment/EnchantmentBehaviors.java @@ -0,0 +1,36 @@ +package org.cloudburstmc.api.enchantment; + +import org.cloudburstmc.api.data.BehaviorKey; +import org.cloudburstmc.api.data.DataKey; +import org.cloudburstmc.api.enchantment.behavior.DamageBonusBehavior; +import org.cloudburstmc.api.enchantment.behavior.DamageProtectionBehavior; +import org.cloudburstmc.api.enchantment.behavior.PostHurtBehavior; +import org.cloudburstmc.api.util.Identifier; +import org.cloudburstmc.api.util.behavior.IntBehavior; + +public final class EnchantmentBehaviors { + + public static final BehaviorKey GET_DAMAGE_BONUS = + DataKey.behavior(Identifier.fromString("get_damage_bonus"), DamageBonusBehavior.class, DamageBonusBehavior.Executor.class); + + public static final BehaviorKey GET_DAMAGE_PROTECTION = + DataKey.behavior(Identifier.fromString("get_damage_protection"), DamageProtectionBehavior.class, DamageProtectionBehavior.Executor.class); + + public static final BehaviorKey DO_POST_HURT = + DataKey.behavior(Identifier.fromString("do_post_hurt"), PostHurtBehavior.class, PostHurtBehavior.Executor.class); + + public static final BehaviorKey GET_MIN_LEVEL = + DataKey.behavior(Identifier.fromString("get_min_level"), IntBehavior.class, IntBehavior.Executor.class); + + public static final BehaviorKey GET_MAX_LEVEL = + DataKey.behavior(Identifier.fromString("get_max_level"), IntBehavior.class, IntBehavior.Executor.class); + + public static final BehaviorKey GET_MIN_COST = + DataKey.behavior(Identifier.fromString("get_min_cost"), IntBehavior.class, IntBehavior.Executor.class); + + public static final BehaviorKey GET_MAX_COST = + DataKey.behavior(Identifier.fromString("get_max_cost"), IntBehavior.class, IntBehavior.Executor.class); + + public static final BehaviorKey GET_FREQUENCY = + DataKey.behavior(Identifier.fromString("get_frequency"), IntBehavior.class, IntBehavior.Executor.class); +} diff --git a/src/main/java/org/cloudburstmc/api/enchantment/behavior/DamageBonusBehavior.java b/src/main/java/org/cloudburstmc/api/enchantment/behavior/DamageBonusBehavior.java new file mode 100644 index 0000000..cd543bd --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/enchantment/behavior/DamageBonusBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.enchantment.behavior; + +import org.cloudburstmc.api.entity.Entity; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface DamageBonusBehavior { + + float getDamageBonus(Behavior behavior, int level, Entity target); + + @FunctionalInterface + interface Executor { + float execute(int level, Entity target); + } +} diff --git a/src/main/java/org/cloudburstmc/api/enchantment/behavior/DamageProtectionBehavior.java b/src/main/java/org/cloudburstmc/api/enchantment/behavior/DamageProtectionBehavior.java new file mode 100644 index 0000000..1953190 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/enchantment/behavior/DamageProtectionBehavior.java @@ -0,0 +1,14 @@ +package org.cloudburstmc.api.enchantment.behavior; + +import org.cloudburstmc.api.event.entity.EntityDamageEvent; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface DamageProtectionBehavior { + + int getDamageProtection(Behavior behavior, int level, EntityDamageEvent event); + + @FunctionalInterface + interface Executor { + int execute(int level, EntityDamageEvent event); + } +} diff --git a/src/main/java/org/cloudburstmc/api/enchantment/behavior/PostHurtBehavior.java b/src/main/java/org/cloudburstmc/api/enchantment/behavior/PostHurtBehavior.java new file mode 100644 index 0000000..a5874d4 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/enchantment/behavior/PostHurtBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.enchantment.behavior; + +import org.cloudburstmc.api.entity.Entity; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface PostHurtBehavior { + + void doPostHurt(Behavior behavior, ItemStack item, Entity victim, Entity attacker, int level); + + @FunctionalInterface + interface Executor { + void execute(ItemStack item, Entity victim, Entity attacker, int level); + } +} diff --git a/src/main/java/org/cloudburstmc/api/entity/Entity.java b/src/main/java/org/cloudburstmc/api/entity/Entity.java index 94c3b3f..0d52d72 100644 --- a/src/main/java/org/cloudburstmc/api/entity/Entity.java +++ b/src/main/java/org/cloudburstmc/api/entity/Entity.java @@ -1,7 +1,5 @@ package org.cloudburstmc.api.entity; -import com.nukkitx.math.vector.Vector2f; -import com.nukkitx.math.vector.Vector3f; import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.nullness.qual.Nullable; import org.cloudburstmc.api.Server; @@ -20,6 +18,8 @@ import org.cloudburstmc.api.util.AxisAlignedBB; import org.cloudburstmc.api.util.Direction; import org.cloudburstmc.api.util.data.MountType; +import org.cloudburstmc.math.vector.Vector2f; +import org.cloudburstmc.math.vector.Vector3f; import java.util.List; import java.util.Map; diff --git a/src/main/java/org/cloudburstmc/api/entity/misc/AreaEffectCloud.java b/src/main/java/org/cloudburstmc/api/entity/misc/AreaEffectCloud.java index b4819d4..8bacfb9 100644 --- a/src/main/java/org/cloudburstmc/api/entity/misc/AreaEffectCloud.java +++ b/src/main/java/org/cloudburstmc/api/entity/misc/AreaEffectCloud.java @@ -36,7 +36,7 @@ public interface AreaEffectCloud extends Entity { long getSpawnTime(); - void setSpawnTime(long spawnTime); + void setSpawnTime(int spawnTime); int getDuration(); diff --git a/src/main/java/org/cloudburstmc/api/event/block/BlockBreakEvent.java b/src/main/java/org/cloudburstmc/api/event/block/BlockBreakEvent.java index e83dc5a..5067522 100644 --- a/src/main/java/org/cloudburstmc/api/event/block/BlockBreakEvent.java +++ b/src/main/java/org/cloudburstmc/api/event/block/BlockBreakEvent.java @@ -32,8 +32,7 @@ public BlockBreakEvent(Player player, Block block, ItemStack item, ItemStack[] d } public BlockBreakEvent(Player player, Block block, ItemStack item, ItemStack[] drops, boolean instaBreak, boolean fastBreak) { - this(player, block, null, item, drops, - block.getState().getBehavior().getDropExp(), instaBreak, fastBreak); + this(player, block, null, item, drops, 0, instaBreak, fastBreak); } public BlockBreakEvent(Player player, Block block, Direction face, ItemStack item, ItemStack[] drops, int dropExp, boolean instaBreak, boolean fastBreak) { diff --git a/src/main/java/org/cloudburstmc/api/event/entity/EntityExplodeEvent.java b/src/main/java/org/cloudburstmc/api/event/entity/EntityExplodeEvent.java index b4d959c..555e36b 100644 --- a/src/main/java/org/cloudburstmc/api/event/entity/EntityExplodeEvent.java +++ b/src/main/java/org/cloudburstmc/api/event/entity/EntityExplodeEvent.java @@ -1,9 +1,9 @@ package org.cloudburstmc.api.event.entity; -import com.nukkitx.math.vector.Vector3f; import org.cloudburstmc.api.block.Block; import org.cloudburstmc.api.entity.Entity; import org.cloudburstmc.api.event.Cancellable; +import org.cloudburstmc.math.vector.Vector3f; import java.util.List; diff --git a/src/main/java/org/cloudburstmc/api/event/entity/EntityMotionEvent.java b/src/main/java/org/cloudburstmc/api/event/entity/EntityMotionEvent.java index 1fd4a0f..0c91109 100644 --- a/src/main/java/org/cloudburstmc/api/event/entity/EntityMotionEvent.java +++ b/src/main/java/org/cloudburstmc/api/event/entity/EntityMotionEvent.java @@ -1,8 +1,8 @@ package org.cloudburstmc.api.event.entity; -import com.nukkitx.math.vector.Vector3f; import org.cloudburstmc.api.entity.Entity; import org.cloudburstmc.api.event.Cancellable; +import org.cloudburstmc.math.vector.Vector3f; /** * author: MagicDroidX diff --git a/src/main/java/org/cloudburstmc/api/event/inventory/FurnaceSmeltEvent.java b/src/main/java/org/cloudburstmc/api/event/inventory/FurnaceSmeltEvent.java index e820fd4..c6a4b15 100644 --- a/src/main/java/org/cloudburstmc/api/event/inventory/FurnaceSmeltEvent.java +++ b/src/main/java/org/cloudburstmc/api/event/inventory/FurnaceSmeltEvent.java @@ -17,7 +17,7 @@ public final class FurnaceSmeltEvent extends BlockEvent implements Cancellable { public FurnaceSmeltEvent(Furnace furnace, ItemStack source, ItemStack result) { super(furnace.getBlock()); - this.source = source.withAmount(1); + this.source = source.withCount(1); this.result = result; this.furnace = furnace; } diff --git a/src/main/java/org/cloudburstmc/api/event/level/SpawnChangeEvent.java b/src/main/java/org/cloudburstmc/api/event/level/SpawnChangeEvent.java index 0a188c4..3f17137 100644 --- a/src/main/java/org/cloudburstmc/api/event/level/SpawnChangeEvent.java +++ b/src/main/java/org/cloudburstmc/api/event/level/SpawnChangeEvent.java @@ -1,7 +1,7 @@ package org.cloudburstmc.api.event.level; -import com.nukkitx.math.vector.Vector3f; import org.cloudburstmc.api.level.Level; +import org.cloudburstmc.math.vector.Vector3f; /** * author: MagicDroidX diff --git a/src/main/java/org/cloudburstmc/api/event/player/PlayerInteractEntityEvent.java b/src/main/java/org/cloudburstmc/api/event/player/PlayerInteractEntityEvent.java index 6b9ad8c..6de31ed 100644 --- a/src/main/java/org/cloudburstmc/api/event/player/PlayerInteractEntityEvent.java +++ b/src/main/java/org/cloudburstmc/api/event/player/PlayerInteractEntityEvent.java @@ -1,10 +1,10 @@ package org.cloudburstmc.api.event.player; -import com.nukkitx.math.vector.Vector3f; import org.cloudburstmc.api.entity.Entity; import org.cloudburstmc.api.event.Cancellable; import org.cloudburstmc.api.item.ItemStack; import org.cloudburstmc.api.player.Player; +import org.cloudburstmc.math.vector.Vector3f; /** * Created by CreeperFace on 1. 1. 2017. diff --git a/src/main/java/org/cloudburstmc/api/event/player/PlayerInteractEvent.java b/src/main/java/org/cloudburstmc/api/event/player/PlayerInteractEvent.java index d492782..bd50315 100644 --- a/src/main/java/org/cloudburstmc/api/event/player/PlayerInteractEvent.java +++ b/src/main/java/org/cloudburstmc/api/event/player/PlayerInteractEvent.java @@ -1,11 +1,11 @@ package org.cloudburstmc.api.event.player; -import com.nukkitx.math.vector.Vector3f; import org.cloudburstmc.api.block.Block; import org.cloudburstmc.api.event.Cancellable; import org.cloudburstmc.api.item.ItemStack; import org.cloudburstmc.api.player.Player; import org.cloudburstmc.api.util.Direction; +import org.cloudburstmc.math.vector.Vector3f; /** diff --git a/src/main/java/org/cloudburstmc/api/inventory/InventoryType.java b/src/main/java/org/cloudburstmc/api/inventory/InventoryType.java index 1f0dba5..625afac 100644 --- a/src/main/java/org/cloudburstmc/api/inventory/InventoryType.java +++ b/src/main/java/org/cloudburstmc/api/inventory/InventoryType.java @@ -8,7 +8,9 @@ public enum InventoryType { CHEST(27, "Chest"), ENDER_CHEST(27, "Ender Chest"), DOUBLE_CHEST(27 + 27, "Double Chest"), - PLAYER(41, "Player"), //36 CONTAINER, 4 ARMOR, 1 OFFHAND + PLAYER(41, "Player"), //36 CONTAINER + ARMOR(4, "Armor"), + HAND(1, "Hand"), FURNACE(3, "Furnace"), CRAFTING(5, "Crafting"), //4 CRAFTING slots, 1 RESULT WORKBENCH(10, "Crafting"), //9 CRAFTING slots, 1 RESULT diff --git a/src/main/java/org/cloudburstmc/api/inventory/WorkbenchInventory.java b/src/main/java/org/cloudburstmc/api/inventory/WorkbenchInventory.java new file mode 100644 index 0000000..7db66e2 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/inventory/WorkbenchInventory.java @@ -0,0 +1,4 @@ +package org.cloudburstmc.api.inventory; + +public interface WorkbenchInventory extends Inventory { +} diff --git a/src/main/java/org/cloudburstmc/api/inventory/screen/HudInventoryScreen.java b/src/main/java/org/cloudburstmc/api/inventory/screen/HudInventoryScreen.java new file mode 100644 index 0000000..c877efc --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/inventory/screen/HudInventoryScreen.java @@ -0,0 +1,8 @@ +package org.cloudburstmc.api.inventory.screen; + +import org.cloudburstmc.api.inventory.PlayerInventory; + +public interface HudInventoryScreen extends InventoryScreen { + + PlayerInventory getPlayerInventory(); +} diff --git a/src/main/java/org/cloudburstmc/api/inventory/screen/InventoryScreen.java b/src/main/java/org/cloudburstmc/api/inventory/screen/InventoryScreen.java new file mode 100644 index 0000000..1848ded --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/inventory/screen/InventoryScreen.java @@ -0,0 +1,20 @@ +package org.cloudburstmc.api.inventory.screen; + +import org.cloudburstmc.api.inventory.Inventory; +import org.cloudburstmc.api.item.ItemStack; + +import java.util.Collection; + +public interface InventoryScreen { + + ItemStack getItem(int slot); + + void setItem(int slot, ItemStack item); + + /** + * Retrieves the backing inventories for this screen. + * + * @return the backing inventories + */ + Collection getInventories(); +} diff --git a/src/main/java/org/cloudburstmc/api/inventory/screen/PlayerInventoryScreen.java b/src/main/java/org/cloudburstmc/api/inventory/screen/PlayerInventoryScreen.java new file mode 100644 index 0000000..31ff008 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/inventory/screen/PlayerInventoryScreen.java @@ -0,0 +1,13 @@ +package org.cloudburstmc.api.inventory.screen; + +import org.cloudburstmc.api.inventory.PlayerInventory; +import org.cloudburstmc.api.inventory.WorkbenchInventory; + +public interface PlayerInventoryScreen { + + PlayerInventory getPlayerInventory(); + + WorkbenchInventory getWorkbenchInventory(); + + +} diff --git a/src/main/java/org/cloudburstmc/api/inventory/view/InventoryView.java b/src/main/java/org/cloudburstmc/api/inventory/view/InventoryView.java new file mode 100644 index 0000000..50c953c --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/inventory/view/InventoryView.java @@ -0,0 +1,4 @@ +package org.cloudburstmc.api.inventory.view; + +public interface InventoryView { +} diff --git a/src/main/java/org/cloudburstmc/api/item/ItemBehaviors.java b/src/main/java/org/cloudburstmc/api/item/ItemBehaviors.java new file mode 100644 index 0000000..7b97830 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/ItemBehaviors.java @@ -0,0 +1,60 @@ +package org.cloudburstmc.api.item; + +import lombok.experimental.UtilityClass; +import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.block.behavior.BooleanBlockBehavior; +import org.cloudburstmc.api.data.BehaviorKey; +import org.cloudburstmc.api.data.DataKey; +import org.cloudburstmc.api.item.behavior.*; +import org.cloudburstmc.api.util.Identifier; +import org.cloudburstmc.api.util.behavior.FloatBehavior; +import org.cloudburstmc.api.util.behavior.IntBehavior; + +import java.util.Optional; + +@UtilityClass +public class ItemBehaviors { + + public static final BehaviorKey GET_MAX_STACK_SIZE = DataKey.behavior(Identifier.fromString("get_max_stack_size"), IntBehavior.class, IntBehavior.Executor.class); + + public static final BehaviorKey IS_DAMAGEABLE = DataKey.behavior(Identifier.fromString("is_damageable"), Boolean.class); + public static final BehaviorKey GET_MAX_DAMAGE = DataKey.behavior(Identifier.fromString("get_max_damage"), IntBehavior.class, IntBehavior.Executor.class); + + public static final BehaviorKey MINE_BLOCK = DataKey.behavior(Identifier.fromString("mine_block"), MineBlockBehavior.class, MineBlockBehavior.Executor.class); + + public static final BehaviorKey ON_DAMAGE = DataKey.behavior(Identifier.fromString("on_damage"), DamageItemBehavior.class, DamageItemBehavior.Executor.class); + + public static final BehaviorKey CAN_DESTROY = DataKey.behavior(Identifier.fromString("can_destroy"), BooleanBlockBehavior.class, BooleanBlockBehavior.Executor.class); + + public static final BehaviorKey GET_DESTROY_SPEED = DataKey.behavior(Identifier.fromString("get_destroy_speed"), DestroySpeedBehavior.class, DestroySpeedBehavior.Executor.class); + + public static final BehaviorKey GET_DESTROY_SPEED_BONUS = DataKey.behavior(Identifier.fromString("get_destroy_speed_bonus"), FloatItemBehavior.class, FloatItemBehavior.Executor.class); + + public static final BehaviorKey CAN_DESTROY_IN_CREATIVE = DataKey.behavior(Identifier.fromString("can_destroy_in_creative"), Boolean.class); + + public static final BehaviorKey GET_DAMAGE_CHANCE = DataKey.behavior(Identifier.fromString("get_damage_chance"), DamageChanceBehavior.class, DamageChanceBehavior.Executor.class); + + public static final BehaviorKey CAN_BE_USED = DataKey.behavior(Identifier.fromString("can_be_used"), BooleanItemBehavior.class, BooleanItemBehavior.Executor.class); + public static final BehaviorKey USE_ON = DataKey.behavior(Identifier.fromString("use_on"), UseOnBehavior.class, UseOnBehavior.Executor.class); + + public static final BehaviorKey GET_FUEL_DURATION = DataKey.behavior(Identifier.fromString("get_fuel_duration"), Float.class); + + public static final BehaviorKey GET_ATTACH_DAMAGE = DataKey.behavior(Identifier.fromString("get_attack_damage"), FloatBehavior.class, FloatBehavior.Executor.class); + + public static final BehaviorKey IS_TOOL = DataKey.behavior(Identifier.fromString("is_tool"), BooleanItemBehavior.class, BooleanItemBehavior.Executor.class); + + public static final BehaviorKey CAN_BE_PLACED = DataKey.behavior(Identifier.fromString("can_be_placed"), BooleanItemBehavior.class, BooleanItemBehavior.Executor.class); + + public static final BehaviorKey CAN_BE_PLACED_ON = DataKey.behavior(Identifier.fromString("can_be_placed_on"), CanBePlacedOnBehavior.class, CanBePlacedOnBehavior.Executor.class); + + public static final BehaviorKey>, GetItemBehavior.Executor>> GET_BLOCK = DataKey.behavior(Identifier.fromString("get_block"), GetItemBehavior.class, GetItemBehavior.Executor.class); + + public static final BehaviorKey ALLOW_OFFHAND = DataKey.behavior(Identifier.fromString("allow_offhand"), Boolean.class); + + public static final BehaviorKey CAN_BE_CHARGED = DataKey.behavior(Identifier.fromString("can_be_charged"), Boolean.class); + + public static final BehaviorKey CAN_BE_DEPLETED = DataKey.behavior(Identifier.fromString("can_be_depleted"), Boolean.class); + + public static final BehaviorKey GET_ATTACK_DAMAGE = DataKey.behavior(Identifier.fromString("get_attack_damage"), Integer.class); + +} diff --git a/src/main/java/org/cloudburstmc/api/item/ItemFactory.java b/src/main/java/org/cloudburstmc/api/item/ItemFactory.java deleted file mode 100644 index 1e50008..0000000 --- a/src/main/java/org/cloudburstmc/api/item/ItemFactory.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.cloudburstmc.api.item; - -import org.cloudburstmc.api.util.Identifier; - -@FunctionalInterface -public interface ItemFactory { - - ItemStack create(Identifier identifier); -} diff --git a/src/main/java/org/cloudburstmc/api/item/ItemKeys.java b/src/main/java/org/cloudburstmc/api/item/ItemKeys.java new file mode 100644 index 0000000..8eac561 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/ItemKeys.java @@ -0,0 +1,56 @@ +package org.cloudburstmc.api.item; + +import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.block.BlockType; +import org.cloudburstmc.api.data.DataKey; +import org.cloudburstmc.api.data.ListDataKey; +import org.cloudburstmc.api.data.MapDataKey; +import org.cloudburstmc.api.data.SimpleDataKey; +import org.cloudburstmc.api.enchantment.Enchantment; +import org.cloudburstmc.api.enchantment.EnchantmentType; +import org.cloudburstmc.api.entity.EntityType; +import org.cloudburstmc.api.item.data.Record; +import org.cloudburstmc.api.item.data.*; +import org.cloudburstmc.api.util.Identifier; +import org.cloudburstmc.api.util.data.DyeColor; +import org.cloudburstmc.api.util.data.FireworkData; +import org.cloudburstmc.api.util.data.TreeSpecies; + +public final class ItemKeys { + + public static final SimpleDataKey BLOCK_STATE = DataKey.simple(Identifier.fromString("block_state"), BlockState.class); + + public static final SimpleDataKey CUSTOM_NAME = DataKey.simple(Identifier.fromString("custom_name"), String.class); + + public static final ListDataKey CUSTOM_LORE = DataKey.list(Identifier.fromString("custom_lore"), String.class); + + public static final SimpleDataKey DAMAGE = DataKey.simple(Identifier.fromString("item_damage"), Integer.class); + + public static final SimpleDataKey UNBREAKABLE = DataKey.simple(Identifier.fromString("unbreakable"), Boolean.class); + + public static final SimpleDataKey COLOR = DataKey.simple(Identifier.fromString("dye_color"), DyeColor.class); + + public static final MapDataKey ENCHANTMENTS = DataKey.map(Identifier.fromString("enchantments"), EnchantmentType.class, Enchantment.class); + + public static final SimpleDataKey FIREWORK_DATA = DataKey.simple(Identifier.fromString("firework_data"), FireworkData.class); + + public static final SimpleDataKey BUCKET_DATA = DataKey.simple(Identifier.fromString("bucket_data"), Bucket.class); + + public static final ListDataKey CAN_DESTROY = DataKey.list(Identifier.fromString("can_destroy"), BlockType.class); + + public static final ListDataKey CAN_PLACE_ON = DataKey.list(Identifier.fromString("can_place_on"), BlockType.class); + + public static final SimpleDataKey SHIELD_BLOCKING_TICKS = DataKey.simple(Identifier.fromString("shield_blocking_ticks"), Long.class); + + public static final SimpleDataKey RECORD_TYPE = DataKey.simple(Identifier.fromString("record_type"), Record.class); + + public static final SimpleDataKey> SPAWN_EGG_TYPE = DataKey.simple(Identifier.fromString("spawn_egg_type"), EntityType.class); + + public static final SimpleDataKey TREE_SPECIES = DataKey.simple(Identifier.fromString("tree_species"), TreeSpecies.class); + + public static final SimpleDataKey BOOK_DATA = DataKey.simple(Identifier.fromString("book_data"), WrittenBook.class); + + public static final SimpleDataKey MAP_DATA = DataKey.simple(Identifier.fromString("map_data"), MapItem.class); + + public static final SimpleDataKey BANNER_DATA = DataKey.simple(Identifier.fromString("banner_data"), BannerData.class); +} diff --git a/src/main/java/org/cloudburstmc/api/item/ItemStack.java b/src/main/java/org/cloudburstmc/api/item/ItemStack.java index 80d7b98..5068043 100644 --- a/src/main/java/org/cloudburstmc/api/item/ItemStack.java +++ b/src/main/java/org/cloudburstmc/api/item/ItemStack.java @@ -1,156 +1,153 @@ package org.cloudburstmc.api.item; -import com.nukkitx.math.GenericMath; -import org.checkerframework.checker.nullness.qual.NonNull; +import com.google.common.collect.ImmutableMap; +import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.nullness.qual.Nullable; import org.cloudburstmc.api.block.BlockState; -import org.cloudburstmc.api.enchantment.EnchantmentInstance; -import org.cloudburstmc.api.enchantment.EnchantmentType; -import org.cloudburstmc.api.item.behavior.ItemBehavior; -import org.cloudburstmc.api.registry.ItemRegistry; -import org.cloudburstmc.api.util.Identifier; - -import javax.inject.Inject; -import java.util.Collection; -import java.util.List; +import org.cloudburstmc.api.block.BlockType; +import org.cloudburstmc.api.block.BlockTypes; +import org.cloudburstmc.api.data.DataKey; +import org.cloudburstmc.api.data.DataStore; + +import java.util.Collections; import java.util.Map; +import java.util.Optional; -@NonNull -public interface ItemStack extends Comparable { +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; - @Inject - ItemRegistry registry = null; //does that work? +public final class ItemStack implements DataStore, Comparable { - ItemType getType(); + public static final ItemStack EMPTY = ItemStack.builder(BlockTypes.AIR).build(); - int getAmount(); + private final ItemType type; + private final int count; + private final ImmutableMap, ?> metadata; - default boolean isNull() { - return true; + ItemStack(ItemType type, int count, Map, ?> metadata) { + this.type = type; + this.count = count; + this.metadata = ImmutableMap.copyOf(metadata); } - String getName(); - - default boolean hasName() { - return getName() != null; + public static ItemStackBuilder builder() { + return new ItemStackBuilder(null, 1, Collections.emptyMap()); } - List getLore(); - - default boolean hasEnchantments() { - return !getEnchantments().isEmpty(); + public static ItemStackBuilder builder(BlockState state) { + return new ItemStackBuilder(state.getType(), 1, Collections.emptyMap()) + .data(ItemKeys.BLOCK_STATE, state); } - Map getEnchantments(); - - default EnchantmentInstance getEnchantment(EnchantmentType enchantment) { - for (EnchantmentInstance ench : getEnchantments().values()) { - if (ench.getType() == enchantment) { - return ench; - } - } - - return null; + public static ItemStackBuilder builder(ItemType type) { + return new ItemStackBuilder(type, 1, Collections.emptyMap()); } - Collection getCanDestroy(); - - default boolean canDestroy(BlockState state) { - return getCanDestroy().contains(state.getType().getId()); + public static ItemStack from(BlockState state) { + return from(state, 1); } - Collection getCanPlaceOn(); - - default boolean canPlaceOn(BlockState state) { - return getCanPlaceOn().contains(state.getType().getId()); + public static ItemStack from(BlockState state, @NonNegative int amount) { + checkNotNull(state, "state"); + checkArgument(amount > 0, "Amount cannot be negative"); + return new ItemStack(state.getType(), amount, Map.of(ItemKeys.BLOCK_STATE, state)); } - default T getMetadata(Class metadataClass) { - return getMetadata(metadataClass, null); + public static ItemStack from(ItemType type) { + return from(type, 1); } - T getMetadata(Class metadataClass, T defaultValue); - - boolean hasMetadata(Class metadataClass); - - boolean hasTag(); - - ItemStackBuilder toBuilder(); - -// RecipeItemStackBuilder toRecipeBuilder(); - - ItemBehavior getBehavior(); - - boolean isMergeable(@NonNull ItemStack itemStack); + public static ItemStack from(ItemType type, @NonNegative int amount) { + checkNotNull(type, "type"); + checkArgument(amount > 0, "Amount cannot be negative"); + return new ItemStack(type, amount, Collections.emptyMap()); + } - boolean equals(@Nullable ItemStack item); + public ItemType getType() { + return type; + } - default boolean isFull() { - return getAmount() >= getType().getMaximumStackSize(); + public int getCount() { + return count; } - default boolean equals(@Nullable ItemStack other, boolean checkAmount) { - return equals(other, checkAmount, true); + public ItemStackBuilder toBuilder() { + return new ItemStackBuilder(this.type, this.count, this.metadata); } - boolean equals(@Nullable ItemStack other, boolean checkAmount, boolean checkData); + public ItemStack decreaseCount() { + return withCount(-1); + } - default ItemStack decrementAmount() { - return decrementAmount(1); + public ItemStack decreaseCount(int count) { + return withCount(-count); } - default ItemStack decrementAmount(int amount) { - return withAmount(getAmount() - amount); + public ItemStack increaseCount() { + return addCount(1); } - default ItemStack incrementAmount() { - return incrementAmount(1); + public ItemStack increaseCount(int count) { + return addCount(count); } - default ItemStack incrementAmount(int amount) { - return withAmount(getAmount() + amount); + public ItemStack addCount(int delta) { + return withCount(this.count + delta); } - default ItemStack withAmount(int amount) { - if (this.getAmount() == amount) { + public ItemStack withCount(int amount) { + if (this.count == amount) { return this; } - return toBuilder().amount(GenericMath.clamp(amount, 0, getBehavior().getMaxStackSize(this))).build(); + return toBuilder().amount(amount).build(); } - default ItemStack withEnchantment(EnchantmentInstance enchantment) { - return toBuilder().addEnchantment(enchantment).build(); + @SuppressWarnings("unchecked") + @Override + public T get(DataKey key) { + checkNotNull(key, "key"); + Object data = metadata.get(key); + return data == null ? key.getDefaultValue() : (T) data; } - ItemStack withData(Object data); - - ItemStack withData(Class metadataClass, Object data); - - default BlockState getBlockState() { - throw new UnsupportedOperationException("Item " + this.getType() + " cannot be converted to a block state"); + public Optional getBlockState() { + return Optional.ofNullable(this.isBlock() ? this.get(ItemKeys.BLOCK_STATE) : null); } -/* static ItemStack get(BlockState state) { // Do we need get methods in ItemStack? - return get(state, 1); + public ImmutableMap, ?> getAllMetadata() { + return metadata; } - static ItemStack get(BlockState state, int amount) { - return this.registry.getItem(state, amount); - } + @Nullable + public BlockState getEnsuringBlockState() { + if(!this.isBlock()) { + throw new NullPointerException("Current Item isn't a block so it can't have a BlockState."); + } - static ItemStack get(ItemType type) { - return get(type, 1); + return this.get(ItemKeys.BLOCK_STATE); } - static ItemStack get(ItemType type, int amount, Object... metadata) { - return ItemRegistry.get().getItem(type, amount, metadata); - }*/ + public boolean isBlock() { + return type instanceof BlockType; + } @Override - default int compareTo(ItemStack other) { + public int compareTo(ItemStack other) { if (other.getType().equals(this.getType())) { - return this.getAmount() - other.getAmount(); + return this.getCount() - other.getCount(); } return this.getType().getId().compareTo(other.getType().getId()); } + + public boolean isSimilar(ItemStack other) { + return this.getType().equals(other.getType()); + } + + public boolean isSimilarMetadata(ItemStack other) { + return getAllMetadata().equals(other.getAllMetadata()); + } + + public boolean isMergeable(ItemStack other) { + return isSimilar(other) && isSimilarMetadata(other); + } } diff --git a/src/main/java/org/cloudburstmc/api/item/ItemStackBuilder.java b/src/main/java/org/cloudburstmc/api/item/ItemStackBuilder.java index a9ed16e..4683823 100644 --- a/src/main/java/org/cloudburstmc/api/item/ItemStackBuilder.java +++ b/src/main/java/org/cloudburstmc/api/item/ItemStackBuilder.java @@ -1,63 +1,67 @@ package org.cloudburstmc.api.item; +import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.block.BlockType; +import org.cloudburstmc.api.data.DataKey; import org.cloudburstmc.api.enchantment.EnchantmentInstance; import org.cloudburstmc.api.enchantment.EnchantmentType; import org.cloudburstmc.api.util.Identifier; import java.util.Collection; +import java.util.IdentityHashMap; import java.util.List; - -public interface ItemStackBuilder { - - ItemStackBuilder itemType(@NonNull ItemType itemType); - - ItemStackBuilder blockState(BlockState blockState); - - ItemStackBuilder amount(int amount); - - ItemStackBuilder name(@NonNull String name); - - ItemStackBuilder clearName(); - - ItemStackBuilder lore(List lines); - - ItemStackBuilder clearLore(); - - ItemStackBuilder itemData(Object data); - - ItemStackBuilder itemData(Class metadataClass, Object data); - - ItemStackBuilder clearData(); - - ItemStackBuilder clearData(Class metadataClass); - - ItemStackBuilder addEnchantment(EnchantmentInstance enchantment); - - ItemStackBuilder addEnchantments(Collection enchantmentInstanceCollection); - - ItemStackBuilder clearEnchantments(); - - ItemStackBuilder removeEnchantment(EnchantmentType enchantment); - - ItemStackBuilder removeEnchantments(Collection enchantments); - - ItemStackBuilder addCanPlaceOn(Identifier id); - - ItemStackBuilder addCanPlaceOn(ItemType type); - - ItemStackBuilder removeCanPlaceOn(Identifier id); - - ItemStackBuilder clearCanPlaceOn(); - - ItemStackBuilder addCanDestroy(Identifier id); - - ItemStackBuilder addCanDestroy(ItemType type); - - ItemStackBuilder removeCanDestroy(Identifier id); - - ItemStackBuilder clearCanDestroy(); - - ItemStack build(); +import java.util.Map; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.cloudburstmc.api.item.ItemKeys.BLOCK_STATE; + +public final class ItemStackBuilder { + + private ItemType itemType; + private int amount; + private final Map, Object> metadata; + + ItemStackBuilder(ItemType itemType, int amount, Map, ?> metadata) { + this.itemType = itemType; + this.amount = amount; + this.metadata = new IdentityHashMap<>(metadata); + } + + public ItemStackBuilder itemType(@NonNull ItemType itemType) { + checkNotNull(itemType, "itemType is null"); + this.itemType = itemType; + return this; + } + + public ItemStackBuilder amount(@NonNegative int amount) { + checkArgument(amount > 0, "amount cannot be less than zero"); + this.amount = amount; + return this; + } + + public ItemStackBuilder clearData() { + this.metadata.clear(); + return this; + } + + public ItemStackBuilder data(DataKey key, M value) { + checkNotNull(key, "key"); + checkNotNull(value, "value"); + this.metadata.put(key, key.getImmutableFunction().apply(value)); + return this; + } + + public ItemStack build() { + checkNotNull(this.itemType, "itemType is null"); + checkArgument(this.amount > 0, "amount cannot be less than zero"); + if((this.itemType instanceof BlockType) && !this.metadata.containsKey(BLOCK_STATE)) { + this.metadata.put(BLOCK_STATE, ((BlockType) this.itemType).getDefaultState()); + } +// checkArgument(!(this.itemType instanceof BlockType) || this.metadata.containsKey(BLOCK_STATE), +// "ItemStack with a BlockType requires BlockState data"); + return new ItemStack(itemType, amount, metadata); + } } diff --git a/src/main/java/org/cloudburstmc/api/item/ItemStacks.java b/src/main/java/org/cloudburstmc/api/item/ItemStacks.java deleted file mode 100644 index 58984b8..0000000 --- a/src/main/java/org/cloudburstmc/api/item/ItemStacks.java +++ /dev/null @@ -1,496 +0,0 @@ -package org.cloudburstmc.api.item; - -import lombok.experimental.UtilityClass; - -@UtilityClass -public class ItemStacks { -/* // TODO these can't be used until BlockTypes.createItem() is implemented - public static final ItemStack AIR = BlockTypes.AIR.createItem(); - //blocks - public static final ItemStack ACTIVATOR_RAIL = BlockTypes.ACTIVATOR_RAIL.createItem(); - public static final ItemStack ALLOW = BlockTypes.ALLOW.createItem(); - public static final ItemStack ANCIENT_DEBRIS = BlockTypes.ANCIENT_DEBRIS.createItem(); - public static final ItemStack ANVIL = BlockTypes.ANVIL.createItem(); - public static final ItemStack BAMBOO = BlockTypes.BAMBOO.createItem(); - public static final ItemStack BAMBOO_SAPLING = BlockTypes.BAMBOO_SAPLING.createItem(); - public static final ItemStack BARREL = BlockTypes.BARREL.createItem(); - public static final ItemStack BARRIER = BlockTypes.BARRIER.createItem(); - public static final ItemStack BASALT = BlockTypes.BASALT.createItem(); - public static final ItemStack BEACON = BlockTypes.BEACON.createItem(); - public static final ItemStack BED = BlockTypes.BED.createItem(); - public static final ItemStack BEDROCK = BlockTypes.BEDROCK.createItem(); - public static final ItemStack BEEHIVE = BlockTypes.BEEHIVE.createItem(); - public static final ItemStack BEETROOT = BlockTypes.BEETROOT.createItem(); - public static final ItemStack BEE_NEST = BlockTypes.BEE_NEST.createItem(); - public static final ItemStack BELL = BlockTypes.BELL.createItem(); - public static final ItemStack BLACKSTONE = BlockTypes.BLACKSTONE.createItem(); - public static final ItemStack BLAST_FURNACE = BlockTypes.BLAST_FURNACE.createItem(); - public static final ItemStack BLUE_ICE = BlockTypes.BLUE_ICE.createItem(); - public static final ItemStack BONE_BLOCK = BlockTypes.BONE_BLOCK.createItem(); - public static final ItemStack BOOKSHELF = BlockTypes.BOOKSHELF.createItem(); - public static final ItemStack BORDER_BLOCK = BlockTypes.BORDER_BLOCK.createItem(); - public static final ItemStack BREWING_STAND = BlockTypes.BREWING_STAND.createItem(); - public static final ItemStack BRICK_BLOCK = BlockTypes.BRICK_BLOCK.createItem(); - public static final ItemStack BROWN_MUSHROOM = BlockTypes.BROWN_MUSHROOM.createItem(); - public static final ItemStack BROWN_MUSHROOM_BLOCK = BlockTypes.BROWN_MUSHROOM_BLOCK.createItem(); - public static final ItemStack BUBBLE_COLUMN = BlockTypes.BUBBLE_COLUMN.createItem(); - public static final ItemStack CACTUS = BlockTypes.CACTUS.createItem(); - public static final ItemStack CAKE = BlockTypes.CAKE.createItem(); - public static final ItemStack CAMERA = BlockTypes.CAMERA.createItem(); - public static final ItemStack CAMPFIRE = BlockTypes.CAMPFIRE.createItem(); - public static final ItemStack CARPET = BlockTypes.CARPET.createItem(); - public static final ItemStack CARROTS = BlockTypes.CARROTS.createItem(); - public static final ItemStack CARTOGRAPHY_TABLE = BlockTypes.CARTOGRAPHY_TABLE.createItem(); - public static final ItemStack CARVED_PUMPKIN = BlockTypes.CARVED_PUMPKIN.createItem(); - public static final ItemStack CAULDRON = BlockTypes.CAULDRON.createItem(); - public static final ItemStack CHAIN = BlockTypes.CHAIN.createItem(); - public static final ItemStack CHAIN_COMMAND_BLOCK = BlockTypes.CHAIN_COMMAND_BLOCK.createItem(); - public static final ItemStack CHEMICAL_HEAT = BlockTypes.CHEMICAL_HEAT.createItem(); - public static final ItemStack CHEMISTRY_TABLE = BlockTypes.CHEMISTRY_TABLE.createItem(); - public static final ItemStack CHEST = BlockTypes.CHEST.createItem(); - public static final ItemStack CHISELED_POLISHED_BLACKSTONE = BlockTypes.CHISELED_POLISHED_BLACKSTONE.createItem(); - public static final ItemStack CHORUS_FLOWER = BlockTypes.CHORUS_FLOWER.createItem(); - public static final ItemStack CHORUS_PLANT = BlockTypes.CHORUS_PLANT.createItem(); - public static final ItemStack CLAY = BlockTypes.CLAY.createItem(); - public static final ItemStack COAL_BLOCK = BlockTypes.COAL_BLOCK.createItem(); - public static final ItemStack COAL_ORE = BlockTypes.COAL_ORE.createItem(); - public static final ItemStack COBBLESTONE = BlockTypes.COBBLESTONE.createItem(); - public static final ItemStack COCOA = BlockTypes.COCOA.createItem(); - public static final ItemStack COLORED_TORCH_BP = BlockTypes.COLORED_TORCH_BP.createItem(); - public static final ItemStack COLORED_TORCH_RG = BlockTypes.COLORED_TORCH_RG.createItem(); - public static final ItemStack COMMAND_BLOCK = BlockTypes.COMMAND_BLOCK.createItem(); - public static final ItemStack COMPARATOR = BlockTypes.COMPARATOR.createItem(); - public static final ItemStack COMPOSTER = BlockTypes.COMPOSTER.createItem(); - public static final ItemStack CONCRETE = BlockTypes.CONCRETE.createItem(); - public static final ItemStack CONCRETE_POWDER = BlockTypes.CONCRETE_POWDER.createItem(); - public static final ItemStack CONDUIT = BlockTypes.CONDUIT.createItem(); - public static final ItemStack CORAL = BlockTypes.CORAL.createItem(); - public static final ItemStack CORAL_BLOCK = BlockTypes.CORAL_BLOCK.createItem(); - public static final ItemStack CORAL_FAN = BlockTypes.CORAL_FAN.createItem(); - public static final ItemStack CORAL_FAN_DEAD = BlockTypes.CORAL_FAN_DEAD.createItem(); - public static final ItemStack CORAL_FAN_HANG = BlockTypes.CORAL_FAN_HANG.createItem(); - public static final ItemStack CRACKED_POLISHED_BLACKSTONE_BRICKS = BlockTypes.CRACKED_POLISHED_BLACKSTONE_BRICKS.createItem(); - public static final ItemStack CRAFTING_TABLE = BlockTypes.CRAFTING_TABLE.createItem(); - public static final ItemStack CRYING_OBSIDIAN = BlockTypes.CRYING_OBSIDIAN.createItem(); - public static final ItemStack DAYLIGHT_DETECTOR = BlockTypes.DAYLIGHT_DETECTOR.createItem(); - public static final ItemStack DAYLIGHT_DETECTOR_INVERTED = BlockTypes.DAYLIGHT_DETECTOR_INVERTED.createItem(); - public static final ItemStack DEADBUSH = BlockTypes.DEADBUSH.createItem(); - public static final ItemStack DENY = BlockTypes.DENY.createItem(); - public static final ItemStack DETECTOR_RAIL = BlockTypes.DETECTOR_RAIL.createItem(); - public static final ItemStack DIAMOND_BLOCK = BlockTypes.DIAMOND_BLOCK.createItem(); - public static final ItemStack DIAMOND_ORE = BlockTypes.DIAMOND_ORE.createItem(); - public static final ItemStack DIRT = BlockTypes.DIRT.createItem(); - public static final ItemStack DISPENSER = BlockTypes.DISPENSER.createItem(); - public static final ItemStack DOUBLE_PLANT = BlockTypes.DOUBLE_PLANT.createItem(); - public static final ItemStack DRAGON_EGG = BlockTypes.DRAGON_EGG.createItem(); - public static final ItemStack DRIED_KELP_BLOCK = BlockTypes.DRIED_KELP_BLOCK.createItem(); - public static final ItemStack DROPPER = BlockTypes.DROPPER.createItem(); - public static final ItemStack ELEMENT = BlockTypes.ELEMENT.createItem(); - public static final ItemStack EMERALD_BLOCK = BlockTypes.EMERALD_BLOCK.createItem(); - public static final ItemStack EMERALD_ORE = BlockTypes.EMERALD_ORE.createItem(); - public static final ItemStack ENCHANTING_TABLE = BlockTypes.ENCHANTING_TABLE.createItem(); - public static final ItemStack ENDER_CHEST = BlockTypes.ENDER_CHEST.createItem(); - public static final ItemStack END_BRICKS = BlockTypes.END_BRICKS.createItem(); - public static final ItemStack END_GATEWAY = BlockTypes.END_GATEWAY.createItem(); - public static final ItemStack END_PORTAL = BlockTypes.END_PORTAL.createItem(); - public static final ItemStack END_PORTAL_FRAME = BlockTypes.END_PORTAL_FRAME.createItem(); - public static final ItemStack END_ROD = BlockTypes.END_ROD.createItem(); - public static final ItemStack END_STONE = BlockTypes.END_STONE.createItem(); - public static final ItemStack FARMLAND = BlockTypes.FARMLAND.createItem(); - public static final ItemStack FIRE = BlockTypes.FIRE.createItem(); - public static final ItemStack FLETCHING_TABLE = BlockTypes.FLETCHING_TABLE.createItem(); - public static final ItemStack FLOWER = BlockTypes.FLOWER.createItem(); - public static final ItemStack FLOWER_POT = BlockTypes.FLOWER_POT.createItem(); - public static final ItemStack FLOWING_LAVA = BlockTypes.FLOWING_LAVA.createItem(); - public static final ItemStack FLOWING_WATER = BlockTypes.FLOWING_WATER.createItem(); - public static final ItemStack FRAME = BlockTypes.FRAME.createItem(); - public static final ItemStack FROSTED_ICE = BlockTypes.FROSTED_ICE.createItem(); - public static final ItemStack FURNACE = BlockTypes.FURNACE.createItem(); - public static final ItemStack GILDED_BLACKSTONE = BlockTypes.GILDED_BLACKSTONE.createItem(); - public static final ItemStack GLASS = BlockTypes.GLASS.createItem(); - public static final ItemStack GLASS_PANE = BlockTypes.GLASS_PANE.createItem(); - public static final ItemStack GLAZED_TERRACOTTA = BlockTypes.GLAZED_TERRACOTTA.createItem(); - public static final ItemStack GLOWING_OBSIDIAN = BlockTypes.GLOWING_OBSIDIAN.createItem(); - public static final ItemStack GLOWSTONE = BlockTypes.GLOWSTONE.createItem(); - public static final ItemStack GOLDEN_RAIL = BlockTypes.GOLDEN_RAIL.createItem(); - public static final ItemStack GOLD_BLOCK = BlockTypes.GOLD_BLOCK.createItem(); - public static final ItemStack GOLD_ORE = BlockTypes.GOLD_ORE.createItem(); - public static final ItemStack GRASS = BlockTypes.GRASS.createItem(); - public static final ItemStack GRASS_PATH = BlockTypes.GRASS_PATH.createItem(); - public static final ItemStack GRAVEL = BlockTypes.GRAVEL.createItem(); - public static final ItemStack GRINDSTONE = BlockTypes.GRINDSTONE.createItem(); - public static final ItemStack HARDENED_CLAY = BlockTypes.HARDENED_CLAY.createItem(); - public static final ItemStack HARD_GLASS = BlockTypes.HARD_GLASS.createItem(); - public static final ItemStack HARD_GLASS_PANE = BlockTypes.HARD_GLASS_PANE.createItem(); - public static final ItemStack HARD_STAINED_GLASS = BlockTypes.HARD_STAINED_GLASS.createItem(); - public static final ItemStack HARD_STAINED_GLASS_PANE = BlockTypes.HARD_STAINED_GLASS_PANE.createItem(); - public static final ItemStack HAY_BLOCK = BlockTypes.HAY_BLOCK.createItem(); - public static final ItemStack HEAVY_WEIGHTED_PRESSURE_PLATE = BlockTypes.HEAVY_WEIGHTED_PRESSURE_PLATE.createItem(); - public static final ItemStack HONEYCOMB_BLOCK = BlockTypes.HONEYCOMB_BLOCK.createItem(); - public static final ItemStack HONEY_BLOCK = BlockTypes.HONEY_BLOCK.createItem(); - public static final ItemStack HOPPER = BlockTypes.HOPPER.createItem(); - public static final ItemStack ICE = BlockTypes.ICE.createItem(); - public static final ItemStack INFO_UPDATE = BlockTypes.INFO_UPDATE.createItem(); - public static final ItemStack INFO_UPDATE2 = BlockTypes.INFO_UPDATE2.createItem(); - public static final ItemStack INVISIBLE_BEDROCK = BlockTypes.INVISIBLE_BEDROCK.createItem(); - public static final ItemStack IRON_BARS = BlockTypes.IRON_BARS.createItem(); - public static final ItemStack IRON_BLOCK = BlockTypes.IRON_BLOCK.createItem(); - public static final ItemStack IRON_DOOR = BlockTypes.IRON_DOOR.createItem(); - public static final ItemStack IRON_ORE = BlockTypes.IRON_ORE.createItem(); - public static final ItemStack IRON_TRAPDOOR = BlockTypes.IRON_TRAPDOOR.createItem(); - public static final ItemStack JIGSAW = BlockTypes.JIGSAW.createItem(); - public static final ItemStack JUKEBOX = BlockTypes.JUKEBOX.createItem(); - public static final ItemStack KELP = BlockTypes.KELP.createItem(); - public static final ItemStack LADDER = BlockTypes.LADDER.createItem(); - public static final ItemStack LANTERN = BlockTypes.LANTERN.createItem(); - public static final ItemStack LAPIS_BLOCK = BlockTypes.LAPIS_BLOCK.createItem(); - public static final ItemStack LAPIS_ORE = BlockTypes.LAPIS_ORE.createItem(); - public static final ItemStack LAVA = BlockTypes.LAVA.createItem(); - public static final ItemStack LEAVES = BlockTypes.LEAVES.createItem(); - public static final ItemStack LECTERN = BlockTypes.LECTERN.createItem(); - public static final ItemStack LEVER = BlockTypes.LEVER.createItem(); - public static final ItemStack LIGHT_BLOCK = BlockTypes.LIGHT_BLOCK.createItem(); - public static final ItemStack LIGHT_WEIGHTED_PRESSURE_PLATE = BlockTypes.LIGHT_WEIGHTED_PRESSURE_PLATE.createItem(); - public static final ItemStack LIT_PUMPKIN = BlockTypes.LIT_PUMPKIN.createItem(); - public static final ItemStack LODESTONE = BlockTypes.LODESTONE.createItem(); - public static final ItemStack LOG = BlockTypes.LOG.createItem(); - public static final ItemStack LOOM = BlockTypes.LOOM.createItem(); - public static final ItemStack MAGMA = BlockTypes.MAGMA.createItem(); - public static final ItemStack MELON_BLOCK = BlockTypes.MELON_BLOCK.createItem(); - public static final ItemStack MELON_STEM = BlockTypes.MELON_STEM.createItem(); - public static final ItemStack MOB_SPAWNER = BlockTypes.MOB_SPAWNER.createItem(); - public static final ItemStack MONSTER_EGG = BlockTypes.MONSTER_EGG.createItem(); - public static final ItemStack MOSSY_COBBLESTONE = BlockTypes.MOSSY_COBBLESTONE.createItem(); - public static final ItemStack MOVING_BLOCK = BlockTypes.MOVING_BLOCK.createItem(); - public static final ItemStack MYCELIUM = BlockTypes.MYCELIUM.createItem(); - public static final ItemStack NETHERITE_BLOCK = BlockTypes.NETHERITE_BLOCK.createItem(); - public static final ItemStack NETHERRACK = BlockTypes.NETHERRACK.createItem(); - public static final ItemStack NETHER_BRICK = BlockTypes.NETHER_BRICK.createItem(); - public static final ItemStack NETHER_BRICK_FENCE = BlockTypes.NETHER_BRICK_FENCE.createItem(); - public static final ItemStack NETHER_FUNGUS = BlockTypes.NETHER_FUNGUS.createItem(); - public static final ItemStack NETHER_GOLD_ORE = BlockTypes.NETHER_GOLD_ORE.createItem(); - public static final ItemStack NETHER_NYLIUM = BlockTypes.NETHER_NYLIUM.createItem(); - public static final ItemStack NETHER_REACTOR = BlockTypes.NETHER_REACTOR.createItem(); - public static final ItemStack NETHER_ROOTS = BlockTypes.NETHER_ROOTS.createItem(); - public static final ItemStack NETHER_SPROUTS = BlockTypes.NETHER_SPROUTS.createItem(); - public static final ItemStack NETHER_WART = BlockTypes.NETHER_WART.createItem(); - public static final ItemStack NETHER_WART_BLOCK = BlockTypes.NETHER_WART_BLOCK.createItem(); - public static final ItemStack NOTEBLOCK = BlockTypes.NOTEBLOCK.createItem(); - public static final ItemStack OBSERVER = BlockTypes.OBSERVER.createItem(); - public static final ItemStack OBSIDIAN = BlockTypes.OBSIDIAN.createItem(); - public static final ItemStack PACKED_ICE = BlockTypes.PACKED_ICE.createItem(); - public static final ItemStack PISTON = BlockTypes.PISTON.createItem(); - public static final ItemStack PISTON_ARM_COLLISION = BlockTypes.PISTON_ARM_COLLISION.createItem(); - public static final ItemStack PLANKS = BlockTypes.PLANKS.createItem(); - public static final ItemStack PODZOL = BlockTypes.PODZOL.createItem(); - public static final ItemStack POLISHED_BASALT = BlockTypes.POLISHED_BASALT.createItem(); - public static final ItemStack POLISHED_BLACKSTONE = BlockTypes.POLISHED_BLACKSTONE.createItem(); - public static final ItemStack POLISHED_BLACKSTONE_BRICKS = BlockTypes.POLISHED_BLACKSTONE_BRICKS.createItem(); - public static final ItemStack PORTAL = BlockTypes.PORTAL.createItem(); - public static final ItemStack POTATOES = BlockTypes.POTATOES.createItem(); - public static final ItemStack PRISMARINE = BlockTypes.PRISMARINE.createItem(); - public static final ItemStack PUMPKIN = BlockTypes.PUMPKIN.createItem(); - public static final ItemStack PUMPKIN_STEM = BlockTypes.PUMPKIN_STEM.createItem(); - public static final ItemStack PURPUR_BLOCK = BlockTypes.PURPUR_BLOCK.createItem(); - public static final ItemStack QUARTZ_BLOCK = BlockTypes.QUARTZ_BLOCK.createItem(); - public static final ItemStack QUARTZ_BRICKS = BlockTypes.QUARTZ_BRICKS.createItem(); - public static final ItemStack QUARTZ_ORE = BlockTypes.QUARTZ_ORE.createItem(); - public static final ItemStack RAIL = BlockTypes.RAIL.createItem(); - public static final ItemStack REDSTONE_BLOCK = BlockTypes.REDSTONE_BLOCK.createItem(); - public static final ItemStack REDSTONE_LAMP = BlockTypes.REDSTONE_LAMP.createItem(); - public static final ItemStack REDSTONE_ORE = BlockTypes.REDSTONE_ORE.createItem(); - public static final ItemStack REDSTONE_TORCH = BlockTypes.REDSTONE_TORCH.createItem(); - public static final ItemStack REDSTONE_WIRE = BlockTypes.REDSTONE_WIRE.createItem(); - public static final ItemStack RED_MUSHROOM = BlockTypes.RED_MUSHROOM.createItem(); - public static final ItemStack RED_MUSHROOM_BLOCK = BlockTypes.RED_MUSHROOM_BLOCK.createItem(); - public static final ItemStack RED_SANDSTONE = BlockTypes.RED_SANDSTONE.createItem(); - public static final ItemStack REEDS = BlockTypes.REEDS.createItem(); - public static final ItemStack REPEATER = BlockTypes.REPEATER.createItem(); - public static final ItemStack REPEATING_COMMAND_BLOCK = BlockTypes.REPEATING_COMMAND_BLOCK.createItem(); - public static final ItemStack RESERVED6 = BlockTypes.RESERVED6.createItem(); - public static final ItemStack RESPAWN_ANCHOR = BlockTypes.RESPAWN_ANCHOR.createItem(); - public static final ItemStack SAND = BlockTypes.SAND.createItem(); - public static final ItemStack SANDSTONE = BlockTypes.SANDSTONE.createItem(); - public static final ItemStack SAPLING = BlockTypes.SAPLING.createItem(); - public static final ItemStack SCAFFOLDING = BlockTypes.SCAFFOLDING.createItem(); - public static final ItemStack SEAGRASS = BlockTypes.SEAGRASS.createItem(); - public static final ItemStack SEA_LANTERN = BlockTypes.SEA_LANTERN.createItem(); - public static final ItemStack SEA_PICKLE = BlockTypes.SEA_PICKLE.createItem(); - public static final ItemStack SHROOMLIGHT = BlockTypes.SHROOMLIGHT.createItem(); - public static final ItemStack SHULKER_BOX = BlockTypes.SHULKER_BOX.createItem(); - public static final ItemStack SKULL = BlockTypes.SKULL.createItem(); - public static final ItemStack SLIME = BlockTypes.SLIME.createItem(); - public static final ItemStack SMITHING_TABLE = BlockTypes.SMITHING_TABLE.createItem(); - public static final ItemStack SMOKER = BlockTypes.SMOKER.createItem(); - public static final ItemStack SMOOTH_STONE = BlockTypes.SMOOTH_STONE.createItem(); - public static final ItemStack SNOW = BlockTypes.SNOW.createItem(); - public static final ItemStack SNOW_LAYER = BlockTypes.SNOW_LAYER.createItem(); - public static final ItemStack SOUL_FIRE = BlockTypes.SOUL_FIRE.createItem(); - public static final ItemStack SOUL_SAND = BlockTypes.SOUL_SAND.createItem(); - public static final ItemStack SOUL_SOIL = BlockTypes.SOUL_SOIL.createItem(); - public static final ItemStack SPONGE = BlockTypes.SPONGE.createItem(); - public static final ItemStack STAINED_GLASS = BlockTypes.STAINED_GLASS.createItem(); - public static final ItemStack STAINED_GLASS_PANE = BlockTypes.STAINED_GLASS_PANE.createItem(); - public static final ItemStack STAINED_HARDENED_CLAY = BlockTypes.STAINED_HARDENED_CLAY.createItem(); - public static final ItemStack STANDING_BANNER = BlockTypes.STANDING_BANNER.createItem(); - public static final ItemStack STANDING_SIGN = BlockTypes.STANDING_SIGN.createItem(); - public static final ItemStack STONE = BlockTypes.STONE.createItem(); - public static final ItemStack STONEBRICK = BlockTypes.STONEBRICK.createItem(); - public static final ItemStack STONECUTTER = BlockTypes.STONECUTTER.createItem(); - public static final ItemStack STONECUTTER_BLOCK = BlockTypes.STONECUTTER_BLOCK.createItem(); - public static final ItemStack STONE_BUTTON = BlockTypes.STONE_BUTTON.createItem(); - public static final ItemStack STONE_PRESSURE_PLATE = BlockTypes.STONE_PRESSURE_PLATE.createItem(); - public static final ItemStack STONE_SLAB = BlockTypes.STONE_SLAB.createItem(); - public static final ItemStack STONE_STAIRS = BlockTypes.STONE_STAIRS.createItem(); - public static final ItemStack STONE_WALL = BlockTypes.STONE_WALL.createItem(); - public static final ItemStack STRUCTURE_BLOCK = BlockTypes.STRUCTURE_BLOCK.createItem(); - public static final ItemStack STRUCTURE_VOID = BlockTypes.STRUCTURE_VOID.createItem(); - public static final ItemStack SWEET_BERRY_BUSH = BlockTypes.SWEET_BERRY_BUSH.createItem(); - public static final ItemStack TALL_GRASS = BlockTypes.TALL_GRASS.createItem(); - public static final ItemStack TARGET = BlockTypes.TARGET.createItem(); - public static final ItemStack TNT = BlockTypes.TNT.createItem(); - public static final ItemStack TORCH = BlockTypes.TORCH.createItem(); - public static final ItemStack TRAPPED_CHEST = BlockTypes.TRAPPED_CHEST.createItem(); - public static final ItemStack TRIPWIRE = BlockTypes.TRIPWIRE.createItem(); - public static final ItemStack TRIPWIRE_HOOK = BlockTypes.TRIPWIRE_HOOK.createItem(); - public static final ItemStack TURTLE_EGG = BlockTypes.TURTLE_EGG.createItem(); - public static final ItemStack TWISTING_VINES = BlockTypes.TWISTING_VINES.createItem(); - public static final ItemStack UNDERWATER_TORCH = BlockTypes.UNDERWATER_TORCH.createItem(); - public static final ItemStack UNDYED_SHULKER_BOX = BlockTypes.UNDYED_SHULKER_BOX.createItem(); - public static final ItemStack VINE = BlockTypes.VINE.createItem(); - public static final ItemStack WALL_BANNER = BlockTypes.WALL_BANNER.createItem(); - public static final ItemStack WALL_SIGN = BlockTypes.WALL_SIGN.createItem(); - public static final ItemStack WATER = BlockTypes.WATER.createItem(); - public static final ItemStack WATERLILY = BlockTypes.WATERLILY.createItem(); - public static final ItemStack WEB = BlockTypes.WEB.createItem(); - public static final ItemStack WEEPING_VINES = BlockTypes.WEEPING_VINES.createItem(); - public static final ItemStack WHEAT = BlockTypes.WHEAT.createItem(); - public static final ItemStack WITHER_ROSE = BlockTypes.WITHER_ROSE.createItem(); - public static final ItemStack WOOD = BlockTypes.WOOD.createItem(); - public static final ItemStack WOODEN_BUTTON = BlockTypes.WOODEN_BUTTON.createItem(); - public static final ItemStack WOODEN_DOOR = BlockTypes.WOODEN_DOOR.createItem(); - public static final ItemStack WOODEN_FENCE = BlockTypes.WOODEN_FENCE.createItem(); - public static final ItemStack WOODEN_FENCE_GATE = BlockTypes.WOODEN_FENCE_GATE.createItem(); - public static final ItemStack WOODEN_PRESSURE_PLATE = BlockTypes.WOODEN_PRESSURE_PLATE.createItem(); - public static final ItemStack WOODEN_SLAB = BlockTypes.WOODEN_SLAB.createItem(); - public static final ItemStack WOODEN_STAIRS = BlockTypes.WOODEN_STAIRS.createItem(); - public static final ItemStack WOODEN_TRAPDOOR = BlockTypes.WOODEN_TRAPDOOR.createItem(); - public static final ItemStack WOOL = BlockTypes.WOOL.createItem(); - - - //items - public static final ItemStack APPLE = ItemTypes.APPLE.createItem(); - public static final ItemStack APPLE_ENCHANTED = ItemTypes.APPLE_ENCHANTED.createItem(); - public static final ItemStack ARMOR_STAND = ItemTypes.ARMOR_STAND.createItem(); - public static final ItemStack ARROW = ItemTypes.ARROW.createItem(); - public static final ItemStack BAKED_POTATO = ItemTypes.BAKED_POTATO.createItem(); - public static final ItemStack BANNER = ItemTypes.BANNER.createItem(); - public static final ItemStack BED_ITEM = ItemTypes.BED.createItem(); - public static final ItemStack BEEF = ItemTypes.BEEF.createItem(); - public static final ItemStack BEETROOT_ITEM = ItemTypes.BEETROOT.createItem(); - public static final ItemStack BEETROOT_SEEDS = ItemTypes.BEETROOT_SEEDS.createItem(); - public static final ItemStack BEETROOT_SOUP = ItemTypes.BEETROOT_SOUP.createItem(); - public static final ItemStack BLAZE_POWDER = ItemTypes.BLAZE_POWDER.createItem(); - public static final ItemStack BLAZE_ROD = ItemTypes.BLAZE_ROD.createItem(); - public static final ItemStack BOARD = ItemTypes.BOARD.createItem(); - public static final ItemStack BOAT = ItemTypes.BOAT.createItem(); - public static final ItemStack BONE = ItemTypes.BONE.createItem(); - public static final ItemStack BOOK = ItemTypes.BOOK.createItem(); - public static final ItemStack BOW = ItemTypes.BOW.createItem(); - public static final ItemStack BOWL = ItemTypes.BOWL.createItem(); - public static final ItemStack BREAD = ItemTypes.BREAD.createItem(); - public static final ItemStack BREWING_STAND_ITEM = ItemTypes.BREWING_STAND.createItem(); - public static final ItemStack BRICK = ItemTypes.BRICK.createItem(); - public static final ItemStack BUCKET = ItemTypes.BUCKET.createItem(); - public static final ItemStack CAKE_ITEM = ItemTypes.CAKE.createItem(); - public static final ItemStack CAMERA_ITEM = ItemTypes.CAMERA.createItem(); - public static final ItemStack CAMPFIRE_ITEM = ItemTypes.CAMPFIRE.createItem(); - public static final ItemStack CARROT = ItemTypes.CARROT.createItem(); - public static final ItemStack CARROT_ON_A_STICK = ItemTypes.CARROT_ON_A_STICK.createItem(); - public static final ItemStack CAULDRON_ITEM = ItemTypes.CAULDRON.createItem(); - public static final ItemStack CHAINMAIL_BOOTS = ItemTypes.CHAINMAIL_BOOTS.createItem(); - public static final ItemStack CHAINMAIL_CHESTPLATE = ItemTypes.CHAINMAIL_CHESTPLATE.createItem(); - public static final ItemStack CHAINMAIL_HELMET = ItemTypes.CHAINMAIL_HELMET.createItem(); - public static final ItemStack CHAINMAIL_LEGGINGS = ItemTypes.CHAINMAIL_LEGGINGS.createItem(); - public static final ItemStack CHEST_MINECART = ItemTypes.CHEST_MINECART.createItem(); - public static final ItemStack CHICKEN = ItemTypes.CHICKEN.createItem(); - public static final ItemStack CHORUS_FRUIT = ItemTypes.CHORUS_FRUIT.createItem(); - public static final ItemStack CHORUS_FRUIT_POPPED = ItemTypes.CHORUS_FRUIT_POPPED.createItem(); - public static final ItemStack CLAY_BALL = ItemTypes.CLAY_BALL.createItem(); - public static final ItemStack CLOCK = ItemTypes.CLOCK.createItem(); - public static final ItemStack CLOWNFISH = ItemTypes.CLOWNFISH.createItem(); - public static final ItemStack COAL = ItemTypes.COAL.createItem(); - public static final ItemStack COMMAND_BLOCK_MINECART = ItemTypes.COMMAND_BLOCK_MINECART.createItem(); - public static final ItemStack COMPARATOR_ITEM = ItemTypes.COMPARATOR.createItem(); - public static final ItemStack COMPASS = ItemTypes.COMPASS.createItem(); - public static final ItemStack COOKED_BEEF = ItemTypes.COOKED_BEEF.createItem(); - public static final ItemStack COOKED_CHICKEN = ItemTypes.COOKED_CHICKEN.createItem(); - public static final ItemStack COOKED_FISH = ItemTypes.COOKED_FISH.createItem(); - public static final ItemStack COOKED_PORKCHOP = ItemTypes.COOKED_PORKCHOP.createItem(); - public static final ItemStack COOKED_RABBIT = ItemTypes.COOKED_RABBIT.createItem(); - public static final ItemStack COOKED_SALMON = ItemTypes.COOKED_SALMON.createItem(); - public static final ItemStack COOKIE = ItemTypes.COOKIE.createItem(); - public static final ItemStack CROSSBOW = ItemTypes.CROSSBOW.createItem(); - public static final ItemStack DIAMOND = ItemTypes.DIAMOND.createItem(); - public static final ItemStack DIAMOND_AXE = ItemTypes.DIAMOND_AXE.createItem(); - public static final ItemStack DIAMOND_BOOTS = ItemTypes.DIAMOND_BOOTS.createItem(); - public static final ItemStack DIAMOND_CHESTPLATE = ItemTypes.DIAMOND_CHESTPLATE.createItem(); - public static final ItemStack DIAMOND_HELMET = ItemTypes.DIAMOND_HELMET.createItem(); - public static final ItemStack DIAMOND_HOE = ItemTypes.DIAMOND_HOE.createItem(); - public static final ItemStack DIAMOND_LEGGINGS = ItemTypes.DIAMOND_LEGGINGS.createItem(); - public static final ItemStack DIAMOND_PICKAXE = ItemTypes.DIAMOND_PICKAXE.createItem(); - public static final ItemStack DIAMOND_SHOVEL = ItemTypes.DIAMOND_SHOVEL.createItem(); - public static final ItemStack DIAMOND_SWORD = ItemTypes.DIAMOND_SWORD.createItem(); - public static final ItemStack DRAGON_BREATH = ItemTypes.DRAGON_BREATH.createItem(); - public static final ItemStack DRIED_KELP = ItemTypes.DRIED_KELP.createItem(); - public static final ItemStack DYE = ItemTypes.DYE.createItem(); - public static final ItemStack EGG = ItemTypes.EGG.createItem(); - public static final ItemStack ELYTRA = ItemTypes.ELYTRA.createItem(); - public static final ItemStack EMERALD = ItemTypes.EMERALD.createItem(); - public static final ItemStack EMPTY_MAP = ItemTypes.EMPTY_MAP.createItem(); - public static final ItemStack ENCHANTED_BOOK = ItemTypes.ENCHANTED_BOOK.createItem(); - public static final ItemStack ENDER_EYE = ItemTypes.ENDER_EYE.createItem(); - public static final ItemStack ENDER_PEARL = ItemTypes.ENDER_PEARL.createItem(); - public static final ItemStack END_CRYSTAL = ItemTypes.END_CRYSTAL.createItem(); - public static final ItemStack EXPERIENCE_BOTTLE = ItemTypes.EXPERIENCE_BOTTLE.createItem(); - public static final ItemStack FEATHER = ItemTypes.FEATHER.createItem(); - public static final ItemStack FERMENTED_SPIDER_EYE = ItemTypes.FERMENTED_SPIDER_EYE.createItem(); - public static final ItemStack FIREBALL = ItemTypes.FIREBALL.createItem(); - public static final ItemStack FIREWORKS = ItemTypes.FIREWORKS.createItem(); - public static final ItemStack FIREWORKS_CHARGE = ItemTypes.FIREWORKS_CHARGE.createItem(); - public static final ItemStack FISH = ItemTypes.FISH.createItem(); - public static final ItemStack FISHING_ROD = ItemTypes.FISHING_ROD.createItem(); - public static final ItemStack FLINT = ItemTypes.FLINT.createItem(); - public static final ItemStack FLINT_AND_STEEL = ItemTypes.FLINT_AND_STEEL.createItem(); - public static final ItemStack FLOWER_POT_ITEM = ItemTypes.FLOWER_POT.createItem(); - public static final ItemStack FRAME_ITEM = ItemTypes.FRAME.createItem(); - public static final ItemStack GHAST_TEAR = ItemTypes.GHAST_TEAR.createItem(); - public static final ItemStack GLASS_BOTTLE = ItemTypes.GLASS_BOTTLE.createItem(); - public static final ItemStack GLOWSTONE_DUST = ItemTypes.GLOWSTONE_DUST.createItem(); - public static final ItemStack GOLDEN_APPLE = ItemTypes.GOLDEN_APPLE.createItem(); - public static final ItemStack GOLDEN_AXE = ItemTypes.GOLDEN_AXE.createItem(); - public static final ItemStack GOLDEN_BOOTS = ItemTypes.GOLDEN_BOOTS.createItem(); - public static final ItemStack GOLDEN_CARROT = ItemTypes.GOLDEN_CARROT.createItem(); - public static final ItemStack GOLDEN_CHESTPLATE = ItemTypes.GOLDEN_CHESTPLATE.createItem(); - public static final ItemStack GOLDEN_HELMET = ItemTypes.GOLDEN_HELMET.createItem(); - public static final ItemStack GOLDEN_HOE = ItemTypes.GOLDEN_HOE.createItem(); - public static final ItemStack GOLDEN_LEGGINGS = ItemTypes.GOLDEN_LEGGINGS.createItem(); - public static final ItemStack GOLDEN_PICKAXE = ItemTypes.GOLDEN_PICKAXE.createItem(); - public static final ItemStack GOLDEN_SHOVEL = ItemTypes.GOLDEN_SHOVEL.createItem(); - public static final ItemStack GOLDEN_SWORD = ItemTypes.GOLDEN_SWORD.createItem(); - public static final ItemStack GOLD_INGOT = ItemTypes.GOLD_INGOT.createItem(); - public static final ItemStack GOLD_NUGGET = ItemTypes.GOLD_NUGGET.createItem(); - public static final ItemStack GUNPOWDER = ItemTypes.GUNPOWDER.createItem(); - public static final ItemStack HEART_OF_THE_SEA = ItemTypes.HEART_OF_THE_SEA.createItem(); - public static final ItemStack HONEYCOMB = ItemTypes.HONEYCOMB.createItem(); - public static final ItemStack HONEY_BOTTLE = ItemTypes.HONEY_BOTTLE.createItem(); - public static final ItemStack HOPPER_ITEM = ItemTypes.HOPPER.createItem(); - public static final ItemStack HOPPER_MINECART = ItemTypes.HOPPER_MINECART.createItem(); - public static final ItemStack HORSE_ARMOR_DIAMOND = ItemTypes.HORSE_ARMOR_DIAMOND.createItem(); - public static final ItemStack HORSE_ARMOR_GOLD = ItemTypes.HORSE_ARMOR_GOLD.createItem(); - public static final ItemStack HORSE_ARMOR_IRON = ItemTypes.HORSE_ARMOR_IRON.createItem(); - public static final ItemStack HORSE_ARMOR_LEATHER = ItemTypes.HORSE_ARMOR_LEATHER.createItem(); - public static final ItemStack IRON_AXE = ItemTypes.IRON_AXE.createItem(); - public static final ItemStack IRON_BOOTS = ItemTypes.IRON_BOOTS.createItem(); - public static final ItemStack IRON_CHESTPLATE = ItemTypes.IRON_CHESTPLATE.createItem(); - public static final ItemStack IRON_DOOR_ITEM = ItemTypes.IRON_DOOR.createItem(); - public static final ItemStack IRON_HELMET = ItemTypes.IRON_HELMET.createItem(); - public static final ItemStack IRON_HOE = ItemTypes.IRON_HOE.createItem(); - public static final ItemStack IRON_INGOT = ItemTypes.IRON_INGOT.createItem(); - public static final ItemStack IRON_LEGGINGS = ItemTypes.IRON_LEGGINGS.createItem(); - public static final ItemStack IRON_NUGGET = ItemTypes.IRON_NUGGET.createItem(); - public static final ItemStack IRON_PICKAXE = ItemTypes.IRON_PICKAXE.createItem(); - public static final ItemStack IRON_SHOVEL = ItemTypes.IRON_SHOVEL.createItem(); - public static final ItemStack IRON_SWORD = ItemTypes.IRON_SWORD.createItem(); - public static final ItemStack KELP_ITEM = ItemTypes.KELP.createItem(); - public static final ItemStack LEAD = ItemTypes.LEAD.createItem(); - public static final ItemStack LEATHER = ItemTypes.LEATHER.createItem(); - public static final ItemStack LEATHER_BOOTS = ItemTypes.LEATHER_BOOTS.createItem(); - public static final ItemStack LEATHER_CHESTPLATE = ItemTypes.LEATHER_CHESTPLATE.createItem(); - public static final ItemStack LEATHER_HELMET = ItemTypes.LEATHER_HELMET.createItem(); - public static final ItemStack LEATHER_LEGGINGS = ItemTypes.LEATHER_LEGGINGS.createItem(); - public static final ItemStack LINGERING_POTION = ItemTypes.LINGERING_POTION.createItem(); - public static final ItemStack MAGMA_CREAM = ItemTypes.MAGMA_CREAM.createItem(); - public static final ItemStack MAP = ItemTypes.MAP.createItem(); - public static final ItemStack MELON = ItemTypes.MELON.createItem(); - public static final ItemStack MELON_SEEDS = ItemTypes.MELON_SEEDS.createItem(); - public static final ItemStack MINECART = ItemTypes.MINECART.createItem(); - public static final ItemStack MUSHROOM_STEW = ItemTypes.MUSHROOM_STEW.createItem(); - public static final ItemStack MUTTON_COOKED = ItemTypes.MUTTON_COOKED.createItem(); - public static final ItemStack MUTTON_RAW = ItemTypes.MUTTON_RAW.createItem(); - public static final ItemStack NAME_TAG = ItemTypes.NAME_TAG.createItem(); - public static final ItemStack NAUTILUS_SHELL = ItemTypes.NAUTILUS_SHELL.createItem(); - public static final ItemStack NETHERBRICK = ItemTypes.NETHERBRICK.createItem(); - public static final ItemStack NETHERITE_AXE = ItemTypes.NETHERITE_AXE.createItem(); - public static final ItemStack NETHERITE_BOOTS = ItemTypes.NETHERITE_BOOTS.createItem(); - public static final ItemStack NETHERITE_CHESTPLATE = ItemTypes.NETHERITE_CHESTPLATE.createItem(); - public static final ItemStack NETHERITE_HELMET = ItemTypes.NETHERITE_HELMET.createItem(); - public static final ItemStack NETHERITE_HOE = ItemTypes.NETHERITE_HOE.createItem(); - public static final ItemStack NETHERITE_LEGGINGS = ItemTypes.NETHERITE_LEGGINGS.createItem(); - public static final ItemStack NETHERITE_PICKAXE = ItemTypes.NETHERITE_PICKAXE.createItem(); - public static final ItemStack NETHERITE_SHOVEL = ItemTypes.NETHERITE_SHOVEL.createItem(); - public static final ItemStack NETHERITE_SWORD = ItemTypes.NETHERITE_SWORD.createItem(); - public static final ItemStack NETHER_STAR = ItemTypes.NETHER_STAR.createItem(); - public static final ItemStack NETHER_WART_ITEM = ItemTypes.NETHER_WART.createItem(); - public static final ItemStack PAINTING = ItemTypes.PAINTING.createItem(); - public static final ItemStack PAPER = ItemTypes.PAPER.createItem(); - public static final ItemStack PHANTOM_MEMBRANE = ItemTypes.PHANTOM_MEMBRANE.createItem(); - public static final ItemStack POISONOUS_POTATO = ItemTypes.POISONOUS_POTATO.createItem(); - public static final ItemStack PORKCHOP = ItemTypes.PORKCHOP.createItem(); - public static final ItemStack PORTFOLIO = ItemTypes.PORTFOLIO.createItem(); - public static final ItemStack POTATO = ItemTypes.POTATO.createItem(); - public static final ItemStack POTION = ItemTypes.POTION.createItem(); - public static final ItemStack PRISMARINE_CRYSTALS = ItemTypes.PRISMARINE_CRYSTALS.createItem(); - public static final ItemStack PRISMARINE_SHARD = ItemTypes.PRISMARINE_SHARD.createItem(); - public static final ItemStack PUFFERFISH = ItemTypes.PUFFERFISH.createItem(); - public static final ItemStack PUMPKIN_PIE = ItemTypes.PUMPKIN_PIE.createItem(); - public static final ItemStack PUMPKIN_SEEDS = ItemTypes.PUMPKIN_SEEDS.createItem(); - public static final ItemStack QUARTZ = ItemTypes.QUARTZ.createItem(); - public static final ItemStack RABBIT = ItemTypes.RABBIT.createItem(); - public static final ItemStack RABBIT_FOOT = ItemTypes.RABBIT_FOOT.createItem(); - public static final ItemStack RABBIT_HIDE = ItemTypes.RABBIT_HIDE.createItem(); - public static final ItemStack RABBIT_STEW = ItemTypes.RABBIT_STEW.createItem(); - public static final ItemStack RECORD = ItemTypes.RECORD.createItem(); - public static final ItemStack REDSTONE = ItemTypes.REDSTONE.createItem(); - public static final ItemStack REEDS_ITEM = ItemTypes.REEDS.createItem(); - public static final ItemStack REPEATER_ITEM = ItemTypes.REPEATER.createItem(); - public static final ItemStack ROTTEN_FLESH = ItemTypes.ROTTEN_FLESH.createItem(); - public static final ItemStack SADDLE = ItemTypes.SADDLE.createItem(); - public static final ItemStack SALMON = ItemTypes.SALMON.createItem(); - public static final ItemStack SHEARS = ItemTypes.SHEARS.createItem(); - public static final ItemStack SHIELD = ItemTypes.SHIELD.createItem(); - public static final ItemStack SHULKER_SHELL = ItemTypes.SHULKER_SHELL.createItem(); - public static final ItemStack SIGN = ItemTypes.SIGN.createItem(); - public static final ItemStack SKULL_ITEM = ItemTypes.SKULL.createItem(); - public static final ItemStack SLIME_BALL = ItemTypes.SLIME_BALL.createItem(); - public static final ItemStack SNOWBALL = ItemTypes.SNOWBALL.createItem(); - //public static final ItemStack SPAWN_EGG = ItemTypes.SPAWN_EGG.createItem(); - public static final ItemStack SPECKLED_MELON = ItemTypes.SPECKLED_MELON.createItem(); - public static final ItemStack SPIDER_EYE = ItemTypes.SPIDER_EYE.createItem(); - public static final ItemStack SPLASH_POTION = ItemTypes.SPLASH_POTION.createItem(); - public static final ItemStack STICK = ItemTypes.STICK.createItem(); - public static final ItemStack STONE_AXE = ItemTypes.STONE_AXE.createItem(); - public static final ItemStack STONE_HOE = ItemTypes.STONE_HOE.createItem(); - public static final ItemStack STONE_PICKAXE = ItemTypes.STONE_PICKAXE.createItem(); - public static final ItemStack STONE_SHOVEL = ItemTypes.STONE_SHOVEL.createItem(); - public static final ItemStack STONE_SWORD = ItemTypes.STONE_SWORD.createItem(); - public static final ItemStack STRING = ItemTypes.STRING.createItem(); - public static final ItemStack SUGAR = ItemTypes.SUGAR.createItem(); - public static final ItemStack SWEET_BERRIES = ItemTypes.SWEET_BERRIES.createItem(); - public static final ItemStack TNT_MINECART = ItemTypes.TNT_MINECART.createItem(); - public static final ItemStack TOTEM = ItemTypes.TOTEM.createItem(); - public static final ItemStack TRIDENT = ItemTypes.TRIDENT.createItem(); - public static final ItemStack TURTLE_HELMET = ItemTypes.TURTLE_HELMET.createItem(); - public static final ItemStack TURTLE_SHELL_PIECE = ItemTypes.TURTLE_SHELL_PIECE.createItem(); - public static final ItemStack WHEAT_ITEM = ItemTypes.WHEAT.createItem(); - public static final ItemStack WHEAT_SEEDS = ItemTypes.WHEAT_SEEDS.createItem(); - public static final ItemStack WOODEN_AXE = ItemTypes.WOODEN_AXE.createItem(); - public static final ItemStack WOODEN_DOOR_ITEM = ItemTypes.WOODEN_DOOR.createItem(); - public static final ItemStack WOODEN_HOE = ItemTypes.WOODEN_HOE.createItem(); - public static final ItemStack WOODEN_PICKAXE = ItemTypes.WOODEN_PICKAXE.createItem(); - public static final ItemStack WOODEN_SHOVEL = ItemTypes.WOODEN_SHOVEL.createItem(); - public static final ItemStack WOODEN_SWORD = ItemTypes.WOODEN_SWORD.createItem(); - public static final ItemStack WRITABLE_BOOK = ItemTypes.WRITABLE_BOOK.createItem(); - public static final ItemStack WRITTEN_BOOK = ItemTypes.WRITTEN_BOOK.createItem(); -*/ -} diff --git a/src/main/java/org/cloudburstmc/api/item/ItemType.java b/src/main/java/org/cloudburstmc/api/item/ItemType.java index 13239b4..a99e215 100644 --- a/src/main/java/org/cloudburstmc/api/item/ItemType.java +++ b/src/main/java/org/cloudburstmc/api/item/ItemType.java @@ -1,61 +1,43 @@ package org.cloudburstmc.api.item; -import org.checkerframework.checker.nullness.qual.Nullable; import org.cloudburstmc.api.block.BlockType; +import org.cloudburstmc.api.data.DataKey; import org.cloudburstmc.api.util.Identifier; -public sealed interface ItemType permits BlockType, ItemTypes.IntItem { - Identifier getId(); +import java.util.Set; - boolean isBlock(); +import static com.google.common.base.Preconditions.checkNotNull; - boolean isPlaceable(); +public sealed class ItemType permits BlockType { - @Nullable - BlockType getBlock(); + private final Identifier id; + private final Set> dataKeys; - @Nullable - Class getMetadataClass(); - - int getMaximumStackSize(); - - default ItemStack createItem() { - return createItem(1); - } - - ItemStack createItem(int amount, Object... metadata); - - default int getAttackDamage() { - return 2; + protected ItemType(Identifier id, Set> dataKeys) { + this.id = id; + this.dataKeys = dataKeys; } - default int getArmorPoints() { - return 0; + public final Identifier getId() { + return id; } - default int getToughness() { - return 0; + public Set> getDataKeys() { + return dataKeys; } - default int getDurability() { - return 0; + @Override + public String toString() { + return "ItemType{id=" + id + ')'; } - default short getFuelTime() { - return 0; + public static ItemType of(Identifier id) { + return of(id, new DataKey[0]); } - default BlockType getBlockType() { - return null; - } + public static ItemType of(Identifier id, DataKey... dataKeys) { + checkNotNull(id, "id"); - default boolean isStackable() { - return getMaximumStackSize() > 1; + return new ItemType(id, Set.of(dataKeys)); } - - @Nullable - ToolType getToolType(); - - @Nullable - TierType getTierType(); } diff --git a/src/main/java/org/cloudburstmc/api/item/ItemTypes.java b/src/main/java/org/cloudburstmc/api/item/ItemTypes.java index 9bf4549..eaf396e 100644 --- a/src/main/java/org/cloudburstmc/api/item/ItemTypes.java +++ b/src/main/java/org/cloudburstmc/api/item/ItemTypes.java @@ -1,529 +1,258 @@ package org.cloudburstmc.api.item; -import org.checkerframework.checker.nullness.qual.Nullable; -import org.cloudburstmc.api.block.BlockType; -import org.cloudburstmc.api.block.BlockTypes; -import org.cloudburstmc.api.item.data.Bucket; -import org.cloudburstmc.api.item.data.Coal; -import org.cloudburstmc.api.item.data.Damageable; -import org.cloudburstmc.api.util.Identifier; +import lombok.experimental.UtilityClass; import org.cloudburstmc.api.util.Identifiers; -import org.cloudburstmc.api.util.data.DyeColor; -import org.cloudburstmc.api.util.data.TreeSpecies; - -import java.util.IdentityHashMap; -import java.util.Map; - -import static org.cloudburstmc.api.item.TierTypes.*; -import static org.cloudburstmc.api.item.ToolTypes.*; +@UtilityClass public class ItemTypes { - private static final Map BY_ID = new IdentityHashMap<>(); - private static final Map BLOCKS_BY_ID = new IdentityHashMap<>(); - - public static final ItemType IRON_SHOVEL = IntItem.builder().id(ItemIds.IRON_SHOVEL).maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(IRON).attackDamage(4).build(); - public static final ItemType IRON_PICKAXE = IntItem.builder().id(ItemIds.IRON_PICKAXE).maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(IRON).attackDamage(4).build(); - public static final ItemType IRON_AXE = IntItem.builder().id(ItemIds.IRON_AXE).maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(IRON).attackDamage(6).build(); - public static final ItemType FLINT_AND_STEEL = IntItem.builder().id(ItemIds.FLINT_AND_STEEL).maxStackSize(1).build(); - public static final ItemType APPLE = IntItem.builder().id(ItemIds.APPLE).maxStackSize(64).build(); - public static final ItemType BOW = IntItem.builder().id(ItemIds.BOW).maxStackSize(1).fuelTime((short) 200).build(); - public static final ItemType ARROW = IntItem.builder().id(ItemIds.ARROW).maxStackSize(64).build(); - public static final ItemType COAL = IntItem.builder().id(ItemIds.COAL).maxStackSize(64).data(Coal.class).fuelTime((short) 1600).build(); - public static final ItemType DIAMOND = IntItem.builder().id(ItemIds.DIAMOND).maxStackSize(64).build(); - public static final ItemType IRON_INGOT = IntItem.builder().id(ItemIds.IRON_INGOT).maxStackSize(64).build(); - public static final ItemType GOLD_INGOT = IntItem.builder().id(ItemIds.GOLD_INGOT).maxStackSize(64).build(); - public static final ItemType IRON_SWORD = IntItem.builder().id(ItemIds.IRON_SWORD).maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(IRON).attackDamage(7).build(); - public static final ItemType WOODEN_SWORD = IntItem.builder().id(ItemIds.WOODEN_SWORD).maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(WOOD).attackDamage(5).fuelTime((short) 200).build(); - public static final ItemType WOODEN_SHOVEL = IntItem.builder().id(ItemIds.WOODEN_SHOVEL).maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(WOOD).attackDamage(2).fuelTime((short) 200).build(); - public static final ItemType WOODEN_PICKAXE = IntItem.builder().id(ItemIds.WOODEN_PICKAXE).maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(WOOD).attackDamage(2).fuelTime((short) 200).build(); - public static final ItemType WOODEN_AXE = IntItem.builder().id(ItemIds.WOODEN_AXE).maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(WOOD).attackDamage(4).fuelTime((short) 200).build(); - public static final ItemType STONE_SWORD = IntItem.builder().id(ItemIds.STONE_SWORD).maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(STONE).attackDamage(6).build(); - public static final ItemType STONE_SHOVEL = IntItem.builder().id(ItemIds.STONE_SHOVEL).maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(STONE).attackDamage(3).build(); - public static final ItemType STONE_PICKAXE = IntItem.builder().id(ItemIds.STONE_PICKAXE).maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(STONE).attackDamage(3).build(); - public static final ItemType STONE_AXE = IntItem.builder().id(ItemIds.STONE_AXE).maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(STONE).attackDamage(5).build(); - public static final ItemType DIAMOND_SWORD = IntItem.builder().id(ItemIds.DIAMOND_SWORD).maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(TierTypes.DIAMOND).attackDamage(8).build(); - public static final ItemType DIAMOND_SHOVEL = IntItem.builder().id(ItemIds.DIAMOND_SHOVEL).maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(TierTypes.DIAMOND).attackDamage(5).build(); - public static final ItemType DIAMOND_PICKAXE = IntItem.builder().id(ItemIds.DIAMOND_PICKAXE).maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(TierTypes.DIAMOND).attackDamage(5).build(); - public static final ItemType DIAMOND_AXE = IntItem.builder().id(ItemIds.DIAMOND_AXE).maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(TierTypes.DIAMOND).attackDamage(7).build(); - public static final ItemType STICK = IntItem.builder().id(ItemIds.STICK).maxStackSize(64).fuelTime((short) 100).build(); - public static final ItemType BOWL = IntItem.builder().id(ItemIds.BOWL).maxStackSize(64).fuelTime((short) 200).build(); - public static final ItemType MUSHROOM_STEW = IntItem.builder().id(ItemIds.MUSHROOM_STEW).maxStackSize(1).build(); - public static final ItemType GOLDEN_SWORD = IntItem.builder().id(ItemIds.GOLDEN_SWORD).maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(GOLD).attackDamage(5).build(); - public static final ItemType GOLDEN_SHOVEL = IntItem.builder().id(ItemIds.GOLDEN_SHOVEL).maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(GOLD).attackDamage(2).build(); - public static final ItemType GOLDEN_PICKAXE = IntItem.builder().id(ItemIds.GOLDEN_PICKAXE).maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(GOLD).attackDamage(2).build(); - public static final ItemType GOLDEN_AXE = IntItem.builder().id(ItemIds.GOLDEN_AXE).maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(GOLD).attackDamage(4).build(); - public static final ItemType STRING = IntItem.builder().id(ItemIds.STRING).maxStackSize(64).blockType(BlockTypes.TRIP_WIRE).build(); - public static final ItemType FEATHER = IntItem.builder().id(ItemIds.FEATHER).maxStackSize(64).build(); - public static final ItemType GUNPOWDER = IntItem.builder().id(ItemIds.GUNPOWDER).maxStackSize(64).build(); - public static final ItemType WOODEN_HOE = IntItem.builder().id(ItemIds.WOODEN_HOE).maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(WOOD).attackDamage(2).fuelTime((short) 200).build(); - public static final ItemType STONE_HOE = IntItem.builder().id(ItemIds.STONE_HOE).maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(STONE).attackDamage(3).build(); - public static final ItemType IRON_HOE = IntItem.builder().id(ItemIds.IRON_HOE).maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(IRON).attackDamage(4).build(); - public static final ItemType DIAMOND_HOE = IntItem.builder().id(ItemIds.DIAMOND_HOE).maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(TierTypes.DIAMOND).attackDamage(5).build(); - public static final ItemType GOLDEN_HOE = IntItem.builder().id(ItemIds.GOLDEN_HOE).maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(GOLD).attackDamage(2).build(); - public static final ItemType WHEAT_SEEDS = IntItem.builder().id(ItemIds.WHEAT_SEEDS).maxStackSize(64).blockType(BlockTypes.WHEAT).build(); - public static final ItemType WHEAT = IntItem.builder().id(ItemIds.WHEAT).maxStackSize(64).build(); - public static final ItemType BREAD = IntItem.builder().id(ItemIds.BREAD).maxStackSize(64).build(); - public static final ItemType LEATHER_HELMET = IntItem.builder().id(ItemIds.LEATHER_HELMET).maxStackSize(1).tierType(TierTypes.LEATHER).build(); //TODO: color meta - public static final ItemType LEATHER_CHESTPLATE = IntItem.builder().id(ItemIds.LEATHER_CHESTPLATE).maxStackSize(1).tierType(TierTypes.LEATHER).build(); //TODO: color meta - public static final ItemType LEATHER_LEGGINGS = IntItem.builder().id(ItemIds.LEATHER_LEGGINGS).maxStackSize(1).tierType(TierTypes.LEATHER).build(); //TODO: color meta - public static final ItemType LEATHER_BOOTS = IntItem.builder().id(ItemIds.LEATHER_BOOTS).maxStackSize(1).tierType(TierTypes.LEATHER).build(); //TODO: color meta - public static final ItemType CHAINMAIL_HELMET = IntItem.builder().id(ItemIds.CHAINMAIL_HELMET).maxStackSize(1).tierType(CHAINMAIL).build(); - public static final ItemType CHAINMAIL_CHESTPLATE = IntItem.builder().id(ItemIds.CHAINMAIL_CHESTPLATE).maxStackSize(1).tierType(CHAINMAIL).build(); - public static final ItemType CHAINMAIL_LEGGINGS = IntItem.builder().id(ItemIds.CHAINMAIL_LEGGINGS).maxStackSize(1).tierType(CHAINMAIL).build(); - public static final ItemType CHAINMAIL_BOOTS = IntItem.builder().id(ItemIds.CHAINMAIL_BOOTS).maxStackSize(1).tierType(CHAINMAIL).build(); - public static final ItemType IRON_HELMET = IntItem.builder().id(ItemIds.IRON_HELMET).maxStackSize(1).tierType(IRON).build(); - public static final ItemType IRON_CHESTPLATE = IntItem.builder().id(ItemIds.IRON_CHESTPLATE).maxStackSize(1).tierType(IRON).build(); - public static final ItemType IRON_LEGGINGS = IntItem.builder().id(ItemIds.IRON_LEGGINGS).maxStackSize(1).tierType(IRON).build(); - public static final ItemType IRON_BOOTS = IntItem.builder().id(ItemIds.IRON_BOOTS).maxStackSize(1).tierType(IRON).build(); - public static final ItemType DIAMOND_HELMET = IntItem.builder().id(ItemIds.DIAMOND_HELMET).maxStackSize(1).tierType(TierTypes.DIAMOND).build(); - public static final ItemType DIAMOND_CHESTPLATE = IntItem.builder().id(ItemIds.DIAMOND_CHESTPLATE).maxStackSize(1).tierType(TierTypes.DIAMOND).build(); - public static final ItemType DIAMOND_LEGGINGS = IntItem.builder().id(ItemIds.DIAMOND_LEGGINGS).maxStackSize(1).tierType(TierTypes.DIAMOND).build(); - public static final ItemType DIAMOND_BOOTS = IntItem.builder().id(ItemIds.DIAMOND_BOOTS).maxStackSize(1).tierType(TierTypes.DIAMOND).build(); - public static final ItemType GOLDEN_HELMET = IntItem.builder().id(ItemIds.GOLDEN_HELMET).maxStackSize(1).tierType(GOLD).build(); - public static final ItemType GOLDEN_CHESTPLATE = IntItem.builder().id(ItemIds.GOLDEN_CHESTPLATE).maxStackSize(1).tierType(GOLD).build(); - public static final ItemType GOLDEN_LEGGINGS = IntItem.builder().id(ItemIds.GOLDEN_LEGGINGS).maxStackSize(1).tierType(GOLD).build(); - public static final ItemType GOLDEN_BOOTS = IntItem.builder().id(ItemIds.GOLDEN_BOOTS).maxStackSize(1).tierType(GOLD).build(); - public static final ItemType FLINT = IntItem.builder().id(ItemIds.FLINT).maxStackSize(64).build(); - public static final ItemType PORKCHOP = IntItem.builder().id(ItemIds.PORKCHOP).maxStackSize(64).build(); - public static final ItemType COOKED_PORKCHOP = IntItem.builder().id(ItemIds.COOKED_PORKCHOP).maxStackSize(64).build(); - public static final ItemType PAINTING = IntItem.builder().id(ItemIds.PAINTING).maxStackSize(64).build(); - public static final ItemType GOLDEN_APPLE = IntItem.builder().id(ItemIds.GOLDEN_APPLE).maxStackSize(64).build(); - public static final ItemType SIGN = IntItem.builder().id(ItemIds.SIGN).maxStackSize(16).blockType(BlockTypes.STANDING_SIGN).data(TreeSpecies.class).build(); - public static final ItemType WOODEN_DOOR = IntItem.builder().id(ItemIds.WOODEN_DOOR).maxStackSize(64).blockType(BlockTypes.WOODEN_DOOR).data(TreeSpecies.class).build(); - public static final ItemType BUCKET = IntItem.builder().id(ItemIds.BUCKET).data(Bucket.class).maxStackSize(16).build(); - public static final ItemType MINECART = IntItem.builder().id(ItemIds.MINECART).maxStackSize(1).build(); - public static final ItemType SADDLE = IntItem.builder().id(ItemIds.SADDLE).maxStackSize(1).build(); - public static final ItemType IRON_DOOR = IntItem.builder().id(ItemIds.IRON_DOOR).maxStackSize(64).blockType(BlockTypes.IRON_DOOR).build(); - public static final ItemType REDSTONE = IntItem.builder().id(ItemIds.REDSTONE).maxStackSize(64).blockType(BlockTypes.REDSTONE_WIRE).build(); - public static final ItemType SNOWBALL = IntItem.builder().id(ItemIds.SNOWBALL).maxStackSize(16).build(); - public static final ItemType BOAT = IntItem.builder().id(ItemIds.BOAT).maxStackSize(1).fuelTime((short) 1200).build(); - - public static final ItemType CHEST_BOAT = IntItem.builder().id(ItemIds.BOAT).maxStackSize(1).fuelTime((short) 1200).build(); - public static final ItemType LEATHER = IntItem.builder().id(ItemIds.LEATHER).maxStackSize(64).build(); - public static final ItemType KELP = IntItem.builder().id(ItemIds.KELP).maxStackSize(64).blockType(BlockTypes.KELP).build(); - public static final ItemType BRICK = IntItem.builder().id(ItemIds.BRICK).maxStackSize(64).build(); - public static final ItemType CLAY_BALL = IntItem.builder().id(ItemIds.CLAY_BALL).maxStackSize(64).build(); - public static final ItemType REEDS = IntItem.builder().id(ItemIds.SUGAR_CANE).maxStackSize(64).blockType(BlockTypes.REEDS).build(); - public static final ItemType PAPER = IntItem.builder().id(ItemIds.PAPER).maxStackSize(64).build(); - public static final ItemType BOOK = IntItem.builder().id(ItemIds.BOOK).maxStackSize(64).build(); - public static final ItemType SLIME_BALL = IntItem.builder().id(ItemIds.SLIME_BALL).maxStackSize(64).build(); - public static final ItemType CHEST_MINECART = IntItem.builder().id(ItemIds.CHEST_MINECART).maxStackSize(1).build(); - public static final ItemType EGG = IntItem.builder().id(ItemIds.EGG).maxStackSize(16).build(); - public static final ItemType COMPASS = IntItem.builder().id(ItemIds.COMPASS).maxStackSize(64).build(); - public static final ItemType FISHING_ROD = IntItem.builder().id(ItemIds.FISHING_ROD).maxStackSize(1).fuelTime((short) 300).build(); - public static final ItemType CLOCK = IntItem.builder().id(ItemIds.CLOCK).maxStackSize(64).build(); - public static final ItemType GLOWSTONE_DUST = IntItem.builder().id(ItemIds.GLOWSTONE_DUST).maxStackSize(64).build(); - public static final ItemType FISH = IntItem.builder().id(ItemIds.COD).maxStackSize(64).build(); - public static final ItemType COOKED_FISH = IntItem.builder().id(ItemIds.COOKED_COD).maxStackSize(64).build(); - public static final ItemType DYE = IntItem.builder().id(ItemIds.INK_SAC).maxStackSize(64).data(DyeColor.class).build(); - public static final ItemType BONE = IntItem.builder().id(ItemIds.BONE).maxStackSize(64).build(); - public static final ItemType SUGAR = IntItem.builder().id(ItemIds.SUGAR).maxStackSize(64).build(); - public static final ItemType CAKE = IntItem.builder().id(ItemIds.CAKE).maxStackSize(1).build(); - public static final ItemType BED = IntItem.builder().id(ItemIds.BED).maxStackSize(1).data(DyeColor.class).build(); - public static final ItemType REPEATER = IntItem.builder().id(ItemIds.REPEATER).maxStackSize(64).blockType(BlockTypes.REPEATER).build(); - public static final ItemType COOKIE = IntItem.builder().id(ItemIds.COOKIE).maxStackSize(64).build(); - public static final ItemType MAP = IntItem.builder().id(ItemIds.MAP).maxStackSize(64).build(); - public static final ItemType SHEARS = IntItem.builder().id(ItemIds.SHEARS).maxStackSize(1).data(Damageable.class).toolType(ToolTypes.SHEARS).build(); - public static final ItemType MELON = IntItem.builder().id(ItemIds.MELON).maxStackSize(64).build(); - public static final ItemType PUMPKIN_SEEDS = IntItem.builder().id(ItemIds.PUMPKIN_SEEDS).maxStackSize(64).blockType(BlockTypes.PUMPKIN_STEM).build(); - public static final ItemType MELON_SEEDS = IntItem.builder().id(ItemIds.MELON_SEEDS).maxStackSize(64).blockType(BlockTypes.MELON_STEM).build(); - public static final ItemType BEEF = IntItem.builder().id(ItemIds.BEEF).maxStackSize(64).build(); - public static final ItemType COOKED_BEEF = IntItem.builder().id(ItemIds.COOKED_BEEF).maxStackSize(64).build(); - public static final ItemType CHICKEN = IntItem.builder().id(ItemIds.CHICKEN).maxStackSize(64).build(); - public static final ItemType COOKED_CHICKEN = IntItem.builder().id(ItemIds.COOKED_CHICKEN).maxStackSize(64).build(); - public static final ItemType ROTTEN_FLESH = IntItem.builder().id(ItemIds.ROTTEN_FLESH).maxStackSize(64).build(); - public static final ItemType ENDER_PEARL = IntItem.builder().id(ItemIds.ENDER_PEARL).maxStackSize(64).build(); - public static final ItemType BLAZE_ROD = IntItem.builder().id(ItemIds.BLAZE_ROD).maxStackSize(64).fuelTime((short) 2400).build(); - public static final ItemType GHAST_TEAR = IntItem.builder().id(ItemIds.GHAST_TEAR).maxStackSize(64).build(); - public static final ItemType GOLD_NUGGET = IntItem.builder().id(ItemIds.GOLD_NUGGET).maxStackSize(64).build(); - public static final ItemType NETHER_WART = IntItem.builder().id(ItemIds.NETHER_WART).maxStackSize(64).blockType(BlockTypes.NETHER_WART).build(); - public static final ItemType POTION = IntItem.builder().id(ItemIds.POTION).maxStackSize(1).build(); - public static final ItemType GLASS_BOTTLE = IntItem.builder().id(ItemIds.GLASS_BOTTLE).maxStackSize(64).build(); - public static final ItemType SPIDER_EYE = IntItem.builder().id(ItemIds.SPIDER_EYE).maxStackSize(64).build(); - public static final ItemType FERMENTED_SPIDER_EYE = IntItem.builder().id(ItemIds.FERMENTED_SPIDER_EYE).maxStackSize(64).build(); - public static final ItemType BLAZE_POWDER = IntItem.builder().id(ItemIds.BLAZE_POWDER).maxStackSize(64).build(); - public static final ItemType MAGMA_CREAM = IntItem.builder().id(ItemIds.MAGMA_CREAM).maxStackSize(64).build(); - public static final ItemType BREWING_STAND = IntItem.builder().id(ItemIds.BREWING_STAND).maxStackSize(64).blockType(BlockTypes.BREWING_STAND).build(); - public static final ItemType CAULDRON = IntItem.builder().id(ItemIds.CAULDRON).maxStackSize(64).blockType(BlockTypes.CAULDRON).build(); - public static final ItemType ENDER_EYE = IntItem.builder().id(ItemIds.ENDER_EYE).maxStackSize(64).build(); - public static final ItemType SPECKLED_MELON = IntItem.builder().id(ItemIds.SPECKLED_MELON).maxStackSize(64).build(); - public static final ItemType SPAWN_EGG = IntItem.builder().id(ItemIds.SPAWN_EGG).maxStackSize(64).build(); - public static final ItemType EXPERIENCE_BOTTLE = IntItem.builder().id(ItemIds.EXPERIENCE_BOTTLE).maxStackSize(64).build(); - public static final ItemType FIREBALL = IntItem.builder().id(ItemIds.FIRE_CHARGE).maxStackSize(64).build(); - public static final ItemType WRITABLE_BOOK = IntItem.builder().id(ItemIds.WRITABLE_BOOK).maxStackSize(1).build(); - public static final ItemType WRITTEN_BOOK = IntItem.builder().id(ItemIds.WRITTEN_BOOK).maxStackSize(16).build(); - public static final ItemType EMERALD = IntItem.builder().id(ItemIds.EMERALD).maxStackSize(64).build(); - public static final ItemType FRAME = IntItem.builder().id(ItemIds.FRAME).maxStackSize(64).blockType(BlockTypes.FRAME).build(); - public static final ItemType FLOWER_POT = IntItem.builder().id(ItemIds.FLOWER_POT).maxStackSize(64).blockType(BlockTypes.FLOWER_POT).build(); - public static final ItemType CARROT = IntItem.builder().id(ItemIds.CARROT).maxStackSize(64).build(); - public static final ItemType POTATO = IntItem.builder().id(ItemIds.POTATO).maxStackSize(64).build(); - public static final ItemType BAKED_POTATO = IntItem.builder().id(ItemIds.BAKED_POTATO).maxStackSize(64).build(); - public static final ItemType POISONOUS_POTATO = IntItem.builder().id(ItemIds.POISONOUS_POTATO).maxStackSize(64).build(); - public static final ItemType EMPTY_MAP = IntItem.builder().id(ItemIds.EMPTY_MAP).maxStackSize(64).build(); - public static final ItemType GOLDEN_CARROT = IntItem.builder().id(ItemIds.GOLDEN_CARROT).maxStackSize(64).build(); - public static final ItemType SKULL = IntItem.builder().id(ItemIds.SKULL).maxStackSize(64).build(); //TODO: skull type - public static final ItemType CARROT_ON_A_STICK = IntItem.builder().id(ItemIds.CARROT_ON_A_STICK).maxStackSize(1).build(); - public static final ItemType NETHER_STAR = IntItem.builder().id(ItemIds.NETHER_STAR).maxStackSize(64).build(); - public static final ItemType PUMPKIN_PIE = IntItem.builder().id(ItemIds.PUMPKIN_PIE).maxStackSize(64).build(); - public static final ItemType FIREWORKS = IntItem.builder().id(ItemIds.FIREWORK_ROCKET).maxStackSize(64).build(); - public static final ItemType FIREWORKS_CHARGE = IntItem.builder().id(ItemIds.FIREWORKS_CHARGE).maxStackSize(64).build(); - public static final ItemType ENCHANTED_BOOK = IntItem.builder().id(ItemIds.ENCHANTED_BOOK).maxStackSize(1).build(); - public static final ItemType COMPARATOR = IntItem.builder().id(ItemIds.COMPARATOR).maxStackSize(64).blockType(BlockTypes.COMPARATOR).build(); - public static final ItemType NETHERBRICK = IntItem.builder().id(ItemIds.NETHERBRICK).maxStackSize(64).build(); - public static final ItemType QUARTZ = IntItem.builder().id(ItemIds.QUARTZ).maxStackSize(64).build(); - public static final ItemType TNT_MINECART = IntItem.builder().id(ItemIds.TNT_MINECART).maxStackSize(1).build(); - public static final ItemType HOPPER_MINECART = IntItem.builder().id(ItemIds.HOPPER_MINECART).maxStackSize(1).build(); - public static final ItemType PRISMARINE_SHARD = IntItem.builder().id(ItemIds.PRISMARINE_SHARD).maxStackSize(64).build(); - public static final ItemType HOPPER = IntItem.builder().id(ItemIds.HOPPER).maxStackSize(64).blockType(BlockTypes.HOPPER).build(); - public static final ItemType RABBIT = IntItem.builder().id(ItemIds.RABBIT).maxStackSize(64).build(); - public static final ItemType COOKED_RABBIT = IntItem.builder().id(ItemIds.COOKED_RABBIT).maxStackSize(64).build(); - public static final ItemType RABBIT_STEW = IntItem.builder().id(ItemIds.RABBIT_STEW).maxStackSize(64).build(); - public static final ItemType RABBIT_FOOT = IntItem.builder().id(ItemIds.RABBIT_FOOT).maxStackSize(64).build(); - public static final ItemType RABBIT_HIDE = IntItem.builder().id(ItemIds.RABBIT_HIDE).maxStackSize(64).build(); - public static final ItemType HORSE_ARMOR_LEATHER = IntItem.builder().id(ItemIds.HORSE_ARMOR_LEATHER).maxStackSize(1).build(); - public static final ItemType HORSE_ARMOR_IRON = IntItem.builder().id(ItemIds.HORSE_ARMOR_IRON).maxStackSize(1).build(); - public static final ItemType HORSE_ARMOR_GOLD = IntItem.builder().id(ItemIds.HORSE_ARMOR_GOLD).maxStackSize(1).build(); - public static final ItemType HORSE_ARMOR_DIAMOND = IntItem.builder().id(ItemIds.HORSE_ARMOR_DIAMOND).maxStackSize(1).build(); - public static final ItemType LEAD = IntItem.builder().id(ItemIds.LEAD).maxStackSize(64).build(); - public static final ItemType NAME_TAG = IntItem.builder().id(ItemIds.NAME_TAG).maxStackSize(64).build(); - public static final ItemType PRISMARINE_CRYSTALS = IntItem.builder().id(ItemIds.PRISMARINE_CRYSTALS).maxStackSize(64).build(); - public static final ItemType MUTTON_RAW = IntItem.builder().id(ItemIds.MUTTON_RAW).maxStackSize(64).build(); - public static final ItemType MUTTON_COOKED = IntItem.builder().id(ItemIds.MUTTON_COOKED).maxStackSize(64).build(); - public static final ItemType ARMOR_STAND = IntItem.builder().id(ItemIds.ARMOR_STAND).maxStackSize(64).build(); - public static final ItemType END_CRYSTAL = IntItem.builder().id(ItemIds.END_CRYSTAL).maxStackSize(64).build(); - public static final ItemType CHORUS_FRUIT = IntItem.builder().id(ItemIds.CHORUS_FRUIT).maxStackSize(64).build(); - public static final ItemType CHORUS_FRUIT_POPPED = IntItem.builder().id(ItemIds.CHORUS_FRUIT_POPPED).maxStackSize(64).build(); - public static final ItemType DRAGON_BREATH = IntItem.builder().id(ItemIds.DRAGON_BREATH).maxStackSize(64).build(); - public static final ItemType SPLASH_POTION = IntItem.builder().id(ItemIds.SPLASH_POTION).maxStackSize(1).build(); - public static final ItemType LINGERING_POTION = IntItem.builder().id(ItemIds.LINGERING_POTION).maxStackSize(1).build(); - public static final ItemType COMMAND_BLOCK_MINECART = IntItem.builder().id(ItemIds.COMMAND_BLOCK_MINECART).maxStackSize(1).build(); - public static final ItemType ELYTRA = IntItem.builder().id(ItemIds.ELYTRA).maxStackSize(1).build(); - public static final ItemType SHULKER_SHELL = IntItem.builder().id(ItemIds.SHULKER_SHELL).maxStackSize(64).build(); - public static final ItemType BANNER = IntItem.builder().id(ItemIds.BANNER).maxStackSize(16).fuelTime((short) 300).build(); - public static final ItemType BANNER_PATTERN = IntItem.builder().id(ItemIds.BANNER_PATTERN).maxStackSize(1).build(); - public static final ItemType TOTEM = IntItem.builder().id(ItemIds.TOTEM).maxStackSize(1).build(); - public static final ItemType IRON_NUGGET = IntItem.builder().id(ItemIds.IRON_NUGGET).maxStackSize(64).build(); - public static final ItemType BOARD = IntItem.builder().id(ItemIds.BOARD).maxStackSize(16).build(); - public static final ItemType PORTFOLIO = IntItem.builder().id(ItemIds.PORTFOLIO).maxStackSize(64).build(); - public static final ItemType TRIDENT = IntItem.builder().id(ItemIds.TRIDENT).maxStackSize(64).build(); - public static final ItemType BEETROOT = IntItem.builder().id(ItemIds.BEETROOT).maxStackSize(54).blockType(BlockTypes.BEETROOT).build(); - public static final ItemType BEETROOT_SEEDS = IntItem.builder().id(ItemIds.BEETROOT_SEEDS).maxStackSize(64).build(); - public static final ItemType BEETROOT_SOUP = IntItem.builder().id(ItemIds.BEETROOT_SOUP).maxStackSize(1).build(); - public static final ItemType SALMON = IntItem.builder().id(ItemIds.SALMON).maxStackSize(64).build(); - public static final ItemType CLOWNFISH = IntItem.builder().id(ItemIds.TROPICAL_FISH).maxStackSize(64).build(); - public static final ItemType PUFFERFISH = IntItem.builder().id(ItemIds.PUFFERFISH).maxStackSize(64).build(); - public static final ItemType COOKED_SALMON = IntItem.builder().id(ItemIds.COOKED_SALMON).maxStackSize(64).build(); - public static final ItemType NAUTILUS_SHELL = IntItem.builder().id(ItemIds.NAUTILUS_SHELL).maxStackSize(64).build(); - public static final ItemType DRIED_KELP = IntItem.builder().id(ItemIds.DRIED_KELP).maxStackSize(64).build(); - public static final ItemType APPLE_ENCHANTED = IntItem.builder().id(ItemIds.APPLE_ENCHANTED).maxStackSize(64).build(); - public static final ItemType HEART_OF_THE_SEA = IntItem.builder().id(ItemIds.HEART_OF_THE_SEA).maxStackSize(64).build(); - public static final ItemType TURTLE_SHELL_PIECE = IntItem.builder().id(ItemIds.TURTLE_SHELL_PIECE).maxStackSize(64).build(); - public static final ItemType TURTLE_HELMET = IntItem.builder().id(ItemIds.TURTLE_HELMET).maxStackSize(1).build(); - public static final ItemType PHANTOM_MEMBRANE = IntItem.builder().id(ItemIds.PHANTOM_MEMBRANE).maxStackSize(64).build(); - public static final ItemType CROSSBOW = IntItem.builder().id(ItemIds.CROSSBOW).maxStackSize(1).build(); - public static final ItemType SWEET_BERRIES = IntItem.builder().id(ItemIds.SWEET_BERRIES).maxStackSize(64).build(); - public static final ItemType CAMERA = IntItem.builder().id(ItemIds.CAMERA).maxStackSize(64).build(); - public static final ItemType RECORD = IntItem.builder().id(ItemIds.RECORD_13).maxStackSize(1).build(); - - public static final ItemType SUSPICIOUS_STEW = IntItem.builder().id(ItemIds.SUSPICIOUS_STEW).build(); - public static final ItemType LODESTONE_COMPASS = IntItem.builder().id(ItemIds.LODESTONE_COMPASS).build(); - public static final ItemType WARPED_FUNGUS_ON_A_STICK = IntItem.builder().id(ItemIds.WARPED_FUNGUS_ON_STICK).build(); - - - public static final ItemType SHIELD = IntItem.builder().id(ItemIds.SHIELD).maxStackSize(1).data(Damageable.class).build(); - public static final ItemType CAMPFIRE = IntItem.builder().id(ItemIds.CAMPFIRE).maxStackSize(1).blockType(BlockTypes.CAMPFIRE).build(); - public static final ItemType HONEYCOMB = IntItem.builder().id(ItemIds.HONEYCOMB).maxStackSize(64).build(); - public static final ItemType HONEY_BOTTLE = IntItem.builder().id(ItemIds.HONEY_BOTTLE).maxStackSize(16).build(); - public static final ItemType NETHERITE_INGOT = IntItem.builder().id(ItemIds.NETHERITE_INGOT).maxStackSize(64).build(); - public static final ItemType NETHERITE_SCRAP = IntItem.builder().id(ItemIds.NETHERITE_SCRAP).build(); - public static final ItemType NETHERITE_SWORD = IntItem.builder().id(ItemIds.NETHERITE_SWORD).maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(NETHERITE).attackDamage(9).build(); - public static final ItemType NETHERITE_SHOVEL = IntItem.builder().id(ItemIds.NETHERITE_SHOVEL).maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(NETHERITE).attackDamage(6).build(); - public static final ItemType NETHERITE_PICKAXE = IntItem.builder().id(ItemIds.NETHERITE_PICKAXE).maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(NETHERITE).attackDamage(6).build(); - public static final ItemType NETHERITE_AXE = IntItem.builder().id(ItemIds.NETHERITE_AXE).maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(NETHERITE).attackDamage(8).build(); - public static final ItemType NETHERITE_HOE = IntItem.builder().id(ItemIds.NETHERITE_HOE).maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(NETHERITE).attackDamage(6).build(); - public static final ItemType NETHERITE_HELMET = IntItem.builder().id(ItemIds.NETHERITE_HELMET).maxStackSize(1).data(Damageable.class).tierType(NETHERITE).build(); - public static final ItemType NETHERITE_CHESTPLATE = IntItem.builder().id(ItemIds.NETHERITE_CHESTPLATE).maxStackSize(1).data(Damageable.class).tierType(NETHERITE).build(); - public static final ItemType NETHERITE_LEGGINGS = IntItem.builder().id(ItemIds.NETHERITE_LEGGINGS).maxStackSize(1).data(Damageable.class).tierType(NETHERITE).build(); - public static final ItemType NETHERITE_BOOTS = IntItem.builder().id(ItemIds.NETHERITE_BOOTS).maxStackSize(1).data(Damageable.class).tierType(NETHERITE).build(); - public static final ItemType CONCRETE_POWDER = IntItem.builder().id(ItemIds.CONCRETE_POWDER).maxStackSize(64).data(DyeColor.class).blockType(BlockTypes.CONCRETE_POWDER).build(); - public static final ItemType UNKNOWN = IntItem.builder().id(Identifiers.UNKNOWN).build(); - - public static final ItemType AMETHYST_SHARD = IntItem.builder().id(ItemIds.AMETHYST_SHARD).build(); - public static final ItemType GLOW_BERRIES = IntItem.builder().id(ItemIds.GLOW_BERRIES).build(); - public static final ItemType GLOW_INK_SAC = IntItem.builder().id(ItemIds.GLOW_INK_SAC).build(); - public static final ItemType GOAT_HORN = IntItem.builder().id(ItemIds.GOAT_HORN).build(); - public static final ItemType GLOW_FRAME = IntItem.builder().id(ItemIds.GLOW_FRAME).build(); - public static final ItemType RAW_COPPER = IntItem.builder().id(ItemIds.RAW_COPPER).build(); - public static final ItemType RAW_GOLD = IntItem.builder().id(ItemIds.RAW_GOLD).build(); - public static final ItemType RAW_IRON = IntItem.builder().id(ItemIds.RAW_IRON).build(); - public static final ItemType SPYGLASS = IntItem.builder().id(ItemIds.SPYGLASS).build(); - public static final ItemType COPPER_INGOT = IntItem.builder().id(ItemIds.COPPER_INGOT).build(); - - public static final ItemType DISC_FRAGMENT_5 = IntItem.builder().id(ItemIds.DISC_FRAGMENT_5).build(); - public static final ItemType RECOVERY_COMPASS = IntItem.builder().id(ItemIds.RECOVERY_COMPASS).build(); - public static final ItemType ECHO_CHARD = IntItem.builder().id(ItemIds.ECHO_CHARD).build(); - - public static final class IntItem implements ItemType { - private final Identifier id; - private final int maxStackSize; - private final int attackDamage; - private final int armorPoints; - private final int toughness; - private final int durability; - private final short fuelTime; - private final int enchantAbility; - private final BlockType blockType; - private final Class data; - private final ToolType toolType; - private final TierType tierType; - - private IntItem( - Identifier id, - int maxStackSize, - int attackDamage, - int armorPoints, - int toughness, - int durability, - short fuelTime, - int enchantAbility, - Class data, - BlockType blockType, - ToolType toolType, - TierType tierType - ) { - this.id = id; - this.maxStackSize = Math.max(1, maxStackSize); - this.attackDamage = attackDamage; - this.armorPoints = armorPoints; - this.toughness = toughness; - this.fuelTime = fuelTime; - this.enchantAbility = enchantAbility; - this.data = data; - this.blockType = blockType; - this.toolType = toolType; - this.tierType = tierType; - - if (durability >= 0) { - this.durability = durability; - } else { - if (tierType != null) { - this.durability = tierType.getDurability(); - } else { - this.durability = 0; - } - } - - BY_ID.put(id, this); - } - - @Override - public ItemStack createItem(int amount, Object... metadata) { - //return CloudItemRegistry.get().getItem(this, amount, metadata); - return null; //TODO SB - How to reference ItemRegistry statically? - } - - @Override - public Identifier getId() { - return id; - } - - @Override - public boolean isBlock() { - return false; - } - - @Override - public int getMaximumStackSize() { - return maxStackSize; - } - - @Override - public int getAttackDamage() { - return attackDamage; - } - - @Override - public int getArmorPoints() { - return armorPoints; - } - - @Override - public int getToughness() { - return toughness; - } - - @Override - public int getDurability() { - return durability; - } - - @Override - public short getFuelTime() { - return fuelTime; - } - - public BlockType getBlockType() { - return blockType; - } - - @Nullable - @Override - public Class getMetadataClass() { - return data; - } - - @Override - @Nullable - public ToolType getToolType() { - return toolType; - } - - @Override - @Nullable - public TierType getTierType() { - return tierType; - } - - @Override - public boolean isPlaceable() { - return blockType != null; - } - - @Override - @Nullable - public BlockType getBlock() { - return null; - } - - @Override - public String toString() { - return "ItemType(" + id + ")"; - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - private static Builder builder() { - return new Builder(); - } - - private static class Builder { - private Identifier id; - private int maxStackSize; - private int attackDamage = 2; - private int armorPoints; - private int toughness; - private int durability = -1; - private short fuelTime; - private int enchantAbility; - private BlockType blockType; - private Class data; - private ToolType toolType; - private TierType tierType; - - private Builder id(Identifier id) { - this.id = id; - return this; - } - - private Builder maxStackSize(int maxStackSize) { - this.maxStackSize = maxStackSize; - return this; - } - - private Builder attackDamage(int damage) { - this.attackDamage = damage; - return this; - } - - private Builder armorPoints(int points) { - this.armorPoints = points; - return this; - } - - private Builder toughness(int toughness) { - this.toughness = toughness; - return this; - } - - private Builder durability(int durability) { - this.durability = durability; - return this; - } - - private Builder fuelTime(short duration) { - this.fuelTime = duration; - return this; - } - - private Builder enchantAbility(int enchantAbility) { - this.enchantAbility = enchantAbility; - return this; - } - - private Builder blockType(BlockType type) { - this.blockType = type; - return this; - } - - private Builder data(Class data) { - this.data = data; - return this; - } - - private Builder toolType(ToolType toolType) { - this.data(Damageable.class).toolType = toolType; - return this; - } - - private Builder tierType(TierType tierType) { - this.tierType = tierType; - return this; - } - - public IntItem build() { - return new IntItem( - id, - maxStackSize, - attackDamage, - armorPoints, - toughness, - durability, - fuelTime, - enchantAbility, - data, - blockType, - toolType, - tierType - ); - } - } - } - - public static ItemType byId(Identifier id) { - return byId(id, false); - } - - public static ItemType byId(Identifier id, boolean itemsOnly) { - ItemType type = BY_ID.get(id); - if (type == null) { - if (itemsOnly) { - throw new IllegalArgumentException("ID " + id + " is not valid."); - } else { - return BLOCKS_BY_ID.get(id); - } - } - return type; - } - - public static void addType(Identifier id, BlockType type) { - BLOCKS_BY_ID.putIfAbsent(id, type); - } - - public static void addType(Identifier id, ItemType type) { - BY_ID.putIfAbsent(id, type); - } + public static final ItemType IRON_SHOVEL = ItemType.of(ItemIds.IRON_SHOVEL); //.maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(IRON).attackDamage(4).build(); + public static final ItemType IRON_PICKAXE = ItemType.of(ItemIds.IRON_PICKAXE); //.maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(IRON).attackDamage(4).build(); + public static final ItemType IRON_AXE = ItemType.of(ItemIds.IRON_AXE); //.maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(IRON).attackDamage(6).build(); + public static final ItemType FLINT_AND_STEEL = ItemType.of(ItemIds.FLINT_AND_STEEL); //.maxStackSize(1).build(); + public static final ItemType APPLE = ItemType.of(ItemIds.APPLE); //.maxStackSize(64).build(); + public static final ItemType BOW = ItemType.of(ItemIds.BOW); //.maxStackSize(1).fuelTime((short) 200).build(); + public static final ItemType ARROW = ItemType.of(ItemIds.ARROW); //.maxStackSize(64).build(); + public static final ItemType COAL = ItemType.of(ItemIds.COAL); //.maxStackSize(64).data(Coal.class).fuelTime((short) 1600).build(); + public static final ItemType CHARCOAL = ItemType.of(ItemIds.CHARCOAL); + public static final ItemType DIAMOND = ItemType.of(ItemIds.DIAMOND); //.maxStackSize(64).build(); + public static final ItemType IRON_INGOT = ItemType.of(ItemIds.IRON_INGOT); //.maxStackSize(64).build(); + public static final ItemType GOLD_INGOT = ItemType.of(ItemIds.GOLD_INGOT); //.maxStackSize(64).build(); + public static final ItemType IRON_SWORD = ItemType.of(ItemIds.IRON_SWORD); //.maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(IRON).attackDamage(7).build(); + public static final ItemType WOODEN_SWORD = ItemType.of(ItemIds.WOODEN_SWORD); //.maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(WOOD).attackDamage(5).fuelTime((short) 200).build(); + public static final ItemType WOODEN_SHOVEL = ItemType.of(ItemIds.WOODEN_SHOVEL); //.maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(WOOD).attackDamage(2).fuelTime((short) 200).build(); + public static final ItemType WOODEN_PICKAXE = ItemType.of(ItemIds.WOODEN_PICKAXE); //.maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(WOOD).attackDamage(2).fuelTime((short) 200).build(); + public static final ItemType WOODEN_AXE = ItemType.of(ItemIds.WOODEN_AXE); //.maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(WOOD).attackDamage(4).fuelTime((short) 200).build(); + public static final ItemType STONE_SWORD = ItemType.of(ItemIds.STONE_SWORD); //.maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(STONE).attackDamage(6).build(); + public static final ItemType STONE_SHOVEL = ItemType.of(ItemIds.STONE_SHOVEL); //.maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(STONE).attackDamage(3).build(); + public static final ItemType STONE_PICKAXE = ItemType.of(ItemIds.STONE_PICKAXE); //.maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(STONE).attackDamage(3).build(); + public static final ItemType STONE_AXE = ItemType.of(ItemIds.STONE_AXE); //.maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(STONE).attackDamage(5).build(); + public static final ItemType DIAMOND_SWORD = ItemType.of(ItemIds.DIAMOND_SWORD); //.maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(TierTypes.DIAMOND).attackDamage(8).build(); + public static final ItemType DIAMOND_SHOVEL = ItemType.of(ItemIds.DIAMOND_SHOVEL); //.maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(TierTypes.DIAMOND).attackDamage(5).build(); + public static final ItemType DIAMOND_PICKAXE = ItemType.of(ItemIds.DIAMOND_PICKAXE); //.maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(TierTypes.DIAMOND).attackDamage(5).build(); + public static final ItemType DIAMOND_AXE = ItemType.of(ItemIds.DIAMOND_AXE); //.maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(TierTypes.DIAMOND).attackDamage(7).build(); + public static final ItemType STICK = ItemType.of(ItemIds.STICK); //.maxStackSize(64).fuelTime((short) 100).build(); + public static final ItemType BOWL = ItemType.of(ItemIds.BOWL); //.maxStackSize(64).fuelTime((short) 200).build(); + public static final ItemType MUSHROOM_STEW = ItemType.of(ItemIds.MUSHROOM_STEW); //.maxStackSize(1).build(); + public static final ItemType GOLDEN_SWORD = ItemType.of(ItemIds.GOLDEN_SWORD); //.maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(GOLD).attackDamage(5).build(); + public static final ItemType GOLDEN_SHOVEL = ItemType.of(ItemIds.GOLDEN_SHOVEL); //.maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(GOLD).attackDamage(2).build(); + public static final ItemType GOLDEN_PICKAXE = ItemType.of(ItemIds.GOLDEN_PICKAXE); //.maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(GOLD).attackDamage(2).build(); + public static final ItemType GOLDEN_AXE = ItemType.of(ItemIds.GOLDEN_AXE); //.maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(GOLD).attackDamage(4).build(); + public static final ItemType STRING = ItemType.of(ItemIds.STRING); //.maxStackSize(64).blockType(BlockTypes.TRIPWIRE).build(); + public static final ItemType FEATHER = ItemType.of(ItemIds.FEATHER); //.maxStackSize(64).build(); + public static final ItemType GUNPOWDER = ItemType.of(ItemIds.GUNPOWDER); //.maxStackSize(64).build(); + public static final ItemType WOODEN_HOE = ItemType.of(ItemIds.WOODEN_HOE); //.maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(WOOD).attackDamage(2).fuelTime((short) 200).build(); + public static final ItemType STONE_HOE = ItemType.of(ItemIds.STONE_HOE); //.maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(STONE).attackDamage(3).build(); + public static final ItemType IRON_HOE = ItemType.of(ItemIds.IRON_HOE); //.maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(IRON).attackDamage(4).build(); + public static final ItemType DIAMOND_HOE = ItemType.of(ItemIds.DIAMOND_HOE); //.maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(TierTypes.DIAMOND).attackDamage(5).build(); + public static final ItemType GOLDEN_HOE = ItemType.of(ItemIds.GOLDEN_HOE); //.maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(GOLD).attackDamage(2).build(); + public static final ItemType WHEAT_SEEDS = ItemType.of(ItemIds.WHEAT_SEEDS); //.maxStackSize(64).blockType(BlockTypes.WHEAT).build(); + public static final ItemType WHEAT = ItemType.of(ItemIds.WHEAT); //.maxStackSize(64).build(); + public static final ItemType BREAD = ItemType.of(ItemIds.BREAD); //.maxStackSize(64).build(); + public static final ItemType LEATHER_HELMET = ItemType.of(ItemIds.LEATHER_HELMET); //.maxStackSize(1).tierType(TierTypes.LEATHER).build(); //TODO: color meta + public static final ItemType LEATHER_CHESTPLATE = ItemType.of(ItemIds.LEATHER_CHESTPLATE); //.maxStackSize(1).tierType(TierTypes.LEATHER).build(); //TODO: color meta + public static final ItemType LEATHER_LEGGINGS = ItemType.of(ItemIds.LEATHER_LEGGINGS); //.maxStackSize(1).tierType(TierTypes.LEATHER).build(); //TODO: color meta + public static final ItemType LEATHER_BOOTS = ItemType.of(ItemIds.LEATHER_BOOTS); //.maxStackSize(1).tierType(TierTypes.LEATHER).build(); //TODO: color meta + public static final ItemType CHAINMAIL_HELMET = ItemType.of(ItemIds.CHAINMAIL_HELMET); //.maxStackSize(1).tierType(CHAINMAIL).build(); + public static final ItemType CHAINMAIL_CHESTPLATE = ItemType.of(ItemIds.CHAINMAIL_CHESTPLATE); //.maxStackSize(1).tierType(CHAINMAIL).build(); + public static final ItemType CHAINMAIL_LEGGINGS = ItemType.of(ItemIds.CHAINMAIL_LEGGINGS); //.maxStackSize(1).tierType(CHAINMAIL).build(); + public static final ItemType CHAINMAIL_BOOTS = ItemType.of(ItemIds.CHAINMAIL_BOOTS); //.maxStackSize(1).tierType(CHAINMAIL).build(); + public static final ItemType IRON_HELMET = ItemType.of(ItemIds.IRON_HELMET); //.maxStackSize(1).tierType(IRON).build(); + public static final ItemType IRON_CHESTPLATE = ItemType.of(ItemIds.IRON_CHESTPLATE); //.maxStackSize(1).tierType(IRON).build(); + public static final ItemType IRON_LEGGINGS = ItemType.of(ItemIds.IRON_LEGGINGS); //.maxStackSize(1).tierType(IRON).build(); + public static final ItemType IRON_BOOTS = ItemType.of(ItemIds.IRON_BOOTS); //.maxStackSize(1).tierType(IRON).build(); + public static final ItemType DIAMOND_HELMET = ItemType.of(ItemIds.DIAMOND_HELMET); //.maxStackSize(1).tierType(TierTypes.DIAMOND).build(); + public static final ItemType DIAMOND_CHESTPLATE = ItemType.of(ItemIds.DIAMOND_CHESTPLATE); //.maxStackSize(1).tierType(TierTypes.DIAMOND).build(); + public static final ItemType DIAMOND_LEGGINGS = ItemType.of(ItemIds.DIAMOND_LEGGINGS); //.maxStackSize(1).tierType(TierTypes.DIAMOND).build(); + public static final ItemType DIAMOND_BOOTS = ItemType.of(ItemIds.DIAMOND_BOOTS); //.maxStackSize(1).tierType(TierTypes.DIAMOND).build(); + public static final ItemType GOLDEN_HELMET = ItemType.of(ItemIds.GOLDEN_HELMET); //.maxStackSize(1).tierType(GOLD).build(); + public static final ItemType GOLDEN_CHESTPLATE = ItemType.of(ItemIds.GOLDEN_CHESTPLATE); //.maxStackSize(1).tierType(GOLD).build(); + public static final ItemType GOLDEN_LEGGINGS = ItemType.of(ItemIds.GOLDEN_LEGGINGS); //.maxStackSize(1).tierType(GOLD).build(); + public static final ItemType GOLDEN_BOOTS = ItemType.of(ItemIds.GOLDEN_BOOTS); //.maxStackSize(1).tierType(GOLD).build(); + public static final ItemType FLINT = ItemType.of(ItemIds.FLINT); //.maxStackSize(64).build(); + public static final ItemType PORKCHOP = ItemType.of(ItemIds.PORKCHOP); //.maxStackSize(64).build(); + public static final ItemType COOKED_PORKCHOP = ItemType.of(ItemIds.COOKED_PORKCHOP); //.maxStackSize(64).build(); + public static final ItemType PAINTING = ItemType.of(ItemIds.PAINTING); //.maxStackSize(64).build(); + public static final ItemType GOLDEN_APPLE = ItemType.of(ItemIds.GOLDEN_APPLE); //.maxStackSize(64).build(); + public static final ItemType SIGN = ItemType.of(ItemIds.SIGN); //.maxStackSize(16).blockType(BlockTypes.STANDING_SIGN).data(TreeSpecies.class).build(); + public static final ItemType WOODEN_DOOR = ItemType.of(ItemIds.WOODEN_DOOR); //.maxStackSize(64).blockType(BlockTypes.WOODEN_DOOR).data(TreeSpecies.class).build(); + public static final ItemType BUCKET = ItemType.of(ItemIds.BUCKET); //.data(Bucket.class).maxStackSize(16).build(); + public static final ItemType MILK_BUCKET = ItemType.of(ItemIds.MILK_BUCKET); + public static final ItemType COD_BUCKET = ItemType.of(ItemIds.COD_BUCKET); + public static final ItemType SALMON_BUCKET = ItemType.of(ItemIds.SALMON_BUCKET); + public static final ItemType TROPICAL_FISH_BUCKET = ItemType.of(ItemIds.TROPICAL_FISH_BUCKET); + public static final ItemType PUFFERFISH_BUCKET = ItemType.of(ItemIds.PUFFERFISH_BUCKET); + public static final ItemType WATER_BUCKET = ItemType.of(ItemIds.WATER_BUCKET); + public static final ItemType LAVA_BUCKET = ItemType.of(ItemIds.LAVA_BUCKET); + public static final ItemType MINECART = ItemType.of(ItemIds.MINECART); //.maxStackSize(1).build(); + public static final ItemType SADDLE = ItemType.of(ItemIds.SADDLE); //.maxStackSize(1).build(); + public static final ItemType IRON_DOOR = ItemType.of(ItemIds.IRON_DOOR); //.maxStackSize(64).blockType(BlockTypes.IRON_DOOR).build(); + public static final ItemType REDSTONE = ItemType.of(ItemIds.REDSTONE); //.maxStackSize(64).blockType(BlockTypes.REDSTONE_WIRE).build(); + public static final ItemType SNOWBALL = ItemType.of(ItemIds.SNOWBALL); //.maxStackSize(16).build(); + public static final ItemType BOAT = ItemType.of(ItemIds.BOAT); //.maxStackSize(1).fuelTime((short) 1200).build(); + public static final ItemType LEATHER = ItemType.of(ItemIds.LEATHER); //.maxStackSize(64).build(); + public static final ItemType KELP = ItemType.of(ItemIds.KELP); //.maxStackSize(64).blockType(BlockTypes.KELP).build(); + public static final ItemType BRICK = ItemType.of(ItemIds.BRICK); //.maxStackSize(64).build(); + public static final ItemType CLAY_BALL = ItemType.of(ItemIds.CLAY_BALL); //.maxStackSize(64).build(); + public static final ItemType REEDS = ItemType.of(ItemIds.SUGAR_CANE); //.maxStackSize(64).blockType(BlockTypes.REEDS).build(); + public static final ItemType PAPER = ItemType.of(ItemIds.PAPER); //.maxStackSize(64).build(); + public static final ItemType BOOK = ItemType.of(ItemIds.BOOK); //.maxStackSize(64).build(); + public static final ItemType SLIME_BALL = ItemType.of(ItemIds.SLIME_BALL); //.maxStackSize(64).build(); + public static final ItemType CHEST_MINECART = ItemType.of(ItemIds.CHEST_MINECART); //.maxStackSize(1).build(); + public static final ItemType EGG = ItemType.of(ItemIds.EGG); //.maxStackSize(16).build(); + public static final ItemType COMPASS = ItemType.of(ItemIds.COMPASS); //.maxStackSize(64).build(); + public static final ItemType FISHING_ROD = ItemType.of(ItemIds.FISHING_ROD); //.maxStackSize(1).fuelTime((short) 300).build(); + public static final ItemType CLOCK = ItemType.of(ItemIds.CLOCK); //.maxStackSize(64).build(); + public static final ItemType GLOWSTONE_DUST = ItemType.of(ItemIds.GLOWSTONE_DUST); //.maxStackSize(64).build(); + public static final ItemType FISH = ItemType.of(ItemIds.COD); //.maxStackSize(64).build(); + public static final ItemType COOKED_FISH = ItemType.of(ItemIds.COOKED_COD); //.maxStackSize(64).build(); + public static final ItemType DYE = ItemType.of(ItemIds.INK_SAC); //.maxStackSize(64).data(DyeColor.class).build(); + public static final ItemType BONE = ItemType.of(ItemIds.BONE); //.maxStackSize(64).build(); + public static final ItemType SUGAR = ItemType.of(ItemIds.SUGAR); //.maxStackSize(64).build(); + public static final ItemType CAKE = ItemType.of(ItemIds.CAKE); //.maxStackSize(1).build(); + public static final ItemType BED = ItemType.of(ItemIds.BED); //.maxStackSize(1).data(DyeColor.class).build(); + public static final ItemType REPEATER = ItemType.of(ItemIds.REPEATER); //.maxStackSize(64).blockType(BlockTypes.REPEATER).build(); + public static final ItemType COOKIE = ItemType.of(ItemIds.COOKIE); //.maxStackSize(64).build(); + public static final ItemType MAP = ItemType.of(ItemIds.MAP); //.maxStackSize(64).build(); + public static final ItemType SHEARS = ItemType.of(ItemIds.SHEARS); //.maxStackSize(1).data(Damageable.class).toolType(ToolTypes.SHEARS).build(); + public static final ItemType MELON = ItemType.of(ItemIds.MELON); //.maxStackSize(64).build(); + public static final ItemType PUMPKIN_SEEDS = ItemType.of(ItemIds.PUMPKIN_SEEDS); //.maxStackSize(64).blockType(BlockTypes.PUMPKIN_STEM).build(); + public static final ItemType MELON_SEEDS = ItemType.of(ItemIds.MELON_SEEDS); //.maxStackSize(64).blockType(BlockTypes.MELON_STEM).build(); + public static final ItemType BEEF = ItemType.of(ItemIds.BEEF); //.maxStackSize(64).build(); + public static final ItemType COOKED_BEEF = ItemType.of(ItemIds.COOKED_BEEF); //.maxStackSize(64).build(); + public static final ItemType CHICKEN = ItemType.of(ItemIds.CHICKEN); //.maxStackSize(64).build(); + public static final ItemType COOKED_CHICKEN = ItemType.of(ItemIds.COOKED_CHICKEN); //.maxStackSize(64).build(); + public static final ItemType ROTTEN_FLESH = ItemType.of(ItemIds.ROTTEN_FLESH); //.maxStackSize(64).build(); + public static final ItemType ENDER_PEARL = ItemType.of(ItemIds.ENDER_PEARL); //.maxStackSize(64).build(); + public static final ItemType BLAZE_ROD = ItemType.of(ItemIds.BLAZE_ROD); //.maxStackSize(64).fuelTime((short) 2400).build(); + public static final ItemType GHAST_TEAR = ItemType.of(ItemIds.GHAST_TEAR); //.maxStackSize(64).build(); + public static final ItemType GOLD_NUGGET = ItemType.of(ItemIds.GOLD_NUGGET); //.maxStackSize(64).build(); + public static final ItemType NETHER_WART = ItemType.of(ItemIds.NETHER_WART); //.maxStackSize(64).blockType(BlockTypes.NETHER_WART).build(); + public static final ItemType POTION = ItemType.of(ItemIds.POTION); //.maxStackSize(1).build(); + public static final ItemType GLASS_BOTTLE = ItemType.of(ItemIds.GLASS_BOTTLE); //.maxStackSize(64).build(); + public static final ItemType SPIDER_EYE = ItemType.of(ItemIds.SPIDER_EYE); //.maxStackSize(64).build(); + public static final ItemType FERMENTED_SPIDER_EYE = ItemType.of(ItemIds.FERMENTED_SPIDER_EYE); //.maxStackSize(64).build(); + public static final ItemType BLAZE_POWDER = ItemType.of(ItemIds.BLAZE_POWDER); //.maxStackSize(64).build(); + public static final ItemType MAGMA_CREAM = ItemType.of(ItemIds.MAGMA_CREAM); //.maxStackSize(64).build(); + public static final ItemType BREWING_STAND = ItemType.of(ItemIds.BREWING_STAND); //.maxStackSize(64).blockType(BlockTypes.BREWING_STAND).build(); + public static final ItemType CAULDRON = ItemType.of(ItemIds.CAULDRON); //.maxStackSize(64).blockType(BlockTypes.CAULDRON).build(); + public static final ItemType ENDER_EYE = ItemType.of(ItemIds.ENDER_EYE); //.maxStackSize(64).build(); + public static final ItemType SPECKLED_MELON = ItemType.of(ItemIds.SPECKLED_MELON); //.maxStackSize(64).build(); + public static final ItemType SPAWN_EGG = ItemType.of(ItemIds.SPAWN_EGG); //.maxStackSize(64).build(); + public static final ItemType EXPERIENCE_BOTTLE = ItemType.of(ItemIds.EXPERIENCE_BOTTLE); //.maxStackSize(64).build(); + public static final ItemType FIREBALL = ItemType.of(ItemIds.FIRE_CHARGE); //.maxStackSize(64).build(); + public static final ItemType WRITABLE_BOOK = ItemType.of(ItemIds.WRITABLE_BOOK); //.maxStackSize(1).build(); + public static final ItemType WRITTEN_BOOK = ItemType.of(ItemIds.WRITTEN_BOOK); //.maxStackSize(16).build(); + public static final ItemType EMERALD = ItemType.of(ItemIds.EMERALD); //.maxStackSize(64).build(); + public static final ItemType FRAME = ItemType.of(ItemIds.FRAME); //.maxStackSize(64).blockType(BlockTypes.FRAME).build(); + public static final ItemType FLOWER_POT = ItemType.of(ItemIds.FLOWER_POT); //.maxStackSize(64).blockType(BlockTypes.FLOWER_POT).build(); + public static final ItemType CARROT = ItemType.of(ItemIds.CARROT); //.maxStackSize(64).build(); + public static final ItemType POTATO = ItemType.of(ItemIds.POTATO); //.maxStackSize(64).build(); + public static final ItemType BAKED_POTATO = ItemType.of(ItemIds.BAKED_POTATO); //.maxStackSize(64).build(); + public static final ItemType POISONOUS_POTATO = ItemType.of(ItemIds.POISONOUS_POTATO); //.maxStackSize(64).build(); + public static final ItemType EMPTY_MAP = ItemType.of(ItemIds.EMPTY_MAP); //.maxStackSize(64).build(); + public static final ItemType GOLDEN_CARROT = ItemType.of(ItemIds.GOLDEN_CARROT); //.maxStackSize(64).build(); + public static final ItemType SKULL = ItemType.of(ItemIds.SKULL); //.maxStackSize(64).build(); //TODO: skull type + public static final ItemType CARROT_ON_A_STICK = ItemType.of(ItemIds.CARROT_ON_A_STICK); //.maxStackSize(1).build(); + public static final ItemType NETHER_STAR = ItemType.of(ItemIds.NETHER_STAR); //.maxStackSize(64).build(); + public static final ItemType PUMPKIN_PIE = ItemType.of(ItemIds.PUMPKIN_PIE); //.maxStackSize(64).build(); + public static final ItemType FIREWORKS = ItemType.of(ItemIds.FIREWORK_ROCKET); //.maxStackSize(64).build(); + public static final ItemType FIREWORKS_CHARGE = ItemType.of(ItemIds.FIREWORKS_CHARGE); //.maxStackSize(64).build(); + public static final ItemType ENCHANTED_BOOK = ItemType.of(ItemIds.ENCHANTED_BOOK); //.maxStackSize(1).build(); + public static final ItemType COMPARATOR = ItemType.of(ItemIds.COMPARATOR); //.maxStackSize(64).blockType(BlockTypes.COMPARATOR).build(); + public static final ItemType NETHERBRICK = ItemType.of(ItemIds.NETHERBRICK); //.maxStackSize(64).build(); + public static final ItemType QUARTZ = ItemType.of(ItemIds.QUARTZ); //.maxStackSize(64).build(); + public static final ItemType TNT_MINECART = ItemType.of(ItemIds.TNT_MINECART); //.maxStackSize(1).build(); + public static final ItemType HOPPER_MINECART = ItemType.of(ItemIds.HOPPER_MINECART); //.maxStackSize(1).build(); + public static final ItemType PRISMARINE_SHARD = ItemType.of(ItemIds.PRISMARINE_SHARD); //.maxStackSize(64).build(); + public static final ItemType HOPPER = ItemType.of(ItemIds.HOPPER); //.maxStackSize(64).blockType(BlockTypes.HOPPER).build(); + public static final ItemType RABBIT = ItemType.of(ItemIds.RABBIT); //.maxStackSize(64).build(); + public static final ItemType COOKED_RABBIT = ItemType.of(ItemIds.COOKED_RABBIT); //.maxStackSize(64).build(); + public static final ItemType RABBIT_STEW = ItemType.of(ItemIds.RABBIT_STEW); //.maxStackSize(64).build(); + public static final ItemType RABBIT_FOOT = ItemType.of(ItemIds.RABBIT_FOOT); //.maxStackSize(64).build(); + public static final ItemType RABBIT_HIDE = ItemType.of(ItemIds.RABBIT_HIDE); //.maxStackSize(64).build(); + public static final ItemType HORSE_ARMOR_LEATHER = ItemType.of(ItemIds.HORSE_ARMOR_LEATHER); //.maxStackSize(1).build(); + public static final ItemType HORSE_ARMOR_IRON = ItemType.of(ItemIds.HORSE_ARMOR_IRON); //.maxStackSize(1).build(); + public static final ItemType HORSE_ARMOR_GOLD = ItemType.of(ItemIds.HORSE_ARMOR_GOLD); //.maxStackSize(1).build(); + public static final ItemType HORSE_ARMOR_DIAMOND = ItemType.of(ItemIds.HORSE_ARMOR_DIAMOND); //.maxStackSize(1).build(); + public static final ItemType LEAD = ItemType.of(ItemIds.LEAD); //.maxStackSize(64).build(); + public static final ItemType NAME_TAG = ItemType.of(ItemIds.NAME_TAG); //.maxStackSize(64).build(); + public static final ItemType PRISMARINE_CRYSTALS = ItemType.of(ItemIds.PRISMARINE_CRYSTALS); //.maxStackSize(64).build(); + public static final ItemType MUTTON_RAW = ItemType.of(ItemIds.MUTTON_RAW); //.maxStackSize(64).build(); + public static final ItemType MUTTON_COOKED = ItemType.of(ItemIds.MUTTON_COOKED); //.maxStackSize(64).build(); + public static final ItemType ARMOR_STAND = ItemType.of(ItemIds.ARMOR_STAND); //.maxStackSize(64).build(); + public static final ItemType END_CRYSTAL = ItemType.of(ItemIds.END_CRYSTAL); //.maxStackSize(64).build(); + public static final ItemType CHORUS_FRUIT = ItemType.of(ItemIds.CHORUS_FRUIT); //.maxStackSize(64).build(); + public static final ItemType CHORUS_FRUIT_POPPED = ItemType.of(ItemIds.CHORUS_FRUIT_POPPED); //.maxStackSize(64).build(); + public static final ItemType DRAGON_BREATH = ItemType.of(ItemIds.DRAGON_BREATH); //.maxStackSize(64).build(); + public static final ItemType SPLASH_POTION = ItemType.of(ItemIds.SPLASH_POTION); //.maxStackSize(1).build(); + public static final ItemType LINGERING_POTION = ItemType.of(ItemIds.LINGERING_POTION); //.maxStackSize(1).build(); + public static final ItemType COMMAND_BLOCK_MINECART = ItemType.of(ItemIds.COMMAND_BLOCK_MINECART); //.maxStackSize(1).build(); + public static final ItemType ELYTRA = ItemType.of(ItemIds.ELYTRA); //.maxStackSize(1).build(); + public static final ItemType SHULKER_SHELL = ItemType.of(ItemIds.SHULKER_SHELL); //.maxStackSize(64).build(); + public static final ItemType BANNER = ItemType.of(ItemIds.BANNER); //.maxStackSize(16).fuelTime((short) 300).build(); + public static final ItemType BANNER_PATTERN = ItemType.of(ItemIds.BANNER_PATTERN); //.maxStackSize(1).build(); + public static final ItemType TOTEM = ItemType.of(ItemIds.TOTEM); //.maxStackSize(1).build(); + public static final ItemType IRON_NUGGET = ItemType.of(ItemIds.IRON_NUGGET); //.maxStackSize(64).build(); + public static final ItemType BOARD = ItemType.of(ItemIds.BOARD); //.maxStackSize(16).build(); + public static final ItemType PORTFOLIO = ItemType.of(ItemIds.PORTFOLIO); //.maxStackSize(64).build(); + public static final ItemType TRIDENT = ItemType.of(ItemIds.TRIDENT); //.maxStackSize(64).build(); + public static final ItemType BEETROOT = ItemType.of(ItemIds.BEETROOT); //.maxStackSize(54).blockType(BlockTypes.BEETROOT).build(); + public static final ItemType BEETROOT_SEEDS = ItemType.of(ItemIds.BEETROOT_SEEDS); //.maxStackSize(64).build(); + public static final ItemType BEETROOT_SOUP = ItemType.of(ItemIds.BEETROOT_SOUP); //.maxStackSize(1).build(); + public static final ItemType SALMON = ItemType.of(ItemIds.SALMON); //.maxStackSize(64).build(); + public static final ItemType CLOWNFISH = ItemType.of(ItemIds.TROPICAL_FISH); //.maxStackSize(64).build(); + public static final ItemType PUFFERFISH = ItemType.of(ItemIds.PUFFERFISH); //.maxStackSize(64).build(); + public static final ItemType COOKED_SALMON = ItemType.of(ItemIds.COOKED_SALMON); //.maxStackSize(64).build(); + public static final ItemType NAUTILUS_SHELL = ItemType.of(ItemIds.NAUTILUS_SHELL); //.maxStackSize(64).build(); + public static final ItemType DRIED_KELP = ItemType.of(ItemIds.DRIED_KELP); //.maxStackSize(64).build(); + public static final ItemType APPLE_ENCHANTED = ItemType.of(ItemIds.APPLE_ENCHANTED); //.maxStackSize(64).build(); + public static final ItemType HEART_OF_THE_SEA = ItemType.of(ItemIds.HEART_OF_THE_SEA); //.maxStackSize(64).build(); + public static final ItemType TURTLE_SHELL_PIECE = ItemType.of(ItemIds.TURTLE_SHELL_PIECE); //.maxStackSize(64).build(); + public static final ItemType TURTLE_HELMET = ItemType.of(ItemIds.TURTLE_HELMET); //.maxStackSize(1).build(); + public static final ItemType PHANTOM_MEMBRANE = ItemType.of(ItemIds.PHANTOM_MEMBRANE); //.maxStackSize(64).build(); + public static final ItemType CROSSBOW = ItemType.of(ItemIds.CROSSBOW); //.maxStackSize(1).build(); + public static final ItemType SWEET_BERRIES = ItemType.of(ItemIds.SWEET_BERRIES); //.maxStackSize(64).build(); + public static final ItemType CAMERA = ItemType.of(ItemIds.CAMERA); //.maxStackSize(64).build(); + public static final ItemType RECORD = ItemType.of(ItemIds.RECORD_13); //.maxStackSize(1).build(); + + public static final ItemType SUSPICIOUS_STEW = ItemType.of(ItemIds.SUSPICIOUS_STEW); //.build(); + public static final ItemType LODESTONE_COMPASS = ItemType.of(ItemIds.LODESTONE_COMPASS); //.build(); + public static final ItemType WARPED_FUNGUS_ON_A_STICK = ItemType.of(ItemIds.WARPED_FUNGUS_ON_STICK); //.build(); + + + public static final ItemType SHIELD = ItemType.of(ItemIds.SHIELD); //.maxStackSize(1).data(Damageable.class).build(); + public static final ItemType CAMPFIRE = ItemType.of(ItemIds.CAMPFIRE); //.maxStackSize(1).blockType(BlockTypes.CAMPFIRE).build(); + public static final ItemType HONEYCOMB = ItemType.of(ItemIds.HONEYCOMB); //.maxStackSize(64).build(); + public static final ItemType HONEY_BOTTLE = ItemType.of(ItemIds.HONEY_BOTTLE); //.maxStackSize(16).build(); + public static final ItemType NETHERITE_INGOT = ItemType.of(ItemIds.NETHERITE_INGOT); //.maxStackSize(64).build(); + public static final ItemType NETHERITE_SCRAP = ItemType.of(ItemIds.NETHERITE_SCRAP); //.build(); + public static final ItemType NETHERITE_SWORD = ItemType.of(ItemIds.NETHERITE_SWORD); //.maxStackSize(1).data(Damageable.class).toolType(SWORD).tierType(NETHERITE).attackDamage(9).build(); + public static final ItemType NETHERITE_SHOVEL = ItemType.of(ItemIds.NETHERITE_SHOVEL); //.maxStackSize(1).data(Damageable.class).toolType(SHOVEL).tierType(NETHERITE).attackDamage(6).build(); + public static final ItemType NETHERITE_PICKAXE = ItemType.of(ItemIds.NETHERITE_PICKAXE); //.maxStackSize(1).data(Damageable.class).toolType(PICKAXE).tierType(NETHERITE).attackDamage(6).build(); + public static final ItemType NETHERITE_AXE = ItemType.of(ItemIds.NETHERITE_AXE); //.maxStackSize(1).data(Damageable.class).toolType(AXE).tierType(NETHERITE).attackDamage(8).build(); + public static final ItemType NETHERITE_HOE = ItemType.of(ItemIds.NETHERITE_HOE); //.maxStackSize(1).data(Damageable.class).toolType(HOE).tierType(NETHERITE).attackDamage(6).build(); + public static final ItemType NETHERITE_HELMET = ItemType.of(ItemIds.NETHERITE_HELMET); //.maxStackSize(1).data(Damageable.class).tierType(NETHERITE).build(); + public static final ItemType NETHERITE_CHESTPLATE = ItemType.of(ItemIds.NETHERITE_CHESTPLATE); //.maxStackSize(1).data(Damageable.class).tierType(NETHERITE).build(); + public static final ItemType NETHERITE_LEGGINGS = ItemType.of(ItemIds.NETHERITE_LEGGINGS); //.maxStackSize(1).data(Damageable.class).tierType(NETHERITE).build(); + public static final ItemType NETHERITE_BOOTS = ItemType.of(ItemIds.NETHERITE_BOOTS); //.maxStackSize(1).data(Damageable.class).tierType(NETHERITE).build(); + public static final ItemType CONCRETE_POWDER = ItemType.of(ItemIds.CONCRETE_POWDER); //.maxStackSize(64).data(DyeColor.class).blockType(BlockTypes.CONCRETE_POWDER).build(); + public static final ItemType UNKNOWN = ItemType.of(Identifiers.UNKNOWN); + + public static final ItemType AMETHYST_SHARD = ItemType.of(ItemIds.AMETHYST_SHARD); //.build(); + public static final ItemType GLOW_BERRIES = ItemType.of(ItemIds.GLOW_BERRIES); //.build(); + public static final ItemType GLOW_INK_SAC = ItemType.of(ItemIds.GLOW_INK_SAC); //.build(); + public static final ItemType GOAT_HORN = ItemType.of(ItemIds.GOAT_HORN); //.build(); + public static final ItemType GLOW_FRAME = ItemType.of(ItemIds.GLOW_FRAME); //.build(); + public static final ItemType RAW_COPPER = ItemType.of(ItemIds.RAW_COPPER); //.build(); + public static final ItemType RAW_GOLD = ItemType.of(ItemIds.RAW_GOLD); //.build(); + public static final ItemType RAW_IRON = ItemType.of(ItemIds.RAW_IRON); //.build(); + public static final ItemType SPYGLASS = ItemType.of(ItemIds.SPYGLASS); //.build(); + public static final ItemType COPPER_INGOT = ItemType.of(ItemIds.COPPER_INGOT); //.build(); + + public static final ItemType LAPIS_LAZULI = ItemType.of(ItemIds.LAPIS_LAZULI); + + public static final ItemType DISC_FRAGMENT_5 = ItemType.of(ItemIds.DISC_FRAGMENT_5); + public static final ItemType RECOVERY_COMPASS = ItemType.of(ItemIds.RECOVERY_COMPASS); + public static final ItemType ECHO_CHARD = ItemType.of(ItemIds.ECHO_CHARD); } diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/BooleanItemBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/BooleanItemBehavior.java new file mode 100644 index 0000000..f4739f6 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/behavior/BooleanItemBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.item.behavior; + +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface BooleanItemBehavior { + + boolean get(Behavior behavior, ItemStack itemStack); + + @FunctionalInterface + interface Executor { + + boolean execute(ItemStack itemStack); + } +} diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/CanBePlacedOnBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/CanBePlacedOnBehavior.java new file mode 100644 index 0000000..82f6289 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/behavior/CanBePlacedOnBehavior.java @@ -0,0 +1,16 @@ +package org.cloudburstmc.api.item.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface CanBePlacedOnBehavior { + + boolean get(Behavior behavior, ItemStack item, Block block); + + @FunctionalInterface + interface Executor { + + boolean execute(ItemStack itemStack, Block block); + } +} diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/DamageChanceBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/DamageChanceBehavior.java new file mode 100644 index 0000000..8f62814 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/behavior/DamageChanceBehavior.java @@ -0,0 +1,13 @@ +package org.cloudburstmc.api.item.behavior; + +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface DamageChanceBehavior { + + int getDamageChance(Behavior executor, int unbreaking); + + interface Executor { + + int execute(int unbreaking); + } +} diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/DamageItemBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/DamageItemBehavior.java new file mode 100644 index 0000000..c3ba31e --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/behavior/DamageItemBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.item.behavior; + +import org.cloudburstmc.api.entity.Entity; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface DamageItemBehavior { + + ItemStack onDamage(Behavior behavior, ItemStack itemStack, int damage, Entity owner); + + interface Executor { + + ItemStack execute(ItemStack itemStack, int damage, Entity owner); + } +} diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/DestroySpeedBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/DestroySpeedBehavior.java new file mode 100644 index 0000000..7a1bae9 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/behavior/DestroySpeedBehavior.java @@ -0,0 +1,16 @@ +package org.cloudburstmc.api.item.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface DestroySpeedBehavior { + + float getDestroySpeed(Behavior behavior, ItemStack itemStack, Block block); + + @FunctionalInterface + interface Executor { + + float execute(ItemStack itemStack, Block block); + } +} diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/FloatItemBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/FloatItemBehavior.java new file mode 100644 index 0000000..ea2a3ec --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/behavior/FloatItemBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.item.behavior; + +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface FloatItemBehavior { + + float get(Behavior behavior, ItemStack itemStack); + + @FunctionalInterface + interface Executor { + + float execute(ItemStack itemStack); + } +} diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/GetItemBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/GetItemBehavior.java new file mode 100644 index 0000000..8f757de --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/behavior/GetItemBehavior.java @@ -0,0 +1,15 @@ +package org.cloudburstmc.api.item.behavior; + +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface GetItemBehavior { + + T get(Behavior> behavior, ItemStack item); + + @FunctionalInterface + interface Executor { + + T execute(ItemStack itemStack); + } +} diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/ItemBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/ItemBehavior.java index 23a1763..57e37fa 100644 --- a/src/main/java/org/cloudburstmc/api/item/behavior/ItemBehavior.java +++ b/src/main/java/org/cloudburstmc/api/item/behavior/ItemBehavior.java @@ -1,16 +1,17 @@ package org.cloudburstmc.api.item.behavior; -import com.nukkitx.math.vector.Vector3f; import org.cloudburstmc.api.block.Block; import org.cloudburstmc.api.block.BlockState; import org.cloudburstmc.api.entity.Entity; import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.item.ItemType; import org.cloudburstmc.api.item.TierType; import org.cloudburstmc.api.item.ToolType; import org.cloudburstmc.api.level.Level; import org.cloudburstmc.api.player.Player; import org.cloudburstmc.api.util.Direction; import org.cloudburstmc.api.util.Identifier; +import org.cloudburstmc.math.vector.Vector3f; public interface ItemBehavior { boolean canBeActivated(); @@ -61,6 +62,10 @@ public interface ItemBehavior { boolean isBoots(); + ToolType getToolType(ItemType type); + + TierType getTierType(ItemType type); + int getEnchantAbility(ItemStack item); int getAttackDamage(ItemStack item); diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/MineBlockBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/MineBlockBehavior.java new file mode 100644 index 0000000..9dacdf1 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/behavior/MineBlockBehavior.java @@ -0,0 +1,17 @@ +package org.cloudburstmc.api.item.behavior; + +import org.cloudburstmc.api.block.Block; +import org.cloudburstmc.api.entity.Entity; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.behavior.Behavior; + +public interface MineBlockBehavior { + + ItemStack mineBlock(Behavior behavior, ItemStack itemStack, Block block, Entity owner); + + @FunctionalInterface + interface Executor { + + ItemStack mineBlock(ItemStack itemStack, Block block, Entity owner); + } +} diff --git a/src/main/java/org/cloudburstmc/api/item/behavior/UseOnBehavior.java b/src/main/java/org/cloudburstmc/api/item/behavior/UseOnBehavior.java new file mode 100644 index 0000000..0c57790 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/item/behavior/UseOnBehavior.java @@ -0,0 +1,19 @@ +package org.cloudburstmc.api.item.behavior; + +import org.cloudburstmc.api.entity.Entity; +import org.cloudburstmc.api.item.ItemStack; +import org.cloudburstmc.api.util.Direction; +import org.cloudburstmc.api.util.behavior.Behavior; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.math.vector.Vector3i; + +public interface UseOnBehavior { + + ItemStack useOn(Behavior behavior, ItemStack itemStack, Entity entity, Vector3i blockPosition, Direction face, Vector3f clickPosition); + + @FunctionalInterface + interface Executor { + + ItemStack execute(ItemStack itemStack, Entity entity, Vector3i blockPosition, Direction face, Vector3f clickPosition); + } +} diff --git a/src/main/java/org/cloudburstmc/api/level/ChunkLoader.java b/src/main/java/org/cloudburstmc/api/level/ChunkLoader.java index 1476e49..1a85e32 100644 --- a/src/main/java/org/cloudburstmc/api/level/ChunkLoader.java +++ b/src/main/java/org/cloudburstmc/api/level/ChunkLoader.java @@ -1,7 +1,7 @@ package org.cloudburstmc.api.level; -import com.nukkitx.math.vector.Vector3f; import org.cloudburstmc.api.level.chunk.Chunk; +import org.cloudburstmc.math.vector.Vector3f; /** * author: MagicDroidX diff --git a/src/main/java/org/cloudburstmc/api/level/ChunkManager.java b/src/main/java/org/cloudburstmc/api/level/ChunkManager.java index c0f4904..3333789 100644 --- a/src/main/java/org/cloudburstmc/api/level/ChunkManager.java +++ b/src/main/java/org/cloudburstmc/api/level/ChunkManager.java @@ -1,14 +1,14 @@ package org.cloudburstmc.api.level; -import com.nukkitx.math.vector.Vector2i; -import com.nukkitx.math.vector.Vector3f; -import com.nukkitx.math.vector.Vector3i; -import com.nukkitx.math.vector.Vector4i; import org.checkerframework.checker.nullness.qual.Nullable; import org.cloudburstmc.api.block.Block; import org.cloudburstmc.api.block.BlockState; import org.cloudburstmc.api.level.chunk.Chunk; import org.cloudburstmc.api.player.Player; +import org.cloudburstmc.math.vector.Vector2i; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.math.vector.Vector3i; +import org.cloudburstmc.math.vector.Vector4i; import java.util.Set; import java.util.concurrent.CompletableFuture; diff --git a/src/main/java/org/cloudburstmc/api/level/Level.java b/src/main/java/org/cloudburstmc/api/level/Level.java index fc29168..91673b0 100644 --- a/src/main/java/org/cloudburstmc/api/level/Level.java +++ b/src/main/java/org/cloudburstmc/api/level/Level.java @@ -1,7 +1,5 @@ package org.cloudburstmc.api.level; -import com.nukkitx.math.vector.Vector3f; -import com.nukkitx.math.vector.Vector3i; import org.cloudburstmc.api.Server; import org.cloudburstmc.api.block.Block; import org.cloudburstmc.api.blockentity.BlockEntity; @@ -12,6 +10,8 @@ import org.cloudburstmc.api.player.Player; import org.cloudburstmc.api.util.AxisAlignedBB; import org.cloudburstmc.api.util.Direction; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.math.vector.Vector3i; import java.util.Map; import java.util.Set; @@ -210,4 +210,7 @@ default DroppedItem dropItem(Vector3f position, ItemStack item, Vector3f motion, Set getNearbyEntities(AxisAlignedBB bb, Entity entity, boolean loadChunks); + int getMinHeight(); + + int getMaxHeight(); } diff --git a/src/main/java/org/cloudburstmc/api/level/Location.java b/src/main/java/org/cloudburstmc/api/level/Location.java index 5ed676d..7e23e80 100644 --- a/src/main/java/org/cloudburstmc/api/level/Location.java +++ b/src/main/java/org/cloudburstmc/api/level/Location.java @@ -1,10 +1,10 @@ package org.cloudburstmc.api.level; -import com.nukkitx.math.vector.Vector3f; -import com.nukkitx.math.vector.Vector3i; import lombok.EqualsAndHashCode; import org.cloudburstmc.api.block.BlockState; import org.cloudburstmc.api.level.chunk.Chunk; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.math.vector.Vector3i; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/src/main/java/org/cloudburstmc/api/player/Player.java b/src/main/java/org/cloudburstmc/api/player/Player.java index 8101155..bc5302f 100644 --- a/src/main/java/org/cloudburstmc/api/player/Player.java +++ b/src/main/java/org/cloudburstmc/api/player/Player.java @@ -1,18 +1,17 @@ package org.cloudburstmc.api.player; -import com.nukkitx.math.vector.Vector3i; import org.cloudburstmc.api.Server; import org.cloudburstmc.api.blockentity.EnderChest; import org.cloudburstmc.api.crafting.CraftingGrid; import org.cloudburstmc.api.entity.Creature; import org.cloudburstmc.api.inventory.ContainerInventory; -import org.cloudburstmc.api.inventory.Inventory; import org.cloudburstmc.api.inventory.InventoryHolder; import org.cloudburstmc.api.inventory.PlayerInventory; import org.cloudburstmc.api.level.Level; import org.cloudburstmc.api.level.Location; import org.cloudburstmc.api.player.skin.Skin; import org.cloudburstmc.api.util.data.CardinalDirection; +import org.cloudburstmc.math.vector.Vector3i; import java.util.OptionalLong; import java.util.UUID; @@ -136,20 +135,6 @@ public interface Player extends Creature, InventoryHolder { GameMode getGamemode(); - byte getWindowId(Inventory inventory); - - default byte addWindow(Inventory window) { - return addWindow(window, null, false); - } - - default byte addWindow(Inventory window, Byte forceId) { - return addWindow(window, forceId, false); - } - - byte addWindow(Inventory window, Byte forceId, boolean isPermanent); - - void removeWindow(Inventory inventory); - String getDisplayName(); String getXuid(); diff --git a/src/main/java/org/cloudburstmc/api/potion/Effect.java b/src/main/java/org/cloudburstmc/api/potion/Effect.java index d6bbd38..535e665 100644 --- a/src/main/java/org/cloudburstmc/api/potion/Effect.java +++ b/src/main/java/org/cloudburstmc/api/potion/Effect.java @@ -1,10 +1,10 @@ package org.cloudburstmc.api.potion; -import com.nukkitx.math.vector.Vector3i; import lombok.Getter; import lombok.NonNull; import org.cloudburstmc.api.entity.Entity; import org.cloudburstmc.api.util.Identifier; +import org.cloudburstmc.math.vector.Vector3i; @Getter public abstract class Effect { diff --git a/src/main/java/org/cloudburstmc/api/potion/EffectType.java b/src/main/java/org/cloudburstmc/api/potion/EffectType.java index 7faae12..e426eaa 100644 --- a/src/main/java/org/cloudburstmc/api/potion/EffectType.java +++ b/src/main/java/org/cloudburstmc/api/potion/EffectType.java @@ -1,9 +1,9 @@ package org.cloudburstmc.api.potion; -import com.nukkitx.math.vector.Vector3i; import lombok.Getter; import org.checkerframework.checker.nullness.qual.Nullable; import org.cloudburstmc.api.util.Identifier; +import org.cloudburstmc.math.vector.Vector3i; import java.util.HashMap; diff --git a/src/main/java/org/cloudburstmc/api/potion/EffectTypes.java b/src/main/java/org/cloudburstmc/api/potion/EffectTypes.java index 9d4d8ca..d82d039 100644 --- a/src/main/java/org/cloudburstmc/api/potion/EffectTypes.java +++ b/src/main/java/org/cloudburstmc/api/potion/EffectTypes.java @@ -1,8 +1,8 @@ package org.cloudburstmc.api.potion; -import com.nukkitx.math.vector.Vector3i; import lombok.experimental.UtilityClass; import org.cloudburstmc.api.util.Identifiers; +import org.cloudburstmc.math.vector.Vector3i; @UtilityClass public class EffectTypes { diff --git a/src/main/java/org/cloudburstmc/api/registry/BehaviorRegistry.java b/src/main/java/org/cloudburstmc/api/registry/BehaviorRegistry.java new file mode 100644 index 0000000..329d0d6 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/registry/BehaviorRegistry.java @@ -0,0 +1,21 @@ +package org.cloudburstmc.api.registry; + +import org.cloudburstmc.api.data.BehaviorKey; +import org.cloudburstmc.api.util.behavior.BehaviorCollection; + +public interface BehaviorRegistry { + + void registerBehavior(BehaviorKey key, F defaultBehavior); + + void registerContextBehavior(BehaviorKey key, F defaultBehavior); + + F getDefaultBehavior(BehaviorKey key); + + BehaviorCollection getBehaviors(T type); + + default E getBehavior(T type, BehaviorKey key) { + return getBehaviors(type).get(key); + } + + GlobalRegistry global(); +} diff --git a/src/main/java/org/cloudburstmc/api/registry/BlockRegistry.java b/src/main/java/org/cloudburstmc/api/registry/BlockRegistry.java index 0593d53..44c6418 100644 --- a/src/main/java/org/cloudburstmc/api/registry/BlockRegistry.java +++ b/src/main/java/org/cloudburstmc/api/registry/BlockRegistry.java @@ -3,17 +3,20 @@ import com.google.common.collect.ImmutableList; import org.cloudburstmc.api.block.BlockState; import org.cloudburstmc.api.block.BlockType; -import org.cloudburstmc.api.block.behavior.BlockBehavior; +import org.cloudburstmc.api.data.BehaviorKey; import org.cloudburstmc.api.item.ItemStack; import org.cloudburstmc.api.util.Identifier; +import org.cloudburstmc.api.util.behavior.BehaviorCollection; -public interface BlockRegistry extends Registry { +public interface BlockRegistry extends BehaviorRegistry { - void register(BlockType type, BlockBehavior behavior) throws RegistryException; + BehaviorCollection register(BlockType type) throws RegistryException; - BlockBehavior getBehavior(BlockType type); + BehaviorCollection getBehaviors(BlockType type); - void overwriteBehavior(BlockType type, BlockBehavior behavior); + default T getBehavior(BlockType type, BehaviorKey key) { + return getBehaviors(type).get(key); + } boolean isBlock(Identifier id); diff --git a/src/main/java/org/cloudburstmc/api/registry/GameRuleRegistry.java b/src/main/java/org/cloudburstmc/api/registry/GameRuleRegistry.java index 8b80a45..ee2af03 100644 --- a/src/main/java/org/cloudburstmc/api/registry/GameRuleRegistry.java +++ b/src/main/java/org/cloudburstmc/api/registry/GameRuleRegistry.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.Set; -public interface GameRuleRegistry extends Registry { +public interface GameRuleRegistry { > void register(GameRule gameRule); diff --git a/src/main/java/org/cloudburstmc/api/registry/GlobalRegistry.java b/src/main/java/org/cloudburstmc/api/registry/GlobalRegistry.java new file mode 100644 index 0000000..18b3738 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/registry/GlobalRegistry.java @@ -0,0 +1,6 @@ +package org.cloudburstmc.api.registry; + +public interface GlobalRegistry { + + BehaviorRegistry getRegistry(Class typeClass); +} diff --git a/src/main/java/org/cloudburstmc/api/registry/ItemRegistry.java b/src/main/java/org/cloudburstmc/api/registry/ItemRegistry.java index 40f39b6..67a3067 100644 --- a/src/main/java/org/cloudburstmc/api/registry/ItemRegistry.java +++ b/src/main/java/org/cloudburstmc/api/registry/ItemRegistry.java @@ -1,32 +1,31 @@ package org.cloudburstmc.api.registry; import com.google.common.collect.ImmutableList; -import org.cloudburstmc.api.block.BlockState; +import org.cloudburstmc.api.data.BehaviorKey; import org.cloudburstmc.api.item.ItemStack; import org.cloudburstmc.api.item.ItemType; import org.cloudburstmc.api.item.behavior.ItemBehavior; import org.cloudburstmc.api.util.Identifier; +import org.cloudburstmc.api.util.behavior.BehaviorCollection; -public interface ItemRegistry extends Registry { +public interface ItemRegistry extends BehaviorRegistry { void register(ItemType type, ItemBehavior behavior, Identifier... identifiers) throws RegistryException; void registerCreativeItem(ItemStack item); - default ItemStack getItem(BlockState state) throws RegistryException { - return getItem(state, 1); - } - - ItemStack getItem(BlockState state, int amount) throws RegistryException; + BehaviorCollection getBehaviors(ItemType type); - default ItemStack getItem(ItemType type) throws RegistryException { - return getItem(type, 1); + default T getBehavior(ItemType type, BehaviorKey key) { + return getBehaviors(type).get(key); } - ItemStack getItem(ItemType type, int amount, Object... metadata) throws RegistryException; - Identifier getIdentifier(int runtimeId) throws RegistryException; + ItemType getType(Identifier runtimeId, int data); + + ItemType getType(int runtimeId, int data); + ImmutableList getItems(); } diff --git a/src/main/java/org/cloudburstmc/api/registry/RecipeRegistry.java b/src/main/java/org/cloudburstmc/api/registry/RecipeRegistry.java index cac5e8f..9732950 100644 --- a/src/main/java/org/cloudburstmc/api/registry/RecipeRegistry.java +++ b/src/main/java/org/cloudburstmc/api/registry/RecipeRegistry.java @@ -8,7 +8,7 @@ import java.util.Collection; import java.util.UUID; -public interface RecipeRegistry extends Registry { +public interface RecipeRegistry { void register(Recipe recipe) throws RegistryException; diff --git a/src/main/java/org/cloudburstmc/api/registry/Registry.java b/src/main/java/org/cloudburstmc/api/registry/Registry.java deleted file mode 100644 index 0b487df..0000000 --- a/src/main/java/org/cloudburstmc/api/registry/Registry.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.cloudburstmc.api.registry; - -public interface Registry { - - void close() throws RegistryException; -} diff --git a/src/main/java/org/cloudburstmc/api/registry/ResourcePackRegistry.java b/src/main/java/org/cloudburstmc/api/registry/ResourcePackRegistry.java index 133c434..aafa48b 100644 --- a/src/main/java/org/cloudburstmc/api/registry/ResourcePackRegistry.java +++ b/src/main/java/org/cloudburstmc/api/registry/ResourcePackRegistry.java @@ -1,4 +1,4 @@ package org.cloudburstmc.api.registry; -public interface ResourcePackRegistry extends Registry { +public interface ResourcePackRegistry { } diff --git a/src/main/java/org/cloudburstmc/api/util/AxisAlignedBB.java b/src/main/java/org/cloudburstmc/api/util/AxisAlignedBB.java index e2c75cf..154fe06 100644 --- a/src/main/java/org/cloudburstmc/api/util/AxisAlignedBB.java +++ b/src/main/java/org/cloudburstmc/api/util/AxisAlignedBB.java @@ -1,8 +1,8 @@ package org.cloudburstmc.api.util; -import com.nukkitx.math.GenericMath; -import com.nukkitx.math.vector.Vector3f; -import com.nukkitx.math.vector.Vector3i; +import org.cloudburstmc.math.GenericMath; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.math.vector.Vector3i; public interface AxisAlignedBB extends Cloneable { @@ -17,6 +17,10 @@ default AxisAlignedBB setBounds(float minX, float minY, float minZ, float maxX, return this; } + default AxisAlignedBB addCoord(Vector3i v) { + return addCoord(v.getX(), v.getY(), v.getZ()); + } + default AxisAlignedBB addCoord(Vector3f v) { return addCoord(v.getX(), v.getY(), v.getZ()); } diff --git a/src/main/java/org/cloudburstmc/api/util/Direction.java b/src/main/java/org/cloudburstmc/api/util/Direction.java index 2857d1e..8a3cb1d 100644 --- a/src/main/java/org/cloudburstmc/api/util/Direction.java +++ b/src/main/java/org/cloudburstmc/api/util/Direction.java @@ -1,10 +1,10 @@ package org.cloudburstmc.api.util; import com.google.common.collect.Iterators; -import com.nukkitx.math.GenericMath; -import com.nukkitx.math.vector.Vector3i; import lombok.RequiredArgsConstructor; import org.cloudburstmc.api.util.data.CardinalDirection; +import org.cloudburstmc.math.GenericMath; +import org.cloudburstmc.math.vector.Vector3i; import java.util.Iterator; import java.util.Random; diff --git a/src/main/java/org/cloudburstmc/api/util/MovingObjectPosition.java b/src/main/java/org/cloudburstmc/api/util/MovingObjectPosition.java index 1514b32..23b1cb9 100644 --- a/src/main/java/org/cloudburstmc/api/util/MovingObjectPosition.java +++ b/src/main/java/org/cloudburstmc/api/util/MovingObjectPosition.java @@ -1,8 +1,8 @@ package org.cloudburstmc.api.util; -import com.nukkitx.math.vector.Vector3f; -import com.nukkitx.math.vector.Vector3i; import org.cloudburstmc.api.entity.Entity; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.math.vector.Vector3i; /** * author: MagicDroidX diff --git a/src/main/java/org/cloudburstmc/api/util/Randoms.java b/src/main/java/org/cloudburstmc/api/util/Randoms.java new file mode 100644 index 0000000..aabf04e --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/util/Randoms.java @@ -0,0 +1,31 @@ +package org.cloudburstmc.api.util; + +import org.cloudburstmc.math.GenericMath; + +import java.util.random.RandomGenerator; + +public final class Randoms { + + public static int nextInclusiveInt(RandomGenerator random, int min, int max) { + if (min < max + 1) { + min += random.nextInt(max - min + 1); + } + return min; + } + + public static boolean chance(RandomGenerator random, int likeliness, int possibilities) { + return possibilities > 0 && (likeliness >= possibilities || + nextInclusiveInt(random, 1, possibilities) >= likeliness); + } + + public static boolean chanceInOne(RandomGenerator random, int possibilities) { + return chance(random, 1, possibilities); + } + + private static final float MIN_EXCESSIVE_IMPROBABILITY = Math.nextAfter(1f, 0f); + + public static boolean chanceFloatGreaterThan(RandomGenerator random, float improbability) { + return improbability < MIN_EXCESSIVE_IMPROBABILITY && + (improbability <= -GenericMath.FLT_EPSILON || improbability < random.nextFloat()); + } +} diff --git a/src/main/java/org/cloudburstmc/api/util/SimpleAxisAlignedBB.java b/src/main/java/org/cloudburstmc/api/util/SimpleAxisAlignedBB.java index bd52009..7936dfd 100644 --- a/src/main/java/org/cloudburstmc/api/util/SimpleAxisAlignedBB.java +++ b/src/main/java/org/cloudburstmc/api/util/SimpleAxisAlignedBB.java @@ -1,7 +1,7 @@ package org.cloudburstmc.api.util; -import com.nukkitx.math.vector.Vector3f; -import com.nukkitx.math.vector.Vector3i; +import org.cloudburstmc.math.vector.Vector3f; +import org.cloudburstmc.math.vector.Vector3i; /** * auth||: MagicDroidX diff --git a/src/main/java/org/cloudburstmc/api/util/behavior/Behavior.java b/src/main/java/org/cloudburstmc/api/util/behavior/Behavior.java new file mode 100644 index 0000000..9ec3850 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/util/behavior/Behavior.java @@ -0,0 +1,35 @@ +package org.cloudburstmc.api.util.behavior; + +import org.checkerframework.checker.nullness.qual.NonNull; +import org.cloudburstmc.api.data.BehaviorKey; +import org.cloudburstmc.api.registry.BehaviorRegistry; + +public interface Behavior { + + /** + * Returns the parent function or the default if nothing is set. + * + * @return function + */ + @NonNull + E parent(); + + /** + * Get a behavior for a specified key + * + * @param key behavior key + * @param function type + * @return behavior function + */ + T get(BehaviorKey key); + + /** + * Retrieves a {@link BehaviorRegistry} for the given class. + * + * @param type class of registry type + * @param registry type + * @return behavior registry + * @throws IllegalArgumentException if registry type does not exist + */ + BehaviorRegistry getRegistry(Class type); +} diff --git a/src/main/java/org/cloudburstmc/api/util/behavior/BehaviorBuilder.java b/src/main/java/org/cloudburstmc/api/util/behavior/BehaviorBuilder.java new file mode 100644 index 0000000..9f509e6 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/util/behavior/BehaviorBuilder.java @@ -0,0 +1,72 @@ +package org.cloudburstmc.api.util.behavior; + +import org.cloudburstmc.api.data.BehaviorKey; + +import java.util.*; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +public final class BehaviorBuilder { + + private final Map, List> behaviors = new IdentityHashMap<>(); + + private BehaviorBuilder() { + } + + public static BehaviorBuilder create() { + return new BehaviorBuilder(); + } + + public static BehaviorBuilder extend(BehaviorBuilder builder) { + BehaviorBuilder extendedBuilder = new BehaviorBuilder(); + extendedBuilder.behaviors.putAll(builder.behaviors); + return extendedBuilder; + } + + public BehaviorBuilder extend(BehaviorKey key, T function) { + checkNotNull(key, "key"); + checkNotNull(function, "function"); + checkArgument(key.getType() == function.getClass(), "%s does not match expected type of %s for '%s'", + function.getClass(), key.getType(), key.getId()); + + List functions = this.behaviors.computeIfAbsent(key, behaviorKey -> { + var list = new ArrayList<>(); + list.add(null); + return list; + }); + + functions.add(function); + return this; + } + + public BehaviorBuilder overwrite(BehaviorKey key, T function) { + checkNotNull(key, "key"); + checkNotNull(function, "function"); + checkArgument(key.getType().isInstance(function), "%s does not match expected type of %s for '%s'", + function.getClass(), key.getType(), key.getId()); + + List functions = this.behaviors.computeIfAbsent(key, behaviorKey -> new ArrayList<>()); + + functions.clear(); + functions.add(function); + return this; + } + + @SuppressWarnings("unchecked") + public void applyTo(BehaviorCollection collection) { + for (Map.Entry, List> entry : this.behaviors.entrySet()) { + ListIterator iterator = entry.getValue().listIterator(); + + Object function = iterator.next(); + if (function == null) { + collection.extend((BehaviorKey) entry.getKey(), iterator.next()); + } else { + collection.overwrite((BehaviorKey) entry.getKey(), function); + } + while (iterator.hasNext()) { + collection.extend((BehaviorKey) entry.getKey(), iterator.next()); + } + } + } +} diff --git a/src/main/java/org/cloudburstmc/api/util/behavior/BehaviorCollection.java b/src/main/java/org/cloudburstmc/api/util/behavior/BehaviorCollection.java new file mode 100644 index 0000000..ae837bc --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/util/behavior/BehaviorCollection.java @@ -0,0 +1,50 @@ +package org.cloudburstmc.api.util.behavior; + +import org.cloudburstmc.api.data.BehaviorKey; +import org.cloudburstmc.api.registry.BehaviorRegistry; + +public interface BehaviorCollection { + + /** + * Get behavior for specified key + * + * @param key behavior key + * @param function type + * @return function + */ + T get(BehaviorKey key); + + /** + * Extend existing functionality for this key + * + * @param key behavior key + * @param function function to extend + * @param function type + * @return this behavior collection + */ + BehaviorCollection extend(BehaviorKey key, T function); + + /** + * Overwrite default functionality for this key + * + * @param key behavior key + * @param function function to overwrite + * @param function type + * @return this behavior collection + */ + BehaviorCollection overwrite(BehaviorKey key, T function); + + /** + * Applies all behaviors in a {@link BehaviorBuilder} to the specified collection. + * + * @param builder builder + */ + void apply(BehaviorBuilder builder); + + /** + * Get the registry that this behavior collection belongs to. + * + * @return behavior registry + */ + BehaviorRegistry getRegistry(); +} diff --git a/src/main/java/org/cloudburstmc/api/util/behavior/FloatBehavior.java b/src/main/java/org/cloudburstmc/api/util/behavior/FloatBehavior.java new file mode 100644 index 0000000..29c4671 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/util/behavior/FloatBehavior.java @@ -0,0 +1,11 @@ +package org.cloudburstmc.api.util.behavior; + +public interface FloatBehavior { + + float get(Behavior behavior); + + @FunctionalInterface + interface Executor { + float execute(); + } +} diff --git a/src/main/java/org/cloudburstmc/api/util/behavior/IntBehavior.java b/src/main/java/org/cloudburstmc/api/util/behavior/IntBehavior.java new file mode 100644 index 0000000..52f7a83 --- /dev/null +++ b/src/main/java/org/cloudburstmc/api/util/behavior/IntBehavior.java @@ -0,0 +1,11 @@ +package org.cloudburstmc.api.util.behavior; + +public interface IntBehavior { + + int get(Behavior behavior); + + @FunctionalInterface + interface Executor { + int execute(); + } +} diff --git a/src/main/java/org/cloudburstmc/api/util/data/TreeSpecies.java b/src/main/java/org/cloudburstmc/api/util/data/TreeSpecies.java index aee27b5..2a686a7 100644 --- a/src/main/java/org/cloudburstmc/api/util/data/TreeSpecies.java +++ b/src/main/java/org/cloudburstmc/api/util/data/TreeSpecies.java @@ -9,6 +9,5 @@ public enum TreeSpecies { DARK_OAK, CRIMSON, WARPED, - MANGROVE, }