Plex-FAWE/worldedit-core/src/main/java/com/boydti/fawe/object/brush/heightmap/RotatableHeightMap.java

28 lines
884 B
Java
Raw Normal View History

package com.boydti.fawe.object.brush.heightmap;
2018-12-23 16:19:33 +00:00
import com.sk89q.worldedit.math.BlockVector3;
2019-03-31 16:09:20 +00:00
import com.sk89q.worldedit.math.MutableVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
public class RotatableHeightMap extends AbstractDelegateHeightMap {
private AffineTransform transform;
2019-03-31 16:09:20 +00:00
private MutableVector3 mutable;
public RotatableHeightMap(HeightMap parent) {
super(parent);
2019-03-31 16:09:20 +00:00
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);
2019-03-31 16:09:20 +00:00
BlockVector3 pos = transform.apply(mutable.setComponents(x, 0, z)).toBlockPoint();
return super.getHeight(pos.getBlockX(), pos.getBlockZ());
}
}