-
-
Notifications
You must be signed in to change notification settings - Fork 342
/
Copy pathViewer.java
245 lines (225 loc) · 8.64 KB
/
Viewer.java
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.effect;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.sound.Sound;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.effect.particle.ParticleEffect;
import org.spongepowered.api.effect.sound.SoundType;
import org.spongepowered.api.effect.sound.music.MusicDisc;
import org.spongepowered.api.item.inventory.ItemStackLike;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.WorldType;
import org.spongepowered.api.world.WorldTypes;
import org.spongepowered.math.vector.Vector3d;
import org.spongepowered.math.vector.Vector3i;
import java.util.Objects;
/**
* A Viewer is something that sees effects.
* E.g. the Viewer class contains methods for spawning particles and playing
* sound effects.
*/
public interface Viewer extends Audience {
/**
* Sends the effect of being in a particular world environment, such as the Nether,
* as an effect to the viewer.
*
* <p>For example, specifying {@link WorldTypes#THE_NETHER} will create an empty skybox
* and hazy fog on the vanilla minecraft client</p>
*
* @param worldType The world type
*/
void sendWorldType(WorldType worldType);
/**
* Plays a client-only death protection effect with the given item.
*
* @param stack The item to display
*/
void playTotemOfUndyingEffect(ItemStackLike stack);
/**
* Spawn the given {@link ParticleEffect} at the given position.
*
* @param particleEffect The particle effect to spawn
* @param position The position
*/
default void spawnParticles(final ParticleEffect particleEffect, final Vector3d position) {
Objects.requireNonNull(position, "position");
this.spawnParticles(particleEffect, position.x(), position.y(), position.z());
}
/**
* Spawn the given {@link ParticleEffect} at the given position.
*
* @param particleEffect The particle effect to spawn
* @param x The x position
* @param y The y position
* @param z The z position
*/
void spawnParticles(ParticleEffect particleEffect, double x, double y, double z);
/**
* Plays the given {@link Sound} at the given position.
*
* @param sound The sound
* @param position The position
*/
default void playSound(final @NonNull Sound sound, final Vector3d position) {
Objects.requireNonNull(position, "position");
this.playSound(sound, position.x(), position.y(), position.z());
}
/**
* Plays the given {@link MusicDisc} at the given position. The benefit of playing
* {@link MusicDisc} instead of a {@link SoundType} allows you to stop them through
* the {@link #stopMusicDisc(Vector3i)}. Playing a new {@link MusicDisc} at the same
* position will cancel the currently playing one.
*
* @param position The position
* @param musicDisc The music disc
*/
default void playMusicDisc(final Vector3i position, final MusicDisc musicDisc) {
Objects.requireNonNull(position, "position");
this.playMusicDisc(position.x(), position.y(), position.z(), musicDisc);
}
/**
* Plays the given {@link MusicDisc} at the given position. The benefit of playing
* {@link MusicDisc} instead of a {@link SoundType} allows you to stop them through
* the {@link #stopMusicDisc(Vector3i)}. Playing a new {@link MusicDisc} at the same
* position will cancel the currently playing one.
*
* @param x The x position
* @param y The y position
* @param z The z position
* @param musicDisc The music disc
*/
void playMusicDisc(int x, int y, int z, MusicDisc musicDisc);
/**
* Stops the {@link MusicDisc} that is playing at the given position.
*
* @param position The position
*/
default void stopMusicDisc(final Vector3i position) {
Objects.requireNonNull(position, "position");
this.stopMusicDisc(position.x(), position.y(), position.z());
}
/**
* Stops the {@link MusicDisc} that is playing at the given position.
*
* @param x The x position
* @param y The y position
* @param z The z position
*/
void stopMusicDisc(int x, int y, int z);
/**
* Sends a client-only block change.
*
* <p>This will not change the {@link World} in any way.</p>
*
* @param position The position
* @param state The block state
*/
default void sendBlockChange(final Vector3i position, final BlockState state) {
Objects.requireNonNull(position, "position");
this.sendBlockChange(position.x(), position.y(), position.z(), state);
}
/**
* Sends a client-only block change.
*
* <p>This will not change the {@link World} in any way.</p>
*
* @param x The x position
* @param y The y position
* @param z The z position
* @param state The block state
*/
void sendBlockChange(int x, int y, int z, BlockState state);
/**
* Resets the client's view of the provided position to what
* actually exists in the {@link World}.
*
* <p>This is useful for resetting what the client sees
* after sending a {@link #sendBlockChange block change}.</p>
*
* @param position The position
*/
default void resetBlockChange(final Vector3i position) {
Objects.requireNonNull(position, "position");
this.resetBlockChange(position.x(), position.y(), position.z());
}
/**
* Resets the client's view of the provided position to what
* actually exists in the {@link World}.
*
* <p>This is useful for resetting what the client sees
* after sending a {@link #sendBlockChange block change}.</p>
*
* @param x The x position
* @param y The y position
* @param z The z position
*/
void resetBlockChange(int x, int y, int z);
/**
* Sends a client-only block breaking progress.
*
* @param position The position
* @param progress The breaking progress from 0 to 1
*/
default void sendBlockProgress(final Vector3i position, final double progress) {
Objects.requireNonNull(position, "position");
this.sendBlockProgress(position.x(), position.y(), position.z(), progress);
}
/**
* Sends a client-only block breaking progress.
*
* @param x The x position
* @param y The y position
* @param z The z position
* @param progress The breaking progress from 0 to 1
*/
void sendBlockProgress(int x, int y, int z, double progress);
/**
* Resets the client's view of the provided position to actual
* breaking progress.
*
* <p>This is useful for resetting what the client sees
* after sending a {@link #sendBlockProgress block progress}.</p>
*
* @param position The position
*/
default void resetBlockProgress(final Vector3i position) {
Objects.requireNonNull(position, "position");
this.resetBlockProgress(position.x(), position.y(), position.z());
}
/**
* Resets the client's view of the provided position to actual
* breaking progress.
*
* <p>This is useful for resetting what the client sees
* after sending a {@link #sendBlockProgress block progress}.</p>
*
* @param x The x position
* @param y The y position
* @param z The z position
*/
void resetBlockProgress(int x, int y, int z);
}