net.minecraftforge.fml.network.NetworkHooks Java Examples
The following examples show how to use
net.minecraftforge.fml.network.NetworkHooks.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModificationTable.java From MiningGadgets with MIT License | 5 votes |
@Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult result) { if (!world.isRemote) { TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof INamedContainerProvider) { NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tileEntity, tileEntity.getPos()); } else { throw new IllegalStateException("Our named container provider is missing!"); } return ActionResultType.SUCCESS; } return ActionResultType.SUCCESS; }
Example #2
Source File: SawmillBlock.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) { if (worldIn.isRemote) return ActionResultType.SUCCESS; TileEntity tileEntity = worldIn.getTileEntity(pos); if (!(tileEntity instanceof INamedContainerProvider)) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tileEntity); return ActionResultType.SUCCESS; }
Example #3
Source File: DryingRackBlock.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Deprecated @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult blockRayTraceResult) { if (worldIn.isRemote) return ActionResultType.SUCCESS; TileEntity tileEntity = worldIn.getTileEntity(pos); if (!(tileEntity instanceof INamedContainerProvider)) return ActionResultType.FAIL; NetworkHooks.openGui((ServerPlayerEntity) player, (INamedContainerProvider) tileEntity); return ActionResultType.SUCCESS; }
Example #4
Source File: MixinServerLoginNetworkHandler.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Inject(method = "onQueryResponse", at = @At("HEAD"), cancellable = true) private void patchwork$hookQueryResponse(LoginQueryResponseC2SPacket packet, CallbackInfo callback) { if (NetworkHooks.onCustomPayload((ICustomPacket<?>) packet, getConnection())) { callback.cancel(); } }
Example #5
Source File: MixinServerPlayNetworkHandler.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true) private void patchwork$hookCustomPayload(CustomPayloadC2SPacket packet, CallbackInfo callback) { if (NetworkHooks.onCustomPayload((ICustomPacket<?>) packet, getConnection())) { callback.cancel(); } }
Example #6
Source File: MixinClientLoginNetworkHandler.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Inject(method = "onQueryRequest", at = @At("HEAD"), cancellable = true) private void patchwork$hookQueryRequest(LoginQueryRequestS2CPacket packet, CallbackInfo callback) { if (NetworkHooks.onCustomPayload((ICustomPacket<?>) packet, getConnection())) { callback.cancel(); } }
Example #7
Source File: MixinClientPlayNetworkHandler.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true) private void patchwork$hookCustomPayload(CustomPayloadS2CPacket packet, CallbackInfo callback) { if (NetworkHooks.onCustomPayload((ICustomPacket<?>) packet, getConnection())) { callback.cancel(); } }
Example #8
Source File: RockEntity.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); }