Plex-FAWE/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java
2019-04-01 03:09:20 +11:00

28 lines
884 B
Java

package com.boydti.fawe.object.brush.heightmap;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
public class RotatableHeightMap extends AbstractDelegateHeightMap {
private AffineTransform transform;
private MutableVector3 mutable;
public RotatableHeightMap(HeightMap parent) {
super(parent);
mutable = new MutableVector3();
this.transform = new AffineTransform();
}
public void rotate(double angle) {
this.transform = transform.rotateY(angle);
}
@Override
public double getHeight(int x, int z) {
mutable.mutX(x);
mutable.mutZ(z);
BlockVector3 pos = transform.apply(mutable.setComponents(x, 0, z)).toBlockPoint();
return super.getHeight(pos.getBlockX(), pos.getBlockZ());
}
}