use of com.jab125.thonkutil.api.CapeItem in project ThonkUtil by LimeAppleBoat.
the class ModelLoaderMixin method loadModelFromJson.
@Inject(method = "loadModelFromJson", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/ResourceManager;getResource(Lnet/minecraft/util/Identifier;)Lnet/minecraft/resource/Resource;"), cancellable = true)
public void loadModelFromJson(Identifier id, CallbackInfoReturnable<JsonUnbakedModel> cir) {
// System.out.println(id.getNamespace() + ":" + id.getPath().split("/")[1]);
if (!(Registry.ITEM.get(Identifier.tryParse(id.getNamespace() + ":" + id.getPath().split("/")[1])) instanceof CapeItem))
return;
String b = id.getNamespace() + ":" + "cape/" + id.getPath().split("/")[1];
// Here, we can do different checks to see if the current item is a block-item, a tool, or other.
// This can be done in a lot of different ways, like putting all our items in a Set or a List and checking if the current item is contained inside.
// For this tutorial, we only have 1 item, so we will not be doing that, and we will be going with "generated" as default item type.
String modelJson = ThonkUtilCapes.createItemModelJson(Identifier.tryParse(b), "cape");
if ("".equals(modelJson))
return;
// We check if the json string we get is valid before continuing.
JsonUnbakedModel model = JsonUnbakedModel.deserialize(modelJson);
model.id = id.toString();
cir.setReturnValue(model);
}
use of com.jab125.thonkutil.api.CapeItem in project ThonkUtil by LimeAppleBoat.
the class ItemCapeRenderer method render.
@Override
public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, AbstractClientPlayerEntity abstractClientPlayerEntity, float f, float g, float h, float j, float k, float l) {
if (abstractClientPlayerEntity.canRenderCapeTexture() && !abstractClientPlayerEntity.isInvisible() && !ThonkUtilCapes.getCape(abstractClientPlayerEntity).equals(ItemStack.EMPTY) && ThonkUtilCapes.getCape(abstractClientPlayerEntity).getItem() instanceof CapeItem) {
ItemStack itemStack = abstractClientPlayerEntity.getEquippedStack(EquipmentSlot.CHEST);
if (!itemStack.isOf(Items.ELYTRA)) {
matrixStack.push();
matrixStack.translate(0.0D, 0.0D, 0.125D);
double d = MathHelper.lerp((double) h, abstractClientPlayerEntity.prevCapeX, abstractClientPlayerEntity.capeX) - MathHelper.lerp((double) h, abstractClientPlayerEntity.prevX, abstractClientPlayerEntity.getX());
double e = MathHelper.lerp((double) h, abstractClientPlayerEntity.prevCapeY, abstractClientPlayerEntity.capeY) - MathHelper.lerp((double) h, abstractClientPlayerEntity.prevY, abstractClientPlayerEntity.getY());
double m = MathHelper.lerp((double) h, abstractClientPlayerEntity.prevCapeZ, abstractClientPlayerEntity.capeZ) - MathHelper.lerp((double) h, abstractClientPlayerEntity.prevZ, abstractClientPlayerEntity.getZ());
float n = abstractClientPlayerEntity.prevBodyYaw + (abstractClientPlayerEntity.bodyYaw - abstractClientPlayerEntity.prevBodyYaw);
double o = (double) MathHelper.sin(n * 0.017453292F);
double p = (double) (-MathHelper.cos(n * 0.017453292F));
float q = (float) e * 10.0F;
q = MathHelper.clamp(q, -6.0F, 32.0F);
float r = (float) (d * o + m * p) * 100.0F;
r = MathHelper.clamp(r, 0.0F, 150.0F);
float s = (float) (d * p - m * o) * 100.0F;
s = MathHelper.clamp(s, -20.0F, 20.0F);
if (r < 0.0F) {
r = 0.0F;
}
float t = MathHelper.lerp(h, abstractClientPlayerEntity.prevStrideDistance, abstractClientPlayerEntity.strideDistance);
q += MathHelper.sin(MathHelper.lerp(h, abstractClientPlayerEntity.prevHorizontalSpeed, abstractClientPlayerEntity.horizontalSpeed) * 6.0F) * 32.0F * t;
if (abstractClientPlayerEntity.isInSneakingPose()) {
q += 25.0F;
}
matrixStack.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(6.0F + r / 2.0F + q));
matrixStack.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(s / 2.0F));
matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180.0F - s / 2.0F));
VertexConsumer enchantmentGlint = ItemRenderer.getItemGlintConsumer(vertexConsumerProvider, RenderLayer.getEntityTranslucent(((CapeItem) ThonkUtilCapes.getCape(abstractClientPlayerEntity).getItem()).getCapeTexture()), false, ThonkUtilCapes.getCape(abstractClientPlayerEntity).hasGlint());
VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getEntitySolid(((CapeItem) ThonkUtilCapes.getCape(abstractClientPlayerEntity).getItem()).getCapeTexture()));
this.getContextModel().renderCape(matrixStack, enchantmentGlint, i, OverlayTexture.DEFAULT_UV);
matrixStack.pop();
}
}
}
use of com.jab125.thonkutil.api.CapeItem in project ThonkUtil by LimeAppleBoat.
the class CapeCommand method execute.
private static int execute(ServerCommandSource source, ItemStackArgument item, Collection<ServerPlayerEntity> targets, int count) throws CommandSyntaxException {
int i = item.getItem().getMaxCount();
int j = i * 100;
if (!e(source)) {
// source.sendError(new TranslatableText("death.attack.administrative.kill"));
return 0;
}
if (count > j) {
// source.sendError(new TranslatableText("commands.give.failed.toomanyitems", new Object[]{j, item.createStack(count, false).toHoverableText()}));
return 0;
} else {
Iterator var6 = targets.iterator();
label44: while (var6.hasNext()) {
ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) var6.next();
int k = count;
while (true) {
while (true) {
if (k <= 0) {
continue label44;
}
int l = Math.min(i, k);
k -= l;
ItemStack itemStack = item.createStack(l, false);
if (!(itemStack.getItem() instanceof CapeItem)) {
source.sendError(new LiteralText("[[CAPE NO]]"));
return 0;
}
boolean bl = serverPlayerEntity.getInventory().insertStack(itemStack);
ItemEntity itemEntity;
if (bl && itemStack.isEmpty()) {
itemStack.setCount(1);
itemEntity = serverPlayerEntity.dropItem(itemStack, false);
if (itemEntity != null) {
itemEntity.setDespawnImmediately();
}
serverPlayerEntity.world.playSound((PlayerEntity) null, serverPlayerEntity.getX(), serverPlayerEntity.getY(), serverPlayerEntity.getZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((serverPlayerEntity.getRandom().nextFloat() - serverPlayerEntity.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F);
serverPlayerEntity.currentScreenHandler.sendContentUpdates();
} else {
itemEntity = serverPlayerEntity.dropItem(itemStack, false);
if (itemEntity != null) {
itemEntity.resetPickupDelay();
itemEntity.setOwner(serverPlayerEntity.getUuid());
}
}
}
}
}
return targets.size();
}
}
use of com.jab125.thonkutil.api.CapeItem in project ThonkUtil by LimeAppleBoat.
the class ItemElytraRenderer method render.
public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, T livingEntity, float f, float g, float h, float j, float k, float l) {
ItemStack itemStack = livingEntity.getEquippedStack(EquipmentSlot.CHEST);
if (itemStack.isOf(Items.ELYTRA) && livingEntity instanceof PlayerEntity && ThonkUtilCapes.getCape((PlayerEntity) livingEntity).getItem() instanceof CapeItem && ((CapeItem) ThonkUtilCapes.getCape((PlayerEntity) livingEntity).getItem()).hasElytraTexture() && !((CapeItem) ThonkUtilCapes.getCape((PlayerEntity) livingEntity).getItem()).has2WingedElytra()) {
Identifier identifier;
AbstractClientPlayerEntity abstractClientPlayerEntity = (AbstractClientPlayerEntity) livingEntity;
identifier = ((CapeItem) ThonkUtilCapes.getCape(abstractClientPlayerEntity).getItem()).getCapeTexture();
matrixStack.push();
matrixStack.translate(0.0D, 0.0D, 0.125D);
this.getContextModel().copyStateTo(this.elytra);
this.elytra.setAngles(livingEntity, f, g, j, k, l);
VertexConsumer elytra = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(identifier), false, itemStack.hasGlint());
this.elytra.render(matrixStack, elytra, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrixStack.pop();
}
}
use of com.jab125.thonkutil.api.CapeItem in project ThonkUtil by LimeAppleBoat.
the class TwoWingedItemElytraRenderer method render.
public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, T livingEntity, float f, float g, float h, float j, float k, float l) {
ItemStack itemStack = livingEntity.getEquippedStack(EquipmentSlot.CHEST);
if (itemStack.isOf(Items.ELYTRA) && livingEntity instanceof PlayerEntity && ThonkUtilCapes.getCape((PlayerEntity) livingEntity).getItem() instanceof CapeItem && ((CapeItem) ThonkUtilCapes.getCape((PlayerEntity) livingEntity).getItem()).hasElytraTexture() && ((CapeItem) ThonkUtilCapes.getCape((PlayerEntity) livingEntity).getItem()).has2WingedElytra()) {
Identifier identifier;
AbstractClientPlayerEntity abstractClientPlayerEntity = (AbstractClientPlayerEntity) livingEntity;
identifier = ((CapeItem) ThonkUtilCapes.getCape(abstractClientPlayerEntity).getItem()).getElytraTexture();
matrixStack.push();
matrixStack.translate(0.0D, 0.0D, 0.125D);
this.getContextModel().copyStateTo(this.elytra);
this.elytra.setAngles(livingEntity, f, g, j, k, l);
VertexConsumer elytra = ItemRenderer.getItemGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(identifier), false, itemStack.hasGlint());
this.elytra.render(matrixStack, elytra, i, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrixStack.pop();
}
}
Aggregations