generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24534e4
commit 3a83a9f
Showing
15 changed files
with
152 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
59 changes: 59 additions & 0 deletions
59
...ain/java/io/github/lunathelemon/territorial/block/entity/CorruptedPyramidBlockEntity.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,59 @@ | ||
package io.github.lunathelemon.territorial.block.entity; | ||
|
||
import io.github.lunathelemon.territorial.block.TerritorialBlocks; | ||
import io.github.lunathelemon.territorial.init.TerritorialTags; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.entity.BlockEntity; | ||
import net.minecraft.block.entity.BlockEntityType; | ||
import net.minecraft.util.math.BlockPos; | ||
|
||
public abstract class CorruptedPyramidBlockEntity extends BlockEntity { | ||
private static final int[] beaconSizes = { 9, 34, 83, 164 }; | ||
protected Block mainPyramidBlock = TerritorialBlocks.OMNISCIENT_OBSIDIAN; | ||
protected float mainBlockFormationThreshold = 0.5f; | ||
|
||
public CorruptedPyramidBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) { | ||
super(type, pos, state); | ||
} | ||
|
||
protected int updateLevel() { | ||
final int bottomY = world.getBottomY(); | ||
|
||
int level = 0, mainPyramidBlockCount = 0, y, xPos, zPos; | ||
BlockState currentState; | ||
|
||
// Decrement the y value to check the blocks below | ||
for(int yInc = 1; yInc <= 4; level = yInc++) { | ||
y = pos.getY() - yInc; | ||
// If we reach the bottom of the world exist early | ||
if(y < bottomY) | ||
break; | ||
else { | ||
xPos = pos.getX(); | ||
zPos = pos.getZ(); | ||
// Check each slice of blocks below in the same way a beacon would | ||
for(int x = xPos - yInc; x <= xPos + yInc; ++x) { | ||
for(int z = zPos - yInc; z <= zPos + yInc; ++z) { | ||
currentState = world.getBlockState(new BlockPos(x, y, z)); | ||
|
||
// Return the current level if a new block cannot be found | ||
if(!currentState.isIn(TerritorialTags.Blocks.CORRUPTED_PYRAMID)) { | ||
return checkFormationThreshold(mainPyramidBlockCount, level); | ||
} else if(currentState.getBlock().equals(mainPyramidBlock)) { | ||
mainPyramidBlockCount++; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
return checkFormationThreshold(mainPyramidBlockCount, level); | ||
} | ||
|
||
protected int checkFormationThreshold(int mainPyramidBlockCount, int level) { | ||
if(mainBlockFormationThreshold > 0 && level > 0) | ||
return (float) mainPyramidBlockCount / beaconSizes[level-1] >= mainBlockFormationThreshold ? level : 0; | ||
else | ||
return level; | ||
} | ||
} |
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
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
15 changes: 15 additions & 0 deletions
15
src/main/java/io/github/lunathelemon/territorial/init/TerritorialTags.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,15 @@ | ||
package io.github.lunathelemon.territorial.init; | ||
|
||
import io.github.lunathelemon.territorial.Territorial; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.registry.tag.TagKey; | ||
|
||
public class TerritorialTags { | ||
|
||
public static class Blocks { | ||
public static final TagKey<Block> CORRUPTED_PYRAMID = TagKey.of(RegistryKeys.BLOCK, Territorial.getID("corrupted_pyramid")); | ||
} | ||
|
||
public static class Items {} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
src/main/resources/data/territorial/tags/blocks/corrupted_pyramid.json
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,8 @@ | ||
{ | ||
"replace": false, | ||
"values": [ | ||
"minecraft:obsidian", | ||
"minecraft:crying_obsidian", | ||
"territorial:omniscient_obsidian" | ||
] | ||
} |