-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs to classes/interfaces, add support for server side light sou…
…rces (experimental)
- Loading branch information
Showing
22 changed files
with
335 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package eu.pb4.polymer.block; | ||
|
||
import eu.pb4.polymer.mixin.block.AbstractBlockAccessor; | ||
import eu.pb4.polymer.mixin.block.AbstractBlockSettingAccessor; | ||
import it.unimi.dsi.fastutil.objects.Object2BooleanArrayMap; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
|
||
import java.util.function.ToIntFunction; | ||
|
||
public class BlockHelper { | ||
private static Object2BooleanArrayMap<Block> IS_LIGHT_SOURCE_CACHE = new Object2BooleanArrayMap(); | ||
|
||
public static boolean isLightSource(Block block) { | ||
if (BlockHelper.IS_LIGHT_SOURCE_CACHE.containsKey(block)) { | ||
return BlockHelper.IS_LIGHT_SOURCE_CACHE.getBoolean(block); | ||
} else { | ||
ToIntFunction<BlockState> luminance = ((AbstractBlockSettingAccessor) ((AbstractBlockAccessor) block).getSettings()).getLuminance(); | ||
|
||
for (BlockState state : block.getStateManager().getStates()) { | ||
if (luminance.applyAsInt(state) != 0) { | ||
BlockHelper.IS_LIGHT_SOURCE_CACHE.put(block, true); | ||
return true; | ||
} | ||
} | ||
|
||
BlockHelper.IS_LIGHT_SOURCE_CACHE.put(block, false); | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
package eu.pb4.polymer.interfaces; | ||
|
||
// Used to mark general virtual objects like BlockEntities, Enchantments, Recipe Serializers, etc | ||
/** | ||
* Used to mark general virtual objects like BlockEntities, Enchantments, Recipe Serializers, etc | ||
* | ||
* Doesn't implement anything by itself | ||
*/ | ||
public interface VirtualObject {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/eu/pb4/polymer/mixin/block/AbstractBlockAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package eu.pb4.polymer.mixin.block; | ||
|
||
import net.minecraft.block.AbstractBlock; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
@Mixin(AbstractBlock.class) | ||
public interface AbstractBlockAccessor { | ||
@Accessor("settings") | ||
AbstractBlock.Settings getSettings(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.