use of net.minecraft.inventory.container.INamedContainerProvider in project AgriCraft by AgriCraft.
the class GuiPlugin method onSeedAnalyzerRightClick.
public void onSeedAnalyzerRightClick(PlayerInteractEvent.RightClickBlock event) {
BlockPos pos = event.getPos();
BlockState state = event.getWorld().getBlockState(pos);
if (event.getPlayer().isSneaking()) {
return;
}
if (state.getBlock() != AgriCraft.instance.getModBlockRegistry().seed_analyzer.getBlock()) {
return;
}
event.setCancellationResult(ActionResultType.SUCCESS);
event.setCanceled(true);
if (event.getPlayer().world.isRemote) {
return;
}
INamedContainerProvider containerProvider = new INamedContainerProvider() {
@Nonnull
@Override
public ITextComponent getDisplayName() {
return new TranslationTextComponent("screen.agricraft.seed_analyzer");
}
@Override
public Container createMenu(int id, @Nonnull PlayerInventory playerInventory, @Nonnull PlayerEntity player) {
return new SeedAnalyzerContainer(id, event.getWorld(), playerInventory, pos);
}
};
NetworkHooks.openGui((ServerPlayerEntity) event.getPlayer(), containerProvider, pos);
}
Aggregations