/* * Copyright (C) 2018 BARBOTIN Nicolas */ package net.montoyo.wd.entity; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.block.state.BlockState; import net.montoyo.wd.core.ScreenRights; import net.montoyo.wd.data.SetURLData; import net.montoyo.wd.init.TileInit; import net.montoyo.wd.utilities.Util; public class TileEntityRCtrl extends TileEntityPeripheralBase { public TileEntityRCtrl(BlockPos arg2, BlockState arg3) { super(TileInit.REMOTE_CONTROLLER.get(), arg2, arg3); } @Override public InteractionResult onRightClick(Player player, InteractionHand hand) { if(level.isClientSide) return InteractionResult.SUCCESS; if(!isScreenChunkLoaded()) { Util.toast(player, "chunkUnloaded"); return InteractionResult.SUCCESS; } TileEntityScreen tes = getConnectedScreen(); if(tes == null) { Util.toast(player, "notLinked"); return InteractionResult.SUCCESS; } TileEntityScreen.Screen scr = tes.getScreen(screenSide); if((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) { Util.toast(player, "restrictions"); return InteractionResult.SUCCESS; } (new SetURLData(screenPos, screenSide, scr.url, getBlockPos())).sendTo((ServerPlayer) player); return InteractionResult.SUCCESS; } }