From d9d5616469224ce2dca4a7378dac92f5dde43d67 Mon Sep 17 00:00:00 2001 From: Darkere Date: Sun, 30 Aug 2020 19:48:49 +0200 Subject: [PATCH] Allow addons to extend GridBlock (#2666) * create GridBlocks with static initializer * Make constructor take RL instead. --- .../com/refinedmods/refinedstorage/block/GridBlock.java | 6 +++--- .../refinedmods/refinedstorage/setup/CommonSetup.java | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/refinedmods/refinedstorage/block/GridBlock.java b/src/main/java/com/refinedmods/refinedstorage/block/GridBlock.java index d51b50808..450581b09 100644 --- a/src/main/java/com/refinedmods/refinedstorage/block/GridBlock.java +++ b/src/main/java/com/refinedmods/refinedstorage/block/GridBlock.java @@ -13,6 +13,7 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.IBlockReader; @@ -23,12 +24,11 @@ import javax.annotation.Nullable; public class GridBlock extends NetworkNodeBlock { private final GridType type; - public GridBlock(GridType type) { + public GridBlock(GridType type, ResourceLocation registryName) { super(BlockUtils.DEFAULT_ROCK_PROPERTIES); this.type = type; - - this.setRegistryName(RS.ID, type == GridType.NORMAL ? "grid" : type.getString() + "_grid"); + setRegistryName(registryName); } @Override diff --git a/src/main/java/com/refinedmods/refinedstorage/setup/CommonSetup.java b/src/main/java/com/refinedmods/refinedstorage/setup/CommonSetup.java index 7c2a42d43..fba0fdbb2 100644 --- a/src/main/java/com/refinedmods/refinedstorage/setup/CommonSetup.java +++ b/src/main/java/com/refinedmods/refinedstorage/setup/CommonSetup.java @@ -51,6 +51,7 @@ import net.minecraft.item.crafting.IRecipeSerializer; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.extensions.IForgeContainerType; import net.minecraftforge.event.RegistryEvent; @@ -158,10 +159,10 @@ public class CommonSetup { e.getRegistry().register(new MachineCasingBlock()); e.getRegistry().register(new CableBlock()); e.getRegistry().register(new DiskDriveBlock()); - e.getRegistry().register(new GridBlock(GridType.NORMAL)); - e.getRegistry().register(new GridBlock(GridType.CRAFTING)); - e.getRegistry().register(new GridBlock(GridType.PATTERN)); - e.getRegistry().register(new GridBlock(GridType.FLUID)); + e.getRegistry().register(new GridBlock(GridType.NORMAL, new ResourceLocation(RS.ID, "grid"))); + e.getRegistry().register(new GridBlock(GridType.CRAFTING, new ResourceLocation(RS.ID, GridType.CRAFTING.getString() + "_grid"))); + e.getRegistry().register(new GridBlock(GridType.PATTERN, new ResourceLocation(RS.ID, GridType.PATTERN.getString() + "_grid"))); + e.getRegistry().register(new GridBlock(GridType.FLUID, new ResourceLocation(RS.ID, GridType.FLUID.getString() + "_grid"))); for (ItemStorageType type : ItemStorageType.values()) { e.getRegistry().register(new StorageBlock(type));