MineDen
-
Posts
47 -
Joined
Posts posted by MineDen
-
-
9 minutes ago, V0idWa1k3r said:
If there are no overloads then you are using a forge version which doesn't have that introduced. In the newer version GameRegistry#registerTileEntity(Class<? extends TileEntity> tileEntityClass, String key) is deprecated with a comment that it'll be removed in 1.13.
Also I want to open furnace GUI but it doesn't open. Here is my code:
Block:
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityFurnace) { playerIn.displayGUIChest((TileEntityFurnace) tileentity); playerIn.addStat(TestMod.CHEMICAL_LABORATORY_INTERACT); } return true; } }
TileEntity:
@Nonnull public String getGuiID() { return "minecraft:furnace"; } @Nonnull public Container createContainer(@Nonnull InventoryPlayer playerInventory, @Nonnull EntityPlayer playerIn) { return new ContainerFurnace(playerInventory, this); }
-
5 minutes ago, V0idWa1k3r said:
It's still GameRegistry#registerTileEntity. Use the overload which takes a ResourceLocation as the second argument though.
Okay, I'll try this.
UPD: there is no overloads, only string. Is this should be like "testmod:my_tileentity"? -
Today I copied and edited furnace tileentity and then started testing. But now I have "TileEntity is missing a mapping! This is a bug!" exception. In 1.9 I can fix it by registering TE with GameRegistry.registerTileEntity(...) but in 1.12 I should use RegistryEvents and here is described types of events, and there is no TileEntity! So how I can register my TE?
-
Just now, Choonster said:
Use Random#nextInt(int) to generate a random integer between 0 (inclusive) and the argument (exclusive) instead of the multiplication, subtraction and rounding you're doing now.
Math.round(Math.random() * <count> - 1)
is the JavaScript arrays way, and it's my favourite way, so
shut upi will use this way. -
10 minutes ago, Choonster said:
It adds the items to the list that you pass as an argument.
Is this code right? It works.
public static CreativeTabs decoration = new CreativeTabs("mtest_decoration") { @Override public ItemStack getTabIconItem() { int index = (int) Math.round(Math.random() * (MBlocks.BLOCKS.size() - 1)); Block block = MBlocks.BLOCKS.get(index); NonNullList<ItemStack> subBlocks = NonNullList.create(); block.getSubBlocks(CreativeTabs.SEARCH, subBlocks); System.out.println(subBlocks); int meta = (int) Math.round(Math.random() * (subBlocks.size() - 1)); ItemStack is = new ItemStack(block, 1, meta); return is; } };
-
Just now, Choonster said:
It adds the items to the list that you pass as an argument.
OK, I'll try that.
-
On 16.02.2018 at 8:42 PM, diesieben07 said:
You create an empty NonNullList using NonNullList.create. Then you call getSubItems with that list and CreativeTabs.SEARCH. Afterwards you will have all sub items of that item in the list.
Seriously, this is not hard.
This method returns void, what I can do?
-
Sorry, but I can't understand this chain getSubItems>NonNullList>List>ItemStack, CreativeTabs... It is better to
make own game on LWJGL 3 with bulit-in modloaderalways return random block with metadata 0. -
7 minutes ago, jabelar said:
It's just a coding style thing. That was probably convenient to the person who needed that method in the first place since they were using it for making creative tabs. Like you could pass in an existing list for the creative tab and this method would add to it then you could get the list containing the subitems of multiple item types and if they are itemstacks that makes it super easy to put into the gui container inventory.
Okay, I'll try this now.
-
9 minutes ago, diesieben07 said:
Call getSubItems to get all variants of an item.
This method requires NonNullList of ItemStacks.
But why? I trying to call this method from an instance of Item.
-
1 minute ago, sir_titi said:
meta data is limited to 16, ranging from 0 to 15.
But what if i have other block with only one variant?
-
Hello, I need to get maximum meta value of block. I created a creative tab and returning random block as icon, but I have colored blocks. And I want to return random meta. But I don't know how to get maximum meta value of block. Now my creative tab code looks like this:
public static CreativeTabs decoration = new CreativeTabs("mtest_decoration") { @Override public ItemStack getTabIconItem() { int index = (int) Math.round(Math.random() * (MBlocks.BLOCKS.size() - 1)); Block block = MBlocks.BLOCKS.get(index); int meta = 0; ItemStack is = new ItemStack(block, 1, meta); return is; } };
-
3 minutes ago, loordgek said:
what is the problem now
Thanks, Draco18s, diesieben07, Kokkie, loordgek! All works properly!
-
5 minutes ago, loordgek said:
when you check for world.isremote you check for client
you need !world.isremote
I understand it.
-
1 minute ago, diesieben07 said:
For the hundredth time: WHERE?
Here.
2 minutes ago, loordgek said:nope
this is the javadoc for isremote
Lol. Sorry, I'm read only 0.2% of this comments.
-
37 minutes ago, loordgek said:
nbt is only saved on the server
I'm adding energy on server side.
-
RETEST: NBT don't saves automatically. Only /blockdata changes NBT, and after world reload, NBT entered in /blockdata restored.
-
2 hours ago, Draco18s said:
Any time the TE data changes and you want to update the client, call these methods:
https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/farming/entities/TileEntityTanner.java#L95-L98And have these methods overridden
In 1.12.1, method this.getState() not exist. What method i need to use?
-
After i typed /blockdata ... ... ... {Energy:5000}, energy changed to 5000 properly. When I reloaded world, energy saved and readed properly! GUI shows 5034 (this is previous value). But /blockdata shows 5000. I need to send energy level to client?
-
9 minutes ago, diesieben07 said:
This is broken. If setEnergy is called with 0 as it's argument, it will set the energy to capacity.
I fix it. But now it sets to 0.
-
Just now, diesieben07 said:
I don't want video. I want code that shows where you change the energy. You have shown no such code, as such I can only assume that the energy value never changes.
Energy don't change, but after world restart it always maximum. I think, that this is storage creating or update() method problem.
-
1 minute ago, diesieben07 said:
Once again, not sure what else you expected, given that:
I can record video of what changes in my world.
-
18 hours ago, diesieben07 said:
Ok, great. Now, what's your issue?
getEnergy() always returns 10000.
/blockdata <x> <y> <z> {} shows {Energy: 10000}.
-
16 minutes ago, diesieben07 said:
You can do that. But you must also have a no-argument constructor and you must be aware that only the no-argument constructor will be used when reading your TileEntity from disk.
I recrated zero-argument constructor and uploaded new code to GitHub.
How to register TileEntity in 1.12?
in Modder Support
Posted
Oh, I forgot that my TE doesn't extend TileEntityFurnace, and I also forgot to change checking in block code!