Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


Forge Modder
  • Posts

  • Joined

  • Last visited

Everything posted by TheTrollguy_

  1. Well hello there I'm back with rendering-related questions. My main goal is to render my block that I'm about to place in the position it would be placed if I pressed right-click. Here's an example: say I'm looking in the distance, no block outlines are rendered. But, if I'm looking at e.g. dirt (which is near me), I would see it's bounding box (the black outline). If I were to place my block, it would be placed in front of that dirt block. What I want to do is to render my own block in that place (with a certain level of transparency), without actually placing it. I hope I explained it well enough for you to understand.
  2. Welp, I have another problem which really doesn't require a new thread on its own, still connected to showing the capability on the screen. The following code doesn't get called at all. It's inside BSMClientEventHandler(Client only class), however, I had the same code in an another mod and it worked. The event handler class is registered in ClientProxy in init. There's also another event inside BSMClientEventHandler that gets called normally. I really don't know what's happening here, but knowing me it's going to be an idiotic mistake...
  3. Okay another thing, kinda connected to capabilities. In the event RenderGameOverlayEvent.Text, how can I get the player object so I can grab its capability to show it on the screen? Is Minecraft.getMinecraft().player the right way?
  4. I registered my event handler in both preInit and init, so that part has been solved. (Its 1 AM for me) Now 2 questions: 1) Do I put the registrations for event handlers in preInit or init (I've seen both on the internet, both seem to work...) 2) Do I have to do the check in the code? package tt.betterslabsmod.event; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import tt.betterslabsmod.capability.placementmode.PlacementMode; import tt.betterslabsmod.capability.placementmode.PlacementModeProvider; import tt.betterslabsmod.utils.BSMUtils; public class BSMCapabilityHandler { @SubscribeEvent public void attachCapability(AttachCapabilitiesEvent<Entity> event) { // THE LINE DOWN HERE if (event.getObject() instanceof EntityPlayer && !event.getObject().hasCapability(PlacementMode.PLACEMENT_MODE, null)) // <- is the check for the mode even required { event.addCapability(new ResourceLocation(BSMUtils.MODID, "placement_mode"), new PlacementModeProvider()); System.out.println("whatever the hell should be here...."); } } }
  5. Happy Easter to anyone who's reading this! Thanks, @diesieben07, will do that later. I'm getting headaches from these capabilities. I don't fully understand them aand I've got another problem. Here the crash log: All related, name-self-explanatory classes: package tt.betterslabsmod.capability.placementmode; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTPrimitive; import net.minecraft.nbt.NBTTagInt; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability.IStorage; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilitySerializable; public class PlacementMode implements IPlacementMode { @CapabilityInject(IPlacementMode.class) public static final Capability<IPlacementMode> PLACEMENT_MODE = null; private Mode placement_mode = Mode.NORMAL; @Override public void setPlacementMode(PlacementMode.Mode newPlacementMode) { placement_mode = newPlacementMode; } @Override public PlacementMode.Mode getCurrentPlacementMode() { return placement_mode; } public enum Mode { NORMAL(0, "normal"), VERTICAL(1, "vertical"), AXIS(2, "axis"), ROTATIONAL(3, "rotational"), RANDOM(4, "random"); public int ID; public String name; Mode(int ID_, String name_) { this.ID = ID_; this.name = name_; } } } package tt.betterslabsmod.capability.placementmode; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTPrimitive; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.ICapabilitySerializable; public class PlacementModeProvider implements ICapabilitySerializable<NBTBase> { private IPlacementMode instance = PlacementMode.PLACEMENT_MODE.getDefaultInstance(); @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return capability == PlacementMode.PLACEMENT_MODE; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { return capability == PlacementMode.PLACEMENT_MODE ? PlacementMode.PLACEMENT_MODE.<T>cast(instance) : null; } @Override public NBTBase serializeNBT() { return (NBTPrimitive)PlacementMode.PLACEMENT_MODE.getStorage().writeNBT(PlacementMode.PLACEMENT_MODE, instance, null); } @Override public void deserializeNBT(NBTBase NBT) { PlacementMode.PLACEMENT_MODE.getStorage().readNBT(PlacementMode.PLACEMENT_MODE, instance, null, NBT); } } package tt.betterslabsmod.capability.placementmode; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTPrimitive; import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagInt; import net.minecraft.util.EnumFacing; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability.IStorage; public class PlacementModeStorage implements IStorage<IPlacementMode> { @Override public NBTBase writeNBT(Capability<IPlacementMode> capability, IPlacementMode placementMode, EnumFacing side) { return new NBTTagByte((byte)(placementMode.getCurrentPlacementMode().ID)); } @Override public void readNBT(Capability<IPlacementMode> capability, IPlacementMode placementMode, EnumFacing side, NBTBase NBT) { placementMode.setPlacementMode(PlacementMode.Mode.values()[((NBTPrimitive) NBT).getByte()]); } } package tt.betterslabsmod.capability.placementmode; import tt.betterslabsmod.capability.placementmode.PlacementMode.Mode; public interface IPlacementMode { void setPlacementMode(PlacementMode.Mode newPlacementMode); PlacementMode.Mode getCurrentPlacementMode(); }
  6. Everything seems to be going fine for now. Now, I've read that the capability gets reset when a player dies and it says I should do it through an event. So which one should I use, because the tutorial I was looking at s using an old version and that event doesn't exist in the current version. Basically I should have an entity before death and after death or something like that. All in all I don't know how to copy that....
  7. So, you're in the world, and you have one of my slabs in your hands. On the top left part of the screen, it says e.g. horizontal mode. This enables you to place a normal slab, and an upside-down slab. You click F9, and the mode switches to vertical mode. This enables you to place vertical slabs facing where you're facing. You click F9 and it switches to another mode called axis, and then the next one random and so on. I hope I explained it well.
  8. Hello again In my mod, I have a 'property' called placement mode (it's just a custom object) that, as the name says, determines how a block is going to be placed, aka what properties should be set when placed in that mode. If I were to make this mod Client-Only, there wouldn't be any problems, however, I want this mod to be run on servers too and this is a client-specific property. What I want to do with it is send its ID to the server when a player tries to place the block right before the block itself is placed(or the code for the placement is run). So how could I accomplish that?
  9. As the tittle says, I want to render a 2D texture/image in 3D in the same way Minecraft does items - the 2D image is rendered in 3D, with the 3rd dimension being 1 pixel thickness. The block I want to make is going to be a Block Entity, EDIT: To make myself clear. I'm making a block, that has it's own block entity and a special renderer. I'll have to use the special renderer since I'll have too many combinations.
  10. Removed it, same thing, it's looking in the wrong folder. I got over 500 and not even all showed up. I mean how am I supoused to register models for those item blocks
  11. That didn't work at all. Now it won't even load any files and doesn't search through given folders. The bolded should be trafficstuffmod:model/item/cones/cone_big_black Here's what I did: ModelLoader.registerItemVariants(*fileName*); ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation(*fileName*, "inventory")); But I used this code before and it worked perfectly fine, minus the logs that say in the blockstates file I didn't specify the inventory variant ModelBakery.registerItemVariants(item, new ResourceLocation(TSMUtils.MODID_ + names[i])); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, i, new ModelResourceLocation(TSMUtils.MODID_ + names[i], "inventory"));
  12. As the tittle says my console log is filled with these: The thing is, all of my blocks load their models from model\item\*someOtherFolderOrFileHere* and there's no need to load the "#inventory" variant of my block because I handle it myself (please no questions here, it's not about how I register them it's how to get rid of the logs). So is there a way I can make Minecraft/Forge skip searching for that variant/file so it doesn't feed me with over 200 logs like the one above?
  13. Straight to the point. I'm trying to render flowers translated -0.5 on the Y axis if the flower is on top of my grass slab. What I currently have in mind is that I should probably use a drawing event and check if the flower block is being drawn and then translate the drawing start point by -0.5 and probably not cancel the event as it would then make a random XZ offset and draw the flower model. Now this the idea I have, but can someone tell me what the event I should call is called, werther it's pre- or normal drawing event and basically help me move in the right direction.
  14. The tittle says it all, I get this NullPointerException and it's driving me crazy. In the method createBlockState it says that the setType is null, which I checked and for some reason it is null. I really don't know why this is not working... How I register my Block: BOA_0 = new AsphaltSet_BASE("boa_0", SetType.SET_0); Here's the code package tt.roadsmod.asphalt; import java.util.List; import java.util.Random; import javax.annotation.Nullable; import org.apache.commons.lang3.StringUtils; import org.lwjgl.input.Keyboard; import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import tt.roadsmod.asphalt.EnumAsphalt.Half; import tt.roadsmod.asphalt.EnumAsphalt.Set_0; import tt.roadsmod.client.RenderingRegistry; import tt.roadsmod.main.EnumAsphaltColor; import tt.roadsmod.main.EnumAsphaltType; import tt.roadsmod.main.IAsphaltBlockHelper; public class AsphaltSet_BASE extends Block implements IAsphaltBlockHelper { public static final PropertyEnum<Half> HALF = PropertyEnum.create("half", Half.class); public static final PropertyInteger META = PropertyInteger.create("meta", 0, 15); public static final PropertyBool OPEN = PropertyBool.create("open"); public static final PropertyInteger ORIENTATION_SD = PropertyInteger.create("orientation", 1, ; public static final PropertyInteger ORIENTATION_S = PropertyInteger.create("orientation", 1, 4); public static final PropertyInteger ORIENTATION_D = PropertyInteger.create("orientation", 1, 4); public static final PropertyEnum<Set_0> TYPE = PropertyEnum.create("type", Set_0.class); private String name; SetType setType = SetType.FULL; public AsphaltSet_BASE(String name, SetType setType) { super(Material.ROCK); this.name = name; this.setType = setType; register(); loadProperties(); } private void register() { GameRegistry.register(this.setRegistryName(name)); GameRegistry.register(new ItemAsphaltBlock(this, setType).setRegistryName(this.getRegistryName())); } /* PROPERTIES */ private void loadProperties() { setHardness(5.0F*getHeight()); setResistance(10.0F*getHeight()); RenderingRegistry.addToList(this, setType); switch (setType) { case FULL: this.setDefaultState(getDefaultState().withProperty(META, 0)); break; case SET_0: this.setDefaultState(getDefaultState().withProperty(TYPE, Set_0.ASPHALT).withProperty(OPEN, false)); break; case R28: this.setDefaultState(getDefaultState().withProperty(HALF, Half.FIRST).withProperty(ORIENTATION_SD, 0)); break; default: break; } } @Override public float getHeight() { if (StringUtils.contains(name, "coa")) { return 0.75F; } else if (StringUtils.contains(name, "soa")) { return 0.50F; } else if (StringUtils.contains(name, "hoa")) { return 0.25F; } else { return 1.0F; } } @Override public int getSet() { return Integer.valueOf(StringUtils.substringAfterLast(name, "_")); } @Override public EnumAsphaltColor getColor(IBlockState blockState) { return EnumAsphaltColor.getColorByString(setType == SetType.SET_0 ? blockState.getValue(TYPE).getName() : name); } @Override public EnumAsphaltType getType() { return EnumAsphaltType.getTypeByHeight(getHeight()); } @Override public MapColor getMapColor(IBlockState blockState) { return EnumAsphaltColor.getMapColor(getColor(blockState)); } public SetType getSetType() { return setType; } /* SOLID, OPAQUE, FULL CUBE */ @Override public boolean isOpaqueCube(IBlockState blockState) { if (setType == SetType.SET_0) { return (blockState.getValue(OPEN) == true || getHeight() != 1.0F || blockState.getValue(TYPE).getID() > 3) ? false : true; } else { return getHeight() == 1.0F; } } @Override public boolean isFullBlock(IBlockState blockState) { return isOpaqueCube(blockState); } @Override public BlockRenderLayer getBlockLayer() { if (setType == SetType.SET_0) { return BlockRenderLayer.CUTOUT; } else { return BlockRenderLayer.SOLID; } } @Override public boolean isSideSolid(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos, EnumFacing facing) { if (getHeight() == 1.0F) { return true; } else { if (facing == EnumFacing.DOWN) { return true; } else { return false; } } } /* COLLISION AND BOUNDING BOXES */ @Override public void addCollisionBoxToList(IBlockState blockState, World world, BlockPos blockPos, AxisAlignedBB axisAlignedBB, List<AxisAlignedBB> list, @Nullable Entity entity) { if (setType == SetType.SET_0) { this.addCollisionBoxToList(blockPos, axisAlignedBB, list, new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0*getHeight(), 0.0)); this.addCollisionBoxToList(blockPos, axisAlignedBB, list, new AxisAlignedBB(0.0, 0.0, 0.0, 0.0, 1.0*getHeight(), 1.0)); this.addCollisionBoxToList(blockPos, axisAlignedBB, list, new AxisAlignedBB(1.0, 0.0, 0.0, 1.0, 1.0*getHeight(), 1.0)); this.addCollisionBoxToList(blockPos, axisAlignedBB, list, new AxisAlignedBB(0.0, 0.0, 1.0, 1.0, 1.0*getHeight(), 1.0)); if (!(blockState.getValue(OPEN) == true)) { this.addCollisionBoxToList(blockPos, axisAlignedBB, list, new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0*getHeight(), 1.0)); this.addCollisionBoxToList(blockPos, axisAlignedBB, list, new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 0, 1.0)); } } else { this.addCollisionBoxToList(blockPos, axisAlignedBB, list, new AxisAlignedBB(0.0, 0.0, 0.0, 1.0, 1.0*getHeight(), 1.0)); } } @Override public boolean isLadder(IBlockState blockState, IBlockAccess blockAccess, BlockPos blockPos, EntityLivingBase entityLivingBase) { if (setType == SetType.SET_0) { return ((blockState.getValue(TYPE).getID() > 3) && blockState.getValue(OPEN) == true) ? true : false; } else { return false; } } /* BLOCK STATE */ @Override protected BlockStateContainer createBlockState() { System.out.println("################################################"); System.out.println(setType); // THTA'S HOW I CHECKED IF IT'S NULL switch (setType) // THROWS THE EXCEPTION ON THIS LINE { case FULL: return new BlockStateContainer(this, new IProperty[] {META}); case SET_0: return new BlockStateContainer(this, new IProperty[] {TYPE, OPEN}); case R28: return new BlockStateContainer(this, new IProperty[] {HALF, ORIENTATION_SD}); default: return null; } } @Override public IBlockState getStateFromMeta(int meta) { switch (setType) { case FULL: getDefaultState().withProperty(META, meta); case SET_0: return getDefaultState().withProperty(TYPE, EnumAsphalt.Set_0.getTypeByID(meta%).withProperty(OPEN, meta < 8 ? false : true); case R28: return getDefaultState().withProperty(HALF, meta < 8 ? Half.FIRST : Half.SECOND).withProperty(ORIENTATION_SD, meta % 2); default: return null; } } @Override public int getMetaFromState(IBlockState blockState) { switch (setType) { case FULL: return blockState.getValue(META); case SET_0: return ((blockState.getValue(OPEN) == false ? 0 : + blockState.getValue(TYPE).getID()); case R28: return ((blockState.getValue(HALF) == Half.FIRST ? 0 : + blockState.getValue(ORIENTATION_SD)); default: return 0; } } /* DROP, PICK AND TAB */ @Override public Item getItemDropped(IBlockState blockState, Random random, int fortune) { return Item.getItemFromBlock(this); } @Override public int damageDropped(IBlockState blockState) { switch (setType) { case FULL: return blockState.getValue(META); case SET_0: return blockState.getValue(TYPE).getID(); case R28: return (blockState.getValue(HALF) == Half.FIRST ? 0 : ; default: return 0; } } @Override public ItemStack getPickBlock(IBlockState blockState, RayTraceResult rayTraceResult, World world, BlockPos blockPos, EntityPlayer entityPlayer) { return new ItemStack(getItemDropped(blockState, RANDOM, 0), 1, damageDropped(blockState)); } @SideOnly(Side.CLIENT) @Override public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) { switch (setType) { case FULL: for (int i = 0; i < 16; i++) { list.add(new ItemStack(item, 1, i)); } break; case SET_0: for (int i = 0; i < 8; i++) { list.add(new ItemStack(item, 1, i)); } break; case R28: list.add(new ItemStack(item, 1, 0)); list.add(new ItemStack(item, 1, ); break; } } /* SPECIAL FUNCTIONS */ @Override public boolean onBlockActivated(World world, BlockPos blockPos, IBlockState blockState, EntityPlayer entityPlayer, EnumHand hand, @Nullable ItemStack itemStack, EnumFacing side, float hitX, float hitY, float hitZ) { if (setType == SetType.SET_0) { if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) && blockState.getValue(TYPE).getID() > 3) { if (!world.isRemote) { world.setBlockState(blockPos, getDefaultState().withProperty(TYPE, blockState.getValue(TYPE)).withProperty(OPEN, (blockState.getValue(OPEN) == true) ? false : true)); } return true; } } return false; } }
  15. Hi, I was searching through Minecarft's files but I can't find how it renders the leash that connects the player and the leashed mob. I'm trying to make a chain that connects only to blocks just like the leash would to mobs and player. Where can I find the class and what would I need to do? My idea now is to when I right click the block it should spawn an invisible entity inside the block and then the leash should connect to the player and then when I righr click to another block it again spawns the invisible entity and adds the leash to that block(as far as I know the principle is the same because lash knots are entities). This is just the base,I know there are multiple factors I'll have to consider when making those
  16. I saw the EntityHanging class and I believe you. So many unnecessary methods (at least for me). I know I'll have to make my own entity class (not Entity, EntitySign).
  17. Hi! This is the first time I'm making entities for my mod and since I haven't played with entities before I need some direction to help me on the way. What I'm trying to make is an entity that behaves like leash knot - it doesn't move, it's there where it is, but it should have a value for it's facing and the type(aka as I saw the methods write/read from/to NBT I should just write those two tags along other stuff)*. Now how do I make the entity have different textures depending on the 'type' and are there any great tutorials for making entities. Any help is appreciated. *From my understanding how things work in Minecraft, I should make this entity non collidable and it should have no AI. EDIT: Should work kinda like paintings (I'm making traffic signs, just to give you a picture of what I'm doing).
  18. Thanks for the clarification. It was very late when I started playing with Packets. That helped me a lot. It's really nice to see a working example and then based on it make your own working code. I also found this very helpful: http://mcforge.readthedocs.io/en/latest/networking/simpleimpl/ Thank you all for help. I've got everything working perfectly. SOLVED!
  19. Hello again! I've just started playing with packets; I've made my Message and MessageHandler classes and I've done the basics from tutorials. Now I really don't know where to begin and what to do. WHAT I WANT TO DO: During an event send info to server that I want to change the damage of the item I'm currently holding in my hand and after the server sends approval back to actually change it. WHAT I NEED HELP WITH: I basically need a guide telling me what to do, when to send the packet, how to get the player and send that player approval to change the item stack's damage.
  20. Thanks for the help, but I fixed my problems after numerous tries. And nope, I'm not using any for-loops. As I said the mod has a very complex structure that makes my lifes easier when just adding blocks. This is just a piece of code I gave you.
  21. Well I'm not doing something simple and I'm not picking up the block I'm looking at and there are tens and thousands of reasons why the method looks like that. There's no other way. End of discussion.
  22. Yeah Draco, I know, but as I said if the code was any simpler I would've just used this, but I actually have around 100 blocks that use this class and each of them get a different block from the array. I don't think there's a need to specify which block uses what block in that piece of code if there's a simple algorithm.
  23. Ok nevermind the problem of this thread, I fixed it by using a random method I found in the Block class. Now regarding the pick block, it's complicated, around 100 blocks are using the same class and I would have to show you the whole mod code for you to understands since explaining it here really does nothing.
  24. Anyone? It's been a week now, I have been working on other stuff and searching for a solution, but I can't find anything (Sorry for the bump again, but I'm sure I'm not the only one with this problem)
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.