Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: use default GlowKit BoundingBox & nullability annotations #1131

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
200 changes: 98 additions & 102 deletions src/main/java/net/glowstone/GlowWorld.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face,

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
// This is replicated from BlockNeedsTool and has been copy/pasted because classes cannot
// extend 2 parents
ToolType neededTool = ToolType.PICKAXE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static List<Pattern> fromNbt(List<CompoundTag> tag) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
GlowBanner state = (GlowBanner) block.getState();
ItemStack drop = new ItemStack(Material.LEGACY_BANNER, 1);
BannerMeta meta = (BannerMeta) drop.getItemMeta();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/block/blocktype/BlockBed.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static Block getExitLocation(GlowBlock head, GlowBlock foot) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
return Collections.singletonList(new ItemStack(block.getType(), 1,
(((GlowBed) block.getState()).getColor().getWoolData())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private boolean canPlaceNear(Material type) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock me, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock me, ItemStack tool) {
// Overridden for cactus to remove data from the dropped item
return Collections.unmodifiableList(Arrays.asList(new ItemStack(Material.CACTUS)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class BlockCarrot extends BlockCrops {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
if (block.getData() >= CropState.RIPE.ordinal()) {
return Collections.unmodifiableList(Arrays.asList(
new ItemStack(Material.CARROT, ThreadLocalRandom.current().nextInt(4) + 1)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BlockChorusPlant extends BlockType {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
if (ThreadLocalRandom.current().nextBoolean()) {
return Collections
.unmodifiableList(Arrays.asList(new ItemStack(Material.CHORUS_FRUIT, 1)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against)

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
MaterialData data = block.getState().getData();
if (data instanceof CocoaPlant) {
int amount = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public boolean blockInteract(GlowPlayer player, GlowBlock block, BlockFace face,

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
Collection<ItemStack> drops = getContentDrops(block);

MaterialMatcher neededTool = getNeededMiningTool(block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against)

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
if (block.getData() >= CropState.RIPE.ordinal()) {
return Collections.unmodifiableList(
Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against)

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock me, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock me, ItemStack tool) {
// If the block below the dead bush is removed,
// the bush will simply disappear without dropping anything.
if (tool == null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/block/blocktype/BlockDirt.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class BlockDirt extends BlockType {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
//TODO switch to MaterialData instead of using magic values
if (block.getData() == 1) {
//Coarse dirt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void afterPlace(GlowPlayer player, GlowBlock block, ItemStack holding,

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
Bisected data = getCastedBlockData(Bisected.class, block.getBlockData());
if (block.getType() != Material.TALL_GRASS
&& block.getType() != Material.LARGE_FERN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private ItemStack getDrops(GlowBlock block) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
if (Tag.WOODEN_SLABS.isTagged(block.getType())
|| tool != null && ToolType.PICKAXE.matches(tool.getType())) {
return getMinedDrops(block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class BlockDropless extends BlockType {

@NotNull
@Override
public final Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public final Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void onOpened(GlowPlayer player, GlowBlock block, BlockFace face, Vect

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
return Arrays.asList(new ItemStack(block.getType()));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/block/blocktype/BlockFire.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face,

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
return Collections.emptyList();
}

Expand Down
13 changes: 6 additions & 7 deletions src/main/java/net/glowstone/block/blocktype/BlockFlowerPot.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package net.glowstone.block.blocktype;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import net.glowstone.block.GlowBlock;
import net.glowstone.block.GlowBlockState;
import net.glowstone.block.entity.BlockEntity;
Expand All @@ -15,17 +20,11 @@
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class BlockFlowerPot extends BlockType {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
List<ItemStack> drops = new LinkedList<>(Arrays.asList(new ItemStack(Material.FLOWER_POT)));
GlowBlockState state = block.getState();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public BlockGravel() {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
return Collections.unmodifiableList(Arrays.asList(new ItemStack(
ThreadLocalRandom.current().nextInt(10) == 1 ? Material.FLINT : Material.GRAVEL, 1)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public BlockHugeMushroom(boolean isRedMushroom) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
int rnd = ThreadLocalRandom.current().nextInt(100);
if (rnd < 80) {
return Collections.emptyList();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/block/blocktype/BlockIce.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BlockIce extends BlockType {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock me, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock me, ItemStack tool) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void blockDestroy(GlowPlayer player, GlowBlock block, BlockFace face) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
ItemStack disk = ((GlowJukebox) block.getState()).getRecord();
if (disk == null) {
return Arrays.asList(new ItemStack(block.getType()));
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/net/glowstone/block/blocktype/BlockLeaves.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package net.glowstone.block.blocktype;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import net.glowstone.EventFactory;
import net.glowstone.GlowWorld;
import net.glowstone.block.GlowBlock;
Expand All @@ -12,13 +18,6 @@
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class BlockLeaves extends BlockType {

private static final int LEAVE_BLOCK_DECAY_RANGE = 6;
Expand All @@ -36,7 +35,7 @@ public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face,

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
int data = block.getData() & 0x03; //ignore "non-decay" and "check-decay" data.

if (tool != null && tool.getType() == Material.SHEARS) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/block/blocktype/BlockLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face,

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
// TODO: 1.13 log types
return Arrays
.asList(new ItemStack(Material.LEGACY_LOG, 1, (short) (block.getData() & 0x03)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class BlockMelon extends BlockType {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
return Collections.unmodifiableList(Arrays
.asList(new ItemStack(Material.MELON, ThreadLocalRandom.current().nextInt(5) + 3)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void blockDestroy(GlowPlayer player, GlowBlock block, BlockFace face) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
// monster egg blocks do not drop blocks
return new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public abstract class BlockNeedsTool extends BlockType {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
MaterialMatcher neededTool = getNeededMiningTool(block);
if (neededTool != null
&& (tool == null || !neededTool.matches(tool.getType()))) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/block/blocktype/BlockOre.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public BlockOre(Material dropType, MaterialMatcher neededTool) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
// TODO: Implement Silk Touch
ThreadLocalRandom random = ThreadLocalRandom.current();
int count = minCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class BlockPotato extends BlockCrops {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
if (block.getData() >= CropState.RIPE.ordinal()) {
if (ThreadLocalRandom.current().nextInt(100) < 2) {
return Collections.unmodifiableList(Arrays.asList(
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/net/glowstone/block/blocktype/BlockRails.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package net.glowstone.block.blocktype;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import net.glowstone.block.GlowBlock;
import net.glowstone.block.GlowBlockState;
import net.glowstone.entity.GlowPlayer;
Expand All @@ -8,13 +14,6 @@
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class BlockRails extends BlockNeedsAttached {

private static final int NORTH = 0;
Expand Down Expand Up @@ -145,7 +144,7 @@ private static boolean isRailBlock(GlowBlock block) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
return Arrays.asList(new ItemStack(block.getType()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ && isMatchingSapling(b.getRelative(BlockFace.SOUTH_EAST), data)) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
// TODO: 1.13 sapling types
return Arrays
.asList(new ItemStack(Material.LEGACY_SAPLING, 1, (short) (block.getData() % 8)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void afterPlace(GlowPlayer player, GlowBlock block, ItemStack holding,

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
GlowSkull skull = (GlowSkull) block.getState();
Material skullMaterial = SKULL_MATERIALS.get(skull.getSkullType());
ItemStack drop = new ItemStack(skullMaterial, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/block/blocktype/BlockSlab.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean canAbsorb(GlowBlock block, BlockFace face, ItemStack holding) {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
// todo: 1.13 new slab types
if (block.getType() == Material.LEGACY_WOOD_STEP
|| tool != null && ToolType.PICKAXE.matches(tool.getType())) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/block/blocktype/BlockSnow.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face,

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
if (tool != null && ToolType.SHOVEL.matches(tool.getType())) {
return Arrays.asList(new ItemStack(Material.SNOWBALL, block.getData() + 1));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class BlockSnowBlock extends BlockType {

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
if (tool != null && ToolType.SHOVEL.matches(tool.getType())) {
return Arrays.asList(new ItemStack(Material.SNOWBALL, 4));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face,

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
if (isWoodenStair(block.getType())
|| tool != null && ToolType.PICKAXE.matches(tool.getType())) {
return getMinedDrops(block);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/glowstone/block/blocktype/BlockStem.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public boolean canPlaceAt(GlowPlayer player, GlowBlock block, BlockFace against)

@NotNull
@Override
public Collection<ItemStack> getDrops(GlowBlock block, ItemStack tool) {
public Collection<ItemStack> getDrops(@NotNull GlowBlock block, ItemStack tool) {
if (block.getState().getRawData() >= CropState.RIPE.ordinal()) {
return Collections.unmodifiableList(
Arrays.asList(new ItemStack(seedsType, ThreadLocalRandom.current().nextInt(4))));
Expand Down