-
Posts
235 -
Joined
-
Last visited
Everything posted by abused_master
-
Currently forge does not have a Fluid API as of 1.13+, they're currently working on a rewrite for it. If you're interested you can check out this PR that was proposed, i say that because KingLemming is the one who was working on the API but someone else has also proposed one so it may or may not be merged. https://github.com/MinecraftForge/MinecraftForge/pull/5983 PS. You really should move to 1.14 from 1.13
-
How do i make a block with a model, that it two blocks high?
abused_master replied to Drachenbauer's topic in Modder Support
That's also pretty simple, all you really need to is create an ItemBlock for your block, and override the placeBlock method, there you can check if the top block is air and place and if not cancel the placement. Edit: Also take a look at the `TallBlockItem` class, it's what minecraft uses for stuff like doors, take a look at Items.OAK_DOOR. (PSA. im on 1.14 so if you're on 1.12 the names will be slightly different) -
You cant exactly just ask someone to do it for you. You need to at least try something so we can help you figure out where to go from there and help if you have any issues. That being said there's multiple ways to create multiblocks as well so you need to decide which one you want. How i usually do multiblocks i have one "master" block, with all the other blocks around it being slave blocks. Then i write my multiblock as a json (doesn't have to be json specifically, could be done in code i just like it being json and customizable), and then once the multiblock master block is activated it'll read that json and check adjacent blocks. Again as i said there's multiple different types of multiblocks, so figure out which you'd like first and then attempt something, as people aren't going to write the code for you.
-
How do i make a block with a model, that it two blocks high?
abused_master replied to Drachenbauer's topic in Modder Support
You could use World#isAirBlock. To get the position above you simply can call .up() on the original blocks position to translate it up by 1. World#setBlockState will take in the state to place and the position to place it at. EX: world.setBlockState(pos, Blocks.STONE_BRICKS.getDefaultState()) If you were setting a state property like direction you could do it here, example with furnace: world.setBlockState(pos, Blocks.FURNACE.getDefaultState().with(FurnaceBlock.FACING, Direction.NORTH)) -
They should work just fine. It would help if you showed some of the files so we can take a look at where the error could be happening. However how it should be in the mtl: map_Kd modid:block/texturename
-
OpenGLHelper is now just GLX, its found in the com.mojang.blaze3d.platform; package
- 1 reply
-
- 1
-
Hello everyone, so earlier today i was attempting to create an entity, now this was the first time i've ever messed with entities so i half didn't know what i was doing, but the issue i'm running into is that, when i attempt to spawn the entity, instantly the game crashes. This is the crash im getting: https://pastebin.com/gmDzeLhA Here's my entity code: https://pastebin.com/mjFRA57E And im attempting to spawn the entity via an item using world.spawnEntity(); @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { world.spawnEntity(new EntityKnowledge(world, player)); return super.onItemRightClick(world, player, hand); } Does anyone happen to know why exactly this might be happening?
-
[1.12.2] Updating rendering to 1.12
abused_master replied to abused_master's topic in Modder Support
What about ISBRH models that needed some GL11 functions? -
Hey guys, so i'm working on updating a mod to 1.12 from 1.7, but am having some trouble with rendering. A lot of their models depend on ISBRH which is no longer a thing, which i can switch over to an BakedModel, however some of them only use the renderInventoryBlock method from ISBRH, so i was wondering what is a viable option i have for editing the block rendering in the inventory? This is what im trying to port over public class BlockCatalystRenderer implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glScalef(-1F, -1F, 1F); GL11.glTranslated(0, -1F, 0); Minecraft.getMinecraft().renderEngine.bindTexture(TileCatalystRenderer.modelTexture); TileCatalystRenderer.model.render(metadata); GL11.glPopMatrix(); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return false; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } @Override public int getRenderId() { return RenderIds.idCatalyst; } }
-
bump?
-
Hmm, all right, that works, reason i was going about it this way was to keep the mod clean in game without cluttering it with blocks that dont have the ore they drop exist
-
All right point taken, what i'm trying to do is register a block based on if an another block is found, in this case oreOsmium if(OreDictionary.doesOreNameExist("oreOsmium")) { event.getRegistry().register(ModBlocks.ModifiedOsmiumOre); } from mekanism, i have tried dependencies = "required-after:forge@[14.23.0.2500,);" + "after:mekanism;" + "after:tconstruct;" + "after:bigreactors;" but that doesn't seem to be changing anything
-
Hey guys, so i was wondering if there was any way to make my mod load absolutely last, reason is i am adding support and checks for other mod's blocks but cannot get it working as they are being loaded after mine but don't want to make those mods a dependency
-
Hello everyone, so i was wondering how i could go about rendering a java model onto my player, when they have the item in their inventory I have the model created, but how would i go about rendering it? I know getArmorModel would be used for armor but im just extending Item. would i use RenderLivingEvent? How would i add the model on the player? Any help would be appreciated, thanks!
-
ok i've implemented getUpdateTag, as for notifyBlockUpdate i am not manually triggering or sending it. Soon i plan to have some fluid rendered for the block but this is after i get the gui situation sorted.
-
Ok i have removed the static fields, as for my syncing all i really have is this: @Nullable @Override public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound data = new NBTTagCompound(); writeToNBT(data); return new SPacketUpdateTileEntity(this.pos, 1, data); } @Override @SideOnly(Side.CLIENT) public void onDataPacket(NetworkManager networkManager, SPacketUpdateTileEntity s35PacketUpdateTileEntity) { readFromNBT(s35PacketUpdateTileEntity.getNbtCompound()); world.markBlockRangeForRenderUpdate(this.pos, this.pos); this.world.notifyBlockUpdate(this.pos, world.getBlockState(this.pos), world.getBlockState(this.pos), 3); } @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { return oldState.getBlock() != newState.getBlock(); }
-
Hey guys, so i'm working on creating a machine that has 2 FluidTanks 1 for water, and 1 for lava, but im running into a little problem: https://gyazo.com/2941bbccab4a2d50d42a0e74f25c4955 thats basically what's happening, and im not sure how to solve it, so i was wondering if one of you guys could help, here's my code: Block onActivated: @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing enumFacing, float side, float hitX, float hitY) { if(!world.isRemote) { ItemStack heldItem = player.getHeldItem(hand); Item item = heldItem.getItem(); final TileEntityOriginator originator = (TileEntityOriginator) world.getTileEntity(pos); IFluidHandler waterHandler = originator.waterTank; IFluidHandler lavaHandler = originator.lavaTank; if (originator != null && !player.isSneaking() && item != Items.LAVA_BUCKET && item != Items.WATER_BUCKET) { player.openGui(TechExpansion.instance, GuiHandler.GUI_ORIGINATOR, world, pos.getX(), pos.getY(), pos.getZ()); } else { if (item == Items.WATER_BUCKET) { FluidActionResult res = FluidUtil.interactWithFluidHandler(heldItem, waterHandler, player); if (res.isSuccess()) { player.setHeldItem(hand, res.getResult()); } } else if (item == Items.LAVA_BUCKET) { FluidActionResult res1 = FluidUtil.interactWithFluidHandler(heldItem, lavaHandler, player); if (res1.isSuccess()) { player.setHeldItem(hand, res1.getResult()); } } } } return true; } TileEntity: public class TileEntityOriginator extends TileEntityInventory { public static FluidTank waterTank; public static FluidTank lavaTank; public static final int SIZE = 3; public int cookTime; public int totalCookTime; public TileEntityOriginator() { super(SIZE); waterTank = new FluidTank(10000); lavaTank = new FluidTank(10000); } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setInteger("CookTime", (short)this.cookTime); nbt.setInteger("TotalCookTime", this.totalCookTime); waterTank.writeToNBT(nbt); lavaTank.writeToNBT(nbt); return super.writeToNBT(nbt); } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); this.cookTime = nbt.getInteger("CookTime"); this.totalCookTime = nbt.getInteger("TotalCookTime"); waterTank.readFromNBT(nbt); lavaTank.readFromNBT(nbt); } @Override public void update() { } public int getCookTime() { return 100; } @Override public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { return this.getCapability(capability, facing) != null; } @Nullable @Override public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { if(facing == EnumFacing.UP) { return (T) waterTank; } if(facing == EnumFacing.DOWN) { return (T) lavaTank; } } return super.getCapability(capability, facing); } } and my GUI: @Override public void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { mc.getTextureManager().bindTexture(Originator); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); renderFluid(); if (this.isPointInRegion(8, 5, 19, 69, mouseX, mouseY)) { List<String> water = new ArrayList<String>(); water.add(originator.waterTank.getFluidAmount() + " / " + originator.waterTank.getCapacity() + " MB"); GuiUtils.drawHoveringText(water, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); } if (this.isPointInRegion(148, 5, 19, 69, mouseX, mouseY)) { List<String> lava = new ArrayList<String>(); lava.add(originator.lavaTank.getFluidAmount() + " / " + originator.lavaTank.getCapacity() + " MB"); GuiUtils.drawHoveringText(lava, mouseX, mouseY, mc.displayWidth, mc.displayHeight, -1, mc.fontRenderer); } } public void renderFluid() { GlStateManager.pushMatrix(); GlStateManager.enableBlend(); final Minecraft mc = Minecraft.getMinecraft(); final Tessellator tessellator = Tessellator.getInstance(); final VertexBuffer buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); setupRenderState(); if (originator.waterTank != null && originator.waterTank.getFluidAmount() > 0) { final int color = originator.waterTank.getFluid().getFluid().getColor(); int i = originator.waterTank.getFluidAmount() * 65 / originator.waterTank.getCapacity(); final TextureAtlasSprite still = mc.getTextureMapBlocks().getTextureExtry(originator.waterTank.getFluid().getFluid().getStill().toString()); addTexturedQuad(buffer, still, guiLeft + 10, guiTop + 7, 15, i, color); } if (originator.lavaTank != null && originator.lavaTank.getFluidAmount() > 0) { final int color = originator.lavaTank.getFluid().getFluid().getColor(); int i = originator.lavaTank.getFluidAmount() * 65 / originator.lavaTank.getCapacity(); final TextureAtlasSprite lavaStill = mc.getTextureMapBlocks().getTextureExtry(originator.lavaTank.getFluid().getFluid().getStill().toString()); addTexturedQuad(buffer, lavaStill, guiLeft + 150, guiTop + 7, 15, i, color); } tessellator.draw(); cleanupRenderState(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); } public static void setupRenderState() { GlStateManager.pushMatrix(); RenderHelper.disableStandardItemLighting(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); if (Minecraft.isAmbientOcclusionEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); } else { GL11.glShadeModel(GL11.GL_FLAT); } } public static void addTexturedQuad(VertexBuffer buffer, TextureAtlasSprite sprite, double x, double y, double width, double height, int color) { if (sprite == null) { return; } final int alpha = color >> 24 & 0xFF; final int red = color >> 16 & 0xFF; final int green = color >> 8 & 0xFF; final int blue = color & 0xFF; addTextureQuad(buffer, sprite, x, y, width, height, red, green, blue, alpha); } public static void addTextureQuad(VertexBuffer buffer, TextureAtlasSprite sprite, double x, double y, double width, double height, int red, int green, int blue, int alpha) { double minU; double maxU; double minV; double maxV; final double size = 16f; final double x2 = x + width; final double y2 = y + height; final double u = x % 1d; double u1 = u + width; while (u1 > 1f) { u1 -= 1f; } final double vy = y % 1d; double vy1 = vy + height; while (vy1 > 1f) { vy1 -= 1f; } minU = sprite.getMinU(); maxU = sprite.getMaxU(); minV = sprite.getMinV(); maxV = sprite.getMaxV(); buffer.pos(x, y, 0).color(red, green, blue, alpha).tex(minU, maxV).endVertex(); buffer.pos(x, y2, 0).color(red, green, blue, alpha).tex(minU, minV).endVertex(); buffer.pos(x2, y2, 0).color(red, green, blue, alpha).tex(maxU, minV).endVertex(); buffer.pos(x2, y, 0).color(red, green, blue, alpha).tex(maxU, maxV).endVertex(); } public static void cleanupRenderState() { GlStateManager.disableBlend(); GlStateManager.popMatrix(); RenderHelper.enableStandardItemLighting(); }
-
ah wow that was surprisingly easy, thanks
-
Hey guys, so i need some help with rendering some stuff in my GUI. So my GUI looks like this: https://gyazo.com/f53e95ac6741f05e8dd2c41c4e89e9a1 what my goal is, is to render a block model in the center black area and have it spinning. I should be able to manage getting it spinning but i cant seem to figure out how to render the block like that with custom dimensions.
-
All right i've fixed those, but the problem still persists, also when the block is broken then replaced, and the world is reloaded the contents disappear, this however does not occur if the block is not moved on initial placement
-
All right i've used NBTTagCompound#setTag and it works fine, but when the block is broken it can be picked up but a ghost block remains on the floor, any idea what could be causing this? also when the block is broken then placed again with fluid inside it gives me this: [09:29:15] [Client thread/ERROR]: Received invalid update packet for null tile entity at BlockPos{x=-137, y=64, z=70} with data: {FluidName:"water",Amount:2000,FluidData:{FluidName:"water",Amount:2000},x:-137,y:64,z:70,id:"minecraft:tile_tank"} the fluid is also rendered at the old position instead of the new one my TileEntity Code: public class TileEntityTank extends TileEntityBase { public FluidTank tank; public TileEntityTank() { tank = new FluidTank(this.tier()); } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); if (nbt.hasKey("FluidData")) { tank.setFluid(FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("FluidData"))); } if(tank != null && tank.getFluid() != null) { tank.readFromNBT(nbt); } if (this.tank != null) { tank.setTileEntity(this); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { if (tank != null && tank.getFluid() != null) { final NBTTagCompound tankTag = new NBTTagCompound(); tank.getFluid().writeToNBT(tankTag); nbt.setTag("FluidData", tankTag); } tank.writeToNBT(nbt); return super.writeToNBT(nbt); } public int tier() { return 60000; } @Override public void update() { if(!world.isRemote) { IBlockState state = world.getBlockState(pos); world.notifyBlockUpdate(pos, state, state, 8); } } @Override public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { return this.getCapability(capability, facing) != null; } @Nullable @Override public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { return (T) this.tank; } return super.getCapability(capability, facing); } }
-
All right so when trying this on a fluid tank it would crash when breaking with java.lang.NullPointerException: Unexpected error at abused_master.techexpansion.blocks.tank.BlockTank.saveFluidToStack(BlockTank.java:151) at abused_master.techexpansion.blocks.tank.BlockTank.removedByPlayer(BlockTank.java:165) at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerDestroyBlock(PlayerControllerMP.java:192) at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerDamageBlock(PlayerControllerMP.java:339) at net.minecraft.client.Minecraft.sendClickBlockToController(Minecraft.java:1512) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2298) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2061) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1849) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1127) at net.minecraft.client.Minecraft.run(Minecraft.java:407) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) this is how i'm saving my data: public ItemStack saveFluidToStack(World world, BlockPos pos) { ItemStack stack = new ItemStack(Item.getItemFromBlock(this)); TileEntityTank te = (TileEntityTank) world.getTileEntity(pos); if (te.tank.getFluid() != null && te.tank.getFluidAmount() > 0) { final NBTTagCompound tileTag = te.writeToNBT(new NBTTagCompound()); stack.getTagCompound().setTag("TileData", tileTag); } return stack; } @Override public boolean removedByPlayer (IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { ItemStack dropStack = saveFluidToStack(world, pos); EntityItem item = new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), dropStack); world.spawnEntity(item); return world.setBlockToAir(pos); } @Override public int quantityDropped(Random random) { return 0; } @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { world.setBlockState(pos, state.withProperty(TYPE, TankTier.get(stack.getMetadata()))); final TileEntityTank tank = (TileEntityTank) world.getTileEntity(pos); if (stack.hasTagCompound()) { if (tank.tank != null) { tank.readFromNBT(stack.getTagCompound().getCompoundTag("TileData")); } } } Line 151 is stack.getTagCompound().setTag("TileData", tileTag);
-
wouldn't that just cause a huge mess in code? and would't i have to do a check for every facing?
-
How can i go about counting the matches found with BlockPos#getAllInBox?
-
I'd like the controller to be placed at the bottom middle, here is a picture of roughly how it will be https://gyazo.com/e40ca6e3b4d682f087e1892208163631 Andesite = frame glass is tank glass, so you can see liquid inside, iron block = input redstone = output furnace = controller yes it will be empty, i want to make it so that those cannot be moved elsewhere with that first part i think i get will, will give it a shot in a little and reply if i have any questions/problems, but is there any place that goes over IBakedModels, how to use them, and an implementation example i could look at?