优化minigun的逻辑
This commit is contained in:
parent
a180f50ce6
commit
43e5ca19a8
2 changed files with 16 additions and 23 deletions
|
@ -47,7 +47,7 @@ public class MinigunItemModel extends GeoModel<Minigun> {
|
||||||
}
|
}
|
||||||
float times = 250f / fps;
|
float times = 250f / fps;
|
||||||
|
|
||||||
float heat = (float)stack.getOrCreateTag().getDouble("heat");
|
float heat = (float) stack.getOrCreateTag().getDouble("heat");
|
||||||
|
|
||||||
heat_barrels.setScaleZ(4 * heat);
|
heat_barrels.setScaleZ(4 * heat);
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ public class MinigunItemModel extends GeoModel<Minigun> {
|
||||||
shen.setPosZ(2.2f * (float) (0.5 * fp + 1.54f * fr));
|
shen.setPosZ(2.2f * (float) (0.5 * fp + 1.54f * fr));
|
||||||
shen.setRotX(0.05f * (float) (0.18f * fp + fr));
|
shen.setRotX(0.05f * (float) (0.18f * fp + fr));
|
||||||
shen.setRotZ(-0.02f * (float) (fp + 1.3 * fr));
|
shen.setRotZ(-0.02f * (float) (fp + 1.3 * fr));
|
||||||
shen.setPosX(0.5f * (float)fr * (float)((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon * fp));
|
shen.setPosX(0.5f * (float) fr * (float) ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).recoilHorizon * fp));
|
||||||
|
|
||||||
if (stack.getOrCreateTag().getInt("fire_animation") > 0) {
|
if (stack.getOrCreateTag().getInt("fire_animation") > 0) {
|
||||||
flare.setHidden(false);
|
flare.setHidden(false);
|
||||||
|
@ -77,8 +77,8 @@ public class MinigunItemModel extends GeoModel<Minigun> {
|
||||||
|
|
||||||
CoreGeoBone root = getAnimationProcessor().getBone("root");
|
CoreGeoBone root = getAnimationProcessor().getBone("root");
|
||||||
|
|
||||||
float PosX = (float)player.getPersistentData().getDouble("gun_move_posX");
|
float PosX = (float) player.getPersistentData().getDouble("gun_move_posX");
|
||||||
float PosY = (float)player.getPersistentData().getDouble("gun_move_posY");
|
float PosY = (float) player.getPersistentData().getDouble("gun_move_posY");
|
||||||
|
|
||||||
double y = 0;
|
double y = 0;
|
||||||
double x = 0;
|
double x = 0;
|
||||||
|
|
|
@ -46,7 +46,7 @@ import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
public class Minigun extends GunItem implements GeoItem, AnimatedItem {
|
public class Minigun extends GunItem implements GeoItem, AnimatedItem {
|
||||||
private static final String TAG_HEAT = "heat_bar";
|
private static final String TAG_HEAT = "heat";
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
public String animationProcedure = "empty";
|
public String animationProcedure = "empty";
|
||||||
public static ItemDisplayContext transformType;
|
public static ItemDisplayContext transformType;
|
||||||
|
@ -57,17 +57,18 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBarVisible(ItemStack pStack) {
|
public boolean isBarVisible(ItemStack pStack) {
|
||||||
return ItemNBTTool.getInt(pStack, TAG_HEAT, 0) != 51;
|
return ItemNBTTool.getDouble(pStack, TAG_HEAT, 0) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBarWidth(ItemStack pStack) {
|
public int getBarWidth(ItemStack pStack) {
|
||||||
return Math.round((float) ItemNBTTool.getInt(pStack, TAG_HEAT, 0) * 13.0F / 51F);
|
return Math.round((float) ItemNBTTool.getDouble(pStack, TAG_HEAT, 0) * 13.0F / 51F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBarColor(ItemStack pStack) {
|
public int getBarColor(ItemStack pStack) {
|
||||||
return 0xFF0000;
|
double f = 1 - ItemNBTTool.getDouble(pStack, TAG_HEAT, 0) / 55.0F;
|
||||||
|
return Mth.hsvToRgb((float) f / 3.0F, 1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,8 +83,7 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HumanoidModel.ArmPose MinigunPose = HumanoidModel.ArmPose.create("Minigun", false, (model, entity, arm) -> {
|
private static final HumanoidModel.ArmPose MinigunPose = HumanoidModel.ArmPose.create("Minigun", false, (model, entity, arm) -> {
|
||||||
if (arm == HumanoidArm.LEFT) {
|
if (arm != HumanoidArm.LEFT) {
|
||||||
} else {
|
|
||||||
model.rightArm.xRot = -0.2F + model.head.xRot;
|
model.rightArm.xRot = -0.2F + model.head.xRot;
|
||||||
model.rightArm.yRot = -0.2F;
|
model.rightArm.yRot = -0.2F;
|
||||||
model.leftArm.xRot = -1F + model.head.xRot;
|
model.leftArm.xRot = -1F + model.head.xRot;
|
||||||
|
@ -108,7 +108,7 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem {
|
||||||
transformType = type;
|
transformType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayState idlePredicate(AnimationState event) {
|
private PlayState idlePredicate(AnimationState<Minigun> event) {
|
||||||
LocalPlayer player = Minecraft.getInstance().player;
|
LocalPlayer player = Minecraft.getInstance().player;
|
||||||
if (player == null) return PlayState.STOP;
|
if (player == null) return PlayState.STOP;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
@ -128,7 +128,7 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem {
|
||||||
return PlayState.STOP;
|
return PlayState.STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayState procedurePredicate(AnimationState event) {
|
private PlayState procedurePredicate(AnimationState<Minigun> event) {
|
||||||
if (transformType != null && transformType.firstPerson()) {
|
if (transformType != null && transformType.firstPerson()) {
|
||||||
if (!this.animationProcedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
if (!this.animationProcedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
||||||
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationProcedure));
|
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationProcedure));
|
||||||
|
@ -186,25 +186,18 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem {
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
super.inventoryTick(itemstack, world, entity, slot, selected);
|
super.inventoryTick(itemstack, world, entity, slot, selected);
|
||||||
if (entity == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
double cooldown = 0;
|
double cooldown = 0;
|
||||||
if(entity.wasInPowderSnow){
|
if (entity.wasInPowderSnow) {
|
||||||
cooldown = 0.75;
|
cooldown = 0.75;
|
||||||
} else if (entity.isInWaterOrRain()){
|
} else if (entity.isInWaterOrRain()) {
|
||||||
cooldown = 0.2;
|
cooldown = 0.2;
|
||||||
} else if (entity.isOnFire() || entity.isInLava()){
|
} else if (entity.isOnFire() || entity.isInLava()) {
|
||||||
cooldown = -0.5;
|
cooldown = -0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemstack.getOrCreateTag().putDouble("heat", Mth.clamp(itemstack.getOrCreateTag().getDouble("heat") - 0.25 - cooldown,0,55));
|
itemstack.getOrCreateTag().putDouble("heat", Mth.clamp(itemstack.getOrCreateTag().getDouble("heat") - 0.25 - cooldown, 0, 55));
|
||||||
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("heat") == 0) {
|
|
||||||
itemstack.getOrCreateTag().putDouble("heat_bar", 51);
|
|
||||||
} else {
|
|
||||||
itemstack.getOrCreateTag().putDouble("heat_bar", (itemstack.getOrCreateTag().getDouble("heat")));
|
|
||||||
}
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("overheat") > 0) {
|
if (itemstack.getOrCreateTag().getDouble("overheat") > 0) {
|
||||||
itemstack.getOrCreateTag().putDouble("overheat", (itemstack.getOrCreateTag().getDouble("overheat") - 1));
|
itemstack.getOrCreateTag().putDouble("overheat", (itemstack.getOrCreateTag().getDouble("overheat") - 1));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue