Skip to content

Commit

Permalink
docs: translate all JavaDocs in API module
Browse files Browse the repository at this point in the history
* refactor: Enchantment compatibilities & add rarity
* fix: Enchantments rarity
* refactor: Do not use short on enchantments
* refactor: API module
  • Loading branch information
IWareQ committed Jun 22, 2024
1 parent 447b868 commit 22d2bfc
Show file tree
Hide file tree
Showing 241 changed files with 1,670 additions and 1,817 deletions.
26 changes: 11 additions & 15 deletions Allay-API/src/main/java/org/allaymc/api/AllayAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,22 @@ public static AllayAPI getInstance() {
*/
@SuppressWarnings("unchecked")
public void implement(String coreName) throws MissingImplementationException {
if (!i18nSet) {
throw new MissingImplementationException("Missing i18n implementation!");
}
for (Map.Entry<Class<?>, ApiBindingAction<?>> entry : bindings.entrySet()) {
if (entry.getValue() == null) {
if (!i18nSet) throw new MissingImplementationException("Missing i18n implementation!");
for (var entry : bindings.entrySet()) {
if (entry.getValue() == null)
throw new MissingImplementationException("Missing binding for " + entry.getKey().getName());
}

var apiInstance = entry.getValue().bindingAction.get();
Consumer<Object> consumer = (Consumer<Object>) consumers.get(entry.getKey());
if (consumer == null) {
var consumer = (Consumer<Object>) consumers.get(entry.getKey());
if (consumer == null)
throw new MissingRequirementException("Missing requirement for " + entry.getKey().getName());
}

consumer.accept(apiInstance);
if (entry.getValue().afterBound != null) {
((Consumer<Object>) entry.getValue().afterBound).accept(apiInstance);
}
}

this.coreName = coreName;
log.info(I18n.get().tr(TrKeys.A_API_IMPLEMENTED, coreName, API_VERSION));
implemented = true;
Expand All @@ -119,9 +118,7 @@ public <T> void requireImpl(Class<T> api) {
*/
public <T> void requireImpl(Class<T> api, Consumer<T> apiInstanceConsumer) {
bindings.put(api, null);
if (apiInstanceConsumer != null) {
consumers.put(api, apiInstanceConsumer);
}
if (apiInstanceConsumer != null) consumers.put(api, apiInstanceConsumer);
}

public <T> void bind(Class<T> api, Supplier<T> supplier) {
Expand Down Expand Up @@ -212,6 +209,5 @@ private void defaultAPIRequirements() {
requireImpl(PackRegistry.class, PackRegistry.REGISTRY::set);
}

private record ApiBindingAction<T>(Supplier<T> bindingAction, Consumer<T> afterBound) {
}
}
private record ApiBindingAction<T>(Supplier<T> bindingAction, Consumer<T> afterBound) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import java.lang.annotation.Target;

/**
* An annotation used to mark a method as being slow or blocking a thread <br>
* An annotation used to mark a method as being slow or blocking a thread
* <p>
* It usually means that you may need to call it asynchronously
* <p>
* Allay Project 2023/7/8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public class BlockAttributes {
@Builder.Default
protected boolean pushesUpFallingBlocks = false;
/**
* 此方块状态是否可以被徒手挖取
* 若可以,则玩家在非创造模式下可以使用任何工具挖取此方块并产生掉落物
* Whether this block state can be harvested by hand
* If true, players in non-creative mode can use any tool to mine this block and produce drops
*/
@Builder.Default
protected boolean canHarvestWithHand = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ default <DATATYPE> void updateBlockProperty(BlockPropertyType<DATATYPE> property

/**
* Check if the block can keep existing when a neighbor block updates.
*
* @param current The current block
* @param face The face of the current block that is being updated
* @param face The face of the current block that is being updated
*
* @return true if the block can keep existing, false if the block should be broken
*/
default boolean canKeepExisting(BlockStateWithPos current, BlockStateWithPos neighbor, BlockFace face) {
Expand Down Expand Up @@ -96,10 +98,7 @@ default void checkPlaceMethodParam(Dimension dimension, BlockState blockState, V
*
* @return true if the block is placed successfully, false if failed
*/
boolean place(
Dimension dimension, BlockState blockState,
Vector3ic placeBlockPos,
PlayerInteractInfo placementInfo);
boolean place(Dimension dimension, BlockState blockState, Vector3ic placeBlockPos, PlayerInteractInfo placementInfo);

/**
* Called when a block is placed.
Expand All @@ -120,9 +119,7 @@ boolean place(
* For example, right-clicking on the crafting table is normally considered a valid operation, so this method will return true
* If false is returned, the useItemOn method of the player's item will continue to be called
*/
boolean onInteract(
ItemStack itemStack, Dimension dimension,
PlayerInteractInfo interactInfo);
boolean onInteract(ItemStack itemStack, Dimension dimension, PlayerInteractInfo interactInfo);

/**
* Called when a block is replaced.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
/**
* Allay Project 2024/6/20
*
* @param player The player who is placing the block
* @param player The player who is placing the block
* @param clickBlockPos The block that the player clicked on
* @param clickPos The precise pos where the player clicked
* @param blockFace The face of the block that the player clicked on
* @param clickPos The precise pos where the player clicked
* @param blockFace The face of the block that the player clicked on
*
* @author daoge_cmd
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
import lombok.Getter;
import lombok.Setter;
import org.allaymc.api.block.component.common.PlayerInteractInfo;
import org.allaymc.api.block.data.BlockFace;
import org.allaymc.api.entity.interfaces.EntityPlayer;
import org.allaymc.api.eventbus.event.Event;
import org.allaymc.api.item.ItemStack;
import org.allaymc.api.world.Dimension;
import org.joml.Vector3fc;
import org.joml.Vector3ic;

/**
* Allay Project 2023/9/23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import org.allaymc.api.block.data.BlockFace;
import org.allaymc.api.block.data.BlockStateWithPos;
import org.allaymc.api.eventbus.event.Event;
import org.allaymc.api.world.Dimension;
import org.joml.Vector3ic;

/**
* Allay Project 2023/9/23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public record Material(
MaterialType materialType,
boolean canBeMovingBlock,
boolean canHavePrecipitation,
//isAlwaysDestroyable为true时,表示方块可以被任何物品破坏(甚至是空手)而不产生挖掘惩罚
//部分方块(例如石头,黑曜石)不可以被徒手挖去。若强行挖取它们,挖掘速度会受到惩罚(baseTime增大5倍,正常是1.5倍)
//请注意,isAlwaysDestroyable为true不代表方块一定可以掉落为物品!
// When isAlwaysDestroyable is true, it means the block can be destroyed by any item (even bare hands) without incurring a mining penalty.
// Some blocks (such as stone and obsidian) cannot be mined by hand. If you try to mine them, the mining speed will be penalized (baseTime increased by 5 times, normally it's 1.5 times).
// Note that isAlwaysDestroyable being true does not mean the block will necessarily drop as an item!
boolean isAlwaysDestroyable,
boolean isLiquid,
boolean isSolid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
* @author daoge_cmd
*/
public record MaterialType(String name) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ static BlockStateHashPalette getRegistry() {
@Override
default BlockState register(Integer hash, BlockState blockState) {
if (getContent().containsKey(hash))
throw new BlockStateHashCollisionException("Checked for possible block state hash collisions! Hash: " + hash + " ,BlockState: " + blockState);
throw new BlockStateHashCollisionException("Checked for possible block state hash collisions! Hash: " + hash + ", BlockState: " + blockState);
else return MappedRegistry.super.register(hash, blockState);
}

class BlockStateHashCollisionException extends RuntimeException {
public BlockStateHashCollisionException() {
}

public BlockStateHashCollisionException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.allaymc.api.block.property;

import lombok.experimental.UtilityClass;
import org.allaymc.api.block.data.BlockFace;
import org.allaymc.api.block.property.enums.MinecraftCardinalDirection;

Expand All @@ -8,6 +9,7 @@
*
* @author daoge_cmd
*/
@UtilityClass
public class PropertyUtil {
public static MinecraftCardinalDirection toMinecraftCardinalDirection(BlockFace face) {
return switch (face) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.allaymc.api.block.property.enums;

/**
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen} <br>
* Allay Project <p>
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen}
* <p>
* Allay Project
*
* @author daoge_cmd
*/
public enum Attachment {
HANGING,
HANGING,

MULTIPLE,
MULTIPLE,

SIDE,
SIDE,

STANDING
STANDING
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package org.allaymc.api.block.property.enums;

/**
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen} <br>
* Allay Project <p>
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen}
* <p>
* Allay Project
*
* @author daoge_cmd
*/
public enum BambooLeafSize {
LARGE_LEAVES,
LARGE_LEAVES,

NO_LEAVES,
NO_LEAVES,

SMALL_LEAVES
SMALL_LEAVES
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.allaymc.api.block.property.enums;

/**
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen} <br>
* Allay Project <p>
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen}
* <p>
* Allay Project
*
* @author daoge_cmd
*/
public enum BambooStalkThickness {
THICK,
THICK,

THIN
THIN
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.allaymc.api.block.property.enums;

/**
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen} <br>
* Allay Project <p>
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen}
* <p>
* Allay Project
*
* @author daoge_cmd
*/
public enum BigDripleafTilt {
FULL_TILT,
FULL_TILT,

NONE,
NONE,

PARTIAL_TILT,
PARTIAL_TILT,

UNSTABLE
UNSTABLE
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package org.allaymc.api.block.property.enums;

/**
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen} <br>
* Allay Project <p>
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen}
* <p>
* Allay Project
*
* @author daoge_cmd
*/
public enum CauldronLiquid {
LAVA,
LAVA,

POWDER_SNOW,
POWDER_SNOW,

WATER
WATER
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.allaymc.api.block.property.enums;

/**
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen} <br>
* Allay Project <p>
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen}
* <p>
* Allay Project
*
* @author daoge_cmd
*/
public enum ChemistryTableType {
COMPOUND_CREATOR,
COMPOUND_CREATOR,

ELEMENT_CONSTRUCTOR,
ELEMENT_CONSTRUCTOR,

LAB_TABLE,
LAB_TABLE,

MATERIAL_REDUCER
MATERIAL_REDUCER
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.allaymc.api.block.property.enums;

/**
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen} <br>
* Allay Project <p>
* Automatically generated by {@code org.allaymc.codegen.VanillaBlockPropertyTypeGen}
* <p>
* Allay Project
*
* @author daoge_cmd
*/
public enum ChiselType {
CHISELED,
CHISELED,

DEFAULT,
DEFAULT,

LINES,
LINES,

SMOOTH
SMOOTH
}

This file was deleted.

Loading

0 comments on commit 22d2bfc

Please sign in to comment.