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