• 0

    posted a message on Check if Block is Fluid

    So, I'm able to check if a block is a fluid, but how can I get an instance of "Fluid" from that?


    Edit: Think I've got it. Thanks!


    If anyone needs it:



    IBlockState state = world.getBlockState(pos);
    Block b = state.getBlock();
    
    FluidStack s = null;
    
    if(b instanceof IFluidBlock) {
    	s = new FluidBlockWrapper((IFluidBlock) b, world, pos).getTankProperties()[0].getContents();
    } else if(b instanceof BlockLiquid) {
    	s = new BlockLiquidWrapper((BlockLiquid) b, world, pos).getTankProperties()[0].getContents();
    }
    
    return (s != null) ? s.getFluid() : null;


    Posted in: Modification Development
  • 0

    posted a message on Check if Block is Fluid

    Just a simple question, how would I check if a certain block in the world is a fluid? If it is, how would I get the FluidStack?

    Posted in: Modification Development
  • 0

    posted a message on Getting Fluid from Bucket

    My god I'm stupid. I forgot to register it. Thanks for your help!

    Posted in: Modification Development
  • 0

    posted a message on Getting Fluid from Bucket

    OK, I tried out your code, but upon placement, I get this crash when placing my block:



    net.minecraft.util.ReportedException: Exception ticking world
    	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:704) ~[MinecraftServer.class:?]
    	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:613) ~[MinecraftServer.class:?]
    	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:149) ~[IntegratedServer.class:?]
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471) [MinecraftServer.class:?]
    	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_65]
    Caused by: java.lang.RuntimeException: class com.cjburkey.buildalt.block.tile.TileEntityPump is missing a mapping! This is a bug!
    	at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:81) ~[TileEntity.class:?]
    	at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:72) ~[TileEntity.class:?]
    	at net.minecraftforge.fluids.capability.TileFluidHandler.writeToNBT(TileFluidHandler.java:43) ~[TileFluidHandler.class:?]
    	at com.cjburkey.buildalt.block.tile.TileEntityPump.getUpdateTag(TileEntityPump.java:19) ~[TileEntityPump.class:?]
    	at com.cjburkey.buildalt.block.tile.TileEntityPump.getUpdatePacket(TileEntityPump.java:24) ~[TileEntityPump.class:?]
    	at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:287) ~[PlayerChunkMapEntry.class:?]
    	at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:249) ~[PlayerChunkMapEntry.class:?]
    	at net.minecraft.server.management.PlayerChunkMap.tick(SourceFile:115) ~[PlayerChunkMap.class:?]
    	at net.minecraft.world.WorldServer.tick(WorldServer.java:221) ~[WorldServer.class:?]
    	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:698) ~[MinecraftServer.class:?]
    	... 4 more
    [13:39:52] [Server thread/ERROR]: This crash report has been saved to: /Users/cjburkey/Documents/Files/Java/Modding/Forge/Workspace/BuildcraftAlt/run/./crash-reports/crash-2016-07-10_13.39.52-server.txt
    [13:39:52] [Server thread/INFO]: Stopping server
    [13:39:52] [Server thread/INFO]: Saving players
    [13:39:52] [Client thread/INFO]: [net.minecraft.init.Bootstrap:printToSYSOUT:560]: ---- Minecraft Crash Report ----
    // Uh... Did I do that?
    
    Time: 7/10/16 1:39 PM
    Description: Exception ticking world
    
    java.lang.RuntimeException: class com.cjburkey.buildalt.block.tile.TileEntityPump is missing a mapping! This is a bug!
    	at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:81)
    	at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:72)
    	at net.minecraftforge.fluids.capability.TileFluidHandler.writeToNBT(TileFluidHandler.java:43)
    	at com.cjburkey.buildalt.block.tile.TileEntityPump.getUpdateTag(TileEntityPump.java:19)
    	at com.cjburkey.buildalt.block.tile.TileEntityPump.getUpdatePacket(TileEntityPump.java:24)
    	at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:287)
    	at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:249)
    	at net.minecraft.server.management.PlayerChunkMap.tick(SourceFile:115)
    	at net.minecraft.world.WorldServer.tick(WorldServer.java:221)
    	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:698)
    	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:613)
    	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:149)
    	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:471)
    	at java.lang.Thread.run(Thread.java:745)
    
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- Head --
    Thread: Client thread
    Stacktrace:
    	at net.minecraft.tileentity.TileEntity.writeInternal(TileEntity.java:81)
    	at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:72)
    	at net.minecraftforge.fluids.capability.TileFluidHandler.writeToNBT(TileFluidHandler.java:43)
    	at com.cjburkey.buildalt.block.tile.TileEntityPump.getUpdateTag(TileEntityPump.java:19)
    	at com.cjburkey.buildalt.block.tile.TileEntityPump.getUpdatePacket(TileEntityPump.java:24)
    	at net.minecraft.server.management.PlayerChunkMapEntry.sendBlockEntity(PlayerChunkMapEntry.java:287)
    	at net.minecraft.server.management.PlayerChunkMapEntry.update(PlayerChunkMapEntry.java:249)
    	at net.minecraft.server.management.PlayerChunkMap.tick(SourceFile:115)
    	at net.minecraft.world.WorldServer.tick(WorldServer.java:221)






    Here's the code:



    package com.cjburkey.buildalt.block.tile;
    
    import javax.annotation.Nullable;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.network.NetworkManager;
    import net.minecraft.network.play.server.SPacketUpdateTileEntity;
    import net.minecraftforge.fluids.Fluid;
    import net.minecraftforge.fluids.capability.TileFluidHandler;
    
    public class TileEntityPump extends TileFluidHandler {
    	
    	public static final int CAP = 5 * Fluid.BUCKET_VOLUME;
    	
    	public TileEntityPump() {
    		this.tank = new FluidTankWithTile(this, CAP);
    	}
    	
    	public NBTTagCompound getUpdateTag() {
    		return this.writeToNBT(new NBTTagCompound());
    	}
    	
    	@Nullable
    	public SPacketUpdateTileEntity getUpdatePacket() {
    		return new SPacketUpdateTileEntity(this.getPos(), 0, this.getUpdateTag());
    	}
    	
    	public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
    		this.readFromNBT(pkt.getNbtCompound());
    	}
    	
    }


    Posted in: Modification Development
  • 0

    posted a message on Getting Fluid from Bucket

    Hello, I'm working on a tank-like block. So far, I've got a TileEntity implementing IFluidHandler, which is great, but I have no way of testing whether or not this thing will actually store fluid. How would I implement a "right click with a bucket to fill block" system?

    Posted in: Modification Development
  • 0

    posted a message on Fluid Pump and Quarry

    I'm very impatient, and I don't want to wait for Buildcraft for upgrade lol. Sure, RF Tools has a quarry thing, and I'm using that now, but a dedicated quarry would be nice. Also, a fluid pump is quite necessary in my opinion. Anyway, that's just my 2043¢.

    Posted in: Requests / Ideas For Mods
  • 0

    posted a message on Iguanas Tinker Tweaks
    Quote from endercreeper04»

    any idea if this is going to be continued to 1.8 and 1.9 any time soon? i was kind of disappointed that it wasn't updated with tinkers ;D


    Ditto.
    Posted in: Minecraft Mods
  • 0

    posted a message on Drawing Rect on GUIContainer

    I thought a simple html hex would suffice, do I have to add a number in front to tell the alpha? Sorry for my "noobiness", I'm new to any color system other than simple RGB.


    EDIT: Would 0xFF800000 work?

    Ok, I got it figured out now, thank you very much for your help :)


    This is what I used:

    drawRect(this.guiLeft + 5, this.guiTop + 5, this.guiLeft + 15, this.guiTop + (this.ySize - 5), 0xFFFF0000);
    Posted in: Modification Development
  • 0

    posted a message on Drawing Rect on GUIContainer

    Hello, I've created a custom container GUI, and so far, it works fine. The only issue is that I cannot use the drawRect method for some reason. Iv'e tried it in the background and foreground render but it still refuses to work. Am I used it correctly?



    package com.cjburkey.mods.rafmagn.client.gui;
    
    import com.cjburkey.mods.rafmagn.container.ContainerTileEntityGenerator;
    import com.cjburkey.mods.rafmagn.tile.TileEntityGenerator;
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.client.renderer.GlStateManager;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.util.ResourceLocation;
    
    public class GuiTileEntityGenerator extends GuiContainer {
    	
    	private IInventory playerInv;
    	private TileEntityGenerator te;
    	
    	public GuiTileEntityGenerator(IInventory playerInv, TileEntityGenerator te) {
    		super(new ContainerTileEntityGenerator(playerInv, te));
    		this.playerInv = playerInv;
    		this.te = te;
    		
    		this.xSize = 176;
    		this.ySize = 166;
    	}
    	
    	public boolean doesGuiPauseGame() {
    		return false;
    	}
    	
    	public void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
    		GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
    		this.mc.getTextureManager().bindTexture(new ResourceLocation("rafmagn:textures/gui/container/guiTileEntityGenerator.png"));
    		this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
    	}
    	
    	public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    		String s = this.te.getDisplayName().getUnformattedText();
    		drawRect(this.guiLeft + 5, this.guiTop + 5, this.guiLeft + 15, this.guiTop + (this.ySize - 5), 0x800000);
    		this.fontRendererObj.drawString(s, this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
    		this.fontRendererObj.drawString(this.playerInv.getDisplayName().getUnformattedText(), 8, 72, 4210752);
    	}
    	
    }

    Posted in: Modification Development
  • 0

    posted a message on Texturing Tile Entity
    Quote from Choonster»

    Ok, thank you :)
    Posted in: Modification Development
  • 0

    posted a message on Texturing Tile Entity

    Which methods would I override?

    Posted in: Modification Development
  • 0

    posted a message on Texturing Tile Entity

    I ended up implementing the ITileEntityProvider(I think) class. Either way, I didn't have to do that.

    Posted in: Modification Development
  • 0

    posted a message on Texturing Tile Entity
    Quote from UpcraftLP»

    You'd probably need a custom renderer for your TileEntity. Maybe look at TileEntitySpecialRenderer.



    If I do that, will I have to write all the render code, or can I just override it and give it a texture?


    EDIT: I looked into the furnace tile entity, and it doesn't create its own renderer, is that because it's a sided inventory?

    Posted in: Modification Development
  • 0

    posted a message on Texturing Tile Entity

    For some reason, my tile entity has no texture or model in game. Do I have to create a special renderer to render my tile entity now? If so, how would I go about making it look like any other block?

    Posted in: Modification Development
  • To post a comment, please .