use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity in project ResourcefulBees by Resourceful-Bees.
the class HoneyDipper method useOn.
@Override
@NotNull
public InteractionResult useOn(@NotNull UseOnContext useContext) {
if (!useContext.getLevel().isClientSide()) {
Block clickedBlock = useContext.getLevel().getBlockState(useContext.getClickedPos()).getBlock();
if (selectedBee instanceof CustomBeeEntity) {
CoreData beeData = ((CustomBeeEntity) selectedBee).getCoreData();
if (!beeData.getBlockFlowers().isEmpty() && beeData.getBlockFlowers().contains(clickedBlock)) {
setFlowerPosition(useContext);
return InteractionResult.SUCCESS;
}
} else if (selectedBee != null && clickedBlock.is(BlockTags.FLOWERS)) {
setFlowerPosition(useContext);
return InteractionResult.SUCCESS;
}
BlockEntity clickedTile = useContext.getLevel().getBlockEntity(useContext.getClickedPos());
if (selectedBee != null && (clickedTile instanceof BeehiveBlockEntity || clickedTile instanceof ApiaryTileEntity)) {
selectedBee.hivePos = useContext.getClickedPos();
sendMessageToPlayer(useContext.getPlayer(), MessageTypes.HIVE, useContext.getClickedPos());
selectedBee = null;
return InteractionResult.SUCCESS;
}
}
return super.useOn(useContext);
}
use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity in project ResourcefulBees by Resourceful-Bees.
the class ExportBeeMessage method handle.
public static void handle(ExportBeeMessage message, Supplier<NetworkEvent.Context> context) {
context.get().enqueueWork(() -> {
ServerPlayer player = context.get().getSender();
if (player != null && player.level.isLoaded(message.pos)) {
BlockEntity tileEntity = player.level.getBlockEntity(message.pos);
if (tileEntity instanceof ApiaryTileEntity) {
ApiaryTileEntity apiaryTileEntity = (ApiaryTileEntity) tileEntity;
apiaryTileEntity.exportBee(player, message.beeType);
}
}
});
context.get().setPacketHandled(true);
}
use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity in project ResourcefulBees by Resourceful-Bees.
the class ImportBeeMessage method handle.
public static void handle(ImportBeeMessage message, Supplier<NetworkEvent.Context> context) {
context.get().enqueueWork(() -> {
ServerPlayer player = context.get().getSender();
if (player != null && player.level.isLoaded(message.pos)) {
BlockEntity tileEntity = player.level.getBlockEntity(message.pos);
if (tileEntity instanceof ApiaryTileEntity) {
ApiaryTileEntity apiaryTileEntity = (ApiaryTileEntity) tileEntity;
apiaryTileEntity.importBee(player);
}
}
});
context.get().setPacketHandled(true);
}
use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity in project ResourcefulBees by Resourceful-Bees.
the class ApiaryBlock method setPlacedBy.
@Override
public void setPlacedBy(Level worldIn, @NotNull BlockPos pos, @NotNull BlockState state, @Nullable LivingEntity placer, @NotNull ItemStack stack) {
BlockEntity tile = worldIn.getBlockEntity(pos);
if (tile instanceof ApiaryTileEntity) {
ApiaryTileEntity apiaryTileEntity = (ApiaryTileEntity) tile;
apiaryTileEntity.setTier(tier);
}
}
use of com.teamresourceful.resourcefulbees.tileentity.multiblocks.apiary.ApiaryTileEntity in project ResourcefulBees by Resourceful-Bees.
the class MixinEnterBeehiveGoal method start.
/**
* @author epic_oreo
* @reason crashes when switching to vanilla code due to hivePos being null. retained vanilla checks in overwrite.
*/
@Overwrite()
public void start() {
if (beeEntity.hivePos != null) {
BlockEntity tileentity = beeEntity.level.getBlockEntity(beeEntity.hivePos);
if (tileentity != null) {
if (tileentity instanceof BeehiveBlockEntity) {
BeehiveBlockEntity beehivetileentity = (BeehiveBlockEntity) tileentity;
beehivetileentity.addOccupant(beeEntity, beeEntity.hasNectar());
} else if (tileentity instanceof ApiaryTileEntity) {
ApiaryTileEntity apiaryTileEntity = (ApiaryTileEntity) tileentity;
apiaryTileEntity.tryEnterHive(beeEntity, beeEntity.hasNectar(), false);
}
}
}
}
Aggregations