use of lumien.randomthings.tileentity.TileEntityChatDetector in project Random-Things by lumien231.
the class RTEventHandler method chatEvent.
@SubscribeEvent
public void chatEvent(ServerChatEvent event) {
EntityPlayerMP player = event.getPlayer();
BlockPos below = player.getPosition().down();
IBlockState state = player.world.getBlockState(below);
ItemStack flooDust = player.getHeldItemMainhand();
if (!player.world.getEntitiesWithinAABB(EntityTemporaryFlooFireplace.class, player.getEntityBoundingBox().grow(0.5)).isEmpty()) {
String target = event.getMessage();
FlooNetworkHandler networkHandler = FlooNetworkHandler.get(player.world);
boolean success = networkHandler.teleport(player.world, null, null, player, target);
if (success) {
event.setCanceled(true);
}
} else if ((player.capabilities.isCreativeMode || (!flooDust.isEmpty() && flooDust.getItem() instanceof ItemIngredient && flooDust.getItemDamage() == ItemIngredient.INGREDIENT.FLOO_POWDER.id)) && state.getBlock() == ModBlocks.flooBrick) {
String target = event.getMessage();
TileEntityFlooBrick te = (TileEntityFlooBrick) player.world.getTileEntity(below);
UUID firePlaceUUID = te.getFirePlaceUid();
if (firePlaceUUID != null) {
FlooNetworkHandler networkHandler = FlooNetworkHandler.get(player.world);
TileEntity masterTE = networkHandler.getFirePlaceTE(player.world, firePlaceUUID);
if (masterTE instanceof TileEntityFlooBrick) {
TileEntityFlooBrick masterBrick = ((TileEntityFlooBrick) masterTE);
if (masterBrick.isMaster()) {
boolean success = networkHandler.teleport(player.world, masterBrick.getPos(), masterBrick, player, target);
if (success) {
if (!player.capabilities.isCreativeMode) {
flooDust.shrink(1);
}
}
event.setCanceled(true);
}
}
}
return;
}
if (!(player instanceof FakePlayer) && player.getGameProfile() != null) {
Iterator<TileEntityChatDetector> iterator = TileEntityChatDetector.detectors.iterator();
while (iterator.hasNext()) {
TileEntityChatDetector chatDetector = iterator.next();
if (chatDetector.isInvalid()) {
iterator.remove();
} else {
if (chatDetector.checkMessage(event.getPlayer(), event.getMessage())) {
event.setCanceled(true);
}
}
}
Iterator<TileEntityGlobalChatDetector> iteratorGlobal = TileEntityGlobalChatDetector.detectors.iterator();
while (iteratorGlobal.hasNext()) {
TileEntityGlobalChatDetector chatDetector = iteratorGlobal.next();
if (chatDetector.isInvalid()) {
iteratorGlobal.remove();
} else {
if (chatDetector.checkMessage(event.getPlayer(), event.getMessage())) {
event.setCanceled(true);
}
}
}
}
}
use of lumien.randomthings.tileentity.TileEntityChatDetector in project Random-Things by lumien231.
the class BlockChatDetector method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
if (!worldIn.isRemote && placer != null && placer instanceof EntityPlayerMP && worldIn.getTileEntity(pos) != null) {
EntityPlayerMP player = (EntityPlayerMP) placer;
((TileEntityChatDetector) worldIn.getTileEntity(pos)).setPlayerUUID(player.getGameProfile().getId());
}
}
Aggregations