Jump to content

BlockyPenguin

Members
  • Posts

    138
  • Joined

  • Last visited

Everything posted by BlockyPenguin

  1. ah, so, by the sound of that, there's no way to make a FourWayBlock's hitbox suspended in mid air, e.g. like an endrod?
  2. I don't mean to sound rude, but I disagree with that. Many times when learning something new, I'd find some example code, or code that achieves a similar effect to what i need, I'd read through it, attempt to understand and learn from it, then maybe tweak it if needed. I'm sure I'm not the only one! I understand that not everybody does that, but if they are serious about learning whatever it is, then they would. That's just my opinion though.
  3. So, I have a block which extends FourWayBlock. FourWayBlock's constructor takes in 5 numbers. I haven't been able to figure out what they do, with most of them having no impact whatsoever when changed... I know they in some way control the bounds of the block, but in all honesty, I can't see any logic to the way they work. All help appreciated, thanks!
  4. Thanks! I have been looking at fences, walls and the like, so I think I have a better idea now. I'll make those models first, as you said, it might help. Thank you!
  5. Hi! I'm trying to figure out how to make a block like crime-scene tape. In my mind, it would work similarly to a fence in that it connects to its neighbours, but also if you place a tape block above/below it, it will expand to fill the space between. My texture is easily repeatable, so this won't be a problem. This is my first time attempting a block this complex, so any and all help is much appreciated. Thanks!
  6. Hmm, I've had a look at that, thanks, but how would I get that into a single float value between 0 and 1. Sorry, I didn't mention, but I'm using item property overrides here to make an item like a compass
  7. Like the compass finds the direction to the spawn, how would I find the direction to a specific block position? (only x + z matter)
  8. bump? How do i give my block crafting abilities?
  9. bump Please, I really need to know!
  10. bump? Just to reclarify, I'm currently asking: why is this not working, and how do I make my block a crafting block? Edit: I figured out what was wrong with the screen not registering
  11. Oh, ok, thanks, I understand now!
  12. Actually, I've changed my mind on `how I want the crafting system to work. I'd like a GUI instead, so I can show more information. I have a basic container and screen class, but I can't seem to get the screen to register (The container I had no issues with). I have this code in my client setup method: ScreenManager.registerFactory(ModRegistry.ContainerTypes.LABKAULDRON.get(), LabKauldronScreen::new); But I'm getting this warning from my IDE: The type LabKauldronScreen does not define LabKauldronScreen(M, PlayerInventory, ITextComponent) that is applicable here. Here's my screen's code: public class LabKauldronScreen extends ContainerScreen<LabKauldronContainer> { public LabKauldronScreen(LabKauldronContainer container, PlayerInventory inv, ITextComponent name) { super(container, inv, name); } public void render(int mouseX, int mouseY, float partialTicks) { this.renderBackground(); super.render(mouseX, mouseY, partialTicks); this.renderHoveredToolTip(mouseX, mouseY); } //Draw the foreground layer for the GuiContainer (everything in front of the items) protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { this.font.drawString(this.title.getFormattedText(), 8.0F, 6.0F, 4210752); this.font.drawString(this.playerInventory.getDisplayName().getFormattedText(), 8.0F, (float)(this.ySize - 96 + 2), 4210752); } //Draws the background layer of this container (behind the items). protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); this.minecraft.getTextureManager().bindTexture(ModGUITextures.LABKAULDRON_GUI_TEXTURE); int relX = (this.width - this.xSize) / 2; int relY = (this.height - this.ySize) / 2; this.blit(relX, relY, 0, 0, this.xSize, this.ySize); } } I have no idea what's wrong, I've even copy-pasted from several open-source mods and modified it to my classes. The thing is, the code is exactly the same, and it still produces the same errors... All help appreciated, thanks! EDIT: Also, I forgot to mention, how would making recipes static help?
  13. Ah, okay, thank you so much! I feel like ashamed for not thinking of this earlier! I'm a noob lol.
  14. Oh oops! Thanks for pointing that out. I've changed it to this now: @Override public boolean matches(RecipeWrapper inv, World world) { ArrayList<Boolean> list = new ArrayList<Boolean>(); for(int i = 0; i <= ingredients.length; i++) { Ingredient ingredient = ingredients[i]; if(ingredient.test(inv.getStackInSlot(i))) { list.add(true); }else { list.add(false); } } if(list.contains(false)) { return false; } return true; }
  15. Well, by looking at it again, I've changed it to this: @Override public boolean matches(RecipeWrapper inv, World world) { ArrayList<Boolean> list = new ArrayList<Boolean>(); for(int i = 0; i <= ingredients.length; i++) { Ingredient ingredient = ingredients[i]; if(ingredient.test(inv.getStackInSlot(i))) { list.add(true); } } list.add(false); if(list.contains(false)) { return false; } return true; } Which will hopefully work better, but I have no way of checking at the moment, I need some way of finding the recipe the player is currently making. Any ideas? EDIT: Also, how would making recipes static help?
  16. The reason I did this is because I heard that RecipeManager#getRecipes() is system intensive, and shouldn't be called too frequently. currentRecipe will be used to keep track of the recipe that's currently being brewed. Looking at that, I can tell I was tired! 😆 Would this be better? @Override public boolean matches(RecipeWrapper inv, World world) { for(int i = 0; i <= ingredients.length; i++) { Ingredient ingredient = ingredients[i]; if(ingredient.matches(inv.getStackInSlot(i))) { return true; } } return false; }
  17. So I'm trying to create a new crafting block. I've already got the recipe, the serialiser, etc. I've taken a look different crafting blocks in vanilla's code (mostly AbstractFunaceTileEntity, as the other blocks are done without a tile), and I keep writing code, getting stuck, then rewriting it, over and over. How would I go about making this work? I have a custom cauldron block, and I want a player to right-click it to add one of the items in the stack they're holding to the tile's inventory, or if they're holding nothing then drop all the items in the inventory. Here's my code so far: Block: public class LabKauldron extends Block { public LabKauldron() { super(Block.Properties.from(Blocks.CAULDRON) .lootFrom(Blocks.CAULDRON) ); } @Override public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; } @Override public boolean hasTileEntity(BlockState state) { return true; } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new LabKauldronTileEntity(); } @Override public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) { TileEntity tile = world.getTileEntity(pos); //Do something with the tile } } Tile: public class LabKauldronTileEntity extends TileEntity { private LazyOptional<IItemHandler> itemHandler = LazyOptional.of(this::createItemHandler); private ArrayList<CauldronRecipe> recipes = CauldronRecipe.getAllCauldronRecipes(); private CauldronRecipe currentRecipe; public LabKauldronTileEntity() { super(ModRegistry.TileTypes.LABKAULDRON.get()); } @Override @SuppressWarnings("unchecked") public void read(CompoundNBT tag) { CompoundNBT invTag = tag.getCompound("inv"); itemHandler.ifPresent(h -> ((INBTSerializable<CompoundNBT>) h).deserializeNBT(invTag)); super.read(tag); } @Override @SuppressWarnings("unchecked") public CompoundNBT write(CompoundNBT tag) { itemHandler.ifPresent(h -> { CompoundNBT compound = ((INBTSerializable<CompoundNBT>) h).serializeNBT(); tag.put("inv", compound); }); return super.write(tag); } private IItemHandler createItemHandler() { return new ItemStackHandler(50) { @Override protected void onContentsChanged(int slot) { markDirty(); } @Override public boolean isItemValid(int slot, @Nonnull ItemStack stack) { return true; } }; } } CauldronRecipe: public class CauldronRecipe implements ICauldronRecipe { private ResourceLocation id; private ItemStack output; private int cookingDelay; private Ingredient[] ingredients; public CauldronRecipe(ResourceLocation id, ItemStack output, int cookingDelay, Ingredient... ingredients) { this.id = id; this.output = output; this.cookingDelay = cookingDelay; this.ingredients = ingredients; } public ItemStack getIcon() { return new ItemStack(Blocks.CAULDRON); } public IRecipeSerializer<?> getSerializer() { return ModRegistry.RecipeSerializers.CAULDRON_RECIPE.get(); } @Override public boolean matches(RecipeWrapper inv, World world) { for(Ingredient ingredient : ingredients) { if(ingredient.test(inv.getStackInSlot(0)) == false) { return false; } } return true; } @Override public ItemStack getCraftingResult(RecipeWrapper inv) { return output; } @Override public ItemStack getRecipeOutput() { return output; } @Override public ResourceLocation getId() { return id; } @Override public Ingredient[] getInputs() { return ingredients; } @Override public int getCookingDelay() { return cookingDelay; } @Override public NonNullList<Ingredient> getIngredients() { return NonNullList.from(null, getInputs()); } public static ArrayList<CauldronRecipe> getAllCauldronRecipes() { ArrayList<CauldronRecipe> recipeList = new ArrayList<CauldronRecipe>(); RecipeManager rm = new RecipeManager(); for (IRecipe<?> r : rm.getRecipes()) { if(r.getType() == ModRecipeTypes.CAULDRON) { recipeList.add((CauldronRecipe) r); } } return recipeList; } } Also, here's the json file for an example recipe: { "type": "labkit:cauldron", "inputs": [ { "item": "minecraft:dirt", "count": 1 }, { "tag": "forge:seeds", "count": 3 } ], "cooking_delay": 50, "output": { "item": "minecraft:grass_block", "count": 1 } } This all gets parsed correctly, it's just for reference The order of the inputs doesn't matter to me, I'd just like to know how to check if they equal a recipe's ingredients. Thanks!
  18. ...and there's also a whole bunch of errors relating to item handling I'll make a new thread for this.
  19. My guess would be the if (!world.isRemote) { Try removing the if statement, (obviously keeping the switch statement), and see how that goes. I haven't tested it yet myself. I believe world.isRemote checks if the world is on a separate physical server, so by inverting it, you're making it so it only works on a client.
  20. Ok, I figured out where I was going wrong with it not having a tile entity, so that's fixed. Still not sure how to check for recipes...
  21. Ah right ok What about adding it to the build path of the other mod? In eclipse, if you right click your project folder, go to build path > configure build path > libraries and then press "Add external JARs" I mean, I can see forge in there? Again, I don't know much about lib mods, this is just my guesswork.
  22. I'm not going to pretend to know anything about making a library mod, but don't you just add it as a dependency in the mods.toml file of the mods that depend on your library?
×
×
  • Create New...

Important Information

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