修改Pose相关代码

This commit is contained in:
17146 2024-08-24 23:33:44 +08:00
parent 9e1523d6be
commit b79a67cf60
43 changed files with 242 additions and 252 deletions

View file

@ -14,7 +14,7 @@ def getGitCommitHash() {
return stdout.toString().trim()
}
version = '0.1.7-SNAPSHOT-' + getGitCommitHash()
version = '0.1.8-SNAPSHOT-' + getGitCommitHash()
group = 'com.Atsushio.superbwarfare'
archivesBaseName = 'superbwarfare'

View file

@ -92,12 +92,12 @@ public class ModUtils {
}
public void onCommonSetup(final FMLCommonSetupEvent event) {
addNetworkMessage(ZoomMessage.class, ZoomMessage::buffer, ZoomMessage::new, ZoomMessage::handler);
addNetworkMessage(DoubleJumpMessage.class, DoubleJumpMessage::buffer, DoubleJumpMessage::new, DoubleJumpMessage::handler);
addNetworkMessage(ZoomMessage.class, ZoomMessage::encode, ZoomMessage::decode, ZoomMessage::handler);
addNetworkMessage(DoubleJumpMessage.class, DoubleJumpMessage::encode, DoubleJumpMessage::decode, DoubleJumpMessage::handler);
addNetworkMessage(GunsDataMessage.class, GunsDataMessage::encode, GunsDataMessage::decode, GunsDataMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
addNetworkMessage(FireMessage.class, FireMessage::buffer, FireMessage::new, FireMessage::handler);
addNetworkMessage(VehicleFireMessage.class, VehicleFireMessage::buffer, VehicleFireMessage::new, VehicleFireMessage::handler);
addNetworkMessage(FireModeMessage.class, FireModeMessage::buffer, FireModeMessage::new, FireModeMessage::handler);
addNetworkMessage(FireMessage.class, FireMessage::encode, FireMessage::new, FireMessage::handler);
addNetworkMessage(VehicleFireMessage.class, VehicleFireMessage::encode, VehicleFireMessage::new, VehicleFireMessage::handler);
addNetworkMessage(FireModeMessage.class, FireModeMessage::encode, FireModeMessage::new, FireModeMessage::handler);
addNetworkMessage(ReloadMessage.class, ReloadMessage::encode, ReloadMessage::decode, ReloadMessage::handler);
addNetworkMessage(PlayerGunKillMessage.class, PlayerGunKillMessage::encode, PlayerGunKillMessage::decode, PlayerGunKillMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
addNetworkMessage(ClientIndicatorMessage.class, ClientIndicatorMessage::encode, ClientIndicatorMessage::decode, ClientIndicatorMessage::handler, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
@ -106,11 +106,11 @@ public class ModUtils {
addNetworkMessage(AdjustMortarAngleMessage.class, AdjustMortarAngleMessage::encode, AdjustMortarAngleMessage::decode, AdjustMortarAngleMessage::handler);
addNetworkMessage(InteractMessage.class, InteractMessage::encode, InteractMessage::decode, InteractMessage::handler);
addNetworkMessage(DroneMovementMessage.class, DroneMovementMessage::encode, DroneMovementMessage::decode, DroneMovementMessage::handler);
addNetworkMessage(DroneFireMessage.class, DroneFireMessage::buffer, DroneFireMessage::new, DroneFireMessage::handler);
addNetworkMessage(DroneFireMessage.class, DroneFireMessage::encode, DroneFireMessage::new, DroneFireMessage::handler);
addNetworkMessage(SimulationDistanceMessage.class, SimulationDistanceMessage::encode, SimulationDistanceMessage::decode, SimulationDistanceMessage::handle, Optional.of(NetworkDirection.PLAY_TO_CLIENT));
addNetworkMessage(GunReforgeMessage.class, GunReforgeMessage::encode, GunReforgeMessage::decode, GunReforgeMessage::handler);
addNetworkMessage(SetPerkLevelMessage.class, SetPerkLevelMessage::encode, SetPerkLevelMessage::decode, SetPerkLevelMessage::handler);
addNetworkMessage(BreathMessage.class, BreathMessage::buffer, BreathMessage::new, BreathMessage::handler);
addNetworkMessage(BreathMessage.class, BreathMessage::encode, BreathMessage::decode, BreathMessage::handler);
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));

View file

@ -31,7 +31,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
import java.util.Comparator;
public class ClaymoreEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity{
public class ClaymoreEntity extends ThrowableItemProjectile implements GeoEntity, AnimatedEntity {
public static final EntityDataAccessor<String> ANIMATION = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.STRING);
public static final EntityDataAccessor<Float> ROT_Y = SynchedEntityData.defineId(ClaymoreEntity.class, EntityDataSerializers.FLOAT);
@ -159,12 +159,13 @@ public class ClaymoreEntity extends ThrowableItemProjectile implements GeoEntity
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
}
@Override
protected void updateRotation() {
this.setXRot(0);
this.setYRot(this.entityData.get(ROT_Y));
}
@Override
public EntityDimensions getDimensions(Pose p_33597_) {
return super.getDimensions(p_33597_).scale((float) 0.5);

View file

@ -80,7 +80,7 @@ public class MortarShellEntity extends ThrowableItemProjectile {
super.onHitBlock(blockHitResult);
BlockPos resultPos = blockHitResult.getBlockPos();
BlockState state = this.level().getBlockState(resultPos);
if(state.getBlock() instanceof BellBlock bell) {
if (state.getBlock() instanceof BellBlock bell) {
bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection());
}
if (!this.level().isClientSide() && this.level() instanceof ServerLevel) {

View file

@ -94,7 +94,6 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
@Override
public boolean hurt(DamageSource source, float amount) {
if (source.is(DamageTypes.IN_FIRE)
|| source.getDirectEntity() instanceof ThrownPotion
|| source.getDirectEntity() instanceof AreaEffectCloud
@ -149,7 +148,7 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
if (sourceEntity instanceof Player player) {
player.displayClientMessage(Component.literal(("Target Down " + new java.text.DecimalFormat("##.#").format((entity.position()).distanceTo((sourceEntity.position()))) + "M")), true);
SoundTool.playLocalSound(player, ModSounds.TARGET_DOWN.get(), 100, 1);
((TargetEntity) entity).entityData.set(DOWN_TIME,90);
((TargetEntity) entity).entityData.set(DOWN_TIME, 90);
}
}
}
@ -193,11 +192,10 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
public void baseTick() {
super.baseTick();
if (this.entityData.get(DOWN_TIME) > 0) {
this.entityData.set(DOWN_TIME,this.entityData.get(DOWN_TIME) - 1);
this.entityData.set(DOWN_TIME, this.entityData.get(DOWN_TIME) - 1);
}
}
@Override
public boolean isPushable() {
return false;
@ -227,9 +225,6 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
this.setNoGravity(true);
}
public static void init() {
}
public static AttributeSupplier.Builder createAttributes() {
return Mob.createMobAttributes()
.add(Attributes.MOVEMENT_SPEED, 0)
@ -241,7 +236,6 @@ public class TargetEntity extends PathfinderMob implements GeoEntity, AnimatedEn
.add(Attributes.FLYING_SPEED, 0);
}
@Override
protected void tickDeath() {
++this.deathTime;

View file

@ -11,7 +11,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.lwjgl.glfw.GLFW;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = {Dist.CLIENT})
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ModKeyMappings {
public static final KeyMapping RELOAD = new KeyMapping("key.superbwarfare.reload", GLFW.GLFW_KEY_R, "key.categories.superbwarfare") {
private boolean isDownOld = false;
@ -34,9 +34,9 @@ public class ModKeyMappings {
super.setDown(isDown);
if (isDownOld != isDown && isDown) {
ModUtils.PACKET_HANDLER.sendToServer(new DoubleJumpMessage(0));
if (Minecraft.getInstance().player != null) {
DoubleJumpMessage.pressAction(Minecraft.getInstance().player, 0);
}
// if (Minecraft.getInstance().player != null) {
// DoubleJumpMessage.pressAction(Minecraft.getInstance().player, 0);
// }
}
isDownOld = isDown;
}
@ -106,9 +106,7 @@ public class ModKeyMappings {
super.setDown(isDown);
if (isDownOld != isDown && isDown) {
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(2, true));
FORWARD_LASTPRESS = System.currentTimeMillis();
} else if (isDownOld != isDown) {
int dt = (int) (System.currentTimeMillis() - FORWARD_LASTPRESS);
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(2, false));
}
isDownOld = isDown;
@ -122,9 +120,7 @@ public class ModKeyMappings {
super.setDown(isDown);
if (isDownOld != isDown && isDown) {
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(3, true));
BACKWARD_LASTPRESS = System.currentTimeMillis();
} else if (isDownOld != isDown) {
int dt = (int) (System.currentTimeMillis() - BACKWARD_LASTPRESS);
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(3, false));
}
isDownOld = isDown;
@ -138,9 +134,7 @@ public class ModKeyMappings {
super.setDown(isDown);
if (isDownOld != isDown && isDown) {
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(0, true));
LEFT_LASTPRESS = System.currentTimeMillis();
} else if (isDownOld != isDown) {
int dt = (int) (System.currentTimeMillis() - LEFT_LASTPRESS);
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(0, false));
}
isDownOld = isDown;
@ -154,9 +148,7 @@ public class ModKeyMappings {
super.setDown(isDown);
if (isDownOld != isDown && isDown) {
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(1, true));
RIGHT_LASTPRESS = System.currentTimeMillis();
} else if (isDownOld != isDown) {
int dt = (int) (System.currentTimeMillis() - RIGHT_LASTPRESS);
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(1, false));
}
isDownOld = isDown;
@ -170,9 +162,7 @@ public class ModKeyMappings {
super.setDown(isDown);
if (isDownOld != isDown && isDown) {
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(4, true));
UP_LASTPRESS = System.currentTimeMillis();
} else if (isDownOld != isDown) {
int dt = (int) (System.currentTimeMillis() - UP_LASTPRESS);
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(4, false));
}
isDownOld = isDown;
@ -186,9 +176,7 @@ public class ModKeyMappings {
super.setDown(isDown);
if (isDownOld != isDown && isDown) {
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(5, true));
DOWN_LASTPRESS = System.currentTimeMillis();
} else if (isDownOld != isDown) {
int dt = (int) (System.currentTimeMillis() - DOWN_LASTPRESS);
ModUtils.PACKET_HANDLER.sendToServer(new DroneMovementMessage(5, false));
}
isDownOld = isDown;
@ -203,23 +191,13 @@ public class ModKeyMappings {
super.setDown(isDown);
if (isDownOld != isDown && isDown) {
ModUtils.PACKET_HANDLER.sendToServer(new BreathMessage(true));
BREATH_LASTPRESS = System.currentTimeMillis();
} else if (isDownOld != isDown) {
int dt = (int) (System.currentTimeMillis() - BREATH_LASTPRESS);
ModUtils.PACKET_HANDLER.sendToServer(new BreathMessage(false));
}
isDownOld = isDown;
}
};
private static long FORWARD_LASTPRESS = 0;
private static long BACKWARD_LASTPRESS = 0;
private static long LEFT_LASTPRESS = 0;
private static long RIGHT_LASTPRESS = 0;
private static long UP_LASTPRESS = 0;
private static long DOWN_LASTPRESS = 0;
private static long BREATH_LASTPRESS = 0;
@SubscribeEvent
public static void registerKeyMappings(RegisterKeyMappingsEvent event) {
event.register(RELOAD);

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -68,7 +69,7 @@ public class AK47Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.RarityTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
@ -68,7 +69,7 @@ public class Aa12Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -69,7 +70,7 @@ public class Abekiri extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,12 +9,11 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
@ -24,8 +23,10 @@ import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.*;
import net.minecraft.world.level.Level;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import software.bernie.geckolib.animatable.GeoItem;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
@ -36,7 +37,6 @@ import software.bernie.geckolib.core.animation.RawAnimation;
import software.bernie.geckolib.core.object.PlayState;
import software.bernie.geckolib.util.GeckoLibUtil;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
@ -63,12 +63,11 @@ public class Devotion extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}
public void getTransformType(ItemDisplayContext type) {
transformType = type;
}
@ -148,11 +147,6 @@ public class Devotion extends GunItem implements GeoItem, AnimatedItem {
return map;
}
@Override
public void appendHoverText(ItemStack stack, Level world, List<Component> list, TooltipFlag flag) {
TooltipTool.addGunTips(list, stack);
}
@Override
public Set<SoundEvent> getReloadSound() {
return Set.of(ModSounds.DEVOTION_RELOAD_EMPTY.get(), ModSounds.DEVOTION_RELOAD_NORMAL.get());

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -66,7 +67,7 @@ public class Glock17Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -66,7 +67,7 @@ public class Glock18Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -63,7 +64,7 @@ public class Hk416Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -68,7 +69,7 @@ public class HuntingRifle extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -66,7 +67,7 @@ public class K98Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -66,7 +67,7 @@ public class M1911Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -63,7 +64,7 @@ public class M4Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -63,7 +64,7 @@ public class M60Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -70,7 +71,7 @@ public class M79Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -64,7 +65,7 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -63,7 +64,7 @@ public class M98bItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -64,7 +65,7 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -63,7 +64,7 @@ public class Mk14Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.RarityTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
@ -76,7 +77,7 @@ public class Ntw20 extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -66,7 +67,7 @@ public class Qbz95Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -65,7 +66,7 @@ public class RpgItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -63,7 +64,7 @@ public class RpkItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -10,6 +10,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.RarityTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
@ -111,7 +112,7 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -68,7 +69,7 @@ public class SksItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -63,7 +64,7 @@ public class SvdItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,10 +9,7 @@ import net.mcreator.superbwarfare.init.ModItems;
import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.EnchantmentCategoryTool;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.ItemNBTTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.mcreator.superbwarfare.tools.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer;
@ -93,7 +90,7 @@ public class Taser extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.RarityTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.ChatFormatting;
@ -75,7 +76,7 @@ public class Trachelium extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -9,6 +9,7 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.PoseTool;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
@ -63,7 +64,7 @@ public class VectorItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public HumanoidModel.ArmPose getArmPose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
return GunsTool.pose(entityLiving, hand, stack);
return PoseTool.pose(entityLiving, hand, stack);
}
});
}

