Jump to content

Recommended Posts

Posted

I have a Problem with my crops, they have the missing-texture texture and i cant find my mistake.

 

Main:

package io.github.dommihd.blazecraft;

import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.items.BlazeItems;
import io.github.dommihd.blazecraft.proxy.CommonProxy;
import io.github.dommihd.blazecraft.recepies.BlazeCrafting;
import io.github.dommihd.blazecraft.recepies.BlazeSmelting;
import net.minecraft.init.Blocks;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;

@Mod(modid = Blazecraft.MODID, version = Blazecraft.VERSION, name = Blazecraft.NAME)
public class Blazecraft
{
    public static final String MODID = "blazecraft";
    public static final String VERSION = "0.1";
    public static final String NAME = "Blazecraft";
  
    @Instance(MODID)
public static Blazecraft instance = new Blazecraft();
    
@SidedProxy(modId = MODID, serverSide = "io.github.dommihd.blazecraft.proxy.CommonProxy", clientSide = "io.github.dommihd.blazecraft.proxy.ClientProxy")
public static CommonProxy proxy = new CommonProxy();

public BlazeItems items;
public BlazeBlocks blocks;
public BlazeTab tab;
public BlazeCrafting craft;
public BlazeSmelting smelt;

@EventHandler
public void preInit(FMLPreInitializationEvent event){
	tab = new BlazeTab();

	items = new BlazeItems();
	items.init();
	items.register();

	blocks = new BlazeBlocks();
	blocks.init();
	blocks.register();
}
@EventHandler
public void load(FMLInitializationEvent event){
	craft = new BlazeCrafting();
	craft.register();

	smelt = new BlazeSmelting();
	smelt.register();
}
@EventHandler
public void postInit(FMLPostInitializationEvent event){
	proxy.registerModels();
}
}

 

Client Proxy:

package io.github.dommihd.blazecraft.proxy;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;

public class ClientProxy extends CommonProxy {


public void registerModels() {
	//items
	registerModel(BlazeItems.testitem, 0, new ModelResourceLocation(BlazeItems.testitem.getRegistryName(),"inventory"));
	registerModel(BlazeItems.emberorchidSeeds, 0, new ModelResourceLocation(BlazeItems.emberorchidSeeds.getRegistryName(),"inventory"));
	//blocks
	registerModel(BlazeBlocks.testblock, 0, new ModelResourceLocation(BlazeBlocks.testblock.getRegistryName(),"inventory"));
	registerModel(BlazeBlocks.emberorchid, 0, new ModelResourceLocation(BlazeBlocks.emberorchid.getRegistryName(),"inventory"));
}

private void registerModel(Object obj, int meta, ModelResourceLocation loc){
	Item item = null;
	if (obj instanceof Item){
		item = (Item) obj;
	}else if (obj instanceof ItemSeeds){
		item = (ItemSeeds) obj;

	} else if (obj instanceof Block){
		item = Item.getItemFromBlock((Block) obj);

	}else{
		throw new IllegalArgumentException();
	} 
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, loc);
}

}

Name Utils:

package io.github.dommihd.blazecraft;

import net.minecraft.block.Block;
import net.minecraft.item.Item;

public class NameUtils {

public static void setNames(Object obj,String name){
	if(obj instanceof Item){
		((Item)obj).setRegistryName(name).setUnlocalizedName(name);
	} else if(obj instanceof Block){
		((Block)obj).setRegistryName(name).setUnlocalizedName(name);
	}else{
		throw new IllegalArgumentException();
	}
}

}

Blocks Class:

package io.github.dommihd.blazecraft.blocks;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.NameUtils;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class BlazeBlocks {

public static Block testblock;
public static Block emberorchid;

public void init(){
	testblock = new BlockTest().setCreativeTab(Blazecraft.instance.tab);
	NameUtils.setNames(testblock, "testblock");
	emberorchid = new EmberOrchid();
	NameUtils.setNames(emberorchid, "emberorchid");
}

public void register(){
	registerBlock(testblock);
	registeremberBlock(emberorchid);
}

private void registerBlock(Block block){
	GameRegistry.register(block);
	ItemBlock itemblock = new ItemBlock(block);
	itemblock.setUnlocalizedName(block.getUnlocalizedName()).setRegistryName(block.getRegistryName());
	GameRegistry.register(itemblock);
}
private void registeremberBlock(Block block){
	GameRegistry.register(block);
}
}

Block Crops

