├── .classpath
├── .github
└── workflows
│ └── maven.yml
├── .gitignore
├── .project
├── .settings
├── org.eclipse.core.resources.prefs
├── org.eclipse.jdt.core.prefs
├── org.eclipse.jdt.ui.prefs
└── org.eclipse.m2e.core.prefs
├── LICENSE
├── README.md
├── pom.xml
└── src
├── basic
├── IOConsumer.java
├── IORunnable.java
├── Loggger.java
├── NameSupplier.java
├── RunnableWith.java
├── Tuple.java
├── Validator.java
└── Value.java
├── converter
├── Converter.java
├── ConvertingReport.java
├── Skins.java
├── actions
│ ├── Action.java
│ ├── ActionManager.java
│ ├── BlockMap.java
│ ├── ConvertEntity.java
│ ├── CustomActionManager.java
│ └── actions
│ │ ├── Cactus.java
│ │ ├── CenteredPointEntity.java
│ │ ├── CssLamp.java
│ │ ├── Debug.java
│ │ ├── DetailBlock.java
│ │ ├── EndPortalFrame.java
│ │ ├── Fence.java
│ │ ├── Fire.java
│ │ ├── LilypadTf2.java
│ │ ├── Liquid.java
│ │ ├── NoAction.java
│ │ ├── Pane.java
│ │ ├── PlayerSpawnCss.java
│ │ ├── PlayerSpawnTf2.java
│ │ ├── SlabBottom.java
│ │ ├── SlabTop.java
│ │ ├── SnowBlock.java
│ │ ├── Solid.java
│ │ ├── Stairs.java
│ │ ├── SupplyTf2.java
│ │ ├── TallGrassTf2.java
│ │ ├── Torch.java
│ │ ├── TorchEast.java
│ │ ├── TorchNorth.java
│ │ ├── TorchSouth.java
│ │ ├── TorchWest.java
│ │ ├── VinesEast.java
│ │ ├── VinesNorth.java
│ │ ├── VinesSouth.java
│ │ └── VinesWest.java
├── cuboidFinder
│ ├── CuboidFinder.java
│ └── DefaultCuboidFinder.java
└── mapper
│ ├── BlockMapper.java
│ ├── Mapper.java
│ ├── SourceMapper.java
│ └── SubblockMapper.java
├── gui
├── Gui.java
├── SimpleTextFieldChangeListener.java
├── WorldComboboxRenderer.java
└── panel
│ ├── DetailsPanel.java
│ ├── InputPanel.java
│ ├── LabeledCoordinates.java
│ ├── OutputPanel.java
│ ├── ResultPanel.java
│ └── SetupPanel.java
├── main
├── ConvertTask.java
├── GuiLogic.java
├── Main.java
└── TextureFolderMover.java
├── minecraft
├── Area.java
├── Block.java
├── BlockTemplate.java
├── Blocks.java
├── Material.java
├── MaterialLegacy.java
├── MinecraftMap.java
├── Position.java
├── Property.java
├── SubBlockPosition.java
├── Texture.java
└── World.java
├── nbtReader
├── BitNbtReader.java
├── ChunkPosition.java
├── ChunkReader.java
├── NamedTag.java
├── NbtReader.java
├── NbtTag.java
├── NbtTasks.java
├── PlayerInLevelReader.java
├── PlayerPositionReader.java
├── PlayerReader.java
├── RegionFile.java
├── Section.java
└── WorldPiece.java
├── periphery
├── Config.java
├── ConfigIO.java
├── ConvertOption.java
├── DirectoryFilter.java
├── Minecraft.java
├── Periphery.java
├── Place.java
├── Places.java
├── SourceGame.java
├── Steam.java
├── TextureOptions.java
└── TexturePack.java
└── vmfWriter
├── Angles.java
├── Color.java
├── Counter.java
├── Cuboid.java
├── DefaultSourceMap.java
├── EightPoint.java
├── Free8Point.java
├── Orientation.java
├── Ramp.java
├── Skin.java
├── Solid.java
├── SourceMap.java
├── ValveElement.java
├── ValveWriter.java
├── entity
├── Entity.java
├── Tf2Team.java
├── pointEntity
│ ├── NamedPointEntity.java
│ ├── PointEntity.java
│ ├── PointEntityNameException.java
│ ├── RotateablePointEntity.java
│ └── pointEntity
│ │ ├── CustomPointEntity.java
│ │ ├── EnvFire.java
│ │ ├── InfoParticleSystem.java
│ │ ├── InfoPlayerCT.java
│ │ ├── InfoPlayerStart.java
│ │ ├── InfoPlayerT.java
│ │ ├── InfoPlayerTeamSpawn.java
│ │ ├── Light.java
│ │ ├── LightEnvironment.java
│ │ ├── NamedRotateablePointEntity.java
│ │ ├── PropDynamic.java
│ │ ├── PropStatic.java
│ │ └── ShadowControl.java
└── solidEntity
│ ├── BombTarget.java
│ ├── Buyzone.java
│ ├── FuncDetail.java
│ ├── FuncIllusionary.java
│ ├── FuncRegenerate.java
│ └── SolidEntity.java
└── texture
├── ValveTexture.java
└── VmtGenerator.java
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # This workflow will build a Java project with Maven
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
3 |
4 | name: Java CI with Maven
5 |
6 | on:
7 | push:
8 | branches: [ master ]
9 | pull_request:
10 | branches: [ master ]
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2
19 | - name: Set up JDK 1.8
20 | uses: actions/setup-java@v1
21 | with:
22 | java-version: 1.8
23 | - name: Build with Maven
24 | run: mvn -B package --file pom.xml
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
25 | target/*
26 | textures/*
27 | *.json
28 | .metadata
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | sourcecraft
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.jdt.core.javanature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | encoding//src/minecraft/MaterialLegacy.java=UTF-8
3 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | activeProfiles=
2 | eclipse.preferences.version=1
3 | resolveWorkspaceProjects=true
4 | version=1
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # sourcecraft
2 |
3 | an easy to use Minecraft to Source Engine Converter. It converts a given piece of Minecraft World into a map in .vmf-format that can be opened by Hammer Editor. It still needs to be compiled by Hammer Editor (/the Source-Engine compile tools). Aim of this project though is that no further steps or Hammer-Editor editing skills are needed. That is sourcecraft createas a (after compiling) a runnable and playable map with spawn-points and so on.
4 |
5 | ### what is needed
6 | - Minecraft world of version 1.13 or newer (tested with 1.15) either created in singleplayer or by a Minecraft server.
7 | - Java Runtime Enviroment 1.8 or newer
8 | - Recommended: Steam with installed target Source-Engine game and installed 'Source SDK'. The latter includes the Hammer Editor and the compile tools. You should have launched your target game and 'Source SDK' for your target game at least once. Then sourcecraft suggets to create the output-map at the correct path for the Hammer Editor. It can also copy the required textures to the correct path.
9 |
10 | ### textures
11 | Sourcecraft creates the map with texture names equal to that used in minecraft. Suitable minecraft-like textures are not included here, but can be found online. If you put them into the "texture/" folder, sourcecraft makes sure that a copy is at the correct directory needed for the Hammer Editor (unlesss you wish otherwise).
12 |
13 | ### hammer editor
14 | You can launch Hammer Editor directly from sourcecraft (alternatively you may launch it via Steam). Open the coverted .vmf-file via 'File->Open'. You may further edit your map here. By pressing F9 you open the compile dialog. For a first test, you should select for "Run VIS" the option "Fast". It is also better to check not to launch the game after compiling. Instead launch your target game manually with launch option "-console". Ingame you can open your map with the console command "map my-map-name".
15 |
16 |
17 | ### manual setup:
18 | ```
19 | git clone git@github.com:Garten/sourcecraft.git
20 | cd sourcecraft
21 | mvn install
22 | cd target
23 | java -jar sourcecraft-x.y.jar
24 | ```
25 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
4 | 4.0.0
5 | sourcecraft
6 | sourcecraft
7 | 3.2
8 | jar
9 |
10 | src
11 |
12 |
13 | maven-compiler-plugin
14 | 3.8.0
15 |
16 | 1.8
17 | 1.8
18 |
19 |
20 |
21 | org.apache.maven.plugins
22 | maven-dependency-plugin
23 |
24 |
25 | copy-dependencies
26 | prepare-package
27 |
28 | copy-dependencies
29 |
30 |
31 |
32 | ${project.build.directory}/libs
33 |
34 |
35 |
36 |
37 |
38 |
39 | org.apache.maven.plugins
40 | maven-jar-plugin
41 | 3.2.0
42 |
43 |
44 |
45 | true
46 | libs/
47 |
48 | main.Main
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | com.google.code.gson
59 | gson
60 | 2.8.6
61 |
62 |
63 | com.google.guava
64 | guava
65 | 29.0-jre
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/src/basic/IOConsumer.java:
--------------------------------------------------------------------------------
1 | package basic;
2 |
3 | import java.io.IOException;
4 |
5 | public interface IOConsumer {
6 |
7 | public static final IOConsumer INSTANCE = argument -> {
8 | // do nothing
9 | };
10 |
11 | public abstract void run(Argument argument) throws IOException;
12 | }
13 |
--------------------------------------------------------------------------------
/src/basic/IORunnable.java:
--------------------------------------------------------------------------------
1 | package basic;
2 |
3 | import java.io.IOException;
4 |
5 | public interface IORunnable {
6 |
7 | public abstract void run() throws IOException;
8 | }
9 |
--------------------------------------------------------------------------------
/src/basic/Loggger.java:
--------------------------------------------------------------------------------
1 | package basic;
2 |
3 | public class Loggger {
4 |
5 | private static final int TAB_SIZE = 8;
6 | private static final int DEFAULT_INDENT = 1 * TAB_SIZE;
7 | private static int minimalIndent = DEFAULT_INDENT;
8 |
9 | public static void debug(String message) {
10 | print(message, 0);
11 | }
12 |
13 | public static void log(String message) {
14 | print(message, 0);
15 | }
16 |
17 | public static void logg(String message) {
18 | print(message, 1);
19 | }
20 |
21 | public static void log(String message, int callDepth) {
22 |
23 | }
24 |
25 | public static void warn(String message) {
26 | print(message, 0);
27 | }
28 |
29 | public static void error(String message) {
30 | print(message, 0);
31 | }
32 |
33 | public static void maybeLog(String message) {
34 | if (Math.random() < 0.1f) {
35 | print(message, 0);
36 | }
37 | }
38 |
39 | public static void print(String mesasge, int callDepth) {
40 | StringBuilder stringBuilder = new StringBuilder();
41 | addCallLocation(stringBuilder, callDepth);
42 | adjustMinimalIndent(stringBuilder);
43 | addTabs(stringBuilder);
44 | stringBuilder.append(mesasge);
45 | System.out.println(stringBuilder.toString());
46 | }
47 |
48 | private static final int EXPECTED_STACK_DEPTH = 4;
49 |
50 | private static void addCallLocation(StringBuilder stringBuilder, int additonalCallDepth) {
51 | int callDepth = EXPECTED_STACK_DEPTH + additonalCallDepth;
52 | StackTraceElement[] elements = Thread.currentThread()
53 | .getStackTrace();
54 | if (elements.length >= callDepth) {
55 | StackTraceElement element = elements[callDepth];
56 | String text = "(" + element.getFileName() + ":" + element.getLineNumber() + ")";
57 | stringBuilder.append(text);
58 | }
59 | }
60 |
61 | private static void adjustMinimalIndent(StringBuilder stringBuilder) {
62 | while (minimalIndent < stringBuilder.length() + 1) {
63 | minimalIndent += TAB_SIZE;
64 | }
65 | }
66 |
67 | private static void addTabs(StringBuilder stringBuilder) {
68 | int blankLength = minimalIndent - stringBuilder.length();
69 | while (blankLength > 0) {
70 | blankLength -= TAB_SIZE;
71 | stringBuilder.append("\t");
72 | }
73 | }
74 |
75 | public static void breakk() {
76 | Loggger.log("broken");
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/basic/NameSupplier.java:
--------------------------------------------------------------------------------
1 | package basic;
2 |
3 | public interface NameSupplier {
4 |
5 | public abstract String name();
6 |
7 | default String getName() {
8 | String name = this.name();
9 | if (name.endsWith("$")) {
10 | return name.substring(0, name.length() - 1);
11 | }
12 | return name;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/basic/RunnableWith.java:
--------------------------------------------------------------------------------
1 | //package basic;
2 | //
3 | //import periphery.Place;
4 | //
5 | //public interface RunnableWith {
6 | //
7 | // public static final RunnableWith INSTANCE = argument -> {
8 | // // do nothing
9 | // };
10 | //
11 | // public static final RunnableWith INSTANCE_PLACE = argument -> {
12 | // // do nothing
13 | // };
14 | //
15 | // public abstract void run(Argument argument);
16 | //}
17 |
--------------------------------------------------------------------------------
/src/basic/Tuple.java:
--------------------------------------------------------------------------------
1 | package basic;
2 |
3 | public class Tuple {
4 |
5 | private A first;
6 | private B second;
7 |
8 | public Tuple(A first, B second) {
9 | this.first = first;
10 | this.second = second;
11 | }
12 |
13 | public A getFirst() {
14 | return this.first;
15 | }
16 |
17 | public B getSecond() {
18 | return this.second;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/basic/Validator.java:
--------------------------------------------------------------------------------
1 | package basic;
2 |
3 | import periphery.Place;
4 |
5 | public interface Validator {
6 |
7 | public static final Validator PLACE_ACCEPTOR = argument -> true;
8 |
9 | public abstract boolean run(Argument argument);
10 | }
11 |
--------------------------------------------------------------------------------
/src/basic/Value.java:
--------------------------------------------------------------------------------
1 | package basic;
2 |
3 | public class Value {
4 |
5 | private T value;
6 |
7 | public Value set(T value) {
8 | this.value = value;
9 | return this;
10 | }
11 |
12 | public T get() {
13 | return this.value;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/converter/ConvertingReport.java:
--------------------------------------------------------------------------------
1 | package converter;
2 |
3 | public class ConvertingReport {
4 |
5 | private int brushCount;
6 |
7 | public ConvertingReport() {
8 |
9 | }
10 |
11 | public int getBrushCount() {
12 | return this.brushCount;
13 | }
14 |
15 | public void setBrushCount(int brushCount) {
16 | this.brushCount = brushCount;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/converter/actions/Action.java:
--------------------------------------------------------------------------------
1 | package converter.actions;
2 |
3 | import java.util.LinkedList;
4 | import java.util.List;
5 |
6 | import basic.Loggger;
7 | import converter.mapper.Mapper;
8 | import minecraft.Block;
9 | import minecraft.Position;
10 | import vmfWriter.Orientation;
11 | import vmfWriter.entity.pointEntity.RotateablePointEntity;
12 |
13 | public abstract class Action {
14 |
15 | protected int[] materialUsedFor = {};
16 |
17 | public Action() {
18 | }
19 |
20 | public Iterable getInstances() {
21 | List list = new LinkedList<>();
22 | try {
23 | Action a = (Action) this.getClass()
24 | .getConstructors()[0].newInstance();
25 | list.add(a);
26 | } catch (Exception ex) {
27 | Loggger.warn("Addable " + this.getClass()
28 | .getSimpleName() + " does not have a suitable constructor (InvocationTargetException)");
29 | }
30 | return list;
31 | }
32 |
33 | public String getName() {
34 | return this.getClass()
35 | .getSimpleName();
36 | }
37 |
38 | /**
39 | * Returns whether the added blocks are air.
40 | */
41 | public boolean isAirBlock() {
42 | return true;
43 | }
44 |
45 | public boolean hasWall(Orientation orientation) {
46 | return false;
47 | }
48 |
49 | @Deprecated
50 | public void setMaterialUsedFor(int[] material) {
51 | this.materialUsedFor = material;
52 | }
53 |
54 | public void setMaterialUsedFor(int material) {
55 | this.materialUsedFor = new int[1];
56 | this.materialUsedFor[0] = material;
57 | }
58 |
59 | /**
60 | * For a given position with given material, this method adds solids and
61 | * entities to the resulting Source map.
62 | *
63 | */
64 | public void add(Mapper context, Position position, Block material) {
65 |
66 | }
67 |
68 | protected void addDebugMarker(Mapper context, Position position, Block material) {
69 | context.setPointToGrid(position);
70 | context.movePointInGridDimension(0.5, 0, 0.5);
71 | int verticalAngle = (int) (Math.random() * 360);
72 | context.addPointEntity(new RotateablePointEntity().setName(material.getName() + " at " + position.toString())
73 | .setRotation(verticalAngle));
74 | context.markAsConverted(position);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/converter/actions/ActionManager.java:
--------------------------------------------------------------------------------
1 | package converter.actions;
2 |
3 | import basic.Tuple;
4 | import converter.actions.actions.NoAction;
5 | import converter.mapper.Mapper;
6 | import minecraft.Block;
7 | import minecraft.Position;
8 |
9 | public class ActionManager {
10 |
11 | protected BlockMap actions;
12 |
13 | public ActionManager(Action fallBack) {
14 | this.actions = new BlockMap().setDefault(fallBack);
15 | }
16 |
17 | public ActionManager setAction(Block block, Action addable) {
18 | this.actions.put(block, addable);
19 | return this;
20 | }
21 |
22 | public ActionManager setActions(Iterable> actions) {
23 | actions.forEach(a -> this.setAction(a.getFirst(), a.getSecond()));
24 | return this;
25 | }
26 |
27 | public Action getAction(Block block) {
28 | return this.actions.getFallBackToSuffix(block);
29 | }
30 |
31 | public void add(Mapper context, Position position, Block block) {
32 | Action action;
33 | if (block == null) {
34 | action = NoAction.INSTANCE;
35 | } else {
36 | action = this.getAction(block);
37 | }
38 | action.add(context, position, block);
39 | }
40 |
41 | public void print() {
42 | actions.print();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/converter/actions/BlockMap.java:
--------------------------------------------------------------------------------
1 | package converter.actions;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 | import java.util.function.Supplier;
6 |
7 | import basic.Loggger;
8 | import minecraft.Block;
9 | import minecraft.BlockTemplate;
10 |
11 | public class BlockMap {
12 |
13 | private static final String SEPERATOR = "_";
14 |
15 | private Value fallback;
16 | private Map map;
17 |
18 | private BlockTemplate newKey = new BlockTemplate();
19 | private BlockTemplate newSimpleKey = new BlockTemplate();
20 |
21 | public BlockMap() {
22 | this.map = new HashMap<>();
23 | }
24 |
25 | public BlockMap put(Supplier keyHolder, Value value) { // TODO
26 | this.map.put(keyHolder.get(), value);
27 | return this;
28 | }
29 |
30 | public Value getFallBackToPrefix(Block key) {
31 | this.newKey.copyFrom(key);
32 | Value result = this.getFallBackNoProperties(key);
33 | if (result != null) {
34 | return result;
35 | }
36 | String title = key.getName();
37 | while (true) {
38 | int i = title.lastIndexOf(SEPERATOR);
39 | if (i < 1) {
40 | break;
41 | }
42 | if (title.contains("ramp")) {
43 | Loggger.log("break");
44 | }
45 | title = title.substring(0, i);
46 | this.newKey.setName(title);
47 | result = this.getFallBackNoProperties(this.newKey);
48 | if (result != null) {
49 | this.put(key, result);
50 | return result;
51 | }
52 | }
53 | return this.fallback;
54 | }
55 |
56 | public Value getFallBackToSuffix(Block key) {
57 | Value result = this.getFallBackNoProperties(key);
58 | if (result != null) {
59 | return result;
60 | }
61 | String title = key.getName();
62 | int colonPos = title.indexOf(":");
63 | String nameSpace = title.substring(0, colonPos);
64 | while (true) {
65 | int i = title.indexOf(SEPERATOR);
66 | if (i < 1) {
67 | break;
68 | }
69 | title = title.substring(i + 1);
70 | this.newKey.setName(nameSpace + ":" + title);
71 | result = this.getFallBackNoProperties(this.newKey);
72 | if (result != null) {
73 | this.put(key, result);
74 | return result;
75 | }
76 | }
77 | return this.fallback;
78 | }
79 |
80 | private Value getFallBackNoProperties(Block key) {
81 | Value value = this.map.get(key);
82 | if (value != null) {
83 | return value;
84 | }
85 | // test without properties
86 | this.newSimpleKey.setName(key.getName());
87 | this.newSimpleKey.setProperties(null);
88 | value = this.map.get(this.newSimpleKey);
89 | if (value != null) {
90 | this.put(key, value);
91 | return value;
92 | }
93 | return null;
94 | }
95 |
96 | public Value get(Block key) {
97 | assert this.fallback != null;
98 | Value value = this.map.get(key);
99 | if (value == null) {
100 | return this.fallback;
101 | }
102 | return value;
103 | }
104 |
105 | public BlockMap setDefault(Value fallback) {
106 | this.fallback = fallback;
107 | return this;
108 | }
109 |
110 | public void print() {
111 | this.map.forEach((key, value) -> Loggger.log(key.toString() + " mapsTo " + value.toString()));
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/src/converter/actions/ConvertEntity.java:
--------------------------------------------------------------------------------
1 | package converter.actions;
2 |
3 | import java.util.function.Supplier;
4 |
5 | import converter.actions.actions.NoAction;
6 | import minecraft.Block;
7 |
8 | public class ConvertEntity {
9 | private Supplier block;
10 | private Action action = NoAction.INSTANCE;
11 |
12 | public ConvertEntity(Supplier block, Action action) {
13 | this.block = block;
14 | this.action = action;
15 | }
16 |
17 | public Supplier getBlock() {
18 | return this.block;
19 | }
20 |
21 | public ConvertEntity setBlock(Supplier block) {
22 | this.block = block;
23 | return this;
24 | }
25 |
26 | public Action getAction() {
27 | return this.action;
28 | }
29 |
30 | public ConvertEntity setAction(Action action) {
31 | this.action = action;
32 | return this;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/converter/actions/CustomActionManager.java:
--------------------------------------------------------------------------------
1 | package converter.actions;
2 |
3 | import java.util.Collection;
4 |
5 | import converter.actions.actions.Cactus;
6 | import converter.actions.actions.CenteredPointEntity;
7 | import converter.actions.actions.DetailBlock;
8 | import converter.actions.actions.Fence;
9 | import converter.actions.actions.Fire;
10 | import converter.actions.actions.Liquid;
11 | import converter.actions.actions.NoAction;
12 | import converter.actions.actions.PlayerSpawnCss;
13 | import converter.actions.actions.SlabBottom;
14 | import converter.actions.actions.SlabTop;
15 | import converter.actions.actions.Solid;
16 | import converter.actions.actions.Stairs;
17 | import converter.actions.actions.TallGrassTf2;
18 | import converter.actions.actions.Torch;
19 | import converter.mapper.Mapper;
20 | import minecraft.Blocks;
21 | import minecraft.Material;
22 | import minecraft.Property;
23 | import vmfWriter.entity.pointEntity.pointEntity.InfoPlayerCT;
24 | import vmfWriter.entity.pointEntity.pointEntity.InfoPlayerT;
25 |
26 | public class CustomActionManager extends ActionManager {
27 |
28 | public CustomActionManager(Mapper map, Collection converters) {
29 | super(Solid.INSTANCE);
30 | }
31 |
32 | public CustomActionManager setDefaults() {
33 | this.actions.put(Blocks._UNSET, NoAction.INSTANCE);
34 | this.actions.put(Material.air, NoAction.INSTANCE);
35 | this.actions.put(Material.cave_air, NoAction.INSTANCE);
36 | this.actions.put(Material.void_air, NoAction.INSTANCE);
37 |
38 | for (Material m : new Material[] { Material.fern, Material.grass, Material.dandelion, Material.poppy,
39 | Material.brown_mushroom, Material.red_mushroom, Material.redstone_dust, Material.wheat,
40 | Material.oak_door, Material.ladder, Material.rail, Material.oak_wall_sign, Material.lever,
41 | Material.stone_pressure_plate, Material.iron_door, Material.oak_pressure_plate, Material.sugar_cane,
42 | Material.sunflower, Material.cobweb, Material.detector_rail, Material.detector_rail, Material.fire,
43 | Material.redstone_wall_torch, Material.redstone_torch, Material.stone_button, Material.tall_grass,
44 | Material.tall_grass, Material.large_fern, Material.blue_orchid, Material.allium, Material.azure_bluet,
45 | Material.red_tulip, Material.orange_tulip, Material.white_tulip, Material.pink_tulip,
46 | Material.oxeye_daisy, Material.cornflower, Material.lily_of_the_valley, Material.wither_rose,
47 | Material.lilac, Material.rose_bush, Material.peony, Material.sugar_cane, Material.seagrass,
48 | Material.tall_seagrass, Material.sweet_berry_bush }) {
49 | this.actions.put(m, NoAction.INSTANCE);
50 | }
51 | for (Material m : new Material[] { Material._leaves, Material.glass, Material.ice }) {
52 | this.actions.put(m, new DetailBlock());
53 | }
54 | for (Material m : new Material[] { Material.water, Material.lava, Material.seagrass, Material.tall_seagrass,
55 | Material.kelp, Material.kelp_plant }) {
56 | this.actions.put(m, new Liquid());
57 | }
58 | this.actions.put(Material._fence, new Fence());
59 | this.actions.put(Material._stairs, new Stairs());
60 | this.actions.put(Blocks.get(t -> t.setName(Material._slab)
61 | .addProperty(Property.half, Property.Half.top)
62 | .addProperty(Property.waterlogged, Property.Waterlogged.false$)), new SlabTop());
63 | this.actions.put(Blocks.get(t -> t.setName(Material._slab)
64 | .addProperty(Property.half, Property.Half.bottom)
65 | .addProperty(Property.waterlogged, Property.Waterlogged.false$)), new SlabBottom());
66 | this.actions.put(Material.torch, Torch.INSTANCE);
67 | this.actions.put(Material.wall_torch, Torch.INSTANCE);
68 | this.actions.put(Material.cactus, new Cactus());
69 | this.actions.put(Material.fire, new Fire());
70 |
71 | // tf2
72 | this.actions.put(Material.grass, new TallGrassTf2());
73 |
74 | // ttt
75 | this.actions.put(Material.zombie_head, new CenteredPointEntity("info_player_start"));
76 | this.actions.put(Material.fletching_table, new CenteredPointEntity("ttt_random_weapon"));
77 | this.actions.put(Material.grindstone, new CenteredPointEntity("ttt_random_ammo"));
78 |
79 | // css
80 | // this.actions.put(Material.torch, new CssLamp());
81 | // this.actions.put(Material.wall_torch, new CssLamp());
82 | this.actions.put(Material.end_portal_frame, new PlayerSpawnCss(new InfoPlayerT().setRotation(0), false));
83 | this.actions.put(Material.ender_chest, new PlayerSpawnCss(new InfoPlayerCT().setRotation(180), true));
84 | return this;
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/Cactus.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 |
8 | public class Cactus extends Action {
9 |
10 | @Override
11 | public void add(Mapper context, Position position, Block block) {
12 | Position end = context.getCuboidFinder()
13 | .getBestY(position, block);
14 | int parts = 8;
15 | Position offset = new Position(1, 0, 1);
16 | Position negativeOffset = new Position(1, 1, 1);
17 | context.addDetail(context.createCuboid(position, end, parts, offset, negativeOffset, block));
18 | context.markAsConverted(position, end);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/CenteredPointEntity.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 | import vmfWriter.entity.pointEntity.RotateablePointEntity;
8 |
9 | public class CenteredPointEntity extends Action {
10 |
11 | private RotateablePointEntity entity;
12 | private float yOffset = 0;
13 |
14 | public CenteredPointEntity() {
15 |
16 | }
17 |
18 | public CenteredPointEntity(String name) {
19 | this.setEntity(new RotateablePointEntity().setName(name));
20 | }
21 |
22 | public CenteredPointEntity setYOffset(float yOffset) {
23 | this.yOffset = yOffset;
24 | return this;
25 | }
26 |
27 | @Override
28 | public void add(Mapper context, Position position, Block material) {
29 | context.setPointToGrid(position);
30 | context.movePointInGridDimension(0.5, yOffset, 0.5);
31 | int verticalAngle = (int) (Math.random() * 360);
32 | context.addPointEntity(this.getEntity()
33 | .setRotation(verticalAngle));
34 | context.markAsConverted(position);
35 | }
36 |
37 | public CenteredPointEntity setEntity(RotateablePointEntity entity) {
38 | this.entity = entity;
39 | return this;
40 | }
41 |
42 | protected RotateablePointEntity getEntity() {
43 | return this.entity;
44 | }
45 |
46 | @Override
47 | public boolean isAirBlock() {
48 | return true;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/CssLamp.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Blocks;
7 | import minecraft.Material;
8 | import minecraft.Position;
9 | import minecraft.Property;
10 | import vmfWriter.Angles;
11 | import vmfWriter.Color;
12 | import vmfWriter.entity.pointEntity.pointEntity.Light;
13 | import vmfWriter.entity.pointEntity.pointEntity.PropStatic;
14 |
15 | /**
16 | * Add torch props and light entities
17 | *
18 | */
19 | public class CssLamp extends Action {
20 |
21 | private final static String TORCH_MODEL = "models/props/cs_italy/it_lantern1.mdl";
22 | private final static String TORCH_HOLDER_MODEL = "models/props/cs_italy/it_lampholder1.mdl";
23 |
24 | private final static int red = 255;
25 | private final static int green = 255;
26 | private final static int blue = 150;
27 | private final static int brigthness = 10;
28 | private final static int distance50 = 96;
29 | private final static int distance100 = 256;
30 | private final static Color LIGHT_COLOR = new Color(CssLamp.red, CssLamp.green, CssLamp.blue, CssLamp.brigthness);
31 | private final static Light LIGHT = new Light(CssLamp.LIGHT_COLOR, CssLamp.distance50, CssLamp.distance100);
32 | private final static PropStatic TORCH = new PropStatic(CssLamp.TORCH_MODEL);
33 | private final static PropStatic TORCH_HOLDER_EAST = new PropStatic(CssLamp.TORCH_HOLDER_MODEL, new Angles(0, 0, 0));
34 | private final static PropStatic TORCH_HOLDER_WEST = new PropStatic(CssLamp.TORCH_HOLDER_MODEL,
35 | new Angles(0, 180, 0));
36 | private final static PropStatic TORCH_HOLDER_SOUTH = new PropStatic(CssLamp.TORCH_HOLDER_MODEL,
37 | new Angles(0, 270, 0));
38 | private final static PropStatic TORCH_HOLDER_NORTH = new PropStatic(CssLamp.TORCH_HOLDER_MODEL,
39 | new Angles(0, 90, 0));
40 |
41 | @Override
42 | public void add(Mapper context, Position p, Block block) {
43 | int d = 0;
44 | // x=EAST
45 | // z=SOUTH
46 | context.setPointToGrid(p);
47 |
48 | if (block.equals(Material.torch.get())) { // on ground
49 | context.movePointInGridDimension(0.5, 0, 0.5);
50 | context.movePointExactly(new Position(0, 10, 0));
51 | } else if (block.equals(Blocks.get(t -> t.setName(Material.wall_torch)
52 | .addProperty(Property.facing, Property.Facing.east)))) { // pointing east
53 | // block == 341
54 | context.movePointInGridDimension(0, 0, 0.5);
55 | context.movePointExactly(new Position(0, -6, 0));
56 | context.addPointEntity(CssLamp.TORCH_HOLDER_EAST);
57 | context.movePointExactly(new Position(8, 22, 0));
58 | d = 1;
59 | } else if (block.equals(Blocks.get(t -> t.setName(Material.wall_torch)
60 | .addProperty(Property.facing, Property.Facing.west)))) { // pointing west
61 | context.movePointInGridDimension(1, 0, 0.5);
62 | context.movePointExactly(new Position(0, -6, 0));
63 | context.addPointEntity(CssLamp.TORCH_HOLDER_WEST);
64 | context.movePointExactly(new Position(0 - 8, 22, 0));
65 | d = 2;
66 | } else if (block.equals(Blocks.get(t -> t.setName(Material.wall_torch)
67 | .addProperty(Property.facing, Property.Facing.south)))) { // pointing south // !
68 | context.movePointInGridDimension(0.5, 0, 0);
69 | context.movePointExactly(new Position(0, -6, 0));
70 | context.addPointEntity(CssLamp.TORCH_HOLDER_SOUTH);
71 | context.movePointExactly(new Position(0, 22, 8));
72 | d = 4;
73 | } else if (block.equals(Blocks.get(t -> t.setName(Material.wall_torch)
74 | .addProperty(Property.facing, Property.Facing.north)))) { // pointing north
75 | context.movePointInGridDimension(0.5, 0, 1);
76 | context.movePointExactly(new Position(0, -6, 0));
77 | context.addPointEntity(CssLamp.TORCH_HOLDER_NORTH);
78 | context.movePointExactly(new Position(0, 22, -8));
79 | d = 3;
80 |
81 | }
82 | context.addPointEntity(CssLamp.TORCH);
83 |
84 | context.movePointExactly(new Position(10, 0, 0));
85 | if (d != 2) {
86 | context.addPointEntity(CssLamp.LIGHT);
87 | }
88 | context.movePointExactly(new Position(-20, 0, 0));
89 | if (d != 1) {
90 | context.addPointEntity(CssLamp.LIGHT);
91 | }
92 | context.movePointExactly(new Position(10, 0, 0));
93 | context.movePointExactly(new Position(0, 0, 10));
94 | if (d != 3) {
95 | context.addPointEntity(CssLamp.LIGHT);
96 | }
97 | context.movePointExactly(new Position(0, 0, -20));
98 | if (d != 4) {
99 | context.addPointEntity(CssLamp.LIGHT);
100 | }
101 | context.markAsConverted(p);
102 | }
103 |
104 | }
105 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/Debug.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 |
8 | public class Debug extends Action {
9 |
10 | @Override
11 | public void add(Mapper context, Position position, Block block) {
12 | this.addDebugMarker(context, position, block);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/DetailBlock.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 | import vmfWriter.entity.solidEntity.FuncDetail;
8 |
9 | /**
10 | * creates a "func_detail"-Block
11 | */
12 | public class DetailBlock extends Action {
13 |
14 | @Override
15 | public void add(Mapper context, Position p, Block material) {
16 | Position end = context.getCuboidFinder()
17 | .getBestXYZ(p, material);
18 | context.addSolidEntity(new FuncDetail(context.createCuboid(p, end, material)));
19 | context.markAsConverted(p, end);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/EndPortalFrame.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 |
8 | /**
9 | *
10 | *
11 | */
12 | public class EndPortalFrame extends Action {
13 |
14 | public EndPortalFrame() {
15 | // TODO
16 | }
17 |
18 | @Override
19 | public void add(Mapper context, Position p, Block material) {
20 | Position end = context.getCuboidFinder()
21 | .getBestXZ(p, material);
22 | int parts = 4;
23 | Position offset = new Position(0, 0, 0);
24 | Position negativeOffset = new Position(0, 1, 0);
25 | context.addDetail(context.createCuboid(p, end, parts, offset, negativeOffset, material));
26 | context.markAsConverted(p, end);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/Fence.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import java.util.function.Predicate;
4 |
5 | import converter.actions.Action;
6 | import converter.actions.ActionManager;
7 | import converter.mapper.Mapper;
8 | import minecraft.Block;
9 | import minecraft.Position;
10 | import vmfWriter.Orientation;
11 |
12 | public class Fence extends Action {
13 |
14 | private static int BEAM_SIDE = 7;
15 | private static int BEAM_TOP_OFF = 1;
16 | private static int BEAM_TOP_ON = 12;
17 | private static int BEAM_MID_OFF = 8;
18 | private static int BEAM_MID_ON = 5;
19 |
20 | @Override
21 | public boolean hasWall(Orientation orientation) {
22 | return true;
23 | }
24 |
25 | @Override
26 | public void add(Mapper context, Position p, Block material) {
27 | Position end = context.getCuboidFinder()
28 | .getBestY(p, material);
29 | // pole
30 | int parts = 8;
31 | Position offset = new Position(3, 0, 3);
32 | Position negativeOffset = new Position(3, 0, 3);
33 | context.addDetail(context.createCuboid(p, end, parts, offset, negativeOffset, material));
34 | context.markAsConverted(p, end);
35 | // add beams
36 | parts = 16;
37 | while (p.getY() <= end.getY()) {
38 | if (context.hasBlock(p.getOffset(1, 0, 0), material)) {
39 | offset = new Position(10, Fence.BEAM_TOP_ON, Fence.BEAM_SIDE);
40 | negativeOffset = new Position(10, Fence.BEAM_TOP_OFF, Fence.BEAM_SIDE);
41 | context.addDetail(
42 | context.createCuboid(p, p.getOffset(1, 0, 0), parts, offset, negativeOffset, material));
43 | offset = new Position(10, Fence.BEAM_MID_ON, Fence.BEAM_SIDE);
44 | negativeOffset = new Position(10, Fence.BEAM_MID_OFF, Fence.BEAM_SIDE);
45 | context.addDetail(
46 | context.createCuboid(p, p.getOffset(1, 0, 0), parts, offset, negativeOffset, material));
47 | } else if (context.hasBlock(p.getOffset(1, 0, 0),
48 | new MaterialWallFilter(context.getActions(), Orientation.EAST))) {
49 | offset = new Position(10, Fence.BEAM_TOP_ON, Fence.BEAM_SIDE);
50 | negativeOffset = new Position(parts, Fence.BEAM_TOP_OFF, Fence.BEAM_SIDE);
51 | context.addDetail(
52 | context.createCuboid(p, p.getOffset(1, 0, 0), parts, offset, negativeOffset, material));
53 | offset = new Position(10, Fence.BEAM_MID_ON, Fence.BEAM_SIDE);
54 | negativeOffset = new Position(parts, Fence.BEAM_MID_OFF, Fence.BEAM_SIDE);
55 | context.addDetail(
56 | context.createCuboid(p, p.getOffset(1, 0, 0), parts, offset, negativeOffset, material));
57 | }
58 |
59 | if (context.hasBlock(p.getOffset(-1, 0, 0),
60 | new MaterialWallFilter(context.getActions(), Orientation.WEST))) {
61 | offset = new Position(parts, Fence.BEAM_TOP_ON, Fence.BEAM_SIDE);
62 | negativeOffset = new Position(10, Fence.BEAM_TOP_OFF, Fence.BEAM_SIDE);
63 | context.addDetail(
64 | context.createCuboid(p.getOffset(-1, 0, 0), p, parts, offset, negativeOffset, material));
65 | offset = new Position(parts, Fence.BEAM_MID_ON, Fence.BEAM_SIDE);
66 | negativeOffset = new Position(10, Fence.BEAM_MID_OFF, Fence.BEAM_SIDE);
67 | context.addDetail(
68 | context.createCuboid(p.getOffset(-1, 0, 0), p, parts, offset, negativeOffset, material));
69 | }
70 |
71 | if (context.hasBlock(p.getOffset(0, 0, 1), material)) {
72 | offset = new Position(Fence.BEAM_SIDE, Fence.BEAM_TOP_ON, 10);
73 | negativeOffset = new Position(Fence.BEAM_SIDE, Fence.BEAM_TOP_OFF, 10);
74 | context.addDetail(
75 | context.createCuboid(p, p.getOffset(0, 0, 1), parts, offset, negativeOffset, material));
76 | offset = new Position(Fence.BEAM_SIDE, Fence.BEAM_MID_ON, 10);
77 | negativeOffset = new Position(Fence.BEAM_SIDE, Fence.BEAM_MID_OFF, 10);
78 | context.addDetail(
79 | context.createCuboid(p, p.getOffset(0, 0, 1), parts, offset, negativeOffset, material));
80 | } else if (context.hasBlock(p.getOffset(0, 0, 1),
81 | new MaterialWallFilter(context.getActions(), Orientation.SOUTH))) {
82 | offset = new Position(Fence.BEAM_SIDE, Fence.BEAM_TOP_ON, 10);
83 | negativeOffset = new Position(Fence.BEAM_SIDE, Fence.BEAM_TOP_OFF, parts);
84 | context.addDetail(
85 | context.createCuboid(p, p.getOffset(0, 0, 1), parts, offset, negativeOffset, material));
86 | offset = new Position(Fence.BEAM_SIDE, Fence.BEAM_MID_ON, 10);
87 | negativeOffset = new Position(Fence.BEAM_SIDE, Fence.BEAM_MID_OFF, parts);
88 | context.addDetail(
89 | context.createCuboid(p, p.getOffset(0, 0, 1), parts, offset, negativeOffset, material));
90 | }
91 |
92 | if (context.hasBlock(p.getOffset(0, 0, -1),
93 | new MaterialWallFilter(context.getActions(), Orientation.NORTH))) {
94 | offset = new Position(Fence.BEAM_SIDE, Fence.BEAM_TOP_ON, parts);
95 | negativeOffset = new Position(Fence.BEAM_SIDE, Fence.BEAM_TOP_OFF, 10);
96 | context.addDetail(
97 | context.createCuboid(p.getOffset(0, 0, -1), p, parts, offset, negativeOffset, material));
98 | offset = new Position(Fence.BEAM_SIDE, Fence.BEAM_MID_ON, parts);
99 | negativeOffset = new Position(Fence.BEAM_SIDE, Fence.BEAM_MID_OFF, 10);
100 | context.addDetail(
101 | context.createCuboid(p.getOffset(0, 0, -1), p, parts, offset, negativeOffset, material));
102 | }
103 |
104 | p.move(0, 1, 0);
105 | // Block.getMaterialUsedForStatic()
106 | }
107 | }
108 |
109 | private class MaterialWallFilter implements Predicate {
110 |
111 | private ActionManager manager;
112 | private Orientation orientation;
113 |
114 | public MaterialWallFilter(ActionManager manager, Orientation orientation) {
115 | this.manager = manager;
116 | this.orientation = orientation;
117 | }
118 |
119 | @Override
120 | public boolean test(Block material) {
121 | Action addable = this.manager.getAction(material);
122 | if (addable != null) {
123 | return this.manager.getAction(material)
124 | .hasWall(this.orientation);
125 | } else {
126 | return false;
127 | }
128 | }
129 | }
130 | }
131 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/Fire.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 | import vmfWriter.Color;
8 | import vmfWriter.entity.pointEntity.pointEntity.EnvFire;
9 | import vmfWriter.entity.pointEntity.pointEntity.Light;
10 |
11 | public class Fire extends Action {
12 |
13 | private final static int red = 255;
14 | private final static int green = 113;
15 | private final static int blue = 28;
16 | private final static int brigthness = 100;
17 | private final static int distance50 = 96;
18 | private final static int distance100 = 256;
19 | private final static Color FIRE_COLOR = new Color(Fire.red, Fire.green, Fire.blue, Fire.brigthness);
20 | private static Light LIGHT = new Light(Fire.FIRE_COLOR, Fire.distance50, Fire.distance100);
21 | private static EnvFire ENV_FIRE;
22 |
23 | @Override
24 | public void add(Mapper context, Position position, Block material) {
25 | Fire.ENV_FIRE.setFireSize(context.getScale());
26 | context.setPointToGrid(position);
27 | context.movePointInGridDimension(0.5, 0, 0.5);
28 | context.movePointExactly(new Position(0, 1, 0));
29 | context.movePointInGridDimension(this.randomOffset(0.5), 0, this.randomOffset(0.5));
30 | context.addPointEntity(Fire.ENV_FIRE);
31 | context.movePointInGridDimension(0, 0.5, 0);
32 | context.movePointExactly(new Position(0, -1, 0));
33 | context.addPointEntity(Fire.LIGHT);
34 | context.markAsConverted(position);
35 | }
36 |
37 | private double randomOffset(double scale) {
38 | return scale;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/LilypadTf2.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.MaterialLegacy;
7 | import minecraft.Position;
8 | import vmfWriter.entity.pointEntity.pointEntity.PropStatic;
9 |
10 | /**
11 | *
12 | *
13 | */
14 | public class LilypadTf2 extends Action {
15 |
16 | private final static String MODEL = "models/props_swamp/lilypad_large.mdl";
17 | private final static PropStatic LILY_PAD = new PropStatic(LilypadTf2.MODEL);
18 |
19 | public LilypadTf2() {
20 | int[] temp = { MaterialLegacy.LILY_PAD };
21 | super.materialUsedFor = temp;
22 | }
23 |
24 | @Override
25 | public void add(Mapper context, Position position, Block material) {
26 | context.setPointToGrid(position);
27 | context.movePointInGridDimension(0.5, 0, 0.5);
28 | int verticalAngle = (int) (Math.random() * 360);
29 | LilypadTf2.LILY_PAD.getAngles()
30 | .setY(verticalAngle);
31 | context.addPointEntity(LilypadTf2.LILY_PAD);
32 | context.markAsConverted(position);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/Liquid.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 |
8 | /**
9 | * A non-solid block (thus counts as air) that has a lowered height when it ends
10 | *
11 | */
12 | public class Liquid extends Action {
13 |
14 | @Override
15 | public void add(Mapper context, Position position, Block material) {
16 | Position end = context.getCuboidFinder()
17 | .getBestXYZ(position, material);
18 | context.addSolid(context.createCuboid(position, end, material));
19 | context.markAsConverted(position, end);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/NoAction.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 |
8 | public class NoAction extends Action {
9 |
10 | public static final NoAction INSTANCE = new NoAction();
11 |
12 | @Override
13 | public void add(Mapper context, Position position, Block material) {
14 | context.markAsConverted(position);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/Pane.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.MaterialLegacy;
7 | import minecraft.Position;
8 |
9 | public class Pane extends Action {
10 |
11 | public Pane() {
12 | int temp[] = { MaterialLegacy.GLASS_PANE };
13 | super.materialUsedFor = temp;
14 | }
15 |
16 | @Override
17 | public void add(Mapper context, Position p, Block material) {
18 | Position bestXY = context.getCuboidFinder()
19 | .getBestXY(p, material);
20 | Position bestYZ = context.getCuboidFinder()
21 | .getBestYZ(p, material);
22 | int sizeXY = p.getRoomSizeTo(bestXY);
23 | int sizeYZ = p.getRoomSizeTo(bestYZ);
24 | int parts = 16;
25 | int yOffset = 0;
26 | int yStop = 0;
27 | int xOffset = 0;
28 | int zOffset = 0;
29 | int xStop = 0;
30 | int zStop = 0;
31 | Position end;
32 | if (sizeXY > sizeYZ) { // window in x,y direction
33 | end = bestXY;
34 | zOffset = 7;
35 | zStop = 7;
36 | } else if (sizeXY < sizeYZ) { // window in z,y direction
37 | end = bestYZ;
38 | xOffset = 7;
39 | xStop = 7;
40 | } else { // check for borders
41 | int x = p.getX();
42 | int y = p.getY();
43 | int z = p.getZ();
44 | int sumX = this.countAirY(context, x + 1, y, z, bestXY.getY())
45 | + this.countAirY(context, x - 1, y, z, bestXY.getY());
46 | int sumZ = this.countAirY(context, x, y, z + 1, bestYZ.getY())
47 | + this.countAirY(context, x, y, z - 1, bestYZ.getY());
48 | if (sumX <= sumZ) {
49 | end = bestXY;
50 | zOffset = 7;
51 | zStop = 7;
52 | } else {
53 | end = bestYZ;
54 | xOffset = 7;
55 | xStop = 7;
56 | }
57 | }
58 | Position offset = new Position(xOffset, yOffset, zOffset);
59 | Position negativeOffset = new Position(xStop, yStop, zStop);
60 | context.addDetail(context.createCuboid(p, end, parts, offset, negativeOffset, material));
61 | context.markAsConverted(p, end);
62 | }
63 |
64 | private int countAirY(Mapper context, int x, int yStart, int z, int yEnd) {
65 | int sum = 0;
66 | for (int yRun = yStart; yRun <= yEnd; yRun++) {
67 | if (context.isAirBlock(new Position(x, yRun, z))) {
68 | sum++;
69 | }
70 | }
71 | return sum;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/PlayerSpawnCss.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 | import vmfWriter.entity.pointEntity.RotateablePointEntity;
8 | import vmfWriter.entity.solidEntity.Buyzone;
9 |
10 | public class PlayerSpawnCss extends Action {
11 |
12 | private final static int SPACE = 40;
13 |
14 | private RotateablePointEntity type;
15 | private boolean police;
16 |
17 | public PlayerSpawnCss() {
18 |
19 | }
20 |
21 | public PlayerSpawnCss(RotateablePointEntity type, boolean police) {
22 | this.type = type;
23 | this.police = police;
24 | }
25 |
26 | @Override
27 | public void add(Mapper context, Position p, Block material) {
28 | Position end = context.getCuboidFinder()
29 | .getBestXZ(p, material);
30 | context.addPointEntitys(p, end, PlayerSpawnCss.SPACE, this.type);
31 | end.move(0, 2, 0);
32 | context.addSolidEntity(new Buyzone(context.createCuboid(p, end, null), this.police));
33 | context.markAsConverted(p, end);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/PlayerSpawnTf2.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 | import vmfWriter.entity.pointEntity.RotateablePointEntity;
8 | import vmfWriter.entity.solidEntity.Buyzone;
9 |
10 | public class PlayerSpawnTf2 extends Action {
11 |
12 | private final static int SPACE = 50;
13 |
14 | private RotateablePointEntity type;
15 | private boolean police;
16 |
17 | public PlayerSpawnTf2() {
18 |
19 | }
20 |
21 | // public PlayerSpawnTf2(Block material, RotateablePointEntity type, boolean police) {
22 | // super.setMaterialUsedFor(material);
23 | // this.type = type;
24 | // this.police = police;
25 | // }
26 | //
27 | // @Override
28 | // public Iterable getInstances() {
29 | // RotateablePointEntity redSpawn = new InfoPlayerTeamSpawn().setTeamNum(Tf2Team.RED)
30 | // .setRotation(0);
31 | // RotateablePointEntity blueSpawn = new InfoPlayerTeamSpawn().setTeamNum(Tf2Team.BLUE)
32 | // .setRotation(180);
33 | // LinkedList list = new LinkedList<>();
34 | // list.add(new PlayerSpawnTf2(MaterialLegacy.END_PORTAL_FRAME, redSpawn, false));
35 | // list.add(new PlayerSpawnTf2(MaterialLegacy.ENDER_CHEST$NORTH, blueSpawn, true));
36 | // list.add(new PlayerSpawnTf2(MaterialLegacy.ENDER_CHEST$EAST, blueSpawn, true));
37 | // list.add(new PlayerSpawnTf2(MaterialLegacy.ENDER_CHEST$SOUTH, blueSpawn, true));
38 | // list.add(new PlayerSpawnTf2(MaterialLegacy.ENDER_CHEST$WEST, blueSpawn, true));
39 | // return list;
40 | // }
41 |
42 | @Override
43 | public void add(Mapper context, Position p, Block material) {
44 | Position end = context.getCuboidFinder()
45 | .getBestXZ(p, material);
46 | context.addPointEntitys(p, end, PlayerSpawnTf2.SPACE, this.type);
47 | context.markAsConverted(p, end);
48 | end.move(0, 2, 0);
49 | context.addSolidEntity(new Buyzone(context.createCuboid(p, end, null), this.police));
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/SlabBottom.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.MaterialLegacy;
7 | import minecraft.Position;
8 | import minecraft.SubBlockPosition;
9 |
10 | public class SlabBottom extends Action {
11 |
12 | public SlabBottom() {
13 | int[] temp = { MaterialLegacy.OAK_SLAB$BOTTOM, MaterialLegacy.COBBLESTONE_SLAB$BOTTOM,
14 | MaterialLegacy.BRICK_SLAB$BOTTOM, MaterialLegacy.ANDESITE_SLAB$BOTTOM,
15 | MaterialLegacy.NETHER_BRICK_SLAB$BOTTOM, MaterialLegacy.ACACIA_SLAB$BOTTOM,
16 | MaterialLegacy.BIRCH_SLAB$BOTTOM, MaterialLegacy.DIORITE_SLAB$BOTTOM,
17 | MaterialLegacy.CUT_RED_SANDSTONE_SLAB$BOTTOM, MaterialLegacy.CUT_SANDSTONE_SLAB$BOTTOM,
18 | MaterialLegacy.DIORITE_SLAB$BOTTOM, MaterialLegacy.DARK_OAK_SLAB$BOTTOM,
19 | MaterialLegacy.DARK_PRISMARINE_SLAB$BOTTOM, MaterialLegacy.END_STONE_BRICK_SLAB$BOTTOM,
20 | MaterialLegacy.GRANITE_SLAB$BOTTOM, MaterialLegacy.JUNGLE_SLAB$BOTTOM,
21 | MaterialLegacy.MOSSY_COBBLESTONE_SLAB$BOTTOM, MaterialLegacy.MOSSY_STONE_BRICK_SLAB$BOTTOM,
22 | MaterialLegacy.PETRIFIED_OAK_SLAB$BOTTOM, MaterialLegacy.POLISHED_ANDESITE_SLAB$BOTTOM,
23 | MaterialLegacy.POLISHED_DIORITE_SLAB$BOTTOM, MaterialLegacy.POLISHED_GRANITE_SLAB$BOTTOM,
24 | MaterialLegacy.PRISMARINE_BRICK_SLAB$BOTTOM, MaterialLegacy.PURPUR_SLAB$BOTTOM,
25 | MaterialLegacy.QUARTZ_SLAB$BOTTOM, MaterialLegacy.RED_NETHER_BRICK_SLAB$BOTTOM,
26 | MaterialLegacy.SANDSTONE_SLAB$BOTTOM, MaterialLegacy.SMOOTH_QUARTZ_SLAB$BOTTOM,
27 | MaterialLegacy.SMOOTH_RED_SANDSTONE_SLAB$BOTTOM, MaterialLegacy.SMOOTH_SANDSTONE_SLAB$BOTTOM,
28 | MaterialLegacy.SMOOTH_STONE_SLAB$BOTTOM, MaterialLegacy.SPRUCE_SLAB$BOTTOM,
29 | MaterialLegacy.STONE_BRICK_SLAB$BOTTOM, MaterialLegacy.STONE_SLAB$BOTTOM };
30 | super.materialUsedFor = temp;
31 | }
32 |
33 | @Override
34 | public void add(Mapper context, Position position, Block material) {
35 | context.addSubBlock(position, SubBlockPosition.BOTTOM_EAST_SOUTH, material);
36 | context.addSubBlock(position, SubBlockPosition.BOTTOM_EAST_NORTH, material);
37 | context.addSubBlock(position, SubBlockPosition.BOTTOM_WEST_SOUTH, material);
38 | context.addSubBlock(position, SubBlockPosition.BOTTOM_WEST_NORTH, material);
39 | context.markAsConverted(position);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/SlabTop.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.MaterialLegacy;
7 | import minecraft.Position;
8 | import minecraft.SubBlockPosition;
9 |
10 | public class SlabTop extends Action {
11 |
12 | public SlabTop() {
13 | int[] temp = { MaterialLegacy.OAK_SLAB$TOP, MaterialLegacy.COBBLESTONE_SLAB$TOP, MaterialLegacy.BRICK_SLAB$TOP,
14 | MaterialLegacy.ANDESITE_SLAB$TOP, MaterialLegacy.NETHER_BRICK_SLAB$TOP, MaterialLegacy.ACACIA_SLAB$TOP,
15 | MaterialLegacy.BIRCH_SLAB$TOP, MaterialLegacy.DIORITE_SLAB$TOP,
16 | MaterialLegacy.CUT_RED_SANDSTONE_SLAB$TOP, MaterialLegacy.CUT_SANDSTONE_SLAB$TOP,
17 | MaterialLegacy.DIORITE_SLAB$TOP, MaterialLegacy.DARK_OAK_SLAB$TOP,
18 | MaterialLegacy.DARK_PRISMARINE_SLAB$TOP, MaterialLegacy.END_STONE_BRICK_SLAB$TOP,
19 | MaterialLegacy.GRANITE_SLAB$TOP, MaterialLegacy.JUNGLE_SLAB$TOP,
20 | MaterialLegacy.MOSSY_COBBLESTONE_SLAB$TOP, MaterialLegacy.MOSSY_STONE_BRICK_SLAB$TOP,
21 | MaterialLegacy.PETRIFIED_OAK_SLAB$TOP, MaterialLegacy.POLISHED_ANDESITE_SLAB$TOP,
22 | MaterialLegacy.POLISHED_DIORITE_SLAB$TOP, MaterialLegacy.POLISHED_GRANITE_SLAB$TOP,
23 | MaterialLegacy.PRISMARINE_BRICK_SLAB$TOP, MaterialLegacy.PURPUR_SLAB$TOP,
24 | MaterialLegacy.QUARTZ_SLAB$TOP, MaterialLegacy.RED_NETHER_BRICK_SLAB$TOP,
25 | MaterialLegacy.SANDSTONE_SLAB$TOP, MaterialLegacy.SMOOTH_QUARTZ_SLAB$TOP,
26 | MaterialLegacy.SMOOTH_RED_SANDSTONE_SLAB$TOP, MaterialLegacy.SMOOTH_SANDSTONE_SLAB$TOP,
27 | MaterialLegacy.SMOOTH_STONE_SLAB$TOP, MaterialLegacy.SPRUCE_SLAB$TOP,
28 | MaterialLegacy.STONE_BRICK_SLAB$TOP, MaterialLegacy.STONE_SLAB$TOP };
29 | super.materialUsedFor = temp;
30 | }
31 |
32 | @Override
33 | public void add(Mapper context, Position position, Block material) {
34 | context.addSubBlock(position, SubBlockPosition.TOP_EAST_SOUTH, material);
35 | context.addSubBlock(position, SubBlockPosition.TOP_EAST_NORTH, material);
36 | context.addSubBlock(position, SubBlockPosition.TOP_WEST_SOUTH, material);
37 | context.addSubBlock(position, SubBlockPosition.TOP_WEST_NORTH, material);
38 | context.markAsConverted(position);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/SnowBlock.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.MaterialLegacy;
7 | import minecraft.Position;
8 |
9 | public class SnowBlock extends Action {
10 |
11 | public SnowBlock() {
12 | int[] temp = { MaterialLegacy.SNOW };
13 | super.setMaterialUsedFor(temp);
14 | }
15 |
16 | @Override
17 | public void add(Mapper context, Position p, Block material) {
18 | Position end = context.getCuboidFinder()
19 | .getBestXZ(p, material);
20 | int parts = 8;
21 | Position offset = new Position(0, 0, 0);
22 | Position negativeOffset = new Position(0, 7, 0);
23 | context.addDetail(context.createCuboid(p, end, parts, offset, negativeOffset, material));
24 | context.markAsConverted(p, end);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/Solid.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import basic.Loggger;
4 | import converter.Skins;
5 | import converter.actions.Action;
6 | import converter.mapper.Mapper;
7 | import minecraft.Block;
8 | import minecraft.Position;
9 | import vmfWriter.Orientation;
10 |
11 | public class Solid extends Action {
12 |
13 | public static final Action INSTANCE = new Solid();
14 |
15 | public Solid() {
16 | // is default addable
17 | }
18 |
19 | @Override
20 | public boolean isAirBlock() {
21 | return false;
22 | }
23 |
24 | @Override
25 | public boolean hasWall(Orientation orientation) {
26 | return true;
27 | }
28 |
29 | @Override
30 | public void add(Mapper context, Position position, Block block) {
31 | Position end = context.getCuboidFinder()
32 | .getBestXYZ(position, block);
33 | if (Skins.INSTANCE.getSkin(block).materialFront.equals(Skins.DEFAULT_TEXTURE)) { // temp
34 | Loggger.log("no texture set for " + block.getName());
35 | }
36 | context.addSolid(context.createCuboid(position, end, block));
37 | context.markAsConverted(position, end);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/SupplyTf2.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import basic.Loggger;
4 | import converter.actions.Action;
5 | import converter.mapper.Mapper;
6 | import minecraft.Block;
7 | import minecraft.MaterialLegacy;
8 | import minecraft.Position;
9 | import vmfWriter.Orientation;
10 | import vmfWriter.Solid;
11 | import vmfWriter.entity.Tf2Team;
12 | import vmfWriter.entity.pointEntity.pointEntity.PropDynamic;
13 | import vmfWriter.entity.solidEntity.FuncRegenerate;
14 |
15 | /**
16 | *
17 | *
18 | */
19 | public class SupplyTf2 extends Action {
20 |
21 | private static final String MODEL = "models/props_gameplay/resupply_locker.mdl";
22 | private static final int DISTANCE_FROM_WALL = 16;
23 |
24 | private Orientation orientation;
25 | private PropDynamic prop;
26 |
27 | public SupplyTf2() {
28 | int[] temp = { MaterialLegacy.CHEST$NORTH, MaterialLegacy.CHEST$SOUTH, MaterialLegacy.CHEST$WEST,
29 | MaterialLegacy.CHEST$EAST };
30 | super.setMaterialUsedFor(temp);
31 | }
32 |
33 | // public SupplyTf2(Block material, Orientation orientation) {
34 | // super.setMaterialUsedFor(material);
35 | // this.setPropDynamic(orientation);
36 | // }
37 | //
38 | // @Override
39 | // public Iterable getInstances() {
40 | // LinkedList list = new LinkedList<>();
41 | //// list.add(new SupplyTf2(MaterialLegacy.CHEST$NORTH, Orientation.NORTH));
42 | //// list.add(new SupplyTf2(MaterialLegacy.CHEST$SOUTH, Orientation.SOUTH));
43 | //// list.add(new SupplyTf2(MaterialLegacy.CHEST$EAST, Orientation.EAST));
44 | //// list.add(new SupplyTf2(MaterialLegacy.CHEST$WEST, Orientation.WEST));
45 | // return list;
46 | // }
47 |
48 | @Override
49 | public void add(Mapper context, Position p, Block material) {
50 | Loggger.log(this.getName() + " at " + p.getString());
51 | Position end = context.getCuboidFinder()
52 | .getBestXZ(p, material);
53 | Position point = new Position(p);
54 | context.setPointToGrid(p);
55 | this.moveToMiddle(context, point, point); // TODO
56 | PropDynamic createdProp = (PropDynamic) context.addPointEntity(this.prop);
57 | context.addSolidEntity(new FuncRegenerate(this.createArea(context, p, end), Tf2Team.ANY, createdProp));
58 | context.markAsConverted(p, end);
59 | }
60 |
61 | private Solid createArea(Mapper context, Position p, Position end) {
62 | return context.createCuboid(p, end.getOffset(0, 2, 0), null);
63 | }
64 |
65 | private void moveToMiddle(Mapper context, Position p, Position end) {
66 | switch (this.orientation) {
67 | case NORTH:
68 | context.movePointInGridDimension((end.x - p.x + 1) / 2, 0, 1);
69 | context.movePointExactly(new Position(0, 0, -SupplyTf2.DISTANCE_FROM_WALL));
70 | break;
71 | case SOUTH:
72 | context.movePointInGridDimension((end.x - p.x + 1) / 2, 0, 0);
73 | context.movePointExactly(new Position(0, 0, SupplyTf2.DISTANCE_FROM_WALL));
74 | break;
75 | case EAST:
76 | context.movePointInGridDimension(0, 0, (end.z - p.z + 1) / 2);
77 | context.movePointExactly(new Position(SupplyTf2.DISTANCE_FROM_WALL, 0, 0));
78 | break;
79 | case WEST:
80 | context.movePointInGridDimension(1, 0, (end.z - p.z + 1) / 2);
81 | context.movePointExactly(new Position(-SupplyTf2.DISTANCE_FROM_WALL, 0, 0));
82 | break;
83 | default:
84 | break;
85 | }
86 | }
87 |
88 | public void setPropDynamic(Orientation orientation) {
89 | this.orientation = orientation;
90 | this.prop = new PropDynamic(SupplyTf2.MODEL, 0, this.getAngleY(orientation), 0);
91 | }
92 |
93 | private int getAngleY(Orientation orientation) {
94 | switch (orientation) {
95 | case NORTH:
96 | return 90;
97 | case SOUTH:
98 | return 270;
99 | case EAST:
100 | return 0;
101 | case WEST:
102 | return 180;
103 | default:
104 | return 0;
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/TallGrassTf2.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 | import vmfWriter.entity.pointEntity.pointEntity.PropStatic;
8 |
9 | /**
10 | *
11 | *
12 | */
13 | public class TallGrassTf2 extends Action {
14 |
15 | private final static String MODEL = "models/props_swamp/tallgrass_01.mdl";
16 | private final static PropStatic TALL_GRASS = new PropStatic(TallGrassTf2.MODEL);
17 |
18 | @Override
19 | public void add(Mapper context, Position p, Block material) {
20 | context.setPointToGrid(p);
21 | context.movePointInGridDimension(0.5, 0, 0.5);
22 | int verticalRotation = (int) (Math.random() * 360);
23 | TallGrassTf2.TALL_GRASS.getAngles()
24 | .setY(verticalRotation);
25 | context.addPointEntity(TallGrassTf2.TALL_GRASS);
26 | context.markAsConverted(p);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/Torch.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 | import vmfWriter.Color;
8 | import vmfWriter.entity.pointEntity.PointEntity;
9 | import vmfWriter.entity.pointEntity.pointEntity.EnvFire;
10 | import vmfWriter.entity.pointEntity.pointEntity.InfoParticleSystem;
11 | import vmfWriter.entity.pointEntity.pointEntity.Light;
12 | import vmfWriter.entity.solidEntity.FuncIllusionary;
13 |
14 | public class Torch extends Action {
15 |
16 | public final static int red = 255;
17 | public final static int blue = 50;
18 | public final static int green = 243;
19 | public final static int brigthness = 40;
20 | public final static int distance50 = 96;
21 | public final static int distance100 = 256;
22 | public final static Color LIGHT_COLOR = new Color(Torch.red, Torch.green, Torch.blue, Torch.brigthness);
23 | public final static Light LIGHT = new Light(Torch.LIGHT_COLOR, Torch.distance50, Torch.distance100);
24 | private final static String EFFECT_NAME = "flaming_arrow";
25 | public final static InfoParticleSystem PARTICLE_SYSTEM = new InfoParticleSystem(Torch.EFFECT_NAME, 270, 0, 0);
26 | protected static final PointEntity FLAME = new EnvFire().setFireSize(3);
27 | public static final Torch INSTANCE = new Torch();
28 |
29 | @Override
30 | public void add(Mapper context, Position p, Block material) {
31 | int parts = 16;
32 | Position offset = new Position(7, 0, 7);
33 | Position negativeOffset = new Position(7, 6, 7);
34 | context.addSolidEntity(
35 | new FuncIllusionary(context.createCuboid(p, p, parts, offset, negativeOffset, material)));
36 | context.setPointToGrid(p);
37 | context.movePointInGridDimension(0.5, ((double) (parts - negativeOffset.getY())) / ((parts)), 0.5);
38 | this.addFlame(context);
39 | context.markAsConverted(p);
40 | }
41 |
42 | public void addFlame(Mapper context) {
43 | context.addPointEntity(Torch.PARTICLE_SYSTEM);
44 | context.movePointInGridDimension(0, 1.0 / ((16)), 0);
45 | context.addPointEntity(Torch.FLAME);
46 | context.addPointEntity(Torch.LIGHT);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/TorchEast.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.mapper.Mapper;
4 | import minecraft.Block;
5 | import minecraft.Position;
6 | import vmfWriter.entity.solidEntity.FuncIllusionary;
7 |
8 | public class TorchEast extends Torch {
9 |
10 | public static int red = 255;
11 | public static int blue = 50;
12 | public static int green = 243;
13 | public static int brigthness = 40;
14 | public final static int distance50 = 96;
15 | public final static int distance100 = 256;
16 |
17 | @Override
18 | public void add(Mapper context, Position p, Block material) {
19 | int parts = 32;
20 | Position[] pointOffset = new Position[8];
21 | pointOffset[0] = new Position(0, 6, 18); // a
22 | pointOffset[1] = new Position(9, 24, 18); // b
23 | pointOffset[2] = new Position(13, 22, 18); // c
24 | pointOffset[3] = new Position(4, 4, 18); // d
25 | pointOffset[4] = new Position(0, 6, 14); // e
26 | pointOffset[5] = new Position(9, 24, 14); // f
27 | pointOffset[6] = new Position(13, 22, 14); // g
28 | pointOffset[7] = new Position(4, 4, 14); // h
29 |
30 | Position point = new Position(p);
31 | context.addSolidEntity(
32 | new FuncIllusionary(context.createFree8Point(point, point, parts, pointOffset, true, material)));
33 | context.setPointToGrid(p);
34 | context.movePointInGridDimension((7.0 / 20.0), 0.7, 0.5);
35 | this.addFlame(context);
36 | context.markAsConverted(p);
37 |
38 | // textureshift: -92
39 | // textureshift -24
40 | // rotation 28
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/TorchNorth.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.Position;
7 | import vmfWriter.entity.solidEntity.FuncIllusionary;
8 |
9 | public class TorchNorth extends Action {
10 |
11 | @Override
12 | public void add(Mapper context, Position p, Block material) {
13 | int parts = 32;
14 | Position[] pointOffset = new Position[8];
15 |
16 | pointOffset[0] = new Position(18, 6, 32); // a
17 | pointOffset[1] = new Position(18, 24, 23); // b
18 | pointOffset[2] = new Position(18, 22, 19); // c
19 | pointOffset[3] = new Position(18, 4, 28); // d
20 | pointOffset[4] = new Position(14, 6, 32); // e
21 | pointOffset[5] = new Position(14, 24, 23); // f
22 | pointOffset[6] = new Position(14, 22, 19); // g
23 | pointOffset[7] = new Position(14, 4, 28); // h
24 |
25 | Position point = new Position(p);
26 | context.addSolidEntity(
27 | new FuncIllusionary(context.createFree8Point(point, point, parts, pointOffset, false, material)));
28 | context.setPointToGrid(p);
29 | context.movePointInGridDimension(0.5, 0.7, (13.0 / 20.0));
30 | context.addPointEntity(Torch.PARTICLE_SYSTEM);
31 | context.movePointInGridDimension(0, 1.0 / ((parts)), 0);
32 | context.addPointEntity(Torch.LIGHT);
33 | context.markAsConverted(p);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/TorchSouth.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.mapper.Mapper;
4 | import minecraft.Block;
5 | import minecraft.Position;
6 | import vmfWriter.entity.solidEntity.FuncIllusionary;
7 |
8 | public class TorchSouth extends Torch {
9 |
10 | @Override
11 | public void add(Mapper context, Position p, Block material) {
12 | int parts = 32;
13 | Position[] pointOffset = new Position[8];
14 |
15 | pointOffset[0] = new Position(14, 6, 0); // a
16 | pointOffset[1] = new Position(14, 24, 9); // b
17 | pointOffset[2] = new Position(14, 22, 13); // c
18 | pointOffset[3] = new Position(14, 4, 4); // d
19 | pointOffset[4] = new Position(18, 6, 0); // e
20 | pointOffset[5] = new Position(18, 24, 9); // f
21 | pointOffset[6] = new Position(18, 22, 13); // g
22 | pointOffset[7] = new Position(18, 4, 4); // h
23 |
24 | Position point = new Position(p);
25 | context.addSolidEntity(
26 | new FuncIllusionary(context.createFree8Point(point, point, parts, pointOffset, false, material)));
27 | context.setPointToGrid(p);
28 | context.movePointInGridDimension(0.5, 0.7, (7.0 / 20.0));
29 | this.addFlame(context);
30 | context.markAsConverted(p);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/TorchWest.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.mapper.Mapper;
4 | import minecraft.Block;
5 | import minecraft.Position;
6 | import vmfWriter.entity.solidEntity.FuncIllusionary;
7 |
8 | public class TorchWest extends Torch {
9 |
10 | @Override
11 | public void add(Mapper context, Position p, Block material) {
12 | int parts = 32;
13 | Position[] pointOffset = new Position[8];
14 |
15 | pointOffset[0] = new Position(32, 6, 14); // a
16 | pointOffset[1] = new Position(23, 24, 14); // b
17 | pointOffset[2] = new Position(19, 22, 14); // c
18 | pointOffset[3] = new Position(28, 4, 14); // d
19 | pointOffset[4] = new Position(32, 6, 18); // e
20 | pointOffset[5] = new Position(23, 24, 18); // f
21 | pointOffset[6] = new Position(19, 22, 18); // g
22 | pointOffset[7] = new Position(28, 4, 18); // h
23 |
24 | Position point = Position.create(p);
25 | context.addSolidEntity(
26 | new FuncIllusionary(context.createFree8Point(point, point, parts, pointOffset, true, material)));
27 | context.setPointToGrid(p);
28 | context.movePointInGridDimension((13.0 / 20.0), 0.7, 0.5);
29 | this.addFlame(context);
30 | context.markAsConverted(p);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/VinesEast.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.MaterialLegacy;
7 | import minecraft.Position;
8 | import vmfWriter.entity.solidEntity.FuncIllusionary;
9 |
10 | /**
11 | *
12 | *
13 | */
14 | public class VinesEast extends Action {
15 |
16 | public VinesEast() {
17 | int[] temp = { MaterialLegacy.VINES };
18 | super.setMaterialUsedFor(temp);
19 | }
20 |
21 | @Override
22 | public void add(Mapper context, Position p, Block material) {
23 | Position end = context.getCuboidFinder()
24 | .getBestY(p, material);
25 | int parts = 8;
26 | Position offset = new Position(7, 0, 0);
27 | Position negativeOffset = new Position(0, 0, 0);
28 | context.addSolidEntity(
29 | new FuncIllusionary(context.createCuboid(p, end, parts, offset, negativeOffset, material)));
30 | context.markAsConverted(p, end);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/VinesNorth.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.MaterialLegacy;
7 | import minecraft.Position;
8 | import vmfWriter.entity.solidEntity.FuncIllusionary;
9 |
10 | /**
11 | *
12 | *
13 | */
14 | public class VinesNorth extends Action {
15 |
16 | public VinesNorth() {
17 | int[] temp = { MaterialLegacy.VINES };
18 | super.setMaterialUsedFor(temp);
19 | }
20 |
21 | @Override
22 | public void add(Mapper context, Position p, Block material) {
23 | Position end = context.getCuboidFinder()
24 | .getBestY(p, material);
25 | int parts = 8;
26 | Position offset = new Position(0, 0, 0);
27 | Position negativeOffset = new Position(0, 0, 7);
28 | context.addSolidEntity(
29 | new FuncIllusionary(context.createCuboid(p, end, parts, offset, negativeOffset, material)));
30 | context.markAsConverted(p, end);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/VinesSouth.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.MaterialLegacy;
7 | import minecraft.Position;
8 | import vmfWriter.entity.solidEntity.FuncIllusionary;
9 |
10 | /**
11 | *
12 | *
13 | */
14 | public class VinesSouth extends Action {
15 |
16 | public VinesSouth() {
17 | int[] temp = { MaterialLegacy.VINES };
18 | super.setMaterialUsedFor(temp);
19 | }
20 |
21 | @Override
22 | public void add(Mapper context, Position p, Block material) {
23 | Position end = context.getCuboidFinder()
24 | .getBestY(p, material);
25 | int parts = 8;
26 | Position offset = new Position(0, 0, 7);
27 | Position negativeOffset = new Position(0, 0, 0);
28 | context.addSolidEntity(
29 | new FuncIllusionary(context.createCuboid(p, end, parts, offset, negativeOffset, material)));
30 | context.markAsConverted(p, end);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/converter/actions/actions/VinesWest.java:
--------------------------------------------------------------------------------
1 | package converter.actions.actions;
2 |
3 | import converter.actions.Action;
4 | import converter.mapper.Mapper;
5 | import minecraft.Block;
6 | import minecraft.MaterialLegacy;
7 | import minecraft.Position;
8 | import vmfWriter.entity.solidEntity.FuncIllusionary;
9 |
10 | /**
11 | *
12 | *
13 | */
14 | public class VinesWest extends Action {
15 |
16 | public VinesWest() {
17 | int[] temp = { MaterialLegacy.VINES };
18 | super.setMaterialUsedFor(temp);
19 | }
20 |
21 | @Override
22 | public void add(Mapper context, Position p, Block material) {
23 | Position end = context.getCuboidFinder()
24 | .getBestY(p, material);
25 | int parts = 8;
26 | Position offset = new Position(0, 0, 0);
27 | Position negativeOffset = new Position(7, 0, 0);
28 | context.addSolidEntity(
29 | new FuncIllusionary(context.createCuboid(p, end, parts, offset, negativeOffset, material)));
30 | context.markAsConverted(p, end);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/converter/cuboidFinder/CuboidFinder.java:
--------------------------------------------------------------------------------
1 | package converter.cuboidFinder;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collection;
5 |
6 | import minecraft.Block;
7 | import minecraft.Position;
8 |
9 | public abstract class CuboidFinder {
10 |
11 | public Position getBestXYZ(Position position, Block... material) {
12 | return this.getBestXYZ(position, Arrays.asList(material));
13 | }
14 |
15 | public Position getBestXY(Position position, Block... material) {
16 | return this.getBestXY(position, Arrays.asList(material));
17 | }
18 |
19 | public Position getBestXZ(Position position, Block... material) {
20 | return this.getBestXZ(position, Arrays.asList(material));
21 | }
22 |
23 | public Position getBestYZ(Position position, Block... material) {
24 | return this.getBestYZ(position, Arrays.asList(material));
25 | }
26 |
27 | public Position getBestX(Position position, Block... material) {
28 | return this.getBestX(position, Arrays.asList(material));
29 | }
30 |
31 | public Position getBestY(Position position, Block... material) {
32 | return this.getBestY(position, Arrays.asList(material));
33 | }
34 |
35 | public Position getBestZ(Position position, Block... material) {
36 | return this.getBestZ(position, Arrays.asList(material));
37 | }
38 |
39 | public abstract Position getBestXYZ(Position position, Collection material);
40 |
41 | public abstract Position getBestXY(Position position, Collection material);
42 |
43 | public abstract Position getBestXZ(Position position, Collection material);
44 |
45 | public abstract Position getBestYZ(Position position, Collection material);
46 |
47 | public abstract Position getBestX(Position position, Collection material);
48 |
49 | public abstract Position getBestY(Position position, Collection material);
50 |
51 | public abstract Position getBestZ(Position position, Collection material);
52 | }
53 |
--------------------------------------------------------------------------------
/src/converter/mapper/Mapper.java:
--------------------------------------------------------------------------------
1 | package converter.mapper;
2 |
3 | import basic.Tuple;
4 | import converter.ConvertingReport;
5 | import converter.Skins;
6 | import converter.actions.ActionManager;
7 | import converter.cuboidFinder.CuboidFinder;
8 | import converter.cuboidFinder.DefaultCuboidFinder;
9 | import minecraft.Block;
10 | import minecraft.Position;
11 | import minecraft.SubBlockPosition;
12 | import periphery.SourceGame;
13 | import vmfWriter.Cuboid;
14 | import vmfWriter.entity.pointEntity.PointEntity;
15 |
16 | public abstract class Mapper extends SourceMapper {
17 |
18 | private CuboidFinder cuboidFinder = new DefaultCuboidFinder(this);
19 | protected ActionManager convertActions;
20 | private int scale;
21 |
22 | public Mapper() {
23 | }
24 |
25 | public CuboidFinder getCuboidFinder() {
26 | return this.cuboidFinder;
27 | }
28 |
29 | public Mapper setAddableManager(ActionManager addableManager) {
30 | this.convertActions = addableManager;
31 | return this;
32 | }
33 |
34 | @Override
35 | public ConvertingReport prepareWrite(SourceGame game) {
36 | this.addObjects(game);
37 | return null;
38 | }
39 |
40 | public abstract void addObjects(SourceGame game);
41 |
42 | public void addSubBlock(Position position, SubBlockPosition pos, Block materialInt) {
43 | throw new UnsupportedOperationException();
44 | }
45 |
46 | public Mapper setScale(int scale) {
47 | this.scale = scale;
48 | return this;
49 | }
50 |
51 | public int getScale() {
52 | return this.scale;
53 | }
54 |
55 | @Override
56 | public void movePointInGridDimension(double x, double y, double z) {
57 | // ugly
58 | this.target.movePointInGridDimension(x * this.scale, -z * this.scale, y * this.scale);
59 | }
60 |
61 | @Override
62 | public void movePointExactly(Position offset) {
63 | Position translated = new Position(offset.x, -offset.z, offset.y);
64 | this.target.movePointExactly(translated);
65 | }
66 |
67 | protected Position convert(Position p) {
68 | // z and y axis are switched
69 | // NORTH-SOUTH axis is flipped
70 | return new Position(p.getX() * this.scale, -p.getZ() * this.scale, p.getY() * this.scale);
71 | }
72 |
73 | @Override
74 | public void setPointToGrid(Position position) {
75 | this.target.setPointToGrid(this.convert(position));
76 | }
77 |
78 | @Override
79 | public Cuboid createCuboid(Position start, Position end, Block material) {
80 | return new Cuboid(this.convertPositions(start, end), Skins.INSTANCE.getSkin(material));
81 | }
82 |
83 | public Tuple convertPositions(Position start, Position endIn) {
84 | Position end = endIn.getOffset(1, 1, 1);
85 | Position startConverted = this.convert(start);
86 | Position endConverted = this.convert(end);
87 | Position.bringInOrder(startConverted, endConverted);
88 |
89 | return new Tuple<>(startConverted, endConverted);
90 | }
91 |
92 | @Override
93 | public Cuboid createCuboid(Position start, Position end, int parts, Position offset, Position negativeOffset,
94 | Block material) {
95 | double grid = (double) (this.getScale()) / (double) (parts);
96 | Position startNew = new Position(start.x * this.getScale() + offset.x * grid,
97 | (-end.z - 1) * this.getScale() + negativeOffset.z * grid, start.y * this.getScale() + offset.y * grid);
98 | Position endNew = new Position((end.x + 1) * this.getScale() - negativeOffset.x * grid,
99 | -start.z * this.getScale() - offset.z * grid, (end.y + 1) * this.getScale() - negativeOffset.y * grid);
100 | return new Cuboid(new Tuple<>(startNew, endNew), Skins.INSTANCE.getSkin(material));
101 | }
102 |
103 | // protected abstract boolean needsConversion(Position position);
104 |
105 | public ActionManager getActions() {
106 | return this.convertActions;
107 | }
108 |
109 | public boolean isAirBlock(Position position) {
110 | return this.getActions()
111 | .getAction(this.getBlock(position))
112 | .isAirBlock();
113 | }
114 |
115 | // public boolean stillNeedsConversion(Position position) {
116 | // return this.needsConversion(position) && (!this.isConverted(position));
117 | // }
118 |
119 | public boolean needsConversion(Position position) {
120 | return true; // overwrite me
121 | }
122 |
123 | public abstract void markAsConverted(Position position);
124 |
125 | public abstract void markAsConverted(Position position, Position end);
126 |
127 | @Override
128 | public void addPointEntitys(Position start, Position end, int space, PointEntity type) {
129 | Tuple conveted = this.convertPositions(start, end);
130 | this.addPointEntitys(conveted.getFirst(), conveted.getSecond(), space, type);
131 | }
132 |
133 | }
134 |
--------------------------------------------------------------------------------
/src/converter/mapper/SourceMapper.java:
--------------------------------------------------------------------------------
1 | package converter.mapper;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 |
6 | import converter.ConvertingReport;
7 | import minecraft.Block;
8 | import minecraft.MinecraftMap;
9 | import minecraft.Position;
10 | import periphery.SourceGame;
11 | import vmfWriter.Cuboid;
12 | import vmfWriter.Free8Point;
13 | import vmfWriter.Solid;
14 | import vmfWriter.SourceMap;
15 | import vmfWriter.entity.pointEntity.PointEntity;
16 | import vmfWriter.entity.solidEntity.SolidEntity;
17 |
18 | public abstract class SourceMapper extends MinecraftMap implements SourceMap {
19 |
20 | protected SourceMap target;
21 |
22 | public SourceMapper() {
23 | }
24 |
25 | public SourceMapper setTarget(SourceMap target) {
26 | this.target = target;
27 | return this;
28 | }
29 |
30 | @Override
31 | public void setSkyTexture(String skyTexture) {
32 | this.target.setSkyTexture(skyTexture);
33 | }
34 |
35 | @Override
36 | public void addSolid(Solid shape) {
37 | this.target.addSolid(shape);
38 | }
39 |
40 | @Override
41 | public void addDetail(Solid... solids) {
42 | this.target.addDetail(solids);
43 | }
44 |
45 | @Override
46 | public PointEntity addPointEntity(PointEntity position) {
47 | return this.target.addPointEntity(position);
48 | }
49 |
50 | @Override
51 | public PointEntity addPointEntity(PointEntity entity, Position position) {
52 | return this.target.addPointEntity(entity, position);
53 | }
54 |
55 | @Override
56 | public void addPointEntity(Position origin, PointEntity type) {
57 | this.target.addPointEntity(origin, type);
58 | }
59 |
60 | @Override
61 | public void addSolidEntity(SolidEntity solidEnttiy) {
62 | this.target.addSolidEntity(solidEnttiy);
63 | }
64 |
65 | @Override
66 | public void setCameraPosition(Position origin) {
67 | this.target.setCameraPosition(origin);
68 | }
69 |
70 | @Override
71 | public void setCameraLook(Position position) {
72 | this.target.setCameraLook(position);
73 | }
74 |
75 | @Override
76 | public ConvertingReport write(File file, SourceGame game) throws IOException {
77 | this.prepareWrite(game);
78 | this.target.write(file, game);
79 | return null;
80 | }
81 |
82 | public abstract ConvertingReport prepareWrite(SourceGame game);
83 |
84 | public abstract Cuboid createCuboid(Position start, Position end, Block material);
85 |
86 | public abstract Cuboid createCuboid(Position start, Position end, int positionarts, Position offset,
87 | Position negativeOffset, Block material);
88 |
89 | public abstract Free8Point createFree8Point(Position start, Position end, int parts, Position[] offset,
90 | boolean align, Block material);
91 | }
92 |
--------------------------------------------------------------------------------
/src/converter/mapper/SubblockMapper.java:
--------------------------------------------------------------------------------
1 | package converter.mapper;
2 |
3 | import java.util.HashSet;
4 | import java.util.Set;
5 | import java.util.SortedMap;
6 | import java.util.TreeMap;
7 |
8 | import basic.Value;
9 | import converter.actions.Action;
10 | import converter.actions.ActionManager;
11 | import converter.actions.actions.DetailBlock;
12 | import minecraft.Block;
13 | import minecraft.Blocks;
14 | import minecraft.Position;
15 | import periphery.SourceGame;
16 | import vmfWriter.Cuboid;
17 | import vmfWriter.Free8Point;
18 | import vmfWriter.Orientation;
19 | import vmfWriter.Ramp;
20 | import vmfWriter.SourceMap;
21 |
22 | public class SubblockMapper extends Mapper {
23 |
24 | private static final Position STEP_NORTH = new Position(0, 0, 1);
25 | private static final Position STEP_SOUTH = new Position(0, 0, -1);
26 | private static final Position STEP_WEST = new Position(1, 0, 0);
27 | private static final Position STEP_EAST = new Position(-1, 0, 0);
28 |
29 | private Set isConverted = new HashSet<>();
30 | private SortedMap> subBlocks;
31 |
32 | private class RampAddableZ extends Action {
33 | private Orientation orientation;
34 | private Block mStart;
35 | private Block mEnd;
36 |
37 | public RampAddableZ(Orientation orientation, Block mStart, Block mEnd) {
38 | this.orientation = orientation;
39 | this.mStart = mStart;
40 | this.mEnd = mEnd;
41 | }
42 |
43 | @Override
44 | public void add(Mapper context, Position start, Block material) {
45 | Position end = context.getCuboidFinder()
46 | .getBestZ(start, material);
47 | Cuboid cuboid = context.createCuboid(start, end, material);
48 | if (context.hasBlock(Position.add(end, STEP_NORTH), this.mEnd)) {
49 | cuboid.extend(this.orientation, Orientation.NORTH);
50 | }
51 | if (context.hasBlock(Position.add(start, STEP_SOUTH), this.mStart)) {
52 | cuboid.extend(this.orientation, Orientation.SOUTH);
53 | }
54 | Ramp ramp = new Ramp(cuboid, this.orientation);
55 | context.addSolid(ramp);
56 | context.markAsConverted(start, end);
57 | }
58 |
59 | }
60 |
61 | private class RampAddableX extends Action {
62 | private Orientation orientation;
63 | private Block mStart;
64 | private Block mEnd;
65 |
66 | public RampAddableX(Orientation orientation, Block mStart, Block mEnd) {
67 | this.orientation = orientation;
68 | this.mStart = mStart;
69 | this.mEnd = mEnd;
70 | }
71 |
72 | @Override
73 | public void add(Mapper mapper, Position start, Block material) {
74 | Position end = mapper.getCuboidFinder()
75 | .getBestX(start, material);
76 | Cuboid cuboid = mapper.createCuboid(start, end, material);
77 | if (mapper.hasBlock(Position.add(end, STEP_WEST), this.mEnd)) {
78 | cuboid.extend(this.orientation, Orientation.WEST);
79 | }
80 | if (mapper.hasBlock(Position.add(start, STEP_EAST), this.mStart)) {
81 | cuboid.extend(this.orientation, Orientation.EAST);
82 | }
83 | Ramp ramp = new Ramp(cuboid, this.orientation);
84 | mapper.addSolid(ramp);
85 | mapper.markAsConverted(start, end);
86 | }
87 | }
88 |
89 | public SubblockMapper(SourceMap target, int originalScale) {
90 | ActionManager addableManager = new ActionManager(new DetailBlock())
91 | .setAction(Blocks._RAMP_EAST,
92 | new RampAddableZ(Orientation.EAST, Blocks._RAMP_SOUTH_EAST, Blocks._RAMP_NORTH_EAST))
93 | .setAction(Blocks._RAMP_WEST,
94 | new RampAddableZ(Orientation.WEST, Blocks._RAMP_SOUTH_WEST, Blocks._RAMP_NORTH_WEST))
95 | .setAction(Blocks._RAMP_NORTH,
96 | new RampAddableX(Orientation.NORTH, Blocks._RAMP_NORTH_EAST, Blocks._RAMP_NORTH_WEST))
97 | .setAction(Blocks._RAMP_SOUTH,
98 | new RampAddableX(Orientation.SOUTH, Blocks._RAMP_SOUTH_EAST, Blocks._RAMP_SOUTH_WEST))
99 | // .setAddable(Arrays.asList(Material._RAMP_NORTH_EAST, Material._RAMP_NORTH_WEST,
100 | // Material._RAMP_SOUTH_EAST, Material._RAMP_SOUTH_WEST), new Debug())
101 | ;
102 | this.setAddableManager(addableManager);
103 | this.setTarget(target);
104 | this.subBlocks = new TreeMap<>();
105 | this.setScale(originalScale / 2);
106 | }
107 |
108 | @Override
109 | public void addObjects(SourceGame game) {
110 | this.subBlocks.forEach((position, block) -> {
111 | if (this.needsConversion(position)) {
112 | this.convertActions.add(this, position, block.get());
113 | }
114 | });
115 | }
116 |
117 | @Override
118 | public Block getBlock(Position position) {
119 | Value value = this.subBlocks.get(position);
120 | if (value == null) {
121 | return Blocks._UNSET;
122 | }
123 | return value.get();
124 | }
125 |
126 | @Override
127 | public void markAsConverted(Position position) {
128 | this.isConverted.add(position);
129 | }
130 |
131 | @Override
132 | public void markAsConverted(Position start, Position end) {
133 | for (int xMark = start.getX(); xMark <= end.getX(); xMark++) {
134 | for (int yMark = start.getY(); yMark <= end.getY(); yMark++) {
135 | for (int zMark = start.getZ(); zMark <= end.getZ(); zMark++) {
136 | this.markAsConverted(new Position(xMark, yMark, zMark));
137 | }
138 | }
139 | }
140 | }
141 |
142 | @Override
143 | public void setBlock(Position position, Block material) {
144 | this.subBlocks.put(position, new Value().set(material));
145 | }
146 |
147 | @Override
148 | public Free8Point createFree8Point(Position start, Position end, int parts, Position[] offset, boolean align,
149 | Block material) {
150 | // not supported
151 | return null;
152 | }
153 |
154 | @Override
155 | public boolean needsConversion(Position position) {
156 | return !this.isConverted.contains(position);
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/src/gui/SimpleTextFieldChangeListener.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | import javax.swing.JTextField;
4 | import javax.swing.event.DocumentEvent;
5 | import javax.swing.event.DocumentListener;
6 |
7 | public class SimpleTextFieldChangeListener implements DocumentListener {
8 |
9 | private Runnable action;
10 |
11 | public SimpleTextFieldChangeListener(Runnable action) {
12 | this.action = action;
13 | }
14 |
15 | @Override
16 | public void changedUpdate(DocumentEvent arg0) {
17 | this.action.run();
18 | }
19 |
20 | @Override
21 | public void insertUpdate(DocumentEvent arg0) {
22 | this.action.run();
23 | }
24 |
25 | @Override
26 | public void removeUpdate(DocumentEvent arg0) {
27 | this.action.run();
28 | }
29 |
30 | public static void addTo(JTextField textField, Runnable action) {
31 | textField.getDocument()
32 | .addDocumentListener(new SimpleTextFieldChangeListener(action));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/gui/WorldComboboxRenderer.java:
--------------------------------------------------------------------------------
1 | package gui;
2 |
3 | import java.awt.Color;
4 | import java.awt.Component;
5 |
6 | import javax.swing.JLabel;
7 | import javax.swing.JList;
8 | import javax.swing.ListCellRenderer;
9 |
10 | import minecraft.World;
11 |
12 | public class WorldComboboxRenderer extends JLabel implements ListCellRenderer