Commit f3a4330a authored by primetoxinz's avatar primetoxinz

Add configs for HCFishing times and world modifiers.

parent f7ab06cf
package betterwithmods.common.entity; package betterwithmods.common.entity;
import betterwithmods.module.hardcore.crafting.HCFishing;
import betterwithmods.util.WorldUtils; import betterwithmods.util.WorldUtils;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block; import net.minecraft.block.Block;
...@@ -54,22 +55,17 @@ public class EntityHCFishHook extends EntityFishHook implements IEntityAdditiona ...@@ -54,22 +55,17 @@ public class EntityHCFishHook extends EntityFishHook implements IEntityAdditiona
WorldServer worldserver = (WorldServer) this.world; WorldServer worldserver = (WorldServer) this.world;
//minutes //minutes
double min = 1; double initialTime = HCFishing.configuration.initialTime;
if (WorldUtils.isTimeFrame(world, WorldUtils.TimeFrame.NIGHT)) { if (WorldUtils.isTimeFrame(world, WorldUtils.TimeFrame.NIGHT))
min *= 2; //2 initialTime *= HCFishing.configuration.nightModifier;
} if (worldserver.isRainingAt(pos.up()))
initialTime *= HCFishing.configuration.rainModifier;
if (worldserver.isRainingAt(pos.up())) { if (WorldUtils.isMoonPhase(world, WorldUtils.MoonPhase.Full))
min *= 0.75; //1.5 initialTime *= HCFishing.configuration.fullMoonModifier;
} if (WorldUtils.isTimeFrame(worldserver, WorldUtils.TimeFrame.DAWN))
initialTime *= HCFishing.configuration.dawnModifier;
if (WorldUtils.isMoonPhase(world, WorldUtils.MoonPhase.Full)) { else if (WorldUtils.isTimeFrame(worldserver, WorldUtils.TimeFrame.DUSK))
min /= 2; //.75 initialTime *= HCFishing.configuration.duskModifier;
}
if (WorldUtils.isTimeFrame(worldserver, WorldUtils.TimeFrame.DAWN) || WorldUtils.isTimeFrame(worldserver, WorldUtils.TimeFrame.DUSK)) {
min /= 2;
}
if (this.ticksCatchable > 0) { if (this.ticksCatchable > 0) {
--this.ticksCatchable; --this.ticksCatchable;
...@@ -145,7 +141,7 @@ public class EntityHCFishHook extends EntityFishHook implements IEntityAdditiona ...@@ -145,7 +141,7 @@ public class EntityHCFishHook extends EntityFishHook implements IEntityAdditiona
this.ticksCaughtDelay = 1; this.ticksCaughtDelay = 1;
} else { } else {
int modifer = 20 * 60; int modifer = 20 * 60;
this.ticksCaughtDelay = MathHelper.getInt(this.rand, (int) (min * (modifer)), (int) ((min + 2) * (modifer))); this.ticksCaughtDelay = MathHelper.getInt(this.rand, (int) (initialTime * (modifer)), (int) ((initialTime + 2) * (modifer)));
this.ticksCaughtDelay = Math.max(1200, this.ticksCaughtDelay - (this.lureSpeed * 1200)); this.ticksCaughtDelay = Math.max(1200, this.ticksCaughtDelay - (this.lureSpeed * 1200));
} }
......
...@@ -61,12 +61,14 @@ public class HCFishing extends Feature { ...@@ -61,12 +61,14 @@ public class HCFishing extends Feature {
private static final ResourceLocation BAITED_FISHING_ROD = new ResourceLocation(BWMod.MODID, "baited_fishing_rod"); private static final ResourceLocation BAITED_FISHING_ROD = new ResourceLocation(BWMod.MODID, "baited_fishing_rod");
public static Ingredient BAIT = Ingredient.EMPTY; public static Ingredient BAIT = Ingredient.EMPTY;
public static FishingTimes configuration;
@Override @Override
public void setupConfig() { public void setupConfig() {
requireBait = loadPropBool("Require Bait", "Change Fishing Rods to require being Baited with certain items to entice fish, they won't nibble without it!", true); requireBait = loadPropBool("Require Bait", "Change Fishing Rods to require being Baited with certain items to entice fish, they won't nibble without it!", true);
restrictToOpenWater = loadPropBool("Restrict to Open Water", "Fishing on underground locations won't work, hook must be placed on a water block with line of sight to the sky.", true); restrictToOpenWater = loadPropBool("Restrict to Open Water", "Fishing on underground locations won't work, hook must be placed on a water block with line of sight to the sky.", true);
minimumWaterDepth = loadPropInt("Minimum Water Depth", "If higher than 1, requires bodies of water to have a minimum depth for fishing to be successful.", 3); minimumWaterDepth = loadPropInt("Minimum Water Depth", "If higher than 1, requires bodies of water to have a minimum depth for fishing to be successful.", 3);
configuration = new FishingTimes();
} }
@Override @Override
...@@ -296,7 +298,8 @@ public class HCFishing extends Feature { ...@@ -296,7 +298,8 @@ public class HCFishing extends Feature {
public static class FishingBait implements ICapabilitySerializable<NBTTagCompound> { public static class FishingBait implements ICapabilitySerializable<NBTTagCompound> {
private boolean bait; private boolean bait;
public FishingBait() {} public FishingBait() {
}
public boolean hasBait() { public boolean hasBait() {
return bait; return bait;
...@@ -331,4 +334,18 @@ public class HCFishing extends Feature { ...@@ -331,4 +334,18 @@ public class HCFishing extends Feature {
setBait(nbt.getBoolean("bait")); setBait(nbt.getBoolean("bait"));
} }
} }
public class FishingTimes {
public double initialTime;
public double nightModifier, rainModifier, fullMoonModifier, dawnModifier, duskModifier;
public FishingTimes() {
initialTime = loadPropDouble("Base Time", "Starting time for which fishing events are calculated in minutes", 1);
nightModifier = loadPropDouble("Night Modifier", "Scale the baseTime by this when it is night time", 2);
rainModifier = loadPropDouble("Rain Modifier", "Scale the baseTime by this when it is raining", 0.75);
fullMoonModifier = loadPropDouble("Full Moon Modifier", "Scale the baseTime by this when it is a full moon", 0.5);
dawnModifier = loadPropDouble("Dawn Modifier", "Scale the baseTime by this when it is dawn", 0.5);
duskModifier = loadPropDouble("Dusk Modifier", "Scale the baseTime by this when it is dusk", 0.5);
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment