MCPcopy Create free account
hub / github.com/Garten/sourcecraft / initInput

Method initInput

src/main/GuiLogic.java:113–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111 }
112
113 private void initInput() {
114
115 // world
116 Vector<World> worldNames = Minecraft.getPossibleWorlds();
117 this.gui.setPossibleWorlds(worldNames);
118
119 // place
120 Vector<Place> placeNames = Periphery.PLACES.getPlaces();
121 this.gui.setPossiblePlaces(placeNames);
122
123 this.gui.setValidatePlace(place -> {
124 if (place == null) {
125 return false;
126 }
127 if (place.correctCoordinates()) {
128 this.gui.setPlace(place);
129 return false;
130 }
131 return true;
132 });
133
134 // place load
135 this.gui.setLoadPlace(place -> {
136 this.gui.setPlace(place);
137 });
138 Place currentPlace = this.gui.getPlace();
139 this.gui.setPlace(currentPlace);
140
141 this.gui.setDeletePlace(place -> {
142 Periphery.PLACES.deletePlace(place);
143 this.gui.setPossiblePlaces(Periphery.PLACES.getPlaces());
144 }); // TODO
145
146 this.gui.setLoadCoordinates(labeledCoordinates -> {
147 this.gui.setLabeledCoordinates(labeledCoordinates);
148 this.gui.setPlace(Place.create()
149 .setStart(labeledCoordinates.getStart())
150 .setEnd(labeledCoordinates.getEnd())
151 .setWorld(this.gui.getWorld()
152 .getName()));
153 });
154
155 // set player coordinates when world is selected
156 this.gui.setUponWorldSelected(world -> {
157 if (world == null) {
158 return;
159 }
160 LabeledCoordinates playerPosition = world.getPlayerPosition();
161 Vector<LabeledCoordinates> labeledCoordinates = new Vector<>();
162
163 labeledCoordinates.add(playerPosition);
164 labeledCoordinates.add(world.getWorldSpawnPosition());
165 labeledCoordinates.add(new LabeledCoordinates("World origin", new Position(-20, 45, -20), new Position(20, 150, 20)));
166 this.gui.setPossibleCoordinates(labeledCoordinates);
167 this.gui.setLabeledCoordinates(new LabeledCoordinates(World.PLAYER_POSITION));
168 });
169 this.gui.setWorld(Place.getWorld(currentPlace));
170 }

Callers 1

runMethod · 0.95

Calls 15

getPossibleWorldsMethod · 0.95
createMethod · 0.95
getWorldMethod · 0.95
getPlacesMethod · 0.80
setValidatePlaceMethod · 0.80
correctCoordinatesMethod · 0.80
deletePlaceMethod · 0.80
setEndMethod · 0.80
setStartMethod · 0.80
getWorldSpawnPositionMethod · 0.80
setPossibleWorldsMethod · 0.45
setPossiblePlacesMethod · 0.45

Tested by

no test coverage detected