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.

Cilka

Members
  • Joined

  • Last visited

Everything posted by Cilka

  1. Hello, I'm currently stuck trying to make a block to change its icon/texture based on a relative position to other blocks. Here is the code as it stands now. Any help would be appreciated. Thanks! package com.hexopygate.Telgttatium; import static net.minecraftforge.common.util.ForgeDirection.EAST; import static net.minecraftforge.common.util.ForgeDirection.NORTH; import static net.minecraftforge.common.util.ForgeDirection.SOUTH; import static net.minecraftforge.common.util.ForgeDirection.WEST; import java.util.HashMap; import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockPane; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class TelNormalGlassPane extends BlockPane { protected enum Position { None, Center, Top, Bottom, Left, Right, TopRight, TopLeft, BottomRight, BottomLeft, CenterFull, CenterWalledHorizontal, CenterWalledVertical, BottomWalled, TopWalled } public HashMap<String, IIcon>icons; String FaceTex; static String RimText = "Glass_Trim"; String name = this.getClass().getSimpleName(); private Position position; IIcon currentIcon; public TelNormalGlassPane(String faceTexture, String rimTexture) { super("tel:" + faceTexture, "tel:" + rimTexture, Material.glass, true); // TODO Auto-generated constructor stub position = Position.None; FaceTex = faceTexture; icons = new HashMap<String,IIcon>(); this.setBlockName(name).setBlockTextureName("tel:" + name); GameRegistry.registerBlock(this, this.getUnlocalizedName().substring(5)); } public TelNormalGlassPane(String texture) { this(texture, RimText); } @Override @SideOnly(Side.CLIENT) public int getRenderBlockPass() { return 1; } @Override public void onBlockPlacedBy(World world, int x, int y, int z,EntityLivingBase base, ItemStack itemstack ) { this.position = Position.None; System.out.println("Initial Position: " + this.position); HashMap<String, Block> neighboringBlocks = new HashMap<String, Block>(); neighboringBlocks.put("north", world.getBlock(x, y + 1, z)); neighboringBlocks.put("south", world.getBlock(x, y - 1, z)); neighboringBlocks.put("east", world.getBlock(x + 1, y, z)); neighboringBlocks.put("west", world.getBlock(x - 1, y, z)); System.out.println("Set Neighboring Blocks"); /* * for(String s : neighboringBlocks.keySet()) { * * if(neighboringBlocks.get(s).getMaterial() == Material.air) { * neighboringBlocks.remove(s); continue; } * * } */ SetPosition(neighboringBlocks, x, y); System.out.println("postiion for " + FaceTex + " is " +this.position + " at " + String.format("(%s,%s ,%s)", x,y,z)); String texName = FaceTex; switch(position) { case Top: texName +="_Top_Frame"; break; case Bottom: texName +="_Down_Frame"; break; case BottomLeft: texName +="_Left_Down_Corner_Frame"; break; case BottomRight: texName +="_Right_Down_Corner_Frame"; break; case BottomWalled: texName +="_Down_Single_Frame"; break; case Center: texName +="_Middle_Frame"; break; case CenterFull: texName +="_Full_Frame"; break; case CenterWalledHorizontal: texName +="_Middle_Single_Frame"; break; case CenterWalledVertical: texName += "_Vertical_Middle_Single_Frame"; break; case Left: texName +="_Left_Frame"; break; case Right: texName +="_Right_Frame"; break; case TopLeft: texName +="_Left_Top_Frame"; break; case TopRight: texName +="_Right_Top_Frame"; break; case TopWalled: texName +="_Top_Single_Frame"; break; default: break; } System.out.println("Texture name is " + texName); this.blockIcon = icons.get(texName); } @SideOnly(Side.CLIENT) @Override public IIcon func_150097_e() { return this.blockIcon; } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister registry) { icons.put(FaceTex+"_Full_Frame", registry.registerIcon("tel:"+FaceTex+"_Full_Frame")); icons.put(FaceTex+"_Top_Frame", registry.registerIcon("tel:"+FaceTex+"_Top_Frame")); icons.put(FaceTex+"_Down_Frame", registry.registerIcon("tel:"+FaceTex+"_Down_Frame")); icons.put(FaceTex+"_Left_Down_Corner_Frame", registry.registerIcon("tel:"+FaceTex+"_Left_Down_Corner_Frame")); icons.put(FaceTex+"_Right_Down_Corner_Frame", registry.registerIcon("tel:"+FaceTex+"_Right_Down_Corner_Frame")); icons.put(FaceTex+"_Down_Single_Frame", registry.registerIcon("tel:"+FaceTex+"_Down_Single_Frame")); icons.put(FaceTex+"_Middle_Frame", registry.registerIcon("tel:"+FaceTex+"_Middle_Frame")); icons.put(FaceTex+"_Middle_Single_Frame", registry.registerIcon("tel:"+FaceTex+"_Middle_Single_Frame")); icons.put(FaceTex+"_Vertical_Middle_Single_Frame", registry.registerIcon("tel:"+FaceTex+"_Vertical_Middle_Single_Frame")); icons.put(FaceTex+"_Left_Frame", registry.registerIcon("tel:"+FaceTex+"_Left_Frame")); icons.put(FaceTex+"_Right_Frame", registry.registerIcon("tel:"+FaceTex+"_Right_Frame")); icons.put(FaceTex+"_Left_Top_Frame", registry.registerIcon("tel:"+FaceTex+"_Left_Top_Frame")); icons.put(FaceTex+"_Right_Top_Frame", registry.registerIcon("tel:"+FaceTex+"_Right_Top_Frame")); icons.put(FaceTex+"_Top_Single_Frame", registry.registerIcon("tel:"+FaceTex+"_Top_Single_Frame")); this.blockIcon = icons.get(FaceTex+"_Full_Frame"); this.currentIcon = this.blockIcon; } private void SetPosition(HashMap<String, Block> neighbors, int x, int y) { if (this.position != Position.None) { return; } /* if (neighbors.get("north") instanceof TelNormalGlassPane && neighbors.get("south") instanceof TelNormalGlassPane && neighbors.get("east") instanceof TelNormalGlassPane && neighbors.get("west") instanceof TelNormalGlassPane) { this.position = Position.Center; return; } if ((neighbors.get("north") instanceof Block && neighbors.get("north").getMaterial() != Material.air) && (neighbors.get("south") instanceof Block && neighbors.get("south").getMaterial() != Material.air) && (neighbors.get("east") instanceof Block && neighbors.get("east").getMaterial() != Material.air) && (neighbors.get("west") instanceof Block && neighbors.get("west").getMaterial() != Material.air)) { this.position = Position.CenterFull; return; } if ((neighbors.get("north") instanceof Block && neighbors.get("north").getMaterial() != Material.air) && (neighbors.get("south") instanceof Block && neighbors.get("south").getMaterial() != Material.air) && (neighbors.get("east") instanceof TelNormalGlassPane || neighbors.get("east").getMaterial() == Material.air) && (neighbors.get("west") instanceof TelNormalGlassPane || neighbors.get("west").getMaterial() == Material.air)) { this.position = Position.CenterWalledHorizontal; return; } if ((neighbors.get("north") instanceof TelNormalGlassPane || neighbors.get("north").getMaterial() == Material.air) && (neighbors.get("south") instanceof TelNormalGlassPane || neighbors.get("south").getMaterial() == Material.air) && (neighbors.get("east") instanceof Block && neighbors.get("east").getMaterial() != Material.air) && (neighbors.get("west") instanceof Block && neighbors.get("west").getMaterial() != Material.air)) { this.position = Position.CenterWalledVertical; return; } if ((neighbors.get("south") instanceof Block && neighbors.get("south").getMaterial() != Material.air) && (neighbors.get("east") instanceof Block && neighbors.get("east").getMaterial() != Material.air) && (neighbors.get("west") instanceof Block && neighbors.get("west").getMaterial() != Material.air)) { this.position = Position.BottomWalled; return; } if ((neighbors.get("north") instanceof Block && neighbors.get("north").getMaterial() != Material.air) && (neighbors.get("east") instanceof Block && neighbors.get("east").getMaterial() != Material.air) && (neighbors.get("west") instanceof Block && neighbors.get("west").getMaterial() != Material.air)) { this.position = Position.TopWalled; return; } if ((neighbors.get("north") instanceof Block && neighbors.get("north").getMaterial() != Material.air) && (neighbors.get("east") instanceof Block && neighbors.get("east").getMaterial() != Material.air)) { this.position = Position.TopLeft; return; } if ((neighbors.get("north") instanceof Block && neighbors.get("north").getMaterial() != Material.air) && (neighbors.get("west") instanceof Block && neighbors.get("west").getMaterial() != Material.air)) { this.position = Position.TopRight; return; } if ((neighbors.get("south") instanceof Block && neighbors.get("south").getMaterial() != Material.air) && (neighbors.get("west") instanceof Block && neighbors.get("west").getMaterial() != Material.air)) { this.position = Position.BottomRight; return; } if ((neighbors.get("south") instanceof Block && neighbors.get("south").getMaterial() != Material.air) && (neighbors.get("east") instanceof Block && neighbors.get("east").getMaterial() != Material.air)) { this.position = Position.BottomLeft; return; } if ((neighbors.get("south") instanceof Block && (neighbors.get("south").getMaterial() != Material.air)||)) { this.position = Position.Bottom; return; } if ((neighbors.get("north") instanceof Block && neighbors.get("north").getMaterial() != Material.air)) { this.position = Position.Top; return; } if ((neighbors.get("east") instanceof Block && neighbors.get("east").getMaterial() != Material.air)) { this.position = Position.Left; return; } this.position = Position.Right; */ if(neighbors.get("north").getMaterial() == Material.air) { this.position = Position.Bottom; } else { this.position = Position.Top; } } }

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.