diff options
| author | BuildTools <james.jenour@protonmail.com> | 2021-06-04 01:18:28 +0800 |
|---|---|---|
| committer | BuildTools <james.jenour@protonmail.com> | 2021-06-04 01:18:28 +0800 |
| commit | a1fa5a67caebf754a0fcc43168672823ede0db93 (patch) | |
| tree | c0d7d78dfffaa659835a59952cac6edd2592be87 /src/main/java/io/github/moulberry/notenoughupdates/miscfeatures | |
| parent | 1b172089ce502803f7644611afd618ce00dcb860 (diff) | |
| download | notenoughupdates-a1fa5a67caebf754a0fcc43168672823ede0db93.tar.gz notenoughupdates-a1fa5a67caebf754a0fcc43168672823ede0db93.tar.bz2 notenoughupdates-a1fa5a67caebf754a0fcc43168672823ede0db93.zip | |
merge is pain
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures')
4 files changed, 157 insertions, 15 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java new file mode 100644 index 00000000..00809d87 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/CollectionLogManager.java @@ -0,0 +1,46 @@ +package io.github.moulberry.notenoughupdates.miscfeatures; + +import io.github.moulberry.notenoughupdates.collectionlog.CollectionConstant; +import io.github.moulberry.notenoughupdates.util.Constants; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityArmorStand; + +import java.util.regex.Matcher; + +public class CollectionLogManager { + + private static CollectionLogManager INSTANCE = new CollectionLogManager(); + + public static CollectionLogManager getInstance() { + return INSTANCE; + } + + public void onEntityMetadataUpdated(int entityId) { + System.out.println("entity created:"+entityId); + WorldClient world = Minecraft.getMinecraft().theWorld; + if(world != null) { + Entity entity = world.getEntityByID(entityId); + + if(entity instanceof EntityArmorStand && entity.hasCustomName()) { + String customName = entity.getName(); + System.out.println("got name:"+customName); + for(CollectionConstant.DropEntry entry : Constants.COLLECTIONLOG.dropdata) { + System.out.println("iter entry"); + if(entry.type.equalsIgnoreCase("itemdrop")) { + Matcher matcher = entry.regex.matcher(customName); + if(matcher.matches()) { + System.out.println("Match found!"); + System.out.println("Count: "+matcher.group("count")); + System.out.println("Name: "+matcher.group("itemname")); + } else { + System.out.println("Doesn't match: " + customName); + } + } + } + } + } + } + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java index 2c59fcd8..71fec1c7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java @@ -7,6 +7,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.PositionedSound; import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.audio.SoundCategory; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; @@ -144,7 +145,7 @@ public class FishingHelper { } int averageMS = totalMS / pingDelayList.size(); - pingDelayTicks = (int)Math.ceil(averageMS/50f); + pingDelayTicks = (int)Math.floor(averageMS/50f); } } @@ -347,23 +348,49 @@ public class FishingHelper { if(newDistance <= 0.2f + 0.1f*pingDelayTicks) { if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSounds && hookedWarningStateTicks <= 0) { - Minecraft.getMinecraft().getSoundHandler().playSound( - PositionedSoundRecord.create(new ResourceLocation("note.pling"), 2f)); + float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishHookedSoundsVol/100f; + if(vol > 0) { + if(vol > 1) vol = 1; + final float volF = vol; + + ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{ + volume = volF; + pitch = 2f; + repeat = false; + repeatDelay = 0; + attenuationType = ISound.AttenuationType.NONE; + }}; + + float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1); + Minecraft.getMinecraft().getSoundHandler().playSound(sound); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel); + } } hookedWarningStateTicks = 12; } else if(newDistance >= 0.4f + 0.1f*pingDelayTicks) { if(NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSounds && buildupSoundDelay <= 0) { - ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{ - volume = 0.1f; - pitch = calculatePitchFromDistance((float)newDistance - (0.3f+0.1f*pingDelayTicks)); - repeat = false; - repeatDelay = 0; - attenuationType = ISound.AttenuationType.NONE; - }}; - Minecraft.getMinecraft().getSoundHandler().playSound(sound); - buildupSoundDelay = 4; + float vol = NotEnoughUpdates.INSTANCE.config.fishing.incomingFishIncSoundsVol/100f; + if(vol > 0) { + if(vol > 1) vol = 1; + final float volF = vol; + + ISound sound = new PositionedSound(new ResourceLocation("note.pling")) {{ + volume = volF; + pitch = calculatePitchFromDistance((float)newDistance - (0.3f+0.1f*pingDelayTicks)); + repeat = false; + repeatDelay = 0; + attenuationType = ISound.AttenuationType.NONE; + }}; + + float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.RECORDS); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, 1); + Minecraft.getMinecraft().getSoundHandler().playSound(sound); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.RECORDS, oldLevel); + buildupSoundDelay = 4; + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java index ecd38bfd..1a266ca8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java @@ -172,7 +172,6 @@ public class PetInfoOverlay extends TextOverlay { } private static int getIdForPet(Pet pet) { - System.out.println("getting for id"); for(Map.Entry<Integer, Pet> entry : config.petMap.entrySet()) { if(entry.getValue() == pet) { return entry.getKey(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java index e7c5b460..4054c4b2 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/SlotLocking.java @@ -8,6 +8,9 @@ import io.github.moulberry.notenoughupdates.core.config.KeybindHelper; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.ISound; +import net.minecraft.client.audio.PositionedSound; +import net.minecraft.client.audio.SoundCategory; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainer; @@ -18,6 +21,7 @@ import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; @@ -96,9 +100,11 @@ public class SlotLocking { private LockedSlot[] getDataForProfile() { if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard() || !NotEnoughUpdates.INSTANCE.config.slotLocking.enableSlotLocking) return null; - if(SBInfo.getInstance().currentProfile == null) return null; - SlotLockProfile profile = config.profileData.computeIfAbsent(SBInfo.getInstance().currentProfile, + String profileName = SBInfo.getInstance().currentProfile; + if(profileName == null) profileName = "generic"; + + SlotLockProfile profile = config.profileData.computeIfAbsent(profileName, k->new SlotLockProfile()); if(profile.currentProfile < 0) profile.currentProfile = 0; @@ -166,6 +172,28 @@ public class SlotLocking { lockedSlots[slotNum].locked = !lockedSlots[slotNum].locked; lockedSlots[slotNum].boundTo = -1; + if(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSound) { + float vol = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSoundVol/100f; + if(vol > 0) { + if(vol > 1) vol = 1; + final float volF = vol; + final boolean locked = lockedSlots[slotNum].locked; + + ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{ + volume = volF; + pitch = locked ? 0.943f : 0.1f; + repeat = false; + repeatDelay = 0; + attenuationType = ISound.AttenuationType.NONE; + }}; + + float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.PLAYERS); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1); + Minecraft.getMinecraft().getSoundHandler().playSound(sound); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel); + } + } + if(isHotbar && lockedSlots[slotNum].locked) { for(int i = 9; i <= 39; i++) { if(lockedSlots[i] != null && lockedSlots[i].boundTo == slotNum) { @@ -220,6 +248,7 @@ public class SlotLocking { if(lockedSlots[pairingNum] == null) { lockedSlots[pairingNum] = new LockedSlot(); } + lockedSlots[pairingNum].boundTo = slotNum; lockedSlots[pairingNum].locked = false; @@ -241,6 +270,47 @@ public class SlotLocking { } } + public void toggleLock(int lockIndex) { + LockedSlot[] lockedSlots = getDataForProfile(); + + if(lockedSlots != null) { + if(lockedSlots[lockIndex] == null) { + lockedSlots[lockIndex] = new LockedSlot(); + } + lockedSlots[lockIndex].locked = !lockedSlots[lockIndex].locked; + lockedSlots[lockIndex].boundTo = -1; + + if(NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSound) { + float vol = NotEnoughUpdates.INSTANCE.config.slotLocking.slotLockSoundVol/100f; + if(vol > 0) { + if(vol > 1) vol = 1; + final float volF = vol; + final boolean locked = lockedSlots[lockIndex].locked; + + ISound sound = new PositionedSound(new ResourceLocation("random.orb")) {{ + volume = volF; + pitch = locked ? 0.943f : 0.1f; + repeat = false; + repeatDelay = 0; + attenuationType = ISound.AttenuationType.NONE; + }}; + + float oldLevel = Minecraft.getMinecraft().gameSettings.getSoundLevel(SoundCategory.PLAYERS); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1); + Minecraft.getMinecraft().getSoundHandler().playSound(sound); + Minecraft.getMinecraft().gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel); + } + } + + if(lockIndex < 9 && lockedSlots[lockIndex].locked) { + for(int i = 9; i <= 39; i++) { + if(lockedSlots[i] != null && lockedSlots[i].boundTo == lockIndex) { + lockedSlots[i].boundTo = -1; + } + } + } + } + } @SubscribeEvent(priority = EventPriority.LOW) public void drawScreenEvent(GuiScreenEvent.DrawScreenEvent.Post event) { |
