Minecraft 1.9 modding block rendering error - java

I'm trying to render a block with a custom model in my 1.9 mod but it gives me a error at .getItemModelMesher
Code:
public class ModBlocks extends Blocks {
public static Block wooden_table;
public static void init() {
// Create Block
wooden_table = new Block(Material.wood).setUnlocalizedName("wooden_table").setCreativeTab(CreativeTabs.tabMisc);
// Register
GameRegistry.registerBlock(wooden_table, wooden_table.getUnlocalizedName().substring(5));
}
public static void registerRenders() {
registerRender(wooden_table);
}
public static void registerRender(Block block) {
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0,
new ModelResourceLocation(
Main.MODID + ":" + Item.getItemFromBlock(block).getUnlocalizedName().substring(5),
"inventory"));
}
}
Crash report:
---- Minecraft Crash Report ----
Description: Initializing game
java.lang.NullPointerException: Initializing game
at mcrafterzzfurnituremod.blocks.ModBlocks.registerRender(ModBlocks.java:29)
at mcrafterzzfurnituremod.blocks.ModBlocks.registerRenders(ModBlocks.java:25)
Please help I can't find any solution for this problem. If you need more code then just ask.

Minecraft.getMinecraft().getRenderItem()
that part only exists in the INIT phase, and not the PreInit phase. there it's still null.
Register variants in preinit,
then register meshes in init
besure to call this via your clientproxy and not the commonproxy
ps, read the tutorial on http://bedrockminer.jimdo.com/modding-tutorials/basic-modding-1-8/blockstates-and-metadata/ and download the example zip to understand where goes where normally

Related

JMXBeanWrapper can not access a member of class "JMX" with modifiers "public"

I am trying to use the JMXWrapper class/project
For a current project for a set of JMX classes all of them work in peace on either JConsole or VisualVM
For one of them I tried to adapt or work with JMXWrapper:
public interface MainJmxMBean {
boolean showIfMainIsRunning();
void stopMain();
}
and
#JMXBean(description="Administrates the Main app", sorted=true)
class MainJmx implements MainJmxMBean {
private boolean isMainRunning;
MainJmx() {
isMainRunning =true;
}
#Override
#JMXBeanOperation(name="Show If Main Is Running",
description="Shows if the Main app is running or not",
sortValue="1")
public boolean showIfMainIsRunning() {
return isMainRunning;
}
#Override
#JMXBeanOperation(description="Stops the Main app", sortValue="2")
public void stopMain() {
isMainRunning = false;
}
}
Note: The class shown above works fine without the annotations. Now was annotated to improve the information and its use in JConsole/VisualVM
And finally
private void registerMBeanWithJMXBeanWrapper(ObjectJmxMBean objectJmxMBean) {
try {
//System.out.printf("%s %n", objectJmxMBean.toString());
ObjectName objectName = new ObjectName(objectJmxMBean.getName());
server.registerMBean(new JMXBeanWrapper(objectJmxMBean.getObject()), objectName);
}
catch(MalformedObjectNameException |
InstanceAlreadyExistsException |
MBeanRegistrationException |
NotCompliantMBeanException |
IntrospectionException e) {
System.err.printf("[CanonicalName] %s - ERROR: %s %n", e.getClass().getCanonicalName(), e.getMessage());
}
}
The important part of above is: new JMXBeanWrapper(objectJmxMBean.getObject())
Until here I did do all the instructions according with the JMXBeanWrapper documentation shared in the link in the top of this post and even from the author's post:
Adding descriptions to JMX beans using an annotation wrapper
When I run the Main app, through either JConsole or VisualVM I can see the annotations being applied and working how is expected, therefore until here the goal seems been accomplished.
Problem: the problem is when I do click to either of them arises:
The complete error message is:
Problem invoking stopMain:
java.lang.IllegalAccessException
Class com.udojava.jmx.wrapper.JMXBeanWrapper can not access a member of class
com.manuel.jordan.jmx.admin.MainJmx with modifiers "public"
Observation: seems the error is thrown directly by JConsole or VisualVM, because according with the JMXBeanWrapper.java source code, there is no the throw new IllegalAccessException statement with the part of that message with modifiers "public"
Note & Observation: according with the project shared on Github, it was tested with JDK 6 and I am using/working with JDK 8.
What could be wrong or missing in the configuration?
The solution is the following:
Edit from:
#JMXBean(description="Administrates the Main app", sorted=true)
class MainJmx implements MainJmxMBean {
private boolean isMainRunning;
MainJmx() {
isMainRunning =true;
}
To
#JMXBean(description="Administrates the Main app", sorted=true)
public class MainJmx implements MainJmxMBean {
private boolean isMainRunning;
MainJmx() {
isMainRunning =true;
}
Conclusion: the JMXWrapper needs that the class annotated with #JMXBean must be public.
How you can see the constructor can remain being package default

Why do I get "Unidentified mapping from registry minecraft:block"?

I am learning how to write Minecraft mods (version 1.14.4) and was able to make an item. Now I am trying to make a block. I am following this tutorial video which actually covers 1.14.3, but I thought it would be close enough.
I am currently getting this error:
[20Mar2020 14:09:10.522] [Server thread/INFO] [net.minecraftforge.registries.ForgeRegistry/REGISTRIES]: Registry Block: Found a missing id from the world examplemod:examplemod
[20Mar2020 14:09:10.613] [Server thread/ERROR] [net.minecraftforge.registries.GameData/REGISTRIES]: Unidentified mapping from registry minecraft:block
examplemod:examplemod: 676
I also get presented with this at runtime:
I have tried messing around with how i'm naming the registries but I just can't seem to pin down what the issue is. Maybe i'm not formatting my json files correctly?
Note that ItemList and BlockList are just classes that contain static instances of each Block/Item I have created.
ExampleMod.java:
// The value here should match an entry in the META-INF/mods.toml file
#Mod(ExampleMod.MOD_ID)
public class ExampleMod
{
// Directly reference a log4j logger.
private static final Logger LOGGER = LogManager.getLogger();
public static final String MOD_ID = "examplemod";
public ExampleMod() {
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
// Register the enqueueIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
// Register the processIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
// Register the doClientStuff method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}
private void setup(final FMLCommonSetupEvent event)
{
// some preinit code
LOGGER.info("HELLO FROM PREINIT");
LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
}
private void doClientStuff(final FMLClientSetupEvent event) {
// do something that can only be done on the client
LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings);
}
private void enqueueIMC(final InterModEnqueueEvent event)
{
// some example code to dispatch IMC to another mod
InterModComms.sendTo(ExampleMod.MOD_ID, "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
}
private void processIMC(final InterModProcessEvent event)
{
// some example code to receive and process InterModComms from other mods
LOGGER.info("Got IMC {}", event.getIMCStream().
map(m->m.getMessageSupplier().get()).
collect(Collectors.toList()));
}
// You can use SubscribeEvent and let the Event Bus discover methods to call
#SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) {
// do something when the server starts
LOGGER.info("HELLO from server starting");
}
// 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 onItemsRegistry(final RegistryEvent.Register<Item> blockItemEvent)
{
ItemList.bomb_item = new Item(new Item.Properties().group(ItemGroup.COMBAT));
ItemList.bomb_item.setRegistryName(new ResourceLocation(ExampleMod.MOD_ID, "bomb_item"));
ItemList.mystery_block = new BlockItem(BlockList.mystery_block, new Item.Properties().group(ItemGroup.MISC));
ItemList.mystery_block.setRegistryName(new ResourceLocation(ExampleMod.MOD_ID, "mystery_block"));
blockItemEvent.getRegistry().registerAll(ItemList.bomb_item, ItemList.mystery_block);
LOGGER.info("Items registered.");
}
#SubscribeEvent
public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) {
BlockList.mystery_block = new Block(Block.Properties.create(Material.CAKE)
.hardnessAndResistance(2.0f, 2.0f)
.sound(SoundType.GLASS));
BlockList.mystery_block.setRegistryName(new ResourceLocation(MOD_ID, "mystery_block"));
blockRegistryEvent.getRegistry().registerAll(BlockList.mystery_block);
LOGGER.info("Blocks registered.");
}
}
}
blockstates/mystery_block.json:
{
"variants": {
"": {
"model": "examplemod:block/mystery_block"
}
}
}
models/block/mystery_block.json:
{
"parent": "block/cube_all",
"textures": {
"all": "examplemod:block/mystery_block"
}
}
models/item/mystery_block.json:
{
"parent": "examplemod:block/mystery_block"
}
All that means is that at some point you had a block registered as "examplemod:examplemod", and now you don't. You can safely ignore the message. If you start a new world instead of opening an old one, you won't get that message.
As an aside, HarryTalks is not a recommended way to learn to mod (on the Minecraft Forge forums ). Apparently he uses several bad practices (I have not actually used them).
Alternative suggestions are Cadiboo's example mod, or McJty's tutorials.

First run Intellij+AspectJ ,hava a lot of errors

I am trying to use AspectJ in sample project in IntelliJ IDEA. I have an experience with Spring AOP, but this is first time I am using AspectJ, and cannot make it work.
Environment:Win 10, IntelliJ IDEA and AspectJ,
Refer to this document for configuration,
https://www.jetbrains.com/help/idea/2016.3/aspectj.html
public class Hello {
public void sayHello() {
System.out.println("test1.Hello, AspectJ!");
}
public static void main(String[] args) {
Hello hello = new Hello();
hello.sayHello();
}
}
public aspect TxAspect {
void around():call(void Hello.sayHello()){
System.out.println("Start transaction...");
proceed();
System.out.println("end transaction...");
}
}
It should hava outputs:
Start transaction...
Hello, AspectJ!
end transaction...
but it appears a lot of errors:
enter image description here
Change the jdk release from 10 to 8 can solve this problem.

I/O using windowbuilder in eclipse for a java application

I've never used java windowbuilder before, however I'm trying to test it with my program which performs operations on sets. It's a Gradle project. I wrote all classes in the default package (I knew that it's discouraged just when I was finished). The program reads a line of operations on sets, parses it and prints the result and keeps doing that while there is a new line input from the user.
I'm trying to make a simple GUI for this program using windowbuilder but I can't figure out how to run the main class in the windowbuilder class and make it take input from a jtextfield and prints output.
My main looks like this:
public static void main(String[] argv) {
new Main().start();
}
private void start() {
hmap = new HashMap<IdentifierInterface, SetInterface<BigInteger>>();
Scanner in = new Scanner(System.in);
// While there is input, read line and parse it.
while (in.hasNextLine()) {
try {
String statement = in.nextLine();
if (statement.trim().isEmpty()) {
System.out.println("error, no statement");
} else {
Scanner statementScanner = new Scanner(statement);
readStatement(statementScanner);
}
} catch (APException e) {
System.out.printf("%s\n", e.getMessage());
}
}
}
I made a new windowbuilder class, with the buttons and text fields, but I got stuck on how to run my main inside the windowbuilder. Your help is appreciated. Thanks in advance.
Eclipse RCP applications are OSGi plug-ins; they do not have a main() method.
Instead your Main class should look like this:
package com.myplugin;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Main implements BundleActivator {
#Override
public void start(BundleContext bundleContext) throws Exception {
// Copy your start logic here
}
}
Then edit META-INF/MANIFEST.MF file and set for example
Bundle-Activator: com.myplugin.Main
This makes your Main class the activator of the plug-in: start() will be invoked at load.

JACOB event registration

I'm trying to use JACOB to obtain a callback whenever a slide show starts or ends using the following:
public class Test {
public static void main(String[] args) {
ActiveXComponent oApp = new ActiveXComponent("PowerPoint.Application");
Dispatch presentations = oApp.getProperty("Presentations").toDispatch();
Dispatch presentation = Dispatch.call(presentations, "Open", "C:\\Users\\Bob\\Documents\\test.ppt").toDispatch();
new DispatchEvents(oApp, new Handler());
}
}
public class Handler {
public void SlideShowBegin(Variant[] args) {
System.out.println("here");
}
}
However, I'm coming a bit unstuck, the result of the above is:
GetEventIID: couldn't get IProvideClassInfo
Exception in thread "main" com.jacob.com.ComFailException: Can't find event iid
at com.jacob.com.DispatchEvents.init3(Native Method)
at com.jacob.com.DispatchEvents.<init>(DispatchEvents.java:138)
at com.jacob.com.DispatchEvents.<init>(DispatchEvents.java:99)
at com.jacob.com.DispatchEvents.<init>(DispatchEvents.java:72)
at tester.Test.main(Test.java:28)
Does anyone have any ideas? Searching has come up pretty short. I've tried using the 4 argument constructor of DispatchEvents, supplying "Powerpoint.Application" and the full path to the powerpoint exe as the last two arguments, but no difference.

Categories

Resources