Skip to content

Commit

Permalink
Migrated rest to RegistryObject
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Mar 7, 2022
1 parent cd01246 commit 2967105
Show file tree
Hide file tree
Showing 134 changed files with 750 additions and 844 deletions.
31 changes: 25 additions & 6 deletions src/main/java/com/teammetallurgy/atum/Atum.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
import com.teammetallurgy.atum.commands.AtumWeather;
import com.teammetallurgy.atum.entity.ai.brain.sensor.AtumSensorTypes;
import com.teammetallurgy.atum.entity.villager.AtumVillagerProfession;
import com.teammetallurgy.atum.init.AtumBlocks;
import com.teammetallurgy.atum.init.AtumEntities;
import com.teammetallurgy.atum.init.AtumItems;
import com.teammetallurgy.atum.init.AtumTileEntities;
import com.teammetallurgy.atum.init.*;
import com.teammetallurgy.atum.integration.IntegrationHandler;
import com.teammetallurgy.atum.misc.AtumConfig;
import com.teammetallurgy.atum.misc.AtumItemGroup;
import com.teammetallurgy.atum.misc.AtumRegistry;
import com.teammetallurgy.atum.misc.datagenerator.BlockStatesGenerator;
import com.teammetallurgy.atum.misc.datagenerator.RecipeGenerator;
import com.teammetallurgy.atum.network.NetworkHandler;
import com.teammetallurgy.atum.world.SandstormHandler;
import com.teammetallurgy.atum.world.biome.AtumBiomeSource;
import net.minecraft.core.Registry;
import net.minecraft.data.DataGenerator;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
Expand All @@ -36,6 +35,7 @@
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.forge.event.lifecycle.GatherDataEvent;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -48,7 +48,7 @@ public class Atum {
public static final Logger LOG = LogManager.getLogger(StringUtils.capitalize(MOD_ID));
public static final CreativeModeTab GROUP = new AtumItemGroup();
public static final ResourceKey<Level> ATUM = ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(MOD_ID, "atum"));
public static final Codec<AtumBiomeSource> ATUM_MULTI_NOISE = Registry.register(Registry.BIOME_SOURCE, new ResourceLocation(MOD_ID, "atum_multi_noise"), AtumBiomeSource.CODEC);
public static Codec<AtumBiomeSource> ATUM_MULTI_NOISE;
public static final WoodType PALM = WoodType.create("atum_palm");
public static final WoodType DEADWOOD = WoodType.create("atum_deadwood");

Expand All @@ -57,6 +57,7 @@ public Atum() {
modBus.addListener(this::setupCommon);
modBus.addListener(this::setupClient);
modBus.addListener(this::interModComms);
modBus.addListener(this::gatherDataEvent);
registerDeferredRegistries(modBus);
MinecraftForge.EVENT_BUS.addListener(this::onCommandRegistering);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, AtumConfig.spec);
Expand All @@ -65,7 +66,10 @@ public Atum() {
}

