修改ntw渲染
This commit is contained in:
parent
07792d6e37
commit
1395e4e047
4 changed files with 70 additions and 54 deletions
|
@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
|||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.data.gun.value.AttachmentType;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -14,11 +13,10 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animation.AnimationState;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
import static com.atsuishio.superbwarfare.event.ClientEventHandler.isProne;
|
||||
|
||||
public class Ntw20Model extends GeoModel<Ntw20Item> {
|
||||
public class Ntw20Model extends CustomGunModel<Ntw20Item> {
|
||||
|
||||
public static float fireRotY = 0f;
|
||||
public static float fireRotZ = 0f;
|
||||
|
@ -40,7 +38,12 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCustomAnimations(Ntw20Item animatable, long instanceId, AnimationState animationState) {
|
||||
public void setCustomAnimations(Ntw20Item animatable, long instanceId, AnimationState<Ntw20Item> 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 action = getAnimationProcessor().getBone("action");
|
||||
GeoBone lh = getAnimationProcessor().getBone("lh");
|
||||
|
@ -48,11 +51,6 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
|
|||
GeoBone scope2 = getAnimationProcessor().getBone("Scope2");
|
||||
GeoBone scope3 = getAnimationProcessor().getBone("Scope3");
|
||||
|
||||
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);
|
||||
double zt = ClientEventHandler.zoomTime;
|
||||
double zp = ClientEventHandler.zoomPos;
|
||||
|
|
|
@ -14,7 +14,9 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
||||
public class Ntw20Renderer extends CustomGunRenderer<Ntw20Item> {
|
||||
|
@ -38,21 +40,20 @@ public class Ntw20Renderer extends CustomGunRenderer<Ntw20Item> {
|
|||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (!(itemStack.getItem() instanceof GunItem)) return;
|
||||
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
if (this.renderPerspective == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND) {
|
||||
if (name.equals("ironSight")) {
|
||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) != 0);
|
||||
}
|
||||
|
||||
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2
|
||||
&& (name.equals("bone1") || name.equals("zhituiqi") || name.equals("guan") || name.equals("hidden"))) {
|
||||
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
||||
}
|
||||
|
||||
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 3
|
||||
&& (name.equals("bone1") || name.equals("zhituiqi") || name.equals("guan") || name.equals("jing") || name.equals("rail") || name.equals("base2") || name.equals("guan7"))) {
|
||||
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
||||
}
|
||||
}
|
||||
|
||||
int scopeType = GunData.from(itemStack).attachment.get(AttachmentType.SCOPE);
|
||||
|
||||
|
@ -66,11 +67,16 @@ public class Ntw20Renderer extends CustomGunRenderer<Ntw20Item> {
|
|||
}
|
||||
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 3.70229375, 0.8);
|
||||
|
||||
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
||||
} else {
|
||||
ItemModelHelper.hideAllAttachments(bone, name);
|
||||
if (name.equals("hidden") || name.equals("jing") || name.equals("base2") || name.equals("guan7")) {
|
||||
bone.setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
@ -59,6 +60,7 @@ public class TracheliumItemRenderer extends CustomGunRenderer<Trachelium> {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.renderPerspective == ItemDisplayContext.FIRST_PERSON_RIGHT_HAND) {
|
||||
if (name.equals("humu")) {
|
||||
bone.setHidden(GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 0 && GunData.from(itemStack).attachment.get(AttachmentType.GRIP) == 0);
|
||||
}
|
||||
|
@ -78,6 +80,7 @@ public class TracheliumItemRenderer extends CustomGunRenderer<Trachelium> {
|
|||
if (GunData.from(itemStack).attachment.get(AttachmentType.SCOPE) == 2 && !NBTTool.getTag(itemStack).getBoolean("ScopeAlt") && (name.equals("hidden"))) {
|
||||
bone.setHidden(ClientEventHandler.zoomPos > 0.7 && ClientEventHandler.zoom);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ItemModelHelper.hideAllAttachments(bone, name);
|
||||
if (name.equals("humu") || name.equals("qianzhunxing1") || name.equals("railup") || name.equals("raildown")) {
|
||||
|
|
|
@ -16,8 +16,10 @@ import net.minecraft.client.player.LocalPlayer;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.constant.DataTickets;
|
||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -44,8 +46,10 @@ public class Ntw20Item extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
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.ntw_20.idle"));
|
||||
|
||||
var data = GunData.from(stack);
|
||||
if (data.bolt.actionTimer.get() > 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.shift"));
|
||||
}
|
||||
|
@ -66,8 +70,10 @@ public class Ntw20Item extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
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.ntw_20.idle"));
|
||||
|
||||
var data = GunData.from(stack);
|
||||
if (player.isSprinting() && player.onGround()
|
||||
&& ClientEventHandler.cantSprint == 0
|
||||
&& !(data.reload.normal() || data.reload.empty())
|
||||
|
@ -83,6 +89,9 @@ public class Ntw20Item extends GunItem {
|
|||
}
|
||||
|
||||
private PlayState editPredicate(AnimationState<Ntw20Item> event) {
|
||||
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ntw_20.idle"));
|
||||
|
||||
if (ClickHandler.isEditing) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.edit"));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue