Minecraft Forge Item Block Render Issue - java

I am having an item block rendering issue, as when I place the block, it renders correctly, but when I hold it in my hand, it has a missing texture/model.
An image of what I see is in the link: http://i.stack.imgur.com/atq1L.png
I have checked many times for the reason, and there is no error message in the console, there does not appear to be any problems with the JSON formatting, and there seems to be no problem in the code.
*By the way, the code for the block class is not too important because it is just a class that extends *Block.class, then gives the super with Material.stone
Here is my code for my blocks class:
package com.kraftymods.luckyblocks.init;
import com.kraftymods.luckyblocks.blocks.LuckyBlock;
import com.kraftymods.luckyblocks.blocks.itemblocks.LuckyBlockItem;
import com.kraftymods.luckyblocks.main.Reference;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class Blocks {
public static Block luckyblock;
public static void init(){
luckyblock = new LuckyBlock().setUnlocalizedName("luckyblock")[enter image description here][1].setCreativeTab(CreativeTabs.tabMisc);
}
public static void register(){
GameRegistry.registerBlock(luckyblock, LuckyBlockItem.class, luckyblock.getUnlocalizedName().substring(5));
}
public static void registerRenders(){
registerRender(luckyblock);
}
private static void registerRender(Block block){
Item item = Item.getItemFromBlock(block);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
}
Here is the code for my JSON files:
Blockdata:
{
"variants": {
"normal": { "model": "luckyblocks:luckyblock" }
}
}
Block Model:
{
"parent": "block/cube_all",
"textures": {
"all": "luckyblocks:blocks/luckyblock"
}
}
Item Model:
{
"parent": "luckyblocks:block/luckyblock",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}
I appreciate the time you took to read this

Please make a class for clientside purposes in which you register your renderers
I have this for example:
public final class BlockRenderRegister {
public static void registerBlockRenderer() {
register(BlocksLibrary.blockDarkStone);
}
public static void register(Block block) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
.register(Item.getItemFromBlock(block),
0,
new ModelResourceLocation(
ModHooks.MODID.toLowerCase() + ":" + BlocksLibrary.DARKSTONE,
"inventory"
)
);
}
}
And for loading your blocks I also suggest a seperate class(just for maintenance purposes
public class BlockLoader {
/**
* Loads all blocks into memory
* and populates the BlocksLibary
* with decent values.
*/
public static void loadBlocks() {
GameRegistry.registerBlock(
BlocksLibrary.blockDarkStone = new BlockDarkStone(Material.rock),
BlocksLibrary.DARKSTONE
);
}
}
I register the blocks in the PreInit event so the game knows my blocks.
#EventHandler
public void preInit(FMLPreInitializationEvent e) {
BlockLoader.loadBlocks();
}
And I call this from the FMLInitializationEvent in my main mod class to register the renderers.
#EventHandler
public void init(FMLInitializationEvent event) {
BlockRenderRegister.registerBlockRenderer();
}

Related

Can't get react-native application working in kiosk mode

Somehow I'm not able to build my application in kiosk mode. I'm able to hide status and navigation bar, but not permanent. I want to lock the app and permanently hide the System UI when the app is active without using a 3rd party-app or system setting.
First of all I've tried the NPM packages since they are (sometimes) really helpful and easy to implement. I've tried https://www.npmjs.com/package/react-native-immersive-mode and https://www.npmjs.com/package/react-native-kiosk-mode
They both didn't work since I had to edit the classes. I did followed all the steps and followed them as instructed. Somehow my build always ends in 🤖 Android build failed: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
I have to be honest, I'm not sure how to find the logs...
I'm using Expo to create, test and build my applications. Would be even greater if I can test kiosk mode in expo go. For now; my app is almost a default initialization when creating a project. Since I first want to create the kiosk functionality without my own code, to make sure there is no error in the actual code.
Currrently my MainApplication.java is default, whenever I add something the build always ends in the same error 🤖 Android build failed: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.:
package com.lavacode.BlocksLauncher;
import android.os.Build;
import android.os.Bundle;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import expo.modules.ReactActivityDelegateWrapper;
public class MainActivity extends ReactActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
// Set the theme to AppTheme BEFORE onCreate to support
// coloring the background, status bar, and navigation bar.
// This is required for expo-splash-screen.
setTheme(R.style.AppTheme);
super.onCreate(null);
}
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
#Override
protected String getMainComponentName() {
return "main";
}
/**
* Returns the instance of the {#link ReactActivityDelegate}. There the RootView is created and
* you can specify the renderer you wish to use - the new renderer (Fabric) or the old renderer
* (Paper).
*/
#Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
new MainActivityDelegate(this, getMainComponentName())
);
}
/**
* Align the back button behavior with Android S
* where moving root activities to background instead of finishing activities.
* #see onBackPressed
*/
#Override
public void invokeDefaultOnBackPressed() {
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.R) {
if (!moveTaskToBack(false)) {
// For non-root activities, use the default implementation to finish them.
super.invokeDefaultOnBackPressed();
}
return;
}
// Use the default back button implementation on Android S
// because it's doing more than {#link Activity#moveTaskToBack} in fact.
super.invokeDefaultOnBackPressed();
}
public static class MainActivityDelegate extends ReactActivityDelegate {
public MainActivityDelegate(ReactActivity activity, String mainComponentName) {
super(activity, mainComponentName);
}
#Override
protected ReactRootView createRootView() {
ReactRootView reactRootView = new ReactRootView(getContext());
// If you opted-in for the New Architecture, we enable the Fabric Renderer.
reactRootView.setIsFabric(BuildConfig.IS_NEW_ARCHITECTURE_ENABLED);
return reactRootView;
}
#Override
protected boolean isConcurrentRootEnabled() {
// If you opted-in for the New Architecture, we enable Concurrent Root (i.e. React 18).
// More on this on https://reactjs.org/blog/2022/03/29/react-v18.html
return BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
}
}
}
MainApplication.java
package com.lavacode.BlocksLauncher;
import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import androidx.annotation.NonNull;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.soloader.SoLoader;
import com.lavacode.BlocksLauncher.newarchitecture.MainApplicationReactNativeHost;
import expo.modules.ApplicationLifecycleDispatcher;
import expo.modules.ReactNativeHostWrapper;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
this,
new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
});
private final ReactNativeHost mNewArchitectureNativeHost =
new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this));
#Override
public ReactNativeHost getReactNativeHost() {
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
return mNewArchitectureNativeHost;
} else {
return mReactNativeHost;
}
}
#Override
public void onCreate() {
super.onCreate();
// If you opted-in for the New Architecture, we enable the TurboModule system
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
ApplicationLifecycleDispatcher.onApplicationCreate(this);
}
#Override
public void onConfigurationChanged(#NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
}
/**
* Loads Flipper in React Native templates. Call this in the onCreate method with something like
* initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
*
* #param context
* #param reactInstanceManager
*/
private static void initializeFlipper(
Context context, ReactInstanceManager reactInstanceManager) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.lavacode.BlocksLauncher.ReactNativeFlipper");
aClass
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
.invoke(null, context, reactInstanceManager);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
And my app.json where I did manage to hide the bars as best as possible
{
"expo": {
"name": "BlocksLauncher",
"slug": "BlocksLauncher",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.lavacode.BlocksLauncher"
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.lavacode.BlocksLauncher"
},
"web": {
"favicon": "./assets/favicon.png"
},
"extra": {
"eas": {
"projectId": "-"
}
},
"androidNavigationBar": {
"visible": "sticky-immersive"
}
}
}
Are there any tips to achieve this? I've been reading a lot about this subject a couple of days already, so I did researched a lot.

Block texture load only when placed, but not in inventory

I've read some other 'similar' questions but their problems is exactly the opposite. I've also read the docs but they won't provide anything useful to this problem.
When I /give myself the block, it shows a missing texture in my inventory as a item. But when I place it, its texture is shown in the world as a block.
Screenshot:
Main mod class:
package com.byethost8.code2828.mcmods.chemc;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.OreBlock;
import net.minecraft.block.material.Material;
import net.minecraft.block.material.MaterialColor;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item.Properties;
import net.minecraft.item.ItemGroup;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
#Mod(CheMC_.modid)
public class CheMC_ {
public static final String modid = "chemc";
public static OreBlock ore_lithium = (OreBlock) new OreBlock(
AbstractBlock.Properties
.create(Material.ROCK, MaterialColor.PINK_TERRACOTTA)
.harvestLevel(1)
.hardnessAndResistance(1, 1)
.setLightLevel(
light -> {
return 1;
}
)
)
.setRegistryName("chemc", "lithium_ore");
public static BlockItem i_ore_lithium = (BlockItem) new BlockItem(
ore_lithium,
new Properties().group(ItemGroup.BUILDING_BLOCKS)
)
.setRegistryName(ore_lithium.getRegistryName());
public static Block block_lithium = new Block(
AbstractBlock.Properties
.create(Material.IRON, MaterialColor.PINK_TERRACOTTA)
.harvestLevel(1)
.hardnessAndResistance(1.2F, 1)
.setLightLevel(
light -> {
return 1;
}
)
)
.setRegistryName("chemc", "lithium_block");
public static BlockItem i_block_lithium = (BlockItem) new BlockItem(
block_lithium,
new Properties().group(ItemGroup.BUILDING_BLOCKS)
)
.setRegistryName(block_lithium.getRegistryName());
public CheMC_() {
FMLJavaModLoadingContext
.get()
.getModEventBus()
.addListener(this::setup);
MinecraftForge.EVENT_BUS.register(this);
}
private void setup(final FMLCommonSetupEvent event) {}
// You can use EventBusSubscriber to automatically subscribe events on the
// contained class (this is subscribing to the MOD
// Event bus for receiving Registry Events)
#Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public static class RegistryEvents {
#SubscribeEvent
public static void onBlocksRegistry(
final RegistryEvent.Register<Block> blockRegistryEvent
) {
// register a new block here
blockRegistryEvent
.getRegistry()
.registerAll(ore_lithium, block_lithium);
}
}
}
Some codes are removed to make the main problem clear.
Following texts only will say about Lithium Block, but same things apply for Lithium Ore.
Model File:
{
"parent": "block/cube_all",
"textures": {
"all": "chemc:block/lithium_block"
}
}
Folder structure of src/main/resources:
Blockstate:
{
"variants": {
"": [
{ "model": "chemc:block/lithium_block" }
]
}
}
I can't believe that I was stupid enough to register a Item and do nothing to assets/chemc/resources/models/item/ folder. See this for more. I have the exactly same problem as that OP.

Flink SerializationSchema: Could not serialize row error

I have some trouble using flink's SerializationSchema.
Here is my main code :
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DeserializationSchema<Row> sourceDeserializer = new JsonRowDeserializationSchema.Builder( /*Extract TypeInformation<Row> from an avsc schema file*/ ).build();
DataStream<Row> myDataStream = env.addSource( new MyCustomSource(sourceDeserializer) ) ;
final SinkFunction<Row> sink = new MyCustomSink(new JsonRowSerializationSchema.Builder(myDataStream.getType()).build());
myDataStream.addSink(sink).name("MyCustomSink");
env.execute("MyJob");
Here is my custom Sink Function :
import org.apache.flink.api.common.serialization.SerializationSchema;
import org.apache.flink.streaming.api.functions.sink.SinkFunction;
import org.apache.flink.types.Row;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
#SuppressWarnings("serial")
public class MyCustomSink implements SinkFunction<Row> {
private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomSink.class);
private final boolean print;
private final SerializationSchema<Row> serializationSchema;
public MyCustomSink(final SerializationSchema<Row> serializationSchema) {
this.serializationSchema = serializationSchema;
}
#Override
public void invoke(final Row value, final Context context) throws Exception {
try {
LOGGER.info("MyCustomSink- invoke : [{}]", new String(serializationSchema.serialize(value)));
}catch (Exception e){
LOGGER.error("MyCustomSink- Error while sending data : " + e);
}
}
}
And here is my custom Source Function (not sure it is useful for the problem I have) :
import org.apache.flink.api.common.serialization.DeserializationSchema;
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.typeutils.ResultTypeQueryable;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.shaded.guava18.com.google.common.io.ByteStreams;
import org.apache.flink.streaming.api.functions.source.RichSourceFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MyCustomSource<T> extends RichSourceFunction<T> implements ResultTypeQueryable<T> {
/** logger */
private static final Logger LOGGER = LoggerFactory.getLogger(MyCustomSource.class);
/** the JSON deserializer */
private final DeserializationSchema<T> deserializationSchema;
public MyCustomSource(final DeserializationSchema<T> deserializer) {
this.deserializationSchema = deserializer;
}
#Override
public void open(final Configuration parameters) {
...
}
#Override
public void run(final SourceContext<T> ctx) throws Exception {
LOGGER.info("run");
InputStream data = ...; // Retrieve the input json data
final T row = deserializationSchema
.deserialize(ByteStreams.toByteArray(data));
ctx.collect(row);
}
#Override
public void cancel() {
...
}
#Override
public TypeInformation<T> getProducedType() {
return deserializationSchema.getProducedType();
}
}
Now I run my code and I send some data sequentially to my pipeline :
==>
{
"id": "sensor1",
"data":{
"rotation": 250
}
}
Here, the data is correctly printed by my sink : MyCustomSink- invoke : [{"id":"sensor1","data":{"rotation":250}}]
==>
{
"id": "sensor1"
}
Here, the data is correctly printed by my sink : MyCustomSink- invoke : [{"id":"sensor1","data":null}]
==>
{
"id": "sensor1",
"data":{
"rotation": 250
}
}
Here, there is an error on serialization. The error log printed is :
MyCustomSink- Error while sending data : java.lang.RuntimeException: Could not serialize row 'sensor1,250'. Make sure that the schema matches the input.
I do not understand at all why I have this behavior. Someone have an idea ?
Notes:
Using Flink 1.9.2
-- EDIT --
I added the CustomSource part
-- EDIT 2 --
After more investigations, it looks like this behavior is caused by the private transient ObjectNode node of the JsonRowSerializationSchema. If I understand correctly, this is used for optimization, but seems to be the cause of my problem.
Is it the normal behavior, and if it is, what would be the correct use of this class in my case ? (Else, is there any way to bypass this problem ?)
This is a JsonRowSerializationSchema bug which has been fixed in most recent Flink versions - I believe, this PR addresses the issue above.

Block texture load only in the inventory

I am creating a mod but the texture of a block (the only one) loads only in the inventory and when it gets dropped, hope you can help me, I'm using the 1.8 MDK.
Blockstates:
{
"variants"": {
"normal": {"model": "horsenexus:horse_block"},
}
}
Models, block:
{
"parent": "block/cube_all",
"textures": {
"down": "horsenexus:blocks/horse_block_down",
"up": "horsenexus:blocks/horse_block_top",
"north": "horsenexus:blocks/horse_block_north",
"east": "horsenexus:blocks/horse_block_east",
"south": "horsenexus:blocks/horse_block_south",
"west": "horsenexus:blocks/horse_block_west"
}
}
Models, item:
{
"parent": "horsenexus:block/horse_block",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}
And the codes:
package com.crazyhoorse961.core.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
public class HorseBlock extends Block{
public HorseBlock(Material materialIn) {
super(materialIn);
this.setHardness(5.6F);
this.setResistance(56.34F);
this.setStepSound(this.soundTypeSnow);
}
}
And the last one:
package com.crazyhoorse961.core.init;
import com.crazyhoorse961.core.Reference;
import com.crazyhoorse961.core.blocks.HorseBlock;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class Horse_Block {
public static Block horse_block;
public static void init()
{
horse_block = new HorseBlock(Material.clay).setUnlocalizedName("horse_block");
}
public static void register()
{
GameRegistry.registerBlock(horse_block, horse_block.getUnlocalizedName().substring(5));
}
public static void registerRenders()
{
registerRender(horse_block);
}
public static void registerRender(Block block)
{
Item item = Item.getItemFromBlock(block);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
}
Thank you for trying to help me, have a good day.
Try changing the following line in your "Models, block" code
"parent": "block/cube_all",
into:
"parent": "block/cube",
As far as I'm aware 'cube_all' is only used when you use the same texture for all sides of your block.

Asterisk + asterisk-java listen new channels

Asterisk 11.4.0
Asterisk-java: 1.0.0.CI-SNAPSHOT
I've try to run this code:
import org.asteriskjava.live.AsteriskChannel;
import org.asteriskjava.live.AsteriskQueue;
import org.asteriskjava.live.AsteriskQueueEntry;
import org.asteriskjava.live.internal.AsteriskAgentImpl;
import org.asteriskjava.live.AsteriskServer;
import org.asteriskjava.live.AsteriskServerListener;
import org.asteriskjava.live.DefaultAsteriskServer;
import org.asteriskjava.live.ManagerCommunicationException;
import org.asteriskjava.live.MeetMeRoom;
import org.asteriskjava.live.MeetMeUser;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
public class HelloLiveEverything implements AsteriskServerListener, PropertyChangeListener
{
private AsteriskServer asteriskServer;
public HelloLiveEverything()
{
asteriskServer = new DefaultAsteriskServer("localhost", "manager", "password");
}
public void run() throws ManagerCommunicationException
{
// listen for new events
asteriskServer.addAsteriskServerListener(this);
// add property change listeners to existing objects
for (AsteriskChannel asteriskChannel : asteriskServer.getChannels())
{
System.out.println(asteriskChannel);
asteriskChannel.addPropertyChangeListener(this);
}
}
public void onNewAsteriskChannel(AsteriskChannel channel)
{
System.out.println(channel);
channel.addPropertyChangeListener(this);
}
public void onNewMeetMeUser(MeetMeUser user)
{
System.out.println(user);
user.addPropertyChangeListener(this);
}
public void onNewQueueEntry(AsteriskQueueEntry user)
{
System.out.println(user);
user.addPropertyChangeListener(this);
}
public void onNewAgent(AsteriskAgentImpl user)
{
System.out.println(user);
user.addPropertyChangeListener(this);
}
public void propertyChange(PropertyChangeEvent propertyChangeEvent)
{
System.out.println(propertyChangeEvent);
}
public static void main(String[] args) throws Exception
{
HelloLiveEverything helloLiveEverything = new HelloLiveEverything();
helloLiveEverything.run();
while (true) {
}
}
}
When executed, connectios is OK. This code show me current channels but never show me new channels when callers make a calls.
I need to catch the events when new asterisk channels are opening.
What I made wrong?
Thank you
Try This:
Your Class HelloLiveEverything should implement ManagerEventListener
then override the onManagerEvent method
#Override
public void onManagerEvent(ManagerEvent event) {
String event_name = event.getClass().getSimpleName();
if (event_name.equals("DialEvent")) {
DialEvent e = (DialEvent) event;
System.out.println(e.getCallerIdNum());//caller number
System.out.println(e.getDestination());//Called number
//do something here
}
}
edit asterisk manager.conf :
[manager]
secret = password
deny=0.0.0.0/0.0.0.0
permit=209.16.236.73/255.255.255.0; change this ip with one your java app is using permit=127.0.0.1/255.255.255.0
read = system,call,log,verbose,command,agent,user,originate; add full permission
write = system,call,log,verbose,command,agent,user,originate; add full permission

Categories

Resources