Loot table, tooltip, recipe, JEI information, on and off states finished
This commit is contained in:
parent
d90ccc298a
commit
c8463d7c9c
|
|
@ -146,6 +146,7 @@
|
|||
"gui.exdeorum.redstone_control.unpowered": "Unpowered",
|
||||
"info.exdeorum.crimson_nylium_spores": "Use on netherrack to turn it into a crimson nylium block.",
|
||||
"info.exdeorum.grass_seeds": "Use on dirt to turn it into a grass block.",
|
||||
"info.exdeorum.mechanical_hammer": "The Mechanical Hammer is a machine that, when supplied with Forge Energy (FE), will hammer blocks without a player having to do it themselves. It can operate without a hammer, but adding any hammer will double the speed, and efficiency enchantments on the hammer will further increase speed. It also supports three different modes of redstone control. Since Ex Deorum does not provide a way to generate FE, you will need another mod to provide power.",
|
||||
"info.exdeorum.mechanical_sieve": "The Mechanical Sieve is a machine that, when supplied with a mesh and Forge Energy (FE), will sift blocks without a player having to do it themselves. It also supports three different modes of redstone control. Since Ex Deorum does not provide a way to generate FE, you will need another mod to provide power.",
|
||||
"info.exdeorum.mycelium_spores": "Use on dirt to turn it into mycelium.",
|
||||
"info.exdeorum.sculk_core": "Use a sculk core on a Sculk Shrieker to enable it to spawn Wardens. Normally, Sculk Shriekers placed by players cannot spawn Wardens, so this item is useful for obtaining Sculk items in a SkyBlock world.",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_item": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": [
|
||||
"minecraft:hopper"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "exdeorum:mechanical_hammer"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_item",
|
||||
"has_the_recipe"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"exdeorum:mechanical_hammer"
|
||||
]
|
||||
},
|
||||
"sends_telemetry_event": true
|
||||
}
|
||||
|
|
@ -11,6 +11,11 @@
|
|||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"functions": [
|
||||
{
|
||||
"function": "exdeorum:machine"
|
||||
}
|
||||
],
|
||||
"name": "exdeorum:mechanical_hammer"
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"category": "misc",
|
||||
"key": {
|
||||
"#": {
|
||||
"item": "minecraft:iron_block"
|
||||
},
|
||||
"H": {
|
||||
"item": "minecraft:hopper"
|
||||
},
|
||||
"I": {
|
||||
"item": "minecraft:iron_ingot"
|
||||
},
|
||||
"T": {
|
||||
"tag": "exdeorum:hammers"
|
||||
}
|
||||
},
|
||||
"pattern": [
|
||||
"III",
|
||||
"ITI",
|
||||
"#H#"
|
||||
],
|
||||
"result": {
|
||||
"item": "exdeorum:mechanical_hammer"
|
||||
},
|
||||
"show_notification": true
|
||||
}
|
||||
|
|
@ -18,21 +18,40 @@
|
|||
|
||||
package thedarkcolour.exdeorum.block;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import thedarkcolour.exdeorum.blockentity.MechanicalHammerBlockEntity;
|
||||
import thedarkcolour.exdeorum.blockentity.MechanicalSieveBlockEntity;
|
||||
import thedarkcolour.exdeorum.config.EConfig;
|
||||
import thedarkcolour.exdeorum.data.TranslationKeys;
|
||||
import thedarkcolour.exdeorum.registry.EBlockEntities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MechanicalHammerBlock extends EBlock {
|
||||
public static final BooleanProperty RUNNING = BooleanProperty.create("running");
|
||||
public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;
|
||||
|
||||
public MechanicalHammerBlock(Properties properties) {
|
||||
super(properties, EBlockEntities.MECHANICAL_HAMMER);
|
||||
|
|
@ -42,7 +61,7 @@ public class MechanicalHammerBlock extends EBlock {
|
|||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(RUNNING);
|
||||
builder.add(RUNNING, FACING);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
@ -52,7 +71,49 @@ public class MechanicalHammerBlock extends EBlock {
|
|||
return type == EBlockEntities.MECHANICAL_HAMMER.get() && !level.isClientSide ? (BlockEntityTicker<T>) new MechanicalHammerBlockEntity.ServerTicker<>() : null;
|
||||
}
|
||||
|
||||
// todo creative drop and tooltip
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable BlockGetter level, List<Component> tooltip, TooltipFlag flag) {
|
||||
var nbt = BlockItem.getBlockEntityData(stack);
|
||||
if (nbt != null) {
|
||||
var inventoryNbt = nbt.getCompound("inventory");
|
||||
var inventory = new ItemStackHandler();
|
||||
inventory.deserializeNBT(inventoryNbt);
|
||||
var hammer = inventory.getStackInSlot(MechanicalHammerBlockEntity.HAMMER_SLOT);
|
||||
if (!hammer.isEmpty()) {
|
||||
tooltip.add(Component.translatable(TranslationKeys.MECHANICAL_HAMMER_HAMMER_LABEL).withStyle(ChatFormatting.GRAY).append(Component.translatable(hammer.getDescriptionId())));
|
||||
}
|
||||
var energy = nbt.getInt("energy");
|
||||
tooltip.add(Component.translatable(TranslationKeys.ENERGY).withStyle(ChatFormatting.GRAY).append(Component.translatable(TranslationKeys.FRACTION_DISPLAY, energy, EConfig.SERVER.mechanicalSieveEnergyStorage.get())).append(" FE"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerWillDestroy(Level level, BlockPos pos, BlockState pState, Player player) {
|
||||
if (!level.isClientSide && player.isCreative() && level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) {
|
||||
if (level.getBlockEntity(pos) instanceof MechanicalHammerBlockEntity sieve) {
|
||||
if (!sieve.inventory.getStackInSlot(MechanicalHammerBlockEntity.HAMMER_SLOT).isEmpty()) {
|
||||
var stack = new ItemStack(this);
|
||||
BlockItem.setBlockEntityData(stack, EBlockEntities.MECHANICAL_HAMMER.get(), sieve.saveWithoutMetadata());
|
||||
var itemEntity = new ItemEntity(level, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack);
|
||||
itemEntity.setDefaultPickUpDelay();
|
||||
level.addFreshEntity(itemEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.playerWillDestroy(level, pos, pState, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
||||
var nbt = BlockItem.getBlockEntityData(context.getItemInHand());
|
||||
var state = defaultBlockState();
|
||||
if (nbt != null && nbt.contains("progress") && nbt.getInt("progress") != MechanicalHammerBlockEntity.NOT_RUNNING) {
|
||||
state = state.setValue(RUNNING, true);
|
||||
}
|
||||
|
||||
return state.setValue(FACING, context.getHorizontalDirection().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
|
||||
|
|
|
|||
|
|
@ -149,6 +149,8 @@ public abstract class AbstractMachineBlockEntity<M extends AbstractMachineBlockE
|
|||
|
||||
protected abstract int getEnergyConsumption();
|
||||
|
||||
protected void noEnergyTick() {}
|
||||
|
||||
public static class ServerTicker<M extends AbstractMachineBlockEntity<M>> implements BlockEntityTicker<M> {
|
||||
@Override
|
||||
public void tick(Level level, BlockPos pos, BlockState state, M machine) {
|
||||
|
|
@ -163,6 +165,8 @@ public abstract class AbstractMachineBlockEntity<M extends AbstractMachineBlockE
|
|||
machine.energy.extractEnergy(energyConsumption, false);
|
||||
machine.runMachineTick();
|
||||
}
|
||||
} else {
|
||||
machine.noEnergyTick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import thedarkcolour.exdeorum.tag.EItemTags;
|
|||
public class MechanicalHammerBlockEntity extends AbstractMachineBlockEntity<MechanicalHammerBlockEntity> {
|
||||
private static final Component TITLE = Component.translatable(TranslationKeys.MECHANICAL_HAMMER_SCREEN_TITLE);
|
||||
private static final int INPUT_SLOT = 0;
|
||||
private static final int HAMMER_SLOT = 1;
|
||||
public static final int HAMMER_SLOT = 1;
|
||||
private static final int OUTPUT_SLOT = 2;
|
||||
public static final int TOTAL_PROGRESS = 10_000_000;
|
||||
// process should take 200 ticks or 10 seconds with no efficiency
|
||||
|
|
@ -111,6 +111,13 @@ public class MechanicalHammerBlockEntity extends AbstractMachineBlockEntity<Mech
|
|||
this.level.setBlock(this.worldPosition, this.getBlockState().setValue(MechanicalHammerBlock.RUNNING, false), 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void noEnergyTick() {
|
||||
if (getBlockState().getValue(MechanicalHammerBlock.RUNNING)) {
|
||||
this.level.setBlock(this.worldPosition, this.getBlockState().setValue(MechanicalHammerBlock.RUNNING, false), 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private HammerRecipe canFitResultIntoOutput(ItemStack input) {
|
||||
var output = this.inventory.getStackInSlot(OUTPUT_SLOT);
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ public class ExDeorumJeiPlugin implements IModPlugin {
|
|||
registration.addRecipeCatalyst(new ItemStack(EItems.IRON_HAMMER.get()), HAMMER);
|
||||
registration.addRecipeCatalyst(new ItemStack(EItems.DIAMOND_HAMMER.get()), HAMMER);
|
||||
registration.addRecipeCatalyst(new ItemStack(EItems.NETHERITE_HAMMER.get()), HAMMER);
|
||||
registration.addRecipeCatalyst(new ItemStack(EItems.MECHANICAL_HAMMER.get()), HAMMER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -232,6 +233,7 @@ public class ExDeorumJeiPlugin implements IModPlugin {
|
|||
registration.addItemStackInfo(new ItemStack(EItems.CRIMSON_NYLIUM_SPORES.get()), Component.translatable(TranslationKeys.CRIMSON_NYLIUM_SPORES_JEI_INFO));
|
||||
registration.addItemStackInfo(new ItemStack(EItems.SCULK_CORE.get()), Component.translatable(TranslationKeys.SCULK_CORE_JEI_INFO));
|
||||
registration.addItemStackInfo(new ItemStack(EItems.MECHANICAL_SIEVE.get()), Component.translatable(TranslationKeys.MECHANICAL_SIEVE_JEI_INFO));
|
||||
registration.addItemStackInfo(new ItemStack(EItems.MECHANICAL_HAMMER.get()), Component.translatable(TranslationKeys.MECHANICAL_HAMMER_JEI_INFO));
|
||||
|
||||
var toRemove = new ArrayList<ItemStack>();
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ class BlockLoot extends BlockLootSubProvider {
|
|||
.setRolls(ConstantValue.exactly(1.0F))
|
||||
.add(LootItem.lootTableItem(EItems.MECHANICAL_SIEVE.get())
|
||||
.apply(MachineLootFunction.machineLoot())))));
|
||||
add(EBlocks.MECHANICAL_HAMMER.get(), LootTable.lootTable()
|
||||
.withPool(applyExplosionCondition(EItems.MECHANICAL_HAMMER.get(), LootPool.lootPool()
|
||||
.setRolls(ConstantValue.exactly(1.0F))
|
||||
.add(LootItem.lootTableItem(EItems.MECHANICAL_HAMMER.get())
|
||||
.apply(MachineLootFunction.machineLoot())))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class English {
|
|||
english.add(TranslationKeys.VOID_WORLD_TYPE, "Void World");
|
||||
english.add(TranslationKeys.FRACTION_DISPLAY, ": %s / %s");
|
||||
english.add(TranslationKeys.MECHANICAL_SIEVE_MESH_LABEL, "Mesh: ");
|
||||
english.add(TranslationKeys.MECHANICAL_HAMMER_HAMMER_LABEL, "Hammer: ");
|
||||
english.add(TranslationKeys.ENERGY, "Energy");
|
||||
|
||||
english.add(TranslationKeys.ROOT_ADVANCEMENT_TITLE, "Don't Look Down...");
|
||||
|
|
@ -55,6 +56,7 @@ class English {
|
|||
english.add(TranslationKeys.CRIMSON_NYLIUM_SPORES_JEI_INFO, "Use on netherrack to turn it into a crimson nylium block.");
|
||||
english.add(TranslationKeys.SCULK_CORE_JEI_INFO, "Use a sculk core on a Sculk Shrieker to enable it to spawn Wardens. Normally, Sculk Shriekers placed by players cannot spawn Wardens, so this item is useful for obtaining Sculk items in a SkyBlock world.");
|
||||
english.add(TranslationKeys.MECHANICAL_SIEVE_JEI_INFO, "The Mechanical Sieve is a machine that, when supplied with a mesh and Forge Energy (FE), will sift blocks without a player having to do it themselves. It also supports three different modes of redstone control. Since Ex Deorum does not provide a way to generate FE, you will need another mod to provide power.");
|
||||
english.add(TranslationKeys.MECHANICAL_HAMMER_JEI_INFO, "The Mechanical Hammer is a machine that, when supplied with Forge Energy (FE), will hammer blocks without a player having to do it themselves. It can operate without a hammer, but adding any hammer will double the speed, and efficiency enchantments on the hammer will further increase speed. It also supports three different modes of redstone control. Since Ex Deorum does not provide a way to generate FE, you will need another mod to provide power.");
|
||||
|
||||
english.add(TranslationKeys.BARREL_COMPOST_CATEGORY_TITLE, "Barrel Compost");
|
||||
english.add(TranslationKeys.BARREL_COMPOST_RECIPE_VOLUME, "Compost: %s");
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ public class TranslationKeys {
|
|||
// ": %s / %s"
|
||||
public static final String FRACTION_DISPLAY = "item." + ExDeorum.ID + ".watering_can_fluid_display";
|
||||
public static final String MECHANICAL_SIEVE_MESH_LABEL = "item." + ExDeorum.ID + ".mechanical_sieve.mesh_label";
|
||||
public static final String MECHANICAL_HAMMER_HAMMER_LABEL = "item." + ExDeorum.ID + ".mechanical_hammer.hammer_label";
|
||||
public static final String ENERGY = "gui." + ExDeorum.ID + ".energy_label";
|
||||
|
||||
// Advancements
|
||||
|
|
@ -53,6 +54,7 @@ public class TranslationKeys {
|
|||
public static final String CRIMSON_NYLIUM_SPORES_JEI_INFO = "info." + ExDeorum.ID + ".crimson_nylium_spores";
|
||||
public static final String SCULK_CORE_JEI_INFO = "info." + ExDeorum.ID + ".sculk_core";
|
||||
public static final String MECHANICAL_SIEVE_JEI_INFO = "info." + ExDeorum.ID + ".mechanical_sieve";
|
||||
public static final String MECHANICAL_HAMMER_JEI_INFO = "info." + ExDeorum.ID + ".mechanical_hammer";
|
||||
|
||||
// JEI recipe categories
|
||||
public static final String BARREL_COMPOST_CATEGORY_TITLE = "gui." + ExDeorum.ID + ".category.barrel_compost";
|
||||
|
|
|
|||
|
|
@ -291,6 +291,16 @@ public class Recipes {
|
|||
recipe.pattern("I I");
|
||||
MKRecipeProvider.unlockedByHaving(recipe, Items.HOPPER);
|
||||
});
|
||||
recipes.shapedCrafting(RecipeCategory.MISC, EItems.MECHANICAL_HAMMER.get(), recipe -> {
|
||||
recipe.define('#', Items.IRON_BLOCK);
|
||||
recipe.define('H', Items.HOPPER);
|
||||
recipe.define('T', EItemTags.HAMMERS);
|
||||
recipe.define('I', Items.IRON_INGOT);
|
||||
recipe.pattern("III");
|
||||
recipe.pattern("ITI");
|
||||
recipe.pattern("#H#");
|
||||
MKRecipeProvider.unlockedByHaving(recipe, Items.HOPPER);
|
||||
});
|
||||
}
|
||||
|
||||
private static void modUShaped(MKRecipeProvider recipes, String modid, RegistryObject<? extends Item> sides, RegistryObject<? extends Item> middle, RegistryObject<? extends Item> result) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user