mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 13:08:19 +01:00
Cleanup...
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
026550ac07
commit
8cbd6460f4
@ -7,7 +7,6 @@ import net.minestom.server.entity.Entity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Supplier;
|
||||
@ -105,20 +104,15 @@ public class BoundingBox {
|
||||
public boolean intersectWithBlock(int blockX, int blockY, int blockZ) {
|
||||
final double offsetX = 1;
|
||||
final double maxX = (double) blockX + offsetX;
|
||||
|
||||
final boolean checkX = getMinX() < maxX && getMaxX() > (double) blockX;
|
||||
if (!checkX)
|
||||
return false;
|
||||
if (!checkX) return false;
|
||||
|
||||
final double maxY = (double) blockY + 0.99999;
|
||||
|
||||
final boolean checkY = getMinY() < maxY && getMaxY() > (double) blockY;
|
||||
if (!checkY)
|
||||
return false;
|
||||
if (!checkY) return false;
|
||||
|
||||
final double offsetZ = 1;
|
||||
final double maxZ = (double) blockZ + offsetZ;
|
||||
|
||||
// Z check
|
||||
return getMinZ() < maxZ && getMaxZ() > (double) blockZ;
|
||||
}
|
||||
@ -170,7 +164,6 @@ public class BoundingBox {
|
||||
*/
|
||||
public boolean intersect(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
// originally from http://www.3dkingdoms.com/weekly/weekly.php?a=3
|
||||
|
||||
double x3 = getMinX();
|
||||
double x4 = getMaxX();
|
||||
double y3 = getMinY();
|
||||
@ -181,8 +174,8 @@ public class BoundingBox {
|
||||
return true;
|
||||
}
|
||||
if (x1 < x3 && x2 < x3 || x1 > x4 && x2 > x4 ||
|
||||
y1 < y3 && y2 < y3 || y1 > y4 && y2 > y4 ||
|
||||
z1 < z3 && z2 < z3 || z1 > z4 && z2 > z4) {
|
||||
y1 < y3 && y2 < y3 || y1 > y4 && y2 > y4 ||
|
||||
z1 < z3 && z2 < z3 || z1 > z4 && z2 > z4) {
|
||||
return false;
|
||||
}
|
||||
return isInsideBoxWithAxis(Axis.X, getSegmentIntersection(x1 - x3, x2 - x3, x1, y1, z1, x2, y2, z2)) ||
|
||||
@ -197,7 +190,7 @@ public class BoundingBox {
|
||||
* Used to know if the bounding box intersects a line segment.
|
||||
*
|
||||
* @param start first line segment point
|
||||
* @param end second line segment point
|
||||
* @param end second line segment point
|
||||
* @return true if the bounding box intersects with the line segment, false otherwise.
|
||||
*/
|
||||
public boolean intersect(@NotNull Point start, @NotNull Point end) {
|
||||
@ -212,10 +205,8 @@ public class BoundingBox {
|
||||
}
|
||||
|
||||
private @Nullable Vec getSegmentIntersection(double dst1, double dst2, double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||
if (dst1 == dst2 || dst1 * dst2 >= 0D) {
|
||||
return null;
|
||||
}
|
||||
double delta = dst1 / (dst1 - dst2);
|
||||
if (dst1 == dst2 || dst1 * dst2 >= 0D) return null;
|
||||
final double delta = dst1 / (dst1 - dst2);
|
||||
return new Vec(
|
||||
x1 + (x2 - x1) * delta,
|
||||
y1 + (y2 - y1) * delta,
|
||||
@ -224,9 +215,7 @@ public class BoundingBox {
|
||||
}
|
||||
|
||||
private boolean isInsideBoxWithAxis(Axis axis, @Nullable Vec intersection) {
|
||||
if (intersection == null) {
|
||||
return false;
|
||||
}
|
||||
if (intersection == null) return false;
|
||||
double x1 = getMinX();
|
||||
double x2 = getMaxX();
|
||||
double y1 = getMinY();
|
||||
@ -246,8 +235,7 @@ public class BoundingBox {
|
||||
* @param z the Z offset
|
||||
* @return a new {@link BoundingBox} expanded
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox expand(double x, double y, double z) {
|
||||
public @NotNull BoundingBox expand(double x, double y, double z) {
|
||||
return new BoundingBox(entity, this.x + x, this.y + y, this.z + z);
|
||||
}
|
||||
|
||||
@ -259,8 +247,7 @@ public class BoundingBox {
|
||||
* @param z the Z offset
|
||||
* @return a new bounding box contracted
|
||||
*/
|
||||
@NotNull
|
||||
public BoundingBox contract(double x, double y, double z) {
|
||||
public @NotNull BoundingBox contract(double x, double y, double z) {
|
||||
return new BoundingBox(entity, this.x - x, this.y - y, this.z - z);
|
||||
}
|
||||
|
||||
@ -415,8 +402,7 @@ public class BoundingBox {
|
||||
X, Y, Z
|
||||
}
|
||||
|
||||
private class CachedFace {
|
||||
|
||||
private final class CachedFace {
|
||||
private final AtomicReference<@Nullable PositionedPoints> reference = new AtomicReference<>(null);
|
||||
private final Supplier<@NotNull List<Vec>> faceProducer;
|
||||
|
||||
@ -434,11 +420,9 @@ public class BoundingBox {
|
||||
return value;
|
||||
}).points;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class PositionedPoints {
|
||||
|
||||
private static final class PositionedPoints {
|
||||
private final @NotNull Pos lastPosition;
|
||||
private final @NotNull List<Vec> points;
|
||||
|
||||
@ -446,7 +430,5 @@ public class BoundingBox {
|
||||
this.lastPosition = lastPosition;
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import net.minestom.server.event.entity.EntityFireEvent;
|
||||
import net.minestom.server.event.item.EntityEquipEvent;
|
||||
import net.minestom.server.event.item.PickupItemEvent;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.inventory.EquipmentHandler;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.ConnectionState;
|
||||
@ -37,7 +36,6 @@ import java.time.Duration;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
|
||||
|
@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class EntityItemMergeEvent implements EntityEvent, CancellableEvent {
|
||||
|
||||
private Entity entity;
|
||||
private final Entity entity;
|
||||
private final ItemEntity merged;
|
||||
private ItemStack result;
|
||||
|
||||
@ -31,9 +31,8 @@ public class EntityItemMergeEvent implements EntityEvent, CancellableEvent {
|
||||
*
|
||||
* @return the source ItemEntity
|
||||
*/
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemEntity getEntity() {
|
||||
public @NotNull ItemEntity getEntity() {
|
||||
return (ItemEntity) entity;
|
||||
}
|
||||
|
||||
@ -44,8 +43,7 @@ public class EntityItemMergeEvent implements EntityEvent, CancellableEvent {
|
||||
*
|
||||
* @return the merged ItemEntity
|
||||
*/
|
||||
@NotNull
|
||||
public ItemEntity getMerged() {
|
||||
public @NotNull ItemEntity getMerged() {
|
||||
return merged;
|
||||
}
|
||||
|
||||
@ -54,8 +52,7 @@ public class EntityItemMergeEvent implements EntityEvent, CancellableEvent {
|
||||
*
|
||||
* @return the item stack
|
||||
*/
|
||||
@NotNull
|
||||
public ItemStack getResult() {
|
||||
public @NotNull ItemStack getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -321,8 +321,7 @@ public class ExtensionManager {
|
||||
*
|
||||
* @return A list of discovered extensions from this folder.
|
||||
*/
|
||||
@NotNull
|
||||
private List<DiscoveredExtension> discoverExtensions() {
|
||||
private @NotNull List<DiscoveredExtension> discoverExtensions() {
|
||||
List<DiscoveredExtension> extensions = new LinkedList<>();
|
||||
|
||||
File[] fileList = extensionFolder.listFiles();
|
||||
@ -378,9 +377,8 @@ public class ExtensionManager {
|
||||
* @param file The jar to grab it from (a .jar is a formatted .zip file)
|
||||
* @return The created DiscoveredExtension.
|
||||
*/
|
||||
@Nullable
|
||||
private DiscoveredExtension discoverFromJar(@NotNull File file) {
|
||||
try (ZipFile f = new ZipFile(file);) {
|
||||
private @Nullable DiscoveredExtension discoverFromJar(@NotNull File file) {
|
||||
try (ZipFile f = new ZipFile(file)) {
|
||||
|
||||
ZipEntry entry = f.getEntry("extension.json");
|
||||
|
||||
|
@ -13,7 +13,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -86,17 +85,17 @@ public class ItemMeta implements TagReadable, Writeable {
|
||||
|
||||
@Contract(pure = true)
|
||||
public @NotNull List<@NotNull Component> getLore() {
|
||||
return Collections.unmodifiableList(lore);
|
||||
return lore;
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
public @NotNull Map<Enchantment, Short> getEnchantmentMap() {
|
||||
return Collections.unmodifiableMap(enchantmentMap);
|
||||
return enchantmentMap;
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
public @NotNull List<@NotNull ItemAttribute> getAttributes() {
|
||||
return Collections.unmodifiableList(attributes);
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
@ -106,12 +105,12 @@ public class ItemMeta implements TagReadable, Writeable {
|
||||
|
||||
@Contract(pure = true)
|
||||
public @NotNull Set<@NotNull Block> getCanDestroy() {
|
||||
return Collections.unmodifiableSet(canDestroy);
|
||||
return canDestroy;
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
public @NotNull Set<@NotNull Block> getCanPlaceOn() {
|
||||
return Collections.unmodifiableSet(canPlaceOn);
|
||||
return canPlaceOn;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,16 +47,16 @@ public class FireworkEffect {
|
||||
List<Color> secondaryColor = new ArrayList<>();
|
||||
|
||||
if (compound.containsKey("Colors")) {
|
||||
int[] color = compound.getIntArray("Colors");
|
||||
for (int i = 0; i < color.length; i++) {
|
||||
primaryColor.add(new Color(color[i]));
|
||||
final int[] color = compound.getIntArray("Colors");
|
||||
for (int j : color) {
|
||||
primaryColor.add(new Color(j));
|
||||
}
|
||||
}
|
||||
|
||||
if (compound.containsKey("FadeColors")) {
|
||||
int[] fadeColor = compound.getIntArray("FadeColors");
|
||||
for (int i = 0; i < fadeColor.length; i++) {
|
||||
secondaryColor.add(new Color(fadeColor[i]));
|
||||
final int[] fadeColor = compound.getIntArray("FadeColors");
|
||||
for (int j : fadeColor) {
|
||||
secondaryColor.add(new Color(j));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,8 @@ public class FireworkMeta extends ItemMeta implements ItemMetaBuilder.Provider<F
|
||||
|
||||
public Builder flightDuration(byte flightDuration) {
|
||||
this.flightDuration = flightDuration;
|
||||
handleCompound("Fireworks", nbtCompound -> {
|
||||
nbtCompound.setByte("Flight", this.flightDuration);
|
||||
});
|
||||
handleCompound("Fireworks", nbtCompound ->
|
||||
nbtCompound.setByte("Flight", this.flightDuration));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,8 @@ public class PlayerHeadMeta extends ItemMeta implements ItemMetaBuilder.Provider
|
||||
|
||||
public Builder skullOwner(@Nullable UUID skullOwner) {
|
||||
this.skullOwner = skullOwner;
|
||||
handleCompound("SkullOwner", nbtCompound -> {
|
||||
nbtCompound.setIntArray("Id", Utils.uuidToIntArray(this.skullOwner));
|
||||
});
|
||||
handleCompound("SkullOwner", nbtCompound ->
|
||||
nbtCompound.setIntArray("Id", Utils.uuidToIntArray(this.skullOwner)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.minestom.server.timer;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minestom.server.extras.selfmodification.MinestomRootClassLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
package net.minestom.server.utils.block;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.LivingEntity;
|
||||
import net.minestom.server.instance.block.BlockFace;
|
||||
import net.minestom.server.coordinate.Point;
|
||||
import net.minestom.server.coordinate.Pos;
|
||||
import net.minestom.server.coordinate.Vec;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.instance.block.BlockFace;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
Loading…
Reference in New Issue
Block a user