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

View file

@ -45,7 +45,7 @@ import com.tterrag.registrate.util.entry.ItemEntry;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.Rarity; import net.minecraft.item.Rarity;
import net.minecraft.tags.Tag; import net.minecraft.tags.ITag;
public class AllItems { public class AllItems {
@ -235,7 +235,7 @@ public class AllItems {
} }
@SafeVarargs @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) return REGISTRATE.item(name, Item::new)
.tag(tags) .tag(tags)
.register(); .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.FORGE;
import static com.simibubi.create.AllTags.NameSpace.MOD; 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.data.CreateRegistrate;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.tterrag.registrate.builders.BlockBuilder; import com.tterrag.registrate.builders.BlockBuilder;
@ -17,9 +19,8 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tags.BlockTags; import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags; import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.tags.TagCollection;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -34,20 +35,20 @@ public class AllTags {
.tag(forgeItemTag(tagName)); .tag(forgeItemTag(tagName));
} }
public static Tag<Block> forgeBlockTag(String name) { public static ITag.INamedTag<Block> forgeBlockTag(String name) {
return forgeTag(BlockTags.getCollection(), name); return forgeTag(BlockTags::makeWrapperTag, name);
} }
public static Tag<Item> forgeItemTag(String name) { public static ITag.INamedTag<Item> forgeItemTag(String name) {
return forgeTag(ItemTags.getCollection(), name); return forgeTag(ItemTags::makeWrapperTag, name);
} }
public static <T> Tag<T> forgeTag(TagCollection<T> collection, String name) { public static <T> ITag.INamedTag<T> forgeTag(Function<String, ITag.INamedTag<T>> wrapperFactory, String name) {
return tag(collection, "forge", name); return tag(wrapperFactory, "forge", name);
} }
public static <T> Tag<T> tag(TagCollection<T> collection, String domain, String name) { public static <T> ITag.INamedTag<T> tag(Function<String, ITag.INamedTag<T>> wrapperFactory, String domain, String name) {
return collection.getOrCreate(new ResourceLocation(domain, name)); return wrapperFactory.apply(new ResourceLocation(domain, name).toString());
} }
public static enum NameSpace { public static enum NameSpace {
@ -67,15 +68,15 @@ public class AllTags {
; ;
public Tag<Item> tag; public ITag.INamedTag<Item> tag;
private AllItemTags(NameSpace namespace) { private AllItemTags(NameSpace namespace) {
this(namespace, ""); this(namespace, "");
} }
private AllItemTags(NameSpace namespace, String path) { private AllItemTags(NameSpace namespace, String path) {
tag = new ItemTags.Wrapper( tag = ItemTags.makeWrapperTag(
new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name()))); new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name())).toString());
} }
public boolean matches(ItemStack stack) { public boolean matches(ItemStack stack) {
@ -83,8 +84,8 @@ public class AllTags {
} }
public void includeIn(AllItemTags parent) { public void includeIn(AllItemTags parent) {
REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.getBuilder(parent.tag) REGISTRATE.addDataGenerator(ProviderType.ITEM_TAGS, prov -> prov.getOrCreateTagBuilder(parent.tag)
.add(tag)); .addTag(tag));
} }
} }
@ -93,7 +94,7 @@ public class AllTags {
; ;
public Tag<Block> tag; public ITag.INamedTag<Block> tag;
private AllBlockTags() { private AllBlockTags() {
this(MOD, ""); this(MOD, "");
@ -104,8 +105,8 @@ public class AllTags {
} }
private AllBlockTags(NameSpace namespace, String path) { private AllBlockTags(NameSpace namespace, String path) {
tag = new BlockTags.Wrapper( tag = BlockTags.makeWrapperTag(
new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name()))); new ResourceLocation(namespace.id, (path.isEmpty() ? "" : path + "/") + Lang.asId(name())).toString());
} }
public boolean matches(BlockState block) { public boolean matches(BlockState block) {
@ -113,16 +114,16 @@ public class AllTags {
} }
public void includeIn(AllBlockTags parent) { public void includeIn(AllBlockTags parent) {
REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getBuilder(parent.tag) REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getOrCreateTagBuilder(parent.tag)
.add(tag)); .addTag(tag));
} }
public void includeAll(Tag<Block> child) { public void includeAll(ITag.INamedTag<Block> child) {
REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getBuilder(tag).add(child)); REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getOrCreateTagBuilder(tag).addTag(child));
} }
public void add(Block ...values) { 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.minecraft.world.IWorld;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.RegisterCommandsEvent;
import net.minecraftforge.event.TickEvent.Phase; import net.minecraftforge.event.TickEvent.Phase;
import net.minecraftforge.event.TickEvent.ServerTickEvent; import net.minecraftforge.event.TickEvent.ServerTickEvent;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent; import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
@EventBusSubscriber @EventBusSubscriber
@ -30,8 +30,8 @@ public class CommonEvents {
} }
@SubscribeEvent @SubscribeEvent
public static void serverStarting(FMLServerStartingEvent event) { public static void registerCommands(RegisterCommandsEvent event) {
new CreateCommand(event.getCommandDispatcher()); new CreateCommand(event.getDispatcher());
} }
@SubscribeEvent @SubscribeEvent