Skip to content

Commit

Permalink
feat: Add Fabricae Ex Nihilo support
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jul 4, 2024
1 parent 890ea1f commit 06b215a
Show file tree
Hide file tree
Showing 37 changed files with 614 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{
"id": "exnihilosequentia:copper_hammer",
"required": false
},
{
"id": "exdeorum:copper_hammer",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{
"id": "exnihilosequentia:crushed_andesite",
"required": false
},
{
"id": "fabricaeexnihilo:crushed_andesite",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{
"id": "exnihilosequentia:crushed_diorite",
"required": false
},
{
"id": "fabricaeexnihilo:crushed_diorite",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:crushed_end_stone",
"required": false
},
{
"id": "fabricaeexnihilo:crushed_endstone",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{
"id": "exnihilosequentia:crushed_granite",
"required": false
},
{
"id": "fabricaeexnihilo:crushed_granite",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:crushed_netherrack",
"required": false
},
{
"id": "fabricaeexnihilo:crushed_netherrack",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:diamond_hammer",
"required": false
},
{
"id": "fabricaeexnihilo:diamond_hammer",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:dust",
"required": false
},
{
"id": "fabricaeexnihilo:dust",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:golden_hammer",
"required": false
},
{
"id": "fabricaeexnihilo:golden_hammer",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:iron_hammer",
"required": false
},
{
"id": "fabricaeexnihilo:iron_hammer",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:netherite_hammer",
"required": false
},
{
"id": "fabricaeexnihilo:netherite_hammer",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,50 @@
{
"id": "exdeorum:crimson_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:acacia_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:birch_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:dark_oak_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:jungle_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:oak_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:spruce_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:cherry_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:mangrove_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:warped_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:crimson_sieve",
"required": false
},
{
"id": "fabricaeexnihilo:bamboo_sieve",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:stone_hammer",
"required": false
},
{
"id": "fabricaeexnihilo:stone_hammer",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:crook",
"required": false
},
{
"id": "fabricaeexnihilo:wooden_crook",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,50 @@
{
"id": "exdeorum:warped_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:acacia_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:birch_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:cherry_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:dark_oak_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:jungle_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:mangrove_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:oak_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:spruce_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:crimson_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:warped_crucible",
"required": false
},
{
"id": "fabricaeexnihilo:bamboo_crucible",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
{
"id": "exdeorum:wooden_hammer",
"required": false
},
{
"id": "fabricaeexnihilo:wooden_hammer",
"required": false
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static void initialize() {

Balm.initializeIfLoaded(Compat.EXNIHILO_SEQUENTIA, "net.blay09.mods.excompressum.forge.compat.exnihilosequentia.ExNihiloSequentiaAddon");
Balm.initializeIfLoaded(Compat.EX_DEORUM, "net.blay09.mods.excompressum.forge.compat.exdeorum.ExDeorumAddon");
Balm.initializeIfLoaded(Compat.FABRICAE_EX_NIHILO, "net.blay09.mods.excompressum.fabric.compat.fabricaeexnihilo.FabricaeExNihiloAddon");

AutoSieveSkinRegistry.load();
HammerSpeedHandler.initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public interface ExNihiloProvider {

boolean isHammerableCompressed(ItemStack itemStack);

boolean isHammerable(BlockState state);
boolean isHammerable(Level level, BlockState state);

List<ItemStack> rollHammerRewards(Level level, BlockState state, ItemStack tool, RandomSource rand);

boolean isSiftableWithMesh(BlockState sieveState, BlockState state, @Nullable SieveMeshRegistryEntry sieveMesh);
boolean isSiftableWithMesh(Level level, BlockState sieveState, BlockState state, @Nullable SieveMeshRegistryEntry sieveMesh);

boolean isHeavySiftableWithMesh(BlockState sieveState, BlockState state, @Nullable SieveMeshRegistryEntry sieveMesh);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public enum CommonMeshType implements StringRepresentable {
STRING,
FLINT,
COPPER,
IRON,
GOLD,
DIAMOND,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public float getEffectiveLuck() {
}

public boolean isSiftableWithMesh(ItemStack itemStack, @Nullable SieveMeshRegistryEntry sieveMesh) {
return ExNihilo.isSiftableWithMesh(getBlockState(), itemStack, sieveMesh);
return ExNihilo.isSiftableWithMesh(level, getBlockState(), itemStack, sieveMesh);
}

private boolean isMesh(ItemStack itemStack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public boolean isRegistered(ItemStack itemStack) {
}

final var recipeManager = level.getRecipeManager();
return ExNihilo.isHammerable(itemStack) || ExRegistries.getHammerRegistry().isHammerable(recipeManager, itemStack);
return ExNihilo.isHammerable(level, itemStack) || ExRegistries.getHammerRegistry().isHammerable(recipeManager, itemStack);
}

public Collection<ItemStack> rollHammerRewards(ItemStack itemStack, ItemStack toolItem, RandomSource rand) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

public class Compat {
public static final String EXNIHILO_SEQUENTIA = "exnihilosequentia";
public static final String FABRICAE_EX_NIHILO = "fabricaeexnihilo";
public static final String EX_DEORUM = "exdeorum";
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.blay09.mods.excompressum.item;

import net.blay09.mods.balm.api.Balm;
import net.blay09.mods.balm.api.energy.BalmEnergyStorageProvider;
import net.blay09.mods.balm.api.energy.EnergyStorage;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
Expand Down Expand Up @@ -31,9 +32,16 @@ public InteractionResult useOn(UseOnContext context) {
if (context.getPlayer() != null && context.getPlayer().getAbilities().instabuild) {
final var blockEntity = context.getLevel().getBlockEntity(context.getClickedPos());
if (blockEntity != null) {
final var energyStorage = Balm.getProviders().getProvider(blockEntity, EnergyStorage.class);
if (energyStorage != null) {
energyStorage.setEnergy(energyStorage.getCapacity());
if (blockEntity instanceof BalmEnergyStorageProvider energyStorageProvider) {
final var energyStorage = energyStorageProvider.getEnergyStorage();
if (energyStorage != null) {
energyStorage.setEnergy(energyStorage.getCapacity());
}
} else {
final var energyStorage = Balm.getProviders().getProvider(blockEntity, EnergyStorage.class);
if (energyStorage != null) {
energyStorage.setEnergy(energyStorage.getCapacity());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public InteractionResult useOn(UseOnContext context) {

@Override
public boolean mineBlock(ItemStack itemStack, Level level, BlockState state, BlockPos pos, LivingEntity entityLiving) {
if (!level.isClientSide && isCorrectToolForDrops(itemStack, state) && ExNihilo.getInstance().isHammerable(state)) {
if (!level.isClientSide && isCorrectToolForDrops(itemStack, state) && ExNihilo.getInstance().isHammerable(level, state)) {
level.removeBlock(pos, false);
Collection<ItemStack> rewards = ExNihilo.getInstance().rollHammerRewards(level, state, itemStack, level.random);
for (ItemStack rewardStack : rewards) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void apply(LootContext context, List<ItemStack> list) {
return;
}

if (ExNihilo.getInstance().isHammerable(state)) {
if (ExNihilo.getInstance().isHammerable(context.getLevel(), state)) {
synchronized (activeContexts) {
activeContexts.add(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void apply(LootContext context, List<ItemStack> list) {
return;
}

if (ExNihilo.getInstance().isHammerable(state)) {
if (ExNihilo.getInstance().isHammerable(context.getLevel(), state)) {
synchronized (activeContexts) {
activeContexts.add(context);
}
Expand Down
Loading

0 comments on commit 06b215a

Please sign in to comment.