Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,8 @@
"config.gtceu.option.batchDuration": "uoıʇɐɹnᗡɥɔʇɐq",
"config.gtceu.option.bedrockOreDistance": "ǝɔuɐʇsıᗡǝɹOʞɔoɹpǝq",
"config.gtceu.option.bedrockOreDropTagPrefix": "xıɟǝɹԀbɐ⟘doɹᗡǝɹOʞɔoɹpǝq",
"config.gtceu.option.blockFovChange": "ǝbuɐɥƆʌoℲʞɔoןq",
"config.gtceu.option.blockSpeedChange": "ǝbuɐɥƆpǝǝdSʞɔoןq",
"config.gtceu.option.borderColor": "ɹoןoƆɹǝpɹoq",
"config.gtceu.option.bronzeBoilerHeatSpeed": "pǝǝdSʇɐǝHɹǝןıoᗺǝzuoɹq",
"config.gtceu.option.bronzeBoilerMaxTemperature": "ǝɹnʇɐɹǝdɯǝ⟘xɐWɹǝןıoᗺǝzuoɹq",
Expand Down
2 changes: 2 additions & 0 deletions src/generated/resources/assets/gtceu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,8 @@
"config.gtceu.option.batchDuration": "batchDuration",
"config.gtceu.option.bedrockOreDistance": "bedrockOreDistance",
"config.gtceu.option.bedrockOreDropTagPrefix": "bedrockOreDropTagPrefix",
"config.gtceu.option.blockFovChange": "blockFovChange",
"config.gtceu.option.blockSpeedChange": "blockSpeedChange",
"config.gtceu.option.borderColor": "borderColor",
"config.gtceu.option.bronzeBoilerHeatSpeed": "bronzeBoilerHeatSpeed",
"config.gtceu.option.bronzeBoilerMaxTemperature": "bronzeBoilerMaxTemperature",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import com.gregtechceu.gtceu.common.commands.GTClientCommands;
import com.gregtechceu.gtceu.common.data.GTAttributeModifierIds;
import com.gregtechceu.gtceu.common.data.GTMobEffects;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.core.mixins.client.AbstractClientPlayerAccessor;
import com.gregtechceu.gtceu.core.mixins.client.PlayerSkinAccessor;
import com.gregtechceu.gtceu.data.recipe.CustomTags;
import com.gregtechceu.gtceu.integration.map.ClientCacheManager;

import net.minecraft.ChatFormatting;
Expand All @@ -26,15 +26,13 @@
import net.minecraft.client.resources.PlayerSkin;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.neoforged.api.distmarker.Dist;
Expand Down Expand Up @@ -99,42 +97,45 @@ public static void updateFOV(ComputeFovModifierEvent event) {
if (speedAttribute == null || !speedAttribute.hasModifier(GTAttributeModifierIds.BLOCK_SPEED_BOOST)) {
return;
}
boolean flying = player.getAbilities().flying;
float originalFov = flying ? 1.1F : 1.0F;
float walkSpeed = player.getAbilities().getWalkingSpeed();

float multiplier = 1.0f;
BlockState state = player.level().getBlockState(player.getOnPos());

// inverse of the math done with the speed attribute in AbstractClientPlayer
if (state.is(CustomTags.VERY_FAST_WALKABLE_BLOCKS)) {
// base speed is 0.1, boost is 0.1*0.6 -> boosted speed = 0.16
// the FOV modifier is `1 + (speed / base speed + 1) / 2`, so `1 + (0.16 / 0.1 + 1) / 2 = 1.3`
// thus, divide by 1.3 to get back to original FOV before the 'fast block boost' modifier
multiplier /= 1.3f;
} else if (state.is(CustomTags.FAST_WALKABLE_BLOCKS)) {
// same as above but the speed boost is 0.25
multiplier /= 1.125f;
originalFov *= ((float) speedAttribute.getBaseValue() / walkSpeed + 1.0F) / 2.0F;
if (walkSpeed == 0.0F || Float.isNaN(originalFov) ||
Float.isInfinite(originalFov)) {
return;
}

multiplier = (float) Mth.lerp(Minecraft.getInstance().options.fovEffectScale().get(), 1.0, multiplier);
event.setNewFovModifier(event.getNewFovModifier() * multiplier);
float newFov = flying ? 1.1F : 1.0F;
newFov *= ((float) getValueWithoutWalkingBoost(speedAttribute) / walkSpeed + 1.0F) /
2.0F;

event.setNewFovModifier(newFov / originalFov);
}

private static double getValueWithoutWalkingBoost(AttributeInstance attribute) {
double base = attribute.getBaseValue();
Map<AttributeModifier.Operation, List<AttributeModifier>> modifiers = attribute.getModifiers().stream()
.collect(Collectors.groupingBy(AttributeModifier::operation));

for (AttributeModifier mod : modifiers.get(AttributeModifier.Operation.ADD_VALUE)) {
base += mod.amount();
if (modifiers.get(AttributeModifier.Operation.ADD_VALUE) != null) {
for (AttributeModifier mod : modifiers.get(AttributeModifier.Operation.ADD_VALUE)) {
base += mod.amount();
}
}

double applied = base;
for (AttributeModifier mod : modifiers.get(AttributeModifier.Operation.ADD_MULTIPLIED_BASE)) {
if (mod.id() == GTAttributeModifierIds.BLOCK_SPEED_BOOST) continue;
if (mod.id() == GTAttributeModifierIds.BLOCK_SPEED_BOOST || !ConfigHolder.INSTANCE.client.blockFovChange)
continue;
applied += base * mod.amount();
}

for (AttributeModifier mod : modifiers.get(AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL)) {
applied *= 1 + mod.amount();
if (modifiers.get(AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL) != null) {
for (AttributeModifier mod : modifiers.get(AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL)) {
applied *= 1 + mod.amount();
}
}

return attribute.getAttribute().value().sanitizeValue(applied);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public static void breakSpeed(PlayerEvent.BreakSpeed event) {
@SubscribeEvent
public static void playerTickEvent(PlayerTickEvent.Pre event) {
Player player = event.getEntity();
if (!player.level().isClientSide) {
if (!player.level().isClientSide && ConfigHolder.INSTANCE.gameplay.blockSpeedChange) {
var speedAttrib = player.getAttribute(Attributes.MOVEMENT_SPEED);
if (speedAttrib == null) return;
var speedMod = speedAttrib.getModifier(GTAttributeModifierIds.BLOCK_SPEED_BOOST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@ public static class GameplayConfigs {
@Configurable.Comment({ "List of domains that are allowed in the image module" })
public String[] allowedImageDomains = new String[] { "imgur.com", "discord.com", "github.com",
"raw.githubusercontent.com" };
@Configurable
@Configurable.Comment({ "Whether or not speed-modifying blocks should change player's speed." })
public boolean blockSpeedChange = true;
}

public static class ClientConfigs {
Expand Down Expand Up @@ -798,6 +801,9 @@ public static class ClientConfigs {
public RendererOptions renderer = new RendererOptions();
@Configurable
public TankItemFluidPreview tankItemFluidPreview = new TankItemFluidPreview();
@Configurable
@Configurable.Comment({ "Whether or not speed-modifying blocks should change player's FOV." })
public boolean blockFovChange = true;

public int getDefaultPaintingColor() {
// OR with full alpha to differentiate from a machine that's painted white (map color 0xffffff)
Expand Down
Loading