├── src ├── main │ ├── resources │ │ ├── matmos │ │ │ ├── dataconfigvars_defaults.cfg │ │ │ └── reloader_blacklist │ │ │ │ └── _matmos_default_blacklist.list │ │ ├── assets │ │ │ └── matmos │ │ │ │ └── lang │ │ │ │ └── en_us.lang │ │ ├── litemod.json │ │ └── matmos.mixin.json │ └── java │ │ └── eu │ │ └── ha3 │ │ └── matmos │ │ ├── core │ │ ├── Simulated.java │ │ ├── ReferenceTime.java │ │ ├── ListContainer.java │ │ ├── InformationContainer.java │ │ ├── PossibilityList.java │ │ ├── VersionListener.java │ │ ├── expansion │ │ │ ├── VolumeContainer.java │ │ │ ├── JsonExpansionDebugUnit.java │ │ │ ├── VolumeUpdatable.java │ │ │ ├── Stable.java │ │ │ ├── FolderExpansionDebugUnit.java │ │ │ ├── ExpansionDebugUnit.java │ │ │ ├── agents │ │ │ │ ├── LoadingAgent.java │ │ │ │ ├── JsonLoadingAgent.java │ │ │ │ ├── RawJsonLoadingAgent.java │ │ │ │ └── LegacyXMLLoadingAgent.java │ │ │ └── ExpansionIdentity.java │ │ ├── Evaluated.java │ │ ├── sheet │ │ │ ├── SheetIndex.java │ │ │ ├── VirtualSheet.java │ │ │ ├── DataPackage.java │ │ │ ├── SheetEntry.java │ │ │ ├── SheetCommander.java │ │ │ ├── SheetDataPackage.java │ │ │ ├── DeltaSheet.java │ │ │ ├── GenericSheet.java │ │ │ └── Sheet.java │ │ ├── Dependable.java │ │ ├── Stated.java │ │ ├── Named.java │ │ ├── SystemClock.java │ │ ├── ducks │ │ │ ├── ISoundManager.java │ │ │ └── ISoundHandler.java │ │ ├── event │ │ │ ├── TimedEventInterface.java │ │ │ ├── EventInterface.java │ │ │ ├── TimedEvent.java │ │ │ ├── Event.java │ │ │ └── TimedEventInformation.java │ │ ├── logic │ │ │ ├── VisualizedSpecialDependencies.java │ │ │ ├── Visualized.java │ │ │ ├── Overrided.java │ │ │ ├── Junction.java │ │ │ └── Condition.java │ │ ├── mixin │ │ │ ├── IEntity.java │ │ │ ├── IFoodStats.java │ │ │ ├── MixinSoundHandler.java │ │ │ ├── MixinSoundManager.java │ │ │ └── MixinSoundManager$1.java │ │ ├── MultistateComponent.java │ │ ├── Possibilities.java │ │ ├── StringListContainer.java │ │ ├── Versioned.java │ │ ├── sound │ │ │ ├── NoAttenuationSound.java │ │ │ ├── StreamingSound.java │ │ │ ├── SoundCapabilities.java │ │ │ ├── SoundHelperRelay.java │ │ │ ├── NoAttenuationMovingSound.java │ │ │ └── Simulacrum.java │ │ ├── SoundRelay.java │ │ ├── ProviderCollection.java │ │ ├── MappedProvider.java │ │ ├── Provider.java │ │ ├── Component.java │ │ ├── Dynamic.java │ │ ├── Providers.java │ │ └── StreamInformation.java │ │ ├── data │ │ ├── IDataGatherer.java │ │ ├── modules │ │ │ ├── EntryBasedModule.java │ │ │ ├── RegistryBasedModule.java │ │ │ ├── PassOnceModule.java │ │ │ ├── EI.java │ │ │ ├── items │ │ │ │ ├── ModulePotionDuration.java │ │ │ │ ├── ModulePotionStrength.java │ │ │ │ └── AbstractPotionQualityModule.java │ │ │ ├── player │ │ │ │ ├── ModuleHeldEnchantment.java │ │ │ │ ├── ModuleArmour.java │ │ │ │ ├── ModuleArmourEnchantment.java │ │ │ │ ├── ModuleInventory.java │ │ │ │ ├── ModuleAction.java │ │ │ │ ├── ItemProcessorHelper.java │ │ │ │ ├── ModuleMotion.java │ │ │ │ ├── ModuleStats.java │ │ │ │ ├── ModuleLeashing.java │ │ │ │ ├── AbstractEnchantmentModule.java │ │ │ │ ├── ModulePlayerStats.java │ │ │ │ └── ModuleHitscan.java │ │ │ ├── world │ │ │ │ ├── ModulePosition.java │ │ │ │ ├── ModuleLighting.java │ │ │ │ ├── ModuleBiome.java │ │ │ │ ├── ModuleCollission.java │ │ │ │ ├── ModuleWorld.java │ │ │ │ └── ModuleColumn.java │ │ │ ├── legacy │ │ │ │ ├── ModuleModData.java │ │ │ │ ├── ModuleDice.java │ │ │ │ ├── ModuleLegacyColumn.java │ │ │ │ ├── ModuleConfigVars.java │ │ │ │ ├── ModuleLegacyHitscan.java │ │ │ │ └── ModuleLegacy.java │ │ │ ├── ModuleMetaOptions.java │ │ │ ├── VirtualModuleProcessor.java │ │ │ ├── Module.java │ │ │ ├── ThousandStringCountModule.java │ │ │ ├── ExternalStringCountModule.java │ │ │ ├── mount │ │ │ │ ├── ModuleRidingMotion.java │ │ │ │ ├── ModuleRiding.java │ │ │ │ └── ModuleHorse.java │ │ │ ├── ModuleProcessor.java │ │ │ ├── ModuleTimedRandom.java │ │ │ ├── AbstractStringCountModule.java │ │ │ ├── ModuleContainer.java │ │ │ └── ProcessorModel.java │ │ ├── scanners │ │ │ ├── ScanOperations.java │ │ │ ├── Progress.java │ │ │ └── ScanVolumetric.java │ │ └── IDataCollector.java │ │ ├── LiteModMAtmos.java │ │ ├── serialisation │ │ └── expansion │ │ │ ├── SerialList.java │ │ │ ├── SerialDynamic.java │ │ │ ├── SerialSet.java │ │ │ ├── SerialMachineStream.java │ │ │ ├── SerialDynamicSheetIndex.java │ │ │ ├── SerialMachineEvent.java │ │ │ ├── SerialEvent.java │ │ │ ├── SerialCondition.java │ │ │ ├── SerialRoot.java │ │ │ └── SerialMachine.java │ │ ├── debug │ │ ├── Pluggable.java │ │ ├── PluggableIntoMAtmos.java │ │ └── SoundsJsonGenerator.java │ │ ├── util │ │ ├── Tags.java │ │ ├── math │ │ │ ├── Numbers.java │ │ │ ├── MAtMutableBlockPos.java │ │ │ └── HelperFadeCalculator.java │ │ ├── IDontKnowHowToCode.java │ │ └── BetterStreams.java │ │ ├── ResourcePackDealer.java │ │ └── gui │ │ ├── GuiExpansionInfo.java │ │ └── GuiBiomeSlider.java ├── soundpacks │ ├── common │ │ └── pack.png │ ├── air │ │ ├── pack.mcmeta │ │ └── assets │ │ │ └── matmos │ │ │ ├── expansions │ │ │ └── nature.json │ │ │ ├── mat_pack.json │ │ │ └── expansions.json │ ├── breeze │ │ ├── pack.mcmeta │ │ └── assets │ │ │ └── matmos │ │ │ ├── expansions.json │ │ │ └── mat_pack.json │ └── default │ │ ├── pack.mcmeta │ │ └── assets │ │ └── matmos │ │ ├── mat_pack.json │ │ ├── expansions.json │ │ └── expansions │ │ └── interactions_extras.json └── dev │ └── java │ └── eu │ └── ha3 │ └── matmos │ ├── editor │ ├── interfaces │ │ ├── IFlaggable.java │ │ ├── Updatable.java │ │ ├── ILister.java │ │ ├── NamedSerialEditor.java │ │ ├── ISerialUpdate.java │ │ ├── Window.java │ │ └── Editor.java │ ├── tree │ │ ├── Selector.java │ │ ├── ItemTreeNode.java │ │ ├── ItemTreeBranch.java │ │ ├── ItemTreeModel.java │ │ └── ItemTreeViewPanel.java │ ├── ItemNamingException.java │ ├── EditorStartWithTestFile.java │ ├── filechooser │ │ ├── JsonFileChooser.java │ │ ├── OggFileChooser.java │ │ └── OverwriteWarningJsonFileChooser.java │ ├── InstantTextField.java │ ├── PopupHelper.java │ ├── WindowEventQueue.java │ ├── PurgeOperator.java │ ├── SimpleFrame.java │ ├── KnowledgeItemType.java │ ├── JsonPanel.java │ ├── edit │ │ ├── SetRemoverPanel.java │ │ └── DynamicRemoverPanel.java │ └── ListerPanel.java │ └── util │ └── Json.java ├── ant ├── buildnumber.txt └── litemod.template.json ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitmodules ├── .gitignore ├── gradle.properties ├── README.md └── gradlew.bat /src/main/resources/matmos/dataconfigvars_defaults.cfg: -------------------------------------------------------------------------------- 1 | 0:-80 2 | 1:-96 -------------------------------------------------------------------------------- /ant/buildnumber.txt: -------------------------------------------------------------------------------- 1 | #Build Number for ANT. Do not edit! 2 | #Fri Jun 12 19:55:44 BST 2015 3 | build.number=30 4 | -------------------------------------------------------------------------------- /src/soundpacks/common/pack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sollace/MAtmos/HEAD/src/soundpacks/common/pack.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sollace/MAtmos/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/soundpacks/air/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 1, 4 | "description": "MAtmos default 2012 pack Air" 5 | } 6 | } -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/MC-Commons"] 2 | path = lib/MC-Commons 3 | url = https://github.com/Sollace/MC-Commons.git 4 | branch = master 5 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Simulated.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface Simulated { 4 | void simulate(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/resources/assets/matmos/lang/en_us.lang: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sollace/MAtmos/HEAD/src/main/resources/assets/matmos/lang/en_us.lang -------------------------------------------------------------------------------- /src/soundpacks/breeze/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 1, 4 | "description": "MAtmos default 2014 pack Breeze" 5 | } 6 | } -------------------------------------------------------------------------------- /src/soundpacks/default/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "pack_format": 2, 4 | "description": "The Default sounds for MAtmos mc1.9+" 5 | } 6 | } -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/ReferenceTime.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface ReferenceTime { 4 | long getMilliseconds(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/ListContainer.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface ListContainer { 4 | boolean contains(String element); 5 | } 6 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/interfaces/IFlaggable.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.interfaces; 2 | 3 | public interface IFlaggable { 4 | void flagChange(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/InformationContainer.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface InformationContainer { 4 | T getInformation(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/PossibilityList.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface PossibilityList { 4 | boolean listHas(String element); 5 | } 6 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/interfaces/Updatable.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.interfaces; 2 | 3 | public interface Updatable { 4 | void update(Editor model); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/VersionListener.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface VersionListener { 4 | void onIncrement(Versioned versionned); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/VolumeContainer.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion; 2 | 3 | public interface VolumeContainer { 4 | float getVolume(); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/IDataGatherer.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data; 2 | 3 | @FunctionalInterface 4 | public interface IDataGatherer { 5 | void process(); 6 | } 7 | -------------------------------------------------------------------------------- /src/soundpacks/air/assets/matmos/expansions/nature.json: -------------------------------------------------------------------------------- 1 | { 2 | "condition": {}, 3 | "set": {}, 4 | "machine": {}, 5 | "event": {}, 6 | "list": {}, 7 | "dynamic": {} 8 | } -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Evaluated.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface Evaluated { 4 | /** 5 | * Evaluate this. 6 | */ 7 | void evaluate(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sheet/SheetIndex.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sheet; 2 | 3 | public interface SheetIndex { 4 | String getSheet(); 5 | 6 | String getIndex(); 7 | } 8 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/interfaces/ILister.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.interfaces; 2 | 3 | public interface ILister extends ISerialUpdate { 4 | void setTitle(String title); 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Dependable.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import java.util.Collection; 4 | 5 | public interface Dependable { 6 | Collection getDependencies(); 7 | } 8 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Stated.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface Stated { 4 | /** 5 | * Tells if this state is active. 6 | */ 7 | boolean isActive(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/resources/matmos/reloader_blacklist/_matmos_default_blacklist.list: -------------------------------------------------------------------------------- 1 | soundpacks.ThreadDownloadResources SoundPacks mod was detected. 2 | eu.ha3.mc.external.se.BlockResourceLoader A generic blocker was detected. -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Named.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface Named { 4 | /** 5 | * Returns the unchanging name of this element. 6 | */ 7 | String getName(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/JsonExpansionDebugUnit.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion; 2 | 3 | public interface JsonExpansionDebugUnit extends ExpansionDebugUnit { 4 | String getJsonString(); 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .metadata 3 | .gradle 4 | .project 5 | .settings 6 | bin/ 7 | build/ 8 | jars/ 9 | run/ 10 | *.iml 11 | *.launch 12 | /.nb-gradle/ 13 | 14 | /*Audio files*/ 15 | *.ogg 16 | *.WAV 17 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/interfaces/NamedSerialEditor.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.interfaces; 2 | 3 | public interface NamedSerialEditor { 4 | void setEditFocus(String name, Object item, boolean forceSelect); 5 | } 6 | -------------------------------------------------------------------------------- /src/soundpacks/air/assets/matmos/mat_pack.json: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "pack_matmos", 3 | "engineversion" : 0, 4 | "metadata" : { 5 | "name" : "MAtmos 2012 Air", 6 | "author" : "Ha3", 7 | "website" : "http://matmos.ha3.eu" 8 | } 9 | } -------------------------------------------------------------------------------- /ant/litemod.template.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eu.ha3.mc.matmos", 3 | "mcversion": "1.9", 4 | "version": "r30", 5 | "revision": "0", 6 | "author": "Hurricaaane (Ha3)", 7 | "url": "http://matmos.ha3.eu", 8 | "description": "MAtmos" 9 | } -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sheet/VirtualSheet.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sheet; 2 | 3 | public interface VirtualSheet extends Sheet { 4 | /** 5 | * Commits this virtual sheet. 6 | */ 7 | void apply(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/EntryBasedModule.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import java.util.Map; 4 | 5 | public interface EntryBasedModule extends Module { 6 | Map getModuleEntries(); 7 | } 8 | -------------------------------------------------------------------------------- /src/soundpacks/breeze/assets/matmos/expansions.json: -------------------------------------------------------------------------------- 1 | { 2 | "expansions" : [ 3 | { 4 | "uniquename" : "eu.ha3.breeze.nature", 5 | "friendlyname" : "Breeze 2014: Nature", 6 | "pointer" : "expansions/nature.json" 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /src/soundpacks/breeze/assets/matmos/mat_pack.json: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "pack_matmos", 3 | "engineversion" : 0, 4 | "metadata" : { 5 | "name" : "MAtmos 2014 Breeze", 6 | "author" : "Ha3", 7 | "website" : "http://matmos.ha3.eu" 8 | } 9 | } -------------------------------------------------------------------------------- /src/soundpacks/default/assets/matmos/mat_pack.json: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "pack_matmos", 3 | "engineversion" : 0, 4 | "metadata" : { 5 | "name" : "MAtmos default pack", 6 | "author" : "Ha3", 7 | "website" : "http://matmos.ha3.eu" 8 | } 9 | } -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/scanners/ScanOperations.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.scanners; 2 | 3 | public interface ScanOperations { 4 | void begin(); 5 | 6 | void finish(); 7 | 8 | void input(int x, int y, int z); 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/SystemClock.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public class SystemClock implements ReferenceTime { 4 | @Override 5 | public long getMilliseconds() { 6 | return System.currentTimeMillis(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/VolumeUpdatable.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion; 2 | 3 | public interface VolumeUpdatable extends VolumeContainer { 4 | void setVolumeAndUpdate(float volume); 5 | 6 | void updateVolume(); 7 | } 8 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/interfaces/ISerialUpdate.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.interfaces; 2 | 3 | import eu.ha3.matmos.serialisation.expansion.SerialRoot; 4 | 5 | public interface ISerialUpdate { 6 | void updateSerial(SerialRoot root); 7 | } 8 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/tree/Selector.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.tree; 2 | 3 | public enum Selector { 4 | LOGIC, 5 | SUPPORT, 6 | CONDITION, 7 | SET, 8 | MACHINE, 9 | LIST, 10 | DYNAMIC, 11 | EVENT 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/LiteModMAtmos.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos; 2 | 3 | import eu.ha3.mc.haddon.litemod.TempLiteKey; 4 | 5 | public class LiteModMAtmos extends TempLiteKey { 6 | public LiteModMAtmos() { 7 | super(new Matmos()); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/ducks/ISoundManager.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.ducks; 2 | 3 | import paulscode.sound.SoundSystem; 4 | 5 | public interface ISoundManager { 6 | SoundSystem getSoundSystem(); 7 | 8 | void setSoundSystem(SoundSystem sndSystem); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/RegistryBasedModule.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | public interface RegistryBasedModule extends Module { 4 | /** 5 | * Gets the name of the registry used to back this module. 6 | */ 7 | String getRegistryName(); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/Stable.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion; 2 | 3 | public interface Stable { 4 | boolean isActivated(); 5 | 6 | void activate(); 7 | 8 | void deactivate(); 9 | 10 | void dispose(); 11 | 12 | void interrupt(); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/FolderExpansionDebugUnit.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion; 2 | 3 | import java.io.File; 4 | 5 | public interface FolderExpansionDebugUnit extends ExpansionDebugUnit { 6 | File getExpansionFile(); 7 | 8 | File getExpansionFolder(); 9 | } 10 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/ItemNamingException.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | public class ItemNamingException extends Exception { 4 | private static final long serialVersionUID = 1L; 5 | 6 | public ItemNamingException(String string) { 7 | super(string); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/event/TimedEventInterface.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.event; 2 | 3 | import eu.ha3.matmos.core.ReferenceTime; 4 | 5 | public interface TimedEventInterface { 6 | void restart(ReferenceTime time); 7 | 8 | void play(ReferenceTime time, float fadeFactor); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/resources/litemod.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MAtmos", 3 | "mcversion": "${mcversion}", 4 | "version": "${version}", 5 | "revision": "${revision}", 6 | "author": "${author}", 7 | "url": "${url}", 8 | "description": "${description}", 9 | "mixinConfigs": [ 10 | "matmos.mixin.json" 11 | ] 12 | } -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/ExpansionDebugUnit.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion; 2 | 3 | import eu.ha3.matmos.core.Knowledge; 4 | import eu.ha3.matmos.core.sheet.DataPackage; 5 | 6 | public interface ExpansionDebugUnit { 7 | DataPackage getData(); 8 | 9 | Knowledge getKnowledge(); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/event/EventInterface.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.event; 2 | 3 | import net.minecraft.client.resources.IResourcePack; 4 | 5 | public interface EventInterface { 6 | 7 | void cacheSounds(IResourcePack resourcePack); 8 | 9 | void playSound(float volMod, float pitchMod); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialList.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import java.util.Set; 4 | import java.util.TreeSet; 5 | 6 | import com.google.gson.annotations.Expose; 7 | 8 | public class SerialList { 9 | @Expose 10 | public Set entries = new TreeSet<>(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/logic/VisualizedSpecialDependencies.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.logic; 2 | 3 | import java.util.Collection; 4 | 5 | import eu.ha3.matmos.core.Dependable; 6 | 7 | public interface VisualizedSpecialDependencies extends Visualized, Dependable { 8 | Collection getSpecialDependencies(String type); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/mixin/IEntity.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.mixin; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Accessor; 5 | 6 | import net.minecraft.entity.Entity; 7 | 8 | @Mixin(Entity.class) 9 | public interface IEntity { 10 | @Accessor("isInWeb") 11 | boolean isInWeb(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialDynamic.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.google.gson.annotations.Expose; 7 | 8 | public class SerialDynamic { 9 | @Expose 10 | public List entries = new ArrayList<>(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/debug/Pluggable.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.debug; 2 | 3 | import java.io.File; 4 | 5 | public interface Pluggable { 6 | boolean isReadOnly(); 7 | 8 | File getFileIfAvailable(); 9 | 10 | File getWorkingDirectoryIfAvailable(); 11 | 12 | void pushJson(String json); 13 | 14 | void reloadFromDisk(); 15 | 16 | void onEditorClosed(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/logic/Visualized.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.logic; 2 | 3 | import eu.ha3.matmos.core.Named; 4 | import eu.ha3.matmos.core.Stated; 5 | 6 | public interface Visualized extends Named, Stated { 7 | /** 8 | * Represents the feed of this visualizable. It's a chain of characters that says what is happening. 9 | */ 10 | String getFeed(); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/mixin/IFoodStats.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.mixin; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Accessor; 5 | 6 | import net.minecraft.util.FoodStats; 7 | 8 | @Mixin(FoodStats.class) 9 | public interface IFoodStats { 10 | @Accessor("foodExhaustionLevel") 11 | float getFoodExhaustionLevel(); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialSet.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import java.util.Set; 4 | import java.util.TreeSet; 5 | 6 | import com.google.gson.annotations.Expose; 7 | 8 | public class SerialSet { 9 | @Expose 10 | public Set yes = new TreeSet<>(); 11 | 12 | @Expose 13 | public Set no = new TreeSet<>(); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/ducks/ISoundHandler.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.ducks; 2 | 3 | import net.minecraft.client.audio.SoundManager; 4 | import paulscode.sound.SoundSystem; 5 | 6 | public interface ISoundHandler { 7 | 8 | SoundManager getSoundManager(); 9 | 10 | default SoundSystem getSoundSystem() { 11 | return ((ISoundManager)getSoundManager()).getSoundSystem(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/resources/matmos.mixin.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.7", 4 | "package": "eu.ha3.matmos.core.mixin", 5 | "refmap": "matmos.mixin.refmap.json", 6 | "compatibilityLevel": "JAVA_8", 7 | "mixins": [ 8 | "IEntity", 9 | "IFoodStats", 10 | "MixinSoundHandler", 11 | "MixinSoundManager", 12 | "MixinSoundManager$1" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/interfaces/Window.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.interfaces; 2 | 3 | import java.awt.Component; 4 | 5 | public interface Window extends ISerialUpdate, NamedSerialEditor { 6 | Component asComponent(); 7 | 8 | void display(); 9 | 10 | void refreshFileState(); 11 | 12 | void showErrorPopup(String error); 13 | 14 | void disableMinecraftCapabilitites(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/MultistateComponent.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public abstract class MultistateComponent extends Component implements Stated, Evaluated { 4 | protected boolean isActive; 5 | 6 | public MultistateComponent(String name) { 7 | super(name); 8 | } 9 | 10 | @Override 11 | public boolean isActive() { 12 | return isActive; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/PassOnceModule.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import java.util.Set; 4 | 5 | /* 6 | * --filenotes-placeholder 7 | */ 8 | 9 | public interface PassOnceModule extends Module { 10 | /** 11 | * Returns a set of modules this pass-once module is capable to handle. 12 | * 13 | * @return 14 | */ 15 | Set getSubModules(); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/IDataCollector.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data; 2 | 3 | import java.util.Set; 4 | 5 | public interface IDataCollector { 6 | 7 | void addModuleStack(String name, Set requiredModules); 8 | 9 | void removeModuleStack(String name); 10 | 11 | /** 12 | * Tells if this collector requires a certain module. 13 | */ 14 | boolean requires(String moduleName); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sheet/DataPackage.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sheet; 2 | 3 | import java.util.Set; 4 | 5 | public interface DataPackage { 6 | Sheet getSheet(String name); 7 | 8 | Set getSheetNames(); 9 | 10 | /** 11 | * Empties the data overall 12 | */ 13 | void clear(); 14 | 15 | /** 16 | * Empties the individual sheets 17 | */ 18 | void clearContents(); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/logic/Overrided.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.logic; 2 | 3 | public interface Overrided { 4 | /** 5 | * Bypass internal logic to force this on. 6 | */ 7 | void overrideForceOn(); 8 | 9 | /** 10 | * Bypass internal logic to force this off. 11 | */ 12 | void overrideForceOff(); 13 | 14 | /** 15 | * Stop bypassing internal logic. 16 | */ 17 | void overrideFinish(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/EI.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | public class EI { 4 | private String name; 5 | private String desc; 6 | 7 | public EI(String name, String description) { 8 | this.name = name; 9 | desc = description; 10 | } 11 | 12 | public String getName() { 13 | return name; 14 | } 15 | 16 | public String getDescription() { 17 | return desc; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/EditorStartWithTestFile.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | import java.io.File; 4 | 5 | public class EditorStartWithTestFile { 6 | private static final String PATH = "L:\\MCMod-C\\jars\\resourcepacks\\mat_breeze\\assets\\matmos\\expansions\\nature.json"; 7 | 8 | public static void main(String[] args) { 9 | EditorMaster master = new EditorMaster(null, new File(PATH)); 10 | master.run(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/tree/ItemTreeNode.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.tree; 2 | 3 | import javax.swing.tree.DefaultMutableTreeNode; 4 | 5 | @SuppressWarnings("serial") 6 | public class ItemTreeNode extends DefaultMutableTreeNode { 7 | private String itemName; 8 | 9 | public ItemTreeNode(String name) { 10 | super(name); 11 | itemName = name; 12 | } 13 | 14 | public String getItemName() { 15 | return itemName; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/scanners/Progress.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.scanners; 2 | 3 | public interface Progress { 4 | /** 5 | * Returns the current progress. 6 | * 7 | * @return 8 | */ 9 | int getProgress_Current(); 10 | 11 | /** 12 | * Returns the total value to "complete". Never set the total to zero, to prevent division by zero 13 | * errors. 14 | * 15 | * @return 16 | */ 17 | int getProgress_Total(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialMachineStream.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | public class SerialMachineStream { 6 | @Expose 7 | public String path = ""; 8 | 9 | @Expose 10 | public float vol = 1; 11 | 12 | @Expose 13 | public float pitch = 1; 14 | 15 | @Expose 16 | public boolean looping; 17 | 18 | @Expose 19 | public boolean pause; 20 | } 21 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | modid=matmos 2 | name=MAtmos 3 | author=Hurricaaane (Ha3), Dag_, Sollace 4 | description=An over-engineered sound enhancement mod for minecraft 5 | group=eu.ha3 6 | inceptionYear=2012 7 | packaging=jar 8 | description=MAtmos, a Minecraft mod. 9 | url=http://matmos.ha3.eu 10 | organization= 11 | buildType=SNAPSHOT 12 | buildVersion=r37 13 | buildRevision=0 14 | mcVersion=1.12.2 15 | mcMappings=stable_39 16 | forgeGradleVersion=2.3-SNAPSHOT 17 | mixinGradleVersion=0.6-SNAPSHOT 18 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Possibilities.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import java.util.List; 4 | 5 | public class Possibilities extends Component implements PossibilityList { 6 | private final List list; 7 | 8 | public Possibilities(String name, List list) { 9 | super(name); 10 | 11 | this.list = list; 12 | } 13 | 14 | @Override 15 | public boolean listHas(String element) { 16 | return list.contains(element); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/StringListContainer.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import java.util.List; 4 | 5 | public class StringListContainer extends Component implements ListContainer { 6 | private final List list; 7 | 8 | public StringListContainer(String name, List list) { 9 | super(name); 10 | 11 | this.list = list; 12 | } 13 | 14 | @Override 15 | public boolean contains(String element) { 16 | return list.contains(element); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sheet/SheetEntry.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sheet; 2 | 3 | public class SheetEntry implements SheetIndex { 4 | private final String sheet; 5 | private final String index; 6 | 7 | public SheetEntry(String sheet, String index) { 8 | this.sheet = sheet; 9 | this.index = index; 10 | } 11 | 12 | @Override 13 | public String getSheet() { 14 | return sheet; 15 | } 16 | 17 | @Override 18 | public String getIndex() { 19 | return index; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialDynamicSheetIndex.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | public class SerialDynamicSheetIndex { 6 | @Expose 7 | public String sheet = ""; 8 | 9 | @Expose 10 | public String index = ""; 11 | 12 | 13 | public SerialDynamicSheetIndex() { 14 | } 15 | 16 | public SerialDynamicSheetIndex(String sheet, String index) { 17 | this.sheet = sheet; 18 | this.index = index; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Versioned.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface Versioned { 4 | /** 5 | * Gets the version of this. Starts at -1. 6 | * 7 | * @return 8 | */ 9 | int version(); 10 | 11 | /** 12 | * Increments the version. 13 | */ 14 | void incrementVersion(); 15 | 16 | /** 17 | * Registers a version listener that is called after incrementation. 18 | * 19 | * @param listener 20 | */ 21 | void registerVersionListener(VersionListener listener); 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/items/ModulePotionDuration.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.items; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import net.minecraft.potion.PotionEffect; 5 | 6 | public class ModulePotionDuration extends AbstractPotionQualityModule { 7 | public ModulePotionDuration(DataPackage data) { 8 | super(data, "potion_duration"); 9 | } 10 | 11 | @Override 12 | protected String getQuality(PotionEffect effect) { 13 | return Integer.toString(effect.getDuration()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/items/ModulePotionStrength.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.items; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import net.minecraft.potion.PotionEffect; 5 | 6 | public class ModulePotionStrength extends AbstractPotionQualityModule { 7 | public ModulePotionStrength(DataPackage data) { 8 | super(data, "potion_power"); 9 | } 10 | 11 | @Override 12 | protected String getQuality(PotionEffect effect) { 13 | return Integer.toString(effect.getAmplifier() + 1); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/mixin/MixinSoundHandler.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.mixin; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Accessor; 5 | 6 | import eu.ha3.matmos.core.ducks.ISoundHandler; 7 | import net.minecraft.client.audio.SoundHandler; 8 | import net.minecraft.client.audio.SoundManager; 9 | 10 | @Mixin(SoundHandler.class) 11 | abstract class MixinSoundHandler implements ISoundHandler { 12 | @Override 13 | @Accessor("sndManager") 14 | public abstract SoundManager getSoundManager(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialMachineEvent.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | public class SerialMachineEvent { 6 | @Expose 7 | public String event = ""; 8 | 9 | @Expose 10 | public float vol_mod = 1; 11 | 12 | @Expose 13 | public float pitch_mod = 1; 14 | 15 | @Expose 16 | public float delay_min = 0; 17 | 18 | @Expose 19 | public float delay_max = 864000; 20 | 21 | @Expose 22 | public float delay_start = -1; 23 | } 24 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/tree/ItemTreeBranch.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.tree; 2 | 3 | @SuppressWarnings("serial") 4 | public class ItemTreeBranch extends ItemTreeNode { 5 | private final Selector rootSelector; 6 | 7 | public ItemTreeBranch(String name, Selector rootSelector) { 8 | super(name); 9 | this.rootSelector = rootSelector; 10 | } 11 | 12 | public Selector getSelector() { 13 | return rootSelector; 14 | } 15 | 16 | @Override 17 | public boolean isLeaf() { 18 | return false; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModuleHeldEnchantment.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import net.minecraft.entity.player.EntityPlayer; 5 | import net.minecraft.item.ItemStack; 6 | 7 | public class ModuleHeldEnchantment extends AbstractEnchantmentModule { 8 | public ModuleHeldEnchantment(DataPackage data) { 9 | super(data, "ench_current"); 10 | } 11 | 12 | @Override 13 | protected ItemStack getItem(EntityPlayer player) { 14 | return player.getActiveItemStack(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sound/NoAttenuationSound.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sound; 2 | 3 | import net.minecraft.client.audio.ISound; 4 | import net.minecraft.client.audio.PositionedSoundRecord; 5 | import net.minecraft.util.ResourceLocation; 6 | import net.minecraft.util.SoundCategory; 7 | 8 | public class NoAttenuationSound extends PositionedSoundRecord { 9 | public NoAttenuationSound(ResourceLocation loc, float volume, float pitch, float x, float y, float z) { 10 | super(loc, SoundCategory.MASTER, volume, pitch, false, 0, ISound.AttenuationType.NONE, x, y, z); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/util/Json.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.util; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | 6 | public final class Json { 7 | private static final Gson ugly = new GsonBuilder().disableHtmlEscaping().create(); 8 | private static final Gson pretty = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); 9 | 10 | public static String toJson(Object blob) { 11 | return ugly.toJson(blob); 12 | } 13 | 14 | public static String toJsonPretty(Object blob) { 15 | return pretty.toJson(blob); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MAtmos 2 | ====== 3 | 4 | MAtmos, a Minecraft mod. 5 | 6 | MAtmos source code requires some custom libraries/classes found at https://github.com/Hurricaaane/MC-Commons/ (WTFPLv2). 7 | 1.8 Fork at: https://github.com/dags-/MC-Commons 8 | 9 | The (net.sf.) PracticalXML library (Apache License) is also required to compile versions that include the XML expansion converter: 10 | - net.sf.practicalxml.* 11 | 12 | Requires a LiteLoader workspace. Before decompiling, make sure you have followed the instructions located at: 13 | https://www.assembla.com/code/liteloader/subversion/nodes/202/LiteLoader/trunk/README.md 14 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/SoundRelay.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | public interface SoundRelay { 4 | void routine(); 5 | 6 | void cacheSound(String path); 7 | 8 | void playSound(String path, float volume, float pitch, int meta); 9 | 10 | int getNewStreamingToken(); 11 | 12 | boolean setupStreamingToken(int token, String path, float volume, float pitch, boolean isLooping, boolean usesPause); 13 | 14 | void startStreaming(int token, float fadeDuration); 15 | 16 | void stopStreaming(int token, float fadeDuration); 17 | 18 | void eraseStreamingToken(int token); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/agents/LoadingAgent.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion.agents; 2 | 3 | import eu.ha3.matmos.core.Knowledge; 4 | import eu.ha3.matmos.core.expansion.ExpansionIdentity; 5 | 6 | public interface LoadingAgent { 7 | /** 8 | * Load whatever serialized data into the knowledge. It should be assumed the knowledge is empty 9 | * before this is called, however it may not necessarily be the case. 10 | * 11 | * @param identity 12 | * @param knowledge 13 | * @return 14 | */ 15 | boolean load(ExpansionIdentity identity, Knowledge knowledge); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialEvent.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import com.google.gson.annotations.Expose; 7 | 8 | public class SerialEvent { 9 | @Expose 10 | public float vol_min = 1; 11 | 12 | @Expose 13 | public float vol_max = 1; 14 | 15 | @Expose 16 | public float pitch_min = 1; 17 | 18 | @Expose 19 | public float pitch_max = 1; 20 | 21 | @Expose 22 | public int distance = 0; 23 | 24 | @Expose 25 | public List path = new ArrayList<>(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/mixin/MixinSoundManager.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.mixin; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | 5 | import eu.ha3.matmos.core.ducks.ISoundManager; 6 | import net.minecraft.client.audio.SoundManager; 7 | import paulscode.sound.SoundSystem; 8 | 9 | @Mixin(SoundManager.class) 10 | abstract class MixinSoundManager implements ISoundManager { 11 | 12 | private SoundSystem __sndSystem; 13 | 14 | @Override 15 | public SoundSystem getSoundSystem() { 16 | return __sndSystem; 17 | } 18 | 19 | @Override 20 | public void setSoundSystem(SoundSystem sndSystem) { 21 | __sndSystem = sndSystem; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/tree/ItemTreeModel.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.tree; 2 | 3 | import javax.swing.tree.DefaultTreeModel; 4 | 5 | import eu.ha3.matmos.editor.interfaces.ISerialUpdate; 6 | import eu.ha3.matmos.serialisation.expansion.SerialRoot; 7 | 8 | @SuppressWarnings("serial") 9 | public class ItemTreeModel extends DefaultTreeModel implements ISerialUpdate { 10 | 11 | public ItemTreeModel() { 12 | super(new ItemTreeRoot()); 13 | } 14 | 15 | @Override 16 | public void updateSerial(SerialRoot root) { 17 | getItemTreeRoot().updateSerial(root); 18 | } 19 | 20 | public ItemTreeRoot getItemTreeRoot() { 21 | return (ItemTreeRoot)getRoot(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/world/ModulePosition.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.world; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.util.math.BlockPos; 7 | 8 | public class ModulePosition extends ModuleProcessor implements Module { 9 | public ModulePosition(DataPackage data) { 10 | super(data, "cb_pos"); 11 | } 12 | 13 | @Override 14 | protected void doProcess() { 15 | BlockPos pos = getPlayer().getPosition(); 16 | 17 | setValue("x", pos.getX()); 18 | setValue("y", pos.getY()); 19 | setValue("z", pos.getZ()); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/ProviderCollection.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import eu.ha3.matmos.core.event.Event; 4 | import eu.ha3.matmos.core.logic.Condition; 5 | import eu.ha3.matmos.core.logic.Junction; 6 | import eu.ha3.matmos.core.logic.Machine; 7 | import eu.ha3.matmos.core.sheet.SheetCommander; 8 | 9 | public interface ProviderCollection { 10 | ReferenceTime getReferenceTime(); 11 | 12 | SoundRelay getSoundRelay(); 13 | 14 | SheetCommander getSheetCommander(); 15 | 16 | Provider getCondition(); 17 | 18 | Provider getJunction(); 19 | 20 | Provider getMachine(); 21 | 22 | Provider getEvent(); 23 | 24 | Provider getDynamic(); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/legacy/ModuleModData.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.legacy; 2 | 3 | import eu.ha3.matmos.Matmos; 4 | import eu.ha3.matmos.core.sheet.DataPackage; 5 | import eu.ha3.matmos.data.modules.Module; 6 | import eu.ha3.matmos.data.modules.ModuleProcessor; 7 | 8 | public class ModuleModData extends ModuleProcessor implements Module { 9 | private final Matmos mod; 10 | 11 | public ModuleModData(DataPackage data, Matmos mod) { 12 | super(data, "meta_mod"); 13 | this.mod = mod; 14 | 15 | EI("mod_tick", "Current tick internal to the mod."); 16 | } 17 | 18 | @Override 19 | protected void doProcess() { 20 | setValue("mod_tick", mod.util().getClientTick()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/ModuleMetaOptions.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import eu.ha3.matmos.Matmos; 4 | import eu.ha3.matmos.core.sheet.DataPackage; 5 | 6 | /* 7 | * --filenotes-placeholder 8 | */ 9 | 10 | public class ModuleMetaOptions extends ModuleProcessor implements Module { 11 | private final Matmos mod; 12 | 13 | public ModuleMetaOptions(DataPackage data, Matmos mod) { 14 | super(data, "meta_option", true); 15 | this.mod = mod; 16 | } 17 | 18 | @Override 19 | protected void doProcess() { 20 | setValue("altitudes_high", mod.getConfig().getBoolean("useroptions.altitudes.high")); 21 | setValue("altitudes_low", mod.getConfig().getBoolean("useroptions.altitudes.low")); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialCondition.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import eu.ha3.matmos.core.sheet.SheetIndex; 6 | 7 | public class SerialCondition { 8 | @Expose 9 | public String sheet = ""; 10 | 11 | @Expose 12 | public String index = ""; 13 | 14 | @Expose 15 | public String symbol = "EQUALS"; 16 | 17 | @Expose 18 | public String value = ""; 19 | 20 | public SerialCondition() {} 21 | 22 | public SerialCondition(SheetIndex sheet, String symbol, String value) { 23 | this.sheet = sheet.getSheet(); 24 | this.index = sheet.getIndex(); 25 | this.symbol = symbol; 26 | this.value = value; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/legacy/ModuleDice.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.legacy; 2 | 3 | import java.util.Random; 4 | 5 | import eu.ha3.matmos.core.sheet.DataPackage; 6 | import eu.ha3.matmos.data.modules.Module; 7 | import eu.ha3.matmos.data.modules.ModuleProcessor; 8 | 9 | public class ModuleDice extends ModuleProcessor implements Module { 10 | 11 | private final char[] sides = "abcdef".toCharArray(); 12 | 13 | private final Random random = new Random(); 14 | 15 | public ModuleDice(DataPackage data) { 16 | super(data, "legacy_random"); 17 | } 18 | 19 | @Override 20 | protected void doProcess() { 21 | for (char side : sides) { 22 | setValue("dice_" + side, 1 + random.nextInt(100)); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialRoot.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import java.util.Map; 4 | import java.util.TreeMap; 5 | 6 | import com.google.gson.annotations.Expose; 7 | 8 | public class SerialRoot { 9 | @Expose 10 | public Map condition = new TreeMap<>(); 11 | 12 | @Expose 13 | public Map set = new TreeMap<>(); 14 | 15 | @Expose 16 | public Map machine = new TreeMap<>(); 17 | 18 | @Expose 19 | public Map event = new TreeMap<>(); 20 | 21 | @Expose 22 | public Map list = new TreeMap<>(); 23 | 24 | @Expose 25 | public Map dynamic = new TreeMap<>(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sound/StreamingSound.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sound; 2 | 3 | public interface StreamingSound { 4 | /** 5 | * Fading unit is in seconds. 6 | * 7 | * @param fadeIn 8 | */ 9 | void play(float fadeIn); 10 | 11 | /** 12 | * Fading unit is in seconds. 13 | * 14 | * @param fadeOut 15 | */ 16 | void stop(float fadeOut); 17 | 18 | /** 19 | * Instantly applies a volume modulation to this stream, upon the initially set volume. 20 | * 21 | * @param volumeMod 22 | */ 23 | void applyVolume(float volumeMod); 24 | 25 | /** 26 | * Dispose of this StreamingSound. The StreamingSound should never be able to be used again. 27 | */ 28 | void dispose(); 29 | 30 | void interrupt(); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/serialisation/expansion/SerialMachine.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.serialisation.expansion; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Set; 6 | import java.util.TreeSet; 7 | 8 | import com.google.gson.annotations.Expose; 9 | 10 | public class SerialMachine { 11 | @Expose 12 | public Set allow = new TreeSet<>(); 13 | 14 | @Expose 15 | public Set restrict = new TreeSet<>(); 16 | 17 | @Expose 18 | public float fadein; 19 | 20 | @Expose 21 | public float fadeout; 22 | 23 | @Expose 24 | public float delay_fadein; 25 | 26 | @Expose 27 | public float delay_fadeout; 28 | 29 | @Expose 30 | public List event = new ArrayList<>(); 31 | 32 | @Expose 33 | public SerialMachineStream stream; 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/agents/JsonLoadingAgent.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion.agents; 2 | 3 | import java.util.Scanner; 4 | 5 | import eu.ha3.matmos.core.Knowledge; 6 | import eu.ha3.matmos.core.expansion.ExpansionIdentity; 7 | import eu.ha3.matmos.serialisation.JsonExpansions_EngineDeserializer; 8 | 9 | public class JsonLoadingAgent implements LoadingAgent { 10 | @Override 11 | public boolean load(ExpansionIdentity identity, Knowledge knowledge) { 12 | try (Scanner sc = new Scanner(identity.getPack().getInputStream(identity.getLocation()))) { 13 | return new JsonExpansions_EngineDeserializer().loadJson(sc.useDelimiter("\\Z").next(), identity, knowledge); 14 | } catch (Exception e) { 15 | e.printStackTrace(); 16 | return false; 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModuleArmour.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.entity.player.EntityPlayer; 7 | 8 | /** 9 | * Module for processing a player's armour slot. Only one. 10 | */ 11 | public class ModuleArmour extends ModuleProcessor implements Module { 12 | public ModuleArmour(DataPackage data) { 13 | super(data, "ply_armor"); 14 | } 15 | 16 | @Override 17 | protected void doProcess() { 18 | EntityPlayer player = getPlayer(); 19 | 20 | for (int i = 0; i < 4; i++) { 21 | ItemProcessorHelper.setValue(this, player.inventory.armorInventory.get(i), Integer.toString(i)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModuleArmourEnchantment.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import net.minecraft.entity.player.EntityPlayer; 5 | import net.minecraft.inventory.EntityEquipmentSlot; 6 | import net.minecraft.item.ItemStack; 7 | 8 | /** 9 | * Module for discovering enchantments on a player's armour. 10 | */ 11 | public class ModuleArmourEnchantment extends AbstractEnchantmentModule { 12 | private final int slot; 13 | 14 | public ModuleArmourEnchantment(DataPackage data, EntityEquipmentSlot slot) { 15 | super(data, "ench_armor" + slot.getSlotIndex()); 16 | this.slot = slot.getSlotIndex(); 17 | } 18 | 19 | @Override 20 | protected ItemStack getItem(EntityPlayer player) { 21 | return player.inventory.armorInventory.get(slot); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/agents/RawJsonLoadingAgent.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion.agents; 2 | 3 | import eu.ha3.matmos.core.Knowledge; 4 | import eu.ha3.matmos.core.expansion.ExpansionIdentity; 5 | import eu.ha3.matmos.serialisation.JsonExpansions_EngineDeserializer; 6 | 7 | public class RawJsonLoadingAgent implements LoadingAgent { 8 | private final String jasonString; 9 | 10 | public RawJsonLoadingAgent(String jasonString) { 11 | this.jasonString = jasonString; 12 | } 13 | 14 | @Override 15 | public boolean load(ExpansionIdentity identity, Knowledge knowledge) { 16 | try { 17 | return new JsonExpansions_EngineDeserializer().loadJson(jasonString, identity, knowledge); 18 | } catch (Exception e) { 19 | e.printStackTrace(); 20 | return false; 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sheet/SheetCommander.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sheet; 2 | 3 | public interface SheetCommander { 4 | /** 5 | * Tells if the sheet index exists 6 | * 7 | * @param sheetIndex 8 | * @return 9 | */ 10 | boolean exists(SheetIndex sheetIndex); 11 | 12 | /** 13 | * Gets the version of the sheet index 14 | * 15 | * @param sheetIndex 16 | * @return 17 | */ 18 | int version(SheetIndex sheetIndex); 19 | 20 | /** 21 | * Returns the value of the sheet index 22 | * 23 | * @param sheetIndex 24 | * @return 25 | */ 26 | T get(SheetIndex sheetIndex); 27 | 28 | /** 29 | * Tells if a list has a certain value. 30 | * 31 | * @param constantX 32 | * @param value 33 | * @return 34 | */ 35 | boolean listHas(String constantX, String value); 36 | } 37 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/filechooser/JsonFileChooser.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.filechooser; 2 | 3 | import java.io.File; 4 | 5 | import javax.swing.JFileChooser; 6 | import javax.swing.filechooser.FileNameExtensionFilter; 7 | 8 | /** 9 | * Courtesy of http://geek.starbean.net/?p=275 10 | * 11 | * << http://stackoverflow.com/questions/8581215/jfilechooser-and-checking-for-overwrite 12 | */ 13 | @SuppressWarnings("serial") 14 | public class JsonFileChooser extends JFileChooser { 15 | protected String dotlessExtension; 16 | 17 | public JsonFileChooser(File dir) { 18 | this(dir, "json"); 19 | } 20 | 21 | private JsonFileChooser(File dir, String dotlessExtension) { 22 | super(dir); 23 | this.dotlessExtension = dotlessExtension; 24 | addChoosableFileFilter(new FileNameExtensionFilter(String.format("%1$s Jason file (*.%1$s)", dotlessExtension), dotlessExtension)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/MappedProvider.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import java.util.Map; 4 | import java.util.Set; 5 | 6 | public class MappedProvider implements Provider { 7 | private Map map; 8 | 9 | public MappedProvider(Map map) { 10 | this.map = map; 11 | } 12 | 13 | @Override 14 | public boolean exists(String name) { 15 | return this.map.containsKey(name); 16 | } 17 | 18 | @Override 19 | public int version(String name) { 20 | return this.map.containsKey(name) ? this.map.get(name).version() : -1; 21 | } 22 | 23 | @Override 24 | public T get(String name) { 25 | return this.map.get(name); 26 | } 27 | 28 | @Override 29 | public T instance() { 30 | return null; 31 | } 32 | 33 | @Override 34 | public Set keySet() { 35 | return this.map.keySet(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/filechooser/OggFileChooser.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.filechooser; 2 | 3 | import java.io.File; 4 | 5 | import javax.swing.JFileChooser; 6 | import javax.swing.filechooser.FileNameExtensionFilter; 7 | 8 | /** 9 | * Courtesy of http://geek.starbean.net/?p=275 10 | * 11 | * << http://stackoverflow.com/questions/8581215/jfilechooser-and-checking-for-overwrite 12 | */ 13 | @SuppressWarnings("serial") 14 | public class OggFileChooser extends JFileChooser { 15 | protected String dotlessExtension; 16 | 17 | public OggFileChooser(File dir) { 18 | this(dir, "ogg"); 19 | } 20 | 21 | private OggFileChooser(File dir, String dotlessExtension) { 22 | super(dir); 23 | this.dotlessExtension = dotlessExtension; 24 | addChoosableFileFilter(new FileNameExtensionFilter( 25 | String.format("%1$s Ogg file (*.%1$s)", dotlessExtension), dotlessExtension)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/VirtualModuleProcessor.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | 5 | /** 6 | * Implements doProcess with nothing inside it. This class is used for placeholder modules where the 7 | * logic of updating the sheet is outsourced to another logic. One should call the set...() methods 8 | * of this class to prepare the new values, and calling process() will apply the virtual sheets that 9 | * this module processor contains. 10 | * 11 | * @author Hurry 12 | */ 13 | public class VirtualModuleProcessor extends ModuleProcessor { 14 | public VirtualModuleProcessor(DataPackage data, String name) { 15 | super(data, name); 16 | } 17 | 18 | public VirtualModuleProcessor(DataPackage data, String name, boolean doNotUseDelta) { 19 | super(data, name, doNotUseDelta); 20 | } 21 | 22 | @Override 23 | protected void doProcess() { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/soundpacks/default/assets/matmos/expansions.json: -------------------------------------------------------------------------------- 1 | { 2 | "expansions" : [ 3 | { 4 | "uniquename" : "eu.ha3.default.earthlies", 5 | "friendlyname" : "Default 2016: Earthlies", 6 | "pointer" : "expansions/earthlies_database.json" 7 | }, 8 | { 9 | "uniquename" : "eu.ha3.default.environments", 10 | "friendlyname" : "Default 2016: Environments", 11 | "pointer" : "expansions/interactions_environments.json" 12 | }, 13 | { 14 | "uniquename" : "eu.ha3.default.extras", 15 | "friendlyname" : "Default 2016: Extras", 16 | "pointer" : "expansions/interactions_extras.json" 17 | }, 18 | { 19 | "uniquename" : "eu.ha3.default.itemswitches", 20 | "friendlyname" : "Default 2016: Itemswitches", 21 | "pointer" : "expansions/interactions_itemswitches.json" 22 | }, 23 | { 24 | "uniquename" : "eu.ha3.default.weapons", 25 | "friendlyname" : "Default 2016: Weapons", 26 | "pointer" : "expansions/interactions_weapons.json" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/InstantTextField.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | import javax.swing.JTextField; 4 | import javax.swing.event.DocumentEvent; 5 | import javax.swing.event.DocumentListener; 6 | 7 | public class InstantTextField extends JTextField { 8 | private static final long serialVersionUID = 1L; 9 | 10 | public InstantTextField() { 11 | super(); 12 | 13 | getDocument().addDocumentListener(new DocumentListener() { 14 | @Override 15 | public void changedUpdate(DocumentEvent e) { 16 | editEvent(); 17 | } 18 | 19 | @Override 20 | public void removeUpdate(DocumentEvent e) { 21 | editEvent(); 22 | } 23 | 24 | @Override 25 | public void insertUpdate(DocumentEvent e) { 26 | editEvent(); 27 | } 28 | }); 29 | } 30 | 31 | protected void editEvent() { 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModuleInventory.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.entity.player.EntityPlayer; 7 | 8 | /** 9 | * Inventory processing to discover items the player is holding or has as a helmet. 10 | */ 11 | public class ModuleInventory extends ModuleProcessor implements Module { 12 | public ModuleInventory(DataPackage data) { 13 | super(data, "ply_inventory"); 14 | } 15 | 16 | @Override 17 | protected void doProcess() { 18 | EntityPlayer player = getPlayer(); 19 | 20 | setValue("held_slot", player.inventory.currentItem); 21 | ItemProcessorHelper.setValue(this, player.inventory.getCurrentItem(), "current"); 22 | ItemProcessorHelper.setValue(this, player.inventory.getItemStack(), "item_in_cursor"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/Module.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import eu.ha3.matmos.core.Named; 4 | import eu.ha3.matmos.data.IDataGatherer; 5 | 6 | public interface Module extends IDataGatherer, Named { 7 | int LEGACY_NO_ITEM = -1; 8 | int LEGACY_NO_BLOCK_IN_THIS_CONTEXT = 0; 9 | int LEGACY_NO_BLOCK_OUT_OF_BOUNDS = 0; 10 | 11 | /** 12 | * This is a magic value to designate a block that is outside the world's actual bounds 13 | */ 14 | String NO_BLOCK_OUT_OF_BOUNDS = ""; 15 | 16 | /** 17 | * This is a magic value to designate a failed detection of block that is unrelated to the world 18 | * height. 19 | */ 20 | String NO_BLOCK_IN_THIS_CONTEXT = ""; 21 | 22 | /** 23 | * This is a magic value to designate the lack of equipped item. 24 | */ 25 | String NO_ITEM = ""; 26 | String NO_POWERMETA = ""; 27 | String NO_NAME = ""; 28 | String NO_ENTITY = ""; 29 | 30 | int NO_META = -1; 31 | } 32 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/PopupHelper.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | import javax.swing.JOptionPane; 4 | 5 | public class PopupHelper { 6 | private static KnowledgeItemType lastChoice = KnowledgeItemType.CONDITION; 7 | 8 | public static KnowledgeItemType askForType(EditorWindow editorWindow, String title) { 9 | KnowledgeItemType choice = (KnowledgeItemType)JOptionPane.showInputDialog( 10 | editorWindow, "Select new item type", title, JOptionPane.PLAIN_MESSAGE, null, 11 | KnowledgeItemType.values(), lastChoice); 12 | if (choice != null) { 13 | lastChoice = choice; 14 | } 15 | return choice; 16 | } 17 | 18 | public static String askForName(EditorWindow editorWindow, String title, String def) { 19 | String name = (String)JOptionPane.showInputDialog( 20 | editorWindow, "Choose a name", title, JOptionPane.PLAIN_MESSAGE, null, null, def); 21 | 22 | return name; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/legacy/ModuleLegacyColumn.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.legacy; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import eu.ha3.matmos.util.MAtUtil; 7 | import net.minecraft.util.math.BlockPos; 8 | 9 | public class ModuleLegacyColumn extends ModuleProcessor implements Module { 10 | public ModuleLegacyColumn(DataPackage data) { 11 | super(data, "legacy_column"); 12 | } 13 | 14 | @Override 15 | protected void doProcess() { 16 | BlockPos pos = getPlayer().getPosition(); 17 | 18 | setValue("y-1_as_number", MAtUtil.legacyOf(MAtUtil.getBlockAt(pos.down()))); 19 | setValue("y-2_as_number", MAtUtil.legacyOf(MAtUtil.getBlockAt(pos.down(2)))); 20 | setValue("y0_as_number", MAtUtil.legacyOf(MAtUtil.getBlockAt(pos))); 21 | setValue("y1_as_number", MAtUtil.legacyOf(MAtUtil.getBlockAt(pos.up()))); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Provider.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import java.util.Set; 4 | 5 | public interface Provider { 6 | /** 7 | * Returns whether a named object exists. 8 | * 9 | * @param name 10 | * @return 11 | */ 12 | boolean exists(String name); 13 | 14 | /** 15 | * Returns a named object version from the provider, or -1 if it doesn't exist. 16 | * 17 | * @param name 18 | * @return 19 | */ 20 | int version(String name); 21 | 22 | /** 23 | * Returns an named object from the provider, or null if it doesn't exist. 24 | * 25 | * @param name 26 | * @return 27 | */ 28 | T get(String name); 29 | 30 | /** 31 | * Returns a commanding instance of the provider. 32 | * 33 | * @return 34 | */ 35 | T instance(); 36 | 37 | /** 38 | * Returns the keySet. Use with care, preferably for debugging purposes. 39 | * 40 | * @return 41 | */ 42 | Set keySet(); 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/ThousandStringCountModule.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import java.util.Map.Entry; 4 | 5 | import eu.ha3.matmos.core.sheet.DataPackage; 6 | 7 | // XXX: This is a terrible use of extends. 8 | public class ThousandStringCountModule extends ExternalStringCountModule { 9 | private int total = 0; 10 | 11 | public ThousandStringCountModule(DataPackage data, String name, boolean doNotUseDelta) { 12 | super(data, name, doNotUseDelta); 13 | } 14 | 15 | public ThousandStringCountModule(DataPackage data, String name) { 16 | super(data, name); 17 | } 18 | 19 | @Override 20 | public void increment(String name) { 21 | super.increment(name); 22 | total++; 23 | } 24 | 25 | @Override 26 | public void apply() { 27 | for (Entry entry : things.entrySet()) { 28 | entry.setValue((int)Math.ceil((float)entry.getValue() / total * 1000f)); 29 | } 30 | super.apply(); 31 | total = 0; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/world/ModuleLighting.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.world; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.util.math.BlockPos; 8 | import net.minecraft.world.EnumSkyBlock; 9 | import net.minecraft.world.World; 10 | 11 | public class ModuleLighting extends ModuleProcessor implements Module { 12 | public ModuleLighting(DataPackage data) { 13 | super(data, "cb_light"); 14 | } 15 | 16 | @Override 17 | protected void doProcess() { 18 | World w = Minecraft.getMinecraft().world; 19 | 20 | BlockPos playerPos = getPlayer().getPosition(); 21 | 22 | setValue("sky", w.getLightFor(EnumSkyBlock.SKY, playerPos)); 23 | setValue("lamp", w.getLightFor(EnumSkyBlock.BLOCK, playerPos)); 24 | setValue("final", w.getLight(playerPos)); 25 | setValue("see_sky", w.canSeeSky(playerPos)); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModuleAction.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.client.entity.EntityPlayerSP; 8 | 9 | /** 10 | * Processing module for discovering player actions. Swing, Fall, Item_Use, etc. 11 | */ 12 | public class ModuleAction extends ModuleProcessor implements Module { 13 | public ModuleAction(DataPackage data) { 14 | super(data, "ply_action"); 15 | } 16 | 17 | @Override 18 | protected void doProcess() { 19 | EntityPlayerSP player = Minecraft.getMinecraft().player; 20 | 21 | setValue("swing_progress16", (int)Math.floor(player.swingProgress * 16)); 22 | setValue("swinging", player.swingProgress != 0); 23 | setValue("fall_distance1k", (int)(player.fallDistance * 1000)); 24 | setValue("item_use_duration", player.getItemInUseCount()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/ExpansionIdentity.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion; 2 | 3 | import net.minecraft.client.resources.IResourcePack; 4 | import net.minecraft.util.ResourceLocation; 5 | 6 | public final class ExpansionIdentity { 7 | private final String uniqueName; 8 | private final String friendlyName; 9 | private final IResourcePack pack; 10 | private final ResourceLocation location; 11 | 12 | public ExpansionIdentity(String uniqueName, String friendlyName, IResourcePack pack, ResourceLocation location) { 13 | this.uniqueName = uniqueName; 14 | this.friendlyName = friendlyName; 15 | this.pack = pack; 16 | this.location = location; 17 | } 18 | 19 | public String getUniqueName() { 20 | return uniqueName; 21 | } 22 | 23 | public String getFriendlyName() { 24 | return friendlyName; 25 | } 26 | 27 | public IResourcePack getPack() { 28 | return pack; 29 | } 30 | 31 | public ResourceLocation getLocation() { 32 | return location; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ItemProcessorHelper.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import eu.ha3.matmos.data.modules.Module; 4 | import eu.ha3.matmos.data.modules.ProcessorModel; 5 | import eu.ha3.matmos.util.MAtUtil; 6 | import net.minecraft.item.ItemStack; 7 | 8 | class ItemProcessorHelper { 9 | static void setValue(ProcessorModel model, ItemStack item, String prefix) { 10 | if (item == null) { 11 | model.setValue(prefix + "_item", Module.NO_ITEM); 12 | model.setValue(prefix + "_damage", Module.NO_META); 13 | model.setValue(prefix + "_name_display", Module.NO_NAME); 14 | model.setValue(prefix + "_powermeta", Module.NO_POWERMETA); 15 | } else { 16 | model.setValue(prefix + "_item", MAtUtil.nameOf(item)); 17 | model.setValue(prefix + "_damage", item.getMetadata()); 18 | model.setValue(prefix + "_name_display", item.getDisplayName()); 19 | model.setValue(prefix + "_powermeta", MAtUtil.asPowerMeta(item)); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/util/Tags.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.util; 2 | 3 | import java.util.Iterator; 4 | 5 | import net.minecraft.nbt.NBTTagCompound; 6 | import net.minecraft.nbt.NBTTagList; 7 | 8 | public final class Tags implements Iterable, Iterator { 9 | private static final Iterable EMPTY = new Tags(null); 10 | 11 | private final NBTTagList list; 12 | private int index = 0; 13 | 14 | public static Iterable of(NBTTagList tags) { 15 | if (tags == null || tags.tagCount() == 0) return EMPTY; 16 | return new Tags(tags); 17 | } 18 | 19 | private Tags(NBTTagList tags) { 20 | list = tags; 21 | } 22 | 23 | @Override 24 | public Iterator iterator() { 25 | return this; 26 | } 27 | 28 | @Override 29 | public boolean hasNext() { 30 | return list != null && index < list.tagCount(); 31 | } 32 | 33 | @Override 34 | public NBTTagCompound next() { 35 | return list.getCompoundTagAt(index++); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/mixin/MixinSoundManager$1.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.mixin; 2 | 3 | import org.spongepowered.asm.mixin.Final; 4 | import org.spongepowered.asm.mixin.Mixin; 5 | import org.spongepowered.asm.mixin.Shadow; 6 | import org.spongepowered.asm.mixin.injection.At; 7 | import org.spongepowered.asm.mixin.injection.Redirect; 8 | 9 | import eu.ha3.matmos.core.ducks.ISoundManager; 10 | import net.minecraft.client.audio.SoundManager; 11 | import paulscode.sound.SoundSystem; 12 | 13 | @Mixin(targets = "net/minecraft/client/audio/SoundManager$1") 14 | abstract class MixinSoundManager$1 implements Runnable { 15 | 16 | @Shadow(aliases = {"this$0", "field_177224_a", "a"}) 17 | @Final 18 | private SoundManager outerThis; 19 | 20 | @Redirect(method = "run()V", 21 | at = @At(value = "INVOKE", target = "Lpaulscode/sound/SoundSystem;setMasterVolume(F)V")) 22 | private void redirectSetMasterVolume(SoundSystem sndSystem, float value) { 23 | ((ISoundManager)outerThis).setSoundSystem(sndSystem); 24 | sndSystem.setMasterVolume(value); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/util/math/Numbers.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.util.math; 2 | 3 | public class Numbers { 4 | public static Long toLong(Object o) { 5 | if (o == null) { 6 | return null; 7 | } 8 | 9 | if (o instanceof Long) { 10 | return (Long)o; 11 | } 12 | 13 | if (o instanceof String) { 14 | try { 15 | return Long.parseLong((String)o); 16 | } catch (NumberFormatException e) { 17 | return null; 18 | } 19 | } 20 | 21 | return null; 22 | } 23 | 24 | public static Float toFloat(Object o) { 25 | if (o == null) { 26 | return null; 27 | } 28 | 29 | if (o instanceof Float) { 30 | return (Float)o; 31 | } 32 | 33 | if (o instanceof String) { 34 | try { 35 | return Float.parseFloat((String)o); 36 | } catch (NumberFormatException e) { 37 | return null; 38 | } 39 | } 40 | 41 | return null; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/ExternalStringCountModule.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.core.sheet.VirtualSheet; 5 | 6 | /** 7 | * Call commit() to apply the changes. 8 | * 9 | * @author Hurry 10 | */ 11 | public class ExternalStringCountModule extends AbstractStringCountModule { 12 | public ExternalStringCountModule(DataPackage data, String name) { 13 | super(data, name); 14 | } 15 | 16 | public ExternalStringCountModule(DataPackage data, String name, boolean doNotUseDelta) { 17 | super(data, name, doNotUseDelta); 18 | } 19 | 20 | @Override 21 | public void process() { 22 | // Don't use 23 | } 24 | 25 | @Override 26 | public void doProcess() { 27 | // Don't use 28 | } 29 | 30 | @Override 31 | public void count() { 32 | // Don't use 33 | } 34 | 35 | protected void commit() { 36 | apply(); 37 | if (sheet instanceof VirtualSheet) { 38 | ((VirtualSheet)sheet).apply(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/util/math/MAtMutableBlockPos.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.util.math; 2 | 3 | import net.minecraft.util.math.BlockPos; 4 | 5 | /** 6 | * @author dags_ 7 | */ 8 | public class MAtMutableBlockPos extends BlockPos { 9 | private static final MAtMutableBlockPos INSTANCE = new MAtMutableBlockPos(); 10 | 11 | private int x; 12 | private int y; 13 | private int z; 14 | 15 | private MAtMutableBlockPos() { 16 | super(0, 0, 0); 17 | } 18 | 19 | /** 20 | * Returns a block position wrapper set at the given coordinates. 21 | */ 22 | public static BlockPos of(int x, int y, int z) { 23 | return INSTANCE.at(x, y, z); 24 | } 25 | 26 | private MAtMutableBlockPos at(int xPos, int yPos, int zPos) { 27 | x = xPos; 28 | y = yPos; 29 | z = zPos; 30 | return this; 31 | } 32 | 33 | @Override 34 | public int getX() { 35 | return x; 36 | } 37 | 38 | @Override 39 | public int getY() { 40 | return y; 41 | } 42 | 43 | @Override 44 | public int getZ() { 45 | return z; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Component.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | public abstract class Component implements Named, Versioned { 7 | private final String name; 8 | private final Set listeners; 9 | private int version; 10 | 11 | public Component(String name) { 12 | this.name = name; 13 | listeners = new HashSet<>(); 14 | version = -1; 15 | } 16 | 17 | @Override 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return "[(" + this.getClass().toString() + ") " + name + "]"; 25 | } 26 | 27 | @Override 28 | public int version() { 29 | return version; 30 | } 31 | 32 | @Override 33 | public void incrementVersion() { 34 | version = version + 1; 35 | 36 | for (VersionListener listener : listeners) { 37 | listener.onIncrement(this); 38 | } 39 | } 40 | 41 | @Override 42 | public void registerVersionListener(VersionListener listener) { 43 | listeners.add(listener); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/mount/ModuleRidingMotion.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.mount; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.entity.Entity; 7 | 8 | public class ModuleRidingMotion extends ModuleProcessor implements Module { 9 | public ModuleRidingMotion(DataPackage data) { 10 | super(data, "ride_motion"); 11 | } 12 | 13 | @Override 14 | protected void doProcess() { 15 | Entity ride = getPlayer().getRidingEntity(); 16 | 17 | if (ride != null) { 18 | int mxx = (int)Math.round(ride.motionX * 1000); 19 | int mzz = (int)Math.round(ride.motionZ * 1000); 20 | 21 | setValue("x_1k", mxx); 22 | setValue("y_1k", (int)Math.round(ride.motionY * 1000)); 23 | setValue("z_1k", mzz); 24 | setValue("sqrt_xx_zz", (int)Math.floor(Math.sqrt(mxx * mxx + mzz * mzz))); 25 | } else { 26 | setValue("x_1k", 0); 27 | setValue("y_1k", 0); 28 | setValue("z_1k", 0); 29 | setValue("sqrt_xx_zz", 0); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModuleMotion.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.entity.player.EntityPlayer; 7 | 8 | /** 9 | * Processing module for player motion. 10 | */ 11 | public class ModuleMotion extends ModuleProcessor implements Module { 12 | public ModuleMotion(DataPackage data) { 13 | super(data, "ply_motion"); 14 | } 15 | 16 | @Override 17 | protected void doProcess() { 18 | EntityPlayer player = getPlayer(); 19 | 20 | setValue("x_1k", (int)Math.round(player.motionX * 1000)); 21 | setValue("y_1k", (int)Math.round(player.motionY * 1000)); 22 | setValue("z_1k", (int)Math.round(player.motionZ * 1000)); 23 | setValue("sqrt_xx_zz", (int)Math.floor(Math.sqrt( 24 | Math.pow(player.motionX, 2) 25 | + Math.pow(player.motionZ, 2) 26 | )) 27 | ); 28 | setValue("sqrt_xx_yy_zz", (int)Math.floor(Math.sqrt( 29 | Math.pow(player.motionX, 2) 30 | + Math.pow(player.motionY, 2) 31 | + Math.pow(player.motionZ, 2) 32 | )) 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sheet/SheetDataPackage.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sheet; 2 | 3 | import java.util.Map; 4 | import java.util.Set; 5 | import java.util.TreeMap; 6 | 7 | /** 8 | * Represents a data package populated by data sheets. 9 | */ 10 | public class SheetDataPackage implements DataPackage { 11 | private final Map sheets; 12 | private final Class sheetType; 13 | 14 | public SheetDataPackage(Class sheetType) { 15 | sheets = new TreeMap<>(); 16 | this.sheetType = sheetType; 17 | } 18 | 19 | @Override 20 | public Sheet getSheet(String name) { 21 | if (!sheets.containsKey(name)) { 22 | try { 23 | sheets.put(name, sheetType.newInstance()); 24 | } catch (Exception e) { 25 | throw new RuntimeException(e); 26 | } 27 | } 28 | 29 | return sheets.get(name); 30 | 31 | } 32 | 33 | @Override 34 | public Set getSheetNames() { 35 | return sheets.keySet(); 36 | } 37 | 38 | @Override 39 | public void clear() { 40 | sheets.clear(); 41 | } 42 | 43 | @Override 44 | public void clearContents() { 45 | for (Sheet sheet : sheets.values()) { 46 | sheet.clear(); 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/mount/ModuleRiding.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.mount; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.entity.Entity; 7 | import net.minecraft.entity.EntityList; 8 | import net.minecraft.entity.item.EntityBoat; 9 | import net.minecraft.entity.item.EntityMinecart; 10 | import net.minecraft.entity.passive.EntityHorse; 11 | import net.minecraft.entity.passive.EntityPig; 12 | import net.minecraft.entity.player.EntityPlayer; 13 | 14 | public class ModuleRiding extends ModuleProcessor implements Module { 15 | public ModuleRiding(DataPackage data) { 16 | super(data, "ride_general"); 17 | } 18 | 19 | @Override 20 | protected void doProcess() { 21 | Entity ride = getPlayer().getRidingEntity(); 22 | 23 | setValue("minecart", ride instanceof EntityMinecart); 24 | setValue("boat", ride instanceof EntityBoat); 25 | setValue("pig", ride instanceof EntityPig); 26 | setValue("horse", ride instanceof EntityHorse); 27 | setValue("player", ride instanceof EntityPlayer); 28 | 29 | setValue("burning", ride != null && ride.isBurning()); 30 | setValue("entity_id", ride == null ? NO_ENTITY : EntityList.getEntityString(ride)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModuleStats.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import eu.ha3.matmos.core.mixin.IFoodStats; 4 | import eu.ha3.matmos.core.sheet.DataPackage; 5 | import eu.ha3.matmos.data.modules.Module; 6 | import eu.ha3.matmos.data.modules.ModuleProcessor; 7 | import net.minecraft.entity.player.EntityPlayer; 8 | 9 | /** 10 | * Processing module for deeper player statistics. Health, Oxygen, Food, etc. 11 | */ 12 | public class ModuleStats extends ModuleProcessor implements Module { 13 | public ModuleStats(DataPackage data) { 14 | super(data, "ply_stats"); 15 | } 16 | 17 | @Override 18 | protected void doProcess() { 19 | EntityPlayer player = getPlayer(); 20 | 21 | setValue("health1k", (int)(player.getHealth() * 1000)); 22 | setValue("oxygen", player.getAir()); 23 | setValue("armor", player.getTotalArmorValue()); 24 | setValue("food", player.getFoodStats().getFoodLevel()); 25 | setValue("saturation1k", (int)(player.getFoodStats().getSaturationLevel() * 1000)); 26 | setValue("exhaustion1k", (int)(((IFoodStats)player.getFoodStats()).getFoodExhaustionLevel() * 1000)); 27 | setValue("experience1k", (int)(player.experience * 1000)); 28 | setValue("experience_level", player.experienceLevel); 29 | setValue("experience_total", player.experienceTotal); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModuleLeashing.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import java.util.List; 4 | 5 | import eu.ha3.matmos.core.sheet.DataPackage; 6 | import eu.ha3.matmos.data.modules.Module; 7 | import eu.ha3.matmos.data.modules.ModuleProcessor; 8 | import net.minecraft.entity.EntityLiving; 9 | import net.minecraft.entity.player.EntityPlayer; 10 | import net.minecraft.util.math.AxisAlignedBB; 11 | 12 | /** 13 | * Processing module for the total entities a player has leashed and withing range. (default 20 14 | * blocks) 15 | */ 16 | public class ModuleLeashing extends ModuleProcessor implements Module { 17 | private static final int RADIUS = 20; 18 | 19 | public ModuleLeashing(DataPackage data) { 20 | super(data, "ply_leash"); 21 | } 22 | 23 | @Override 24 | protected void doProcess() { 25 | EntityPlayer player = getPlayer(); 26 | 27 | List entities = player.getEntityWorld().getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB( 28 | player.posX - RADIUS, player.posY - RADIUS, 29 | player.posZ - RADIUS, player.posX + RADIUS, 30 | player.posY + RADIUS, player.posZ + RADIUS)); 31 | 32 | setValue("total", entities.stream().filter(entity -> { 33 | return entity.getLeashed() && entity.getLeashHolder() == player; 34 | }).count()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/world/ModuleBiome.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.world; 2 | 3 | import eu.ha3.matmos.Matmos; 4 | import eu.ha3.matmos.core.sheet.DataPackage; 5 | import eu.ha3.matmos.data.modules.Module; 6 | import eu.ha3.matmos.data.modules.ModuleProcessor; 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.util.math.BlockPos; 9 | import net.minecraft.world.biome.Biome; 10 | 11 | public class ModuleBiome extends ModuleProcessor implements Module { 12 | private final Matmos mod; 13 | 14 | public ModuleBiome(DataPackage data, Matmos mod) { 15 | super(data, "w_biome"); 16 | this.mod = mod; 17 | } 18 | 19 | @Override 20 | protected void doProcess() { 21 | int biomej = mod.getConfig().getInteger("useroptions.biome.override"); 22 | 23 | if (biomej <= -1) { 24 | Biome biome = calculateBiome(); 25 | setValue("id", Biome.getIdForBiome(biome)); 26 | setValue("biome_name", biome.getBiomeName()); 27 | } else { 28 | setValue("id", biomej); 29 | setValue("biome_name", ""); 30 | } 31 | } 32 | 33 | private Biome calculateBiome() { 34 | Minecraft mc = Minecraft.getMinecraft(); 35 | BlockPos playerPos = getPlayer().getPosition(); 36 | 37 | return mc.world.getChunk(playerPos).getBiome(playerPos, mc.world.getBiomeProvider()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/world/ModuleCollission.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.world; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.AbstractStringCountModule; 5 | import eu.ha3.matmos.util.MAtUtil; 6 | import net.minecraft.util.math.BlockPos; 7 | 8 | public class ModuleCollission extends AbstractStringCountModule { 9 | private final BlockPos[] blocks = { 10 | new BlockPos(0, -1, 0), // bottom 11 | BlockPos.ORIGIN, 12 | new BlockPos(0, 1, 0), // body 13 | new BlockPos(0, 2, 0), // column 14 | new BlockPos(-1, 0, 0), 15 | new BlockPos(1, 0, 0), // x -- 0 16 | new BlockPos(0, 0, -1), 17 | new BlockPos(0, 0, 1), // z -- 0 18 | new BlockPos(-1, 1, 0), 19 | new BlockPos(1, 1, 0), // x -- 1 20 | new BlockPos(0, 1, -1), 21 | new BlockPos(0, 1, 1), // z -- 1 22 | }; 23 | 24 | public ModuleCollission(DataPackage dataIn) { 25 | super(dataIn, "block_contact", true); 26 | dataIn.getSheet(getName()).setDefaultValue("0"); 27 | } 28 | 29 | @Override 30 | protected void count() { 31 | for (BlockPos triplet : blocks) { 32 | BlockPos center = triplet.add(getPlayer().getPosition()); 33 | increment(MAtUtil.getNameAt(center, "")); 34 | increment(MAtUtil.getPowerMetaAt(center, "")); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/WindowEventQueue.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | import java.awt.Component; 4 | import java.awt.EventQueue; 5 | 6 | import eu.ha3.matmos.editor.interfaces.Window; 7 | import eu.ha3.matmos.serialisation.expansion.SerialRoot; 8 | 9 | public class WindowEventQueue implements Window { 10 | private Window window; 11 | 12 | public WindowEventQueue(Window window) { 13 | this.window = window; 14 | } 15 | 16 | @Override 17 | public void updateSerial(final SerialRoot root) { 18 | EventQueue.invokeLater(() -> window.updateSerial(root)); 19 | } 20 | 21 | @Override 22 | public void setEditFocus(final String name, final Object item, boolean forceSelect) { 23 | EventQueue.invokeLater(() -> window.setEditFocus(name, item, false)); 24 | } 25 | 26 | @Override 27 | public Component asComponent() { 28 | return window.asComponent(); 29 | } 30 | 31 | @Override 32 | public void display() { 33 | EventQueue.invokeLater(window::display); 34 | } 35 | 36 | @Override 37 | public void refreshFileState() { 38 | EventQueue.invokeLater(window::refreshFileState); 39 | } 40 | 41 | @Override 42 | public void showErrorPopup(String error) { 43 | EventQueue.invokeLater(() -> window.showErrorPopup(error)); 44 | } 45 | 46 | @Override 47 | public void disableMinecraftCapabilitites() { 48 | EventQueue.invokeLater(window::disableMinecraftCapabilitites); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sheet/DeltaSheet.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sheet; 2 | 3 | import eu.ha3.matmos.util.math.Numbers; 4 | 5 | public class DeltaSheet extends GenericSheet implements VirtualSheet { 6 | private final DataPackage data; 7 | 8 | private final String actualSheet; 9 | private final String deltaSheet; 10 | 11 | public DeltaSheet(DataPackage data, String actualSheet, String deltaSheet) { 12 | this.data = data; 13 | this.actualSheet = actualSheet; 14 | this.deltaSheet = deltaSheet; 15 | } 16 | 17 | @Override 18 | public void apply() { 19 | for (String key : values.keySet()) { 20 | 21 | Sheet actual = data.getSheet(actualSheet); 22 | 23 | String previousValue = actual.getOrDefault(key, "0"); 24 | String newValue = values.get(key); 25 | 26 | actual.set(key, newValue); 27 | data.getSheet(deltaSheet).set(key, computeDelta(previousValue, newValue)); 28 | } 29 | 30 | clear(); 31 | } 32 | 33 | protected String computeDelta(String previousValue, String newValue) { 34 | Long newLong = Numbers.toLong(newValue); 35 | 36 | if (newLong != null) { 37 | Long previousLong = Numbers.toLong(previousValue); 38 | 39 | if (previousLong != null) { 40 | return Long.toString(newLong - previousLong); 41 | } 42 | } 43 | 44 | return newValue.equals(previousValue) ? "NOT_MODIFIED" : "MODIFIED"; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/interfaces/Editor.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.interfaces; 2 | 3 | import java.io.File; 4 | 5 | import eu.ha3.matmos.editor.KnowledgeItemType; 6 | import eu.ha3.matmos.editor.tree.Selector; 7 | import eu.ha3.matmos.serialisation.expansion.SerialEvent; 8 | import eu.ha3.matmos.serialisation.expansion.SerialRoot; 9 | 10 | public interface Editor { 11 | File getExpansionDirectory(); 12 | 13 | File getSoundDirectory(); 14 | 15 | File getWorkingDirectory(); 16 | 17 | void minecraftReloadFromDisk(); 18 | 19 | void minecraftPushCurrentState(); 20 | 21 | boolean isMinecraftControlled(); 22 | 23 | boolean hasValidFile(); 24 | 25 | boolean hasUnsavedChanges(); 26 | 27 | File getFile(); 28 | 29 | String generateJson(boolean pretty); 30 | 31 | void trySetAndLoadFile(File file); 32 | 33 | boolean quickSave(); 34 | 35 | boolean longSave(File location, boolean setAsNewPointer); 36 | 37 | void switchEditItem(Selector selector, String itemName); 38 | 39 | void renameItem(String nameOfItem, Object editFocus, String text); 40 | 41 | void deleteItem(String nameOfItem, Object editFocus); 42 | 43 | boolean createItem(KnowledgeItemType choice, String name); 44 | 45 | void informInnerChange(); 46 | 47 | SerialRoot getRootForCopyPurposes(); 48 | 49 | void duplicateItem(Selector selector, String name); 50 | 51 | void purgeLogic(); 52 | 53 | void purgeSupports(); 54 | 55 | void pushSound(SerialEvent event); 56 | 57 | void mergeFrom(File file); 58 | } 59 | -------------------------------------------------------------------------------- /src/soundpacks/air/assets/matmos/expansions.json: -------------------------------------------------------------------------------- 1 | { 2 | "expansions" : [ 3 | { 4 | "uniquename" : "eu.ha3.earthlies_database", 5 | "friendlyname" : "Air 2012: Earth and Nether", 6 | "pointer" : "expansions/earthlies_database.json" 7 | }, 8 | { 9 | "uniquename" : "eu.ha3.interactions_environments", 10 | "friendlyname" : "Air 2012: Environmental Interactions", 11 | "pointer" : "expansions/interactions_environments.json" 12 | }, 13 | { 14 | "uniquename" : "eu.ha3.interactions_weapons", 15 | "friendlyname" : "Air 2012: Weapons and Items", 16 | "pointer" : "expansions/interactions_weapons.json" 17 | }, 18 | { 19 | "uniquename" : "eu.ha3.interactions_itemswitches", 20 | "friendlyname" : "Air 2012: Item Switches", 21 | "pointer" : "expansions/interactions_itemswitches.json" 22 | } 23 | ], 24 | "legacy" : [ 25 | { 26 | "uniquename" : "legacy__earthlies_database", 27 | "friendlyname" : "XML: Earth and Nether", 28 | "pointer" : "legacy/earthlies_database.xml" 29 | }, 30 | { 31 | "uniquename" : "legacy__interactions_environments", 32 | "friendlyname" : "XML: Environmental Interactions", 33 | "pointer" : "legacy/interactions_environments.xml" 34 | }, 35 | { 36 | "uniquename" : "legacy__interactions_weapons", 37 | "friendlyname" : "XML: Weapons and Items", 38 | "pointer" : "legacy/interactions_weapons.xml" 39 | }, 40 | { 41 | "uniquename" : "legacy__interactions_itemswitches", 42 | "friendlyname" : "XML: Item Switches", 43 | "pointer" : "legacy/interactions_itemswitches.xml" 44 | } 45 | ] 46 | } -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/world/ModuleWorld.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.world; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.client.Minecraft; 7 | import net.minecraft.entity.player.EntityPlayer; 8 | import net.minecraft.world.World; 9 | import net.minecraft.world.storage.WorldInfo; 10 | 11 | public class ModuleWorld extends ModuleProcessor implements Module { 12 | public ModuleWorld(DataPackage data) { 13 | super(data, "w_general"); 14 | } 15 | 16 | @Override 17 | protected void doProcess() { 18 | World w = Minecraft.getMinecraft().world; 19 | EntityPlayer player = getPlayer(); 20 | WorldInfo info = w.getWorldInfo(); 21 | 22 | setValue("time_modulo24k", (int)(info.getWorldTime() % 24000L)); 23 | setValue("rain", w.isRaining()); 24 | setValue("thunder", info.isThundering()); 25 | setValue("thunder", w.getThunderStrength(0f) > 0.9f); 26 | setValue("dimension", player.dimension); 27 | setValue("light_subtracted", w.getSkylightSubtracted()); 28 | setValue("remote", w.isRemote); 29 | setValue("moon_phase", w.getMoonPhase()); 30 | setValue("can_rain_on", w.canSeeSky(player.getPosition())); 31 | setValue("biome_can_rain", w.getBiome(player.getPosition()).canRain()); 32 | setValue("rain_force1k", Math.round(w.getRainStrength(0f) * 1000)); 33 | setValue("thunder_force1k", Math.round(w.getThunderStrength(0f) * 1000)); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/filechooser/OverwriteWarningJsonFileChooser.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.filechooser; 2 | 3 | import java.io.File; 4 | 5 | import javax.swing.JOptionPane; 6 | 7 | /** 8 | * Courtesy of http://geek.starbean.net/?p=275 9 | * 10 | * << http://stackoverflow.com/questions/8581215/jfilechooser-and-checking-for-overwrite 11 | */ 12 | @SuppressWarnings("serial") 13 | public class OverwriteWarningJsonFileChooser extends JsonFileChooser { 14 | public OverwriteWarningJsonFileChooser(File dir) { 15 | super(dir); 16 | } 17 | 18 | @Override 19 | public File getSelectedFile() { 20 | File selectedFile = super.getSelectedFile(); 21 | 22 | if (selectedFile != null) { 23 | String name = selectedFile.getName(); 24 | if (!name.contains(".")) { 25 | selectedFile = new File(selectedFile.getParentFile(), name + '.' + dotlessExtension); 26 | } 27 | } 28 | 29 | return selectedFile; 30 | } 31 | 32 | @Override 33 | public void approveSelection() { 34 | if (getDialogType() == SAVE_DIALOG) { 35 | File selectedFile = getSelectedFile(); 36 | if (selectedFile != null && selectedFile.exists()) { 37 | int response = JOptionPane.showConfirmDialog(this, "The file " + selectedFile.getName() + " already exists. Do you want to replace the existing file?", "Ovewrite file", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); 38 | if (response != JOptionPane.YES_OPTION) { 39 | return; 40 | } 41 | } 42 | } 43 | 44 | super.approveSelection(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sheet/GenericSheet.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sheet; 2 | 3 | import java.util.Map; 4 | import java.util.Set; 5 | import java.util.TreeMap; 6 | 7 | public class GenericSheet implements Sheet { 8 | protected final Map values; 9 | protected final Map versions; 10 | 11 | private String def = "_ENTRY_NOT_DEFINED"; 12 | 13 | public GenericSheet() { 14 | values = new TreeMap<>(); 15 | versions = new TreeMap<>(); 16 | } 17 | 18 | @Override 19 | public String get(String key) { 20 | return values.containsKey(key) ? values.get(key) : def; 21 | } 22 | 23 | @Override 24 | public void set(String key, String value) { 25 | if (!value.equals(values.get(key))) { 26 | int ver = versions.containsKey(key) ? versions.get(key) : -1; 27 | values.put(key, value); 28 | versions.put(key, ver + 1); 29 | } 30 | } 31 | 32 | @Override 33 | public int version(String pos) { 34 | if (versions.containsKey(pos)) { 35 | return versions.get(pos); 36 | } 37 | 38 | return -1; 39 | } 40 | 41 | @Override 42 | public boolean exists(String key) { 43 | return values.containsKey(key); 44 | } 45 | 46 | @Override 47 | public Set keySet() { 48 | return values.keySet(); 49 | } 50 | 51 | @Override 52 | public void clear() { 53 | values.clear(); 54 | } 55 | 56 | @Override 57 | public void setDefaultValue(String def) { 58 | this.def = def; 59 | } 60 | 61 | @Override 62 | public String getDefaultValue() { 63 | return def; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/PurgeOperator.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import eu.ha3.matmos.serialisation.expansion.SerialMachine; 7 | import eu.ha3.matmos.serialisation.expansion.SerialMachineEvent; 8 | import eu.ha3.matmos.serialisation.expansion.SerialRoot; 9 | import eu.ha3.matmos.serialisation.expansion.SerialSet; 10 | 11 | public class PurgeOperator { 12 | public void purgeLogic(SerialRoot root) { 13 | Set unusedSets = new HashSet<>(root.set.keySet()); 14 | for (SerialMachine machine : root.machine.values()) { 15 | unusedSets.removeAll(machine.allow); 16 | unusedSets.removeAll(machine.restrict); 17 | } 18 | 19 | for (String unusedSet : unusedSets) { 20 | root.set.remove(unusedSet); 21 | } 22 | 23 | Set unusedConditions = new HashSet<>(root.condition.keySet()); 24 | 25 | for (SerialSet set : root.set.values()) { 26 | unusedConditions.removeAll(set.yes); 27 | unusedConditions.removeAll(set.no); 28 | } 29 | 30 | for (String unusedCondition : unusedConditions) { 31 | root.condition.remove(unusedCondition); 32 | } 33 | } 34 | 35 | public void purgeEvents(SerialRoot root) { 36 | Set unusedEvents = new HashSet<>(root.event.keySet()); 37 | for (SerialMachine machine : root.machine.values()) { 38 | for (SerialMachineEvent machineEvent : machine.event) { 39 | unusedEvents.remove(machineEvent.event); 40 | } 41 | } 42 | 43 | for (String unusedEvent : unusedEvents) { 44 | root.event.remove(unusedEvent); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sound/SoundCapabilities.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sound; 2 | 3 | public interface SoundCapabilities { 4 | /** 5 | * Plays a mono, localized sound at a certain location. 6 | */ 7 | void playMono(String event, double xx, double yy, double zz, float volume, float pitch); 8 | 9 | /** 10 | * Plays a stereo, unlocalized sound. 11 | */ 12 | void playStereo(String event, float volume, float pitch); 13 | 14 | /** 15 | * Registers a streaming sound. 16 | */ 17 | void registerStreaming(String customName, String path, float volume, float pitch, boolean isLooping, boolean usesPause); 18 | 19 | /** 20 | * Plays a streaming sound, fading in if it's greater than zero. Fading unit is in seconds. 21 | */ 22 | void playStreaming(String customName, float fadeIn); 23 | 24 | /** 25 | * Stops a streaming sound, fading out if it's greater than zero. Fading unit is in seconds. 26 | */ 27 | void stopStreaming(String customName, float fadeOut); 28 | 29 | /** 30 | * Instantly applies a volume modulation of all currently running stuff and future ones. 31 | */ 32 | void applyVolume(float volumeMod); 33 | 34 | /** 35 | * Gracefully stops all activities provided by the implementation. It should stop all sounds from 36 | * playing. 37 | */ 38 | void stop(); 39 | 40 | /** 41 | * Clean up all resources that are not freed up. SoundCapabilities should be able to be used again. 42 | */ 43 | void cleanUp(); 44 | 45 | /** 46 | * Brutally interrupts all activities provided by the implementation. This indicates the sound 47 | * engine may have been dumped during runtime. 48 | */ 49 | void interrupt(); 50 | } 51 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/SimpleFrame.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | import javax.swing.JFrame; 4 | import javax.swing.UIManager; 5 | import javax.swing.WindowConstants; 6 | 7 | /** 8 | * Utility lib to quickly format frames. 9 | * 10 | * @author Hurry 11 | */ 12 | public class SimpleFrame { 13 | /** 14 | * Makes the frame generic, minimal.
15 | *
16 | * Sets: 17 | *
    18 | *
  • Look and feel of the frame using the system's
  • 19 | *
  • EXIT_ON_CLOSE as the default close operation.
  • 20 | *
