Jump to content

[Solved] [1.11] Creating Quarry


abused_master

Recommended Posts

Hello Everyone, im trying to create a quarry in my mod but need a little help with it.

So my idea is when this quarry is placed depending on the side its place it will display a textured line around the outside of where it will mine(64x64 area and down as far as bedrock), and start working on that area, mining, then outputting into an adjacent inventory, and if that isnt available then dont do anything.

so #1 how would i check what direction the block is placed at then draw the like? would i use EnumFacing.NORTH/SOUTH, etc? and if so how would i draw the line with a custom texture

ill get to #2 after this as id like to take it a little bit at a time so i could also learn from this and understand what im doing and how it works.

Link to comment
Share on other sites

Hello Everyone, im trying to create a quarry in my mod but need a little help with it.

So my idea is when this quarry is placed depending on the area it will display a textured line around the outside of where it will mine, and start working on that area, mining, then outputting into an adjacent inventory, and if that isnt available then dont do anything.

so #1 how would i check what direction the block is placed at then draw the like? would i use EnumFacing.NORTH/SOUTH, etc? and if so how would i draw the line with a custom texture

ill get to #2 after this as id like to take it a little bit at a time so i could also learn from this and understand what im doing and how it works.

I would use the blockstates orientation from inside my TileEntity set a variable and either use entities/entity or a TESR if there is a better way to draw the lines someone else say something as that is all that "blockstates orientation" would be getting the blockstate from the world where the TE is and then extracting the variant for the direction. Of course this means you will have to have the Horizontal facing variants. An example of those would be in the FurnaceBlock class.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Hello Everyone, im trying to create a quarry in my mod but need a little help with it.

So my idea is when this quarry is placed depending on the area it will display a textured line around the outside of where it will mine, and start working on that area, mining, then outputting into an adjacent inventory, and if that isnt available then dont do anything.

so #1 how would i check what direction the block is placed at then draw the like? would i use EnumFacing.NORTH/SOUTH, etc? and if so how would i draw the line with a custom texture

ill get to #2 after this as id like to take it a little bit at a time so i could also learn from this and understand what im doing and how it works.

I would use the blockstates orientation from inside my TileEntity set a variable and either use entities/entity or a TESR if there is a better way to draw the lines someone else say something as that is all that "blockstates orientation" would be getting the blockstate from the world where the TE is and then extracting the variant for the direction. Of course this means you will have to have the Horizontal facing variants. An example of those would be in the FurnaceBlock class.

 

What method would i use to check what direction its facing from the blockstate?

Link to comment
Share on other sites

IBlockState#getValue(BlockDirectional.FACING)

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.

Link to comment
Share on other sites

Sounds like your excavator is going to be an extension of BlockHorizontal. That'll give you a property that can be north, east, south or west (see the subset of horizontals within the facing enum). For the initial placement, see how a furnace does so.

 

Take care to separate the block's logic from its rendering. Logic is mostly server-side (world not remote), and rendering is client side-only. Don't scramble their concepts in your mind either.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Iv gone a few steps ahead and created the quarry and made it mine, i also made it mine the chunk its in, so instead of drawing a line in a 64x64 area i just want it to draw a line with a custom texture around the current chunk that the block is in, would that still be in the TESR? and how do i do that specifically to the chunk the block is in?

Link to comment
Share on other sites

Iv gone a few steps ahead and created the quarry and made it mine, i also made it mine the chunk its in, so instead of drawing a line in a 64x64 area i just want it to draw a line with a custom texture around the current chunk that the block is in, would that still be in the TESR? and how do i do that specifically to the chunk the block is in?

First you would have to get the chunks boundaries I would do this by grabbing the x and z position of your TE and convert it to chunk coords. Then from there you can easily get the boundries by converting it back and adding/subtracting 15. Then you need to design what it looks like with a Tessellator and VertexBuffer.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Sorry if i keep changing my idea on how to do this, and it will be the last time

Iv been tinkering a bit and instead have thought to just place blocks outside of the chunk, getting the chunk wont be hard thanks to AnimeFan8888, but how would i place the blocks on the outside of the chunk

int chunkX = getChunkXPos();
int chunkZ = getChunkZPos()
for (int x = chunkX; i < chunkX +/- 16; x++) {
     for (int z = chunkZ; i < chunkZ +/- 16; z++) {
          world.setBlockState(state, new BlockPos(x, pos.getY(), z));
     }
}

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Sorry if i keep changing my idea on how to do this, and it will be the last time

Iv been tinkering a bit and instead have thought to just place blocks outside of the chunk, getting the chunk wont be hard thanks to AnimeFan8888, but how would i place the blocks on the outside of the chunk

