-
Notifications
You must be signed in to change notification settings - Fork 101
Oxygen 2 #517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Oxygen 2 #517
Changes from 26 commits
cace5b8
f115ede
978b818
d9e5334
e1b3cbf
4dc8ac3
2d0d6a8
4bc2b87
68570e2
e738384
45bf444
43ed6e3
e4c837b
ee8a7b3
2edc0e6
9d66199
51860b7
ec77e8d
715e7a8
bfc79c8
a5b498c
456257c
3180a33
7781788
f04a888
0d98a22
b7e2fe5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Copyright (c) 2019-2025 Team Galacticraft | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| package dev.galacticraft.api.accessor; | ||
|
|
||
| import dev.galacticraft.api.block.entity.AtmosphereProvider; | ||
| import net.minecraft.core.BlockPos; | ||
|
|
||
| import java.util.Iterator; | ||
|
|
||
| public interface ChunkOxygenAccessor { | ||
| /** | ||
| * {@return the {@link AtmosphereProvider atmosphere providers} that service the chunk section at the given y-position} | ||
| * @param y the block y-height of the section to check. | ||
| */ | ||
| Iterator<AtmosphereProvider> galacticraft$getProviders(int y); | ||
|
|
||
| /** | ||
| * {@return the positions of the {@link AtmosphereProvider atmosphere providers} that service the chunk section at the given y-position} | ||
| * @param y the block y-height of the section to check. | ||
| */ | ||
| Iterator<BlockPos> galacticraft$getProviderPositions(int y); | ||
|
|
||
| /** | ||
| * Links the given atmosphere provider to the chunk section at the given index. | ||
| * @param sectionIndex the index of the chunk section being provided to. | ||
| * @param provider the location of the atmosphere provider being linked. | ||
| */ | ||
| void galacticraft$addAtmosphereProvider(int sectionIndex, BlockPos provider); | ||
|
|
||
| /** | ||
| * Unlinks the given atmosphere provider to the chunk section at the given index. | ||
| * @param sectionIndex the index of the chunk section that is no longer being provided to. | ||
| * @param provider the location of the atmosphere provider being unlinked. | ||
| */ | ||
| void galacticraft$removeAtmosphereProvider(int sectionIndex, BlockPos provider); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Copyright (c) 2019-2025 Team Galacticraft | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| package dev.galacticraft.api.accessor; | ||
|
|
||
| import dev.galacticraft.api.block.entity.AtmosphereProvider; | ||
| import dev.galacticraft.api.oxygen.OxygenUtil; | ||
| import net.minecraft.core.BlockPos; | ||
| import net.minecraft.server.level.ServerLevel; | ||
| import net.minecraft.world.level.block.state.BlockState; | ||
|
|
||
| import java.util.Iterator; | ||
|
|
||
| public interface GCBlockExtensions { | ||
| /** | ||
| * {@return whether this block will transform on placement due to a lack of atmosphere} | ||
| * This should only be implemented if it is not possible to handle the transformation elsewhere. | ||
| * @param state the state being placed | ||
| */ | ||
| default boolean galacticraft$hasLegacyExtinguishTransform(BlockState state) { | ||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Extinguishes the given state due to a lack of atmosphere. | ||
| * @param pos the position of the block in-world | ||
| * @param state the state being placed | ||
| * @return the transformed block state. | ||
| */ | ||
| default BlockState galacticraft$extinguishBlockPlace(BlockPos pos, BlockState state) { | ||
| return state; | ||
| } | ||
|
|
||
| /** | ||
| * {@return whether the given block state needs to be alerted to changes in atmospheric composition} | ||
| * @param state the state being checked | ||
| */ | ||
| default boolean galacticraft$hasAtmosphereListener(BlockState state) { | ||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Called when the atmospheric composition changes. | ||
| * @param level the current level | ||
| * @param pos the position of the block | ||
| * @param state the current state of the block | ||
| * @param iterator all atmosphere providers at the given position | ||
| * @see #galacticraft$onAtmosphereChange(ServerLevel, BlockPos, BlockState, boolean) | ||
| */ | ||
| default void galacticraft$onAtmosphereChange(ServerLevel level, BlockPos pos, BlockState state, Iterator<AtmosphereProvider> iterator) { | ||
| this.galacticraft$onAtmosphereChange(level, pos, state, OxygenUtil.isBreathable(pos, iterator)); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Called when the atmospheric composition changes. | ||
| * For blocks that just need to know if the position is breathable or not. Should NOT be called outside this class. | ||
| * @param level the current level | ||
| * @param pos the position of the block | ||
| * @param state the current state of the block | ||
| * @param breathable whether the given position is currently breathable | ||
| * @see #galacticraft$onAtmosphereChange(ServerLevel, BlockPos, BlockState, Iterator) | ||
| */ | ||
| default void galacticraft$onAtmosphereChange(ServerLevel level, BlockPos pos, BlockState state, boolean breathable) { | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * Copyright (c) 2019-2025 Team Galacticraft | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| package dev.galacticraft.api.accessor; | ||
|
|
||
| import dev.galacticraft.api.block.entity.AtmosphereProvider; | ||
| import net.minecraft.core.BlockPos; | ||
| import net.minecraft.world.phys.Vec3; | ||
|
|
||
| import java.util.Iterator; | ||
|
|
||
| public interface LevelOxygenAccessorRO { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does the RO stand for, out of curiosity?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It stands for read-only. The interface is split so that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, that makes sense. Don't feel you have to rename it, but a comment saying read-only might be nice. |
||
| /** | ||
| * {@return the atmosphere providers for the given block position} | ||
| */ | ||
| default Iterator<AtmosphereProvider> galacticraft$getAtmosphereProviders(int x, int y, int z) { | ||
| throw new RuntimeException("This should be overridden by mixin!"); | ||
| } | ||
|
|
||
| /** | ||
| * {@return the positions of the atmosphere providers for the given block position} | ||
| */ | ||
| default Iterator<BlockPos> galacticraft$getAtmosphereProviderLocations(int x, int y, int z) { | ||
| throw new RuntimeException("This should be overridden by mixin!"); | ||
| } | ||
|
|
||
| /** | ||
| * {@return whether the given point in the level is breathable} | ||
| */ | ||
| default boolean galacticraft$isBreathable(double x, double y, double z) { | ||
| throw new RuntimeException("This should be overridden by mixin!"); | ||
| } | ||
|
|
||
| /** | ||
| * {@return whether the block position in the level is breathable} | ||
| * It is undefined whether partially breathable block positions are breathable or not. | ||
| */ | ||
| default boolean galacticraft$isBreathable(int x, int y, int z) { | ||
| throw new RuntimeException("This should be overridden by mixin!"); | ||
| } | ||
|
|
||
| /** | ||
| * {@return whether the block position in the level is breathable} | ||
| * It is undefined whether partially breathable block positions are breathable or not. | ||
| */ | ||
| default boolean galacticraft$isBreathable(BlockPos pos) { | ||
| throw new RuntimeException("This should be overridden by mixin!"); | ||
| } | ||
|
|
||
| /** | ||
| * {@return whether this has a breathable atmosphere} | ||
| */ | ||
| default boolean galacticraft$isBreathable() { | ||
| throw new RuntimeException("This should be overridden by mixin!"); | ||
| } | ||
|
|
||
| default boolean galacticraft$isBreathable(Vec3 point) { | ||
| return this.galacticraft$isBreathable(point.x, point.y, point.z); | ||
| } | ||
|
|
||
| default Iterator<BlockPos> galacticraft$getAtmosphereProviderLocations(BlockPos pos) { | ||
| return this.galacticraft$getAtmosphereProviderLocations(pos.getX(), pos.getY(), pos.getZ()); | ||
| } | ||
|
|
||
| default Iterator<AtmosphereProvider> galacticraft$getAtmosphereProviders(BlockPos pos) { | ||
| return this.galacticraft$getAtmosphereProviders(pos.getX(), pos.getY(), pos.getZ()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Copyright (c) 2019-2025 Team Galacticraft | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in all | ||
| * copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| * SOFTWARE. | ||
| */ | ||
|
|
||
| package dev.galacticraft.api.block.entity; | ||
|
|
||
| import net.minecraft.core.BlockPos; | ||
| import net.minecraft.world.level.block.entity.BlockEntity; | ||
| import net.minecraft.world.level.block.state.BlockState; | ||
|
|
||
| /** | ||
| * Describes a {@link BlockEntity} that generates an atmosphere somewhere in the world. | ||
| * | ||
| * @see dev.galacticraft.api.accessor.LevelOxygenAccessor | ||
| * @see dev.galacticraft.api.accessor.ChunkOxygenAccessor | ||
| */ | ||
| public interface AtmosphereProvider { | ||
| /** | ||
| * {@return whether the given point is breathable} | ||
| * @param x the x-coordinate to check | ||
| * @param y the y-coordinate to check | ||
| * @param z the z-coordinate to check | ||
| */ | ||
| boolean canBreathe(double x, double y, double z); | ||
|
|
||
| /** | ||
| * {@return whether the given block position is breathable} | ||
| * It is not defined where within the block is (or is not) breathable. | ||
| * @param x the x-position to check | ||
| * @param y the y-position to check | ||
| * @param z the z-position to check | ||
| */ | ||
| default boolean canBreathe(int x, int y, int z) { | ||
| return this.canBreathe(new BlockPos(x, y, z)); | ||
| } | ||
|
|
||
| /** | ||
| * {@return whether the given block position is breathable} | ||
| * It is not defined where within the block is (or is not) breathable. | ||
| * @param pos the position to check | ||
| */ | ||
| boolean canBreathe(BlockPos pos); | ||
|
|
||
| /** | ||
| * Called when a block state is updated within a chunk that has this atmosphere provider attached. | ||
| * @param pos the position of block that was changed | ||
| * @param newState the new state being placed at the position. | ||
| */ | ||
| void notifyStateChange(BlockPos pos, BlockState newState); | ||
|
|
||
| /** | ||
| * Helper method to get a block entity instance. | ||
| * @return {@code this} | ||
| */ | ||
| default BlockEntity be() { | ||
| return (BlockEntity) this; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.