* Fixed bogus friend list (*I THINK*)
+ Added enableSoundDistance and ytVolume settings in config * YT player volume now depends on global sound volume - Removed debug messages * Updated README
This commit is contained in:
parent
c266b6c1f4
commit
6d6a64e2de
|
|
@ -2,10 +2,9 @@
|
|||
This is the unfinished port of the WebDisplays mod for Minecraft 1.12.2. The text below is my "TODO" list.
|
||||
|
||||
### Bugs to fix
|
||||
* Bugged friend list
|
||||
* Multiply volume by game volume (and add a config option to disable distance<->volume thingy)
|
||||
* Memory leak (screens aren't deleted?!?)
|
||||
* GUIs are not closed blocks gets destroyed
|
||||
* Remove remaining printed debug infos and check for TODOs
|
||||
|
||||
### Things before release
|
||||
* Fix bugs (obviously)
|
||||
|
|
|
|||
|
|
@ -114,6 +114,8 @@ public class WebDisplays {
|
|||
public int maxScreenY;
|
||||
public int miniservPort;
|
||||
public long miniservQuota;
|
||||
public boolean enableSoundDistance;
|
||||
public float ytVolume;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onPreInit(FMLPreInitializationEvent ev) {
|
||||
|
|
@ -133,6 +135,8 @@ public class WebDisplays {
|
|||
Property maxScreenY = cfg.get("main", "maxScreenSizeY", 16);
|
||||
Property loadDistance = cfg.get("client", "loadDistance", 30.0);
|
||||
Property unloadDistance = cfg.get("client", "unloadDistance", 32.0);
|
||||
Property enableSndDist = cfg.get("client", "enableSoundDistance", true);
|
||||
Property ytVolume = cfg.get("client", "ytVolume", 100.0);
|
||||
|
||||
blacklist.setComment("An array of domain names you don't want to load.");
|
||||
padHeight.setComment("The minePad Y resolution in pixels. padWidth = padHeight * " + PAD_RATIO);
|
||||
|
|
@ -148,6 +152,10 @@ public class WebDisplays {
|
|||
miniservQuota.setComment("The amount of data that can be uploaded to miniserv, in KiB (so 1024 = 1 MiO)");
|
||||
maxScreenX.setComment("Maximum screen width, in blocks. Resolution will be clamped by maxResolutionX.");
|
||||
maxScreenY.setComment("Maximum screen height, in blocks. Resolution will be clamped by maxResolutionY.");
|
||||
enableSndDist.setComment("If true, the volume of YouTube videos will change depending on how far you are");
|
||||
ytVolume.setComment("Volume for YouTube videos. This will have no effect if enableSoundDistance is set to false");
|
||||
ytVolume.setMinValue(0.0);
|
||||
ytVolume.setMaxValue(100.0);
|
||||
|
||||
if(unloadDistance.getDouble() < loadDistance.getDouble() + 2.0)
|
||||
unloadDistance.set(loadDistance.getDouble() + 2.0);
|
||||
|
|
@ -166,6 +174,8 @@ public class WebDisplays {
|
|||
this.miniservQuota = miniservQuota.getLong() * 1024L;
|
||||
this.maxScreenX = maxScreenX.getInt();
|
||||
this.maxScreenY = maxScreenY.getInt();
|
||||
enableSoundDistance = enableSndDist.getBoolean();
|
||||
this.ytVolume = (float) ytVolume.getDouble();
|
||||
|
||||
CREATIVE_TAB = new WDCreativeTab();
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ import net.montoyo.wd.miniserv.client.Client;
|
|||
import net.montoyo.wd.net.server.SMessagePadCtrl;
|
||||
import net.montoyo.wd.net.server.SMessageScreenCtrl;
|
||||
import net.montoyo.wd.utilities.*;
|
||||
import paulscode.sound.SoundSystemConfig;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.reflect.Field;
|
||||
|
|
@ -477,8 +478,8 @@ public class ClientProxy extends SharedProxy implements IResourceManagerReloadLi
|
|||
if(tes.isLoaded()) {
|
||||
if(dist2 > WebDisplays.INSTANCE.unloadDistance2)
|
||||
tes.unload();
|
||||
else
|
||||
tes.updateTrackDistance(dist2);
|
||||
else if(WebDisplays.INSTANCE.enableSoundDistance)
|
||||
tes.updateTrackDistance(dist2, SoundSystemConfig.getMasterGain());
|
||||
} else if(dist2 <= WebDisplays.INSTANCE.loadDistance2)
|
||||
tes.load();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -309,30 +309,15 @@ public class GuiScreenConfig extends WDScreen {
|
|||
}
|
||||
|
||||
public boolean isFriendCheckbox(CheckBox cb) {
|
||||
for(CheckBox box : friendBoxes) {
|
||||
if(box == cb)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Arrays.stream(friendBoxes).anyMatch(fb -> cb == fb);
|
||||
}
|
||||
|
||||
public boolean isOtherCheckbox(CheckBox cb) {
|
||||
for(CheckBox box : otherBoxes) {
|
||||
if(box == cb)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Arrays.stream(otherBoxes).anyMatch(ob -> cb == ob);
|
||||
}
|
||||
|
||||
public boolean hasFriend(NameUUIDPair f) {
|
||||
for(NameUUIDPair pair : friends) {
|
||||
if(pair.equals(f))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Arrays.stream(friends).anyMatch(f::equals);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -102,8 +102,6 @@ public class TileEntityScreen extends TileEntity {
|
|||
for(int i = 0; i < upgrades.tagCount(); i++)
|
||||
ret.upgrades.add(new ItemStack(upgrades.getCompoundTagAt(i)));
|
||||
|
||||
System.out.println("Read " + ret.upgrades.size() + " upgrades from NBT"); //TODO: Remove me
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -141,7 +139,6 @@ public class TileEntityScreen extends TileEntity {
|
|||
for(ItemStack is: upgrades)
|
||||
list.appendTag(is.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
System.out.println("Saved " + list.tagCount() + " upgrades"); //TODO: Remove me
|
||||
tag.setTag("Upgrades", list);
|
||||
return tag;
|
||||
}
|
||||
|
|
@ -482,9 +479,6 @@ public class TileEntityScreen extends TileEntity {
|
|||
}
|
||||
|
||||
if(scr.browser != null) {
|
||||
if(event != CMessageScreenUpdate.MOUSE_MOVE)
|
||||
System.out.println(String.format("handleMouseEvent2 %d @ %d, %d", event, vec == null ? -1 : vec.x, vec == null ? -1 : vec.y));
|
||||
|
||||
if(event == CMessageScreenUpdate.MOUSE_CLICK) {
|
||||
scr.browser.injectMouseMove(vec.x, vec.y, 0, false); //Move to target
|
||||
scr.browser.injectMouseButton(vec.x, vec.y, 0, 1, true, 1); //Press
|
||||
|
|
@ -645,7 +639,8 @@ public class TileEntityScreen extends TileEntity {
|
|||
return renderBB;
|
||||
}
|
||||
|
||||
public void updateTrackDistance(double d) {
|
||||
//FIXME: Not called if enableSoundDistance is false
|
||||
public void updateTrackDistance(double d, float masterVolume) {
|
||||
boolean needsComputation = true;
|
||||
int intPart = 0; //Need to initialize those because the compiler is stupid
|
||||
int fracPart = 0;
|
||||
|
|
@ -656,19 +651,19 @@ public class TileEntityScreen extends TileEntity {
|
|||
float dist = (float) Math.sqrt(d);
|
||||
float vol;
|
||||
|
||||
if(dist <= 10.f)
|
||||
vol = 100.f;
|
||||
else if(dist >= 30.f)
|
||||
vol = 0.f;
|
||||
if(dist <= 10.0f)
|
||||
vol = masterVolume * WebDisplays.INSTANCE.ytVolume;
|
||||
else if(dist >= 30.0f)
|
||||
vol = 0.0f;
|
||||
else
|
||||
vol = (1.f - (dist - 10.f) / 20.f) * 100.f;
|
||||
vol = (1.0f - (dist - 10.0f) / 20.0f) * masterVolume * WebDisplays.INSTANCE.ytVolume;
|
||||
|
||||
if(Math.abs(ytVolume - vol) < 0.5f)
|
||||
return; //Delta is too small
|
||||
|
||||
ytVolume = vol;
|
||||
intPart = (int) vol; //Manually convert to string, probably faster in that case...
|
||||
fracPart = ((int) (vol * 100.f)) - intPart * 100;
|
||||
fracPart = ((int) (vol * 100.0f)) - intPart * 100;
|
||||
needsComputation = false;
|
||||
}
|
||||
|
||||
|
|
@ -705,10 +700,8 @@ public class TileEntityScreen extends TileEntity {
|
|||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
||||
if(world.isRemote) {
|
||||
Log.info("===> TES(INVALIDATE) %s", pos.toString());
|
||||
if(world.isRemote)
|
||||
onChunkUnload();
|
||||
}
|
||||
}
|
||||
|
||||
public void addFriend(EntityPlayerMP ply, BlockSide side, NameUUIDPair pair) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
package net.montoyo.wd.net.client;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
|
@ -20,17 +19,6 @@ public class CMessageACResult implements IMessage, Runnable {
|
|||
public CMessageACResult() {
|
||||
}
|
||||
|
||||
public CMessageACResult(GameProfile gp) {
|
||||
result = new NameUUIDPair[] { new NameUUIDPair(gp) };
|
||||
}
|
||||
|
||||
public CMessageACResult(GameProfile[] gps) {
|
||||
result = new NameUUIDPair[gps.length];
|
||||
|
||||
for(int i = 0; i < gps.length; i++)
|
||||
result[i] = new NameUUIDPair(gps[i]);
|
||||
}
|
||||
|
||||
public CMessageACResult(NameUUIDPair[] pairs) {
|
||||
result = pairs;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import net.montoyo.wd.net.client.CMessageACResult;
|
|||
import net.montoyo.wd.utilities.NameUUIDPair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Message(messageId = 5, side = Side.SERVER)
|
||||
public class SMessageACQuery implements IMessage, Runnable {
|
||||
|
|
@ -39,9 +40,6 @@ public class SMessageACQuery implements IMessage, Runnable {
|
|||
public void fromBytes(ByteBuf buf) {
|
||||
beginning = ByteBufUtils.readUTF8String(buf);
|
||||
matchExact = buf.readBoolean();
|
||||
|
||||
if(!matchExact)
|
||||
beginning = beginning.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -53,28 +51,16 @@ public class SMessageACQuery implements IMessage, Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
GameProfile[] profiles = WebDisplays.PROXY.getOnlineGameProfiles();
|
||||
NameUUIDPair[] result;
|
||||
|
||||
if(matchExact) {
|
||||
for(GameProfile gp : profiles) {
|
||||
if(gp.getName().equals(beginning)) {
|
||||
WebDisplays.NET_HANDLER.sendTo(new CMessageACResult(gp), player);
|
||||
return;
|
||||
}
|
||||
|
||||
WebDisplays.NET_HANDLER.sendTo(new CMessageACResult(new NameUUIDPair[0]), player);
|
||||
}
|
||||
} else {
|
||||
ArrayList<NameUUIDPair> results = new ArrayList<>();
|
||||
|
||||
for(GameProfile gp : profiles) {
|
||||
if(gp.getName().toLowerCase().startsWith(beginning)) {
|
||||
results.add(new NameUUIDPair(gp));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WebDisplays.NET_HANDLER.sendTo(new CMessageACResult(results.toArray(new NameUUIDPair[0])), player);
|
||||
if(matchExact)
|
||||
result = Arrays.stream(profiles).filter(gp -> gp.getName().equalsIgnoreCase(beginning)).map(NameUUIDPair::new).toArray(NameUUIDPair[]::new);
|
||||
else {
|
||||
final String lBeg = beginning.toLowerCase();
|
||||
result = Arrays.stream(profiles).filter(gp -> gp.getName().toLowerCase().startsWith(lBeg)).map(NameUUIDPair::new).toArray(NameUUIDPair[]::new);
|
||||
}
|
||||
|
||||
WebDisplays.NET_HANDLER.sendTo(new CMessageACResult(result), player);
|
||||
}
|
||||
|
||||
public static class Handler implements IMessageHandler<SMessageACQuery, IMessage> {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user