mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-25 22:46:42 +01:00
Refine PR changes and improve Mods class
This commit is contained in:
parent
c336c92eb9
commit
1bf201e77c
7 changed files with 41 additions and 33 deletions
|
@ -355,13 +355,12 @@ public class AllTags {
|
|||
}
|
||||
|
||||
public boolean matches(RecipeSerializer<?> recipeSerializer) {
|
||||
return Registry.RECIPE_SERIALIZER.getOrCreateTag(tag).contains(ForgeRegistries.RECIPE_SERIALIZERS.getHolder(recipeSerializer).orElseThrow());
|
||||
return ForgeRegistries.RECIPE_SERIALIZERS.getHolder(recipeSerializer).orElseThrow().is(tag);
|
||||
}
|
||||
|
||||
private static void init() {}
|
||||
}
|
||||
|
||||
|
||||
public static void init() {
|
||||
AllBlockTags.init();
|
||||
AllItemTags.init();
|
||||
|
|
|
@ -177,13 +177,13 @@ public class Create {
|
|||
gen.addProvider(AllSoundEvents.provider(gen));
|
||||
}
|
||||
if (event.includeServer()) {
|
||||
gen.addProvider(new RecipeSerializerTagGen(gen, event.getExistingFileHelper()));
|
||||
gen.addProvider(new AllAdvancements(gen));
|
||||
gen.addProvider(new StandardRecipeGen(gen));
|
||||
gen.addProvider(new MechanicalCraftingRecipeGen(gen));
|
||||
gen.addProvider(new SequencedAssemblyRecipeGen(gen));
|
||||
ProcessingRecipeGen.registerAll(gen);
|
||||
// AllOreFeatureConfigEntries.gatherData(event);
|
||||
gen.addProvider(new RecipeSerializerTagGen(gen, event.getExistingFileHelper()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,26 +14,40 @@ import net.minecraftforge.registries.ForgeRegistries;
|
|||
* For compatibility with and without another mod present, we have to define load conditions of the specific code
|
||||
*/
|
||||
public enum Mods {
|
||||
DYNAMICTREES,
|
||||
TCONSTRUCT,
|
||||
CURIOS,
|
||||
|
||||
COMPUTERCRAFT,
|
||||
CURIOS,
|
||||
DYNAMICTREES,
|
||||
OCCULTISM,
|
||||
STORAGEDRAWERS,
|
||||
TCONSTRUCT,
|
||||
XLPACKETS;
|
||||
|
||||
/**
|
||||
* @return a boolean of whether the mod is loaded or not based on mod id
|
||||
*/
|
||||
public boolean isLoaded() {
|
||||
return ModList.get().isLoaded(asId());
|
||||
private final String id;
|
||||
|
||||
Mods() {
|
||||
id = Lang.asId(name());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mod id
|
||||
*/
|
||||
public String asId() {
|
||||
return Lang.asId(name());
|
||||
public String id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ResourceLocation rl(String path) {
|
||||
return new ResourceLocation(id, path);
|
||||
}
|
||||
|
||||
public Block getBlock(String id) {
|
||||
return ForgeRegistries.BLOCKS.getValue(rl(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a boolean of whether the mod is loaded or not based on mod id
|
||||
*/
|
||||
public boolean isLoaded() {
|
||||
return ModList.get().isLoaded(id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,8 +70,4 @@ public enum Mods {
|
|||
toExecute.get().run();
|
||||
}
|
||||
}
|
||||
|
||||
public Block getBlock(String id) {
|
||||
return ForgeRegistries.BLOCKS.getValue(new ResourceLocation(asId(), id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraftforge.items.IItemHandler;
|
|||
public class StorageDrawers {
|
||||
|
||||
public static boolean isDrawer(BlockEntity be) {
|
||||
return be != null && Mods.STORAGEDRAWERS.asId()
|
||||
return be != null && Mods.STORAGEDRAWERS.id()
|
||||
.equals(be.getType()
|
||||
.getRegistryName()
|
||||
.getNamespace());
|
||||
|
|
|
@ -237,10 +237,10 @@ public class AllDisplayBehaviours {
|
|||
Mods.COMPUTERCRAFT.executeIfInstalled(() -> () -> {
|
||||
DisplayBehaviour computerDisplaySource = register(Create.asResource("computer_display_source"), new ComputerDisplaySource());
|
||||
|
||||
assignBlockEntity(computerDisplaySource, new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "wired_modem_full"));
|
||||
assignBlockEntity(computerDisplaySource, new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "computer_normal"));
|
||||
assignBlockEntity(computerDisplaySource, new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "computer_advanced"));
|
||||
assignBlockEntity(computerDisplaySource, new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "computer_command"));
|
||||
assignBlockEntity(computerDisplaySource, Mods.COMPUTERCRAFT.rl("wired_modem_full"));
|
||||
assignBlockEntity(computerDisplaySource, Mods.COMPUTERCRAFT.rl("computer_normal"));
|
||||
assignBlockEntity(computerDisplaySource, Mods.COMPUTERCRAFT.rl("computer_advanced"));
|
||||
assignBlockEntity(computerDisplaySource, Mods.COMPUTERCRAFT.rl("computer_command"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,30 +2,30 @@ package com.simibubi.create.foundation.data;
|
|||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.simibubi.create.AllTags;
|
||||
import com.simibubi.create.AllTags.AllRecipeSerializerTags;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.compat.Mods;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.tags.TagsProvider;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
|
||||
public class RecipeSerializerTagGen extends TagsProvider<RecipeSerializer<?>> {
|
||||
public RecipeSerializerTagGen(DataGenerator pGenerator, @Nullable ExistingFileHelper existingFileHelper) {
|
||||
super(pGenerator, Registry.RECIPE_SERIALIZER, Create.ID, existingFileHelper);
|
||||
public RecipeSerializerTagGen(DataGenerator generator, @Nullable ExistingFileHelper existingFileHelper) {
|
||||
super(generator, Registry.RECIPE_SERIALIZER, Create.ID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Create Recipe Serializer Tags";
|
||||
return "Create's Recipe Serializer Tags";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags() {
|
||||
this.tag(AllTags.AllRecipeSerializerTags.AUTOMATION_IGNORE.tag)
|
||||
.addOptional(new ResourceLocation("occultism", "spirit_trade"))
|
||||
.addOptional(new ResourceLocation("occultism", "ritual"));
|
||||
this.tag(AllRecipeSerializerTags.AUTOMATION_IGNORE.tag)
|
||||
.addOptional(Mods.OCCULTISM.rl("spirit_trade"))
|
||||
.addOptional(Mods.OCCULTISM.rl("ritual"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.simibubi.create.compat.Mods;
|
|||
import com.simibubi.create.foundation.ponder.PonderRegistry;
|
||||
import com.simibubi.create.foundation.ponder.PonderTag;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
@ -314,7 +313,7 @@ public class AllPonderTags {
|
|||
.add(Blocks.TARGET);
|
||||
|
||||
Mods.COMPUTERCRAFT.executeIfInstalled(() -> () -> {
|
||||
Block computer = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(Mods.COMPUTERCRAFT.asId(), "computer_advanced"));
|
||||
Block computer = ForgeRegistries.BLOCKS.getValue(Mods.COMPUTERCRAFT.rl("computer_advanced"));
|
||||
if (computer != null)
|
||||
PonderRegistry.TAGS.forTag(DISPLAY_SOURCES).add(computer);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue