39 lines
1.5 KiB
Java
39 lines
1.5 KiB
Java
package online.astradev.cauldron;
|
|||
|
|
|
||
|
|
import com.mojang.math.Transformation;
|
||
|
|
|
||
|
|
import net.minecraft.core.BlockPos;
|
||
|
|
|
||
|
|
|
||
|
|
import net.minecraft.server.level.ServerLevel;
|
||
|
|
import net.minecraft.world.entity.Display;
|
||
|
|
import net.minecraft.world.entity.EntityTypes;
|
||
|
|
import net.minecraft.world.item.*;
|
||
|
|
|
||
|
|
import net.minecraft.world.level.storage.ValueOutput;
|
||
|
|
import org.joml.Quaternionf;
|
||
|
|
import org.joml.Vector3f;
|
||
|
|
|
||
|
|
final class SoupDisplay extends Display.ItemDisplay {
|
||
|
|
static final String TAG = "astracauldron:cauldron_visual";
|
||
|
|
SoupDisplay(ServerLevel level, BlockPos pos, ItemStack stack) {
|
||
|
|
super(EntityTypes.ITEM_DISPLAY, level);
|
||
|
|
setPos(pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5);
|
||
|
|
getSlot(0).set(stack.copy());
|
||
|
|
setItemTransform(ItemDisplayContext.FIXED);
|
||
|
|
setNoGravity(true);
|
||
|
|
setInvulnerable(true);
|
||
|
|
setSilent(true);
|
||
|
|
addTag(TAG);
|
||
|
|
setTransformationInterpolationDuration(2);
|
||
|
|
}
|
||
|
|
void ingredient(int slot, int water, int ticks, int elapsed, int duration) {
|
||
|
|
var frame = CauldronAnimation.frame(slot, water, ticks, elapsed, duration);
|
||
|
|
setTransformationInterpolationDelay(0);
|
||
|
|
setTransformation(new Transformation(new Vector3f((float)frame.x() - .5f, (float)frame.y() - .5f, (float)frame.z() - .5f),
|
||
|
|
new Quaternionf(), new Vector3f(.3f), new Quaternionf().rotationY(ticks * .035f + slot)));
|
||
|
|
}
|
||
|
|
@Override public boolean shouldBeSaved() { return false; }
|
||
|
|
@Override public boolean saveAsPassenger(ValueOutput output) { return false; }
|
||
|
|
}
|