Skip to content

Commit

Permalink
chore: remove deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
raoulvdberge committed Mar 10, 2024
1 parent 8a47e57 commit 7b2d3d5
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void registerNetworkNodes(final Object testInstance) {
| IllegalAccessException
| InvocationTargetException
| NoSuchMethodException e) {
throw new NetworkTextException("Could not register network node factory", e);
// shouldn't happen
}
}
}
Expand Down Expand Up @@ -166,7 +166,7 @@ private void setField(final Object instance, final Field field, final Object val
field.setAccessible(true);
field.set(instance, value);
} catch (IllegalAccessException e) {
throw new NetworkTextException("Could not set field", e);
// shouldn't happen
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.refinedmods.refinedstorage2.platform.api.support.registry.PlatformRegistry;
import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceFactory;
import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceRendering;
import com.refinedmods.refinedstorage2.platform.api.support.resource.ResourceType;
import com.refinedmods.refinedstorage2.platform.api.upgrade.BuiltinUpgradeDestinations;
import com.refinedmods.refinedstorage2.platform.api.upgrade.UpgradeRegistry;
import com.refinedmods.refinedstorage2.platform.api.wirelesstransmitter.WirelessTransmitterRangeModifier;
Expand Down Expand Up @@ -81,7 +82,7 @@ public StorageContainerItemHelper getStorageContainerItemHelper() {
}

@Override
public PlatformRegistry getResourceTypeRegistry() {
public PlatformRegistry<ResourceType> getResourceTypeRegistry() {
return ensureLoaded().getResourceTypeRegistry();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.refinedmods.refinedstorage2.platform.common.Platform;
import com.refinedmods.refinedstorage2.platform.common.content.KeyMappings;
import com.refinedmods.refinedstorage2.platform.common.grid.CraftingGridContainerMenu;
import com.refinedmods.refinedstorage2.platform.common.grid.CraftingGridMatrixCloseBehavior;
import com.refinedmods.refinedstorage2.platform.common.support.widget.HoveredImageButton;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -166,9 +167,13 @@ public boolean keyPressed(final int key, final int scanCode, final int modifiers

@Override
public void onClose() {
switch (Platform.INSTANCE.getConfig().getCraftingGrid().getCraftingMatrixCloseBehavior()) {
case CLEAR_TO_NETWORK -> getMenu().clear(false);
case CLEAR_TO_INVENTORY -> getMenu().clear(true);
final CraftingGridMatrixCloseBehavior behavior = Platform.INSTANCE.getConfig()
.getCraftingGrid()
.getCraftingMatrixCloseBehavior();
if (behavior == CraftingGridMatrixCloseBehavior.CLEAR_TO_NETWORK) {
getMenu().clear(false);
} else if (behavior == CraftingGridMatrixCloseBehavior.CLEAR_TO_INVENTORY) {
getMenu().clear(true);
}
super.onClose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public ExternalStorageBlockEntity(final BlockPos pos, final BlockState state) {
}

@Override
@SuppressWarnings("deprecation")
public void setBlockState(final BlockState newBlockState) {
super.setBlockState(newBlockState);
if (level instanceof ServerLevel serverLevel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

public class ItemStorageMonitorExtractionStrategy implements StorageMonitorExtractionStrategy {
@Override
@SuppressWarnings("deprecation")
public boolean extract(final ResourceKey resource,
final boolean fullStack,
final Player player,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(final Level level,
}

@Override
@SuppressWarnings("deprecation")
public InteractionResult use(final BlockState state,
final Level level,
final BlockPos pos,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private boolean rotate(final BlockState state, final Level level, final BlockPos
return !state.equals(rotated);
}

@SuppressWarnings("deprecation")
protected BlockState getRotatedBlockState(final BlockState state, final Level level, final BlockPos pos) {
return state.rotate(Rotation.CLOCKWISE_90);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected AbstractLevelInteractingNetworkNodeContainerBlockEntity(

// used to handle rotations
@Override
@SuppressWarnings("deprecation")
public void setBlockState(final BlockState newBlockState) {
super.setBlockState(newBlockState);
if (!(level instanceof ServerLevel serverLevel)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void toBuffer(final FriendlyByteBuf buf) {
}

@Override
@SuppressWarnings("deprecation")
public long getInterfaceExportLimit() {
return item.getMaxStackSize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
Expand Down Expand Up @@ -86,11 +85,9 @@ public void emitBlockQuads(final BlockAndTintGetter blockView,
}
context.pushTransform(quadRotators.forDirection(direction));
super.emitBlockQuads(blockView, state, pos, randomSupplier, context);
if (blockView instanceof RenderAttachedBlockView renderAttachedBlockView) {
final Object renderAttachment = renderAttachedBlockView.getBlockEntityRenderAttachment(pos);
if (renderAttachment instanceof Disk[] disks) {
emitDiskQuads(blockView, state, pos, randomSupplier, context, disks);
}
final Object renderAttachment = blockView.getBlockEntityRenderData(pos);
if (renderAttachment instanceof Disk[] disks) {
emitDiskQuads(blockView, state, pos, randomSupplier, context, disks);
}
context.popTransform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected Disk[] getDisks(final AbstractDiskDriveBlockEntity blockEntity) {
if (!(blockEntity instanceof FabricDiskDriveBlockEntity fabricDiskDriveBlockEntity)) {
return null;
}
if (fabricDiskDriveBlockEntity.getRenderAttachmentData() instanceof Disk[] disks) {
if (fabricDiskDriveBlockEntity.getRenderData() instanceof Disk[] disks) {
return disks;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@

import javax.annotation.Nullable;

import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;

public class FabricDiskDriveBlockEntity extends AbstractDiskDriveBlockEntity implements RenderAttachmentBlockEntity {
public class FabricDiskDriveBlockEntity extends AbstractDiskDriveBlockEntity {
public FabricDiskDriveBlockEntity(final BlockPos pos, final BlockState state) {
super(pos, state);
}

@Override
@Nullable
public Object getRenderAttachmentData() {
public Object getRenderData() {
return disks;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,17 @@

import javax.annotation.Nullable;

import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;

public class FabricPortableGridBlockEntity extends AbstractPortableGridBlockEntity
implements RenderAttachmentBlockEntity {
public class FabricPortableGridBlockEntity extends AbstractPortableGridBlockEntity {
public FabricPortableGridBlockEntity(final PortableGridType type, final BlockPos pos, final BlockState state) {
super(type, pos, state);
}

@Override
@Nullable
public Object getRenderAttachmentData() {
public Object getRenderData() {
return disk;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import net.fabricmc.fabric.api.renderer.v1.model.ForwardingBakedModel;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachedBlockView;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.resources.model.BakedModel;
Expand Down Expand Up @@ -96,11 +95,9 @@ public void emitBlockQuads(final BlockAndTintGetter blockView,
return;
}
context.pushTransform(quadRotators.forDirection(direction));
if (blockView instanceof RenderAttachedBlockView renderAttachedBlockView) {
final Object renderAttachment = renderAttachedBlockView.getBlockEntityRenderAttachment(pos);
if (renderAttachment instanceof Disk disk) {
emitDiskQuads(blockView, state, pos, randomSupplier, context, disk);
}
final Object renderAttachment = blockView.getBlockEntityRenderData(pos);
if (renderAttachment instanceof Disk disk) {
emitDiskQuads(blockView, state, pos, randomSupplier, context, disk);
}
final boolean active = state.getValue(PortableGridBlock.ACTIVE);
(active ? activeModel : inactiveModel).emitBlockQuads(blockView, state, pos, randomSupplier, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected Disk getDisk(final T blockEntity) {
if (!(blockEntity instanceof FabricPortableGridBlockEntity fabricDiskDriveBlockEntity)) {
return null;
}
if (fabricDiskDriveBlockEntity.getRenderAttachmentData() instanceof Disk disk) {
if (fabricDiskDriveBlockEntity.getRenderData() instanceof Disk disk) {
return disk;
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.refinedmods.refinedstorage2.platform.forge.support.render.RotationTranslationModelBaker;
import com.refinedmods.refinedstorage2.platform.forge.support.render.TransformationBuilder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -58,9 +57,7 @@ class DiskDriveBakedModel extends BakedModelWrapper<BakedModel> {
this.cache = CacheBuilder.newBuilder().build(CacheLoader.from(cacheKey -> {
final Transformation rotation = TransformationBuilder.create().rotate(cacheKey.direction).build();
final RandomSource rand = RandomSource.create();
final List<BakedQuad> quads = new ArrayList<>(
baseModelBaker.bake(rotation).getQuads(null, cacheKey.side, rand)
);
final List<BakedQuad> quads = baseModelBaker.bake(rotation, cacheKey.side, rand);
for (int j = 0; j < diskTranslations.length; ++j) {
final Disk disk = cacheKey.disks[j];
quads.addAll(getDiskQuads(diskModelBaker, cacheKey, disk, j));
Expand All @@ -70,7 +67,7 @@ class DiskDriveBakedModel extends BakedModelWrapper<BakedModel> {
.rotate(cacheKey.direction)
.translate(diskTranslations[j])
.build();
quads.addAll(ledInactiveModelBaker.bake(ledTransform).getQuads(null, cacheKey.side, rand));
quads.addAll(ledInactiveModelBaker.bake(ledTransform, cacheKey.side, rand));
}
}
return quads;
Expand Down Expand Up @@ -117,7 +114,7 @@ private List<BakedQuad> getDiskQuads(final DiskModelBaker diskBakers,
.rotate(cacheKey.direction)
.translate(diskTranslations[index])
.build();
return diskBaker.bake(diskTransform).getQuads(null, cacheKey.side, RandomSource.create());
return diskBaker.bake(diskTransform, cacheKey.side, RandomSource.create());
}

private static Vector3f getDiskTranslation(final int x, final int y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.refinedmods.refinedstorage2.platform.forge.support.render.RotationTranslationModelBaker;
import com.refinedmods.refinedstorage2.platform.forge.support.render.TransformationBuilder;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -50,9 +49,11 @@ class PortableGridBakedModel extends BakedModelWrapper<BakedModel> {
final RotationTranslationModelBaker baseModelBaker = cacheKey.active
? activeModelBaker
: inactiveModelBaker;
final List<BakedQuad> quads = new ArrayList<>(baseModelBaker.bake(TransformationBuilder.create()
.rotate(cacheKey.direction)
.build()).getQuads(null, cacheKey.side(), RandomSource.create()));
final List<BakedQuad> quads = baseModelBaker.bake(
TransformationBuilder.create().rotate(cacheKey.direction).build(),
cacheKey.side(),
RandomSource.create()
);
if (cacheKey.disk.item() == null) {
return quads;
}
Expand All @@ -62,13 +63,13 @@ class PortableGridBakedModel extends BakedModelWrapper<BakedModel> {
.rotate(cacheKey.direction)
.translate(MOVE_TO_DISK_LOCATION)
.rotate(BiDirection.WEST)
.build()).getQuads(null, cacheKey.side(), RandomSource.create()));
.build(), cacheKey.side(), RandomSource.create()));
}
if (cacheKey.includeLed && cacheKey.disk.state() != StorageState.NONE) {
quads.addAll(diskLedBakers.forState(cacheKey.disk.state()).bake(TransformationBuilder.create()
.translate(MOVE_TO_DISK_LED_LOCATION)
.rotate(BiDirection.WEST)
.build()).getQuads(null, cacheKey.side(), RandomSource.create()));
.build(), cacheKey.side(), RandomSource.create()));
}
return quads;
}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package com.refinedmods.refinedstorage2.platform.forge.support.render;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import javax.annotation.Nullable;

import com.mojang.math.Transformation;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.Material;
import net.minecraft.client.resources.model.ModelBaker;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.neoforged.neoforge.client.model.SimpleModelState;

public class RotationTranslationModelBaker {
Expand All @@ -28,9 +33,15 @@ public RotationTranslationModelBaker(final ModelState state,
this.model = model;
}

@Nullable
public BakedModel bake(final Transformation transformation) {
@SuppressWarnings("deprecation")
public List<BakedQuad> bake(final Transformation transformation,
@Nullable final Direction side,
final RandomSource rand) {
final ModelState wrappedState = new SimpleModelState(transformation, state.isUvLocked());
return baker.bake(model, wrappedState, spriterGetter);
final BakedModel bakedModel = baker.bake(model, wrappedState, spriterGetter);
if (bakedModel == null) {
return new ArrayList<>();
}
return new ArrayList<>(bakedModel.getQuads(null, side, rand));
}
}

0 comments on commit 7b2d3d5

Please sign in to comment.