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