Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Regilite Rewrite #839

Draft
wants to merge 7 commits into
base: dev/1.21.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions buildSrc/shared.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ fun getVersionString(): String {
val versionSeries: String by project

// If this is not a release, we're going to get the last tag, add the ci build number, then append -dev+<commit_hash>
var commitHash = shellRunAndRead("git rev-parse --short HEAD").trim();
var previousTagVersion = shellRunAndRead("git describe --tags --abbrev=0").trim();
val commitHash = shellRunAndRead("git rev-parse --short HEAD").trim();
val previousTagVersion = shellRunAndRead("git describe --tags --abbrev=0").trim();

// Extract the numeric component of the last version.
var versionRegex = Regex("""\d+(\.\d+)+""")
val versionRegex = Regex("""\d+(\.\d+)+""")
var currentVersion = versionRegex.find(previousTagVersion)?.value
if (currentVersion == null) {
// Fallback to version series if we're unable to discover the previous version.
Expand Down
2 changes: 1 addition & 1 deletion endercore/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ val almostunifiedVersion: String by project

dependencies {
// Regilite
api("com.enderio:Regilite:${regiliteVersion}")
api("com.enderio:regilite:${regiliteVersion}")

// Almost Unified
compileOnly("com.almostreliable.mods:almostunified-neoforge:1.21.1-${almostunifiedVersion}:api")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.enderio.core.data.model;

import com.enderio.regilite.data.DataGenContext;
import com.enderio.regilite.data.RegiliteItemModelProvider;
import com.enderio.regilite.items.RegiliteItemModelProvider;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.MissingTextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
Expand Down
2 changes: 1 addition & 1 deletion enderio-armory/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ val cctMinecraftVersion: String by project
val cctVersion: String by project

dependencies {
api("com.enderio:Regilite:$regiliteVersion")
api("com.enderio:regilite:$regiliteVersion")

api(project(":enderio-base"))
accessTransformers(project(":enderio-base"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public EnderIOArmory(IEventBus modEventBus, ModContainer modContainer) {
modContainer.registerConfig(ModConfig.Type.CLIENT, ArmoryConfig.CLIENT_SPEC, "enderio/armory-client.toml");

// Perform initialization and registration for everything so things are registered.
ArmoryItems.register(modEventBus);
ArmoryItems.register();
ArmoryRecipes.register(modEventBus);
ArmoryLootModifiers.register(modEventBus);
ArmoryTags.register();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
import com.enderio.armory.common.tag.ArmoryTags;
import com.enderio.base.common.init.EIOCreativeTabs;
import com.enderio.base.common.tag.EIOTags;
import com.enderio.regilite.holder.RegiliteItem;
import com.enderio.regilite.registry.ItemRegistry;
import com.enderio.regilite.items.RegiliteItems;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.crafting.Ingredient;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.common.SimpleTier;
import net.neoforged.neoforge.registries.DeferredItem;

@SuppressWarnings("unused")
public class ArmoryItems {
private static final ItemRegistry ITEM_REGISTRY = EnderIOArmory.REGILITE.itemRegistry();
private static final RegiliteItems ITEMS = EnderIOArmory.REGILITE.items();

/*public static final Tier DARK_STEEL_TIER = TierSortingRegistry.registerTier(
new SimpleTier(3, 2000, 8.0F, 3, 25, ArmoryTags.Blocks.DARK_STEEL_TIER, () -> Ingredient.of(EIOItems.DARK_STEEL_INGOT.get())),
Expand All @@ -24,11 +23,12 @@ public class ArmoryItems {
public static final Tier DARK_STEEL_TIER = new SimpleTier(ArmoryTags.Blocks.INCORRECT_FOR_DARK_STEEL_TOOL, 2000, 8.0f, 3.0f, 25, () -> Ingredient.of(
EIOTags.Items.INGOTS_DARK_STEEL));

public static final RegiliteItem<DarkSteelSwordItem> DARK_STEEL_SWORD = ITEM_REGISTRY
.registerItem("dark_steel_sword", DarkSteelSwordItem::new, new Item.Properties().durability(2000))
.setTab(EIOCreativeTabs.GEAR)
.setTranslation("The Ender")
.setModelProvider((prov, ctx) -> prov.handheld(ctx.get()));
public static final DeferredItem<DarkSteelSwordItem> DARK_STEEL_SWORD = ITEMS
.create("dark_steel_sword", DarkSteelSwordItem::new, new Item.Properties().durability(2000))
.tab(EIOCreativeTabs.GEAR)
.translation("The Ender")
.model((prov, ctx) -> prov.handheld(ctx.get()))
.finish();

// TODO: Bring these back when they are finished.
// public static final ItemEntry<DarkSteelPickaxeItem> DARK_STEEL_PICKAXE = REGISTRATE
Expand Down Expand Up @@ -134,7 +134,6 @@ public class ArmoryItems {
// .lang("Explosive Penetration II" + UPGRADE_TEXT)
// .register();

public static void register(IEventBus bus) {
ITEM_REGISTRY.register(bus);
public static void register() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public class ArmoryLang {
// endregion

private static MutableComponent addTranslation(String prefix, ResourceLocation id, String translation) {
return EnderIOArmory.REGILITE.addTranslation(prefix, id, translation);
return EnderIOArmory.REGILITE.lang().add(prefix, id, translation);
}

private static MutableComponent addTranslation(String prefix, ResourceLocation path, String name, String translation) {
return EnderIOArmory.REGILITE.addTranslation(prefix, ResourceLocation.fromNamespaceAndPath(path.getNamespace(), path.getPath() + "/" + name), translation);
return EnderIOArmory.REGILITE.lang().add(prefix, ResourceLocation.fromNamespaceAndPath(path.getNamespace(), path.getPath() + "/" + name), translation);
}

public static void register() {}
Expand Down
4 changes: 2 additions & 2 deletions enderio-base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ val jeiMinecraftVersion: String by project
val jeiVersion: String by project

dependencies {
api("com.enderio:Regilite:$regiliteVersion")
api("com.enderio:regilite:$regiliteVersion")

// EnderIO Base will bundle Regilite and EnderCore in production.
jarJar("com.enderio:Regilite:$regiliteVersion")
jarJar("com.enderio:regilite:$regiliteVersion")
jarJar(project(":endercore"))

// JEI
Expand Down
14 changes: 7 additions & 7 deletions enderio-base/src/main/java/com/enderio/EnderIOBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,21 @@ public EnderIOBase(IEventBus modEventBus, ModContainer modContainer) {
BaseConfigLang.register();

// Perform initialization and registration for everything so things are registered.
EIODataComponents.register(modEventBus);
EIODataComponents.register();
EIOCreativeTabs.register(modEventBus);
EIOItems.register(modEventBus);
EIOBlocks.register(modEventBus);
EIOBlockEntities.register(modEventBus);
EIOFluids.register(modEventBus);
EIOItems.register();
EIOBlocks.register();
EIOBlockEntities.register();
EIOFluids.register();
//EIOEnchantments.register(modEventBus);
EIOTags.register();
EIOMenus.register(modEventBus);
EIOMenus.register();
EIOLang.register();
EIOEnumLang.register();
EIORecipes.register(modEventBus);
EIOLootModifiers.register(modEventBus);
EIOParticles.register(modEventBus);
EIOEntities.register(modEventBus);
EIOEntities.register();
EIOAttachments.register(modEventBus);
EIOCriterions.register(modEventBus);
REGILITE.register(modEventBus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
import com.enderio.EnderIOBase;
import com.enderio.base.common.init.EIOCreativeTabs;
import com.enderio.base.common.tag.EIOTags;
import com.enderio.regilite.holder.RegiliteBlock;
import com.enderio.regilite.registry.BlockRegistry;
import com.enderio.regilite.registry.ItemRegistry;
import com.enderio.regilite.Regilite;
import com.google.common.collect.ImmutableMap;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.registries.DeferredBlock;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -24,28 +24,28 @@
* Container helper for the fused glass/quartz blocks as theres a lot, and this will tidy stuff up.
*/
public class GlassBlocks {
public final RegiliteBlock<FusedQuartzBlock> CLEAR;
public final Map<DyeColor, RegiliteBlock<FusedQuartzBlock>> COLORS;
public final DeferredBlock<FusedQuartzBlock> CLEAR;
public final Map<DyeColor, DeferredBlock<FusedQuartzBlock>> COLORS;

private final GlassIdentifier glassIdentifier;

/**
* Create the entire color family for this configuration of fused glass.
*/
public GlassBlocks(BlockRegistry blockRegistry, ItemRegistry itemRegistry, GlassIdentifier identifier) {
public GlassBlocks(Regilite regilite, GlassIdentifier identifier) {
glassIdentifier = identifier;
String name = identifier.glassName();
CLEAR = register(blockRegistry, itemRegistry, name);
Map<DyeColor, RegiliteBlock<FusedQuartzBlock>> tempMap = new HashMap<>();
CLEAR = register(regilite, name);
Map<DyeColor, DeferredBlock<FusedQuartzBlock>> tempMap = new HashMap<>();
for (DyeColor color: DyeColor.values()) {
tempMap.put(color,
register(blockRegistry, itemRegistry, name.concat("_").concat(color.getName()), color)
register(regilite, name.concat("_").concat(color.getName()), color)
);
}
COLORS = ImmutableMap.copyOf(tempMap);
}

public Stream<RegiliteBlock<FusedQuartzBlock>> getAllBlocks() {
public Stream<DeferredBlock<FusedQuartzBlock>> getAllBlocks() {
return Stream.concat(Stream.of(CLEAR), COLORS.values().stream());
}

Expand All @@ -65,9 +65,9 @@ private static boolean never(BlockState p_50779_, BlockGetter p_50780_, BlockPos
/**
* Register a non-colored glass
*/
private RegiliteBlock<FusedQuartzBlock> register(BlockRegistry blockRegistry, ItemRegistry itemRegistry, String name) {
var block = blockRegistry
.registerBlock(name,
private DeferredBlock<FusedQuartzBlock> register(Regilite regilite, String name) {
var block = regilite.blocks()
.create(name,
p -> new FusedQuartzBlock(p, glassIdentifier, null),
BlockBehaviour.Properties.of()
.noOcclusion()
Expand All @@ -78,38 +78,36 @@ private RegiliteBlock<FusedQuartzBlock> register(BlockRegistry blockRegistry, It
.isRedstoneConductor(GlassBlocks::never)
.isSuffocating(GlassBlocks::never)
.isViewBlocking(GlassBlocks::never))
.setTranslation("")
.setBlockStateProvider((cons, ctx) -> cons.simpleBlock(ctx.get(), cons.models().getExistingFile(getModelFile())))
.addBlockTags(
glassIdentifier.explosion_resistance() ? EIOTags.Blocks.FUSED_QUARTZ : EIOTags.Blocks.CLEAR_GLASS
);
.translation("")
.blockState((cons, ctx) -> cons.simpleBlock(ctx.get(), cons.models().getExistingFile(getModelFile())))
.tag(glassIdentifier.explosion_resistance() ? EIOTags.Blocks.FUSED_QUARTZ : EIOTags.Blocks.CLEAR_GLASS);

block.createBlockItem(itemRegistry, item -> {
item.setTab(EIOCreativeTabs.BLOCKS)
.addItemTags(
block.createSimpleBlockItem(item -> {
item.tab(EIOCreativeTabs.BLOCKS)
.tags(
glassIdentifier.explosion_resistance() ? EIOTags.Items.FUSED_QUARTZ : EIOTags.Items.CLEAR_GLASS,
EIOTags.Items.GLASS_TAGS.get(glassIdentifier)
)
.setModelProvider((prov, ctx) -> prov.withExistingParent(ctx.getName(), getModelFile()));
.model((prov, ctx) -> prov.withExistingParent(ctx.getName(), getModelFile()));

if (glassIdentifier.lighting() == GlassLighting.EMITTING && glassIdentifier.explosion_resistance()) {
item.addItemTags(EIOTags.Items.ENLIGHTENED_FUSED_QUARTZ);
item.tag(EIOTags.Items.ENLIGHTENED_FUSED_QUARTZ);
}

if (glassIdentifier.lighting() == GlassLighting.BLOCKING && glassIdentifier.explosion_resistance()) {
item.addItemTags(EIOTags.Items.DARK_FUSED_QUARTZ);
item.tag(EIOTags.Items.DARK_FUSED_QUARTZ);
}
});

return block;
return block.finish();
}

/**
* Register a colored glass.
*/
private RegiliteBlock<FusedQuartzBlock> register(BlockRegistry blockRegistry, ItemRegistry itemRegistry, String name, DyeColor color) {
var block = blockRegistry
.registerBlock(name,
private DeferredBlock<FusedQuartzBlock> register(Regilite regilite, String name, DyeColor color) {
var block = regilite.blocks()
.create(name,
p -> new FusedQuartzBlock(p, glassIdentifier, color),
BlockBehaviour.Properties.of()
.noOcclusion()
Expand All @@ -121,32 +119,30 @@ private RegiliteBlock<FusedQuartzBlock> register(BlockRegistry blockRegistry, It
.isSuffocating(GlassBlocks::never)
.isViewBlocking(GlassBlocks::never)
.mapColor(color))
.setTranslation("")
.setBlockStateProvider((prov, ctx) -> prov.simpleBlock(ctx.get(), prov.models().getExistingFile(getModelFile())))
.setColorSupplier(() -> () -> (state, level, pos, tintIndex) -> color.getMapColor().col)
.addBlockTags(
glassIdentifier.explosion_resistance() ? EIOTags.Blocks.FUSED_QUARTZ : EIOTags.Blocks.CLEAR_GLASS
);

block.createBlockItem(itemRegistry, item -> {
item.setTab(EIOCreativeTabs.BLOCKS)
.setColorSupplier(() -> () -> (stack, tintIndex) -> color.getMapColor().col)
.addItemTags(
.translation("")
.blockState((prov, ctx) -> prov.simpleBlock(ctx.get(), prov.models().getExistingFile(getModelFile())))
.blockColor(() -> () -> (state, level, pos, tintIndex) -> color.getMapColor().col)
.tag(glassIdentifier.explosion_resistance() ? EIOTags.Blocks.FUSED_QUARTZ : EIOTags.Blocks.CLEAR_GLASS);

block.createSimpleBlockItem(item -> {
item.tab(EIOCreativeTabs.BLOCKS)
.itemColor(() -> () -> (stack, tintIndex) -> color.getMapColor().col)
.tags(
glassIdentifier.explosion_resistance() ? EIOTags.Items.FUSED_QUARTZ : EIOTags.Items.CLEAR_GLASS,
EIOTags.Items.GLASS_TAGS.get(glassIdentifier)
)
.setModelProvider((prov, ctx) -> prov.withExistingParent(ctx.getName(), getModelFile()));
.model((prov, ctx) -> prov.withExistingParent(ctx.getName(), getModelFile()));

if (glassIdentifier.lighting() == GlassLighting.EMITTING && glassIdentifier.explosion_resistance()) {
item.addItemTags(EIOTags.Items.ENLIGHTENED_FUSED_QUARTZ);
item.tag(EIOTags.Items.ENLIGHTENED_FUSED_QUARTZ);
}

if (glassIdentifier.lighting() == GlassLighting.BLOCKING && glassIdentifier.explosion_resistance()) {
item.addItemTags(EIOTags.Items.DARK_FUSED_QUARTZ);
item.tag(EIOTags.Items.DARK_FUSED_QUARTZ);
}
});

return block;
return block.finish();
}

public GlassIdentifier getGlassIdentifier() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public static void register() {
}

private static void addTranslation(String key, String translation) {
// TODO: More translation options in Regilite
EnderIOBase.REGILITE.addTranslation(() -> EnderIOBase.MODULE_MOD_ID + "." + "configuration" + "." + key, translation);
EnderIOBase.REGILITE.lang().add(EnderIOBase.MODULE_MOD_ID + "." + "configuration" + "." + key, translation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import com.enderio.base.common.blockentity.PoweredLightBlockEntity;
import com.enderio.base.common.paint.blockentity.DoublePaintedBlockEntity;
import com.enderio.base.common.paint.blockentity.SinglePaintedBlockEntity;
import com.enderio.regilite.holder.RegiliteBlockEntity;
import com.enderio.regilite.registry.BlockEntityRegistry;
import net.neoforged.bus.api.IEventBus;
import com.enderio.regilite.blockentities.DeferredBlockEntityType;
import com.enderio.regilite.blockentities.RegiliteBlockEntityTypes;

public class EIOBlockEntities {
private static final BlockEntityRegistry BLOCK_ENTITY_REGISTRY = EnderIOBase.REGILITE.blockEntityRegistry();
private static final RegiliteBlockEntityTypes BLOCK_ENTITY_TYPES = EnderIOBase.REGILITE.blockEntityTypes();

public static final RegiliteBlockEntity<SinglePaintedBlockEntity> SINGLE_PAINTED = BLOCK_ENTITY_REGISTRY
.registerBlockEntity("single_painted",
public static final DeferredBlockEntityType<SinglePaintedBlockEntity> SINGLE_PAINTED = BLOCK_ENTITY_TYPES
.create("single_painted",
SinglePaintedBlockEntity::new,
EIOBlocks.PAINTED_FENCE,
EIOBlocks.PAINTED_FENCE_GATE,
Expand All @@ -25,26 +24,26 @@ public class EIOBlockEntities {
EIOBlocks.PAINTED_TRAPDOOR,
EIOBlocks.PAINTED_WOODEN_PRESSURE_PLATE,
EIOBlocks.PAINTED_GLOWSTONE,
EIOBlocks.PAINTED_WALL);
EIOBlocks.PAINTED_WALL).finish();

public static final RegiliteBlockEntity<DoublePaintedBlockEntity> DOUBLE_PAINTED = BLOCK_ENTITY_REGISTRY
.registerBlockEntity("double_painted", DoublePaintedBlockEntity::new, EIOBlocks.PAINTED_SLAB);
public static final DeferredBlockEntityType<DoublePaintedBlockEntity> DOUBLE_PAINTED = BLOCK_ENTITY_TYPES
.create("double_painted", DoublePaintedBlockEntity::new, EIOBlocks.PAINTED_SLAB).finish();

public static final RegiliteBlockEntity<PoweredLightBlockEntity> POWERED_LIGHT = BLOCK_ENTITY_REGISTRY
.registerBlockEntity("powered_light",
public static final DeferredBlockEntityType<PoweredLightBlockEntity> POWERED_LIGHT = BLOCK_ENTITY_TYPES
.create("powered_light",
PoweredLightBlockEntity::new,
EIOBlocks.POWERED_LIGHT,
EIOBlocks.POWERED_LIGHT_INVERTED,
EIOBlocks.POWERED_LIGHT_WIRELESS,
EIOBlocks.POWERED_LIGHT_INVERTED_WIRELESS);
EIOBlocks.POWERED_LIGHT_INVERTED_WIRELESS)
.finish();

public static final RegiliteBlockEntity<LightNodeBlockEntity> LIGHT_NODE = BLOCK_ENTITY_REGISTRY
.registerBlockEntity("light_node", LightNodeBlockEntity::new, EIOBlocks.LIGHT_NODE);
public static final DeferredBlockEntityType<LightNodeBlockEntity> LIGHT_NODE = BLOCK_ENTITY_TYPES
.create("light_node", LightNodeBlockEntity::new, EIOBlocks.LIGHT_NODE).finish();

public static final RegiliteBlockEntity<EnderSkullBlockEntity> ENDER_SKULL = BLOCK_ENTITY_REGISTRY
.registerBlockEntity("ender_skull", EnderSkullBlockEntity::new, EIOBlocks.WALL_ENDERMAN_HEAD, EIOBlocks.ENDERMAN_HEAD);
public static final DeferredBlockEntityType<EnderSkullBlockEntity> ENDER_SKULL = BLOCK_ENTITY_TYPES
.create("ender_skull", EnderSkullBlockEntity::new, EIOBlocks.WALL_ENDERMAN_HEAD, EIOBlocks.ENDERMAN_HEAD).finish();

public static void register(IEventBus eventBus) {
BLOCK_ENTITY_REGISTRY.register(eventBus);
public static void register() {
}
}
Loading