Renamed #clone to #copy

This commit is contained in:
themode 2020-10-31 18:03:15 +01:00
parent af3d742b13
commit 0184ada9a0
38 changed files with 108 additions and 101 deletions

View File

@ -83,7 +83,7 @@ public class CollisionUtils {
BlockPosition[] cornerPositions = new BlockPosition[corners.length];
Vector[] cornersCopy = new Vector[corners.length];
for (int i = 0; i < corners.length; i++) {
cornersCopy[i] = corners[i].clone();
cornersCopy[i] = corners[i].copy();
cornerPositions[i] = new BlockPosition(corners[i]);
}

View File

@ -41,7 +41,7 @@ public interface Data {
@NotNull
@Override
public Data clone() {
public Data copy() {
return this;
}
@ -106,11 +106,11 @@ public interface Data {
boolean isEmpty();
/**
* Clones this data.
* Copies this data.
*
* @return a cloned data object
*/
@NotNull
Data clone();
Data copy();
}

View File

@ -51,7 +51,7 @@ public class DataImpl implements Data {
@NotNull
@Override
public Data clone() {
public Data copy() {
DataImpl data = new DataImpl();
data.data.putAll(this.data);
return data;

View File

@ -58,7 +58,7 @@ public class SerializableDataImpl extends DataImpl implements SerializableData {
@NotNull
@Override
public Data clone() {
public Data copy() {
SerializableDataImpl data = new SerializableDataImpl();
data.data.putAll(this.data);
data.dataType.putAll(this.dataType);

View File

@ -130,7 +130,7 @@ public abstract class Entity implements Viewable, EventHandler, DataContainer {
this.id = generateId();
this.entityType = entityType;
this.uuid = UUID.randomUUID();
this.position = spawnPosition.clone();
this.position = spawnPosition.copy();
setBoundingBox(0, 0, 0);

View File

@ -386,7 +386,7 @@ public abstract class EntityCreature extends LivingEntity {
return false;
}
final Position targetPosition = position.clone();
final Position targetPosition = position.copy();
this.path = pathFinder.initiatePathTo(position.getX(), position.getY(), position.getZ());
this.pathLock.unlock();

View File

@ -111,7 +111,7 @@ public class ItemEntity extends ObjectEntity {
if (!canApply)
continue;
final ItemStack result = stackingRule.apply(itemStack.clone(), totalAmount);
final ItemStack result = stackingRule.apply(itemStack.copy(), totalAmount);
EntityItemMergeEvent entityItemMergeEvent = new EntityItemMergeEvent(this, itemEntity, result);
callCancellableEvent(EntityItemMergeEvent.class, entityItemMergeEvent, () -> {

View File

@ -1812,7 +1812,7 @@ public class Player extends LivingEntity implements CommandSender {
*/
protected void updatePlayerPosition() {
PlayerPositionAndLookPacket positionAndLookPacket = new PlayerPositionAndLookPacket();
positionAndLookPacket.position = position.clone(); // clone needed to prevent synchronization issue
positionAndLookPacket.position = position.copy(); // clone needed to prevent synchronization issue
positionAndLookPacket.flags = 0x00;
positionAndLookPacket.teleportId = teleportId.incrementAndGet();
playerConnection.sendPacket(positionAndLookPacket);

View File

@ -41,8 +41,8 @@ public class EatBlockGoal extends GoalSelector {
}
final Instance instance = entityCreature.getInstance();
final BlockPosition blockPosition = entityCreature.getPosition().toBlockPosition();
final short blockStateIdIn = instance.getBlockStateId(blockPosition.clone().subtract(0, 1, 0));
final short blockStateIdBelow = instance.getBlockStateId(blockPosition.clone().subtract(0, 2, 0));
final short blockStateIdIn = instance.getBlockStateId(blockPosition.copy().subtract(0, 1, 0));
final short blockStateIdBelow = instance.getBlockStateId(blockPosition.copy().subtract(0, 2, 0));
return eatInMap.containsKey(blockStateIdIn) || eatBelowMap.containsKey(blockStateIdBelow);
}
@ -62,8 +62,8 @@ public class EatBlockGoal extends GoalSelector {
return;
}
Instance instance = entityCreature.getInstance();
final BlockPosition currentPosition = entityCreature.getPosition().toBlockPosition().clone().subtract(0, 1, 0);
final BlockPosition belowPosition = currentPosition.clone().subtract(0, 1, 0);
final BlockPosition currentPosition = entityCreature.getPosition().toBlockPosition().copy().subtract(0, 1, 0);
final BlockPosition belowPosition = currentPosition.copy().subtract(0, 1, 0);
final short blockStateIdIn = instance.getBlockStateId(currentPosition);
final short blockStateIdBelow = instance.getBlockStateId(belowPosition);

View File

@ -69,7 +69,7 @@ public class RandomLookAroundGoal extends GoalSelector {
@Override
public void tick(long time) {
--lookTime;
entityCreature.setView(entityCreature.getPosition().clone().setDirection(lookDirection));
entityCreature.setView(entityCreature.getPosition().copy().setDirection(lookDirection));
}
@Override

View File

@ -35,7 +35,7 @@ public class RandomStrollGoal extends GoalSelector {
Collections.shuffle(closePositions);
for (Position position : closePositions) {
final Position target = position.clone().add(entityCreature.getPosition());
final Position target = position.copy().add(entityCreature.getPosition());
final boolean result = entityCreature.setPathTo(target);
if (result) {
break;

View File

@ -26,7 +26,7 @@ public class Hologram implements Viewable {
private boolean removed;
public Hologram(Instance instance, Position spawnPosition, ColoredText text, boolean autoViewable) {
this.entity = new HologramEntity(spawnPosition.clone().add(0, OFFSET_Y, 0));
this.entity = new HologramEntity(spawnPosition.copy().add(0, OFFSET_Y, 0));
this.entity.setInstance(instance);
this.entity.setAutoViewable(autoViewable);

View File

@ -96,18 +96,18 @@ public class InventoryClickProcessor {
} else {
if (cursor.isAir()) {
final int amount = (int) Math.ceil((double) clicked.getAmount() / 2d);
resultCursor = clicked.clone();
resultCursor = clicked.copy();
resultCursor = cursorRule.apply(resultCursor, amount);
resultClicked = clicked.clone();
resultClicked = clicked.copy();
resultClicked = clickedRule.apply(resultClicked, clicked.getAmount() / 2);
} else {
if (clicked.isAir()) {
final int amount = cursor.getAmount();
resultCursor = cursor.clone();
resultCursor = cursor.copy();
resultCursor = cursorRule.apply(resultCursor, amount - 1);
resultClicked = cursor.clone();
resultClicked = cursor.copy();
resultClicked = clickedRule.apply(resultClicked, 1);
} else {
resultCursor = clicked;
@ -181,7 +181,7 @@ public class InventoryClickProcessor {
final StackingRule clickedRule = clicked.getStackingRule();
boolean filled = false;
ItemStack resultClicked = clicked.clone();
ItemStack resultClicked = clicked.copy();
for (InventoryClickLoopHandler loopHandler : loopHandlers) {
final Int2IntFunction indexModifier = loopHandler.getIndexModifier();
@ -278,7 +278,7 @@ public class InventoryClickProcessor {
int finalCursorAmount = cursorAmount;
for (Integer s : slots) {
ItemStack draggedItem = cursor.clone();
ItemStack draggedItem = cursor.copy();
ItemStack slotItem = itemGetter.apply(s);
clickResult = startCondition(clickResult, inventory, player, s, ClickType.DRAGGING, slotItem, cursor);
@ -318,7 +318,7 @@ public class InventoryClickProcessor {
if (size > cursorAmount)
return null;
for (Integer s : slots) {
ItemStack draggedItem = cursor.clone();
ItemStack draggedItem = cursor.copy();
ItemStack slotItem = itemGetter.apply(s);
clickResult = startCondition(clickResult, inventory, player, s, ClickType.DRAGGING, slotItem, cursor);
@ -435,8 +435,8 @@ public class InventoryClickProcessor {
final StackingRule clickedRule = clicked == null ? null : clicked.getStackingRule();
final StackingRule cursorRule = cursor.getStackingRule();
ItemStack resultClicked = clicked == null ? null : clicked.clone();
ItemStack resultCursor = cursor.clone();
ItemStack resultClicked = clicked == null ? null : clicked.copy();
ItemStack resultCursor = cursor.copy();
if (slot == -999) {
@ -444,7 +444,7 @@ public class InventoryClickProcessor {
if (button == 0) {
// Left (drop all)
final int amount = cursorRule.getAmount(resultCursor);
final ItemStack dropItem = cursorRule.apply(resultCursor.clone(), amount);
final ItemStack dropItem = cursorRule.apply(resultCursor.copy(), amount);
final boolean dropResult = player.dropItem(dropItem);
clickResult.setCancel(!dropResult);
if (dropResult) {
@ -452,7 +452,7 @@ public class InventoryClickProcessor {
}
} else if (button == 1) {
// Right (drop 1)
final ItemStack dropItem = cursorRule.apply(resultCursor.clone(), 1);
final ItemStack dropItem = cursorRule.apply(resultCursor.copy(), 1);
final boolean dropResult = player.dropItem(dropItem);
clickResult.setCancel(!dropResult);
if (dropResult) {
@ -465,7 +465,7 @@ public class InventoryClickProcessor {
} else if (mode == 4) {
if (button == 0) {
// Drop key Q (drop 1)
final ItemStack dropItem = cursorRule.apply(resultClicked.clone(), 1);
final ItemStack dropItem = cursorRule.apply(resultClicked.copy(), 1);
final boolean dropResult = player.dropItem(dropItem);
clickResult.setCancel(!dropResult);
if (dropResult) {
@ -476,7 +476,7 @@ public class InventoryClickProcessor {
} else if (button == 1) {
// Ctrl + Drop key Q (drop all)
final int amount = cursorRule.getAmount(resultClicked);
final ItemStack dropItem = clickedRule.apply(resultClicked.clone(), amount);
final ItemStack dropItem = clickedRule.apply(resultClicked.copy(), amount);
final boolean dropResult = player.dropItem(dropItem);
clickResult.setCancel(!dropResult);
if (dropResult) {

View File

@ -529,12 +529,12 @@ public class ItemStack implements DataContainer {
}
/**
* Clones this item stack.
* Copies this item stack.
*
* @return a cloned item stack
*/
@NotNull
public synchronized ItemStack clone() {
public synchronized ItemStack copy() {
ItemStack itemStack = new ItemStack(material, amount, damage);
itemStack.setDisplayName(displayName);
itemStack.setUnbreakable(unbreakable);
@ -552,11 +552,11 @@ public class ItemStack implements DataContainer {
itemStack.customModelData = customModelData;
if (itemMeta != null)
itemStack.itemMeta = itemMeta.clone();
itemStack.itemMeta = itemMeta.copy();
final Data data = getData();
if (data != null)
itemStack.setData(data.clone());
itemStack.setData(data.copy());
return itemStack;
}

View File

@ -99,7 +99,7 @@ public class CompassMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
CompassMeta compassMeta = new CompassMeta();
compassMeta.lodestoneTracked = lodestoneTracked;
compassMeta.lodestoneDimension = lodestoneDimension;

View File

@ -180,12 +180,12 @@ public class CrossbowMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
CrossbowMeta crossbowMeta = new CrossbowMeta();
crossbowMeta.triple = triple;
crossbowMeta.projectile1 = projectile1 == null ? null : projectile1.clone();
crossbowMeta.projectile2 = projectile2 == null ? null : projectile2.clone();
crossbowMeta.projectile3 = projectile3 == null ? null : projectile3.clone();
crossbowMeta.projectile1 = projectile1 == null ? null : projectile1.copy();
crossbowMeta.projectile2 = projectile2 == null ? null : projectile2.copy();
crossbowMeta.projectile3 = projectile3 == null ? null : projectile3.copy();
crossbowMeta.charged = charged;

View File

@ -85,7 +85,7 @@ public class EnchantedBookMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
EnchantedBookMeta enchantedBookMeta = new EnchantedBookMeta();
enchantedBookMeta.storedEnchantmentMap.putAll(storedEnchantmentMap);

View File

@ -36,7 +36,7 @@ public class FireworkMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
return null;
}

View File

@ -44,13 +44,13 @@ public interface ItemMeta {
void write(@NotNull NBTCompound compound);
/**
* Clones this item meta.
* Copies this item meta.
* <p>
* Used by {@link ItemStack#clone()}.
* Used by {@link ItemStack#copy()}.
*
* @return the cloned item meta
*/
@NotNull
ItemMeta clone();
ItemMeta copy();
}

View File

@ -113,7 +113,7 @@ public class LeatherArmorMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
LeatherArmorMeta leatherArmorMeta = new LeatherArmorMeta();
leatherArmorMeta.modified = modified;
leatherArmorMeta.red = red;

View File

@ -194,7 +194,7 @@ public class MapMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
MapMeta mapMeta = new MapMeta();
mapMeta.setMapId(mapId);
mapMeta.setMapScaleDirection(mapScaleDirection);

View File

@ -34,7 +34,7 @@ public class PlayerHeadMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
return null;
}
}

View File

@ -152,7 +152,7 @@ public class PotionMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
PotionMeta potionMeta = new PotionMeta();
potionMeta.potionType = potionType;
potionMeta.customPotionEffects.addAll(customPotionEffects);

View File

@ -42,7 +42,7 @@ public class SpawnEggMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
SpawnEggMeta spawnEggMeta = new SpawnEggMeta();
spawnEggMeta.entityType = entityType;
return spawnEggMeta;

View File

@ -68,7 +68,7 @@ public class WritableBookMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
WritableBookMeta writableBookMeta = new WritableBookMeta();
writableBookMeta.pages.addAll(pages);

View File

@ -180,7 +180,7 @@ public class WrittenBookMeta implements ItemMeta {
@NotNull
@Override
public ItemMeta clone() {
public ItemMeta copy() {
WrittenBookMeta writtenBookMeta = new WrittenBookMeta();
writtenBookMeta.resolved = resolved;
writtenBookMeta.generation = generation;

View File

@ -92,12 +92,12 @@ public class PlayerDiggingListener {
}
break;
case DROP_ITEM_STACK:
final ItemStack droppedItemStack = player.getInventory().getItemInMainHand().clone();
final ItemStack droppedItemStack = player.getInventory().getItemInMainHand().copy();
dropItem(player, droppedItemStack, ItemStack.getAirItem());
break;
case DROP_ITEM:
ItemStack handItem = player.getInventory().getItemInMainHand().clone();
ItemStack droppedItemStack2 = handItem.clone();
ItemStack handItem = player.getInventory().getItemInMainHand().copy();
ItemStack droppedItemStack2 = handItem.copy();
final StackingRule handStackingRule = handItem.getStackingRule();
droppedItemStack2 = handStackingRule.apply(droppedItemStack2, 1);
@ -119,7 +119,7 @@ public class PlayerDiggingListener {
break;
case SWAP_ITEM_HAND:
PlayerSwapItemEvent swapItemEvent = new PlayerSwapItemEvent(player, offHand.clone(), mainHand.clone());
PlayerSwapItemEvent swapItemEvent = new PlayerSwapItemEvent(player, offHand.copy(), mainHand.copy());
player.callCancellableEvent(PlayerSwapItemEvent.class, swapItemEvent, () -> {
synchronized (playerInventory) {
playerInventory.setItemInMainHand(swapItemEvent.getMainHandItem());

View File

@ -56,9 +56,9 @@ public class PlayerPositionListener {
return;
}
final Position currentPosition = player.getPosition().clone();
final Position currentPosition = player.getPosition().copy();
Position newPosition = new Position(x, y, z, yaw, pitch);
final Position cachedPosition = newPosition.clone();
final Position cachedPosition = newPosition.copy();
PlayerMoveEvent playerMoveEvent = new PlayerMoveEvent(player, newPosition);
player.callEvent(PlayerMoveEvent.class, playerMoveEvent);

View File

@ -143,7 +143,7 @@ public class StorageLocation {
// Copy data from the cachedMap
if (cachedData.containsKey(key)) {
SerializableData data = cachedData.get(key);
dataContainer.setData(data.clone());
dataContainer.setData(data.copy());
return;
}
}

View File

@ -186,12 +186,12 @@ public class BlockPosition {
}
/**
* Clones this block position.
* Copies this block position.
*
* @return the cloned block position
*/
@NotNull
public BlockPosition clone() {
public BlockPosition copy() {
return new BlockPosition(x, y, z);
}

View File

@ -163,11 +163,11 @@ public class Position {
}
/**
* Clones this position object with the same values.
* Copies this position object with the same values.
*
* @return a new {@link Position} object with the same coordinates
*/
public Position clone() {
public Position copy() {
return new Position(getX(), getY(), getZ(), getYaw(), getPitch());
}

View File

@ -1,6 +1,6 @@
package net.minestom.server.utils;
public class Vector implements Cloneable {
public class Vector {
private static final double epsilon = 0.000001;
@ -227,8 +227,7 @@ public class Vector implements Cloneable {
*
* @return vector
*/
@Override
public Vector clone() {
public Vector copy() {
return new Vector(x, y, z);
}

View File

@ -3,7 +3,7 @@ package demo;
import demo.blocks.BurningTorchBlock;
import demo.blocks.StoneBlock;
import demo.blocks.UpdatableBlockDemo;
import demo.commands.*;
import demo.commands.TestCommand;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandManager;
import net.minestom.server.instance.block.BlockManager;
@ -27,14 +27,14 @@ public class Main {
blockManager.registerBlockPlacementRule(new RedstonePlacementRule());
CommandManager commandManager = MinecraftServer.getCommandManager();
commandManager.register(new EntitySelectorCommand());
//commandManager.register(new EntitySelectorCommand());
commandManager.register(new TestCommand());
commandManager.register(new HealthCommand());
/*commandManager.register(new HealthCommand());
commandManager.register(new SimpleCommand());
commandManager.register(new GamemodeCommand());
commandManager.register(new DimensionCommand());
commandManager.register(new ShutdownCommand());
commandManager.register(new TeleportCommand());
commandManager.register(new TeleportCommand());*/
StorageManager storageManager = MinecraftServer.getStorageManager();

View File

@ -5,8 +5,6 @@ import demo.generator.NoiseTestGenerator;
import net.minestom.server.MinecraftServer;
import net.minestom.server.benchmark.BenchmarkManager;
import net.minestom.server.chat.ColoredText;
import net.minestom.server.data.Data;
import net.minestom.server.data.DataImpl;
import net.minestom.server.entity.*;
import net.minestom.server.entity.damage.DamageType;
import net.minestom.server.event.entity.EntityAttackEvent;
@ -16,6 +14,7 @@ import net.minestom.server.event.player.*;
import net.minestom.server.instance.Chunk;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.InstanceContainer;
import net.minestom.server.instance.SharedInstance;
import net.minestom.server.instance.block.Block;
import net.minestom.server.inventory.Inventory;
import net.minestom.server.inventory.InventoryType;
@ -55,12 +54,12 @@ public class PlayerInit {
}
inventory = new Inventory(InventoryType.CHEST_1_ROW, "Test inventory");
inventory.addInventoryCondition((p, slot, clickType, inventoryConditionResult) -> {
/*inventory.addInventoryCondition((p, slot, clickType, inventoryConditionResult) -> {
p.sendMessage("click type inventory: " + clickType);
System.out.println("slot inv: " + slot);
inventoryConditionResult.setCancel(false);
});
inventory.setItemStack(0, new ItemStack(Material.DIAMOND, (byte) 34));
inventoryConditionResult.setCancel(slot == 3);
});*/
inventory.setItemStack(3, new ItemStack(Material.DIAMOND, (byte) 34));
}
public static void init() {
@ -91,13 +90,13 @@ public class PlayerInit {
if (entity instanceof EntityCreature) {
EntityCreature creature = (EntityCreature) entity;
creature.damage(DamageType.fromPlayer(player), -1);
Vector velocity = player.getPosition().clone().getDirection().multiply(6);
Vector velocity = player.getPosition().copy().getDirection().multiply(6);
velocity.setY(4f);
entity.setVelocity(velocity);
player.sendMessage("You attacked an entity!");
} else if (entity instanceof Player) {
Player target = (Player) entity;
Vector velocity = player.getPosition().clone().getDirection().multiply(4);
Vector velocity = player.getPosition().copy().getDirection().multiply(4);
velocity.setY(3.5f);
target.setVelocity(velocity);
target.damage(DamageType.fromPlayer(player), 5);
@ -138,12 +137,20 @@ public class PlayerInit {
player.addEventCallback(ItemDropEvent.class, event -> {
ItemStack droppedItem = event.getItemStack();
Position position = player.getPosition().clone().add(0, 1.5f, 0);
Position position = player.getPosition().copy().add(0, 1.5f, 0);
ItemEntity itemEntity = new ItemEntity(droppedItem, position);
itemEntity.setPickupDelay(500, TimeUnit.MILLISECOND);
itemEntity.setInstance(player.getInstance());
Vector velocity = player.getPosition().clone().getDirection().multiply(6);
Vector velocity = player.getPosition().copy().getDirection().multiply(6);
itemEntity.setVelocity(velocity);
Instance instance = player.getInstance();
InstanceContainer instanceContainer = instance instanceof InstanceContainer ? (InstanceContainer) instance :
((SharedInstance) instance).getInstanceContainer();
SharedInstance sharedInstance = MinecraftServer.getInstanceManager().createSharedInstance(instanceContainer);
player.setInstance(sharedInstance);
player.sendMessage("New instance");
});
player.addEventCallback(PlayerDisconnectEvent.class, event -> {
@ -154,32 +161,25 @@ public class PlayerInit {
event.setSpawningInstance(instanceContainer);
player.getInventory().addInventoryCondition((p, slot, clickType, inventoryConditionResult) -> {
/*player.getInventory().addInventoryCondition((p, slot, clickType, inventoryConditionResult) -> {
if (slot == -999)
return;
inventoryConditionResult.setCancel(false);
ItemStack itemStack = p.getInventory().getItemStack(slot);
Data data = itemStack.getData();
if (data != null) {
System.out.println("DATA: " + data.get("test"));
}
System.out.println("slot player: " + slot + " : " + itemStack.getMaterial() + " : " + (itemStack.getData() != null));
});
});*/
});
player.addEventCallback(PlayerSpawnEvent.class, event -> {
player.setGameMode(GameMode.SURVIVAL);
player.teleport(new Position(0, 73f, 0));
if(event.isFirstSpawn()){
player.teleport(new Position(0, 64f, 0));
}
Data data = new DataImpl();
data.set("test", 5, Integer.class);
ItemStack itemStack = new ItemStack(Material.DIAMOND_PICKAXE, (byte) 1);
itemStack.setData(data);
ItemStack itemStack = new ItemStack(Material.DIAMOND_PICKAXE, (byte) 64);
player.getInventory().addItemStack(itemStack);
//player.getInventory().addItemStack(new ItemStack(Material.STONE, (byte)64));
});
player.addEventCallback(PlayerRespawnEvent.class, event -> {
event.setRespawnPosition(new Position(0f, 75f, 0f));
//player.getInventory().addItemStack(new ItemStack(Material.STONE, (byte)64));
});
player.addEventCallback(PlayerUseItemEvent.class, useEvent -> {

View File

@ -23,7 +23,7 @@ public class StoneBlock extends CustomBlock {
@Override
public void onDestroy(@NotNull Instance instance, @NotNull BlockPosition blockPosition, Data data) {
BlockPosition above = blockPosition.clone().add(0, 1, 0);
BlockPosition above = blockPosition.copy().add(0, 1, 0);
CustomBlock blockAbove = instance.getCustomBlock(above);
if (blockAbove == this) {
instance.setBlock(above, Block.AIR);

View File

@ -4,7 +4,7 @@ import net.minestom.server.command.CommandSender;
import net.minestom.server.command.builder.Arguments;
import net.minestom.server.command.builder.Command;
import net.minestom.server.command.builder.arguments.Argument;
import net.minestom.server.command.builder.arguments.minecraft.ArgumentNbtTag;
import net.minestom.server.command.builder.arguments.ArgumentType;
public class TestCommand extends Command {
@ -17,12 +17,20 @@ public class TestCommand extends Command {
//addSyntax(this::execute, dynamicWord);
}
Argument test = new ArgumentNbtTag("test");
Argument test = ArgumentType.Word("test").from("hey");
Argument num = ArgumentType.Integer("num");
setDefaultExecutor((source, args) -> {
System.out.println("DEFAULT");
});
addSyntax((source, args) -> {
System.out.println("arg: "+args.getNBT("test").getClass());
System.out.println("SUCCESS");
System.out.println(1);
}, test);
addSyntax((source, args) -> {
System.out.println(2);
}, test, num);
}
private void usage(CommandSender sender, Arguments arguments) {

View File

@ -42,7 +42,7 @@ public class ChickenCreature extends EntityChicken {
addEventCallback(EntityAttackEvent.class, event -> {
//System.out.println("CALL ATTACK");
LivingEntity entity = (LivingEntity) event.getTarget();
Vector velocity = getPosition().clone().getDirection().multiply(6);
Vector velocity = getPosition().copy().getDirection().multiply(6);
velocity.setY(4f);
entity.damage(DamageType.fromEntity(this), -1);
entity.setVelocity(velocity);

View File

@ -20,7 +20,7 @@ public class Structure {
return;
if (bPos.getZ() + pos.getZ() >= Chunk.CHUNK_SIZE_Z || bPos.getZ() + pos.getZ() < 0)
return;
batch.setBlock(bPos.clone().add(pos), block);
batch.setBlock(bPos.copy().add(pos), block);
});
}