21 | * 22 | * @param frame 23 | */ 24 | public static void genericMinimal(JFrame frame) { 25 | try { 26 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 27 | } catch (Exception e) { 28 | e.printStackTrace(); 29 | } 30 | 31 | frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 32 | 33 | } 34 | 35 | /** 36 | * Makes the frame generic.
37 | *
38 | * Sets: 39 | *
    40 | *
  • Look and feel of the frame using the system's
  • 41 | *
  • EXIT_ON_CLOSE as the default close operation.
  • 42 | *
  • Sets the size of the frame (including system header).
  • 43 | *
  • Center the frame.
  • 44 | *
  • Sets the title.
  • 45 | *
46 | * 47 | * @param frame 48 | * @param title 49 | * @param width 50 | * @param height 51 | */ 52 | public static void makeMeGeneric(JFrame frame, String title, int width, int height) { 53 | genericMinimal(frame); 54 | frame.setSize(width, height); 55 | frame.setLocationRelativeTo(frame); 56 | frame.setTitle(title); 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/KnowledgeItemType.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import eu.ha3.matmos.serialisation.expansion.SerialCondition; 7 | import eu.ha3.matmos.serialisation.expansion.SerialDynamic; 8 | import eu.ha3.matmos.serialisation.expansion.SerialEvent; 9 | import eu.ha3.matmos.serialisation.expansion.SerialList; 10 | import eu.ha3.matmos.serialisation.expansion.SerialMachine; 11 | import eu.ha3.matmos.serialisation.expansion.SerialSet; 12 | 13 | public enum KnowledgeItemType { 14 | CONDITION("Condition", SerialCondition.class), 15 | SET("Set", SerialSet.class), 16 | MACHINE("Machine", SerialMachine.class), 17 | LIST("List", SerialList.class), 18 | DYNAMIC("Dynamic", SerialDynamic.class), 19 | EVENT("Event", SerialEvent.class); 20 | 21 | private String name; 22 | private Class serialClass; 23 | 24 | private static final Map, KnowledgeItemType> fromSerialClass = new HashMap<>(); 25 | 26 | static { 27 | for (KnowledgeItemType kit : KnowledgeItemType.values()) { 28 | fromSerialClass.put(kit.getSerialClass(), kit); 29 | } 30 | } 31 | 32 | public static KnowledgeItemType fromSerialClass(Class klass) { 33 | if (!fromSerialClass.containsKey(klass)) { 34 | return null; 35 | } 36 | 37 | return fromSerialClass.get(klass); 38 | } 39 | 40 | private KnowledgeItemType(String name, Class serialClass) { 41 | this.name = name; 42 | this.serialClass = serialClass; 43 | } 44 | 45 | public Class getSerialClass() { 46 | return serialClass; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return name; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/items/AbstractPotionQualityModule.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.items; 2 | 3 | import java.util.LinkedHashSet; 4 | import java.util.Set; 5 | 6 | import eu.ha3.matmos.core.sheet.DataPackage; 7 | import eu.ha3.matmos.data.modules.ModuleProcessor; 8 | import eu.ha3.matmos.data.modules.RegistryBasedModule; 9 | import net.minecraft.potion.Potion; 10 | import net.minecraft.potion.PotionEffect; 11 | 12 | /** 13 | * An abstract module that extracts a certain quality of all potion effects (such as time, 14 | * strength...) that is currently affecting the player. The quality is defined by the implementing 15 | * class. 16 | * 17 | * @author Hurry 18 | */ 19 | abstract class AbstractPotionQualityModule extends ModuleProcessor implements RegistryBasedModule { 20 | private Set oldThings = new LinkedHashSet<>(); 21 | 22 | public AbstractPotionQualityModule(DataPackage data, String name) { 23 | super(data, name); 24 | 25 | data.getSheet(name).setDefaultValue("0"); 26 | data.getSheet(name + ModuleProcessor.DELTA_SUFFIX).setDefaultValue("0"); 27 | } 28 | 29 | @Override 30 | public String getRegistryName() { 31 | return "potion"; 32 | } 33 | 34 | @Override 35 | protected void doProcess() { 36 | for (String i : oldThings) { 37 | setValue(i, 0); 38 | } 39 | 40 | oldThings.clear(); 41 | 42 | for (PotionEffect effect : getPlayer().getActivePotionEffects()) { 43 | int id = Potion.getIdFromPotion(effect.getPotion()); 44 | 45 | setValue(Integer.toString(id), getQuality(effect)); 46 | 47 | oldThings.add(Integer.toString(id)); 48 | } 49 | } 50 | 51 | abstract protected String getQuality(PotionEffect effect); 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/world/ModuleColumn.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.world; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import eu.ha3.matmos.util.MAtUtil; 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.util.math.BlockPos; 9 | import net.minecraft.world.World; 10 | 11 | public class ModuleColumn extends ModuleProcessor implements Module { 12 | public ModuleColumn(DataPackage data) { 13 | super(data, "cb_column"); 14 | 15 | EI("y-2", "Block under the feet"); 16 | EI("y-1", "Block at the legs"); 17 | EI("y0", "Block at the body (y)"); 18 | EI("y1", "Block over the head"); 19 | EI("topmost_block", "y coordinate of the top most solid block"); 20 | EI("thickness_overhead", "Number of blocks over the player until topmost_block"); 21 | EI("can_rain_reach", "Can rain reach y?"); 22 | } 23 | 24 | @Override 25 | protected void doProcess() { 26 | World w = Minecraft.getMinecraft().world; 27 | 28 | BlockPos pos = getPlayer().getPosition(); 29 | BlockPos topMostBlock = w.getTopSolidOrLiquidBlock(pos); 30 | 31 | setValue("y-1", MAtUtil.getNameAt(pos.down(), NO_BLOCK_OUT_OF_BOUNDS)); 32 | setValue("y-2", MAtUtil.getNameAt(pos.down(2), NO_BLOCK_OUT_OF_BOUNDS)); 33 | setValue("y0", MAtUtil.getNameAt(pos, NO_BLOCK_OUT_OF_BOUNDS)); 34 | setValue("y1", MAtUtil.getNameAt(pos.up(), NO_BLOCK_OUT_OF_BOUNDS)); 35 | 36 | setValue("topmost_block", topMostBlock.getY()); 37 | setValue("thickness_overhead", topMostBlock.getY() - pos.getY()); 38 | setValue("can_rain_reach", w.canSeeSky(pos) && !(topMostBlock.getY() > pos.getY())); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/ModuleProcessor.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import java.util.Map; 4 | import java.util.TreeMap; 5 | 6 | import eu.ha3.matmos.core.sheet.DataPackage; 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.entity.player.EntityPlayer; 9 | 10 | /** 11 | * A convenient class for modules that use the processor model. When calling process(), doProcess() 12 | * is called first, then the virtual sheets are applied at the end. 13 | * 14 | * @author Hurry 15 | */ 16 | public abstract class ModuleProcessor extends ProcessorModel implements EntryBasedModule { 17 | public static final String DELTA_SUFFIX = "_delta"; 18 | 19 | private final String name; 20 | 21 | private Map eis = new TreeMap<>(); 22 | 23 | public ModuleProcessor(DataPackage data, String name) { 24 | this(data, name, false); 25 | } 26 | 27 | public ModuleProcessor(DataPackage data, String name, boolean doNotUseDelta) { 28 | super(data, name, doNotUseDelta ? null : name + DELTA_SUFFIX); 29 | this.name = name; 30 | } 31 | 32 | @Override 33 | public final String getName() { 34 | return name; 35 | } 36 | 37 | @Override 38 | public Map getModuleEntries() { 39 | return eis; 40 | } 41 | 42 | /** 43 | * Internal method to create an EI. 44 | * 45 | * @param name 46 | * @param desc 47 | */ 48 | protected void EI(String name, String desc) { 49 | eis.put(name, new EI(name, desc)); 50 | } 51 | 52 | /** 53 | * Internal method to register an EI. 54 | * 55 | * @param ei 56 | */ 57 | protected void EI(EI ei) { 58 | eis.put(ei.getName(), ei); 59 | } 60 | 61 | protected EntityPlayer getPlayer() { 62 | return Minecraft.getMinecraft().player; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/legacy/ModuleConfigVars.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.legacy; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | 6 | import eu.ha3.matmos.Matmos; 7 | import eu.ha3.matmos.core.sheet.DataPackage; 8 | import eu.ha3.matmos.data.modules.Module; 9 | import eu.ha3.matmos.data.modules.ModuleProcessor; 10 | import eu.ha3.matmos.util.IDontKnowHowToCode; 11 | import eu.ha3.util.property.simple.ConfigProperty; 12 | 13 | public class ModuleConfigVars extends ModuleProcessor implements Module { 14 | private final Matmos mod; 15 | 16 | private File defaultsConfig; 17 | private File userConfig; 18 | private ConfigProperty config; 19 | 20 | public ModuleConfigVars(DataPackage data, Matmos mod) { 21 | super(data, "legacy_configvars", true); 22 | this.mod = mod; 23 | 24 | defaultsConfig = new File(mod.util().getModsFolder(), "matmos/dataconfigvars_defaults.cfg"); 25 | userConfig = new File(mod.util().getModsFolder(), "matmos/dataconfigvars.cfg"); 26 | 27 | config = new ConfigProperty(); 28 | config.setSource(defaultsConfig.getAbsolutePath()); 29 | config.load(); 30 | 31 | config.setSource(userConfig.getAbsolutePath()); 32 | if (!userConfig.exists()) { 33 | try { 34 | userConfig.createNewFile(); 35 | } catch (IOException e) { 36 | e.printStackTrace(); 37 | } 38 | } 39 | } 40 | 41 | @Override 42 | protected void doProcess() { 43 | for (String key : config.getAllProperties().keySet()) { 44 | try { 45 | setValue(key, config.getInteger(key)); 46 | } catch (Exception e) { 47 | IDontKnowHowToCode.whoops__printExceptionToChat(mod.getChatter(), e, this); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Dynamic.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import java.util.Collection; 4 | import java.util.HashSet; 5 | import java.util.List; 6 | 7 | import eu.ha3.matmos.core.sheet.SheetCommander; 8 | import eu.ha3.matmos.core.sheet.SheetIndex; 9 | import eu.ha3.matmos.util.math.Numbers; 10 | 11 | public class Dynamic extends Component implements Evaluated, InformationContainer, Dependable { 12 | public static final String DEDICATED_SHEET = "_DYNAMIC"; 13 | 14 | private long value; 15 | 16 | private final List indexes; 17 | 18 | private final SheetCommander sheetCommander; 19 | 20 | private Collection dependencies; 21 | 22 | public Dynamic(String name, SheetCommander sheetCommander, List indexes) { 23 | super(name); 24 | this.sheetCommander = sheetCommander; 25 | 26 | this.indexes = indexes; 27 | 28 | dependencies = new HashSet<>(); 29 | for (SheetIndex index : indexes) { 30 | dependencies.add(index.getSheet()); 31 | } 32 | } 33 | 34 | @Override 35 | public void evaluate() { 36 | long previous = value; 37 | 38 | value = 0; 39 | 40 | for (SheetIndex sheetIndex : indexes) { 41 | if (sheetCommander.exists(sheetIndex)) { 42 | Long value = Numbers.toLong(sheetCommander.get(sheetIndex)); 43 | if (value != null) { 44 | this.value = this.value + value; 45 | } 46 | } 47 | } 48 | 49 | if (previous != value) { 50 | incrementVersion(); 51 | } 52 | } 53 | 54 | @Override 55 | public Long getInformation() { 56 | return value; 57 | } 58 | 59 | @Override 60 | public Collection getDependencies() { 61 | return dependencies; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/ModuleTimedRandom.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import java.util.Random; 4 | 5 | import eu.ha3.matmos.core.sheet.DataPackage; 6 | 7 | /** 8 | * @author dags_ 9 | */ 10 | 11 | public class ModuleTimedRandom extends ModuleProcessor implements Module { 12 | private static final Random RANDOM = new Random(); 13 | 14 | private final TimedValue[] timedRandoms = new TimedValue[5]; 15 | 16 | public ModuleTimedRandom(DataPackage data) { 17 | super(data, "timed_random"); 18 | timedRandoms[0] = new TimedValue(1); 19 | timedRandoms[1] = new TimedValue(2); 20 | timedRandoms[2] = new TimedValue(5); 21 | timedRandoms[3] = new TimedValue(10); 22 | timedRandoms[4] = new TimedValue(20); 23 | } 24 | 25 | @Override 26 | protected void doProcess() { 27 | for (TimedValue timedRandom : timedRandoms) { 28 | timedRandom.process(this); 29 | } 30 | } 31 | 32 | private static class TimedValue { 33 | private final String playlistId; 34 | private final long period; 35 | 36 | private int activeValue = -1; 37 | private long endTime; 38 | 39 | public TimedValue(int mins) { 40 | playlistId = "timed_random_" + (mins < 10 ? "0" + mins : mins) + "mins"; 41 | period = 1000 * 60 * mins; 42 | } 43 | 44 | public void process(ModuleTimedRandom timedRandom) { 45 | if (activeValue != -1) { 46 | if (endTime < System.currentTimeMillis()) { 47 | activeValue = RANDOM.nextInt(100); 48 | endTime = System.currentTimeMillis() + period; 49 | timedRandom.setValue(playlistId, activeValue); 50 | } 51 | } else { 52 | activeValue = RANDOM.nextInt(100); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/AbstractEnchantmentModule.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import java.util.LinkedHashSet; 4 | import java.util.Set; 5 | 6 | import eu.ha3.matmos.core.sheet.DataPackage; 7 | import eu.ha3.matmos.data.modules.ModuleProcessor; 8 | import eu.ha3.matmos.data.modules.RegistryBasedModule; 9 | import eu.ha3.matmos.util.Tags; 10 | import net.minecraft.entity.player.EntityPlayer; 11 | import net.minecraft.item.ItemStack; 12 | import net.minecraft.nbt.NBTTagCompound; 13 | 14 | /** 15 | * An abstract module that extracts all enchantments associated to an item defined by the 16 | * implementing class. 17 | * 18 | * @author Hurry 19 | */ 20 | public abstract class AbstractEnchantmentModule extends ModuleProcessor implements RegistryBasedModule { 21 | private Set oldThings = new LinkedHashSet<>(); 22 | 23 | public AbstractEnchantmentModule(DataPackage dataIn, String name) { 24 | super(dataIn, name); 25 | dataIn.getSheet(name).setDefaultValue("0"); 26 | dataIn.getSheet(name + ModuleProcessor.DELTA_SUFFIX).setDefaultValue("0"); 27 | } 28 | 29 | @Override 30 | public String getRegistryName() { 31 | return "enchantment"; 32 | } 33 | 34 | @Override 35 | protected void doProcess() { 36 | ItemStack item = getItem(getPlayer()); 37 | 38 | for (String i : oldThings) { 39 | setValue(i, 0); 40 | } 41 | oldThings.clear(); 42 | 43 | if (item != null) { 44 | for (NBTTagCompound tag : Tags.of(item.getEnchantmentTagList())) { 45 | int id = tag.getShort("id"); 46 | short lvl = tag.getShort("lvl"); 47 | 48 | setValue(Integer.toString(id), Short.toString(lvl)); 49 | oldThings.add(Integer.toString(id)); 50 | } 51 | } 52 | } 53 | 54 | protected abstract ItemStack getItem(EntityPlayer player); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/util/IDontKnowHowToCode.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.util; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import eu.ha3.matmos.Matmos; 7 | import eu.ha3.mc.quick.chat.Chatter; 8 | import net.minecraft.util.text.TextFormatting; 9 | 10 | public class IDontKnowHowToCode { 11 | private static Set crash = new HashSet<>(); 12 | private static Set warning = new HashSet<>(); 13 | 14 | public static void warnOnce(String message) { 15 | if (warning.contains(message.hashCode())) { 16 | return; 17 | } 18 | warning.add(message.hashCode()); 19 | 20 | Matmos.LOGGER.warn(message); 21 | } 22 | 23 | public static void whoops__printExceptionToChat(Chatter chatter, Exception e, Object caller) { 24 | whoops__printExceptionToChat(chatter, e, caller.getClass().getName().hashCode()); 25 | } 26 | 27 | /** 28 | * Call this to print an error to the player's chat. The crash token is meant to prevent the 29 | * exceptions from a single source to print multiple times. 30 | * 31 | * @param chatter 32 | * @param e 33 | * @param crashToken 34 | */ 35 | public static void whoops__printExceptionToChat(Chatter chatter, Exception e, int crashToken) { 36 | if (crash.contains(crashToken)) { 37 | return; 38 | } 39 | crash.add(crashToken); 40 | 41 | chatter.printChat(TextFormatting.RED, "MAtmos is crashing: ", TextFormatting.WHITE, e.getClass().getName(), ": ", e.getCause()); 42 | 43 | int i = 0; 44 | for (StackTraceElement x : e.getStackTrace()) { 45 | if (i <= 5 || x.toString().contains("MAt") || x.toString().contains("eu.ha3.matmos.")) { 46 | chatter.printChat(TextFormatting.WHITE, x.toString()); 47 | } 48 | i++; 49 | } 50 | 51 | chatter.printChat(TextFormatting.RED, "Please report this issue :("); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/legacy/ModuleLegacyHitscan.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.legacy; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import eu.ha3.matmos.core.sheet.DataPackage; 7 | import eu.ha3.matmos.data.modules.Module; 8 | import eu.ha3.matmos.data.modules.ModuleProcessor; 9 | import eu.ha3.matmos.util.MAtUtil; 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.util.math.RayTraceResult; 12 | import net.minecraft.util.math.RayTraceResult.Type; 13 | 14 | public class ModuleLegacyHitscan extends ModuleProcessor implements Module { 15 | private final Map equiv = new HashMap<>(); 16 | 17 | public ModuleLegacyHitscan(DataPackage data) { 18 | super(data, "legacy_hitscan"); 19 | 20 | // The ordinal values was different back then, "0" was the block. 21 | equiv.put(Type.MISS, "-1"); 22 | equiv.put(Type.ENTITY, "1"); 23 | equiv.put(Type.BLOCK, "0"); 24 | } 25 | 26 | @Override 27 | protected void doProcess() { 28 | RayTraceResult mc = Minecraft.getMinecraft().objectMouseOver; 29 | 30 | if (mc == null || mc.typeOfHit == null) { 31 | setValue("mouse_over_something", false); 32 | setValue("mouse_over_what_remapped", -1); 33 | setValue("block_as_number", LEGACY_NO_BLOCK_IN_THIS_CONTEXT); 34 | setValue("meta_as_number", LEGACY_NO_BLOCK_IN_THIS_CONTEXT); 35 | 36 | return; 37 | } 38 | 39 | setValue("mouse_over_something", mc.typeOfHit != Type.MISS); 40 | setValue("mouse_over_what_remapped", equiv.get(mc.typeOfHit)); 41 | setValue("block_as_number", 42 | mc.typeOfHit == Type.BLOCK ? MAtUtil.legacyOf(MAtUtil.getBlockAt(mc.getBlockPos())) : LEGACY_NO_BLOCK_IN_THIS_CONTEXT); 43 | setValue("meta_as_number", mc.typeOfHit == Type.BLOCK ? MAtUtil.getMetaAt(mc.getBlockPos(), LEGACY_NO_BLOCK_OUT_OF_BOUNDS) : LEGACY_NO_BLOCK_IN_THIS_CONTEXT); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModulePlayerStats.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import eu.ha3.matmos.core.mixin.IEntity; 4 | import eu.ha3.matmos.core.sheet.DataPackage; 5 | import eu.ha3.matmos.data.modules.Module; 6 | import eu.ha3.matmos.data.modules.ModuleProcessor; 7 | import eu.ha3.matmos.util.MAtUtil; 8 | import net.minecraft.client.entity.EntityPlayerSP; 9 | import net.minecraft.item.ItemShield; 10 | import net.minecraft.item.ItemStack; 11 | 12 | /** 13 | * Module for processing the base player statistics. 14 | * 15 | */ 16 | public class ModulePlayerStats extends ModuleProcessor implements Module { 17 | public ModulePlayerStats(DataPackage data) { 18 | super(data, "ply_general"); 19 | } 20 | 21 | @Override 22 | protected void doProcess() { 23 | EntityPlayerSP player = (EntityPlayerSP)getPlayer(); 24 | 25 | setValue("in_water", player.isInWater()); 26 | setValue("wet", player.isWet()); 27 | setValue("on_ground", player.onGround); 28 | setValue("burning", player.isBurning()); 29 | setValue("jumping", player.movementInput.jump); 30 | setValue("in_web", ((IEntity)player).isInWeb()); 31 | setValue("on_ladder", player.isOnLadder()); 32 | 33 | ItemStack held = player.getHeldItemMainhand(); 34 | if (held == null) { 35 | held = player.getHeldItemOffhand(); 36 | } 37 | 38 | setValue("blocking", player.isHandActive() && held != null && held.getItem() instanceof ItemShield); 39 | setValue("sprinting", player.isSprinting()); 40 | setValue("sneaking", player.isSneaking()); 41 | setValue("airborne", player.isAirBorne); 42 | setValue("using_item", player.isHandActive()); 43 | setValue("riding", player.isRiding()); 44 | setValue("creative", player.capabilities.isCreativeMode); 45 | setValue("flying", player.capabilities.isFlying); 46 | 47 | setValue("under_water", MAtUtil.isUnderwaterAnyGamemode()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/ResourcePackDealer.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | import java.util.stream.Collectors; 8 | import java.util.stream.Stream; 9 | 10 | import com.mumfrey.liteloader.client.overlays.IMinecraft; 11 | 12 | import net.minecraft.client.Minecraft; 13 | import net.minecraft.client.resources.IResourcePack; 14 | import net.minecraft.client.resources.ResourcePackRepository; 15 | import net.minecraft.util.ResourceLocation; 16 | 17 | public class ResourcePackDealer { 18 | private static final ResourceLocation mat_pack = new ResourceLocation("matmos", "mat_pack.json"); 19 | private static final ResourceLocation expansions = new ResourceLocation("matmos", "expansions.json"); 20 | 21 | public Stream findResourcePacks() { 22 | return Stream.concat( 23 | Minecraft.getMinecraft().getResourcePackRepository().getRepositoryEntries().stream().map(ResourcePackRepository.Entry::getResourcePack), 24 | ((IMinecraft)Minecraft.getMinecraft()).getDefaultResourcePacks().stream() 25 | ).filter(this::checkCompatible) 26 | .distinct(); 27 | } 28 | 29 | public List findDisabledResourcePacks() { 30 | ResourcePackRepository rrr = Minecraft.getMinecraft().getResourcePackRepository(); 31 | 32 | List repo = new ArrayList<>(rrr.getRepositoryEntriesAll()); 33 | repo.removeAll(rrr.getRepositoryEntries()); 34 | 35 | return repo.stream() 36 | .map(ResourcePackRepository.Entry::getResourcePack) 37 | .filter(this::checkCompatible) 38 | .collect(Collectors.toList()); 39 | } 40 | 41 | private boolean checkCompatible(IResourcePack pack) { 42 | return pack.resourceExists(mat_pack); 43 | } 44 | 45 | public InputStream openExpansionsPointerFile(IResourcePack pack) throws IOException { 46 | return pack.getInputStream(expansions); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sheet/Sheet.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sheet; 2 | 3 | import java.util.Set; 4 | 5 | /* x-placeholder */ 6 | 7 | public interface Sheet { 8 | /** 9 | * Get the value of a certain position. This should return a default value if the position does not 10 | * exist. 11 | */ 12 | String get(String key); 13 | 14 | /** 15 | * Returns the value associated with the given key if such a mapping exists, otherwise returns the default. 16 | */ 17 | default String getOrDefault(String key, String def) { 18 | return exists(key) ? get(key) : def; 19 | } 20 | 21 | /** 22 | * Sets the value of a certain position. 23 | * 24 | * @param key 25 | * @param value 26 | */ 27 | void set(String key, String value); 28 | 29 | /** 30 | * Returns a number that increments every time this value is changed to a different value (as 31 | * opposed to set).
32 | * Non-initialized positions start at -1. 33 | * 34 | * @param key 35 | * @return 36 | */ 37 | int version(String key); 38 | 39 | /** 40 | * Tells if this sheet contains a certain key. 41 | */ 42 | boolean exists(String key); 43 | 44 | /** 45 | * Returns the set of keys. 46 | * 47 | * @return 48 | */ 49 | Set keySet(); 50 | 51 | /** 52 | * Empty this sheet. Versions are preserved if cleared this way. 53 | */ 54 | void clear(); 55 | 56 | /** 57 | * Sets a default value to be given out if some module tries to get an uninitialized entry. This is 58 | * useful in case some sheet want to consider uninitialized values to be false or zero. 59 | * 60 | * @param def 61 | */ 62 | void setDefaultValue(String def); 63 | 64 | /** 65 | * Returns the default value given out if some module tries to get an uninitialized entry. This is 66 | * useful in case some sheet want to consider uninitialized values to be false or zero. 67 | * 68 | * @return 69 | */ 70 | String getDefaultValue(); 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sound/SoundHelperRelay.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sound; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import eu.ha3.matmos.core.SoundRelay; 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.entity.Entity; 9 | 10 | public class SoundHelperRelay extends SoundHelper implements SoundRelay { 11 | private static int streamingToken; 12 | 13 | private final Map paths = new HashMap<>(); 14 | 15 | @Override 16 | public void routine() { 17 | } 18 | 19 | @Override 20 | public void cacheSound(String path) { 21 | String dotted = path.replace(".ogg", "").replace('/', '.').replaceAll("[0-9]", ""); 22 | paths.put(path, dotted); 23 | } 24 | 25 | @Override 26 | public void playSound(String path, float volume, float pitch, int meta) { 27 | // XXX 2014-01-12 TEMPORARY: USE MONO-STEREO 28 | //playStereo(this.paths.get(path), volume, pitch); 29 | Entity e = Minecraft.getMinecraft().player; 30 | 31 | if (meta <= 0) { 32 | playStereo(paths.get(path), volume, pitch); 33 | } else { 34 | playMono(paths.get(path), e.posX, e.posY, e.posZ, volume, pitch); 35 | } 36 | } 37 | 38 | @Override 39 | public int getNewStreamingToken() { 40 | return SoundHelperRelay.streamingToken++; 41 | } 42 | 43 | @Override 44 | public boolean setupStreamingToken(int token, String path, float volume, float pitch, boolean isLooping, boolean usesPause) { 45 | registerStreaming("" + token, path, volume, pitch, isLooping, usesPause); 46 | 47 | return true; 48 | } 49 | 50 | @Override 51 | public void startStreaming(int token, float fadeDuration) { 52 | playStreaming(Integer.toString(token), fadeDuration); 53 | } 54 | 55 | @Override 56 | public void stopStreaming(int token, float fadeDuration) { 57 | stopStreaming(Integer.toString(token), fadeDuration); 58 | } 59 | 60 | @Override 61 | public void eraseStreamingToken(int token) { 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/gui/GuiExpansionInfo.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.gui; 2 | 3 | import eu.ha3.matmos.Matmos; 4 | import eu.ha3.matmos.core.expansion.Expansion; 5 | import net.minecraft.client.gui.GuiButton; 6 | import net.minecraft.client.gui.GuiScreen; 7 | import net.minecraft.client.gui.ScaledResolution; 8 | import net.minecraft.client.resources.I18n; 9 | import net.minecraft.util.text.TextFormatting; 10 | 11 | public class GuiExpansionInfo extends GuiScreen { 12 | private final GuiMatMenu parentScreen; 13 | 14 | private final Expansion expansion; 15 | 16 | private final String[] info; 17 | 18 | public GuiExpansionInfo(GuiMatMenu menu, Matmos mod, Expansion expansion) { 19 | parentScreen = menu; 20 | this.expansion = expansion; 21 | 22 | String info = expansion.hasMoreInfo() ? expansion.getInfo() : I18n.format("mat.expansion.noinfo"); 23 | this.info = info.replace("\r", "").replace("�", "\u00A7").split("\n"); 24 | } 25 | 26 | @Override 27 | public void drawScreen(int par1, int par2, float par3) { 28 | drawGradientRect(0, 0, width, height, 0xF0000000, 0x90000000); 29 | 30 | drawCenteredString(fontRenderer, "About " + TextFormatting.YELLOW + TextFormatting.ITALIC + expansion.getFriendlyName() + TextFormatting.RESET + "...", width / 2, 4, 0xffffff); 31 | 32 | int lc = 0; 33 | for (String line : info) { 34 | fontRenderer.drawString(line, width / 2 - 200, 16 + 8 * lc, 0xFFFFFF); 35 | lc++; 36 | } 37 | 38 | super.drawScreen(par1, par2, par3); 39 | } 40 | 41 | @Override 42 | public boolean doesGuiPauseGame() { 43 | return false; 44 | } 45 | 46 | @Override 47 | public void initGui() { 48 | int h = new ScaledResolution(mc).getScaledHeight() - 22; 49 | 50 | buttonList.add(new GuiButton(200, 2, h, 70, 20, I18n.format("mat.options.close"))); 51 | } 52 | 53 | @Override 54 | protected void actionPerformed(GuiButton button) { 55 | if (button.id == 200) { 56 | mc.displayGuiScreen(parentScreen); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/util/BetterStreams.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.util; 2 | 3 | import java.util.Collection; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Set; 7 | import java.util.function.Consumer; 8 | import java.util.function.Function; 9 | import java.util.function.Predicate; 10 | import java.util.stream.Collectors; 11 | import java.util.stream.Stream; 12 | 13 | public interface BetterStreams { 14 | 15 | static BetterStreams of(Collection iterable) { 16 | return () -> iterable.stream(); 17 | } 18 | 19 | @SafeVarargs 20 | static BetterStreams of(Collection ...collections) { 21 | return () -> Stream.of(collections).flatMap(Collection::stream); 22 | } 23 | 24 | @SafeVarargs 25 | static BetterStreams of(Map ...maps) { 26 | return () -> Stream.of(maps).map(Map::values).flatMap(Collection::stream); 27 | } 28 | 29 | Stream s(); 30 | 31 | default BetterStreams unique() { 32 | return () -> s().distinct(); 33 | } 34 | 35 | default BetterStreams flatten(Function> convert) { 36 | return () -> s().flatMap(a -> convert.apply(a).stream()); 37 | } 38 | 39 | default BetterStreams map(Function convert) { 40 | return () -> s().map(convert); 41 | } 42 | 43 | default BetterStreams join(Collection iterable) { 44 | return () -> Stream.concat(s(), iterable.stream()); 45 | } 46 | 47 | default BetterStreams join(Map map) { 48 | return () -> Stream.concat(s(), map.values().stream()); 49 | } 50 | 51 | default BetterStreams filter(Predicate test) { 52 | return () -> s().filter(test); 53 | } 54 | 55 | default List asList() { 56 | return s().collect(Collectors.toList()); 57 | } 58 | 59 | default Set asSet() { 60 | return s().collect(Collectors.toSet()); 61 | } 62 | 63 | default void forEach(Consumer action) { 64 | s().forEach(action); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/JsonPanel.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.FlowLayout; 5 | import java.awt.Font; 6 | import java.awt.Toolkit; 7 | import java.awt.datatransfer.StringSelection; 8 | 9 | import javax.swing.JButton; 10 | import javax.swing.JPanel; 11 | import javax.swing.JScrollPane; 12 | import javax.swing.JTextArea; 13 | 14 | import eu.ha3.matmos.editor.interfaces.Editor; 15 | 16 | public class JsonPanel extends JPanel { 17 | private static final long serialVersionUID = 1L; 18 | 19 | private Editor model; 20 | 21 | private JTextArea textArea; 22 | 23 | public JsonPanel(Editor modelConstruct) { 24 | model = modelConstruct; 25 | 26 | setLayout(new BorderLayout(0, 0)); 27 | 28 | JScrollPane scrollPane = new JScrollPane(); 29 | add(scrollPane); 30 | 31 | textArea = new JTextArea(); 32 | textArea.setEditable(false); 33 | textArea.setFont(new Font("Monospaced", Font.PLAIN, 11)); 34 | textArea.setLineWrap(true); 35 | scrollPane.setViewportView(textArea); 36 | 37 | JPanel panel = new JPanel(); 38 | add(panel, BorderLayout.SOUTH); 39 | 40 | JButton btnGeneratePretty = new JButton("Generate"); 41 | btnGeneratePretty.addActionListener(arg0 -> textArea.setText(model.generateJson(true))); 42 | panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); 43 | panel.add(btnGeneratePretty); 44 | 45 | JButton btnGenerateMinified = new JButton("Minify"); 46 | btnGenerateMinified.addActionListener(arg0 -> textArea.setText(model.generateJson(false))); 47 | panel.add(btnGenerateMinified); 48 | 49 | JButton btnCopyToClipboard = new JButton("Copy to Clipboard"); 50 | btnCopyToClipboard.addActionListener(e -> { 51 | try { 52 | StringSelection selection = new StringSelection(textArea.getText()); 53 | Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection); 54 | } catch (Exception ex) { 55 | ex.printStackTrace(); 56 | } 57 | }); 58 | panel.add(btnCopyToClipboard); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/AbstractStringCountModule.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import java.util.HashMap; 4 | import java.util.LinkedHashSet; 5 | import java.util.Map; 6 | import java.util.Map.Entry; 7 | import java.util.Set; 8 | 9 | import eu.ha3.matmos.core.sheet.DataPackage; 10 | 11 | /** 12 | * An abstract module that specializes in counting things in one pass. 13 | * 14 | * @author Hurry 15 | */ 16 | public abstract class AbstractStringCountModule extends ModuleProcessor implements Module { 17 | private Set oldThings = new LinkedHashSet<>(); 18 | private Set newThings = new LinkedHashSet<>(); 19 | 20 | protected Map things = new HashMap<>(); 21 | 22 | public AbstractStringCountModule(DataPackage data, String name) { 23 | this(data, name, false); 24 | } 25 | 26 | public AbstractStringCountModule(DataPackage data, String name, boolean doNotUseDelta) { 27 | super(data, name, doNotUseDelta); 28 | 29 | data.getSheet(name).setDefaultValue("0"); 30 | if (!doNotUseDelta) { 31 | data.getSheet(name + DELTA_SUFFIX).setDefaultValue("0"); 32 | } 33 | } 34 | 35 | @Override 36 | protected void doProcess() { 37 | count(); 38 | apply(); 39 | } 40 | 41 | public void increment(String thing) { 42 | things.put(thing, things.containsKey(thing) ? things.get(thing) + 1 : 1); 43 | } 44 | 45 | protected abstract void count(); 46 | 47 | public void apply() { 48 | for (Entry entry : things.entrySet()) { 49 | this.setValue(entry.getKey(), entry.getValue()); 50 | } 51 | 52 | newThings.addAll(things.keySet()); // add all new string 53 | things.clear(); 54 | 55 | // Reset all missing string to zero 56 | oldThings.removeAll(newThings); 57 | for (String missing : oldThings) { 58 | setValue(missing, 0); 59 | } 60 | oldThings.clear(); 61 | 62 | // The following code means 63 | // oldThings <- newThings 64 | // newThings <- (empty set) 65 | Set anEmptySet = oldThings; 66 | oldThings = newThings; 67 | newThings = anEmptySet; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/expansion/agents/LegacyXMLLoadingAgent.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.expansion.agents; 2 | 3 | import java.io.File; 4 | import java.io.FileWriter; 5 | import java.io.IOException; 6 | 7 | import javax.xml.parsers.DocumentBuilder; 8 | import javax.xml.parsers.DocumentBuilderFactory; 9 | 10 | import org.w3c.dom.Document; 11 | 12 | import com.google.gson.Gson; 13 | import com.google.gson.GsonBuilder; 14 | 15 | import eu.ha3.matmos.core.Knowledge; 16 | import eu.ha3.matmos.core.expansion.ExpansionIdentity; 17 | import eu.ha3.matmos.serialisation.JsonExpansions_EngineDeserializer; 18 | import eu.ha3.matmos.serialisation.LegacyXMLExpansions_Engine1; 19 | import eu.ha3.matmos.serialisation.expansion.SerialRoot; 20 | 21 | @Deprecated 22 | public class LegacyXMLLoadingAgent implements LoadingAgent { 23 | private static final Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); 24 | 25 | private final File jsonOutput; 26 | 27 | public LegacyXMLLoadingAgent() { 28 | this(null); 29 | } 30 | 31 | public LegacyXMLLoadingAgent(File jsonOutput) { 32 | this.jsonOutput = jsonOutput; 33 | } 34 | 35 | @Override 36 | public boolean load(ExpansionIdentity identity, Knowledge knowledge) { 37 | try { 38 | DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); 39 | DocumentBuilder documentBuilder = dbf.newDocumentBuilder(); 40 | 41 | Document document = documentBuilder.parse(identity.getPack().getInputStream(identity.getLocation())); 42 | 43 | SerialRoot root = new LegacyXMLExpansions_Engine1().loadXMLtoSerial(document); 44 | try { 45 | if (!jsonOutput.exists()) { 46 | jsonOutput.createNewFile(); 47 | } 48 | 49 | FileWriter write = new FileWriter(jsonOutput); 50 | write.append(gson.toJson(root)); 51 | write.close(); 52 | } catch (IOException e) { 53 | e.printStackTrace(); 54 | } 55 | new JsonExpansions_EngineDeserializer().loadSerial(root, identity, knowledge); 56 | 57 | return true; 58 | } catch (Exception e) { 59 | e.printStackTrace(); 60 | return false; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/Providers.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import eu.ha3.matmos.core.event.Event; 4 | import eu.ha3.matmos.core.logic.Condition; 5 | import eu.ha3.matmos.core.logic.Junction; 6 | import eu.ha3.matmos.core.logic.Machine; 7 | import eu.ha3.matmos.core.sheet.SheetCommander; 8 | 9 | public class Providers implements ProviderCollection { 10 | private final ReferenceTime time; 11 | private final SoundRelay soundRelay; 12 | private final SheetCommander commander; 13 | private final Provider conditionProvider; 14 | private final Provider junctionProvider; 15 | private final Provider machineProvider; 16 | private final Provider eventProvider; 17 | private final Provider dynamicProvider; 18 | 19 | public Providers(ReferenceTime time, SoundRelay soundRelay, SheetCommander commander, Provider conditionProvider, Provider junctionProvider, Provider machineProvider, Provider eventProvider, Provider dynamicProvider) { 20 | this.time = time; 21 | this.soundRelay = soundRelay; 22 | this.commander = commander; 23 | 24 | this.conditionProvider = conditionProvider; 25 | this.junctionProvider = junctionProvider; 26 | this.machineProvider = machineProvider; 27 | this.eventProvider = eventProvider; 28 | this.dynamicProvider = dynamicProvider; 29 | } 30 | 31 | @Override 32 | public ReferenceTime getReferenceTime() { 33 | return time; 34 | } 35 | 36 | @Override 37 | public SoundRelay getSoundRelay() { 38 | return soundRelay; 39 | } 40 | 41 | @Override 42 | public SheetCommander getSheetCommander() { 43 | return commander; 44 | } 45 | 46 | @Override 47 | public Provider getCondition() { 48 | return conditionProvider; 49 | } 50 | 51 | @Override 52 | public Provider getJunction() { 53 | return junctionProvider; 54 | } 55 | 56 | @Override 57 | public Provider getMachine() { 58 | return machineProvider; 59 | } 60 | 61 | @Override 62 | public Provider getEvent() { 63 | return eventProvider; 64 | } 65 | 66 | @Override 67 | public Provider getDynamic() { 68 | return dynamicProvider; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/player/ModuleHitscan.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.player; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import eu.ha3.matmos.core.sheet.DataPackage; 7 | import eu.ha3.matmos.data.modules.Module; 8 | import eu.ha3.matmos.data.modules.ModuleProcessor; 9 | import eu.ha3.matmos.util.MAtUtil; 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.entity.EntityList; 12 | import net.minecraft.util.math.RayTraceResult.Type; 13 | 14 | /** 15 | * Processes values for the entity/block that a player focuses over with the cursor. 16 | */ 17 | public class ModuleHitscan extends ModuleProcessor implements Module { 18 | private final Map equiv = new HashMap<>(); 19 | 20 | public ModuleHitscan(DataPackage data) { 21 | super(data, "ply_hitscan"); 22 | equiv.put(Type.MISS, ""); 23 | equiv.put(Type.ENTITY, "entity"); 24 | equiv.put(Type.BLOCK, "block"); 25 | } 26 | 27 | @Override 28 | protected void doProcess() { 29 | Minecraft mc = Minecraft.getMinecraft(); 30 | 31 | if (mc.objectMouseOver == null || mc.objectMouseOver.typeOfHit == null) { 32 | setValue("mouse_over_something", false); 33 | setValue("mouse_over_what", ""); 34 | setValue("block", NO_BLOCK_IN_THIS_CONTEXT); 35 | setValue("meta", NO_META); 36 | setValue("powermeta", NO_POWERMETA); 37 | setValue("entity_id", NO_ENTITY); 38 | 39 | return; 40 | } 41 | 42 | setValue("mouse_over_something", mc.objectMouseOver.typeOfHit != Type.MISS); 43 | setValue("mouse_over_what", equiv.get(mc.objectMouseOver.typeOfHit)); 44 | setValue("block", mc.objectMouseOver.typeOfHit == Type.BLOCK ? MAtUtil.getNameAt(mc.objectMouseOver.getBlockPos(), NO_BLOCK_OUT_OF_BOUNDS) : NO_BLOCK_IN_THIS_CONTEXT); 45 | setValue("meta", mc.objectMouseOver.typeOfHit == Type.BLOCK ? MAtUtil.getMetaAsStringAt(mc.objectMouseOver.getBlockPos(), NO_BLOCK_OUT_OF_BOUNDS) : NO_BLOCK_IN_THIS_CONTEXT); 46 | setValue("powermeta", mc.objectMouseOver.typeOfHit == Type.BLOCK ? MAtUtil.getPowerMetaAt(mc.objectMouseOver.getBlockPos(), NO_BLOCK_OUT_OF_BOUNDS) : NO_BLOCK_IN_THIS_CONTEXT); 47 | setValue("entity_id", mc.objectMouseOver.typeOfHit == Type.ENTITY ? EntityList.getKey(mc.objectMouseOver.entityHit).toString() : NO_ENTITY); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/legacy/ModuleLegacy.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.legacy; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import eu.ha3.matmos.util.MAtUtil; 7 | import net.minecraft.client.Minecraft; 8 | import net.minecraft.client.gui.inventory.GuiContainer; 9 | import net.minecraft.entity.Entity; 10 | import net.minecraft.entity.item.EntityBoat; 11 | import net.minecraft.entity.item.EntityMinecartEmpty; 12 | import net.minecraft.entity.passive.EntityHorse; 13 | import net.minecraft.entity.player.EntityPlayer; 14 | import net.minecraft.item.ItemStack; 15 | 16 | public class ModuleLegacy extends ModuleProcessor implements Module { 17 | public ModuleLegacy(DataPackage data) { 18 | super(data, "legacy"); 19 | } 20 | 21 | @Override 22 | protected void doProcess() { 23 | Minecraft mc = Minecraft.getMinecraft(); 24 | 25 | EntityPlayer player = getPlayer(); 26 | 27 | Entity ride = player.getRidingEntity(); 28 | 29 | setValue("player_health_ceil", (int)Math.ceil(player.getHealth())); 30 | setValue("world_nether", player.dimension == -1); 31 | setValue("player_current_item_as_number", number(player.inventory.getCurrentItem())); 32 | 33 | setValue("72000_minus_item_use_duration", 72000 - player.getItemInUseCount()); 34 | setValue("riding_minecart", ride != null && ride.getClass() == EntityMinecartEmpty.class); 35 | setValue("riding_boat", ride != null && ride.getClass() == EntityBoat.class); 36 | setValue("armor_0_as_number", number(player.inventory.armorInventory.get(0))); 37 | setValue("armor_1_as_number", number(player.inventory.armorInventory.get(1))); 38 | setValue("armor_2_as_number", number(player.inventory.armorInventory.get(2))); 39 | setValue("armor_3_as_number", number(player.inventory.armorInventory.get(3))); 40 | setValue("gui_instanceof_container", mc.currentScreen != null && mc.currentScreen instanceof GuiContainer); 41 | setValue("riding_horse", ride != null && ride instanceof EntityHorse); 42 | setValue("seed_higher", (int)(mc.world.getSeed() >> 32)); 43 | setValue("seed_lower", (int)(mc.world.getSeed() & 0xFFFFFFFF)); 44 | } 45 | 46 | private int number(ItemStack item) { 47 | return item != null ? MAtUtil.legacyOf(item) : LEGACY_NO_ITEM; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/edit/SetRemoverPanel.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.edit; 2 | 3 | import java.awt.BorderLayout; 4 | import java.util.List; 5 | import java.util.Set; 6 | import java.util.TreeSet; 7 | 8 | import javax.swing.JButton; 9 | import javax.swing.JList; 10 | import javax.swing.JPanel; 11 | import javax.swing.JScrollPane; 12 | 13 | import eu.ha3.matmos.editor.interfaces.IFlaggable; 14 | 15 | @SuppressWarnings("serial") 16 | public class SetRemoverPanel extends JPanel { 17 | private final IFlaggable parent; 18 | private final Set set; 19 | private JList list; 20 | 21 | public SetRemoverPanel(IFlaggable parent, Set original) { 22 | this.parent = parent; 23 | set = original; 24 | 25 | setLayout(new BorderLayout(0, 0)); 26 | 27 | JPanel panel = new JPanel(); 28 | add(panel, BorderLayout.CENTER); 29 | panel.setLayout(new BorderLayout(0, 0)); 30 | 31 | JScrollPane scrollPane = new JScrollPane(); 32 | panel.add(scrollPane, BorderLayout.CENTER); 33 | 34 | list = new JList<>(); 35 | list.setVisibleRowCount(4); 36 | scrollPane.setViewportView(list); 37 | 38 | JPanel panel_1 = new JPanel(); 39 | panel.add(panel_1, BorderLayout.EAST); 40 | 41 | JButton btnRemoveSelected = new JButton("Remove"); 42 | btnRemoveSelected.addActionListener(arg0 -> removeSelected()); 43 | panel_1.setLayout(new BorderLayout(0, 0)); 44 | panel_1.add(btnRemoveSelected); 45 | } 46 | 47 | protected void removeSelected() { 48 | //Solly edit list.getSelectedValues is deprecated 49 | List values = list.getSelectedValuesList(); 50 | if (values.size() == 0) { 51 | return; 52 | } 53 | 54 | int removedCount = 0; 55 | for (Object o : values) { 56 | String value = (String)o; 57 | if (set.contains(value)) { 58 | set.remove(value); 59 | removedCount = removedCount + 1; 60 | } 61 | } 62 | 63 | if (removedCount > 0) { 64 | parent.flagChange(); 65 | // Flagging should cause a call to fillWithValues 66 | } 67 | } 68 | 69 | public void fillWithValues() { 70 | list.removeAll(); 71 | list.setListData(new TreeSet<>(set).toArray(new String[set.size()])); 72 | } 73 | 74 | public JList getList() { 75 | return list; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/event/TimedEvent.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.event; 2 | 3 | import java.util.Random; 4 | 5 | import eu.ha3.matmos.core.Provider; 6 | import eu.ha3.matmos.core.ReferenceTime; 7 | import eu.ha3.matmos.serialisation.expansion.SerialMachineEvent; 8 | 9 | public class TimedEvent implements TimedEventInterface { 10 | private static Random random = new Random(); 11 | 12 | private String event; 13 | private final Provider provider; 14 | private final float volMod; 15 | private final float pitchMod; 16 | private final float delayMin; 17 | private final float delayMax; 18 | private final float delayStart; 19 | 20 | private long nextPlayTime; 21 | 22 | public TimedEvent(Provider provider, SerialMachineEvent eelt) { 23 | this(eelt.event, provider, eelt.vol_mod, eelt.pitch_mod, eelt.delay_min, eelt.delay_max, eelt.delay_start); 24 | } 25 | 26 | public TimedEvent(String event, Provider provider, float volMod, float pitchMod, float delayMin, float delayMax, float delayStart) { 27 | this.event = event; 28 | this.provider = provider; 29 | this.volMod = volMod; 30 | this.pitchMod = pitchMod; 31 | this.delayMin = delayMin; 32 | this.delayMax = delayMax; 33 | this.delayStart = delayStart; 34 | 35 | if (delayMax < delayMin) { 36 | delayMax = delayMin; 37 | } 38 | } 39 | 40 | @Override 41 | public void restart(ReferenceTime time) { 42 | if (delayStart == 0) { 43 | nextPlayTime = time.getMilliseconds() + (long)(random.nextFloat() * delayMax * 1000); 44 | } else { 45 | nextPlayTime = time.getMilliseconds() + (long)(delayStart * 1000); 46 | } 47 | } 48 | 49 | @Override 50 | public void play(ReferenceTime time, float fadeFactor) { 51 | if (time.getMilliseconds() < nextPlayTime) { 52 | return; 53 | } 54 | 55 | if (provider.exists(event)) { 56 | provider.get(event).playSound(volMod * fadeFactor, pitchMod); 57 | } 58 | 59 | if (delayMin == delayMax && delayMin > 0) { 60 | while (nextPlayTime < time.getMilliseconds()) { 61 | nextPlayTime = nextPlayTime + (long)(delayMin * 1000); 62 | } 63 | } else { 64 | nextPlayTime = time.getMilliseconds() 65 | + (long)((delayMin + random.nextFloat() * (delayMax - delayMin)) * 1000); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/ModuleContainer.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import net.minecraft.client.Minecraft; 5 | import net.minecraft.client.gui.GuiCommandBlock; 6 | import net.minecraft.client.gui.GuiEnchantment; 7 | import net.minecraft.client.gui.GuiHopper; 8 | import net.minecraft.client.gui.GuiMerchant; 9 | import net.minecraft.client.gui.GuiRepair; 10 | import net.minecraft.client.gui.GuiScreen; 11 | import net.minecraft.client.gui.inventory.GuiBeacon; 12 | import net.minecraft.client.gui.inventory.GuiBrewingStand; 13 | import net.minecraft.client.gui.inventory.GuiChest; 14 | import net.minecraft.client.gui.inventory.GuiContainer; 15 | import net.minecraft.client.gui.inventory.GuiContainerCreative; 16 | import net.minecraft.client.gui.inventory.GuiCrafting; 17 | import net.minecraft.client.gui.inventory.GuiDispenser; 18 | import net.minecraft.client.gui.inventory.GuiFurnace; 19 | import net.minecraft.client.gui.inventory.GuiInventory; 20 | import net.minecraft.client.gui.inventory.GuiScreenHorseInventory; 21 | import net.minecraft.client.gui.inventory.GuiShulkerBox; 22 | 23 | public class ModuleContainer extends ModuleProcessor implements Module { 24 | public ModuleContainer(DataPackage data) { 25 | super(data, "gui_general"); 26 | } 27 | 28 | @Override 29 | protected void doProcess() { 30 | GuiScreen gui = Minecraft.getMinecraft().currentScreen; 31 | 32 | setValue("open", gui != null); 33 | 34 | setValue("is_beacon", gui instanceof GuiBeacon); 35 | setValue("is_brewing", gui instanceof GuiBrewingStand); 36 | setValue("is_chest", gui instanceof GuiChest); 37 | setValue("is_crafting", gui instanceof GuiCrafting); 38 | setValue("is_dispenser", gui instanceof GuiDispenser); 39 | setValue("is_enchantment", gui instanceof GuiEnchantment); 40 | setValue("is_furnace", gui instanceof GuiFurnace); 41 | setValue("is_hopper", gui instanceof GuiHopper); 42 | setValue("is_npc_trade", gui instanceof GuiMerchant); 43 | setValue("is_anvil", gui instanceof GuiRepair); 44 | setValue("is_horse", gui instanceof GuiScreenHorseInventory); 45 | setValue("is_shulker", gui instanceof GuiShulkerBox); 46 | 47 | setValue("is_commandblock", gui instanceof GuiCommandBlock); 48 | setValue("is_container", gui instanceof GuiContainer); 49 | setValue("is_inventory", gui instanceof GuiInventory); 50 | setValue("is_creative", gui instanceof GuiContainerCreative); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/util/math/HelperFadeCalculator.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.util.math; 2 | 3 | import eu.ha3.matmos.core.ReferenceTime; 4 | 5 | public class HelperFadeCalculator { 6 | private final ReferenceTime time; 7 | 8 | private long fadeInTime = 0; 9 | private long fadeInDuration = 0; 10 | 11 | private long fadeOutTime = 0; 12 | private long fadeOutDuration = 0; 13 | 14 | private boolean foLast = true; 15 | private boolean complete = true; 16 | private boolean doneFadingOut = false; 17 | private float fade = 0; 18 | 19 | public HelperFadeCalculator(ReferenceTime time) { 20 | this.time = time; 21 | } 22 | 23 | public void fadeIn(long durationMs) { 24 | float currentFade = calculateFadeFactor(); 25 | 26 | long minTime = (long)(currentFade * durationMs); 27 | 28 | fadeInTime = time.getMilliseconds() - minTime; 29 | fadeInDuration = durationMs; 30 | 31 | foLast = false; 32 | complete = false; 33 | doneFadingOut = false; 34 | } 35 | 36 | public void fadeOut(long durationMs) { 37 | float currentFade = calculateFadeFactor(); 38 | 39 | long minTime = (long)(durationMs - durationMs * currentFade); 40 | 41 | fadeOutTime = time.getMilliseconds() - minTime; 42 | fadeOutDuration = durationMs; 43 | 44 | foLast = true; 45 | complete = false; 46 | doneFadingOut = false; 47 | } 48 | 49 | public float calculateFadeFactor() { 50 | if (complete) { 51 | return fade; 52 | } 53 | 54 | long curTime = time.getMilliseconds(); 55 | if (foLast) { 56 | if (fadeOutDuration <= 0f) { 57 | fade = 0f; 58 | complete = true; 59 | doneFadingOut = true; 60 | } else { 61 | fade = 1 - (curTime - fadeOutTime) / (float)fadeOutDuration; 62 | if (fade < 0f) { 63 | fade = 0f; 64 | complete = true; 65 | doneFadingOut = true; 66 | } 67 | } 68 | } else { 69 | if (fadeInDuration <= 0f) { 70 | fade = 1f; 71 | complete = true; 72 | } else { 73 | fade = (curTime - fadeInTime) / (float)fadeInDuration; 74 | if (fade > 1f) { 75 | fade = 1f; 76 | complete = true; 77 | } 78 | } 79 | } 80 | 81 | return fade; 82 | } 83 | 84 | public boolean isDoneFadingOut() { 85 | return doneFadingOut; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/debug/PluggableIntoMAtmos.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.debug; 2 | 3 | import java.io.File; 4 | import java.util.Optional; 5 | 6 | import eu.ha3.matmos.Matmos; 7 | import eu.ha3.matmos.core.expansion.Expansion; 8 | import eu.ha3.matmos.core.expansion.FolderExpansionDebugUnit; 9 | import net.minecraft.util.text.TextFormatting; 10 | 11 | public class PluggableIntoMAtmos implements Pluggable { 12 | private Matmos mod; 13 | private String expansionName; 14 | 15 | private boolean isReadOnly; 16 | 17 | private File file; 18 | private File workingDirectory; 19 | 20 | public PluggableIntoMAtmos(Matmos mod, Expansion expansion) { 21 | this.mod = mod; 22 | if (expansion.obtainDebugUnit() instanceof FolderExpansionDebugUnit) { 23 | file = ((FolderExpansionDebugUnit)expansion.obtainDebugUnit()).getExpansionFile(); 24 | workingDirectory = ((FolderExpansionDebugUnit)expansion.obtainDebugUnit()).getExpansionFolder(); 25 | isReadOnly = false; 26 | } else { 27 | isReadOnly = true; 28 | } 29 | 30 | expansionName = expansion.getName(); 31 | } 32 | 33 | @Override 34 | public void pushJson(String json) { 35 | mod.queueForNextTick(() -> { 36 | Optional opt = mod.getExpansionEffort(expansionName); 37 | 38 | if (opt.isPresent()) { 39 | Expansion expansion = opt.get(); 40 | 41 | mod.getChatter().printChat(TextFormatting.AQUA, "Reloading from editor state: " + expansion.getName() + " " + getTimestamp()); 42 | expansion.pushDebugJsonAndRefreshKnowledge(json); 43 | } 44 | }); 45 | } 46 | 47 | @Override 48 | public void reloadFromDisk() { 49 | mod.queueForNextTick(() -> { 50 | mod.getExpansionEffort(expansionName).ifPresent(expansion -> { 51 | mod.getChatter().printChat(TextFormatting.BLUE, "Reloading from disk: ", expansion.getName() + " " + getTimestamp()); 52 | expansion.refreshKnowledge(); 53 | }); 54 | }); 55 | } 56 | 57 | protected String getTimestamp() { 58 | return TextFormatting.BLACK + "(" + System.currentTimeMillis() + ")"; 59 | } 60 | 61 | @Override 62 | public boolean isReadOnly() { 63 | return isReadOnly; 64 | } 65 | 66 | @Override 67 | public File getWorkingDirectoryIfAvailable() { 68 | return workingDirectory; 69 | } 70 | 71 | @Override 72 | public File getFileIfAvailable() { 73 | return file; 74 | } 75 | 76 | @Override 77 | public void onEditorClosed() { 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/logic/Junction.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.logic; 2 | 3 | import java.util.Collection; 4 | import java.util.HashSet; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import java.util.TreeSet; 8 | 9 | import eu.ha3.matmos.Matmos; 10 | import eu.ha3.matmos.core.Dependable; 11 | import eu.ha3.matmos.core.MultistateComponent; 12 | import eu.ha3.matmos.core.Provider; 13 | 14 | public class Junction extends MultistateComponent implements Dependable, VisualizedSpecialDependencies { 15 | private final List yes; 16 | private final List no; 17 | 18 | private final Provider provider; 19 | 20 | private final Collection dependencies; 21 | 22 | public Junction(String name, Provider provider, List yes, List no) { 23 | super(name); 24 | this.provider = provider; 25 | 26 | this.yes = yes; 27 | this.no = no; 28 | 29 | dependencies = new TreeSet<>(); 30 | dependencies.addAll(yes); 31 | dependencies.addAll(no); 32 | } 33 | 34 | @Override 35 | public void evaluate() { 36 | boolean pre = isActive; 37 | isActive = testIfTrue(); 38 | 39 | if (pre != isActive) { 40 | Matmos.LOGGER.debug("S: " + getName() + " -> " + isActive); 41 | 42 | incrementVersion(); 43 | } 44 | } 45 | 46 | private boolean testIfTrue() { 47 | boolean isTrue = true; 48 | 49 | Iterator iterYes = yes.iterator(); 50 | while (isTrue && iterYes.hasNext()) { 51 | String yes = iterYes.next(); 52 | if (!provider.exists(yes) || !provider.get(yes).isActive()) { 53 | isTrue = false; 54 | } 55 | } 56 | 57 | if (!isTrue) { 58 | return false; 59 | } 60 | 61 | Iterator iterNo = no.iterator(); 62 | while (isTrue && iterNo.hasNext()) { 63 | String no = iterNo.next(); 64 | if (!provider.exists(no) || provider.get(no).isActive()) { 65 | isTrue = false; 66 | } 67 | } 68 | return isTrue; 69 | } 70 | 71 | @Override 72 | public Collection getDependencies() { 73 | return dependencies; 74 | } 75 | 76 | @Override 77 | public String getFeed() { 78 | return ""; 79 | } 80 | 81 | @Override 82 | public Collection getSpecialDependencies(String type) { 83 | if (type.equals("yes")) { 84 | return yes; 85 | } else if (type.equals("no")) { 86 | return no; 87 | } 88 | 89 | return new HashSet<>(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/ListerPanel.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.FlowLayout; 5 | import java.util.ArrayList; 6 | import java.util.Map; 7 | 8 | import javax.swing.AbstractListModel; 9 | import javax.swing.JButton; 10 | import javax.swing.JLabel; 11 | import javax.swing.JList; 12 | import javax.swing.JPanel; 13 | import javax.swing.JScrollPane; 14 | import javax.swing.ListSelectionModel; 15 | import javax.swing.ScrollPaneConstants; 16 | import javax.swing.SwingConstants; 17 | 18 | import eu.ha3.matmos.editor.interfaces.ILister; 19 | 20 | public abstract class ListerPanel extends JPanel implements ILister { 21 | private static final long serialVersionUID = 1L; 22 | 23 | private JLabel titleLabel; 24 | private JList list; 25 | private JPanel panel; 26 | private JButton create; 27 | private JPanel panel_1; 28 | 29 | public ListerPanel() { 30 | setLayout(new BorderLayout(0, 0)); 31 | 32 | JScrollPane scrollPane = new JScrollPane(); 33 | scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); 34 | add(scrollPane, BorderLayout.CENTER); 35 | 36 | list = new JList<>(); 37 | list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 38 | list.setModel(new AbstractListModel() { 39 | /** 40 | * 41 | */ 42 | private static final long serialVersionUID = 1L; 43 | String[] values = new String[] {}; 44 | 45 | @Override 46 | public int getSize() { 47 | return values.length; 48 | } 49 | 50 | @Override 51 | public String getElementAt(int index) { 52 | return values[index]; 53 | } 54 | }); 55 | scrollPane.setViewportView(list); 56 | 57 | panel = new JPanel(); 58 | add(panel, BorderLayout.SOUTH); 59 | panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5)); 60 | 61 | create = new JButton("Create new"); 62 | panel.add(create); 63 | 64 | panel_1 = new JPanel(); 65 | add(panel_1, BorderLayout.NORTH); 66 | 67 | titleLabel = new JLabel("no label"); 68 | panel_1.add(titleLabel); 69 | titleLabel.setHorizontalAlignment(SwingConstants.CENTER); 70 | } 71 | 72 | @Override 73 | public void setTitle(String title) { 74 | titleLabel.setText(title); 75 | } 76 | 77 | protected void updateWith(Map listing) { 78 | list.removeAll(); 79 | list.setListData(new ArrayList<>(listing.keySet()).toArray(new String[listing.keySet().size()])); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/event/Event.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.event; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | import eu.ha3.matmos.Matmos; 8 | import eu.ha3.matmos.core.Component; 9 | import eu.ha3.matmos.core.SoundRelay; 10 | import net.minecraft.client.Minecraft; 11 | import net.minecraft.client.resources.IResourcePack; 12 | import net.minecraft.util.ResourceLocation; 13 | 14 | public class Event extends Component implements EventInterface { 15 | private static Random random = new Random(); 16 | 17 | public final List paths; 18 | public final float volMin; 19 | public final float volMax; 20 | public final float pitchMin; 21 | public final float pitchMax; 22 | public final int distance; 23 | 24 | private final SoundRelay relay; 25 | 26 | public Event(String name, SoundRelay relay, List paths, float volMin, float volMax, float pitchMin, float pitchMax, int distance) { 27 | super(name); 28 | this.relay = relay; 29 | 30 | this.paths = paths; 31 | this.volMin = volMin; 32 | this.volMax = volMax; 33 | this.pitchMin = pitchMin; 34 | this.pitchMax = pitchMax; 35 | this.distance = distance; 36 | } 37 | 38 | @Override 39 | public void cacheSounds(IResourcePack resourcePack) { 40 | IResourcePack def = Minecraft.getMinecraft().getResourcePackRepository().rprDefaultResourcePack; 41 | List toRemove = new ArrayList<>(); 42 | for (String path : paths) { 43 | ResourceLocation location = new ResourceLocation("minecraft", "sounds/" + path); 44 | if (resourcePack.resourceExists(location) || def.resourceExists(location)) { 45 | relay.cacheSound(path); 46 | } else { 47 | Matmos.LOGGER.warn("File: " + path + " appears to be missing from: " + resourcePack.getPackName() + " [This sound will not be cached or played in-game]"); 48 | toRemove.add(path); 49 | } 50 | } 51 | paths.removeAll(toRemove); 52 | } 53 | 54 | @Override 55 | public void playSound(float volMod, float pitchMod) { 56 | if (paths.isEmpty()) { 57 | return; 58 | } 59 | 60 | float volume = volMax - volMin; 61 | float pitch = pitchMax - pitchMin; 62 | 63 | volume = volMin + (volume > 0 ? random.nextFloat() * volume : 0); 64 | pitch = pitchMin + (pitch > 0 ? random.nextFloat() * pitch : 0); 65 | 66 | volume *= volMod; 67 | pitch *= pitchMod; 68 | 69 | String path = paths.get(random.nextInt(paths.size())); 70 | 71 | relay.playSound(path, volume, pitch, distance); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sound/NoAttenuationMovingSound.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sound; 2 | 3 | import eu.ha3.matmos.core.SystemClock; 4 | import eu.ha3.matmos.util.math.HelperFadeCalculator; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.audio.ISound; 7 | import net.minecraft.client.audio.MovingSound; 8 | import net.minecraft.entity.Entity; 9 | import net.minecraft.init.SoundEvents; 10 | import net.minecraft.util.ResourceLocation; 11 | import net.minecraft.util.SoundCategory; 12 | 13 | public class NoAttenuationMovingSound extends MovingSound implements StreamingSound { 14 | private boolean usesPause; 15 | private final HelperFadeCalculator helper = new HelperFadeCalculator(new SystemClock()); 16 | private float desiredVolume; 17 | private float desiredPitch; 18 | 19 | protected NoAttenuationMovingSound(ResourceLocation myResource, float volume, float pitch, boolean isLooping, boolean usesPause) { 20 | super(SoundEvents.AMBIENT_CAVE, SoundCategory.MASTER); 21 | 22 | positionedSoundLocation = myResource; 23 | attenuationType = ISound.AttenuationType.NONE; 24 | repeat = isLooping; 25 | repeatDelay = 0; 26 | 27 | desiredVolume = volume; 28 | desiredPitch = pitch; 29 | this.volume = volume; 30 | this.pitch = pitch; 31 | 32 | this.usesPause = usesPause; 33 | } 34 | 35 | public NoAttenuationMovingSound copy() { 36 | return new NoAttenuationMovingSound(getSoundLocation(), desiredVolume, desiredPitch, repeat, usesPause); 37 | } 38 | 39 | @Override 40 | public void update() { 41 | Entity e = Minecraft.getMinecraft().player; 42 | 43 | xPosF = (float)e.posX; 44 | yPosF = (float)e.posY; 45 | zPosF = (float)e.posZ; 46 | 47 | volume = helper.calculateFadeFactor() * desiredVolume; 48 | 49 | if (volume < 0.01f && usesPause) { 50 | pitch = 0f; 51 | } 52 | 53 | if (volume > 0.01f && usesPause) { 54 | pitch = desiredPitch; 55 | } 56 | 57 | if (helper.isDoneFadingOut() && repeat && !isDonePlaying()) { 58 | dispose(); 59 | } 60 | } 61 | 62 | @Override 63 | public void play(float fadeIn) { 64 | helper.fadeIn((long)(fadeIn * 1000)); 65 | } 66 | 67 | @Override 68 | public void stop(float fadeOut) { 69 | helper.fadeOut((long)(fadeOut * 1000)); 70 | } 71 | 72 | @Override 73 | public void applyVolume(float volumeMod) { 74 | volume = volumeMod; 75 | } 76 | 77 | @Override 78 | public void dispose() { 79 | donePlaying = true; 80 | } 81 | 82 | @Override 83 | public void interrupt() { 84 | donePlaying = true; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/edit/DynamicRemoverPanel.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.edit; 2 | 3 | import java.awt.BorderLayout; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import javax.swing.JButton; 8 | import javax.swing.JList; 9 | import javax.swing.JPanel; 10 | import javax.swing.JScrollPane; 11 | 12 | import eu.ha3.matmos.editor.interfaces.IFlaggable; 13 | import eu.ha3.matmos.serialisation.expansion.SerialDynamic; 14 | import eu.ha3.matmos.serialisation.expansion.SerialDynamicSheetIndex; 15 | 16 | public class DynamicRemoverPanel extends JPanel { 17 | private static final long serialVersionUID = 1L; 18 | 19 | private final IFlaggable parent; 20 | private final SerialDynamic dynamic; 21 | private JList list; 22 | 23 | private ArrayList things; 24 | 25 | public DynamicRemoverPanel(IFlaggable parent, SerialDynamic original) { 26 | this.parent = parent; 27 | dynamic = original; 28 | 29 | setLayout(new BorderLayout(0, 0)); 30 | 31 | JPanel panel = new JPanel(); 32 | add(panel, BorderLayout.CENTER); 33 | panel.setLayout(new BorderLayout(0, 0)); 34 | 35 | JScrollPane scrollPane = new JScrollPane(); 36 | panel.add(scrollPane, BorderLayout.CENTER); 37 | 38 | list = new JList<>(); 39 | list.setVisibleRowCount(4); 40 | scrollPane.setViewportView(list); 41 | 42 | JPanel panel_1 = new JPanel(); 43 | panel.add(panel_1, BorderLayout.EAST); 44 | 45 | JButton btnRemoveSelected = new JButton("Remove"); 46 | btnRemoveSelected.addActionListener(arg -> removeSelected()); 47 | panel_1.setLayout(new BorderLayout(0, 0)); 48 | panel_1.add(btnRemoveSelected); 49 | } 50 | 51 | protected void removeSelected() { 52 | List values = list.getSelectedValuesList(); 53 | if (values.size() == 0) { 54 | return; 55 | } 56 | 57 | int removedCount = 0; 58 | for (Object o : values) { 59 | String value = (String)o; 60 | if (things.contains(value)) { 61 | dynamic.entries.remove(things.indexOf(value)); 62 | removedCount = removedCount + 1; 63 | } 64 | } 65 | 66 | if (removedCount > 0) { 67 | parent.flagChange(); 68 | // Flagging should cause a call to fillWithValues 69 | } 70 | } 71 | 72 | public void fillWithValues() { 73 | list.removeAll(); 74 | 75 | things = new ArrayList<>(); 76 | for (SerialDynamicSheetIndex si : dynamic.entries) { 77 | things.add(si.sheet + "@" + si.index); 78 | } 79 | 80 | list.setListData(things.toArray(new String[things.size()])); 81 | } 82 | 83 | public JList getList() { 84 | return list; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/ProcessorModel.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.core.sheet.DeltaSheet; 5 | import eu.ha3.matmos.core.sheet.Sheet; 6 | import eu.ha3.matmos.core.sheet.VirtualSheet; 7 | import eu.ha3.matmos.data.IDataGatherer; 8 | 9 | /** 10 | * A processor that contains a sheet, or a virtual delta sheet if the deltaName is not null. Calling 11 | * doProcess() will set the values of the sheet, and automatically apply them at the end of the call 12 | * if the sheet provided by the Data is a virtual sheet, or if the sheet is a delta sheet. 13 | * 14 | * @author Hurry 15 | */ 16 | public abstract class ProcessorModel implements IDataGatherer { 17 | protected Sheet sheet; 18 | 19 | private int interval; 20 | private int callsRemaining; 21 | 22 | public ProcessorModel(DataPackage data, String normalName, String deltaName) { 23 | if (deltaName == null) { 24 | sheet = data.getSheet(normalName); 25 | } else { 26 | sheet = new DeltaSheet(data, normalName, deltaName); 27 | } 28 | 29 | interval = 1; 30 | callsRemaining = 0; 31 | } 32 | 33 | /** 34 | * Runs this module's value discovery processing. 35 | */ 36 | protected abstract void doProcess(); 37 | 38 | @Override 39 | public void process() { 40 | if (callsRemaining <= 0) { 41 | doProcess(); 42 | 43 | if (sheet instanceof VirtualSheet) { 44 | ((VirtualSheet)sheet).apply(); 45 | } 46 | 47 | if (interval != 0) { 48 | callsRemaining = interval; 49 | } 50 | } else { 51 | callsRemaining = callsRemaining - 1; 52 | } 53 | } 54 | 55 | /** 56 | * Sets the number of calls where nothing happens before the process is executed again. Defaults to 57 | * 0 (call every time). 58 | * 59 | * @param value 60 | */ 61 | public void setInterval(int value) { 62 | interval = Math.min(0, value); 63 | callsRemaining = 0; 64 | } 65 | 66 | public void setValueIntIndex(int index, boolean value) { 67 | setValue(Integer.toString(index), value); 68 | } 69 | 70 | public void setValueIntIndex(int index, long value) { 71 | setValue(Integer.toString(index), value); 72 | } 73 | 74 | public void setValueIntIndex(int index, String value) { 75 | setValue(Integer.toString(index), value); 76 | } 77 | 78 | public void setValue(String index, boolean newValue) { 79 | setValue(index, newValue ? "1" : "0"); 80 | } 81 | 82 | public void setValue(String index, long newValue) { 83 | setValue(index, Long.toString(newValue)); 84 | } 85 | 86 | public void setValue(String index, String value) { 87 | sheet.set(index, value == null ? "NULL" : value); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/soundpacks/default/assets/matmos/expansions/interactions_extras.json: -------------------------------------------------------------------------------- 1 | { 2 | "condition": { 3 | "In Minecart": { 4 | "sheet": "legacy", 5 | "index": "riding_minecart", 6 | "symbol": "EQUAL", 7 | "value": "1" 8 | }, 9 | "Is Speedy": { 10 | "sheet": "ride_motion", 11 | "index": "sqrt_xx_zz", 12 | "symbol": "GREATER", 13 | "value": "1500" 14 | }, 15 | "Is very Speedy": { 16 | "sheet": "ride_motion", 17 | "index": "sqrt_xx_zz", 18 | "symbol": "GREATER", 19 | "value": "3000" 20 | } 21 | }, 22 | "set": { 23 | "Is moving in Minecart": { 24 | "yes": [ 25 | "In Minecart", 26 | "Is Speedy" 27 | ], 28 | "no": [] 29 | }, 30 | "Is moving in Minecart fast": { 31 | "yes": [ 32 | "In Minecart", 33 | "Is very Speedy" 34 | ], 35 | "no": [] 36 | } 37 | }, 38 | "machine": { 39 | "Moving in Minecart": { 40 | "allow": [ 41 | "Is moving in Minecart" 42 | ], 43 | "restrict": [ 44 | "Is moving in Minecart fast" 45 | ], 46 | "fadein": 0.0, 47 | "fadeout": 0.0, 48 | "delay_fadein": 0.0, 49 | "delay_fadeout": 0.0, 50 | "event": [ 51 | { 52 | "event": "Moving in Minecart", 53 | "vol_mod": 0.5, 54 | "pitch_mod": 1.0, 55 | "delay_min": 0.7, 56 | "delay_max": 0.8, 57 | "delay_start": 0.0 58 | } 59 | ] 60 | }, 61 | "Moving in Minecart Fast": { 62 | "allow": [ 63 | "Is moving in Minecart fast" 64 | ], 65 | "restrict": [], 66 | "fadein": 0.0, 67 | "fadeout": 0.0, 68 | "delay_fadein": 0.0, 69 | "delay_fadeout": 0.0, 70 | "event": [ 71 | { 72 | "event": "Moving in Minecart fast", 73 | "vol_mod": 0.5, 74 | "pitch_mod": 1.0, 75 | "delay_min": 0.6, 76 | "delay_max": 0.7, 77 | "delay_start": 0.0 78 | } 79 | ] 80 | } 81 | }, 82 | "event": { 83 | "Dummy": { 84 | "vol_min": 1.0, 85 | "vol_max": 1.0, 86 | "pitch_min": 1.0, 87 | "pitch_max": 1.0, 88 | "distance": 0, 89 | "path": [] 90 | }, 91 | "Moving in Minecart": { 92 | "vol_min": 1.0, 93 | "vol_max": 1.0, 94 | "pitch_min": 0.98, 95 | "pitch_max": 1.08, 96 | "distance": 0, 97 | "path": [ 98 | "matmos_extras/minecart1.ogg", 99 | "matmos_extras/minecart2.ogg", 100 | "matmos_extras/minecart3.ogg", 101 | "matmos_extras/minecart4.ogg" 102 | ] 103 | }, 104 | "Moving in Minecart fast": { 105 | "vol_min": 1.0, 106 | "vol_max": 1.0, 107 | "pitch_min": 1.25, 108 | "pitch_max": 1.35, 109 | "distance": 0, 110 | "path": [ 111 | "matmos_extras/minecart1.ogg", 112 | "matmos_extras/minecart2.ogg", 113 | "matmos_extras/minecart3.ogg", 114 | "matmos_extras/minecart4.ogg" 115 | ] 116 | } 117 | }, 118 | "list": {}, 119 | "dynamic": {} 120 | } -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/debug/SoundsJsonGenerator.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.debug; 2 | 3 | import java.io.File; 4 | import java.io.FileWriter; 5 | import java.io.IOException; 6 | import java.util.ArrayList; 7 | import java.util.LinkedHashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | import com.google.gson.Gson; 12 | import com.google.gson.GsonBuilder; 13 | 14 | public class SoundsJsonGenerator implements Runnable { 15 | 16 | private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); 17 | 18 | private List filenames = new ArrayList<>(); 19 | 20 | private boolean OVERWRITE_FILE = true; 21 | 22 | private final File soundsFolder; 23 | private final File jsonFile; 24 | 25 | public SoundsJsonGenerator(File soundsFolder, File jsonFile) { 26 | this.soundsFolder = soundsFolder; 27 | this.jsonFile = jsonFile; 28 | } 29 | 30 | @SuppressWarnings({"unchecked", "rawtypes"}) 31 | @Override 32 | public void run() { 33 | listAllFiles(); 34 | 35 | List workingNames = new ArrayList<>(); 36 | for (String name : filenames) { 37 | if (name.endsWith(".ogg")) { 38 | workingNames.add(name.substring(0, name.indexOf("."))); 39 | } 40 | } 41 | 42 | Map catNames = new LinkedHashMap<>(); 43 | for (String name : workingNames) { 44 | String newName = name.replace('/', '.').replaceAll("[0-9]", ""); 45 | if (!catNames.containsKey(newName)) { 46 | catNames.put(newName, new ArrayList()); 47 | } 48 | 49 | if (!name.contains("stream")) { 50 | catNames.get(newName).add(name); 51 | } else { 52 | Map streaming = new LinkedHashMap<>(); 53 | streaming.put("name", name); 54 | streaming.put("stream", true); 55 | catNames.get(newName).add(streaming); 56 | } 57 | } 58 | 59 | Map toJsonify = new LinkedHashMap<>(); 60 | for (String catName : catNames.keySet()) { 61 | Map blob = new LinkedHashMap<>(); 62 | blob.put("category", catName.contains("underwater") ? "weather" : "ambient"); 63 | blob.put("sounds", catNames.get(catName)); 64 | 65 | toJsonify.put(catName, blob); 66 | } 67 | 68 | String jason = gson.toJson(toJsonify); 69 | 70 | if (!OVERWRITE_FILE) { 71 | System.out.println(jason); 72 | return; 73 | } 74 | 75 | try (FileWriter writer = new FileWriter(jsonFile)) { 76 | writer.append(jason); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | } 81 | 82 | private void listAllFiles() { 83 | listFiles(soundsFolder, soundsFolder); 84 | } 85 | 86 | private void listFiles(File root, File subdir) { 87 | for (File file : subdir.listFiles()) { 88 | if (file.isDirectory()) { 89 | listFiles(root, file); 90 | } else { 91 | filenames.add(root.toURI().relativize(file.toURI()).getPath().toLowerCase().toString()); 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/event/TimedEventInformation.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.event; 2 | 3 | import java.util.List; 4 | 5 | import eu.ha3.matmos.core.MultistateComponent; 6 | import eu.ha3.matmos.core.Provider; 7 | import eu.ha3.matmos.core.ReferenceTime; 8 | import eu.ha3.matmos.core.Simulated; 9 | import eu.ha3.matmos.core.logic.Machine; 10 | import eu.ha3.matmos.util.math.HelperFadeCalculator; 11 | 12 | public class TimedEventInformation extends MultistateComponent implements Simulated { 13 | private float delayBeforeFadeIn = 0; 14 | private float delayBeforeFadeOut = 0; 15 | private float fadeInTime = 0; 16 | private float fadeOutTime = 0; 17 | 18 | private final String machineName; 19 | private final Provider provider; 20 | private final ReferenceTime time; 21 | private List events; 22 | 23 | private HelperFadeCalculator calc; 24 | 25 | private boolean isPlaying; 26 | private long startTime; 27 | private long stopTime; 28 | 29 | public TimedEventInformation(String machineName, Provider provider, ReferenceTime time, List events, float delayBeforeFadeIn, float delayBeforeFadeOut, float fadeInTime, float fadeOutTime) { 30 | super("_TIMED:" + machineName); 31 | 32 | this.machineName = machineName; 33 | this.provider = provider; 34 | this.time = time; 35 | 36 | calc = new HelperFadeCalculator(time); 37 | 38 | this.events = events; 39 | this.delayBeforeFadeIn = delayBeforeFadeIn; 40 | this.delayBeforeFadeOut = delayBeforeFadeOut; 41 | this.fadeInTime = fadeInTime; 42 | this.fadeOutTime = fadeOutTime; 43 | } 44 | 45 | private void signalPlayable() { 46 | startTime = time.getMilliseconds() + (long)(delayBeforeFadeIn * 1000); 47 | } 48 | 49 | private void signalStoppable() { 50 | stopTime = time.getMilliseconds() + (long)(delayBeforeFadeOut * 1000); 51 | } 52 | 53 | @Override 54 | public void evaluate() { 55 | if (!provider.exists(machineName)) { 56 | return; 57 | } 58 | 59 | boolean active = provider.get(machineName).isActive(); 60 | if (active != isActive) { 61 | isActive = active; 62 | incrementVersion(); 63 | if (active) { 64 | signalPlayable(); 65 | } else { 66 | signalStoppable(); 67 | } 68 | } 69 | } 70 | 71 | @Override 72 | public void simulate() { 73 | if (isActive && !isPlaying) { 74 | if (time.getMilliseconds() > startTime) { 75 | isPlaying = true; 76 | calc.fadeIn((long)(fadeInTime * 1000)); 77 | for (TimedEventInterface t : events) { 78 | t.restart(time); 79 | } 80 | } 81 | } else if (!isActive && isPlaying) { 82 | if (time.getMilliseconds() > stopTime) { 83 | isPlaying = false; 84 | calc.fadeOut((long)(fadeOutTime * 1000)); 85 | } 86 | } 87 | 88 | if (isPlaying || calc.calculateFadeFactor() > 0f) { 89 | play(); 90 | } 91 | } 92 | 93 | private void play() { 94 | float fadeFactor = calc.calculateFadeFactor(); 95 | for (TimedEventInterface t : events) { 96 | t.play(time, fadeFactor); 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/gui/GuiBiomeSlider.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.gui; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.annotation.Nullable; 7 | 8 | import eu.ha3.matmos.Matmos; 9 | import eu.ha3.mc.gui.HDisplayStringProvider; 10 | import eu.ha3.mc.gui.HGuiSliderControl; 11 | import eu.ha3.mc.gui.HSliderListener; 12 | import net.minecraft.client.resources.I18n; 13 | import net.minecraft.util.StringUtils; 14 | import net.minecraft.world.biome.Biome; 15 | 16 | public class GuiBiomeSlider implements HDisplayStringProvider, HSliderListener { 17 | final protected Matmos mod; 18 | 19 | final protected int maxBiomes = calculateMaxBiomes(); 20 | protected int definedBiomeID; 21 | 22 | private List validBiomes = new ArrayList<>(); 23 | 24 | public GuiBiomeSlider(Matmos mod, int define) { 25 | this.mod = mod; 26 | definedBiomeID = define; 27 | 28 | computeBiomes(); 29 | } 30 | 31 | private void computeBiomes() { 32 | for (Biome i : Biome.REGISTRY) { 33 | validBiomes.add(Biome.REGISTRY.getIDForObject(i)); 34 | } 35 | } 36 | 37 | @Override 38 | public void sliderValueChanged(HGuiSliderControl slider, float value) { 39 | int biomeID = (int)(Math.floor(value * validBiomes.size()) - 1); 40 | 41 | definedBiomeID = biomeID >= 0 && biomeID < validBiomes.size() ? validBiomes.get(biomeID) : biomeID; 42 | 43 | slider.updateDisplayString(); 44 | } 45 | 46 | @Override 47 | public void sliderReleased(HGuiSliderControl hGuiSliderControl) { 48 | mod.getConfig().setProperty("useroptions.biome.override", definedBiomeID); 49 | mod.saveConfig(); 50 | } 51 | 52 | @Override 53 | public String provideDisplayString() { 54 | String desc = getDescriptorString(); 55 | 56 | if (desc == null) { 57 | return ""; 58 | } 59 | 60 | return I18n.format("mat.biome.override", desc); 61 | } 62 | 63 | @Nullable 64 | protected String getDescriptorString() { 65 | if (definedBiomeID >= 0 && definedBiomeID <= maxBiomes) { 66 | Biome biome = Biome.getBiomeForId(definedBiomeID); 67 | 68 | if (biome == null) { 69 | return I18n.format("mat.biome.undef", definedBiomeID); 70 | } 71 | 72 | if (StringUtils.isNullOrEmpty(biome.getBiomeName())) { 73 | return I18n.format("mat.biome.unamed", definedBiomeID); 74 | } 75 | 76 | return I18n.format("mat.biome.biome", biome.getBiomeName(), definedBiomeID); 77 | } 78 | 79 | if (definedBiomeID == -1) { 80 | return I18n.format("mat.biome.disabled"); 81 | } 82 | 83 | return null; 84 | } 85 | 86 | public float calculateSliderLocation(int biomeID) { 87 | 88 | if (biomeID == -1) { 89 | return 0; 90 | } 91 | 92 | if (validBiomes.contains(biomeID)) { 93 | return (validBiomes.indexOf(biomeID) + 1) / validBiomes.size(); 94 | } 95 | 96 | return 1; 97 | } 98 | 99 | private int calculateMaxBiomes() { 100 | int max = 0; 101 | 102 | for (Biome i : Biome.REGISTRY) { 103 | int id = Biome.REGISTRY.getIDForObject(i); 104 | 105 | if (id > max) { 106 | max = id; 107 | } 108 | } 109 | 110 | return max; 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/modules/mount/ModuleHorse.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.modules.mount; 2 | 3 | import eu.ha3.matmos.core.sheet.DataPackage; 4 | import eu.ha3.matmos.data.modules.Module; 5 | import eu.ha3.matmos.data.modules.ModuleProcessor; 6 | import net.minecraft.entity.Entity; 7 | import net.minecraft.entity.passive.EntityHorse; 8 | import net.minecraft.entity.player.EntityPlayer; 9 | 10 | public class ModuleHorse extends ModuleProcessor implements Module { 11 | public ModuleHorse(DataPackage data) { 12 | super(data, "ride_horse"); 13 | } 14 | 15 | @Override 16 | protected void doProcess() { 17 | Entity xride = getPlayer().getRidingEntity(); 18 | 19 | if (xride == null || !(xride instanceof EntityHorse)) { 20 | setValue("jumping", false); 21 | setValue("rearing", false); 22 | setValue("saddled", false); 23 | setValue("leashed", false); 24 | setValue("chested", false); 25 | setValue("tame", false); 26 | setValue("type", 0); 27 | setValue("variant", 0); 28 | setValue("name_tag", ""); 29 | setValue("health1k", 0); 30 | setValue("leashed_to_player", false); 31 | setValue("ridden_by_owner", false); 32 | setValue("leashed_to_owner", false); 33 | setValue("leash_distance", 0); 34 | setValue("temper", 0); 35 | setValue("owner_name", ""); 36 | setValue("reproduced", false); 37 | setValue("bred", false); 38 | 39 | return; 40 | } 41 | 42 | EntityHorse ride = (EntityHorse)xride; 43 | 44 | setValue("jumping", ride.isHorseJumping()); 45 | setValue("rearing", ride.isRearing()); 46 | setValue("saddled", ride.isHorseSaddled()); 47 | setValue("leashed", ride.getLeashed()); 48 | setValue("tame", ride.isTame()); 49 | // TODO: Where'd it go? 50 | //setValue("chested", ride.isChested()); 51 | setValue("tame", ride.isTame()); 52 | setValue("type", ride.isEntityUndead()); 53 | setValue("variant", ride.getHorseVariant()); 54 | 55 | setValue("name_tag", ride.getCustomNameTag()); 56 | 57 | setValue("health1k", (int)(ride.getHealth() * 1000)); 58 | setValue("leashed_to_player", ride.getLeashed() && ride.getLeashHolder() instanceof EntityPlayer); 59 | setValue("ridden_by_owner", 60 | ride.getControllingPassenger() instanceof EntityPlayer 61 | && ride.getOwnerUniqueId() != null 62 | && ride.getOwnerUniqueId().equals(((EntityPlayer)ride.getControllingPassenger()).getGameProfile().getId())); 63 | setValue("leashed_to_owner", 64 | ride.getLeashHolder() instanceof EntityPlayer 65 | && !ride.getOwnerUniqueId().toString().equals("") 66 | && ride.getOwnerUniqueId().equals(((EntityPlayer)ride.getLeashHolder()).getGameProfile().getId())); 67 | 68 | if (ride.getLeashed() && ride.getLeashHolder() != null) { 69 | setValue("leash_distance", (int)(ride.getLeashHolder().getDistance(ride) * 1000)); 70 | } else { 71 | setValue("leash_distance", 0); 72 | } 73 | 74 | // Server only? 75 | setValue("temper", ride.getTemper()); 76 | setValue("owner_uuid", ride.getOwnerUniqueId().toString()); 77 | setValue("reproduced", ride.isBreeding()); 78 | setValue("bred", ride.isEatingHaystack()); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/logic/Condition.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.logic; 2 | 3 | import java.util.Collection; 4 | import java.util.HashSet; 5 | 6 | import eu.ha3.matmos.Matmos; 7 | import eu.ha3.matmos.core.Dependable; 8 | import eu.ha3.matmos.core.MultistateComponent; 9 | import eu.ha3.matmos.core.Operator; 10 | import eu.ha3.matmos.core.sheet.SheetCommander; 11 | import eu.ha3.matmos.core.sheet.SheetIndex; 12 | import eu.ha3.matmos.util.math.Numbers; 13 | 14 | public class Condition extends MultistateComponent implements Dependable, Visualized { 15 | private final SheetIndex indexX; 16 | 17 | private final Operator operatorX; 18 | 19 | private final String constantX; 20 | 21 | private final Long constantLongX; 22 | 23 | private final SheetCommander sheetCommander; 24 | 25 | // Fixes a bug where conditions don't evaluate for sheet indexes that don't exist 26 | // Required for ALWAYS_TRUE / ALWAYS_FALSE 27 | // This was caused by default value for undefined sheet indexes being -1 (equal to initial siVersion) 28 | private int siVersion = Integer.MIN_VALUE; 29 | 30 | private final Collection dependencies; 31 | 32 | public Condition(String name, SheetCommander sheetCommander, SheetIndex index, Operator operator, String constant) { 33 | super(name); 34 | this.sheetCommander = sheetCommander; 35 | 36 | indexX = index; 37 | operatorX = operator; 38 | constantX = constant; 39 | 40 | constantLongX = Numbers.toLong(constant); 41 | 42 | dependencies = new HashSet<>(); 43 | dependencies.add(index.getSheet()); 44 | } 45 | 46 | @Override 47 | public void evaluate() { 48 | if (sheetCommander.version(indexX) == siVersion) { 49 | return; 50 | } 51 | 52 | boolean pre = isActive; 53 | isActive = testIfTrue(); 54 | 55 | if (pre != isActive) { 56 | incrementVersion(); 57 | 58 | Matmos.LOGGER.debug("C: " + getName() + " -> " + isActive); 59 | } 60 | } 61 | 62 | private boolean testIfTrue() { 63 | try { 64 | String value = sheetCommander.get(indexX); 65 | switch (operatorX) { 66 | case IN_LIST: 67 | return sheetCommander.listHas(constantX, value); 68 | case NOT_IN_LIST: 69 | return !sheetCommander.listHas(constantX, value); 70 | default: 71 | if (constantLongX != null) { 72 | Long longValue = Numbers.toLong(value); 73 | if (longValue != null) { 74 | return operatorX.test(longValue, constantLongX); 75 | } 76 | } 77 | return operatorX.test(value, constantX); 78 | } 79 | } catch (Exception e) { 80 | e.printStackTrace(); 81 | return false; 82 | } 83 | } 84 | 85 | /** 86 | * Returns the required sheet modules of this condition. 87 | */ 88 | @Override 89 | public Collection getDependencies() { 90 | return dependencies; 91 | } 92 | 93 | @Override 94 | public String getFeed() { 95 | String value = sheetCommander.get(indexX); 96 | String op = operatorX.getSymbol(); 97 | 98 | return indexX.getSheet() + ">" + indexX.getIndex() + ":[" + value + "] " + op + " " + constantX; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/sound/Simulacrum.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core.sound; 2 | 3 | import java.io.File; 4 | import java.util.Locale; 5 | import java.util.Map; 6 | 7 | import eu.ha3.easy.TimeStatistic; 8 | import eu.ha3.matmos.Matmos; 9 | import eu.ha3.matmos.ResourcePackDealer; 10 | import eu.ha3.matmos.core.expansion.Expansion; 11 | import eu.ha3.matmos.core.expansion.ExpansionManager; 12 | import eu.ha3.matmos.core.expansion.VolumeUpdatable; 13 | import eu.ha3.matmos.data.modules.ModuleRegistry; 14 | import eu.ha3.matmos.game.user.VisualDebugger; 15 | import eu.ha3.mc.haddon.supporting.SupportsFrameEvents; 16 | import eu.ha3.mc.haddon.supporting.SupportsTickEvents; 17 | 18 | public class Simulacrum implements SupportsTickEvents, SupportsFrameEvents { 19 | private ExpansionManager expansionManager; 20 | private ModuleRegistry dataGatherer; 21 | private VisualDebugger visualDebugger; 22 | private boolean isBrutallyInterrupted; 23 | 24 | private boolean hasResourcePacks; 25 | private boolean hasDisabledResourcePacks; 26 | 27 | public Simulacrum(Matmos mod) { 28 | expansionManager = new ExpansionManager(new File(mod.util().getModsFolder(), "matmos/expansions_r29_userconfig/"), mod.getSoundHandler()); 29 | expansionManager.setVolumeAndUpdate(mod.getConfig().getFloat("globalvolume.scale")); 30 | 31 | TimeStatistic stat = new TimeStatistic(Locale.ENGLISH); 32 | 33 | dataGatherer = new ModuleRegistry(mod); 34 | dataGatherer.load(); 35 | visualDebugger = new VisualDebugger(mod, dataGatherer); 36 | expansionManager.setData(dataGatherer.getData()); 37 | expansionManager.setCollector(dataGatherer); 38 | expansionManager.loadExpansions(); 39 | 40 | hasResourcePacks = true; 41 | if (expansionManager.getExpansions().size() == 0) { 42 | ResourcePackDealer dealer = new ResourcePackDealer(); 43 | 44 | if (dealer.findResourcePacks().count() == 0) { 45 | hasResourcePacks = false; 46 | hasDisabledResourcePacks = dealer.findDisabledResourcePacks().size() > 0; 47 | } 48 | } 49 | 50 | expansionManager.synchronize(); 51 | 52 | Matmos.LOGGER.info("Expansions loaded (" + stat.getSecondsAsString(1) + "s)."); 53 | } 54 | 55 | public void interruptBrutally() { 56 | isBrutallyInterrupted = true; 57 | } 58 | 59 | public void dispose() { 60 | if (!isBrutallyInterrupted) { 61 | expansionManager.dispose(); 62 | } 63 | } 64 | 65 | @Override 66 | public void onFrame(float semi) { 67 | expansionManager.onFrame(semi); 68 | visualDebugger.onFrame(semi); 69 | } 70 | 71 | @Override 72 | public void onTick() { 73 | dataGatherer.process(); 74 | expansionManager.onTick(); 75 | } 76 | 77 | public boolean hasResourcePacks() { 78 | return hasResourcePacks; 79 | } 80 | 81 | public boolean hasDisabledResourcePacks() { 82 | return hasDisabledResourcePacks; 83 | } 84 | 85 | public Map getExpansions() { 86 | return expansionManager.getExpansions(); 87 | } 88 | 89 | public void synchronize() { 90 | expansionManager.synchronize(); 91 | } 92 | 93 | public void saveConfig() { 94 | expansionManager.saveConfig(); 95 | } 96 | 97 | public VisualDebugger getVisualDebugger() { 98 | return visualDebugger; 99 | } 100 | 101 | public VolumeUpdatable getGlobalVolumeControl() { 102 | return expansionManager; 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/data/scanners/ScanVolumetric.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.data.scanners; 2 | 3 | import net.minecraft.client.Minecraft; 4 | 5 | public class ScanVolumetric implements Progress { 6 | private ScanOperations pipeline; 7 | 8 | private int xstart; 9 | private int ystart; 10 | private int zstart; 11 | 12 | private int xsize; 13 | private int ysize; 14 | private int zsize; 15 | 16 | private int opspercall; 17 | 18 | private boolean isScanning; 19 | 20 | private int finalProgress = 1; 21 | // We don't want progress to be zero, to avoid divide by zero 22 | private int progress = 1; 23 | 24 | private int xx; 25 | private int yy; 26 | private int zz; 27 | 28 | public ScanVolumetric() { 29 | pipeline = null; 30 | isScanning = false; 31 | } 32 | 33 | public void setPipeline(ScanOperations pipelineIn) { 34 | pipeline = pipelineIn; 35 | } 36 | 37 | public void startScan(int x, int y, int z, int xsizeIn, int ysizeIn, int zsizeIn, int opspercallIn) { 38 | if (isScanning) { 39 | return; 40 | } 41 | 42 | if (pipeline == null) { 43 | return; 44 | } 45 | 46 | if (opspercallIn <= 0) { 47 | throw new IllegalArgumentException(); 48 | } 49 | 50 | int worldHeight = Minecraft.getMinecraft().world.getHeight(); 51 | 52 | if (ysizeIn > worldHeight) { 53 | ysizeIn = worldHeight; 54 | } 55 | 56 | xsize = xsizeIn; 57 | ysize = ysizeIn; 58 | zsize = zsizeIn; 59 | 60 | y = y - ysize / 2; 61 | 62 | if (y < 0) { 63 | y = 0; 64 | } else if (y > worldHeight - ysize) { 65 | y = worldHeight - ysize; 66 | } 67 | 68 | xstart = x - xsize / 2; 69 | ystart = y; // ((y - ysize / 2)) already done before 70 | zstart = z - zsize / 2; 71 | opspercall = opspercallIn; 72 | 73 | progress = 0; 74 | finalProgress = xsize * ysize * zsize; 75 | 76 | xx = 0; 77 | yy = 0; 78 | zz = 0; 79 | 80 | pipeline.begin(); 81 | isScanning = true; 82 | } 83 | 84 | public boolean routine() { 85 | if (!isScanning) { 86 | return false; 87 | } 88 | long ops = 0; 89 | while (ops < opspercall && progress < finalProgress) { 90 | pipeline.input(xstart + xx, ystart + yy, zstart + zz); 91 | 92 | xx = (xx + 1) % xsize; 93 | if (xx == 0) { 94 | zz = (zz + 1) % zsize; 95 | if (zz == 0) { 96 | yy++; 97 | 98 | if (yy >= ysize && progress != finalProgress - 1) { 99 | System.err.println("LOGIC ERROR"); 100 | } 101 | } 102 | } 103 | 104 | ops++; 105 | progress++; 106 | 107 | } 108 | 109 | if (progress >= finalProgress) { 110 | scanDoneEvent(); 111 | } 112 | 113 | return true; 114 | } 115 | 116 | public void stopScan() { 117 | isScanning = false; 118 | } 119 | 120 | private void scanDoneEvent() { 121 | if (!isScanning) { 122 | return; 123 | } 124 | 125 | pipeline.finish(); 126 | stopScan(); 127 | } 128 | 129 | @Override 130 | public int getProgress_Current() { 131 | return progress; 132 | } 133 | 134 | @Override 135 | public int getProgress_Total() { 136 | return finalProgress; 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /src/main/java/eu/ha3/matmos/core/StreamInformation.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.core; 2 | 3 | import eu.ha3.matmos.core.logic.Machine; 4 | 5 | public class StreamInformation extends MultistateComponent implements Simulated { 6 | private String path; 7 | private float volume; 8 | private float pitch; 9 | private float delayBeforeFadeIn; 10 | private float delayBeforeFadeOut; 11 | private float fadeInTime; 12 | private float fadeOutTime; 13 | private boolean isLooping; 14 | private boolean usesPause; 15 | 16 | private final String machineName; 17 | private final Provider provider; 18 | private final ReferenceTime time; 19 | private final SoundRelay relay; 20 | 21 | private boolean initialized; 22 | private int token; 23 | 24 | private boolean isPlaying; 25 | private long startTime; 26 | private long stopTime; 27 | 28 | public StreamInformation(String machineName, Provider provider, ReferenceTime time, SoundRelay relay, String path, float volume, float pitch, float delayBeforeFadeIn, float delayBeforeFadeOut, float fadeInTime, float fadeOutTime, boolean isLooping, boolean usesPause) { 29 | super("_STREAM:" + machineName); 30 | 31 | this.machineName = machineName; 32 | this.provider = provider; 33 | this.time = time; 34 | this.relay = relay; 35 | 36 | this.path = path; 37 | this.volume = volume; 38 | this.pitch = pitch; 39 | this.delayBeforeFadeIn = delayBeforeFadeIn; 40 | this.delayBeforeFadeOut = delayBeforeFadeOut; 41 | this.fadeInTime = fadeInTime; 42 | this.fadeOutTime = fadeOutTime; 43 | this.isLooping = isLooping; 44 | this.usesPause = usesPause; 45 | 46 | token = -1; 47 | } 48 | 49 | @Override 50 | public void evaluate() { 51 | if (!provider.exists(machineName)) { 52 | return; 53 | } 54 | 55 | boolean active = provider.get(machineName).isActive(); 56 | if (active != isActive) { 57 | isActive = active; 58 | incrementVersion(); 59 | if (active) { 60 | signalPlayable(); 61 | } else { 62 | signalStoppable(); 63 | } 64 | } 65 | } 66 | 67 | private void signalPlayable() { 68 | startTime = time.getMilliseconds() + (long)(delayBeforeFadeIn * 1000); 69 | } 70 | 71 | private void signalStoppable() { 72 | stopTime = time.getMilliseconds() + (long)(delayBeforeFadeOut * 1000); 73 | } 74 | 75 | @Override 76 | public void simulate() { 77 | if (!isLooping && usesPause) { 78 | return; // FIXME: A non-looping sound cannot use the pause scheme. 79 | } 80 | 81 | if (isActive && !isPlaying) { 82 | if (time.getMilliseconds() > startTime) { 83 | isPlaying = true; 84 | 85 | if (!initialized) { 86 | token = relay.getNewStreamingToken(); 87 | 88 | if (relay.setupStreamingToken(token, path, volume, pitch, isLooping, usesPause)) { 89 | initialized = true; 90 | relay.startStreaming(token, fadeInTime); 91 | } 92 | } else { 93 | relay.startStreaming(token, fadeInTime); 94 | } 95 | } 96 | } else if (!isActive && isPlaying) { 97 | if (time.getMilliseconds() > stopTime) { 98 | isPlaying = false; 99 | relay.stopStreaming(token, fadeOutTime); 100 | } 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/dev/java/eu/ha3/matmos/editor/tree/ItemTreeViewPanel.java: -------------------------------------------------------------------------------- 1 | package eu.ha3.matmos.editor.tree; 2 | 3 | import java.awt.BorderLayout; 4 | import java.util.Enumeration; 5 | 6 | import javax.swing.JPanel; 7 | import javax.swing.JScrollPane; 8 | import javax.swing.JTree; 9 | import javax.swing.tree.TreePath; 10 | 11 | import eu.ha3.matmos.editor.KnowledgeItemType; 12 | import eu.ha3.matmos.editor.interfaces.Editor; 13 | import eu.ha3.matmos.editor.interfaces.ISerialUpdate; 14 | import eu.ha3.matmos.editor.interfaces.NamedSerialEditor; 15 | import eu.ha3.matmos.serialisation.expansion.SerialRoot; 16 | 17 | @SuppressWarnings("serial") 18 | public class ItemTreeViewPanel extends JPanel implements ISerialUpdate, NamedSerialEditor { 19 | 20 | private final Editor model; 21 | 22 | private ItemTreeModel itemTreeModel = new ItemTreeModel(); 23 | private JTree itemTree; 24 | 25 | public ItemTreeViewPanel(Editor modelConstruct) { 26 | model = modelConstruct; 27 | 28 | setLayout(new BorderLayout(0, 0)); 29 | 30 | JScrollPane scrollPane = new JScrollPane(); 31 | add(scrollPane, BorderLayout.CENTER); 32 | 33 | itemTree = new JTree(); 34 | itemTree.addTreeSelectionListener(event -> { 35 | try { 36 | Object component = event.getPath().getLastPathComponent(); 37 | if (!(component instanceof ItemTreeNode)) { 38 | return; 39 | } 40 | 41 | if (component instanceof ItemTreeBranch) { 42 | return; 43 | } 44 | 45 | ItemTreeNode item = (ItemTreeNode)component; 46 | ItemTreeBranch parent = (ItemTreeBranch)item.getParent(); 47 | 48 | model.switchEditItem(parent.getSelector(), item.getItemName()); 49 | } catch (ClassCastException e) {} 50 | }); 51 | itemTree.setShowsRootHandles(true); 52 | itemTree.setModel(itemTreeModel); 53 | itemTree.setRootVisible(false); 54 | scrollPane.setViewportView(itemTree); 55 | } 56 | 57 | @Override 58 | public void updateSerial(SerialRoot root) { 59 | itemTreeModel.updateSerial(root); 60 | itemTree.updateUI(); 61 | } 62 | 63 | @Override 64 | public void setEditFocus(String name, Object item, boolean forceSelect) { 65 | if (item == null || name == null) { 66 | return; 67 | } 68 | 69 | if (!forceSelect) { 70 | return; 71 | } 72 | 73 | KnowledgeItemType k = KnowledgeItemType.fromSerialClass(item.getClass()); 74 | if (k == null) { 75 | return; 76 | } 77 | 78 | if (itemTree.getSelectionPath().getLastPathComponent() instanceof ItemTreeNode 79 | && ((ItemTreeNode)itemTree.getSelectionPath().getLastPathComponent()).getItemName().equals(name)) { 80 | return; 81 | } 82 | 83 | @SuppressWarnings("unchecked") 84 | Enumeration nenum = itemTreeModel.getItemTreeRoot().getKnowledgeNode(k).children(); 85 | while (nenum.hasMoreElements()) { 86 | ItemTreeNode next = nenum.nextElement(); 87 | String itemName = next.getItemName(); 88 | 89 | if (itemName.equals(name)) { 90 | itemTree.setSelectionPath(new TreePath(itemTreeModel.getPathToRoot(next))); 91 | return; 92 | } 93 | } 94 | } 95 | 96 | public ItemTreeNode getSelectedITN() { 97 | return (ItemTreeNode)(itemTree.getSelectionPath().getLastPathComponent() instanceof ItemTreeNode 98 | ? itemTree.getSelectionPath().getLastPathComponent() : null); 99 | } 100 | } 101 | --------------------------------------------------------------------------------