blob: 5fbc336b7fd236b836762270dea8bf4feec5747c (
plain)
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
|
package org.bukkit.craftbukkit.block;
import java.util.Objects;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.TileEntityEndGateway;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.EndGateway;
public class CraftEndGateway extends CraftBlockEntityState<TileEntityEndGateway> implements EndGateway {
public CraftEndGateway(Block block) {
super(block, TileEntityEndGateway.class);
}
public CraftEndGateway(final Material material, TileEntityEndGateway te) {
super(material, te);
}
@Override
public Location getExitLocation() {
BlockPosition pos = this.getSnapshot().exitPortal;
return pos == null ? null : new Location(this.isPlaced() ? this.getWorld() : null, pos.getX(), pos.getY(), pos.getZ());
}
@Override
public void setExitLocation(Location location) {
if (location == null) {
this.getSnapshot().exitPortal = null;
} else if (!Objects.equals(location.getWorld(), this.isPlaced() ? this.getWorld() : null)) {
throw new IllegalArgumentException("Cannot set exit location to different world");
} else {
this.getSnapshot().exitPortal = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
}
@Override
public boolean isExactTeleport() {
return this.getSnapshot().exactTeleport;
}
@Override
public void setExactTeleport(boolean exact) {
this.getSnapshot().exactTeleport = exact;
}
@Override
public long getAge() {
return this.getSnapshot().e;
}
@Override
public void setAge(long age) {
this.getSnapshot().e = age;
}
@Override
public void applyTo(TileEntityEndGateway endGateway) {
super.applyTo(endGateway);
if (this.getSnapshot().exitPortal == null) {
endGateway.exitPortal = null;
}
}
}
|