View file

@ -2,7 +2,7 @@ package net.mcreator.superbwarfare.network.message;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.player.Player;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkEvent;
@ -15,45 +15,44 @@ public class BreathMessage {
this.type = type;
}
public BreathMessage(FriendlyByteBuf buffer) {
this.type = buffer.readBoolean();
public static BreathMessage decode(FriendlyByteBuf buffer) {
return new BreathMessage(buffer.readBoolean());
}
public static void buffer(BreathMessage message, FriendlyByteBuf buffer) {
public static void encode(BreathMessage message, FriendlyByteBuf buffer) {
buffer.writeBoolean(message.type);
}
public static void handler(BreathMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
NetworkEvent.Context context = contextSupplier.get();
context.enqueueWork(() -> {
if (context.getSender() != null) {
pressAction(context.getSender(), message.type);
ServerPlayer player = context.getSender();
if (player != null) {
Level level = player.level();
if (!level.isLoaded(player.blockPosition())) {
return;
}
var cap = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
if (message.type && !cap.orElse(new ModVariables.PlayerVariables()).breathExhaustion && cap.orElse(new ModVariables.PlayerVariables()).zooming &&
player.getPersistentData().getDouble("NoBreath") == 0) {
cap.ifPresent(capability -> {
capability.breath = true;
capability.syncPlayerVariables(player);
});
}
if (!message.type) {
cap.ifPresent(capability -> {
capability.breath = false;
capability.syncPlayerVariables(player);
});
}
}
});
context.setPacketHandled(true);
}
public static void pressAction(Player entity, boolean type) {
Level world = entity.level();
if (!world.isLoaded(entity.blockPosition())) {
return;
}
var cap = entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null);
if (type && !cap.orElse(new ModVariables.PlayerVariables()).breathExhaustion && cap.orElse(new ModVariables.PlayerVariables()).zooming && entity.getPersistentData().getDouble("NoBreath") == 0) {
cap.ifPresent(capability -> {
capability.breath = true;
capability.syncPlayerVariables(entity);
});
}
if (!type) {
cap.ifPresent(capability -> {
capability.breath = false;
capability.syncPlayerVariables(entity);
});
}
}
}

View file

@ -4,8 +4,8 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.network.ModVariables;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.NetworkEvent;
@ -19,47 +19,46 @@ public class DoubleJumpMessage {
this.type = type;
}
public DoubleJumpMessage(FriendlyByteBuf buffer) {
this.type = buffer.readInt();
public static DoubleJumpMessage decode(FriendlyByteBuf buffer) {
return new DoubleJumpMessage(buffer.readInt());
}
public static void buffer(DoubleJumpMessage message, FriendlyByteBuf buffer) {
public static void encode(DoubleJumpMessage message, FriendlyByteBuf buffer) {
buffer.writeInt(message.type);
}
public static void handler(DoubleJumpMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
NetworkEvent.Context context = contextSupplier.get();
context.enqueueWork(() -> {
if (context.getSender() != null) {
pressAction(context.getSender(), message.type);
ServerPlayer player = context.getSender();
if (player != null) {
Level level = player.level();
double x = player.getX();
double y = player.getY();
double z = player.getZ();
if (!level.isLoaded(player.blockPosition())) {
return;
}
if (message.type == 0) {
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).playerDoubleJump) {
player.setDeltaMovement(new Vec3(player.getLookAngle().x, 0.8, player.getLookAngle().z));
if (!level.isClientSide()) {
level.playSound(null, BlockPos.containing(x, y, z), ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1);
} else {
level.playLocalSound(x, y, z, ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1, false);
}
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.playerDoubleJump = false;
capability.syncPlayerVariables(player);
});
}
}
}
});
context.setPacketHandled(true);
}
public static void pressAction(Player entity, int type) {
Level level = entity.level();
double x = entity.getX();
double y = entity.getY();
double z = entity.getZ();
if (!level.hasChunkAt(entity.blockPosition())) {
return;
}
if (type == 0) {
if ((entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).playerDoubleJump) {
entity.setDeltaMovement(new Vec3((1 * entity.getLookAngle().x), 0.8, (1 * entity.getLookAngle().z)));
if (!level.isClientSide()) {
level.playSound(null, BlockPos.containing(x, y, z), ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1);
} else {
level.playLocalSound(x, y, z, ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1, false);
}
entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.playerDoubleJump = false;
capability.syncPlayerVariables(entity);
});
}
}
}
}

