use of mekanism.common.content.gear.mekasuit.ModuleJetpackUnit in project Mekanism by mekanism.
the class ClientTickHandler method tickStart.
public void tickStart() {
MekanismClient.ticksPassed++;
if (firstTick && minecraft.level != null) {
MekanismClient.launchClient();
firstTick = false;
}
if (minecraft.level != null) {
shouldReset = true;
} else if (shouldReset) {
MekanismClient.reset();
shouldReset = false;
}
if (minecraft.level != null && minecraft.player != null && !minecraft.isPaused()) {
if (!initHoliday || MekanismClient.ticksPassed % 1_200 == 0) {
HolidayManager.notify(Minecraft.getInstance().player);
initHoliday = true;
}
// Reboot player sounds if needed
SoundHandler.restartSounds();
if (minecraft.level.getGameTime() - lastScrollTime > 20) {
scrollDelta = 0;
}
RadiationManager.INSTANCE.tickClient(minecraft.player);
UUID playerUUID = minecraft.player.getUUID();
// Update player's state for various items; this also automatically notifies server if something changed and
// kicks off sounds as necessary
Mekanism.playerState.setJetpackState(playerUUID, isJetpackActive(minecraft.player), true);
Mekanism.playerState.setScubaMaskState(playerUUID, isScubaMaskOn(minecraft.player), true);
Mekanism.playerState.setGravitationalModulationState(playerUUID, isGravitationalModulationOn(minecraft.player), true);
Mekanism.playerState.setFlamethrowerState(playerUUID, hasFlamethrower(minecraft.player), isFlamethrowerOn(minecraft.player), true);
for (Iterator<Entry<PlayerEntity, TeleportData>> iter = portableTeleports.entrySet().iterator(); iter.hasNext(); ) {
Entry<PlayerEntity, TeleportData> entry = iter.next();
PlayerEntity player = entry.getKey();
for (int i = 0; i < 100; i++) {
double x = player.getX() + rand.nextDouble() - 0.5D;
double y = player.getY() + rand.nextDouble() * 2 - 2D;
double z = player.getZ() + rand.nextDouble() - 0.5D;
minecraft.level.addParticle(ParticleTypes.PORTAL, x, y, z, 0, 1, 0);
}
TeleportData data = entry.getValue();
if (minecraft.level.getGameTime() == data.teleportTime) {
Mekanism.packetHandler.sendToServer(new PacketPortableTeleporterTeleport(data.hand, data.identity));
iter.remove();
}
}
ItemStack chestStack = minecraft.player.getItemBySlot(EquipmentSlotType.CHEST);
IModule<ModuleJetpackUnit> jetpackModule = MekanismAPI.getModuleHelper().load(chestStack, MekanismModules.JETPACK_UNIT);
if (!chestStack.isEmpty() && (chestStack.getItem() instanceof ItemJetpack || jetpackModule != null)) {
MekanismClient.updateKey(minecraft.player.input.jumping, KeySync.ASCEND);
}
if (isJetpackActive(minecraft.player)) {
JetpackMode mode = CommonPlayerTickHandler.getJetpackMode(chestStack);
if (CommonPlayerTickHandler.handleJetpackMotion(minecraft.player, mode, () -> minecraft.player.input.jumping)) {
minecraft.player.fallDistance = 0.0F;
}
}
if (isScubaMaskOn(minecraft.player) && minecraft.player.getAirSupply() == minecraft.player.getMaxAirSupply()) {
for (EffectInstance effect : minecraft.player.getActiveEffects()) {
for (int i = 0; i < 9; i++) {
MekanismUtils.speedUpEffectSafely(minecraft.player, effect);
}
}
}
if (isVisionEnhancementOn(minecraft.player)) {
visionEnhancement = true;
// adds if it doesn't exist, otherwise tops off duration to 220. equal or less than 200 will make vision flickers
minecraft.player.addEffect(new EffectInstance(Effects.NIGHT_VISION, 220, 0, false, true, false));
} else if (visionEnhancement) {
visionEnhancement = false;
EffectInstance effect = minecraft.player.getEffect(Effects.NIGHT_VISION);
if (effect != null && effect.getDuration() <= 220) {
// Only remove it if it is our effect and not one that has a longer remaining duration
minecraft.player.removeEffect(Effects.NIGHT_VISION);
}
}
ItemStack stack = minecraft.player.getItemBySlot(EquipmentSlotType.MAINHAND);
if (MekKeyHandler.isRadialPressed() && stack.getItem() instanceof IRadialModeItem) {
if (minecraft.screen == null || minecraft.screen instanceof GuiRadialSelector) {
updateSelectorRenderer((IRadialModeItem<?>) stack.getItem());
}
} else if (minecraft.screen instanceof GuiRadialSelector) {
minecraft.setScreen(null);
}
if (MekanismConfig.client.enablePlayerSounds.get()) {
RadiationScale scale = RadiationManager.INSTANCE.getClientScale();
if (scale != RadiationScale.NONE && !SoundHandler.radiationSoundMap.containsKey(scale)) {
GeigerSound sound = GeigerSound.create(minecraft.player, scale);
SoundHandler.radiationSoundMap.put(scale, sound);
SoundHandler.playSound(sound);
}
}
}
}
Aggregations