Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snare vines #1244

Draft
wants to merge 1 commit into
base: 1.20
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"values": []
"values": [
"ars_nouveau:snared"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.hollingsworth.arsnouveau.client.renderer.layer;

import com.hollingsworth.arsnouveau.ArsNouveau;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import net.minecraft.client.Camera;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.Material;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.inventory.InventoryMenu;

public class VinesEffectHandler {

public static final Material VINES_1 =new Material(InventoryMenu.BLOCK_ATLAS, new ResourceLocation(ArsNouveau.MODID,"block/snare_0"));
public static final Material VINES_2 =new Material(InventoryMenu.BLOCK_ATLAS, new ResourceLocation(ArsNouveau.MODID,"block/snare_1"));
public static void renderWorldVinesEffect(PoseStack pMatrixStack, MultiBufferSource pBuffer, Camera camera, Entity pEntity) {
TextureAtlasSprite textureAtlasSprite0 = VINES_1.sprite();
TextureAtlasSprite textureAtlasSprite1 = VINES_2.sprite();
pMatrixStack.pushPose();
float f = pEntity.getBbWidth() * 1.4F;
pMatrixStack.scale(f, f, f);
float f1 = 0.5F;
float f3 = pEntity.getBbHeight() / f;
float f4 = 0.0F;
pMatrixStack.mulPose(Axis.YP.rotationDegrees(-camera.getYRot()));
pMatrixStack.translate(0.0D, 0.0D, -0.3F + (float) ((int) f3) * 0.02F);
float f5 = 0.0F;
int i = 0;
VertexConsumer vertexconsumer = pBuffer.getBuffer(Sheets.cutoutBlockSheet());

for (PoseStack.Pose last = pMatrixStack.last(); f3 > 0.0F; ++i) {
TextureAtlasSprite finalSprite = i % 2 == 0 ? textureAtlasSprite0 : textureAtlasSprite1;
float f6 = finalSprite.getU0();
float f7 = finalSprite.getV0();
float f8 = finalSprite.getU1();
float f9 = finalSprite.getV1();
if (i / 2 % 2 == 0) {
float f10 = f8;
f8 = f6;
f6 = f10;
}

fireVertex(last, vertexconsumer, f1 - 0.0F, 0.0F - f4, f5, f8, f9);
fireVertex(last, vertexconsumer, -f1 - 0.0F, 0.0F - f4, f5, f6, f9);
fireVertex(last, vertexconsumer, -f1 - 0.0F, 1.4F - f4, f5, f6, f7);
fireVertex(last, vertexconsumer, f1 - 0.0F, 1.4F - f4, f5, f8, f7);
f3 -= 0.45F;
f4 -= 0.45F;
f1 *= 0.9F;
f5 += 0.03F;
}

pMatrixStack.popPose();
}

protected static void fireVertex(PoseStack.Pose pMatrixEntry, VertexConsumer pBuffer, float pX, float pY, float pZ, float pTexU, float pTexV) {
pBuffer.vertex(pMatrixEntry.pose(), pX, pY, pZ).color(255, 255, 255, 255).uv(pTexU, pTexV).overlayCoords(0, 10).uv2(240).normal(pMatrixEntry.normal(), 0.0F, 1.0F, 0.0F).endVertex();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ protected void addTags(HolderLookup.Provider pProvider) {
);
//placeholder to not leave the tag empty
this.tag(PotionEffectTags.DISPEL_DENY).add(ModPotions.SUMMONING_SICKNESS_EFFECT.get());
this.tag(PotionEffectTags.TO_SYNC);
this.tag(PotionEffectTags.TO_SYNC).add(ModPotions.SNARE_EFFECT.get());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.hollingsworth.arsnouveau.common.mixin;

import com.hollingsworth.arsnouveau.client.renderer.layer.VinesEffectHandler;
import com.hollingsworth.arsnouveau.setup.registry.ModPotions;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Camera;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EntityRenderDispatcher.class)
public class EntityRenderDispatcherMixin {
@Shadow
public Camera camera;

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/EntityRenderer;render(Lnet/minecraft/world/entity/Entity;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V"))
private void ars_nouveau$PotionEffectWorldRendering(Entity pEntity, double pX, double pY, double pZ, float pRotationYaw, float pPartialTicks, PoseStack pMatrixStack, MultiBufferSource pBuffer, int pPackedLight, CallbackInfo ci) {
if (pEntity instanceof LivingEntity living && living.hasEffect(ModPotions.SNARE_EFFECT.get())) {
VinesEffectHandler.renderWorldVinesEffect(pMatrixStack, pBuffer, camera, pEntity);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"textures": [
"ars_nouveau:snare_0",
"ars_nouveau:snare_1"
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.