Some comments

This commit is contained in:
Felix Cravic 2020-06-03 15:17:34 +02:00
parent 2ee93bd7cb
commit f585b3df86
3 changed files with 34 additions and 7 deletions

View File

@ -226,13 +226,27 @@ public abstract class EntityCreature extends LivingEntity {
}
/**
* Call a {@link EntityAttackEvent} with this entity as the source and {@code target} as the target
* Call a {@link EntityAttackEvent} with this entity as the source and {@code target} as the target.
*
* @param target the entity target
* @param swingHand true to swing the entity main hand, false otherwise
*/
public void attack(Entity target, boolean swingHand) {
if (swingHand)
swingMainHand();
EntityAttackEvent attackEvent = new EntityAttackEvent(this, target);
callEvent(EntityAttackEvent.class, attackEvent);
}
/**
* Call a {@link EntityAttackEvent} with this entity as the source and {@code target} as the target.
* <p>
* This does not trigger the hand animation
*
* @param target the entity target
*/
public void attack(Entity target) {
EntityAttackEvent attackEvent = new EntityAttackEvent(this, target);
callEvent(EntityAttackEvent.class, attackEvent);
attack(target, false);
}
public void jump(float height) {

View File

@ -13,6 +13,9 @@ import net.minestom.server.utils.time.UpdateOption;
import java.util.Set;
import java.util.function.Consumer;
/**
* Represent an item on the ground
*/
public class ItemEntity extends ObjectEntity {
/**

View File

@ -1,5 +1,10 @@
package net.minestom.server.item;
/**
* Represent the stacking rule of an item
* This can be used to mimic the vanilla one (using the item amount displayed)
* or a complete new one which can be stored in lore, name, etc...
*/
public abstract class StackingRule {
private int maxSize;
@ -9,6 +14,8 @@ public abstract class StackingRule {
}
/**
* Used to know if two ItemStack can be stacked together
*
* @param item1 the first item
* @param item2 the second item
* @return true if both item can be stacked together (do not take their amount in consideration)
@ -16,6 +23,8 @@ public abstract class StackingRule {
public abstract boolean canBeStacked(ItemStack item1, ItemStack item2);
/**
* Used to know if an ItemStack can have the size {@code newAmount} applied
*
* @param item the item to check
* @param newAmount the desired new amount
* @return true if item can have its stack size set to newAmount
@ -23,10 +32,11 @@ public abstract class StackingRule {
public abstract boolean canApply(ItemStack item, int newAmount);
/**
* At this point we know that the item can have this stack size
* Change the size of the item to {@code newAmount}
* At this point we know that the item can have this stack size applied
*
* @param item
* @param newAmount
* @param item the item stack to applies the size to
* @param newAmount the new item size
* @return the new ItemStack with the new amount
*/
public abstract ItemStack apply(ItemStack item, int newAmount);
@ -35,7 +45,7 @@ public abstract class StackingRule {
* Used to determine the current stack size of an item
* It is possible to have it stored in its Data object, lore, etc...
*
* @param itemStack
* @param itemStack the item stack to check the size
* @return the correct size of itemStack
*/
public abstract int getAmount(ItemStack itemStack);