Javadoc I definitely went ham on

This commit is contained in:
Leo40Git
2021-08-12 22:45:31 +03:00
parent 64be307c1b
commit 0c1aaa98b2
3 changed files with 46 additions and 5 deletions

View File

@@ -10,7 +10,20 @@ import java.util.HashMap;
public final class AxeItemHooks {
private AxeItemHooks() {
}
/**
* Adds a new stripping (interact with axe) recipe to the game.<p>
*
* Note that both the input block and the result block <em>must</em> have the
* {@link net.minecraft.world.level.block.state.properties.BlockStateProperties#AXIS AXIS} property,
* and that the value of this property will be copied from the input block to the result block when the recipe
* is performed.
*
* @param input input block
* @param result result block
* @throws IllegalArgumentException if the input or result blocks do not have the
* {@link net.minecraft.world.level.block.state.properties.BlockStateProperties#AXIS AXIS} property.
*/
public static void addStrippingRecipe(Block input, Block result) {
if (!input.defaultBlockState().hasProperty(RotatedPillarBlock.AXIS))
throw new IllegalArgumentException("Input block is missing required 'AXIS' property!");

View File

@@ -13,11 +13,26 @@ import java.util.function.Predicate;
public final class HoeItemHooks {
private HoeItemHooks() {
}
public static void addTillingRecipe(Block src, Predicate<UseOnContext> predicate, Consumer<UseOnContext> action) {
/**
* Adds a new tilling (interact with hoe) recipe to the game.<p>
*
* Tilling uses a predicate/consumer pair system:
* <ul>
* <li>First, the game tests the context using the predicate.</li>
* <li>Then, if the predicate returns {@code true}, the game will, <em>on the server side only</em>,
* invoke the action and then damage the hoe item by 1.</li>
* <li>Otherwise, no action will be invoked.</li>
* </ul>
*
* @param input input block
* @param predicate context predicate
* @param action action to run
*/
public static void addTillingRecipe(Block input, Predicate<UseOnContext> predicate, Consumer<UseOnContext> action) {
if (HoeItem.TILLABLES instanceof ImmutableMap) {
HoeItem.TILLABLES = new HashMap<>(HoeItem.TILLABLES);
}
HoeItem.TILLABLES.put(src, new Pair<>(predicate, action));
HoeItem.TILLABLES.put(input, new Pair<>(predicate, action));
}
}

View File

@@ -10,7 +10,20 @@ import java.util.HashMap;
public final class ShovelItemHooks {
private ShovelItemHooks() {
}
/**
* Adds a new flattening (interact with shovel) recipe to the game.<p>
*
* <b>Notes:</b>
* <ul>
* <li>Blocks can only be flattened if they have no block above them.</li>
* <li>{@linkplain net.minecraft.world.level.block.CampfireBlock Campfires} have a special case for being extinguished by a shovel,
* though you <em>can</em> override that using this method due to the check order.</li>
* </ul>
*
* @param input input block
* @param result result block state
*/
public static void addFlatteningRecipe(Block input, BlockState result) {
if (ShovelItem.FLATTENABLES instanceof ImmutableMap) {
ShovelItem.FLATTENABLES = new HashMap<>(ShovelItem.FLATTENABLES);