Skip to content

Commit

Permalink
Fix deprecated API usages
Browse files Browse the repository at this point in the history
- removed deprecated delegate implementations in RedStringContainerStorage
- replaced deprecated simulateExtract call in FabricTransferCorporeaNode
- updated deprecated code uses in FabricFloatingFlowerModel and FabricPlatformModel (floating flower rendering in multiblocks works in the lexicon, now, but not yet in the world visualization of those multiblocks; platforms still render as themselves at all times)
  • Loading branch information
TheRealWormbo committed May 2, 2024
1 parent d681139 commit 0cd7174
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.BlockModel;
import net.minecraft.client.renderer.block.model.ItemTransforms;
Expand Down Expand Up @@ -105,11 +104,6 @@ public static class Baked extends ForwardingBakedModel {
this.islands = islands;
}

private void emit(FloatingFlower.IslandType type, RenderContext ctx) {
ctx.bakedModelConsumer().accept(wrapped);
ctx.bakedModelConsumer().accept(islands.get(type));
}

@NotNull
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @NotNull RandomSource rand) {
Expand All @@ -128,15 +122,16 @@ public boolean isVanillaAdapter() {

@Override
public void emitItemQuads(ItemStack stack, Supplier<RandomSource> randomSupplier, RenderContext context) {
emit(FloatingFlower.IslandType.GRASS, context);
wrapped.emitItemQuads(stack, randomSupplier, context);
islands.get(FloatingFlower.IslandType.GRASS).emitItemQuads(stack, randomSupplier, context);
}

@Override
public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier<RandomSource> randomSupplier, RenderContext context) {
Object data = ((RenderAttachedBlockView) blockView).getBlockEntityRenderAttachment(pos);
if (data instanceof FloatingFlower.IslandType type) {
emit(type, context);
}
wrapped.emitBlockQuads(blockView, state, pos, randomSupplier, context);
Object data = blockView.getBlockEntityRenderData(pos);
islands.get(data instanceof FloatingFlower.IslandType type ? type : FloatingFlower.IslandType.GRASS)
.emitBlockQuads(blockView, state, pos, randomSupplier, context);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
*/
package vazkii.botania.fabric.client;

import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
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.resources.model.BakedModel;
import net.minecraft.core.BlockPos;
Expand All @@ -38,12 +36,12 @@ public boolean isVanillaAdapter() {
@Override
public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier<RandomSource> randomSupplier, RenderContext context) {
if (!(state.getBlock() instanceof PlatformBlock)) {
context.fallbackConsumer().accept(Minecraft.getInstance().getBlockRenderer()
.getBlockModelShaper().getModelManager().getMissingModel());
Minecraft.getInstance().getBlockRenderer().getBlockModelShaper().getModelManager().getMissingModel()
.emitBlockQuads(blockView, state, pos, randomSupplier, context);
return;
}

Object data = ((RenderAttachedBlockView) blockView).getBlockEntityRenderAttachment(pos);
Object data = blockView.getBlockEntityRenderData(pos);
if (data instanceof PlatformBlockEntity.PlatformData) {
BlockPos heldPos = ((PlatformBlockEntity.PlatformData) data).pos();
BlockState heldState = ((PlatformBlockEntity.PlatformData) data).state();
Expand All @@ -59,10 +57,8 @@ public void emitBlockQuads(BlockAndTintGetter blockView, BlockState state, Block

BakedModel model = Minecraft.getInstance().getBlockRenderer()
.getBlockModelShaper().getBlockModel(heldState);
if (model instanceof FabricBakedModel) {
// Steal camo's model
((FabricBakedModel) model).emitBlockQuads(blockView, heldState, heldPos, randomSupplier, context);
}
// Steal camo's model
model.emitBlockQuads(blockView, heldState, heldPos, randomSupplier, context);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected List<ItemStack> iterateOverSlots(CorporeaRequest request, boolean doit
getSpark().onItemExtracted(stack);
request.trackExtracted(rem);
} else {
builder.add(item.toStack((int) inv.simulateExtract(item, rem, trans)));
builder.add(item.toStack((int) inv.extract(item, rem, trans)));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;

import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;

import vazkii.botania.common.block.block_entity.red_string.RedStringContainerBlockEntity;

Expand Down Expand Up @@ -59,6 +59,7 @@ public long extract(ItemVariant resource, long maxAmount, TransactionContext tra
return getStorage().extract(resource, maxAmount, transaction);
}

@NotNull
@Override
public Iterator<StorageView<ItemVariant>> iterator() {
return getStorage().iterator();
Expand All @@ -70,28 +71,13 @@ public boolean supportsInsertion() {
return true;
}

@Override
public long simulateInsert(ItemVariant resource, long maxAmount, @Nullable TransactionContext transaction) {
return getStorage().simulateInsert(resource, maxAmount, transaction);
}

@Override
public boolean supportsExtraction() {
// Since the binding target could change we can't know if "absolutely always 0" is correct.
// Corporea spark attachment also depends on this returning true for the UP direction.
return true;
}

@Override
public long simulateExtract(ItemVariant resource, long maxAmount, @Nullable TransactionContext transaction) {
return getStorage().simulateExtract(resource, maxAmount, transaction);
}

@Override
public @Nullable StorageView<ItemVariant> exactView(ItemVariant resource) {
return getStorage().exactView(resource);
}

@Override
public long getVersion() {
return getStorage().getVersion();
Expand Down

0 comments on commit 0cd7174

Please sign in to comment.