package io.github.dommihd.blazecraft.blocks;

import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.BlockCrops;
import net.minecraft.init.Items;
import net.minecraft.item.Item;

public class EmberOrchid extends BlockCrops{

@Override
protected Item getSeed(){

	return BlazeItems.emberorchidSeeds;

}

@Override
protected Item getCrop() {

	return Items.BLAZE_POWDER;
}

}

blockstates:

{
    "variants": {
        "age=0": { "model": "blazecraft:eo_stage0" },
        "age=1": { "model": "blazecraft:eo_stage1" },
        "age=2": { "model": "blazecraft:eo_stage2" },
        "age=3": { "model": "blazecraft:eo_stage3" },
        "age=4": { "model": "blazecraft:eo_stage4" },
        "age=5": { "model": "blazecraft:eo_stage5" },
        "age=6": { "model": "blazecraft:eo_stage6" },
        "age=7": { "model": "blazecraft:eo_stage7" }
    }
}

block models exaple:

{
    "parent": "block/crop",
    "textures": {
        "crop": "blazecraft:blocks/eo_stage0"
    }
}

texture names: eo_stage0.png, eo_stage1.png, ...

Posted

Your blockstate is wrong.  You're telling Minecraft to look for a model that doesn't exist.

You should instead override the texture, like so:

 

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/resources/assets/harderores/blockstates/hardiron.json

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I have the same problem : No texture and no error for my item:

 

the main class:

 

@Mod (modid = References.MOD_ID, name = References.NAME, version = References.VERSION,
      acceptedMinecraftVersions = References.ACCEPTED_VERSIONS)

public class Tem {

@SidedProxy(serverSide= References.CLIENT_PROXY_CLASS, clientSide = References.SERVER_PROXY_CLASS)
public static CommonProxy proxy;


@Instance
public static Tem instance;

@EventHandler
public void preInit (FMLPreInitializationEvent event) {

	ModItems.init();
	ModItems.register();


}
@EventHandler
public void init (FMLInitializationEvent event){



}
@EventHandler
public void postInit(FMLPostInitializationEvent event){

	proxy.init();

}

}

 

 

the references class:

 

public class References {
public static final String MOD_ID = "tem";
public static final String NAME = "Tim's Expansion Mod";
public static final String VERSION = "1.0.0";
public static final String ACCEPTED_VERSIONS = "[1.10]";

public static final String CLIENT_PROXY_CLASS = "winnetrie.tem.proxy.ClientProxy";
public static final String SERVER_PROXY_CLASS = "winnetrie.tem.proxy.ServerProxy";

public static enum temItems {
	CHEESE("cheese", "ItemCheese");

	private String unlocalizedName;
	private String registryName;

	temItems(String unlocalizedName, String registryName){
		this.unlocalizedName = unlocalizedName;
		this.registryName = registryName;

	}
	public String getUnlocalizedName(){
		return unlocalizedName;
	}
	public String getRegistryName(){
		return registryName;
	}
}

}

 

 

the ModItems class:

 

 

public class ModItems {

public static Item cheese;

public static void init(){

	cheese = new ItemCheese();

}

public static void register(){
	GameRegistry.register(cheese);

}

public static void registerRenders(){
	registerRender(cheese);

}

private static void registerRender(Item item){
	ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(),"inventory"));

}

}

 

 

the ItemCheese class:

 

public class ItemCheese extends Item {

public ItemCheese(){
	setUnlocalizedName(References.temItems.CHEESE.getUnlocalizedName());
	setRegistryName(References.temItems.CHEESE.getRegistryName());
}

}

 

the item model ItemCheese.json:

 

{
   "parent": "item/generated",
   "textures": {
      "layer0": "tem:items/ItemCheese"
   }
}

 

 

and the texture is called ItemCheese.png

Posted

When dealing with resources do not use capital letters.

 

I watched a video tutorial where the person use capital letters in his resources.

The example worked fine.

But hey i tried it out and changed everything lower case and guess what?

No errors and still no textures.

 

I also saw a little mistake done by me.

I did put proxy.init(); in the postinit instead of the init method.

That didn't fixed it either, so must be something else...

Posted

i found out that all the textures and sounds works if i place the itemblock of the emberorchid , but i i try to place the seeds thers no sound and the missing-texture texture. This makes no sense ;D

Posted

@_Dommi_

Show your ItemSeed class. If the crop-block is placed just fine, then something is likely wrong with your seed.

