Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Refactor ItemStack and Behavior API #10

Draft
wants to merge 48 commits into
base: bleeding
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
571d41a
Begin implementing DataKey components
SupremeMortal Oct 16, 2021
94496d8
Add more block behaviours
SupremeMortal Oct 17, 2021
d97a36d
Figure out the base implementation for behaviours
SupremeMortal Oct 23, 2021
e6c6e4a
Remove BlockState#getBehavior and references
SupremeMortal Oct 23, 2021
e8bd5ed
Use executor generic parameter for Behavior
SupremeMortal Oct 23, 2021
df6bc9c
Correct values for new MaterialTypes
SupremeMortal Oct 23, 2021
6f62f1d
Add some more block behaviors
SupremeMortal Oct 24, 2021
c4d1a28
Some more block behaviours
SupremeMortal Oct 30, 2021
7165773
Refactor some behaviour and block methods
SupremeMortal Oct 30, 2021
bff6559
More refactoring of blocks and items
SupremeMortal Dec 20, 2021
8a72121
Continue working on item behaviours
SupremeMortal Apr 23, 2022
c82026c
Add Vector3i version of AxisAlignedBB#addCoord
SupremeMortal Apr 23, 2022
4b276c5
Add CAN_DESTROY item behaviour
SupremeMortal Apr 23, 2022
dcb8bae
Create MapDataKey for enchantments
SupremeMortal Apr 23, 2022
e578359
Merge branch 'dev/v1.18.30' into refactor/items-and-behavior
ApocalypsjeNL Apr 25, 2022
74be65b
Add checkerframework exclusions
SupremeMortal Apr 25, 2022
d428e86
Fixed a couple of issues and added the Filtered Light block behaviour
ApocalypsjeNL Apr 25, 2022
30576bc
Added ItemLore key
ApocalypsjeNL Apr 26, 2022
8587777
Fixed the ItemRegistry generic type
ApocalypsjeNL Apr 28, 2022
1c0f148
Adding these back works for me
SupremeMortal Apr 28, 2022
3aeb7e5
Expand available item behaviours
SupremeMortal Apr 28, 2022
883713d
Add damage related behaviours
SupremeMortal Apr 28, 2022
f48c7ff
Implement get_map_color block behavior
SupremeMortal Apr 29, 2022
8880902
Added BOOK_DATA item key and increased the compiler error amount
ApocalypsjeNL May 3, 2022
e6de19e
Added resistance behaviour, map item key and ItemStack comparables
ApocalypsjeNL May 3, 2022
6501845
Added attack damage behaviour
ApocalypsjeNL May 4, 2022
8eac701
Added some more behaviours
ApocalypsjeNL May 5, 2022
2d06fea
Updating lombok dependency
ApocalypsjeNL May 7, 2022
66083c4
Replaced lombok non-null check with Google's one
ApocalypsjeNL May 13, 2022
23c2c07
Added a default blockstate to blocks that don't have one provided
ApocalypsjeNL May 13, 2022
ead2197
Use isInstance for behaviour checks
SupremeMortal May 13, 2022
3d75bc4
Refactor block placing
Creeperface01 Jun 13, 2022
351958c
Merge pull request #16 from Creeperface01/refactor/items/block-placing
Creeperface01 Jun 15, 2022
7cb3a1b
Merge remote-tracking branch 'origin/bleeding' into refactor/items-an…
Creeperface01 Jun 15, 2022
0932dae
Fix compilation
Creeperface01 Jun 15, 2022
b53fd2f
Merge remote-tracking branch 'origin/refactor/items-and-behavior' int…
Creeperface01 Jun 15, 2022
5fa59a9
Fix item serialization
Creeperface01 Jul 9, 2022
ef9192e
Fix item serialization
Creeperface01 Jul 9, 2022
e91d2d9
Merge remote-tracking branch 'origin/refactor/items-and-behavior' int…
Creeperface01 Jul 9, 2022
e2f9e75
Merge branch 'bleeding' into refactor/items-and-behavior
SupremeMortal Aug 12, 2022
1c4f070
Add default values for DataKeys
SupremeMortal Aug 12, 2022
9a99e9f
Separate behaviour registration into contextual and not
SupremeMortal Aug 14, 2022
95e5931
Add more behaviours
SupremeMortal Aug 20, 2022
cdc4112
Modularise block breaking
SupremeMortal Aug 20, 2022
0b4d882
Use math 2.0 library
SupremeMortal Nov 26, 2022
131e8cc
Minor changes for protocol v3
SupremeMortal Dec 17, 2022
6d89066
Rename ItemStack `AIR` to `EMPTY`
SupremeMortal Dec 21, 2022
6b6b724
Inventory API changes
SupremeMortal Apr 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.jupiter.version>5.7.1</junit.jupiter.version>
<jackson.version>2.13.1</jackson.version>
<jackson.version>2.13.2</jackson.version>
<checkerframework.version>3.18.1</checkerframework.version>
</properties>

Expand Down Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
<version>2.13.2.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
Expand All @@ -103,13 +103,19 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
<version>30.0-android</version>
<exclusions>
<exclusion>
<groupId>org.checkerframework</groupId>
<artifactId>checker-compat-qual</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.nukkitx</groupId>
<artifactId>math</artifactId>
<version>1.1.1</version>
<groupId>org.cloudburstmc.math</groupId>
<artifactId>immutable</artifactId>
<version>2.0</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -138,9 +144,15 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<version>1.18.24</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Xmaxerrs</arg>
<arg>1000</arg>
<arg>-Xmaxwarns</arg>
<arg>2000</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
exports org.cloudburstmc.api.inventory.screen;
}
101 changes: 7 additions & 94 deletions src/main/java/org/cloudburstmc/api/block/Block.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -18,6 +19,10 @@ public interface Block extends BlockSnapshot {

Vector3i getPosition();

BehaviorCollection getBehaviors();

int getBrightness();

default int getX() {
return getPosition().getX();
}
Expand All @@ -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);
}
Expand Down
Loading