From 716840116bee089f525461698d0e6e96267a60d1 Mon Sep 17 00:00:00 2001 From: tterrag Date: Wed, 22 Jul 2020 22:34:05 -0400 Subject: [PATCH] Port everything in root package CommonEvents / All*** --- .../java/com/simibubi/create/AllBlocks.java | 8 ++-- .../java/com/simibubi/create/AllItems.java | 4 +- .../java/com/simibubi/create/AllTags.java | 47 ++++++++++--------- .../com/simibubi/create/CommonEvents.java | 6 +-- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index b3a37a50c..26928ba90 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -406,7 +406,7 @@ public class AllBlocks { public static final BlockEntry 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 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 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() diff --git a/src/main/java/com/simibubi/create/AllItems.java b/src/main/java/com/simibubi/create/AllItems.java index 6ac8e3b60..c6fe73b6c 100644 --- a/src/main/java/com/simibubi/create/AllItems.java +++ b/src/main/java/com/simibubi/create/AllItems.java @@ -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 taggedIngredient(String name, Tag... tags) { + private static ItemEntry taggedIngredient(String name, ITag.INamedTag... tags) { return REGISTRATE.item(name, Item::new) .tag(tags) .register(); diff --git a/src/main/java/com/simibubi/create/AllTags.java b/src/main/java/com/simibubi/create/AllTags.java index 7f05d7297..f50a90ce2 100644 --- a/src/main/java/com/simibubi/create/AllTags.java +++ b/src/main/java/com/simibubi/create/AllTags.java @@ -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 forgeBlockTag(String name) { - return forgeTag(BlockTags.getCollection(), name); + public static ITag.INamedTag forgeBlockTag(String name) { + return forgeTag(BlockTags::makeWrapperTag, name); } - public static Tag forgeItemTag(String name) { - return forgeTag(ItemTags.getCollection(), name); + public static ITag.INamedTag forgeItemTag(String name) { + return forgeTag(ItemTags::makeWrapperTag, name); } - public static Tag forgeTag(TagCollection collection, String name) { - return tag(collection, "forge", name); + public static ITag.INamedTag forgeTag(Function> wrapperFactory, String name) { + return tag(wrapperFactory, "forge", name); } - public static Tag tag(TagCollection collection, String domain, String name) { - return collection.getOrCreate(new ResourceLocation(domain, name)); + public static ITag.INamedTag tag(Function> 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 tag; + public ITag.INamedTag 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 tag; + public ITag.INamedTag 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 child) { - REGISTRATE.addDataGenerator(ProviderType.BLOCK_TAGS, prov -> prov.getBuilder(tag).add(child)); + public void includeAll(ITag.INamedTag 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)); } } diff --git a/src/main/java/com/simibubi/create/CommonEvents.java b/src/main/java/com/simibubi/create/CommonEvents.java index 0c4da0e88..4868c8a83 100644 --- a/src/main/java/com/simibubi/create/CommonEvents.java +++ b/src/main/java/com/simibubi/create/CommonEvents.java @@ -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