I have a working ItemSeed implementation here that you can take a look at.

 

 

@winnetrie

1) Mojang will be enforcing lowercase soon for resources, I've heard. It's good practice to follow what will come, and not having to redo all work when updating etc.

2) (Depending on your OS (Windows falls under here)) The dev-environment will ignore lower/uppercase mismatches, and show you the resource for supermod:SuPeRbLoCk == supermod:superblock. This means that if your resources are typed with different cases, they will still show as expected. However, when compiled into a .jar (really just a .zip file with different name) it cannot do this anymore, leading to SuPeRbLoCk =! superblock. It's a pain in the proverbial behind to find all these issues with the naked eye.

3) I don't see you calling ModItems.registerRenders. This has to be done in preInit, in the clientproxy.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

i changed it, but still no textures and no error:

@Mod (modid = References.MOD_ID, name = References.NAME, version = References.VERSION,
      acceptedMinecraftVersions = References.ACCEPTED_VERSIONS)

public class Tem {

@SidedProxy(serverSide= References.CLIENT_PROXY_CLASS, clientSide = References.SERVER_PROXY_CLASS)
public static CommonProxy proxy;


@Instance
public static Tem instance;

@EventHandler
public void preInit (FMLPreInitializationEvent event) {
	proxy.init();
	ModItems.init();
	ModItems.register();



}
@EventHandler
public void init (FMLInitializationEvent event){




}
@EventHandler
public void postInit(FMLPostInitializationEvent event){



}

}

 

I also did it exactly as in the tutorial. In the tutorial they do it in the Init and not preInit

Posted

My seed class:

public class EmberOrchidSeeds extends ItemSeeds{

public EmberOrchidSeeds(){
	super(BlazeBlocks.eo, Blocks.DIRT);
	this.setCreativeTab(Blazecraft.instance.tab);
	this.soilBlockID = Blocks.DIRT;
}
}

 

Posted

@_Dommi_

You need to override

onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)

in your seed class.

You can see how my itemseeds do so in my previous post.

 

 

@Winnetrie

You... What are.... how...

What?

You are calling your proxy's init, from preInit... That is not what I told you to do.

In your main's preInit, call proxy.preInit().

In your clientProxy's preInit, call ModItems.registerRenders

 

i changed it, but still no textures and no error:

 

I also did it exactly as in the tutorial. In the tutorial they do it in the Init and not preInit

ModelLoader HAS to be registered in preInit. If you use Minecraft::getItemModelMesher, then yes, you register in init, but that is buggy as heck, which is why Forge had to add ModelLoader as a better alternative.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

What is it with this trend to put everything inside the proxy classes? That defeats their purpose...

 

Not to mention that your client proxy then calls ModItems, which is common code, further defeating the purpose of proxies.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

now the game crashed ^^ : http://pastebin.com/yE0Nw1jB

 

Seeds:

package io.github.dommihd.blazecraft.items;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.blocks.EmberOrchid;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class EmberOrchidSeeds extends ItemSeeds{

    private static EmberOrchid crops;
    private static Block soilBlockID;

public EmberOrchidSeeds(){
	super(BlazeBlocks.eo, Blocks.DIRT);
	this.setCreativeTab(Blazecraft.instance.tab);
	this.soilBlockID = Blocks.DIRT;
}


@Override
    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);
        if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && worldIn.isAirBlock(pos.up()) && this.crops.canSustainBush(state))
        {
            worldIn.setBlockState(pos.up(), this.crops.getDefaultState());
            --stack.stackSize;
            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
}

}

 

package io.github.dommihd.blazecraft.blocks;

import java.util.Random;

import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class EmberOrchid extends BlockCrops{




@Override
protected Item getSeed(){

	return BlazeItems.emberorchidSeeds;

}

@Override
protected Item getCrop() {

	return Items.BLAZE_POWDER;
}	
  @Override
    public boolean canSustainBush(IBlockState state){
    	if(state.getBlock() == Blocks.DIRT ||state.getBlock() == Blocks.GRASS || state.getBlock() == Blocks.SAND)
    		return true;
    	
        return false;
}
}

Posted

@Winnetrie

You... What are.... how...

What?

You are calling your proxy's init, from preInit... That is not what I told you to do.

In your main's preInit, call proxy.preInit().

In your clientProxy's preInit, call ModItems.registerRenders

 

I'm really confused now. I don't understand what you mean!

Maybe take a look at this tutorial:

 

I did exactly like this and it works for him, why not for me?

