mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-10 06:38:35 +00:00
@ -23,12 +23,15 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.BooleanProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class SnowSimulator implements LayerFunction {
|
||||
|
||||
public static final BooleanProperty snowy = (BooleanProperty) (Property<?>) BlockTypes.GRASS_BLOCK.getProperty("snowy");
|
||||
|
||||
private final BlockState ice = BlockTypes.ICE.getDefaultState();
|
||||
private final BlockState snow = BlockTypes.SNOW.getDefaultState();
|
||||
private final BlockState snowBlock = BlockTypes.SNOW_BLOCK.getDefaultState();
|
||||
@ -42,6 +45,7 @@ public class SnowSimulator implements LayerFunction {
|
||||
private int affected;
|
||||
|
||||
public SnowSimulator(Extent extent, boolean stack) {
|
||||
|
||||
this.extent = extent;
|
||||
this.stack = stack;
|
||||
|
||||
@ -66,9 +70,8 @@ public class SnowSimulator implements LayerFunction {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Can only place on full solid blocks
|
||||
return block.getBlockType().getMaterial().isFullCube()
|
||||
&& block.getBlockType().getMaterial().isSolid();
|
||||
// Stop searching when we hit a movement blocker
|
||||
return block.getBlockType().getMaterial().isMovementBlocker();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,16 +110,25 @@ public class SnowSimulator implements LayerFunction {
|
||||
// We've hit the highest layer (If it doesn't contain current + 2 it means it's 1 away from full)
|
||||
if (!snowLayersProperty.getValues().contains(currentHeight + 2)) {
|
||||
if (this.extent.setBlock(abovePosition, snowBlock)) {
|
||||
if (block.getStates().containsKey(snowy)) {
|
||||
this.extent.setBlock(position, block.with(snowy, true));
|
||||
}
|
||||
this.affected++;
|
||||
}
|
||||
} else {
|
||||
if (this.extent.setBlock(abovePosition, above.with(snowLayersProperty, currentHeight + 1))) {
|
||||
if (block.getStates().containsKey(snowy)) {
|
||||
this.extent.setBlock(position, block.with(snowy, true));
|
||||
}
|
||||
this.affected++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (this.extent.setBlock(abovePosition, snow)) {
|
||||
if (block.getStates().containsKey(snowy)) {
|
||||
this.extent.setBlock(position, block.with(snowy, true));
|
||||
}
|
||||
this.affected++;
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user