1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-27 16:02:17 +00:00

Fix some problems with pocket computer model properties

- We were setting state twice, rather than state and coloured.
 - Fabric forces us to use the clamped item property getter, which
   doesn't work with our computer state, as it takes a value [0, 2].
 - Fixup new pocket computer textures to match original ones.

Co-authored-by: Jummit <jummit@web.de>
This commit is contained in:
Jonathan Coates 2021-12-19 13:04:19 +00:00
parent 57cfcd8709
commit cc08eced48
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
8 changed files with 23 additions and 2 deletions

View File

@ -40,11 +40,16 @@ import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.function.Supplier;
@ -101,7 +106,7 @@ public final class ComputerCraftProxyClient implements ClientModInitializer
.ordinal(),
() -> Registry.ModItems.POCKET_COMPUTER_NORMAL,
() -> Registry.ModItems.POCKET_COMPUTER_ADVANCED );
registerItemProperty( "state",
registerItemProperty( "coloured",
( stack, world, player, integer ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0,
() -> Registry.ModItems.POCKET_COMPUTER_NORMAL,
() -> Registry.ModItems.POCKET_COMPUTER_ADVANCED );
@ -132,9 +137,25 @@ public final class ComputerCraftProxyClient implements ClientModInitializer
private static void registerItemProperty( String name, ClampedItemPropertyFunction getter, Supplier<? extends Item>... items )
{
ResourceLocation id = new ResourceLocation( ComputerCraft.MOD_ID, name );
// Terrible hack, but some of our properties return values greater than 1, so we don't want to clamp.
var unclampedGetter = new ClampedItemPropertyFunction()
{
@Override
@Deprecated
public float call( @NotNull ItemStack itemStack, @Nullable ClientLevel clientLevel, @Nullable LivingEntity livingEntity, int i )
{
return getter.unclampedCall( itemStack, clientLevel, livingEntity, i );
}
@Override
public float unclampedCall( ItemStack itemStack, @Nullable ClientLevel clientLevel, @Nullable LivingEntity livingEntity, int i )
{
return getter.unclampedCall( itemStack, clientLevel, livingEntity, i );
}
};
for( Supplier<? extends Item> item : items )
{
FabricModelPredicateProviderRegistry.register( item.get(), id, getter );
FabricModelPredicateProviderRegistry.register( item.get(), id, unclampedGetter );
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 B

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 624 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 196 B

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 B

After

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

After

Width:  |  Height:  |  Size: 484 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 B

After

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 583 B