-
Notifications
You must be signed in to change notification settings - Fork 14
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
Showing
31 changed files
with
505 additions
and
82 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
4 changes: 3 additions & 1 deletion
4
api/src/main/java/org/allaymc/api/block/interfaces/BlockBeaconBehavior.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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package org.allaymc.api.block.interfaces; | ||
|
||
import org.allaymc.api.block.BlockBehavior; | ||
import org.allaymc.api.block.component.BlockEntityHolderComponent; | ||
import org.allaymc.api.blockentity.interfaces.BlockEntityBeacon; | ||
|
||
public interface BlockBeaconBehavior extends BlockBehavior { | ||
public interface BlockBeaconBehavior extends BlockBehavior, BlockEntityHolderComponent<BlockEntityBeacon> { | ||
} |
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
64 changes: 64 additions & 0 deletions
64
api/src/main/java/org/allaymc/api/blockentity/component/BlockEntityBeaconBaseComponent.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,64 @@ | ||
package org.allaymc.api.blockentity.component; | ||
|
||
import org.allaymc.api.entity.effect.EffectType; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public interface BlockEntityBeaconBaseComponent extends BlockEntityBaseComponent { | ||
/** | ||
* Get the level of the beacon. | ||
* <p> | ||
* level is the amount of the pyramid's levels, it is defined by the mineral blocks which build up the | ||
* pyramid, and can be 0-4. | ||
* | ||
* @return the level of the beacon. | ||
*/ | ||
int getLevel(); | ||
|
||
/** | ||
* Get the primary effect of the beacon. | ||
* | ||
* @return the primary effect of the beacon, or {@code null} if no primary effect. | ||
*/ | ||
EffectType getPrimaryEffect(); | ||
|
||
/** | ||
* Set the primary effect of the beacon. | ||
* | ||
* @param effectType the primary effect of the beacon. | ||
*/ | ||
void setPrimaryEffect(EffectType effectType); | ||
|
||
/** | ||
* Check if the beacon has a primary effect. | ||
* | ||
* @return {@code true} if the beacon has a primary effect, otherwise {@code false}. | ||
*/ | ||
default boolean hasPrimaryEffect() { | ||
return getPrimaryEffect() != null; | ||
} | ||
|
||
/** | ||
* Get the secondary effect of the beacon. | ||
* | ||
* @return the secondary effect of the beacon, or {@code null} if no secondary effect. | ||
*/ | ||
EffectType getSecondaryEffect(); | ||
|
||
/** | ||
* Set the secondary effect of the beacon. | ||
* | ||
* @param effectType the secondary effect of the beacon. | ||
*/ | ||
void setSecondaryEffect(EffectType effectType); | ||
|
||
/** | ||
* Check if the beacon has a secondary effect. | ||
* | ||
* @return {@code true} if the beacon has a secondary effect, otherwise {@code false}. | ||
*/ | ||
default boolean hasSecondaryEffect() { | ||
return getSecondaryEffect() != null; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
api/src/main/java/org/allaymc/api/blockentity/interfaces/BlockEntityBeacon.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,10 @@ | ||
package org.allaymc.api.blockentity.interfaces; | ||
|
||
import org.allaymc.api.blockentity.BlockEntity; | ||
import org.allaymc.api.blockentity.component.BlockEntityBeaconBaseComponent; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public interface BlockEntityBeacon extends BlockEntity, BlockEntityBeaconBaseComponent { | ||
} |
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
24 changes: 24 additions & 0 deletions
24
api/src/main/java/org/allaymc/api/container/impl/BeaconContainer.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,24 @@ | ||
package org.allaymc.api.container.impl; | ||
|
||
import org.allaymc.api.container.FullContainerType; | ||
import org.allaymc.api.item.ItemStack; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public class BeaconContainer extends BlockContainer { | ||
public static final int BEACON_PAYMENT_SLOT = 0; | ||
|
||
public BeaconContainer() { | ||
super(FullContainerType.BEACON); | ||
} | ||
|
||
/** | ||
* Get the item stack in the payment slot. | ||
* | ||
* @return The item stack in the payment slot. | ||
*/ | ||
public ItemStack getBeaconPayment() { | ||
return this.getItemStack(BEACON_PAYMENT_SLOT); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
{} | ||
{ | ||
"allay:beacon_payment": [ | ||
"minecraft:iron_ingot", | ||
"minecraft:gold_ingot", | ||
"minecraft:diamond", | ||
"minecraft:emerald", | ||
"minecraft:netherite_ingot" | ||
] | ||
} |
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
35 changes: 35 additions & 0 deletions
35
server/src/main/java/org/allaymc/server/block/component/BlockBeaconBaseComponentImpl.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,35 @@ | ||
package org.allaymc.server.block.component; | ||
|
||
import org.allaymc.api.block.BlockBehavior; | ||
import org.allaymc.api.block.dto.PlayerInteractInfo; | ||
import org.allaymc.api.block.type.BlockType; | ||
import org.allaymc.api.container.FullContainerType; | ||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.math.position.Position3i; | ||
import org.allaymc.api.world.Dimension; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public class BlockBeaconBaseComponentImpl extends BlockBaseComponentImpl { | ||
public BlockBeaconBaseComponentImpl(BlockType<? extends BlockBehavior> blockType) { | ||
super(blockType); | ||
} | ||
|
||
@Override | ||
public boolean onInteract(ItemStack itemStack, Dimension dimension, PlayerInteractInfo interactInfo) { | ||
if (super.onInteract(itemStack, dimension, interactInfo)) { | ||
return true; | ||
} | ||
|
||
var player = interactInfo.player(); | ||
if (player.isSneaking()) { | ||
return false; | ||
} | ||
|
||
var beaconContainer = player.getContainer(FullContainerType.BEACON); | ||
beaconContainer.setBlockPos(new Position3i(interactInfo.clickedBlockPos(), interactInfo.player().getDimension())); | ||
beaconContainer.addViewer(player); | ||
return true; | ||
} | ||
} |
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.