修改rpk的渲染
This commit is contained in:
parent
4aacfbea78
commit
5860d404a3
3 changed files with 59 additions and 50 deletions
|
@ -6,7 +6,6 @@ import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||||
import com.atsuishio.superbwarfare.data.gun.value.AttachmentType;
|
import com.atsuishio.superbwarfare.data.gun.value.AttachmentType;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
|
||||||
import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem;
|
import com.atsuishio.superbwarfare.item.gun.machinegun.RpkItem;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -15,9 +14,8 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import software.bernie.geckolib.animation.AnimationState;
|
import software.bernie.geckolib.animation.AnimationState;
|
||||||
import software.bernie.geckolib.cache.object.GeoBone;
|
import software.bernie.geckolib.cache.object.GeoBone;
|
||||||
import software.bernie.geckolib.model.GeoModel;
|
|
||||||
|
|
||||||
public class RpkItemModel extends GeoModel<RpkItem> {
|
public class RpkItemModel extends CustomGunModel<RpkItem> {
|
||||||
|
|
||||||
public static float fireRotY = 0f;
|
public static float fireRotY = 0f;
|
||||||
public static float fireRotZ = 0f;
|
public static float fireRotZ = 0f;
|
||||||
|
@ -38,7 +36,12 @@ public class RpkItemModel extends GeoModel<RpkItem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setCustomAnimations(RpkItem animatable, long instanceId, AnimationState animationState) {
|
public void setCustomAnimations(RpkItem animatable, long instanceId, AnimationState<RpkItem> animationState) {
|
||||||
|
Player player = Minecraft.getInstance().player;
|
||||||
|
if (player == null) return;
|
||||||
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
if (shouldCancelRender(stack, animationState)) return;
|
||||||
|
|
||||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||||
GeoBone scope = getAnimationProcessor().getBone("Scope1");
|
GeoBone scope = getAnimationProcessor().getBone("Scope1");
|
||||||
GeoBone button = getAnimationProcessor().getBone("button");
|
GeoBone button = getAnimationProcessor().getBone("button");
|
||||||
|
@ -48,11 +51,6 @@ public class RpkItemModel extends GeoModel<RpkItem> {
|
||||||
GeoBone scope3 = getAnimationProcessor().getBone("Scope3");
|
GeoBone scope3 = getAnimationProcessor().getBone("Scope3");
|
||||||
GeoBone shuan = getAnimationProcessor().getBone("shuan");
|
GeoBone shuan = getAnimationProcessor().getBone("shuan");
|
||||||
|
|
||||||
Player player = Minecraft.getInstance().player;
|
|
||||||
if (player == null) return;
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
|
||||||
if (!(stack.getItem() instanceof GunItem)) return;
|
|
||||||
|
|
||||||
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
||||||
double zt = ClientEventHandler.zoomTime;
|
double zt = ClientEventHandler.zoomTime;
|
||||||
double zp = ClientEventHandler.zoomPos;
|
double zp = ClientEventHandler.zoomPos;
|
||||||
|
|
|
@ -14,7 +14,9 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import software.bernie.geckolib.animatable.GeoItem;
|
||||||
import software.bernie.geckolib.cache.object.GeoBone;
|
import software.bernie.geckolib.cache.object.GeoBone;
|
||||||
|
|
||||||
public class RpkItemRenderer extends CustomGunRenderer<RpkItem> {
|
public class RpkItemRenderer extends CustomGunRenderer<RpkItem> {
|
||||||
|
@ -37,51 +39,54 @@ public class RpkItemRenderer extends CustomGunRenderer<RpkItem> {
|
||||||
|
|
||||||
var player = mc.player;
|
var player = mc.player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
ItemStack itemStack = player.getMainHandItem();
|
ItemStack itemStack = player.getMainHandItem();
|
||||||
if (!(itemStack.getItem() instanceof GunItem)) return;
|
|
||||||
var data = GunData.from(itemStack);
|
|
||||||
|
|
||||||
if (name.equals("humu1")) {
|
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.GRIP) != 0);
|
if (this.renderPerspective == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND) {
|
||||||
|
if (name.equals("humu1")) {
|
||||||
|
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.GRIP) != 0);
|
||||||
|
}
|
||||||
|
if (name.equals("humu2")) {
|
||||||
|
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.GRIP) == 0);
|
||||||
|
}
|
||||||
|
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2
|
||||||
|
&& (name.equals("hide2") || name.equals("Barrel") || name.equals("humu") || name.equals("qiangguan") || name.equals("houzhunxing"))) {
|
||||||
|
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
||||||
|
}
|
||||||
|
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 3
|
||||||
|
&& (name.equals("jing") || name.equals("Barrel") || name.equals("humu") || name.equals("qiangguan") || name.equals("houzhunxing"))) {
|
||||||
|
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int scopeType = GunData.from(itemStack).attachment.get(AttachmentType.SCOPE);
|
||||||
|
|
||||||
|
switch (scopeType) {
|
||||||
|
case 1 ->
|
||||||
|
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.27363125, 20, 1, 255, 0, 0, 255, "pkas", true);
|
||||||
|
case 2 ->
|
||||||
|
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.28, 13, 1, 0, 255, 0, 255, "1p78", false);
|
||||||
|
case 3 ->
|
||||||
|
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.28, 36, (float) ClientEventHandler.customZoom, 255, 0, 0, 255, "lpvo", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
float height = 0.02f;
|
||||||
|
|
||||||
|
if ((GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2 || GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 3) && ClientEventHandler.zoom) {
|
||||||
|
height = -0.1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, height, 1.475, 0.3);
|
||||||
|
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
||||||
|
} else {
|
||||||
|
ItemModelHelper.hideAllAttachments(bone, name);
|
||||||
|
if (name.equals("humu2")) {
|
||||||
|
bone.setHidden(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equals("humu2")) {
|
|
||||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.GRIP) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.attachment.get(AttachmentType.SCOPE) == 2
|
|
||||||
&& (name.equals("hide2") || name.equals("Barrel") || name.equals("humu") || name.equals("qiangguan") || name.equals("houzhunxing"))) {
|
|
||||||
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 3
|
|
||||||
&& (name.equals("jing") || name.equals("Barrel") || name.equals("humu") || name.equals("qiangguan") || name.equals("houzhunxing"))) {
|
|
||||||
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
int scopeType = GunData.from(itemStack).attachment.get(AttachmentType.SCOPE);
|
|
||||||
|
|
||||||
switch (scopeType) {
|
|
||||||
case 1 ->
|
|
||||||
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.27363125, 20, 1, 255, 0, 0, 255, "pkas", true);
|
|
||||||
case 2 ->
|
|
||||||
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.28, 13, 1, 0, 255, 0, 255, "1p78", false);
|
|
||||||
case 3 ->
|
|
||||||
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.28, 36, (float) ClientEventHandler.customZoom, 255, 0, 0, 255, "lpvo", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
float height = 0.02f;
|
|
||||||
|
|
||||||
if ((GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2 || GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 3) && ClientEventHandler.zoom) {
|
|
||||||
height = -0.1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, height, 1.475, 0.3);
|
|
||||||
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
|
||||||
|
|
||||||
if (renderingArms) {
|
if (renderingArms) {
|
||||||
AnimationHelper.renderArms(player, this.transformType, stack, name, bone, this.currentBuffer, type, packedLightIn, false);
|
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, false);
|
||||||
}
|
}
|
||||||
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,12 @@ import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import software.bernie.geckolib.animation.*;
|
import software.bernie.geckolib.animation.*;
|
||||||
|
import software.bernie.geckolib.constant.DataTickets;
|
||||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
@ -42,8 +44,10 @@ public class RpkItem extends GunItem {
|
||||||
if (player == null) return PlayState.STOP;
|
if (player == null) return PlayState.STOP;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
var data = GunData.from(stack);
|
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ak_47.idle"));
|
||||||
|
|
||||||
|
var data = GunData.from(stack);
|
||||||
boolean drum = data.attachment.get(AttachmentType.MAGAZINE) == 2;
|
boolean drum = data.attachment.get(AttachmentType.MAGAZINE) == 2;
|
||||||
boolean grip = data.attachment.get(AttachmentType.GRIP) == 1 || GunData.from(stack).attachment.get(AttachmentType.GRIP) == 2;
|
boolean grip = data.attachment.get(AttachmentType.GRIP) == 1 || GunData.from(stack).attachment.get(AttachmentType.GRIP) == 2;
|
||||||
|
|
||||||
|
@ -103,6 +107,8 @@ public class RpkItem extends GunItem {
|
||||||
if (player == null) return PlayState.STOP;
|
if (player == null) return PlayState.STOP;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||||
|
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||||
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ak_47.idle"));
|
||||||
|
|
||||||
if (ClickHandler.isEditing) {
|
if (ClickHandler.isEditing) {
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak_47.edit"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak_47.edit"));
|
||||||
|
|
Loading…
Add table
Reference in a new issue