From fd1aa404564f9195e00bc2611232a0da08aca928 Mon Sep 17 00:00:00 2001 From: "Luis C.M" Date: Tue, 17 May 2022 05:24:57 -0500 Subject: [PATCH] Added some documentation to a few interfaces for the javadoc. --- .../noppes/npcs/scripted/ScriptBlock.java | 8 +-- .../npcs/scripted/interfaces/IBlock.java | 66 +++++++++++++++++-- .../npcs/scripted/interfaces/IContainer.java | 32 ++++++++- .../scripted/interfaces/IDamageSource.java | 16 +++++ 4 files changed, 111 insertions(+), 11 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/ScriptBlock.java b/src/main/java/noppes/npcs/scripted/ScriptBlock.java index d7ab06245..8c4f25673 100644 --- a/src/main/java/noppes/npcs/scripted/ScriptBlock.java +++ b/src/main/java/noppes/npcs/scripted/ScriptBlock.java @@ -62,8 +62,8 @@ public class ScriptBlock implements IBlock { return this.block.isAir(this.world.getMCWorld(), getX(), getY(), getZ()); } - public ScriptBlock setBlock(String name) { - Block block = (Block)Block.blockRegistry.getObject(new ResourceLocation(name)); + public ScriptBlock setBlock(String blockName) { + Block block = (Block)Block.blockRegistry.getObject(new ResourceLocation(blockName)); if(block == null) { return this; } else { @@ -113,11 +113,11 @@ public class ScriptBlock implements IBlock { return this.tile != null; } - public ScriptTileEntity getTileEntity() { + public ITileEntity getTileEntity() { return new ScriptTileEntity(this.tile); } - public void setTileEntity(ScriptTileEntity tileEntity){ + public void setTileEntity(ITileEntity tileEntity){ world.setTileEntity(pos.getX(),pos.getY(), pos.getZ(),tileEntity); this.tile = tileEntity.getMCTileEntity(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java index 561ddca1c..3dfa5a466 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IBlock.java @@ -7,7 +7,6 @@ package noppes.npcs.scripted.interfaces; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; -import noppes.npcs.scripted.ScriptTileEntity; public interface IBlock { int getX(); @@ -16,35 +15,92 @@ public interface IBlock { int getZ(); + /** + * + * @return Returns an IPos object with the block's XYZ position. + */ IPos getPos(); + /** + * + * @return Returns the block name as it appears in the block registry. Return example: "minecraft:stone" + */ String getName(); + /** + * Deletes the block, setting it to air. + */ void remove(); boolean isAir(); - IBlock setBlock(String var1); + /** + * + * @param blockName The name of the block to be set in place of this block. + * @return Returns the new block set in place of this block as an IBlock object. + */ + IBlock setBlock(String blockName); - IBlock setBlock(IBlock var1); + /** + * + * @param block Input IBlock object to replace this block. + * @return Returns the new block set in place of the previous block. + */ + IBlock setBlock(IBlock block); + /** + * + * @return Returns true if the block can contain items like a chest does. + */ boolean isContainer(); + /** + * + * @return Returns the container object of this block. If this block is not a container, an exception will be thrown. + */ IContainer getContainer(); + /** + * + * @return Returns an IWorld object of the world this block is in. + */ IWorld getWorld(); + /** + * + * @return Returns true if this block has a tile entity. Blocks with custom data like signs, player skulls, chests, etc. will have tile entities. + */ boolean hasTileEntity(); - ScriptTileEntity getTileEntity(); + /** + * + * @return Returns an ITileEntity object which can modify this block's tile entity. + */ + ITileEntity getTileEntity(); - void setTileEntity(ScriptTileEntity tileEntity); + /** + * + * @param tileEntity Replaces this block's tile entity based on the data given by this parameter. + */ + void setTileEntity(ITileEntity tileEntity); + /** + * + * @return Returns a non-script, obfuscated MC object for the block's tile entity. + */ TileEntity getMCTileEntity(); + /** + * + * @return Returns a non-script, obfuscated MC block object. + */ Block getMCBlock(); String getDisplayName(); + /** + * + * @return Returns an INbt object which can modify the block's tile entity's NBT data. + */ INbt getTileEntityNBT(); } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java index 47f6d5358..e639dabbe 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IContainer.java @@ -13,18 +13,46 @@ import noppes.npcs.scripted.interfaces.item.IItemStack; public interface IContainer { int getSize(); - IItemStack getSlot(int var1); + IItemStack getSlot(int slot); + /** + * + * @param slot The slot to be replaced + * @param item The item replacing the previous item in that slot, as an IItemStack object + */ void setSlot(int slot, IItemStack item); + /** + * + * @return Returns a non-script, obfuscated MC inventory object. + */ IInventory getMCInventory(); + /** + * + * @return Returns a non-script, obfuscated MC container object. + */ Container getMCContainer(); - int count(IItemStack var1, boolean var2, boolean var3); + /** + * + * @param itemStack The item stack to be searched in the container + * @param ignoreDamage Whether damage should be ignored when searching + * @param ignoreNBT Whether NBT values should be ignored when searching + * @return Returns the amount of the item stack found, based on the flags given above. + */ + int count(IItemStack itemStack, boolean ignoreDamage, boolean ignoreNBT); + /** + * + * @return Returns a list of all item stacks in the container as a list of IItemStack objects. + */ IItemStack[] getItems(); + /** + * + * @return Returns true if this container belongs to a Custom GUI. + */ boolean isCustomGUI(); void detectAndSendChanges(); diff --git a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java index 529db409c..838b66699 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/IDamageSource.java @@ -9,15 +9,31 @@ import net.minecraft.util.DamageSource; import noppes.npcs.scripted.interfaces.entity.IEntity; public interface IDamageSource { + /** + * + * @return Returns the damage type of the damage source as a string. Ex: "lava", "explosion", "magic", "outOfWorld", etc. + */ String getType(); boolean isUnblockable(); boolean isProjectile(); + /** + * + * @return Returns the entity source of where the damage source originated. If a player was shot by an arrow from a skeleton, this would return an IEntity object of the skeleton. + */ IEntity getTrueSource(); + /** + * + * @return Returns the entity source of where the damage source originated. If a player was shot by an arrow from a skeleton, this would return an IEntity object of the arrow. + */ IEntity getImmediateSource(); + /** + * + * @return Returns a non-script, obfuscated MC damage source object. + */ DamageSource getMCDamageSource(); }