added pixel offset
This commit is contained in:
parent
de14aaa79d
commit
47c6a01ce5
@ -10,27 +10,28 @@ public class Pixel {
|
||||
Location relativeLocation;
|
||||
BlockData blockData;
|
||||
double scale;
|
||||
double offset;
|
||||
|
||||
public Pixel(Location relativeLocation, BlockData blockData, double scale) {
|
||||
public Pixel(Location relativeLocation, BlockData blockData, double scale, double offset) {
|
||||
this.relativeLocation = new Location(
|
||||
relativeLocation.getWorld(),
|
||||
relativeLocation.x(),
|
||||
relativeLocation.y(),
|
||||
relativeLocation.z()
|
||||
relativeLocation.getWorld(),
|
||||
relativeLocation.x(),
|
||||
relativeLocation.y(),
|
||||
relativeLocation.z()
|
||||
);
|
||||
this.blockData = blockData;
|
||||
this.scale = scale;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public void spawn(Location spawnBlockLocation) {
|
||||
double positionX = spawnBlockLocation.x()+relativeLocation.x()*scale;
|
||||
double positionY = spawnBlockLocation.y()+relativeLocation.y()*scale;
|
||||
double positionZ = spawnBlockLocation.z()+relativeLocation.z()*scale;
|
||||
double positionX = spawnBlockLocation.x()+relativeLocation.x()*scale+offset;
|
||||
double positionY = spawnBlockLocation.y()+relativeLocation.y()*scale+offset;
|
||||
double positionZ = spawnBlockLocation.z()+relativeLocation.z()*scale+offset;
|
||||
|
||||
Location spawnLocation = new Location(spawnBlockLocation.getWorld(), positionX, positionY, positionZ);
|
||||
|
||||
BlockDisplay bd;
|
||||
bd = (BlockDisplay) spawnLocation.getWorld().spawnEntity(
|
||||
BlockDisplay bd = (BlockDisplay) spawnLocation.getWorld().spawnEntity(
|
||||
spawnLocation,
|
||||
EntityType.BLOCK_DISPLAY
|
||||
);
|
||||
@ -40,9 +41,5 @@ public class Pixel {
|
||||
Transformation transform = bd.getTransformation();
|
||||
transform.getScale().set(scale);
|
||||
bd.setTransformation(transform);
|
||||
|
||||
System.out.println(spawnLocation.x());
|
||||
System.out.println(spawnLocation.y());
|
||||
System.out.println(spawnLocation.z());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package eu.mhsl.minecraft.pixelblocks.pixelblock;
|
||||
|
||||
import eu.mhsl.minecraft.pixelblocks.PixelBlocks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@ -21,7 +23,7 @@ public class PixelBlock {
|
||||
BlockData block = blockLocation.getBlock().getBlockData();
|
||||
|
||||
if(block.getMaterial() != Material.AIR) {
|
||||
Pixel newPixel = new Pixel(relativeLocation, block, (1/pixelsPerBlock));
|
||||
Pixel newPixel = new Pixel(relativeLocation, block, (1/pixelsPerBlock)-0.0001, 0.00005);
|
||||
pixels.add(newPixel);
|
||||
}
|
||||
}
|
||||
@ -31,9 +33,10 @@ public class PixelBlock {
|
||||
}
|
||||
|
||||
public void place(Location placeLocation) {
|
||||
placeLocation = placeLocation.toBlockLocation();
|
||||
for(Pixel pixel : pixels) {
|
||||
pixel.spawn(placeLocation);
|
||||
}
|
||||
Bukkit.getScheduler().runTask(PixelBlocks.plugin, () -> {
|
||||
for(Pixel pixel : pixels) {
|
||||
pixel.spawn(placeLocation.toBlockLocation());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user