View file

@ -20,7 +20,7 @@ public class DroneFireMessage {
this.type = buffer.readInt();
}
public static void buffer(DroneFireMessage message, FriendlyByteBuf buffer) {
public static void encode(DroneFireMessage message, FriendlyByteBuf buffer) {
buffer.writeInt(message.type);
}

View file

@ -38,7 +38,7 @@ public class FireMessage {
this.type = buffer.readInt();
}
public static void buffer(FireMessage message, FriendlyByteBuf buffer) {
public static void encode(FireMessage message, FriendlyByteBuf buffer) {
buffer.writeInt(message.type);
}

View file

@ -26,7 +26,7 @@ public class FireModeMessage {
this.type = buffer.readInt();
}
public static void buffer(FireModeMessage message, FriendlyByteBuf buffer) {
public static void encode(FireModeMessage message, FriendlyByteBuf buffer) {
buffer.writeInt(message.type);
}

View file

@ -40,8 +40,10 @@ public class ReloadMessage {
public static void pressAction(Player player, int type) {
Level level = player.level();
if (!level.isLoaded(player.blockPosition()))
if (!level.isLoaded(player.blockPosition())) {
return;
}
if (type == 0) {
ItemStack stack = player.getMainHandItem();
var capability = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables());
@ -54,13 +56,11 @@ public class ReloadMessage {
) {
CompoundTag tag = stack.getOrCreateTag();
boolean can_single_reload = tag.getDouble("iterative_time") != 0;
boolean can_reload = (tag.getDouble("normal_reload_time") != 0 || tag.getDouble("empty_reload_time") != 0) && tag.getDouble("clipLoad") != 1;
boolean canSingleReload = tag.getDouble("iterative_time") != 0;
boolean canReload = (tag.getDouble("normal_reload_time") != 0 || tag.getDouble("empty_reload_time") != 0) && tag.getDouble("clipLoad") != 1;
boolean clipLoad = tag.getInt("ammo") == 0 && tag.getDouble("clipLoad") == 1;
//检查备弹
// 检查备弹
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
return;
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
@ -77,7 +77,7 @@ public class ReloadMessage {
return;
}
if (can_reload || clipLoad) {
if (canReload || clipLoad) {
if (stack.is(ModTags.Items.OPEN_BOLT)) {
if (stack.getItem() == ModItems.M_60.get() || stack.getItem() == ModItems.ABEKIRI.get()) {
if (tag.getInt("ammo") < tag.getDouble("mag")) {
@ -94,7 +94,7 @@ public class ReloadMessage {
return;
}
if (can_single_reload) {
if (canSingleReload) {
if (tag.getInt("ammo") < tag.getDouble("mag")) {
tag.putBoolean("start_single_reload", true);
}

View file

@ -19,7 +19,7 @@ public class VehicleFireMessage {
this.type = buffer.readInt();
}
public static void buffer(VehicleFireMessage message, FriendlyByteBuf buffer) {
public static void encode(VehicleFireMessage message, FriendlyByteBuf buffer) {
buffer.writeInt(message.type);
}

View file

@ -6,7 +6,6 @@ import net.mcreator.superbwarfare.network.ModVariables;
import net.mcreator.superbwarfare.tools.SoundTool;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraftforge.network.NetworkEvent;
@ -19,60 +18,53 @@ public class ZoomMessage {
this.type = type;
}
public ZoomMessage(FriendlyByteBuf buffer) {
this.type = buffer.readInt();
public static ZoomMessage decode(FriendlyByteBuf buffer) {
return new ZoomMessage(buffer.readInt());
}
public static void buffer(ZoomMessage message, FriendlyByteBuf buffer) {
public static void encode(ZoomMessage message, FriendlyByteBuf buffer) {
buffer.writeInt(message.type);
}
public static void handler(ZoomMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
NetworkEvent.Context context = contextSupplier.get();
context.enqueueWork(() -> {
if (context.getSender() != null) {
pressAction(context.getSender(), message.type);
ServerPlayer player = context.getSender();
if (player != null) {
Level level = player.level();
if (!level.isLoaded(player.blockPosition())) {
return;
}
if (message.type == 0) {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.zoom = true;
capability.syncPlayerVariables(player);
});
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity) {
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
}
}
if (message.type == 1) {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.zoom = false;
capability.syncPlayerVariables(player);
});
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.zooming = false;
capability.syncPlayerVariables(player);
});
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity) {
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
}
}
}
});
context.setPacketHandled(true);
}
public static void pressAction(Player entity, int type) {
Level world = entity.level();
if (!world.isLoaded(entity.blockPosition())) {
return;
}
if (type == 0) {
entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.zoom = true;
capability.syncPlayerVariables(entity);
});
if (entity.isPassenger() && entity.getVehicle() instanceof ICannonEntity) {
if (entity instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
}
}
}
if (type == 1) {
entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.zoom = false;
capability.syncPlayerVariables(entity);
});
entity.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.zooming = false;
capability.syncPlayerVariables(entity);
});
if (entity.isPassenger() && entity.getVehicle() instanceof ICannonEntity) {
if (entity instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
}
}
}
}
}

View file

@ -4,15 +4,10 @@ import com.google.gson.stream.JsonReader;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.network.ModVariables;
import net.mcreator.superbwarfare.network.message.GunsDataMessage;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
@ -143,45 +138,4 @@ public class GunsTool {
tag.putBoolean("is_empty_reloading", false);
}
public static HumanoidModel.ArmPose pose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")
|| stack.getOrCreateTag().getBoolean("is_normal_reloading")
|| stack.getOrCreateTag().getBoolean("reloading")
|| stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
return ReloadPose;
} else if (entityLiving.isSprinting() && entityLiving.onGround() && entityLiving.getPersistentData().getDouble("noRun") == 0) {
if (entityLiving.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return TacticalSprintPose;
} else {
return SprintPose;
}
} else {
return HumanoidModel.ArmPose.BOW_AND_ARROW;
}
}
private static final HumanoidModel.ArmPose ReloadPose = HumanoidModel.ArmPose.create("ReloadPose", false, (model, entity, arm) -> {
if (arm == HumanoidArm.RIGHT) {
model.rightArm.xRot = -45F * Mth.DEG_TO_RAD;
model.rightArm.yRot = model.head.yRot - 22.5F * Mth.DEG_TO_RAD;
model.leftArm.xRot = -60F * Mth.DEG_TO_RAD;
model.leftArm.yRot = model.head.yRot + 22.5F * Mth.DEG_TO_RAD;
}
});
private static final HumanoidModel.ArmPose SprintPose = HumanoidModel.ArmPose.create("SprintPose", false, (model, entity, arm) -> {
if (arm == HumanoidArm.RIGHT) {
model.rightArm.xRot = -45F * Mth.DEG_TO_RAD;
model.rightArm.yRot = model.head.yRot - 50F * Mth.DEG_TO_RAD;
model.leftArm.xRot = -45F * Mth.DEG_TO_RAD;
model.leftArm.yRot = model.head.yRot + 22.5F * Mth.DEG_TO_RAD;
}
});
private static final HumanoidModel.ArmPose TacticalSprintPose = HumanoidModel.ArmPose.create("TacticalSprintPose", false, (model, entity, arm) -> {
if (arm == HumanoidArm.RIGHT) {
model.rightArm.xRot = 0.2f * model.rightArm.xRot -155F * Mth.DEG_TO_RAD;
model.rightArm.zRot = -5F * Mth.DEG_TO_RAD;
}
});
}