Posted

net.minecraft.block.state.IBlockState state

?  Really?

Couldn't be arsed to import that?

 

As for the crash...

Caused by: java.lang.NullPointerException
    at io.github.dommihd.blazecraft.items.EmberOrchidSeeds.onItemUse(EmberOrchidSeeds.java:33) ~[EmberOrchidSeeds.class:?]

 

Go to EmberOrchidSeeds line 33.  Find the thing that is null, it is very easy.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I checked something and it appears that this is never been called:

 

public class ClientProxy implements CommonProxy{

@Override
public void init() {

	ModItems.registerRenders();
	System.out.println("renders have been registered");

}	

}

I added the System.out.println("renders have been registered"); to check, but i can't see the message.

So i guess it isn't called but why?

 

Also if i name the method init or preInit or whatever name you can imagine, it's just a name. Does it really matter how i name it?

Like i said before i watch the tutorial video (wich is a working example) and checked every step again and again.

Posted

So i guess it isn't called but why?

Because you never call the method...

 

Also if i name the method init or preInit or whatever name you can imagine, it's just a name. Does it really matter how i name it?

Like i said before i watch the tutorial video (wich is a working example) and checked every step again and again.

You can name your methods whatever you want, just be sure to name them something logical.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

@_Dommi_

I didn't mean for you to copy/paste directly from my github.

 

Your crop creates blaze-powder, no? Then I assume you want it to only grow on soulsand. Use that instead of grass|dirt|sand.

 

The nullpointer occurs here:

if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && worldIn.isAirBlock(pos.up()) && this.crops.canSustainBush(state))

Something here, is called, when it does not exist.

You could just simply have if-checks before hand and check if they are null, System.out.print(variable + " is null") and return the method. Then you know what is wrong.

 

net.minecraft.block.state.IBlockState state

?  Really?

Couldn't be arsed to import that?

=_= That's on me, actually. Copied from the github. Lesson learnt: don't code stuff when sick.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted

Because you never call the method...

 

Am i not doing that here?:

 

@Mod (modid = References.MOD_ID, name = References.NAME, version = References.VERSION,
      acceptedMinecraftVersions = References.ACCEPTED_VERSIONS)

public class Tem {

@SidedProxy(serverSide= References.CLIENT_PROXY_CLASS, clientSide = References.SERVER_PROXY_CLASS)
public static CommonProxy proxy;


@Instance
public static Tem instance;

@EventHandler
public void preInit (FMLPreInitializationEvent event) {
	proxy.init();
	ModItems.init();
	ModItems.register();



}
@EventHandler
public void init (FMLInitializationEvent event){




}
@EventHandler
public void postInit(FMLPostInitializationEvent event){



}

}

 

 

the proxy.init() ?

 

Posted

ok private static EmberOrchid crops; was null and i fixed it and the seeds can now only placed on soul sand, but theres no sound and no texture  :-\ :'(

 

package io.github.dommihd.blazecraft.items;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.blocks.EmberOrchid;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class EmberOrchidSeeds extends ItemSeeds{

    private static EmberOrchid crops= new EmberOrchid();
    private static Block soilBlockID;

public EmberOrchidSeeds(){
	super(BlazeBlocks.eo, Blocks.SOUL_SAND);
	this.setCreativeTab(Blazecraft.instance.tab);
	this.soilBlockID = Blocks.SOUL_SAND;
}


@Override
    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);
        if(state!=null&&facing!=null&&pos!=null&&stack!=null&&worldIn!=null&&playerIn!=null&&crops!=null){
        	System.out.println("hi");
        if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && worldIn.isAirBlock(pos.up())&& this.crops.canSustainBush(state))
        {
        	System.out.println("hi2");
            worldIn.setBlockState(pos.up(),this.crops.getDefaultState());
            --stack.stackSize;
            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
        }else  return EnumActionResult.FAIL;
}

}

Posted

Itemseeds class:

package io.github.dommihd.blazecraft.items;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.blocks.EmberOrchid;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

public class EmberOrchidSeeds extends ItemSeeds{

