Skip to content

Commit

Permalink
雷击铁块获得磁铁
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Mar 6, 2024
1 parent 870ce90 commit 43b915e
Show file tree
Hide file tree
Showing 15 changed files with 415 additions and 220 deletions.
2 changes: 2 additions & 0 deletions src/main/java/dev/dubhe/anvilcraft/AnvilCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import dev.dubhe.anvilcraft.config.AnvilCraftConfig;
import dev.dubhe.anvilcraft.data.recipe.ModRecipeTypes;
import dev.dubhe.anvilcraft.event.listener.AnvilEventListener;
import dev.dubhe.anvilcraft.event.listener.LightningEventListener;
import dev.dubhe.anvilcraft.item.ModItems;
import dev.dubhe.anvilcraft.log.Logger;
import net.fabricmc.api.ModInitializer;
Expand Down Expand Up @@ -43,6 +44,7 @@ public class AnvilCraft implements ModInitializer {
@Override
public void onInitialize() {
AnvilCraft.EVENT_BUS.register(new AnvilEventListener());
AnvilCraft.EVENT_BUS.register(new LightningEventListener());
for (Map.Entry<String, Block> entry : ModBlocks.BLOCK_MAP.entrySet()) {
Registry.register(BuiltInRegistries.BLOCK, AnvilCraft.of(entry.getKey()), entry.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Vector;
Expand All @@ -22,8 +23,9 @@ public <E> void listen(Class<E> event, Consumer<E> trigger) {
}

@SuppressWarnings("all")
public <E> void post(E event) {
List<Consumer<?>> triggers = EVENT_LISTENER.getOrDefault(event.getClass(), new Vector<>());
public <E> void post(@NotNull E event) {
List<Consumer<?>> triggers = new ArrayList<>();
EVENT_LISTENER.entrySet().stream().filter((k) -> event.getClass().isAssignableFrom(k.getKey())).map(Map.Entry::getValue).forEach(triggers::addAll);
for (Consumer<?> trigger : triggers) {
((Consumer<E>) trigger).accept(event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
public class AnvilCraftConfig {
@SerializedName("anvil_efficiency")
public int anvilEfficiency = 64;
@SerializedName("lightning_strike_depth")
public int lightningStrikeDepth = 2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ public void buildRecipes(Consumer<FinishedRecipe> exporter) {
.save(exporter, AnvilCraft.of("snow_2_water_cauldron_1"));
BlockAnvilRecipeBuilder.block(RecipeCategory.MISC, Blocks.ICE.defaultBlockState(), Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 2))
.component(Blocks.SNOW_BLOCK)
.component(Component.of(Blocks.WATER_CAULDRON).withState("level", 1))
.component(Component.of(Component.Value.of(Blocks.WATER_CAULDRON).with("level", 1)))
.unlockedBy(hasItem(Items.SNOW), FabricRecipeProvider.has(Items.SNOW))
.save(exporter, AnvilCraft.of("snow_2_water_cauldron_2"));
BlockAnvilRecipeBuilder.block(RecipeCategory.MISC, Blocks.ICE.defaultBlockState(), Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3))
.component(Blocks.SNOW_BLOCK)
.component(Component.of(Blocks.WATER_CAULDRON).withState("level", 2))
.component(Component.of(Component.Value.of(Blocks.WATER_CAULDRON).with("level", 2)))
.unlockedBy(hasItem(Items.SNOW), FabricRecipeProvider.has(Items.SNOW))
.save(exporter, AnvilCraft.of("snow_2_water_cauldron_3"));
}
Expand Down
Loading

0 comments on commit 43b915e

Please sign in to comment.