Skip to content

Commit

Permalink
Fixed some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Qzimyion committed Aug 18, 2024
1 parent 7a25585 commit e24babc
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main/java/com/qzimyion/bucketem/BucketemClient.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package com.qzimyion.bucketem;

import com.qzimyion.bucketem.mixin.EntityBucketItemAccessor;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.Bucketable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.AxolotlEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EntityBucketItem;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
Expand All @@ -12,6 +18,8 @@

@SuppressWarnings("deprecation")
public class BucketemClient implements ClientModInitializer {
private static final MinecraftClient MINECRAFT = MinecraftClient.getInstance();


public static void itemPredicates(){

Expand All @@ -36,6 +44,30 @@ public static void itemPredicates(){
return 1;
}
});

FabricModelPredicateProviderRegistry.register(Items.AXOLOTL_BUCKET, new Identifier("variant"),
(itemStack, world, holder, seed) -> {
Item item = itemStack.getItem();
if (!(item instanceof EntityBucketItem)) {
return 0f;
}

Entity entity = ((EntityBucketItemAccessor) item).getEntityType().create(MINECRAFT.world);
if (!(entity instanceof AxolotlEntity) || entity == null) {
return 0f;
}

((Bucketable) entity).copyDataFromNbt(itemStack.getOrCreateNbt());

return ((AxolotlEntity) entity).getVariant().ordinal() / 10f;
}
);

FabricModelPredicateProviderRegistry.register(GOLDEN_WATER_BUCKET, new Identifier("level"), (stack, level, entity, hash) -> stack.getOrCreateNbt().getInt("fluidlevel"));
FabricModelPredicateProviderRegistry.register(GOLDEN_LAVA_BUCKET, new Identifier("level"), (stack, level, entity, hash) -> stack.getOrCreateNbt().getInt("fluidlevel"));
FabricModelPredicateProviderRegistry.register(GOLDEN_MILK_BUCKET, new Identifier("level"), (stack, level, entity, hash) -> stack.getOrCreateNbt().getInt("fluidlevel"));
FabricModelPredicateProviderRegistry.register(GOLDEN_POWDER_SNOW_BUCKET, new Identifier("level"), (stack, level, entity, hash) -> stack.getOrCreateNbt().getInt("fluidlevel"));

}

public void onInitializeClient(){
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.qzimyion.bucketem.mixin;

import net.minecraft.entity.EntityType;
import net.minecraft.item.EntityBucketItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(EntityBucketItem.class)
public interface EntityBucketItemAccessor {
@Accessor
EntityType<?> getEntityType();
}
1 change: 1 addition & 0 deletions src/main/resources/bucketem.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"package": "com.qzimyion.bucketem.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"EntityBucketItemAccessor",
"BlockEntityMixins.ChiseledBookshelfMixin",
"EntityMixins.BeeEntityMixin",
"EntityMixins.EndermiteEntityMixin",
Expand Down

0 comments on commit e24babc

Please sign in to comment.