Skip to content

Commit

Permalink
1.18.2 time. thank you telepathicgrunt
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Mar 1, 2022
1 parent 88fd773 commit 5ee45b0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
10 changes: 2 additions & 8 deletions src/main/java/dev/cammiescorner/arcanus/Arcanus.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.cammiescorner.arcanus;

import com.google.common.collect.ImmutableList;
import dev.cammiescorner.arcanus.common.packets.CastSpellPacket;
import dev.cammiescorner.arcanus.common.screens.BookshelfScreenHandler;
import dev.cammiescorner.arcanus.common.structure.processor.BookshelfReplacerStructureProcessor;
Expand All @@ -26,16 +25,13 @@
import net.minecraft.item.ItemStack;
import net.minecraft.loot.function.LootFunctionType;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.structure.processor.StructureProcessorList;
import net.minecraft.structure.processor.StructureProcessorLists;
import net.minecraft.structure.processor.StructureProcessorType;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand All @@ -59,10 +55,8 @@ public class Arcanus implements ModInitializer {
public static final LootFunctionType ARCANUS_LOOT_FUNCTION = new LootFunctionType(new ArcanusLootFunction.Serializer());

//-----Structure Processors-----//
public static final RegistryEntry<StructureProcessorList> LECTERN_PROCESSOR = StructureProcessorLists.register("arcanus_lectern_processor", ImmutableList.of(LecternStructureProcessor.INSTANCE));
public static final RegistryEntry<StructureProcessorList> BOOKSHELF_PROCESSOR = StructureProcessorLists.register("arcanus_bookshelf_processor", ImmutableList.of(BookshelfReplacerStructureProcessor.INSTANCE));
public static final StructureProcessorType<LecternStructureProcessor> LECTERN_PROCESSOR_TYPE = StructureProcessorType.register("set_lectern_book", LecternStructureProcessor.CODEC);
public static final StructureProcessorType<BookshelfReplacerStructureProcessor> BOOKSHELF_PROCESSOR_TYPE = StructureProcessorType.register("replace_bookshelf", BookshelfReplacerStructureProcessor.CODEC);
public static final StructureProcessorType<LecternStructureProcessor> LECTERN_PROCESSOR = StructureProcessorType.register("set_lectern_book", LecternStructureProcessor.CODEC);
public static final StructureProcessorType<BookshelfReplacerStructureProcessor> BOOKSHELF_PROCESSOR = StructureProcessorType.register("replace_bookshelf", BookshelfReplacerStructureProcessor.CODEC);

//-----Screen Handlers-----//
public static final ScreenHandlerType<BookshelfScreenHandler> BOOKSHELF_SCREEN_HANDLER = ScreenHandlerRegistry.registerSimple(new Identifier(Arcanus.MOD_ID, "fillable_bookshelf"), BookshelfScreenHandler::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public Structure.StructureBlockInfo process(WorldView world, BlockPos pos, Block

@Override
protected StructureProcessorType<?> getType() {
return Arcanus.BOOKSHELF_PROCESSOR_TYPE;
return Arcanus.BOOKSHELF_PROCESSOR;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public Structure.StructureBlockInfo process(WorldView world, BlockPos pos, Block

@Override
protected StructureProcessorType<?> getType() {
return Arcanus.LECTERN_PROCESSOR_TYPE;
return Arcanus.LECTERN_PROCESSOR;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.mojang.blaze3d.systems.RenderSystem;
import dev.cammiescorner.arcanus.Arcanus;
import dev.cammiescorner.arcanus.common.items.WandItem;
import dev.cammiescorner.arcanus.common.structure.processor.BookshelfReplacerStructureProcessor;
import dev.cammiescorner.arcanus.common.structure.processor.LecternStructureProcessor;
import dev.cammiescorner.arcanus.core.registry.ModCommands;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
Expand All @@ -23,8 +25,14 @@
import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
import net.minecraft.structure.pool.SinglePoolElement;
import net.minecraft.structure.pool.StructurePool;
import net.minecraft.structure.processor.StructureProcessor;
import net.minecraft.structure.processor.StructureProcessorList;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryEntry;

import java.util.ArrayList;
import java.util.List;

public class EventHandler {
private static final Identifier HUD_ELEMENTS = new Identifier(Arcanus.MOD_ID, "textures/gui/hud_elements.png");
Expand Down Expand Up @@ -148,10 +156,17 @@ public static void addStructureProcessors(Registry<StructurePool> templatePoolRe
String currentElement = singleElement.location.left().get().toString();

if(Arcanus.getConfig().structuresWithBookshelves.contains(currentElement) || Arcanus.getConfig().structuresWithLecterns.contains(currentElement)) {
StructureProcessorList originalProcessorList = singleElement.processors.value();
List<StructureProcessor> mutableProcessorList = new ArrayList<>(originalProcessorList.getList());

if(Arcanus.getConfig().doLecternProcessor)
singleElement.processors = Arcanus.LECTERN_PROCESSOR;
mutableProcessorList.add(LecternStructureProcessor.INSTANCE);
if(Arcanus.getConfig().doBookshelfProcessor)
singleElement.processors = Arcanus.BOOKSHELF_PROCESSOR;
mutableProcessorList.add(BookshelfReplacerStructureProcessor.INSTANCE);

StructureProcessorList newProcessorList = new StructureProcessorList(mutableProcessorList);

singleElement.processors = RegistryEntry.of(newProcessorList);
}
}
}));
Expand Down

0 comments on commit 5ee45b0

Please sign in to comment.