View file

@ -0,0 +1,57 @@
package net.mcreator.superbwarfare.tools;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class PoseTool {
private static final HumanoidModel.ArmPose ReloadPose = HumanoidModel.ArmPose.create("ReloadPose", false, (model, entity, arm) -> {
if (arm == HumanoidArm.RIGHT) {
model.rightArm.xRot = -45F * Mth.DEG_TO_RAD;
model.rightArm.yRot = model.head.yRot - 22.5F * Mth.DEG_TO_RAD;
model.leftArm.xRot = -60F * Mth.DEG_TO_RAD;
model.leftArm.yRot = model.head.yRot + 22.5F * Mth.DEG_TO_RAD;
}
});
private static final HumanoidModel.ArmPose SprintPose = HumanoidModel.ArmPose.create("SprintPose", false, (model, entity, arm) -> {
if (arm == HumanoidArm.RIGHT) {
model.rightArm.xRot = -45F * Mth.DEG_TO_RAD;
model.rightArm.yRot = model.head.yRot - 50F * Mth.DEG_TO_RAD;
model.leftArm.xRot = -45F * Mth.DEG_TO_RAD;
model.leftArm.yRot = model.head.yRot + 22.5F * Mth.DEG_TO_RAD;
}
});
private static final HumanoidModel.ArmPose TacticalSprintPose = HumanoidModel.ArmPose.create("TacticalSprintPose", false, (model, entity, arm) -> {
if (arm == HumanoidArm.RIGHT) {
model.rightArm.xRot = 0.2f * model.rightArm.xRot - 155F * Mth.DEG_TO_RAD;
model.rightArm.zRot = -5F * Mth.DEG_TO_RAD;
}
});
public static HumanoidModel.ArmPose pose(LivingEntity entityLiving, InteractionHand hand, ItemStack stack) {
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")
|| stack.getOrCreateTag().getBoolean("is_normal_reloading")
|| stack.getOrCreateTag().getBoolean("reloading")
|| stack.getOrCreateTag().getBoolean("sentinel_is_charging")) {
return ReloadPose;
} else if (entityLiving.isSprinting() && entityLiving.onGround() && entityLiving.getPersistentData().getDouble("noRun") == 0) {
if (entityLiving.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return TacticalSprintPose;
} else {
return SprintPose;
}
} else {
return HumanoidModel.ArmPose.BOW_AND_ARROW;
}
}
}