mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-03 18:43:43 +01:00 
			
		
		
		
	world bounds tweak
This commit is contained in:
		@@ -292,7 +292,8 @@ public final class BlockUtils {
 | 
				
			|||||||
    public static boolean isWithinWorldBounds(@NotNull WorldCompatibilityLayer worldCompatibilityLayer, @NotNull Block block) {
 | 
					    public static boolean isWithinWorldBounds(@NotNull WorldCompatibilityLayer worldCompatibilityLayer, @NotNull Block block) {
 | 
				
			||||||
        World world = block.getWorld();
 | 
					        World world = block.getWorld();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return block.getY() > worldCompatibilityLayer.getMinWorldHeight(world) && block.getY() < worldCompatibilityLayer.getMaxWorldHeight(world);
 | 
					        //pretty sure both height and min height are able to have blocks placed on them
 | 
				
			||||||
 | 
					        return block.getY() >= worldCompatibilityLayer.getMinWorldHeight(world) && block.getY() <= worldCompatibilityLayer.getMaxWorldHeight(world);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,5 +7,5 @@ import org.jetbrains.annotations.NotNull;
 | 
				
			|||||||
public interface WorldCompatibilityLayer extends CompatibilityLayer {
 | 
					public interface WorldCompatibilityLayer extends CompatibilityLayer {
 | 
				
			||||||
    default int getMinWorldHeight(@NotNull World world) { return 0; }
 | 
					    default int getMinWorldHeight(@NotNull World world) { return 0; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    default int getMaxWorldHeight(@NotNull World world) { return 255; }
 | 
					    default int getMaxWorldHeight(@NotNull World world) { return 256; }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@ package com.gmail.nossr50.util.blockmeta;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.gmail.nossr50.TestUtil;
 | 
					import com.gmail.nossr50.TestUtil;
 | 
				
			||||||
import com.gmail.nossr50.mcMMO;
 | 
					import com.gmail.nossr50.mcMMO;
 | 
				
			||||||
 | 
					import com.gmail.nossr50.util.BlockUtils;
 | 
				
			||||||
import com.gmail.nossr50.util.compat.CompatibilityManager;
 | 
					import com.gmail.nossr50.util.compat.CompatibilityManager;
 | 
				
			||||||
import com.gmail.nossr50.util.compat.layers.world.WorldCompatibilityLayer;
 | 
					import com.gmail.nossr50.util.compat.layers.world.WorldCompatibilityLayer;
 | 
				
			||||||
import com.gmail.nossr50.util.platform.PlatformManager;
 | 
					import com.gmail.nossr50.util.platform.PlatformManager;
 | 
				
			||||||
@@ -97,6 +98,22 @@ public class ChunkStoreTest {
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //Bot Block
 | 
				
			||||||
 | 
					        TestBlock bottomBlock = new TestBlock(1337, 0, -1337, mockWorld);
 | 
				
			||||||
 | 
					        Assert.assertFalse(hashChunkManager.isTrue(bottomBlock));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Assert.assertTrue(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, bottomBlock));
 | 
				
			||||||
 | 
					        hashChunkManager.setTrue(bottomBlock);
 | 
				
			||||||
 | 
					        Assert.assertTrue(hashChunkManager.isTrue(bottomBlock));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //Top Block
 | 
				
			||||||
 | 
					        TestBlock topBlock = new TestBlock(1337, 256, -1337, mockWorld);
 | 
				
			||||||
 | 
					        Assert.assertFalse(hashChunkManager.isTrue(topBlock));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Assert.assertTrue(BlockUtils.isWithinWorldBounds(worldCompatibilityLayer, topBlock));
 | 
				
			||||||
 | 
					        hashChunkManager.setTrue(topBlock);
 | 
				
			||||||
 | 
					        Assert.assertTrue(hashChunkManager.isTrue(topBlock));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Test
 | 
					    @Test
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user