Port everything in root package

CommonEvents / All***
This commit is contained in:
tterrag 2020-07-22 22:34:05 -04:00
parent c1f68ab830
commit 716840116b
4 changed files with 33 additions and 32 deletions

View file

@ -406,7 +406,7 @@ public class AllBlocks {
public static final BlockEntry<HeaterBlock> HEATER = REGISTRATE.block("blaze_heater", HeaterBlock::new)
.initialProperties(SharedProperties::softMetal)
.properties(p -> p.lightValue(12))
.properties(p -> p.lightLevel($ -> 12))
.addLayer(() -> RenderType::getCutoutMipped)
.tag(AllBlockTags.FAN_TRANSPARENT.tag, AllBlockTags.FAN_HEATERS.tag)
.blockstate((c, p) -> p.simpleBlock(c.getEntry(), AssetLookup.partialBaseModel(c, p)))
@ -499,7 +499,7 @@ public class AllBlocks {
.loot((p, b) -> p.registerDropping(b, PISTON_EXTENSION_POLE.get()))
.blockstate((c, p) -> BlockStateGen.directionalBlockIgnoresWaterlogged(c, p, state -> p.models()
.getExistingFile(p.modLoc("block/mechanical_piston/" + state.get(MechanicalPistonHeadBlock.TYPE)
.getName() + "/head"))))
.name() + "/head"))))
.register();
public static final BlockEntry<MechanicalBearingBlock> MECHANICAL_BEARING =
@ -651,7 +651,7 @@ public class AllBlocks {
static {
for (DyeColor colour : DyeColor.values()) {
String colourName = colour.getName();
String colourName = colour.name();
REGISTRATE.block(colourName + "_seat", p -> new SeatBlock(p, colour == DyeColor.RED))
.initialProperties(SharedProperties::wooden)
.blockstate((c, p) -> {
@ -816,7 +816,7 @@ public class AllBlocks {
public static final BlockEntry<NixieTubeBlock> NIXIE_TUBE = REGISTRATE.block("nixie_tube", NixieTubeBlock::new)
.initialProperties(SharedProperties::softMetal)
.properties(p -> p.lightValue(5))
.properties(p -> p.lightLevel($ -> 5))
.blockstate(new NixieTubeGenerator()::generate)
.addLayer(() -> RenderType::getTranslucent)
.item()

View file

@ -45,7 +45,7 @@ import com.tterrag.registrate.util.entry.ItemEntry;
import net.minecraft.item.Item;
import net.minecraft.item.Rarity;
import net.minecraft.tags.Tag;
import net.minecraft.tags.ITag;
public class AllItems {
@ -235,7 +235,7 @@ public class AllItems {
}
@SafeVarargs
private static ItemEntry<Item> taggedIngredient(String name, Tag<Item>... tags) {
private static ItemEntry<Item> taggedIngredient(String name, ITag.INamedTag<Item>... tags) {
return REGISTRATE.item(name, Item::new)
.tag(tags)
.register();

View file

@ -3,6 +3,8 @@ package com.simibubi.create;
import static com.simibubi.create.AllTags.NameSpace.FORGE;
import static com.simibubi.create.AllTags.NameSpace.MOD;
import java.util.function.Function;
import com.simibubi.create.foundation.data.CreateRegistrate;
import com.simibubi.create.foundation.utility.Lang;
import com.tterrag.registrate.builders.BlockBuilder;
@ -17,9 +19,8 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagCollection;
import net.minecraft.util.ResourceLocation;
@ -34,20 +35,20 @@ public class AllTags {
.tag(forgeItemTag(tagName));
}
public static Tag<Block> forgeBlockTag(String name) {
return forgeTag(BlockTags.getCollection(), name);
public static ITag.INamedTag<Block> forgeBlockTag(String name) {
return forgeTag(BlockTags::makeWrapperTag, name);
}
public static Tag<Item> forgeItemTag(String name) {
return forgeTag(ItemTags.getCollection(), name);
public static ITag.INamedTag<Item> forgeItemTag(String name) {
return forgeTag(ItemTags::makeWrapperTag, name);
}
public static <T> Tag<T> forgeTag(TagCollection<T> collection, String name) {
return tag(collection, "forge", name);
public static <T> ITag.INamedTag<T> forgeTag(Function<String, ITag.INamedTag<T>> wrapperFactory, String name) {
return tag(wrapperFactory, "forge", name);
}
public static <T> Tag<T> tag(TagCollection<T> collection, String domain, String name) {
return collection.getOrCreate(new ResourceLocation(domain, name));
public static <T> ITag.INamedTag<T> tag(Function<String, ITag.INamedTag<T>> wrapperFactory, String domain, String name) {
return wrapperFactory.apply(new ResourceLocation(domain, name).toString());
}
public static enum NameSpace {
@ -67,15 +68,15 @@ public class AllTags {
;
public Tag<Item> tag;
public ITag.INamedTag<Item> tag;
private AllItemTags(NameSpace namespace) {
this(namespace, "");
}
private AllItemTags(NameSpace namespace, String path) {
tag = new ItemTags.Wrapper(
new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name())));
tag = ItemTags.makeWrapperTag(
new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name())).toString());
}
public boolean matches(ItemStack stack) {
@ -83,8 +84,8 @@ public class AllTags {
}
public void includeIn(AllItemTags parent) {
REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.getBuilder(parent.tag)
.add(tag));
REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.getOrCreateTagBuilder(parent.tag)
.addTag(tag));
}
}
@ -93,7 +94,7 @@ public class AllTags {
;
public Tag<Block> tag;
public ITag.INamedTag<Block> tag;
private AllBlockTags() {
this(MOD, "");
@ -104,8 +105,8 @@ public class AllTags {
}
private AllBlockTags(NameSpace namespace, String path) {
tag = new BlockTags.Wrapper(
new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name())));
tag = BlockTags.makeWrapperTag(
new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name())).toString());
}
public boolean matches(BlockState block) {
@ -113,16 +114,16 @@ public class AllTags {
}
public void includeIn(AllBlockTags parent) {
REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getBuilder(parent.tag)
.add(tag));
REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getOrCreateTagBuilder(parent.tag)
.addTag(tag));
}
public void includeAll(Tag<Block> child) {
REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getBuilder(tag).add(child));
public void includeAll(ITag.INamedTag<Block> child) {
REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getOrCreateTagBuilder(tag).addTag(child));
}
public void add(Block ...values) {
REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getBuilder(tag).add(values));
REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getOrCreateTagBuilder(tag).add(values));
}
}

View file

@ -4,13 +4,13 @@ import com.simibubi.create.foundation.command.CreateCommand;
import net.minecraft.world.IWorld;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.event.TickEvent.ServerTickEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
@EventBusSubscriber
@ -30,8 +30,8 @@ public class CommonEvents {
}
@SubscribeEvent
public static void serverStarting(FMLServerStartingEvent event) {
new CreateCommand(event.getCommandDispatcher());
public static void registerCommands(RegisterCommandsEvent event) {
new CreateCommand(event.getDispatcher());
}
@SubscribeEvent