Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Noxyper

Members
  • Joined

  • Last visited

  1. Although quite aggressive, thanks! It works fine.
  2. Hello! I've recently tried to get back to work on my mod that I've not worked on in months. Where I left off, I was working on a system to transfer steam through pipes to power my machinery. What I remember from back then was that some change in my code broke the system and now occasionally the game throws this crash: I've decoded this and found the source of the problem which is in this if statement (I will warn you, this if statement is incredibly long and will therefore look strange in this post. If you copy it and post it in a notepad document, it will look normal): The issue in the statement being this line of code: worldObj.getTileEntity(pos).getTileData().getString("liquid") == worldObj.getTileEntity(new BlockPos(pos.getX() - 1, pos.getY(), pos.getZ())).getTileData().getString("liquid") My theory is that because if the block it is checking for is not a tile entity, it doesn't know what to do and therefore crashes. I don't know how to solve this issue though and would appreciate any help I could get! If any more code is required, just ask me and I'll add it to this main post! Thanks in advance!
  3. Noxyper replied to Noxyper's topic in Modder Support
    Thanks! Now, lastly, how can I make these pipes transport steam from one block to the other? I understand how I can start it off, by adding like a if(world.getBlockState(pos.up) == GnCBlocks.iron_pipe) { but it is in here I'm having troubles. } What do I put in that if-statement?
  4. Noxyper replied to Noxyper's topic in Modder Support
    Alright, that should be working now, but one last question before I move on to the brain of this problem. How can I make my iron pipe and brass pipe not connect?
  5. Noxyper replied to Noxyper's topic in Modder Support
    One problem done, next one! I've messed around with my code to try to connect these pipes to a machine, such as my boiler. The problem here though, is that it isn't working. At all. Here's the code: package com.minenemo.gearsandclouds.blocks; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.Vec3i; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import com.google.common.collect.ImmutableList; public abstract class BlockPipeBase extends Block { public static final float PIPE_MIN_POS = 0.3125f; public static final float PIPE_MAX_POS = 0.6875f; public static final ImmutableList<IProperty> CONNECTED_PROPERTIES = ImmutableList.copyOf(Stream.of(EnumFacing.VALUES).map(facing -> PropertyBool.create(facing.getName())).collect(Collectors.toList())); public static final ImmutableList<AxisAlignedBB> CONNECTED_BOUNDING_BOXES = ImmutableList.copyOf(Stream.of(EnumFacing.VALUES).map(facing -> {Vec3i directionVec = facing.getDirectionVec();return new AxisAlignedBB(getMinBound(directionVec.getX()), getMinBound(directionVec.getY()), getMinBound(directionVec.getZ()),getMaxBound(directionVec.getX()), getMaxBound(directionVec.getY()), getMaxBound(directionVec.getZ()));}).collect(Collectors.toList())); private static float getMinBound(int dir) { return dir == -1 ? 0 : PIPE_MIN_POS; } private static float getMaxBound(int dir) { return dir == 1 ? 1 : PIPE_MAX_POS; } protected BlockPipeBase(Material material) { super(material); } @Override public boolean isOpaqueCube() { return false; } protected boolean isValidPipe(IBlockState ownState, IBlockState neighbourState, IBlockAccess world, BlockPos ownPos, EnumFacing neighbourDirection) { return neighbourState.getBlock() instanceof BlockPipeBase || neighbourState.getBlock() instanceof BlockBoiler || neighbourState.getBlock() instanceof BlockRuster; } private boolean canConnectTo(IBlockState ownState, IBlockAccess worldIn, BlockPos ownPos, EnumFacing neighbourDirection) { BlockPos neighbourPos = ownPos.offset(neighbourDirection); IBlockState neighbourState = worldIn.getBlockState(neighbourPos); Block neighbourBlock = neighbourState.getBlock(); boolean neighbourIsValidForThis = isValidPipe(ownState, neighbourState, worldIn, ownPos, neighbourDirection); boolean pipeIsValidForNeighbour = neighbourBlock instanceof BlockPipeBase && ((BlockPipeBase) neighbourBlock).isValidPipe(neighbourState, ownState, worldIn, neighbourPos, neighbourDirection.getOpposite()); boolean rusterIsValidForNeighbour = neighbourBlock instanceof BlockRuster && ((BlockRuster) neighbourBlock).isValidPipe(neighbourState, ownState, worldIn, neighbourPos, neighbourDirection.getOpposite()); boolean boilerIsValidForNeighbour = neighbourBlock instanceof BlockBoiler && ((BlockBoiler) neighbourBlock).isValidPipe(neighbourState, ownState, worldIn, neighbourPos, neighbourDirection.getOpposite()); boolean thisIsValidForNeighbour = pipeIsValidForNeighbour || rusterIsValidForNeighbour || boilerIsValidForNeighbour; return neighbourIsValidForThis && thisIsValidForNeighbour; } @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { for (EnumFacing facing : EnumFacing.VALUES) { state = state.withProperty(CONNECTED_PROPERTIES.get(facing.getIndex()), canConnectTo(state, world, pos, facing)); } return state; } public final boolean isConnected(IBlockState state, EnumFacing facing) { return (boolean) state.getValue(CONNECTED_PROPERTIES.get(facing.getIndex())); } public void setBlockBounds(AxisAlignedBB bb) { setBlockBounds((float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ); } @Override public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { setBlockBounds(PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MAX_POS, PIPE_MAX_POS, PIPE_MAX_POS); super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); state = getActualState(state, worldIn, pos); for (EnumFacing facing : EnumFacing.VALUES) { if (isConnected(state, facing)) { AxisAlignedBB axisAlignedBB = CONNECTED_BOUNDING_BOXES.get(facing.getIndex()); setBlockBounds(axisAlignedBB); super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); } } setBlockBounds(PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MAX_POS, PIPE_MAX_POS, PIPE_MAX_POS); } }
  6. Noxyper replied to Noxyper's topic in Modder Support
    So now that THAT problem is fixed, I have another issue. Choonster touched upon this briefly and it is the transport of steam power through the pipes. I would rather not use any API, but if I have to, it is fine. As this is a bit bigger, I'll need help with a few different things. First off, where in the BlockPipeBase.java code can I add in the possibility of my pipes connecting to the machines? The code is posted below: BlockPipeBase.java package com.minenemo.gearsandclouds.blocks; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.Vec3i; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import com.google.common.collect.ImmutableList; public abstract class BlockPipeBase extends Block { public static final float PIPE_MIN_POS = 0.3125f; public static final float PIPE_MAX_POS = 0.6875f; public static final ImmutableList<IProperty> CONNECTED_PROPERTIES = ImmutableList.copyOf(Stream.of(EnumFacing.VALUES).map(facing -> PropertyBool.create(facing.getName())).collect(Collectors.toList())); public static final ImmutableList<AxisAlignedBB> CONNECTED_BOUNDING_BOXES = ImmutableList.copyOf(Stream.of(EnumFacing.VALUES).map(facing -> {Vec3i directionVec = facing.getDirectionVec();return new AxisAlignedBB(getMinBound(directionVec.getX()), getMinBound(directionVec.getY()), getMinBound(directionVec.getZ()),getMaxBound(directionVec.getX()), getMaxBound(directionVec.getY()), getMaxBound(directionVec.getZ()));}).collect(Collectors.toList())); private static float getMinBound(int dir) { return dir == -1 ? 0 : PIPE_MIN_POS; } private static float getMaxBound(int dir) { return dir == 1 ? 1 : PIPE_MAX_POS; } protected BlockPipeBase(Material material) { super(material); } @Override public boolean isOpaqueCube() { return false; } protected boolean isValidPipe(IBlockState ownState, IBlockState neighbourState, IBlockAccess world, BlockPos ownPos, EnumFacing neighbourDirection) { return neighbourState.getBlock() instanceof BlockPipeBase; } private boolean canConnectTo(IBlockState ownState, IBlockAccess worldIn, BlockPos ownPos, EnumFacing neighbourDirection) { BlockPos neighbourPos = ownPos.offset(neighbourDirection); IBlockState neighbourState = worldIn.getBlockState(neighbourPos); Block neighbourBlock = neighbourState.getBlock(); boolean neighbourIsValidForThis = isValidPipe(ownState, neighbourState, worldIn, ownPos, neighbourDirection); boolean thisIsValidForNeighbour = neighbourBlock instanceof BlockPipeBase && ((BlockPipeBase) neighbourBlock).isValidPipe(neighbourState, ownState, worldIn, neighbourPos, neighbourDirection.getOpposite()); return neighbourIsValidForThis && thisIsValidForNeighbour; } @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { for (EnumFacing facing : EnumFacing.VALUES) { state = state.withProperty(CONNECTED_PROPERTIES.get(facing.getIndex()), canConnectTo(state, world, pos, facing)); } return state; } public final boolean isConnected(IBlockState state, EnumFacing facing) { return (boolean) state.getValue(CONNECTED_PROPERTIES.get(facing.getIndex())); } public void setBlockBounds(AxisAlignedBB bb) { setBlockBounds((float) bb.minX, (float) bb.minY, (float) bb.minZ, (float) bb.maxX, (float) bb.maxY, (float) bb.maxZ); } @Override public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { setBlockBounds(PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MAX_POS, PIPE_MAX_POS, PIPE_MAX_POS); super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); state = getActualState(state, worldIn, pos); for (EnumFacing facing : EnumFacing.VALUES) { if (isConnected(state, facing)) { AxisAlignedBB axisAlignedBB = CONNECTED_BOUNDING_BOXES.get(facing.getIndex()); setBlockBounds(axisAlignedBB); super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); } } setBlockBounds(PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MIN_POS, PIPE_MAX_POS, PIPE_MAX_POS, PIPE_MAX_POS); } } I'd assume it is in the canConnectTo() method (and maybe the isValidPipe() method) but I don't know how I'm supposed to go about this. I only want the pipe to be able to connect to the boiler from above.
  7. Noxyper replied to Noxyper's topic in Modder Support
    Wow, now I feel stupid. Well, that's programming. Something that easy is always hiding under your nose. Thanks!
  8. Noxyper replied to Noxyper's topic in Modder Support
    Here's all the pipe code https://github.com/BlackHyp3r/GnC/tree/master/Pipe And here is a debug info picture
  9. Noxyper replied to Noxyper's topic in Modder Support
    Yep, it displays the properties. Do you need the full code?
  10. Noxyper replied to Noxyper's topic in Modder Support
    Here's the getActualState code @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { for (EnumFacing facing : EnumFacing.VALUES) { state = state.withProperty(CONNECTED_PROPERTIES.get(facing.getIndex()), canConnectTo(state, world, pos, facing)); } return state; }
  11. Noxyper replied to Noxyper's topic in Modder Support
    So, now I've messed around a bit with what you said and I got the bounding boxes to work, but the pipes don't connect. I attached a picture so that you could see what I mean: And here is the .json files: iron_pipe_side.json (model) { "textures": { "particle": "#side" }, "elements": [ { "name": "Cube", "from": [ 5.0, 5.0, 5.0 ], "to": [ 11.0, 11.0, 11.0 ], "faces": { "north": { "texture": "#side" }, "east": { "texture": "#side" }, "south": { "texture": "#side" }, "west": { "texture": "#side" }, "up": { "texture": "#side" }, "down": { "texture": "#side" } } } ] } iron_pipe_centre.json (model) { "textures": { "particle": "#centre" }, "elements": [ { "name": "Cube", "from": [ 5.0, 5.0, 5.0 ], "to": [ 11.0, 11.0, 11.0 ], "faces": { "north": { "texture": "#centre" }, "east": { "texture": "#centre" }, "south": { "texture": "#centre" }, "west": { "texture": "#centre" }, "up": { "texture": "#centre" }, "down": { "texture": "#centre" } } } ] } iron_pipe.json (blockstate) { "forge_marker": 1, "defaults": { "textures": { "centre": "blocks/iron_block", "side": "blocks/iron_block" }, "model": "gnc:iron_pipe_centre", "uvlock": true }, "variants": { "down": { "true": { "submodel": { "pipe_down": { "model": "gnc:iron_pipe_side", "x": 90, "uvlock": true } } }, "false": { } }, "up": { "true": { "submodel": { "pipe_up": { "model": "gnc:iron_pipe_side", "x": -90, "uvlock": true } } }, "false": { } }, "north": { "true": { "submodel": { "pipe_north": { "model": "gnc:iron_pipe_side", "uvlock": true } } }, "false": { } }, "south": { "true": { "submodel": { "pipe_south": { "model": "gnc:iron_pipe_side", "y": 180, "uvlock": true } } }, "false": { } }, "east": { "true": { "submodel": { "pipe_east": { "model": "gnc:iron_pipe_side", "y": 90, "uvlock": true } } }, "false": { } }, "west": { "true": { "submodel": { "pipe_west": { "model": "gnc:iron_pipe_side", "y": -90, "uvlock": true } } }, "false": { } } } }
  12. Noxyper replied to Noxyper's topic in Modder Support
    No, how would that model look like? If it is going to be universal, how would I go about modelling it? Or am I just misunderstanding your posts?
  13. Noxyper replied to Noxyper's topic in Modder Support
    So how do I go about making the pipe part? How would that look like?
  14. Noxyper replied to Noxyper's topic in Modder Support
    Just so that I haven't wasted my time, I have to make .json files for all the different ways the pipe can connect, right? But 1 blockstate. That is how Mojang did with the redstone so I'm just assuming...
  15. Noxyper posted a topic in Modder Support
    Alrighty then! So, for my mod I want to implement pipes to carry steam from a boiler to other machines. But I'm having some trouble. Maybe I am jumping straight into this, but I'm an okay programmer. I can the basics: armor, items, guis, mobs. But now I want to move on to the more advanced stuff! So, here's the deal. I'll be posting on this post everytime I run into trouble and maybe you guys could help? So my first problem is how to make these pipes connect to one another. I looked at the redstone code, but that just messes with my head. So, just to recap, my first problem is how do I make my pipes change state and connect to each other? Thank you! Hyp3r

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.