    private static EmberOrchid crops= new EmberOrchid();
    private static Block soilBlockID;

public EmberOrchidSeeds(){
	super(BlazeBlocks.eo, Blocks.SOUL_SAND);
	this.setCreativeTab(Blazecraft.instance.tab);
	this.soilBlockID = Blocks.SOUL_SAND;
}


@Override
    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        net.minecraft.block.state.IBlockState state = worldIn.getBlockState(pos);
        if(state!=null&&facing!=null&&pos!=null&&stack!=null&&worldIn!=null&&playerIn!=null&&crops!=null){
        if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, stack) && worldIn.isAirBlock(pos.up())&& this.crops.canSustainBush(state))
        {
            worldIn.setBlockState(pos.up(),this.crops.getDefaultState());
            --stack.stackSize;
            return EnumActionResult.SUCCESS;
        }
        else
        {
            return EnumActionResult.FAIL;
        }
        }else  return EnumActionResult.FAIL;
}

}

Block crops:

package io.github.dommihd.blazecraft.blocks;

import java.util.Random;

import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class EmberOrchid extends BlockCrops{




@Override
protected Item getSeed(){

	return BlazeItems.emberorchidSeeds;

}

@Override
protected Item getCrop() {

	return Items.BLAZE_POWDER;
}	
  @Override
    public boolean canSustainBush(IBlockState state){
    	if(state.getBlock() == Blocks.SOUL_SAND){
    		return true;
    	}else{
        return false;
    	}
}
}

 

package io.github.dommihd.blazecraft.items;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.NameUtils;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.blocks.EmberOrchid;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemSeeds;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class BlazeItems {

public static Item testitem;
public static EmberOrchidSeeds emberorchidSeeds =new EmberOrchidSeeds();

public void init(){
	testitem = new ItemTest().setCreativeTab(Blazecraft.instance.tab);
	NameUtils.setNames(testitem, "testitem");
	emberorchidSeeds = new EmberOrchidSeeds();
	NameUtils.setNames(emberorchidSeeds, "emberorchidSeeds");
}

public void register(){
	registerItem(testitem);
	registerItemSeeds(emberorchidSeeds);
}

private void registerItem(Item item){
	GameRegistry.register(item);
}

private void registerItemSeeds(ItemSeeds item){
	GameRegistry.register(item);
}
}

package io.github.dommihd.blazecraft.blocks;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.NameUtils;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class BlazeBlocks {

public static Block testblock;
public static EmberOrchid eo = new EmberOrchid();

public void init(){
	testblock = new BlockTest().setCreativeTab(Blazecraft.instance.tab);
	NameUtils.setNames(testblock, "testblock");
	eo = new EmberOrchid();
	NameUtils.setNames(eo, "eo");
}

public void register(){
	registerBlock(testblock);
	registerBlock(eo);
}

private void registerBlock(Block block){
	GameRegistry.register(block);
	ItemBlock itemblock = new ItemBlock(block);
	itemblock.setUnlocalizedName(block.getUnlocalizedName()).setRegistryName(block.getRegistryName());
	GameRegistry.register(itemblock);
}
private void registeremberBlock(Block block){
	GameRegistry.register(block);
	//Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block),0, new ModelResourceLocation("blazecraft:eo","inventory"));
}
}

Client Proxy:

package io.github.dommihd.blazecraft.proxy;

import io.github.dommihd.blazecraft.Blazecraft;
import io.github.dommihd.blazecraft.blocks.BlazeBlocks;
import io.github.dommihd.blazecraft.items.BlazeItems;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSeeds;

public class ClientProxy extends CommonProxy {


public void registerModels() {
	//items
	registerModel(BlazeItems.testitem, 0, new ModelResourceLocation(BlazeItems.testitem.getRegistryName(),"inventory"));
	registerModel(BlazeItems.emberorchidSeeds, 0, new ModelResourceLocation(BlazeItems.emberorchidSeeds.getRegistryName(),"inventory"));
	//blocks
	registerModel(BlazeBlocks.testblock, 0, new ModelResourceLocation(BlazeBlocks.testblock.getRegistryName(),"inventory"));
	registerModel(BlazeBlocks.eo, 0, new ModelResourceLocation(BlazeBlocks.eo.getRegistryName(),"inventory"));
}

private void registerModel(Object obj, int meta, ModelResourceLocation loc){
	Item item = null;
	System.out.println(obj);
	if (obj instanceof Item){
		item = (Item) obj;
		System.out.println(item);
	}else if (obj instanceof ItemSeeds){
		item = (ItemSeeds) obj;
		System.out.println(item);
	} else if (obj instanceof Block){
		item = Item.getItemFromBlock((Block) obj);
		System.out.println(item);
	}else{
		throw new IllegalArgumentException();

	} 
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, meta, loc);
}

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.