Skip to content

Commit

Permalink
Some cleanup as a result of most of the code becoming kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
quinn-semele committed Dec 24, 2024
1 parent f3d3071 commit 56bdabc
Show file tree
Hide file tree
Showing 15 changed files with 9 additions and 199 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,7 @@ private static void expandedstorage_bootstrap(CallbackInfo info) {
at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableMap;builder()Lcom/google/common/collect/ImmutableMap$Builder;")
)
private static void expandedstorage_createBlockRenderers(EntityModelSet entityModelSet, CallbackInfoReturnable<Map<Block, SpecialModelRenderer<?>>> cir, @Local Map<Block, SpecialModelRenderer.Unbaked> map) {
var blocks = List.of(
ModBlocks.WOODEN_CHEST,
ModBlocks.PUMPKIN_CHEST,
ModBlocks.PRESENT,
ModBlocks.BAMBOO_CHEST,
ModBlocks.MOSS_CHEST,
ModBlocks.COPPER_CHEST,
ModBlocks.TRIAL_CHEST,
ModBlocks.IRON_CHEST,
ModBlocks.GOLDEN_CHEST,
ModBlocks.DIAMOND_CHEST,
ModBlocks.OBSIDIAN_CHEST,
ModBlocks.METALLIC_OBSIDIAN_CHEST,
ModBlocks.NETHERITE_CHEST
);

for (ChestBlock block : blocks) {
for (ChestBlock block : ModBlocks.CHESTS) {
map.put(block, new ChestItemModelRenderer.Unbaked(ChestBlockRenderer.Companion.getChestMaterials().get(block)[EsChestType.SINGLE.ordinal()].texture(), 0.0F));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ open class AbstractChestBlock(properties: Properties, openingStat: ResourceLocat
Component.translatable("container.expandedstorage.generic_double", first.getName())
}

return OpenableInventories(name, first, second);
return OpenableInventories(name, first, second)
}

override fun get(single: DoubleBlockEntity): OpenableInventory = single
Expand Down Expand Up @@ -186,7 +186,7 @@ open class AbstractChestBlock(properties: Properties, openingStat: ResourceLocat
offsetState.`is`(this) && offsetState.getValue(HORIZONTAL_FACING) == chestForwardDir
&& offsetState.getValue(CURSED_CHEST_TYPE) == EsChestType.SINGLE
) {
val type = getChestType(chestForwardDir, direction);
val type = getChestType(chestForwardDir, direction)

if (type != EsChestType.SINGLE) {
if (areChestsCompatible(level, context.itemInHand, pos, pos.relative(direction))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ open class ChestBlock(properties: Properties, openingStat: ResourceLocation, slo
blockEntityType: BlockEntityType<T>
): BlockEntityTicker<T>? {
return if (level.isClientSide() && blockEntityType == this.getBlockEntityType()) {
BlockEntityTicker<T>(ChestBlockEntity.Companion::progressLidAnimation)
BlockEntityTicker<T>(ChestBlockEntity::progressLidAnimation)
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ class ChestBlockEntity(type: BlockEntityType<*>, pos: BlockPos, state: BlockStat
level.playSound(null, soundPos.x, soundPos.y, soundPos.z, sound, SoundSource.BLOCKS, 0.5F, level.random.nextFloat() * 0.1F + 0.9F)
}

@JvmStatic
fun progressLidAnimation(level: Level, pos: BlockPos, state: BlockState, entity: BlockEntity) {
(entity as ChestBlockEntity).lidController.tickLid()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ object CopperBlockHelper {
.put(ModBlocks.WAXED_OXIDIZED_COPPER_MINI_BARREL, ModBlocks.OXIDIZED_COPPER_MINI_BARREL)
.build()

@JvmStatic
fun getNextOxidisedState(state: BlockState): Optional<BlockState> {
return Optional.ofNullable(OXIDISATION_MAP[state.block]).map { block: Block ->
block.withPropertiesOf(state)
}
}

@JvmStatic
fun oxidisation(): BiMap<Block, Block> = OXIDISATION_MAP

@JvmStatic
fun dewaxing(): BiMap<Block, Block> = DEWAXED_MAP
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,14 @@ class ChestModel(model: ModelPart) : Model(model, RenderType::entitySolid) {
}

companion object {
@JvmField
val SINGLE_LAYER = ModelLayerLocation("single_chest".modId(), "main")
@JvmField
val LEFT_LAYER = ModelLayerLocation("left_chest".modId(), "main")
@JvmField
val RIGHT_LAYER = ModelLayerLocation("right_chest".modId(), "main")
@JvmField
val TOP_LAYER = ModelLayerLocation("top_chest".modId(), "main")
@JvmField
val BOTTOM_LAYER = ModelLayerLocation("bottom_chest".modId(), "main")
@JvmField
val FRONT_LAYER = ModelLayerLocation("front_chest".modId(), "main")
@JvmField
val BACK_LAYER = ModelLayerLocation("back_chest".modId(), "main")


@JvmStatic
fun createSingleLayer(): LayerDefinition {
val meshDefinition = MeshDefinition()

Expand All @@ -67,7 +58,6 @@ class ChestModel(model: ModelPart) : Model(model, RenderType::entitySolid) {
return LayerDefinition.create(meshDefinition, 64, 48)
}

@JvmStatic
fun createLeftLayer(): LayerDefinition {
val meshDefinition = MeshDefinition()

Expand All @@ -90,7 +80,6 @@ class ChestModel(model: ModelPart) : Model(model, RenderType::entitySolid) {
return LayerDefinition.create(meshDefinition, 64, 48)
}

@JvmStatic
fun createRightLayer(): LayerDefinition {
val meshDefinition = MeshDefinition()

Expand All @@ -113,7 +102,6 @@ class ChestModel(model: ModelPart) : Model(model, RenderType::entitySolid) {
return LayerDefinition.create(meshDefinition, 64, 48)
}

@JvmStatic
fun createTopLayer(): LayerDefinition {
val meshDefinition = MeshDefinition()

Expand All @@ -136,7 +124,6 @@ class ChestModel(model: ModelPart) : Model(model, RenderType::entitySolid) {
return LayerDefinition.create(meshDefinition, 64, 48)
}

@JvmStatic
fun createBottomLayer(): LayerDefinition {
val meshDefinition = MeshDefinition()

Expand All @@ -149,7 +136,6 @@ class ChestModel(model: ModelPart) : Model(model, RenderType::entitySolid) {
return LayerDefinition.create(meshDefinition, 64, 32)
}

@JvmStatic
fun createFrontLayer(): LayerDefinition {
val meshDefinition = MeshDefinition()

Expand All @@ -172,7 +158,6 @@ class ChestModel(model: ModelPart) : Model(model, RenderType::entitySolid) {
return LayerDefinition.create(meshDefinition, 64, 48)
}

@JvmStatic
fun createBackLayer(): LayerDefinition {
val meshDefinition = MeshDefinition()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import net.minecraft.world.item.ItemStack
class StorageMutatorItemModelProperty : SelectItemModelProperty<StorageMutatorMode> {
companion object {
@JvmField
val TYPE = SelectItemModelProperty.Type.create(MapCodec.unit(StorageMutatorItemModelProperty()), StorageMutatorMode.CODEC)
val TYPE: SelectItemModelProperty.Type<StorageMutatorItemModelProperty, StorageMutatorMode> = SelectItemModelProperty.Type.create(MapCodec.unit(StorageMutatorItemModelProperty()), StorageMutatorMode.CODEC)
}

override fun get(stack: ItemStack, level: ClientLevel?, entity: LivingEntity?, seed: Int, context: ItemDisplayContext): StorageMutatorMode? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ import net.minecraft.sounds.SoundSource
import java.util.function.Consumer

object InventoryOpeningApi {
@JvmStatic
fun openBlockInventory(player: ServerPlayer, pos: BlockPos, inventory: OpenableInventoryProvider<BlockContext>?) {
val container = inventory?.getOpenableInventory(BlockContext(player.serverLevel(), player, pos)) ?: throw IllegalStateException("Inventory shouldn't be null.")
s_openInventory(player, container, inventory.getForcedScreenType(), inventory::onInitialOpen)
}

@JvmStatic
fun openEntityInventory(player: ServerPlayer, inventory: OpenableInventoryProvider<BaseContext>?) {
val container = inventory?.getOpenableInventory(BaseContext(player.serverLevel(), player)) ?: throw IllegalStateException("Inventory shouldn't be null.")
s_openInventory(player, container, inventory.getForcedScreenType(), inventory::onInitialOpen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ enum class MutationMode : StringRepresentable {
}

companion object {
@JvmField
val CODEC: Codec<MutationMode> = StringRepresentable.fromValues { entries.toTypedArray() }

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import net.minecraft.core.NonNullList
import net.minecraft.world.item.ItemStack

interface ItemAccessor {
fun expandedstorage_getItems(): NonNullList<ItemStack?>
fun expandedstorage_getItems(): NonNullList<ItemStack>
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ data class BlockConversionRecipe(
customName = entity.getName()
}
} else if (entity is RandomizableContainerBlockEntity) {
originalItems = (entity as ItemAccessor).expandedstorage_getItems() as NonNullList<ItemStack>
originalItems = (entity as ItemAccessor).expandedstorage_getItems()
customName = entity.customName
} else {
throw IllegalStateException()
Expand Down
Loading

0 comments on commit 56bdabc

Please sign in to comment.