int chunkX = getChunkXPos();
int chunkZ = getChunkZPos()
for (int x = chunkX; i < chunkX +/- 16; x++) {
     for (int z = chunkZ; i < chunkZ +/- 16; z++) {
          world.setBlockState(state, new BlockPos(x, pos.getY(), z));
     }
}

so state would be say Blocks.DIAMOND_ORE.getDefaultState() ?

Link to comment
Share on other sites

If you want the block to be diamond, yes.

 

Keep in mind that if you wanted spruce planks instead you'd have to do:

Blocks.PLANKS.getDefaultState().withProperty(BlockPlanks.EnumType.SPRUCE)

(Assuming I got the proper names of everything correct)

Because spurce is a variant.  The default state would get you oak.

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.

Link to comment
Share on other sites

If you want the block to be diamond, yes.

 

Keep in mind that if you wanted spruce planks instead you'd have to do:

Blocks.PLANKS.getDefaultState().withProperty(BlockPlanks.EnumType.SPRUCE)

(Assuming I got the proper names of everything correct)

Because spurce is a variant.  The default state would get you oak.

I see

so i tried to do it with cobblestone like so

world.setBlockState(Blocks.COBBLESTONE.getDefaultState(),new BlockPos(x, pos.getY(), z));

but am getting this error

 

setBlockState

(net.minecraft.util.math.BlockPos, net.minecraft.block.state.IBlockState) in World cannot be applied

to

(net.minecraft.block.state.IBlockState, net.minecraft.util.math.BlockPos)

 

Link to comment
Share on other sites

(A, B) != (B, A)

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.

Link to comment
Share on other sites

When i added and launched my game, and placed down the quarry, it would just freeze the game, no errors in console, no nothing, game just stays frozen

        for (int x = chunkX; i < chunkX + 16; x++) {
            for (int z = chunkZ; i < chunkZ + 16; z++) {
                worldObj.setBlockState(new BlockPos(x, pos.getY(), z), Blocks.COBBLESTONE.getDefaultState());
            }
        }

Link to comment
Share on other sites

When i added and launched my game, and placed down the quarry, it would just freeze the game, no errors in console, no nothing, game just stays frozen

        for (int x = chunkX; i < chunkX + 16; x++) {
            for (int z = chunkZ; i < chunkZ + 16; z++) {
                worldObj.setBlockState(new BlockPos(x, pos.getY(), z), Blocks.COBBLESTONE.getDefaultState());
            }
        }

 

What method is this inside?

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.

Link to comment
Share on other sites

I don't see anything obviously wrong.  Use the debugger and step-through.

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.

Link to comment
Share on other sites

When i added and launched my game, and placed down the quarry, it would just freeze the game, no errors in console, no nothing, game just stays frozen

        for (int x = chunkX; i < chunkX + 16; x++) {
            for (int z = chunkZ; i < chunkZ + 16; z++) {
                worldObj.setBlockState(new BlockPos(x, pos.getY(), z), Blocks.COBBLESTONE.getDefaultState());
            }
        }

What are the values of chunkX and chunkZ?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Iv fixed the problem, someone at the MMD Discord helped me,

So now my quarry mines when given energy, uses energy, places the cobblestone around the area it will mine, the only thing left is outputting the items, how can i make it detect an inventory placed on one of its sides and output the blocks it breaks to it?

Link to comment
Share on other sites

Iv fixed the problem, someone at the MMD Discord helped me,

So now my quarry mines when given energy, uses energy, places the cobblestone around the area it will mine, the only thing left is outputting the items, how can i make it detect an inventory placed on one of its sides and output the blocks it breaks to it?

Easiest way is to loop through the EnumFacings and use the offset function for an enumfacing that BlockPos has then do you if checks on capabilities.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Iv fixed the problem, someone at the MMD Discord helped me,

So now my quarry mines when given energy, uses energy, places the cobblestone around the area it will mine, the only thing left is outputting the items, how can i make it detect an inventory placed on one of its sides and output the blocks it breaks to it?

Easiest way is to loop through the EnumFacings and use the offset function for an enumfacing that BlockPos has then do you if checks on capabilities.

 

could you give me an example of this being done

Link to comment
Share on other sites

Do you want your device to be like a furnace that fills a small inventory until a hopper or player pulls it away? Or, does it need to be like a hopper that can push items into a chest?

 

Being passive and requiring a hopper beneath it to perform the movement task would probably be simpler to code, and that paradigm (parallel to furnace and brewing stand) would make good game sense.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

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

    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
  • Topics

×
×
  • Create New...

Important Information

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