-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add features for 1.20.4, 1.19.4, 1.19.2, 1.17.1, 1.16.5, 1.15.2 (#30)
- Loading branch information
Showing
126 changed files
with
9,144 additions
and
1,842 deletions.
There are no files selected for viewing
401 changes: 165 additions & 236 deletions
401
...e/fg-6.0/1.15.2/src/main/java/com/therainbowville/minegasm/client/ClientEventHandler.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
...-6.0/1.15.2/src/main/java/com/therainbowville/minegasm/common/AbstractVibrationState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package com.therainbowville.minegasm.common; | ||
|
||
import java.util.Map; | ||
import java.util.HashMap; | ||
|
||
import com.therainbowville.minegasm.config.ClientConfig; | ||
import com.therainbowville.minegasm.config.MinegasmConfig; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
// Architecture inspired from https://github.com/Fyustorm/mInetiface | ||
public abstract class AbstractVibrationState | ||
{ | ||
|
||
protected static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger(); | ||
protected final float streakCountdownAmount; | ||
protected float intensity; | ||
|
||
protected float vibrationCountdown; | ||
protected float vibrationFeedbackCountdown; | ||
|
||
protected AbstractVibrationState(float streakSeconds) | ||
{ | ||
streakCountdownAmount = streakSeconds; | ||
vibrationCountdown = 0; | ||
vibrationFeedbackCountdown = 0; | ||
intensity = 0; | ||
} | ||
|
||
public void onTick() | ||
{ | ||
if (accumulationEnabled()) | ||
{ | ||
if (vibrationCountdown > 0) | ||
vibrationCountdown--; | ||
else if (intensity > 0) { | ||
intensity = Math.max(0, intensity - 5); | ||
vibrationCountdown = streakCountdownAmount * MinegasmConfig.ticksPerSecond; | ||
} | ||
} else { | ||
vibrationCountdown = Math.max(0, vibrationCountdown - 1); | ||
} | ||
|
||
vibrationFeedbackCountdown = Math.max(0, vibrationFeedbackCountdown - 1); | ||
} | ||
|
||
public void resetState() | ||
{ | ||
vibrationCountdown = 0; | ||
vibrationFeedbackCountdown = 0; | ||
intensity = 0; | ||
} | ||
|
||
protected static boolean accumulationEnabled() | ||
{ | ||
return MinegasmConfig.mode.equals(ClientConfig.GameplayMode.ACCUMULATION); | ||
} | ||
|
||
public static int getIntensity(String type) { | ||
Map<String, Integer> normal = new HashMap<>(); | ||
normal.put("attack", 60); | ||
normal.put("hurt", 0); | ||
normal.put("mine", 80); | ||
normal.put("place", 20); | ||
normal.put("xpChange", 100); | ||
normal.put("harvest", 10); | ||
normal.put("fishing", 50); | ||
normal.put("vitality", 0); | ||
normal.put("advancement", 100); | ||
|
||
Map<String, Integer> masochist = new HashMap<>(); | ||
masochist.put("attack", 0); | ||
masochist.put("hurt", 100); | ||
masochist.put("mine", 0); | ||
masochist.put("place", 0); | ||
masochist.put("xpChange", 0); | ||
masochist.put("fishing", 0); | ||
masochist.put("harvest", 0); | ||
masochist.put("vitality", 10); | ||
masochist.put("advancement", 0); | ||
|
||
Map<String, Integer> hedonist = new HashMap<>(); | ||
hedonist.put("attack", 60); | ||
hedonist.put("hurt", 10); | ||
hedonist.put("mine", 80); | ||
hedonist.put("place", 20); | ||
hedonist.put("xpChange", 100); | ||
hedonist.put("fishing", 50); | ||
hedonist.put("harvest", 20); | ||
hedonist.put("vitality", 10); | ||
hedonist.put("advancement", 100); | ||
|
||
Map<String, Integer> accumulation = new HashMap<>(); | ||
accumulation.put("attack", 1); | ||
accumulation.put("hurt", 1); | ||
accumulation.put("mine", 1); | ||
accumulation.put("place", 1); | ||
accumulation.put("xpChange", 1); | ||
accumulation.put("fishing", 50); | ||
accumulation.put("harvest", 10); | ||
accumulation.put("vitality", 0); | ||
accumulation.put("advancement", 1); | ||
|
||
Map<String, Integer> custom = new HashMap<>(); | ||
custom.put("attack", MinegasmConfig.attackIntensity); | ||
custom.put("hurt", MinegasmConfig.hurtIntensity); | ||
custom.put("mine", MinegasmConfig.mineIntensity); | ||
custom.put("place", MinegasmConfig.placeIntensity); | ||
custom.put("xpChange", MinegasmConfig.xpChangeIntensity); | ||
custom.put("fishing", MinegasmConfig.fishingIntensity); | ||
custom.put("harvest", MinegasmConfig.harvestIntensity); | ||
custom.put("vitality", MinegasmConfig.vitalityIntensity); | ||
custom.put("advancement", MinegasmConfig.advancementIntensity); | ||
|
||
|
||
int returnValue = -1; | ||
|
||
switch (MinegasmConfig.mode) | ||
{ | ||
case NORMAL: returnValue = normal.get(type); | ||
case MASOCHIST: returnValue = masochist.get(type); | ||
case HEDONIST: returnValue = hedonist.get(type); | ||
case ACCUMULATION: returnValue = accumulation.get(type); | ||
case CUSTOM: returnValue = custom.get(type); | ||
}; | ||
|
||
return returnValue; | ||
} | ||
|
||
public abstract int getIntensity(); | ||
} |
55 changes: 55 additions & 0 deletions
55
...0/1.15.2/src/main/java/com/therainbowville/minegasm/common/VibrationStateAdvancement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.therainbowville.minegasm.common; | ||
|
||
import net.minecraft.advancements.FrameType; | ||
import net.minecraft.advancements.Advancement; | ||
import net.minecraftforge.event.entity.player.AdvancementEvent; | ||
|
||
import com.therainbowville.minegasm.config.MinegasmConfig; | ||
|
||
public class VibrationStateAdvancement extends AbstractVibrationState | ||
{ | ||
public VibrationStateAdvancement() | ||
{ | ||
super(0); | ||
} | ||
|
||
public void onAdvancement(AdvancementEvent event) | ||
{ | ||
if (getIntensity("advancement") == 0) return; | ||
try { | ||
LOGGER.info("Advancement Event: " + event); | ||
Advancement advancement = event.getAdvancement(); | ||
if (advancement == null) return; | ||
FrameType type = advancement.getDisplay().getFrame(); | ||
int duration = 0; | ||
|
||
switch (type) { | ||
case TASK: | ||
duration = 5; | ||
break; | ||
case GOAL: | ||
duration = 7; | ||
break; | ||
case CHALLENGE: | ||
duration = 10; | ||
break; | ||
}; | ||
|
||
vibrationCountdown = duration * MinegasmConfig.ticksPerSecond; | ||
vibrationFeedbackCountdown = 1.5f * MinegasmConfig.ticksPerSecond; | ||
} catch (Throwable e) { | ||
LOGGER.throwing(e); | ||
} | ||
} | ||
|
||
public int getIntensity() | ||
{ | ||
if (accumulationEnabled()) | ||
return Math.toIntExact(Math.round(intensity)); | ||
else if (vibrationFeedbackCountdown > 0) | ||
return Math.min(100, getIntensity("advancement") + 20); | ||
else if (vibrationCountdown > 0) | ||
return getIntensity("advancement"); | ||
else return 0; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...fg-6.0/1.15.2/src/main/java/com/therainbowville/minegasm/common/VibrationStateAttack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.therainbowville.minegasm.common; | ||
|
||
import com.therainbowville.minegasm.config.MinegasmConfig; | ||
|
||
public class VibrationStateAttack extends AbstractVibrationState | ||
{ | ||
public VibrationStateAttack() | ||
{ | ||
super(3); | ||
} | ||
|
||
public void onAttack() | ||
{ | ||
if (getIntensity("attack") == 0) return; | ||
|
||
if (accumulationEnabled()) | ||
{ | ||
intensity = Math.min(100, intensity + 5); | ||
vibrationCountdown = streakCountdownAmount * MinegasmConfig.ticksPerSecond; | ||
vibrationFeedbackCountdown = 1 * 0; | ||
} else { | ||
vibrationCountdown = 3 * MinegasmConfig.ticksPerSecond; | ||
vibrationFeedbackCountdown = 1 * MinegasmConfig.ticksPerSecond; | ||
} | ||
} | ||
|
||
public int getIntensity() | ||
{ | ||
if (accumulationEnabled()) | ||
return Math.toIntExact(Math.round(intensity)); | ||
else if (vibrationFeedbackCountdown > 0) | ||
return Math.min(100, getIntensity("attack") + 20); | ||
else if (vibrationCountdown > 0) | ||
return getIntensity("attack"); | ||
else return 0; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...fg-6.0/1.15.2/src/main/java/com/therainbowville/minegasm/common/VibrationStateClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.therainbowville.minegasm.common; | ||
|
||
import com.therainbowville.minegasm.config.MinegasmConfig; | ||
|
||
public class VibrationStateClient extends AbstractVibrationState | ||
{ | ||
public VibrationStateClient() | ||
{ | ||
super(0); | ||
} | ||
|
||
public void setVibration(int intensity, int durationSeconds) | ||
{ | ||
intensity = intensity; | ||
vibrationCountdown = durationSeconds * MinegasmConfig.ticksPerSecond; | ||
} | ||
|
||
public int getIntensity() | ||
{ | ||
if (vibrationCountdown > 0) | ||
return Math.toIntExact(Math.round(intensity)); | ||
else return 0; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...e/fg-6.0/1.15.2/src/main/java/com/therainbowville/minegasm/common/VibrationStateFish.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.therainbowville.minegasm.common; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.entity.player.ClientPlayerEntity; | ||
import net.minecraft.entity.projectile.FishingBobberEntity; | ||
import net.minecraft.util.math.Vec3d; | ||
|
||
import com.therainbowville.minegasm.config.MinegasmConfig; | ||
|
||
|
||
public class VibrationStateFish extends AbstractVibrationState | ||
{ | ||
|
||
public VibrationStateFish() | ||
{ | ||
super(0); | ||
} | ||
|
||
public void onTick(ClientPlayerEntity player) | ||
{ | ||
if (player == null) return; | ||
|
||
if (player.fishing != null) | ||
{ | ||
Vec3d vector = player.fishing.getDeltaMovement(); | ||
double x = vector.x(); | ||
double y = vector.y(); | ||
double z = vector.z(); | ||
if (y < -0.075 && player.fishing.isInWater() && x == 0 && z == 0) | ||
{ | ||
vibrationCountdown = 1.5f * MinegasmConfig.ticksPerSecond; | ||
LOGGER.info("Fishing!"); | ||
} | ||
} | ||
} | ||
|
||
public int getIntensity() | ||
{ | ||
if (vibrationCountdown > 0) | ||
return getIntensity("fishing"); | ||
else return 0; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...g-6.0/1.15.2/src/main/java/com/therainbowville/minegasm/common/VibrationStateHarvest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.therainbowville.minegasm.common; | ||
|
||
import com.therainbowville.minegasm.config.MinegasmConfig; | ||
|
||
public class VibrationStateHarvest extends AbstractVibrationState | ||
{ | ||
private VibrationStateMine mineState; | ||
|
||
public VibrationStateHarvest(VibrationStateMine state) | ||
{ | ||
super(0); | ||
mineState = state; | ||
} | ||
|
||
public void onHarvest() { | ||
vibrationCountdown = 3; | ||
mineState.onHarvest(); | ||
} | ||
|
||
public int getIntensity() | ||
{ | ||
if (vibrationCountdown > 0){ | ||
if (accumulationEnabled()) | ||
return Math.min(100, mineState.getIntensity() + 20); | ||
else | ||
return getIntensity("harvest"); | ||
} | ||
else return 0; | ||
} | ||
} |
Oops, something went wrong.