-
Posts
37 -
Joined
-
Last visited
Converted
-
Gender
Undisclosed
-
URL
http://www.minecraftinfo.com
-
Location
Minecraft
-
Personal Text
MCICraft Creator
Recent Profile Visitors
2229 profile views
stucuk's Achievements
Tree Puncher (2/8)
3
Reputation
-
[Forge 1.10.2] Render white .OBJ model with specified RGB color?
stucuk replied to mrAppleXZ's topic in Modder Support
The following is all you need to turn RGB values into an int. Alpha is forced to 255 (Opaque): public static int rgb(int r,int g,int b) { return (b & 0xFF) | ((g & 0xFF) << 8) | ((r & 0xFF) << 16) | (255 << 24); } -
Having a tough time creating a crafting mechanic
stucuk replied to That_Martin_Guy's topic in Modder Support
You never want to use markDirty in the writeToNBT (or even readToNBT). markDirty tells minecraft that the chunk that the tile is in needs to be saved. writeToNBT is what minecraft uses when saving to get the Tile's NBT data. So your basically telling minecraft that the chunk your tile is in constantly needs to be saved. As i said before, only when *you* actually change somethings value which you want minecraft to save to the world do you call markDirty(). -
Having a tough time creating a crafting mechanic
stucuk replied to That_Martin_Guy's topic in Modder Support
there is no markDirty() anywhere in your code. For the TileEntity to be saved you need to mark it as dirty to tell Minecraft that the chunk needs saved. Whenever you set data that needs to be saved call markDirty() -
The way the weight system works is basically each item (Or model in your case) is given a value. The total weight is all the values added together. The WeightedRandom::getRandomItem just goes through all the items and subtracts their value from the number passed to it until the value is below 0. If it gets to below zero that item is returned. So lets say you had items each with a weight of 2. If you supply it with a value of 1 or 0, the first item is picked. If you supply it with a value of 2 or 3 the 2nd is picked, etc. It will always give you the exact same results with the same values passed to it. MathHelper.getPositionRandom gives you the same number each time for the same block position.
-
The random numbers are based on the blocks position in the world. BlockModelRenderer::renderModel() uses MathHelper.getPositionRandom(blockPosIn) for the random number. Which is passed to the WeightedBakedModel::getRandomModel which in turn uses Math.abs((int)p_188627_1_ >> 16) % this.totalWeight to work out the "Weight" which is used by WeightedRandom::getRandomItem . So basically the following would give you the weight: Math.abs((int)MathHelper.getPositionRandom(blockPosIn) >> 16) % totalWeight But you would have to work out what the totalWeight was as well as which model is picked based on the weight.
-
Since models are client side and its not based on a State/MetaData (Like snowy being true/false) i don't think there is any way to know.
-
If you want the torch to be above the block, then set its coordinates 1 block above it.... if you want it to the left of the block then set the torches coordinates to be 1 block to the left, etc. aka: BlockPos newpos = pos.offset(facing); You may also want to call the player.canPlayerEdit to see if the player has the editing rights to actually edit the block you want to place the torch in.
-
[1.11]Help with Packets, NBT, and Tile Entities
stucuk replied to its_meow's topic in Modder Support
I use eclipse and never have touched the keybindings. By Autocomplete i mean the CTRL+SPACE thing. I just didn't know you could do it for actual method overrides. -
[1.11]Help with Packets, NBT, and Tile Entities
stucuk replied to its_meow's topic in Modder Support
In the guys defensive i never even knew you could get the IDE to generate an override method using the AutoComplete feature. Iv been playing with it since 2014 (And other languages for alot longer). -
[1.11]Help with Packets, NBT, and Tile Entities
stucuk replied to its_meow's topic in Modder Support
Assuming you have the same basic code as i posted for my packets handlepacket bit, In your TileEntity you need to implement it in the implements bit. I.E: public class BaseTileRedstone extends BaseTile implements IGUIPacketHandler { @Override public void HandleGUIPacket(EntityPlayer player, BlockPos pos, long value, byte extra) { //Do Something! Short and Long values go here! } @Override public void HandleGUIPacket_Float(EntityPlayer player, BlockPos pos, float value, byte extra) { } @Override public void HandleGUIPacket_ItemStack(EntityPlayer player, BlockPos pos, ItemStack value, byte extra) { } } Interfaces which the IGUIPacketHandler is, basically lay out stuff a thing should have. When you use the implements bit your stating what interfaces that class supports (Well implements). You can then treat that class as if it was that interface. Basically it allows you to do: TileEntity te = new MyTileEntity(); if (te instanceof IGUIPacketHandler) //Check its actually implemented the interface { ((IGUIPacketHandler)te).HandleGUIPacket(player,pos,1,0); //we can now treat the TileEntity as if it was a IGUIPacketHandler } -
[1.11]Help with Packets, NBT, and Tile Entities
stucuk replied to its_meow's topic in Modder Support
im guessing that the following is still the way to do things: public class SomeClassName extends Block implements ITileEntityProvider { @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new SomeTileEntityClass(someparameters); } } -
You forgot your crystal ball today?
-
Basically you just need to move all the code into a single for loop public class ItemGeneric { static public ItemBase item_nugget = null; static public ItemBase item_ingot = null; static public ItemBase item_chunk = null; public static void initItems() { for(EnumMaterialMetal enummaterial:EnumMaterialMetal.values()) { item_nugget = new ItemBase(enummaterial); item_nugget.setUnlocalizedName("nugget" + enummaterial.suffix); GameRegistry.register(item_nugget.setRegistryName("nugget" + enummaterial.suffix)); OreDictionary.registerOre("nugget" + enummaterial.suffix, new ItemStack(item_nugget, 1, 0)); item_nugget.setCreativeTab(IndifferentOres.altTabItems); IndifferentOres.proxy.registerItemRenderer(item_nugget); item_ingot = new ItemBase(enummaterial); item_ingot.setUnlocalizedName("ingot" + enummaterial.suffix); GameRegistry.register(item_ingot.setRegistryName("ingot" + enummaterial.suffix)); OreDictionary.registerOre("ingot" + enummaterial.suffix, new ItemStack(item_ingot, 1, 0)); item_ingot.setCreativeTab(IndifferentOres.altTabItems); IndifferentOres.proxy.registerItemRenderer(item_ingot); item_chunk = new ItemBase(enummaterial); item_chunk.setMaxStackSize(enummaterial.MAX_STACK_SIZE); item_chunk.setUnlocalizedName("chunk" + enummaterial.suffix); GameRegistry.register(item_chunk.setRegistryName("chunk" + enummaterial.suffix)); OreDictionary.registerOre("chunk" + enummaterial.suffix, new ItemStack(item_chunk, 1, 0)); item_chunk.setCreativeTab(IndifferentOres.altTabChunks); IndifferentOres.proxy.registerItemRenderer(item_chunk); GameRegistry.addRecipe(new ItemStack(item_ingot), new Object[] {"###", "###", "###", '#', item_nugget}); // Nine Nuggets will make one ingot. GameRegistry.addShapelessRecipe(new ItemStack(item_nugget, 9), new ItemStack(item_ingot, 1)); // One Ingot will make nine nuggets GameRegistry.addSmelting(item_chunk, new ItemStack(item_nugget, 3), 1.0F); //One ore Chunk will make three nuggets. } } } Which could be optimised: public class ItemGeneric { protected static ItemBase getItem(EnumMaterialMetal enummaterial, String _type) { ItemBase item = new ItemBase(enummaterial); item.setMaxStackSize(enummaterial.MAX_STACK_SIZE); item.setUnlocalizedName(_type + enummaterial.suffix); GameRegistry.register(item.setRegistryName(_type + enummaterial.suffix)); OreDictionary.registerOre(_type + enummaterial.suffix, new ItemStack(item, 1, 0)); chunk.setCreativeTab(IndifferentOres.altTabChunks); IndifferentOres.proxy.registerItemRenderer(item); return item; } public static void initItems() { ItemBase item_nugget; ItemBase item_ingot; ItemBase item_chunk; for(EnumMaterialMetal enummaterial:EnumMaterialMetal.values()) { item_nugget = getItem(enummaterial,"nugget"); item_ingot = getItem(enummaterial,"ingot"); item_chunk = getItem(enummaterial,"chunk"); GameRegistry.addRecipe(new ItemStack(item_ingot), new Object[] {"###", "###", "###", '#', item_nugget}); // Nine Nuggets will make one ingot. GameRegistry.addShapelessRecipe(new ItemStack(item_nugget, 9), new ItemStack(item_ingot, 1)); // One Ingot will make nine nuggets GameRegistry.addSmelting(item_chunk, new ItemStack(item_nugget, 3), 1.0F); //One ore Chunk will make three nuggets. } } } Note that if you wanted to access the items you would need to store them in an array or list in the getItem code or ask the registry for them using their registry name.
-
[1.11]Help with Packets, NBT, and Tile Entities
stucuk replied to its_meow's topic in Modder Support
Are you sure the tile entity is actually being created? If there is no TileEntity being created it will return null when you try and get it. The onBlockActivated is called on both client and server, though as diesieben07 sais you want to call it on the server side. public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!world.isRemote) player.openGui(SpaceHeaterMod.mod, 1 , world, pos.getX(), pos.getY(), pos.getZ()); return true; } If we look at a trimmed down IGuiHandler you can see it specifies a bit for server and client. Forge does all the work at deciding which is called. You just tell it what to open and it then calls getServerGuiElement or getClientElement when needed: public class GuiHander implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; // We return a Server GUI Here (one that extends Container) } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; // We return a Client GUI Here (one that extends GUIContainer) } } -
Completely new to modding, but have an idea of what i want.
stucuk replied to Bluethefox's topic in Modder Support
At some point its best to add a config file which lists Blocks which shouldn't be moved (Or which blocks can stop the "teleport" process from happening). Which lets players get around the issue. Your guaranteed to have at least 1 mod out there which will crash when you try and move its block as they will never add certain checks like if the block they are communicating with is actually still in that spot.