private void setupCommon(FMLCommonSetupEvent event) {
ATUM_MULTI_NOISE = Registry.register(Registry.BIOME_SOURCE, new ResourceLocation(MOD_ID, "atum_multi_noise"), AtumBiomeSource.CODEC);
IntegrationHandler.INSTANCE.init();
event.enqueueWork(AtumBlocks::setBlockInfo);
event.enqueueWork(AtumItems::setItemInfo);
event.enqueueWork(() -> WoodType.register(PALM));
event.enqueueWork(() -> WoodType.register(DEADWOOD));
if (AtumConfig.SANDSTORM.sandstormEnabled.get()) {
Expand Down Expand Up @@ -94,11 +98,26 @@ private void interModComms(InterModEnqueueEvent event) {
InterModComms.sendTo("curios", SlotTypeMessage.REGISTER_TYPE, () -> SlotTypePreset.BRACELET.getMessageBuilder().build());
}

public void gatherDataEvent(GatherDataEvent event) {
DataGenerator gen = event.getGenerator();

if (event.includeClient()) {
gen.addProvider(new BlockStatesGenerator(gen, event.getExistingFileHelper()));
}

if (event.includeServer()) {
gen.addProvider(new RecipeGenerator(gen));
}
}

public static void registerDeferredRegistries(IEventBus modBus) {
AtumBlocks.BLOCK_DEFERRED.register(modBus);
AtumItems.ITEM_DEFERRED.register(modBus);
AtumEntities.ENTITY_DEFERRED.register(modBus);
AtumTileEntities.BLOCK_ENTITY_DEFERRED.register(modBus);
AtumMenuType.MENU_TYPE_DEFERRED.register(modBus);
AtumPointsOfInterest.POI_DEFERRED.register(modBus);
AtumSounds.SOUND_DEFERRED.register(modBus);
AtumVillagerProfession.ATUM_PROFESSION_DEFERRED.register(modBus);
AtumSensorTypes.SENSOR_TYPE_DEFERRED.register(modBus);
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/teammetallurgy/atum/api/AtumMats.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public SoundEvent getEquipSound() {
@Override
@Nonnull
public Ingredient getRepairIngredient() {
return Ingredient.of(AtumItems.SCRAP);
return Ingredient.of(AtumItems.SCRAP.get());
}

@Override
Expand Down Expand Up @@ -92,7 +92,7 @@ public SoundEvent getEquipSound() {
@Override
@Nonnull
public Ingredient getRepairIngredient() {
return Ingredient.of(AtumItems.LINEN_CLOTH);
return Ingredient.of(AtumItems.LINEN_CLOTH.get());
}

@Override
Expand Down Expand Up @@ -140,7 +140,7 @@ public int getEnchantmentValue() {
@Override
@Nonnull
public Ingredient getRepairIngredient() {
return Ingredient.of(AtumItems.KHNUMITE);
return Ingredient.of(AtumItems.KHNUMITE.get());
}
};
public static final Tier LIMESTONE = new Tier() {
Expand Down Expand Up @@ -172,7 +172,7 @@ public int getEnchantmentValue() {
@Override
@Nonnull
public Ingredient getRepairIngredient() {
return Ingredient.of(AtumBlocks.LIMESTONE_CRACKED);
return Ingredient.of(AtumBlocks.LIMESTONE_CRACKED.get());
}
};
public static final Tier NEBU = new Tier() {
Expand Down Expand Up @@ -204,7 +204,7 @@ public int getEnchantmentValue() {
@Override
@Nonnull
public Ingredient getRepairIngredient() {
return Ingredient.of(AtumItems.NEBU_INGOT);
return Ingredient.of(AtumItems.NEBU_INGOT.get());
}
};
public static final ArmorMaterial NEBU_ARMOR = new ArmorMaterial() {
Expand Down Expand Up @@ -236,7 +236,7 @@ public SoundEvent getEquipSound() {
@Override
@Nonnull
public Ingredient getRepairIngredient() {
return Ingredient.of(AtumItems.NEBU_INGOT);
return Ingredient.of(AtumItems.NEBU_INGOT.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public int getCookTime() {
@Override
@Nonnull
public RecipeSerializer<?> getSerializer() {
return AtumRecipeSerializers.KILN;
return AtumRecipeSerializers.KILN.get();
}

public static class Serializer<T extends KilnRecipe> extends ForgeRegistryEntry<RecipeSerializer<?>> implements RecipeSerializer<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public QuernRecipe(ResourceLocation id, Ingredient input, @Nonnull ItemStack out
@Override
@Nonnull
public RecipeSerializer<?> getSerializer() {
return AtumRecipeSerializers.QUERN;
return AtumRecipeSerializers.QUERN.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public SpinningWheelRecipe(ResourceLocation id, Ingredient input, @Nonnull ItemS
@Override
@Nonnull
public RecipeSerializer<?> getSerializer() {
return AtumRecipeSerializers.SPINNING_WHEEL;
return AtumRecipeSerializers.SPINNING_WHEEL.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ boolean isValid() {

void placePortalBlocks() {
for (BlockPos portalPos : BlockPos.MutableBlockPos.betweenClosed(nw, se)) {
this.world.setBlock(portalPos, AtumBlocks.PORTAL.defaultBlockState(), 2);
this.world.setBlock(portalPos, AtumBlocks.PORTAL.get().defaultBlockState(), 2);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public static void attemptMakeDoor(Level world, BlockPos pos, Direction facing,
BlockState offsetLeft = world.getBlockState(pos.relative(facing.getClockWise(), 3));
BlockState offsetRight = world.getBlockState(pos.relative(facing.getCounterClockWise(), 3));

if ((offsetLeft.getBlock() == AtumBlocks.QUANDARY_BLOCK && offsetLeft.getValue(ACTIVATED)) || (offsetRight.getBlock() == AtumBlocks.QUANDARY_BLOCK && offsetRight.getValue(ACTIVATED))) {
if ((offsetLeft.getBlock() == AtumBlocks.QUANDARY_BLOCK.get() && offsetLeft.getValue(ACTIVATED)) || (offsetRight.getBlock() == AtumBlocks.QUANDARY_BLOCK.get() && offsetRight.getValue(ACTIVATED))) {
boolean isPrimary = false;
if (offsetRight.getBlock() == AtumBlocks.QUANDARY_BLOCK) {
if (offsetRight.getBlock() == AtumBlocks.QUANDARY_BLOCK.get()) {
isPrimary = true;
}

Expand All @@ -127,10 +127,10 @@ public static void attemptMakeDoor(Level world, BlockPos pos, Direction facing,
if (doorRead != null) {
door = (DoorBlock) doorRead;
} else {
door = (DoorBlock) AtumBlocks.LIMESTONE_DOOR;
door = (DoorBlock) AtumBlocks.LIMESTONE_DOOR.get();
}
} else {
door = (DoorBlock) AtumBlocks.LIMESTONE_DOOR;
door = (DoorBlock) AtumBlocks.LIMESTONE_DOOR.get();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public BlockState getStateForPlacement(BlockPlaceContext context) {
BlockState state = context.getLevel().getBlockState(context.getClickedPos());
if (state.getBlock() == this) {
int layer = state.getValue(LAYERS);
return layer == 7 ? AtumBlocks.SAND.defaultBlockState() : state.setValue(LAYERS, Math.min(7, layer + 1));
return layer == 7 ? AtumBlocks.SAND.get().defaultBlockState() : state.setValue(LAYERS, Math.min(7, layer + 1));
} else {
return super.getStateForPlacement(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public boolean canSustainPlant(@Nonnull BlockState state, @Nonnull BlockGetter w
world.getBlockState(pos.north()).getFluidState().is(FluidTags.WATER) ||
world.getBlockState(pos.south()).getFluidState().is(FluidTags.WATER));

if (plant.getBlock() instanceof CactusBlock || plant.getBlock() == AtumBlocks.ANPUTS_FINGERS) {
if (plant.getBlock() instanceof CactusBlock || plant.getBlock() == AtumBlocks.ANPUTS_FINGERS.get()) {
return true;
}

Expand All @@ -51,6 +51,6 @@ public boolean canSustainPlant(@Nonnull BlockState state, @Nonnull BlockGetter w

@Override
public BlockState getToolModifiedState(BlockState state, Level world, BlockPos pos, Player player, ItemStack stack, ToolAction toolAction) {
return toolAction == ToolActions.SHOVEL_FLATTEN ? AtumBlocks.STRANGE_SAND_PATH.defaultBlockState() : super.getToolModifiedState(state, world, pos, player, stack, toolAction);
return toolAction == ToolActions.SHOVEL_FLATTEN ? AtumBlocks.STRANGE_SAND_PATH.get().defaultBlockState() : super.getToolModifiedState(state, world, pos, player, stack, toolAction);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected ChestBaseBlock(Supplier<BlockEntityType<? extends ChestBlockEntity>> t
@Override
@Nonnull
public ItemStack getCloneItemStack(@Nonnull BlockGetter getter, @Nonnull BlockPos pos, @Nonnull BlockState state) {
return new ItemStack(AtumBlocks.LIMESTONE_CHEST);
return new ItemStack(AtumBlocks.LIMESTONE_CHEST.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public AtumTorchBlock(int lightValue) {
}

public AtumTorchBlock(@Nullable God god) {
this(14, god == null ? AtumParticles.NEBU_FLAME : GOD_FLAMES.get(god));
this(14, god == null ? AtumParticles.NEBU_FLAME.get() : GOD_FLAMES.get(god));
}

public ParticleOptions getParticleType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void onRemove(BlockState state, @Nonnull Level world, @Nonnull BlockPos p
} else {
BlockPos primaryPos = pos.relative(state.getValue(FACING).getCounterClockWise());
BlockState primaryState = world.getBlockState(primaryPos);
if (primaryState.getBlock() == AtumBlocks.KILN && primaryState.getValue(MULTIBLOCK_PRIMARY)) {
if (primaryState.getBlock() == AtumBlocks.KILN.get() && primaryState.getValue(MULTIBLOCK_PRIMARY)) {
this.destroyMultiblock(world, primaryPos, primaryState.getValue(FACING));
}
}
Expand Down Expand Up @@ -102,7 +102,7 @@ public static BlockPos getSecondaryKilnFromPrimary(Level world, BlockPos pos) {
BlockState state = world.getBlockState(pos);
BlockEntity tileEntity = world.getBlockEntity(pos);
if (tileEntity instanceof KilnTileEntity) {
if (state.getBlock() == AtumBlocks.KILN && ((KilnTileEntity) tileEntity).isPrimary()) {
if (state.getBlock() == AtumBlocks.KILN.get() && ((KilnTileEntity) tileEntity).isPrimary()) {
return pos.relative(state.getValue(FACING).getClockWise());
}
}
Expand All @@ -112,11 +112,11 @@ public static BlockPos getSecondaryKilnFromPrimary(Level world, BlockPos pos) {
private BlockPos getPrimaryKilnBlock(Level world, BlockPos pos) {
if (world != null && !world.isEmptyBlock(pos)) {
BlockState state = world.getBlockState(pos);
if (state.getBlock() == AtumBlocks.KILN && state.getValue(MULTIBLOCK_PRIMARY)) {
if (state.getBlock() == AtumBlocks.KILN.get() && state.getValue(MULTIBLOCK_PRIMARY)) {
return pos;
} else {
state = world.getBlockState(pos.relative(state.getValue(FACING).getCounterClockWise()));
if (state.getBlock() == AtumBlocks.KILN && state.getValue(MULTIBLOCK_PRIMARY)) {
if (state.getBlock() == AtumBlocks.KILN.get() && state.getValue(MULTIBLOCK_PRIMARY)) {
return pos.relative(state.getValue(FACING).getCounterClockWise());
}
}
Expand All @@ -127,7 +127,7 @@ private BlockPos getPrimaryKilnBlock(Level world, BlockPos pos) {
private void createMultiblock(Level world, BlockPos primaryPos) {
List<BlockPos> brickPositions = getKilnBrickPositions(primaryPos, world.getBlockState(primaryPos).getValue(FACING));
for (BlockPos brickPos : brickPositions) {
world.setBlockAndUpdate(brickPos, AtumBlocks.KILN_FAKE.defaultBlockState().setValue(KilnFakeBlock.UP, primaryPos.getY() - 1 == brickPos.getY()));
world.setBlockAndUpdate(brickPos, AtumBlocks.KILN_FAKE.get().defaultBlockState().setValue(KilnFakeBlock.UP, primaryPos.getY() - 1 == brickPos.getY()));
BlockEntity tileEntity = world.getBlockEntity(brickPos);
if (tileEntity != null) {
((KilnBaseTileEntity) tileEntity).setPrimaryPos(primaryPos);
Expand Down Expand Up @@ -155,49 +155,47 @@ void destroyMultiblock(Level world, BlockPos primaryPos, Direction facing) {
BlockState secondaryState = world.getBlockState(secondaryPos);
BlockPos dropPos = primaryPos;

if (primaryState.getBlock() == AtumBlocks.KILN) {
if (primaryState.getBlock() == AtumBlocks.KILN.get()) {
world.setBlockAndUpdate(primaryPos, primaryState.setValue(MULTIBLOCK_PRIMARY, false).setValue(LIT, false));
}
if (secondaryState.getBlock() == AtumBlocks.KILN) {
if (secondaryState.getBlock() == AtumBlocks.KILN.get()) {
world.setBlockAndUpdate(secondaryPos, secondaryState.setValue(LIT, false));
} else {
dropPos = secondaryPos;
}
for (BlockPos brickPos : brickPositions) {
if (world.getBlockState(brickPos).getBlock() == AtumBlocks.KILN_FAKE) {
if (world.getBlockState(brickPos).getBlock() == AtumBlocks.KILN_FAKE.get()) {
world.removeBlockEntity(brickPos);
world.setBlockAndUpdate(brickPos, AtumBlocks.LIMESTONE_BRICK_SMALL.defaultBlockState());
world.setBlockAndUpdate(brickPos, AtumBlocks.LIMESTONE_BRICK_SMALL.get().defaultBlockState());
} else {
dropPos = brickPos;
}
}

BlockEntity tileEntity = world.getBlockEntity(primaryPos);
if (tileEntity instanceof KilnBaseTileEntity) {
KilnBaseTileEntity kilnBase = (KilnBaseTileEntity) tileEntity;
if (tileEntity instanceof KilnBaseTileEntity kilnBase) {
kilnBase.setPrimaryPos(null);
Containers.dropContents(world, dropPos, kilnBase);
kilnBase.setRemoved();
}

tileEntity = world.getBlockEntity(secondaryPos);
if (tileEntity instanceof KilnBaseTileEntity) {
KilnBaseTileEntity kilnBase = (KilnBaseTileEntity) tileEntity;
if (tileEntity instanceof KilnBaseTileEntity kilnBase) {
kilnBase.setPrimaryPos(null);
}
}

private boolean checkMultiblock(Level world, BlockPos primaryPos, Direction facing) {
List<BlockPos> brickPositions = getKilnBrickPositions(primaryPos, facing);
if (world.getBlockState(primaryPos).getBlock() != AtumBlocks.KILN) {
if (world.getBlockState(primaryPos).getBlock() != AtumBlocks.KILN.get()) {
return false;
}
if (world.getBlockState(primaryPos.relative(facing.getClockWise())).getBlock() != AtumBlocks.KILN) {
if (world.getBlockState(primaryPos.relative(facing.getClockWise())).getBlock() != AtumBlocks.KILN.get()) {
return false;
}
for (BlockPos brickPos : brickPositions) {
BlockState brickState = world.getBlockState(brickPos);
if (brickState.getBlock() != AtumBlocks.LIMESTONE_BRICK_SMALL) {
if (brickState.getBlock() != AtumBlocks.LIMESTONE_BRICK_SMALL.get()) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public void onRemove(@Nonnull BlockState state, @Nonnull Level world, @Nonnull B
BlockPos primaryPos = this.getPrimaryKilnBlock(world, pos);
if (primaryPos != null) {
BlockState primaryState = world.getBlockState(primaryPos);
if (primaryState.getBlock() == AtumBlocks.KILN && primaryState.getValue(KilnBlock.MULTIBLOCK_PRIMARY)) {
((KilnBlock) AtumBlocks.KILN).destroyMultiblock(world, primaryPos, primaryState.getValue(KilnBlock.FACING));
if (primaryState.getBlock() == AtumBlocks.KILN.get() && primaryState.getValue(KilnBlock.MULTIBLOCK_PRIMARY)) {
((KilnBlock) AtumBlocks.KILN.get()).destroyMultiblock(world, primaryPos, primaryState.getValue(KilnBlock.FACING));
}
}
super.onRemove(state, world, pos, newState, isMoving);
Expand All @@ -80,7 +80,7 @@ private BlockPos getPrimaryKilnBlock(Level world, BlockPos pos) {
@Override
@Nonnull
public ItemStack getCloneItemStack(@Nonnull BlockGetter getter, @Nonnull BlockPos pos, @Nonnull BlockState state) {
return new ItemStack(AtumBlocks.KILN);
return new ItemStack(AtumBlocks.KILN.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void output(Level world, BlockPos pos, @Nullable Player player, SpinningW
@Override
@Nonnull
public ItemStack getCloneItemStack(@Nonnull BlockGetter getter, @Nonnull BlockPos pos, @Nonnull BlockState state) {
return new ItemStack(AtumBlocks.SPINNING_WHEEL);
return new ItemStack(AtumBlocks.SPINNING_WHEEL.get());
}

@Override
Expand Down

0 comments on commit 2967105

Please sign in to comment.