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.

AppliedOnce

Members
  • Joined

  • Last visited

Everything posted by AppliedOnce

  1. I have made a item that I use in recipes and each time it is used it gets damaged, but only when used in the vanilla crafting table. When I use it in a recipe in my custom crafting table I want it to get destroyed.
  2. Hi, I am just wondering how you would go about Crafting Handlers to make them only apply to recipes in the vanilla workbench. Like one item getting damaged if used in a recipe in the vanilla workbench and just getting destroyed when used in a custom workbench recipe.
  3. Hi, I'm working on this furnace and I have gotten everything to work properly except one thing, the progress bars aren't working. Then I found out how the vanilla furnace did it, but when I tried it out it gave me some null pointers and a error log. So here is my Container and error log and the gui in case that is needed. ContainerFuser GuiFuser Error log: Is it something wrong in the code or is that I miss some packets or so. I ealier had some problems with nbt's as well, but a few packets fixed those.
  4. The recipes works without any problems, it takes information from both slots and checks if they are the item they need to be. The only thing that is not working is the writing to NBT, it gives an error on the super.writeToNBT(nbttagcompound); line in the TileEntity. BTW: Changing the names did nothing.
  5. I want a "furnace" with two input and a fuel input. And here is where I get the recipes: package net.blazecoding.magicpowders.recipe; import net.blazecoding.magicpowders.item.ModItems; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class MagicInfuserRecipes { public MagicInfuserRecipes() { } public static ItemStack getInfusingResult(int i, int j, int k, int l) { return getOutput(i, j, k, l); } private static ItemStack getOutput(int i, int j, int k, int l) { if (i == ModItems.magicDust.itemID && k == 0 && j == Item.ingotIron.itemID && l == 0 || i == Item.ingotIron.itemID && k == 0 && j == ModItems.magicDust.itemID && l == 0) { return new ItemStack(ModItems.magicIngot, 1, 0); } if (i == ModItems.magicDust.itemID && k == 1 && j == Item.ingotIron.itemID && l == 0 || i == Item.ingotIron.itemID && k == 0 && j == ModItems.magicDust.itemID && l == 1) { return new ItemStack(ModItems.magicIngot, 1, 1); } if (i == ModItems.magicDust.itemID && k == 2 && j == Item.ingotIron.itemID && l == 0 || i == Item.ingotIron.itemID && k == 0 && j == ModItems.magicDust.itemID && l == 2) { return new ItemStack(ModItems.magicIngot, 1, 2); } return null; } }
  6. Now that I look at it I also get this error in the Console: Don't care about the missing textures, that is a mod that someone else is working on.
  7. Hi, I have just made myself a furnace that takes to inputs (plus the fuel) to make one output. All this works just fine, but the moment I exit the game, if it is any items in the machine, the items disappear. How am I supposed to get rid of this error? CustomFurnaceBlock Class package net.blazecoding.magicpowders.block; import java.util.Random; import net.blazecoding.magicpowders.MagicPowders; import net.blazecoding.magicpowders.lib.Strings; import net.blazecoding.magicpowders.tileentity.TileEntityMagicInfuser; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockMagicInfuser extends BlockContainer { private final Random furnaceRand = new Random(); private final boolean isActive; private static boolean keepFurnaceInventory = false; @SideOnly(Side.CLIENT) private Icon magicInfuserTop; @SideOnly(Side.CLIENT) private Icon magicInfuserFront; protected BlockMagicInfuser(int id, boolean active) { super(id, Material.rock); setUnlocalizedName(Strings.MAGICINFUSERACTIVE_NAME); if (!active) { setUnlocalizedName(Strings.MAGICINFUSER_NAME); setCreativeTab(MagicPowders.tabMP); } this.isActive = active; setHardness(3.0F); setResistance(8.0F); } public int idDropped(int id, Random random, int meta) { return ModBlocks.magicInfuserIdle.blockID; } public void onBlockAdded(World par1World, int par2, int par3, int par4) { super.onBlockAdded(par1World, par2, par3, par4); this.setDefaultDirection(par1World, par2, par3, par4); } private void setDefaultDirection(World par1World, int par2, int par3, int par4) { if (!par1World.isRemote) { int l = par1World.getBlockId(par2, par3, par4 - 1); int i1 = par1World.getBlockId(par2, par3, par4 + 1); int j1 = par1World.getBlockId(par2 - 1, par3, par4); int k1 = par1World.getBlockId(par2 + 1, par3, par4); byte b0 = 3; if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1]) { b0 = 3; } if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l]) { b0 = 2; } if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1]) { b0 = 5; } if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1]) { b0 = 4; } par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2); } } @SideOnly(Side.CLIENT) public Icon getIcon(int par1, int par2) { return par1 == 1 ? this.magicInfuserTop : (par1 == 0 ? this.magicInfuserTop : (par1 != par2 ? this.blockIcon : this.magicInfuserFront)); } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("furnace_side"); this.magicInfuserFront = par1IconRegister.registerIcon(this.isActive ? "furnace_front_on" : "furnace_front_off"); this.magicInfuserTop = par1IconRegister.registerIcon("furnace_top"); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t) { TileEntity tile_entity = world.getBlockTileEntity(x, y, z); if (tile_entity == null || player.isSneaking()) { return false; } player.openGui(MagicPowders.instance, 0, world, x, y, z); return true; } public static void updateFurnaceBlockState(boolean par0, World par1World, int par2, int par3, int par4) { int l = par1World.getBlockMetadata(par2, par3, par4); TileEntity tileentity = par1World.getBlockTileEntity(par2, par3, par4); keepFurnaceInventory = true; if (par0) { par1World.setBlock(par2, par3, par4, ModBlocks.magicInfuserActive.blockID); } else { par1World.setBlock(par2, par3, par4, ModBlocks.magicInfuserIdle.blockID); } keepFurnaceInventory = false; par1World.setBlockMetadataWithNotify(par2, par3, par4, l, 2); if (tileentity != null) { tileentity.validate(); par1World.setBlockTileEntity(par2, par3, par4, tileentity); } } @SideOnly(Side.CLIENT) public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { } public TileEntity createNewTileEntity(World world) { return new TileEntityMagicInfuser(); } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) { int l = MathHelper.floor_double((double) (par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); } if (l == 1) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); } if (l == 2) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); } if (l == 3) { par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2); } if (par6ItemStack.hasDisplayName()) { ((TileEntityFurnace) par1World.getBlockTileEntity(par2, par3, par4)).setGuiDisplayName(par6ItemStack.getDisplayName()); } } public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { if (!keepFurnaceInventory) { TileEntityMagicInfuser tileentityfurnace = (TileEntityMagicInfuser) par1World.getBlockTileEntity(par2, par3, par4); if (tileentityfurnace != null) { for (int j1 = 0; j1 < tileentityfurnace.getSizeInventory(); ++j1) { ItemStack itemstack = tileentityfurnace.getStackInSlot(j1); if (itemstack != null) { float f = this.furnaceRand.nextFloat() * 0.8F + 0.1F; float f1 = this.furnaceRand.nextFloat() * 0.8F + 0.1F; float f2 = this.furnaceRand.nextFloat() * 0.8F + 0.1F; while (itemstack.stackSize > 0) { int k1 = this.furnaceRand.nextInt(21) + 10; if (k1 > itemstack.stackSize) { k1 = itemstack.stackSize; } itemstack.stackSize -= k1; EntityItem entityitem = new EntityItem(par1World, (double) ((float) par2 + f), (double) ((float) par3 + f1), (double) ((float) par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage())); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); } float f3 = 0.05F; entityitem.motionX = (double) ((float) this.furnaceRand.nextGaussian() * f3); entityitem.motionY = (double) ((float) this.furnaceRand.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double) ((float) this.furnaceRand.nextGaussian() * f3); par1World.spawnEntityInWorld(entityitem); } } } par1World.func_96440_m(par2, par3, par4, par5); } } super.breakBlock(par1World, par2, par3, par4, par5, par6); } public boolean hasComparatorInputOverride() { return true; } public int getComparatorInputOverride(World par1World, int par2, int par3, int par4, int par5) { return Container.calcRedstoneFromInventory((IInventory) par1World.getBlockTileEntity(par2, par3, par4)); } } Custom TileEntityFurnace class package net.blazecoding.magicpowders.tileentity; import net.blazecoding.magicpowders.item.ModItems; import net.blazecoding.magicpowders.recipe.MagicInfuserRecipes; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import cpw.mods.fml.common.registry.GameRegistry; public class TileEntityMagicInfuser extends TileEntity implements IInventory { private ItemStack infuserItemStacks[]; public int dualBurnTime; public int currentItemBurnTime; public int dualCookTime; private String magicInfuserName; public TileEntityMagicInfuser() { infuserItemStacks = new ItemStack[4]; dualBurnTime = 0; currentItemBurnTime = 0; dualCookTime = 0; } public int getSizeInventory() { return infuserItemStacks.length; } public ItemStack getStackInSlot(int i) { return infuserItemStacks[i]; } public void setInventorySlotConatainers(int i, ItemStack itemstack) { infuserItemStacks[i] = itemstack; if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } } public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); infuserItemStacks = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); byte byte0 = nbttagcompound1.getByte("Slot"); if (byte0 >= 0 && byte0 < infuserItemStacks.length) { infuserItemStacks[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } dualBurnTime = nbttagcompound.getShort("BurnTime"); dualCookTime = nbttagcompound.getShort("CookTime"); currentItemBurnTime = getItemBurnTime(infuserItemStacks[1]); } public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); nbttagcompound.setShort("BurnTime", (short) dualBurnTime); nbttagcompound.setShort("CookTime", (short) dualCookTime); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < infuserItemStacks.length; i++) { if (infuserItemStacks[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte) i); infuserItemStacks[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } nbttagcompound.setTag("Items", nbttaglist); } public int getInventoryStackLimit() { return 64; } public int getCookProgressScaled(int i) { return (dualCookTime * i) / 200; } public int getBurnTimeRemainingScaled(int i) { if (currentItemBurnTime == 0) { currentItemBurnTime = 200; } return (dualBurnTime * i) / currentItemBurnTime; } public boolean isBurning() { return dualBurnTime > 0; } public void updateEntity() { boolean flag = dualBurnTime > 0; boolean flag1 = false; if (dualBurnTime > 0) { dualBurnTime--; } if (!worldObj.isRemote) { if (dualBurnTime == 0 && canSmelt()) { currentItemBurnTime = dualBurnTime = getItemBurnTime(infuserItemStacks[2]); if (dualBurnTime > 0) { flag1 = true; if (infuserItemStacks[2] != null) { if (infuserItemStacks[2].stackSize == 0) { infuserItemStacks[2] = new ItemStack(infuserItemStacks[2].getItem().setFull3D()); } else { infuserItemStacks[2].stackSize--; } if (infuserItemStacks[2].stackSize == 0) { infuserItemStacks[2] = null; } } } } if (isBurning() && canSmelt()) { dualCookTime++; if (dualCookTime == 200) { dualCookTime = 0; smeltItem(); flag1 = true; } } else { dualCookTime = 0; } if (flag != (dualBurnTime > 0)) { flag1 = true; } } if (flag1) { onInventoryChanged(); } } private boolean canSmelt() { if (infuserItemStacks[0] == null || infuserItemStacks[1] == null) { return false; } ItemStack itemstack = MagicInfuserRecipes.getSmeltingResult(infuserItemStacks[0].getItem().itemID, infuserItemStacks[1].getItem().itemID); if (itemstack == null) { return false; } if (infuserItemStacks[3] == null) { return true; } if (!infuserItemStacks[3].isItemEqual(itemstack)) { return false; } if (infuserItemStacks[3].stackSize < getInventoryStackLimit() && infuserItemStacks[3].stackSize < infuserItemStacks[3].getMaxStackSize()) { return true; } else { return infuserItemStacks[3].stackSize < itemstack.getMaxStackSize(); } } public void smeltItem() { if (!canSmelt()) { return; } ItemStack itemstack = MagicInfuserRecipes.getSmeltingResult(infuserItemStacks[0].getItem().itemID, infuserItemStacks[1].getItem().itemID); if (infuserItemStacks[3] == null) { infuserItemStacks[3] = itemstack.copy(); } else if (infuserItemStacks[3].itemID == itemstack.itemID) { infuserItemStacks[3].stackSize++; } for (int i = 0; i < 2; i++) { if (infuserItemStacks[i].stackSize <= 0) { infuserItemStacks[i] = new ItemStack(infuserItemStacks[i].getItem().setFull3D()); } else { infuserItemStacks[i].stackSize--; } if (infuserItemStacks[i].stackSize <= 0) { infuserItemStacks[i] = null; } } } private int getItemBurnTime(ItemStack itemstack) { if (itemstack == null) { return 0; } int i = itemstack.getItem().itemID; if (i == ModItems.magicDust.itemID) { return 2000; } else { return GameRegistry.getFuelValue(itemstack); } } public boolean isUseableByPlayer(EntityPlayer entityplayer) { if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) { return false; } else { return entityplayer.getDistanceSq((double) xCoord + 0.5D, (double) yCoord + 0.5D, (double) zCoord + 0.5D) <= 64D; } } public ItemStack decrStackSize(int i, int j) { if (infuserItemStacks[i] != null) { if (infuserItemStacks[i].stackSize <= j) { ItemStack itemstack = infuserItemStacks[i]; infuserItemStacks[i] = null; return itemstack; } ItemStack itemstack1 = infuserItemStacks[i].splitStack(j); if (infuserItemStacks[i].stackSize == 0) { infuserItemStacks[i] = null; } return itemstack1; } else { return null; } } public void setInventorySlotContents(int i, ItemStack itemstack) { infuserItemStacks[i] = itemstack; if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } } public String getInvName() { return "container.infuser"; } public void openChest() { } public void closeChest() { } public ItemStack getStackInSlotOnClosing(int i) { if (infuserItemStacks[i] != null) { ItemStack itemstack = infuserItemStacks[i]; infuserItemStacks[i] = null; return itemstack; } else { return null; } } public boolean isInvNameLocalized() { return (this.magicInfuserName != null) && (this.magicInfuserName.length() > 0); } public void setCustomName(String name) { this.magicInfuserName = name; } public boolean isItemValidForSlot(int i, ItemStack itemstack) { return false; } } Custom Container Class package net.blazecoding.magicpowders.inventory; import net.blazecoding.magicpowders.inventory.slot.SlotMagicInfuser; import net.blazecoding.magicpowders.tileentity.TileEntityMagicInfuser; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class ContainerMagicInfuser extends Container { private TileEntityMagicInfuser infuser; private int dualCookTime; private int dualBurnTime; private int lastItemBurnTime; public ContainerMagicInfuser(InventoryPlayer inventoryplayer, TileEntityMagicInfuser tileentityInputFurnace) { dualCookTime = 0; dualBurnTime = 0; lastItemBurnTime = 0; infuser = tileentityInputFurnace; this.addSlotToContainer(new Slot(tileentityInputFurnace, 0, 38, 17)); this.addSlotToContainer(new Slot(tileentityInputFurnace, 1, 74, 17)); this.addSlotToContainer(new Slot(tileentityInputFurnace, 2, 56, 53)); this.addSlotToContainer(new SlotMagicInfuser(inventoryplayer.player, tileentityInputFurnace, 3, 116, 35)); for (int i = 0; i < 3; i++) { for (int k = 0; k < 9; k++) { this.addSlotToContainer(new Slot(inventoryplayer, k + i * 9 + 9, 8 + k * 18, 84 + i * 18)); } } for (int j = 0; j < 9; j++) { this.addSlotToContainer(new Slot(inventoryplayer, j, 8 + j * 18, 142)); } } public void addCraftingToCrafters(ICrafting par1ICrafting) { super.addCraftingToCrafters(par1ICrafting); par1ICrafting.sendProgressBarUpdate(this, 0, this.infuser.dualCookTime); par1ICrafting.sendProgressBarUpdate(this, 1, this.infuser.dualBurnTime); par1ICrafting.sendProgressBarUpdate(this, 2, this.infuser.currentItemBurnTime); } public void detectAndSendChanges() { super.detectAndSendChanges(); for (int var1 = 0; var1 < this.crafters.size(); ++var1) { ICrafting var2 = (ICrafting) this.crafters.get(var1); if (this.dualCookTime != this.infuser.dualCookTime) { var2.sendProgressBarUpdate(this, 0, this.infuser.dualCookTime); } if (this.dualBurnTime != this.infuser.dualBurnTime) { var2.sendProgressBarUpdate(this, 1, this.infuser.dualBurnTime); } if (this.lastItemBurnTime != this.infuser.currentItemBurnTime) { var2.sendProgressBarUpdate(this, 2, this.infuser.currentItemBurnTime); } } this.dualCookTime = this.infuser.dualCookTime; this.dualBurnTime = this.infuser.dualBurnTime; this.lastItemBurnTime = this.infuser.currentItemBurnTime; } public void updateProgressBar(int i, int j) { if (i == 0) { infuser.dualCookTime = j; } if (i == 1) { infuser.dualBurnTime = j; } if (i == 2) { infuser.currentItemBurnTime = j; } } public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot) inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == 2) { if (!mergeItemStack(itemstack1, 3, 39, true)) { return null; } } else if (par2 >= 3 && par2 < 30) { if (!mergeItemStack(itemstack1, 30, 39, false)) { return null; } } else if (par2 >= 30 && par2 < 39) { if (!mergeItemStack(itemstack1, 3, 30, false)) { return null; } } else if (!mergeItemStack(itemstack1, 3, 39, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack(null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize != itemstack.stackSize) { slot.onPickupFromSlot(par1EntityPlayer, itemstack1); } else { return null; } } return itemstack; } public boolean canInteractWith(EntityPlayer entityplayer) { return infuser.isUseableByPlayer(entityplayer); } } Custom FurnaceSlot class package net.blazecoding.magicpowders.inventory.slot; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class SlotMagicInfuser extends Slot { public SlotMagicInfuser(EntityPlayer entityplayer, IInventory iinventory, int i, int j, int k) { super(iinventory, i, j, k); } public boolean isItemValid(ItemStack itemstack) { return false; } public void onPickupFromSlot(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) { this.onCrafting(par2ItemStack); super.onPickupFromSlot(par1EntityPlayer, par2ItemStack); } }
  8. So I'm working on my mod and I wanted to make a enderman-like creature that is always from the very start holding a lapis lazuli block. So I wondered if anyone could tell me how I could do this since, the vanilla minecraft is using some variables that holds what they are able to carry and then they make them randomly picking up blocks from those they are able to pick up.
  9. Moving the portal won't work, this will only make you stuck inside the dimension you want to get to when entering the portal. The only way I see is make it be with a timer, but I don't really know how to make one.
  10. I got it to work, but there is some stuff bugging me... The first thing is that it doesn't seem like very good coding for sure. The second thing is that when the leaf is next to a block you can look through it straight down to the void. Anyone know of a better way of doing this? Here is the code I'm sitting with right now: TickHandler: public class SacredTickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if (type.equals(EnumSet.of(TickType.CLIENT))) { BlockSacredLeaves.setGraphicsLevel(!Minecraft.getMinecraft().gameSettings.fancyGraphics); } } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.CLIENT); } @Override public String getLabel() { return null; } } BlockSacredLeavesBase: public class BlockSacredLeavesBase extends Block { public static boolean graphicsLevel; public BlockSacredLeavesBase(int par1, Material par2Material, boolean par3) { super(par1, par2Material); this.graphicsLevel = par3; } public boolean isOpaqueCube() { return false; } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { int i1 = par1IBlockAccess.getBlockId(par2, par3, par4); return !this.graphicsLevel && i1 == this.blockID ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5); } } BlockSacredLeaves: public class BlockSacredLeaves extends BlockSacredLeavesBase implements IShearable { public static final String[] LEAF_TYPES = new String[] { "sena", "whuna", "3", "4" }; public static final String[][] graphicLeaves = new String[][] { { "sena_leaves", "whuna_leaves", "3_leaves", "4_leaves" }, { "sena_leaves_opaque", "whuna_leaves_opaque", "3_leaves_opaque", "4_leaves_opaque" } }; @SideOnly(Side.CLIENT) private static int field_94394_cP; private Icon[][] iconArray = new Icon[2][]; int[] adjacentTreeBlocks; public BlockSacredLeaves(int par1) { super(par1, Material.leaves, false); this.setTickRandomly(true); setCreativeTab(SacredGrounds.tabSacred); } public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { byte b0 = 1; int j1 = b0 + 1; if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1)) { for (int k1 = -b0; k1 <= b0; ++k1) { for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { int j2 = par1World.getBlockId(par2 + k1, par3 + l1, par4 + i2); if (Block.blocksList[j2] != null) { Block.blocksList[j2].beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2); } } } } } } public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!par1World.isRemote) { int l = par1World.getBlockMetadata(par2, par3, par4); if ((l & != 0 && (l & 4) == 0) { byte b0 = 4; int i1 = b0 + 1; byte b1 = 32; int j1 = b1 * b1; int k1 = b1 / 2; if (this.adjacentTreeBlocks == null) { this.adjacentTreeBlocks = new int[b1 * b1 * b1]; } int l1; if (par1World.checkChunksExist(par2 - i1, par3 - i1, par4 - i1, par2 + i1, par3 + i1, par4 + i1)) { int i2; int j2; int k2; for (l1 = -b0; l1 <= b0; ++l1) { for (i2 = -b0; i2 <= b0; ++i2) { for (j2 = -b0; j2 <= b0; ++j2) { k2 = par1World.getBlockId(par2 + l1, par3 + i2, par4 + j2); Block block = Block.blocksList[k2]; if (block != null && block.canSustainLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0; } else if (block != null && block.isLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2; } else { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1; } } } } for (l1 = 1; l1 <= 4; ++l1) { for (i2 = -b0; i2 <= b0; ++i2) { for (j2 = -b0; j2 <= b0; ++j2) { for (k2 = -b0; k2 <= b0; ++k2) { if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) { if (this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1; } } } } } } } l1 = this.adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1]; if (l1 >= 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, l & -9, 4); } else { this.removeLeaves(par1World, par2, par3, par4); } } } } @SideOnly(Side.CLIENT) public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (par1World.canLightningStrikeAt(par2, par3 + 1, par4) && !par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && par5Random.nextInt(15) == 1) { double d0 = (double) ((float) par2 + par5Random.nextFloat()); double d1 = (double) par3 - 0.05D; double d2 = (double) ((float) par4 + par5Random.nextFloat()); par1World.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D); } } private void removeLeaves(World par1World, int par2, int par3, int par4) { this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); } public int quantityDropped(Random par1Random) { return par1Random.nextInt(20) == 0 ? 1 : 0; } public int idDropped(int par1, Random par2Random, int par2) { return SacredBlocks.sacredSaplings.blockID; } public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) { if (!par1World.isRemote) { int j1 = 20; if ((par5 & 3) == 3) { j1 = 40; } if (par7 > 0) { j1 -= 2 << par7; if (j1 < 10) { j1 = 10; } } if (par1World.rand.nextInt(j1) == 0) { int k1 = this.idDropped(par5, par1World.rand, par7); this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(k1, 1, this.damageDropped(par5))); } j1 = 200; if (par7 > 0) { j1 -= 10 << par7; if (j1 < 40) { j1 = 40; } } if ((par5 & 3) == 0 && par1World.rand.nextInt(j1) == 0) { this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Item.appleGold, 1, 0)); } } } public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); } public int damageDropped(int par1) { return par1 & 3; } public boolean isOpaqueCube() { return !this.graphicsLevel; } @SideOnly(Side.CLIENT) public Icon getBlockTextureFromSideAndMetadata(int par1, int par2) { return (par2 & 3) == 1 ? this.iconArray[this.field_94394_cP][1] : ((par2 & 3) == 3 ? this.iconArray[this.field_94394_cP][3] : this.iconArray[this.field_94394_cP][0]); } @SideOnly(Side.CLIENT) public static void setGraphicsLevel(boolean par1) { graphicsLevel = par1; field_94394_cP = par1 ? 0 : 1; } @SuppressWarnings({ "unchecked", "rawtypes" }) @SideOnly(Side.CLIENT) public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { for (int i = 0; i < graphicLeaves.length; ++i) { this.iconArray[i] = new Icon[graphicLeaves[i].length]; for (int j = 0; j < graphicLeaves[i].length; ++j) { this.iconArray[i][j] = par1IconRegister.registerIcon("sacredgrounds:" + graphicLeaves[i][j]); } } } @Override public boolean isShearable(ItemStack item, World world, int x, int y, int z) { return true; } @Override public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune) { ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 3)); return ret; } @Override public void beginLeavesDecay(World world, int x, int y, int z) { world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4); } @Override public boolean isLeaves(World world, int x, int y, int z) { return true; } }
  11. Noone knows how to fix this issue?
  12. I've got my TickHandler set up, I think. But I don't know what more to put inside it. Anyone have any idea? Here is the TickHandler as for now: package com.xeto.sacredgrounds.handler; import java.util.EnumSet; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; public class SacredTickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { if (type.equals(EnumSet.of(TickType.CLIENT))) { } } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.CLIENT); } @Override public String getLabel() { return null; } }
  13. Okey, I got a bug with my new dimension that when I go into my portal it constantly sends me back to the the vanilla surface and then constantly back to my dimension again and this goes on in an ever lasting loop. Could anyone help me with this issue? Here is my code: TeleporterSacredGrounds: public class TeleporterSacredGrounds extends Teleporter { private final WorldServer worldServerInstance; /** A private Random() function in Teleporter */ private final Random random; private final LongHashMap field_85191_c = new LongHashMap(); @SuppressWarnings("rawtypes") private final List field_85190_d = new ArrayList(); public TeleporterSacredGrounds(WorldServer par1WorldServer) { super(par1WorldServer); this.worldServerInstance = par1WorldServer; this.random = new Random(par1WorldServer.getSeed()); } /** * Place an entity in a nearby portal, creating one if necessary. */ public void placeInPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { if (this.worldServerInstance.provider.dimensionId != 1) { if (!this.placeInExistingPortal(par1Entity, par2, par4, par6, par8)) { this.makePortal(par1Entity); this.placeInExistingPortal(par1Entity, par2, par4, par6, par8); } } else { int i = MathHelper.floor_double(par1Entity.posX); int j = MathHelper.floor_double(par1Entity.posY) - 1; int k = MathHelper.floor_double(par1Entity.posZ); byte b0 = 1; byte b1 = 0; for (int l = -2; l <= 2; ++l) { for (int i1 = -2; i1 <= 2; ++i1) { for (int j1 = -1; j1 < 3; ++j1) { int k1 = i + i1 * b0 + l * b1; int l1 = j + j1; int i2 = k + i1 * b1 - l * b0; boolean flag = j1 < 0; this.worldServerInstance.setBlock(k1, l1, i2, flag ? Block.blockLapis.blockID : 0); } } } par1Entity.setLocationAndAngles((double) i, (double) j, (double) k, par1Entity.rotationYaw, 0.0F); par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; } } /** * Place an entity in a nearby portal which already exists. */ @SuppressWarnings("unchecked") public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8) { short short1 = 128; double d3 = -1.0D; int i = 0; int j = 0; int k = 0; int l = MathHelper.floor_double(par1Entity.posX); int i1 = MathHelper.floor_double(par1Entity.posZ); long j1 = ChunkCoordIntPair.chunkXZ2Int(l, i1); boolean flag = true; double d4; int k1; if (this.field_85191_c.containsItem(j1)) { PortalPosition portalposition = (PortalPosition) this.field_85191_c.getValueByKey(j1); d3 = 0.0D; i = portalposition.posX; j = portalposition.posY; k = portalposition.posZ; portalposition.field_85087_d = this.worldServerInstance.getTotalWorldTime(); flag = false; } else { for (k1 = l - short1; k1 <= l + short1; ++k1) { double d5 = (double) k1 + 0.5D - par1Entity.posX; for (int l1 = i1 - short1; l1 <= i1 + short1; ++l1) { double d6 = (double) l1 + 0.5D - par1Entity.posZ; for (int i2 = this.worldServerInstance.getActualHeight() - 1; i2 >= 0; --i2) { if (this.worldServerInstance.getBlockId(k1, i2, l1) == SacredBlocks.sacredPortal.blockID) { while (this.worldServerInstance.getBlockId(k1, i2 - 1, l1) == SacredBlocks.sacredPortal.blockID) { --i2; } d4 = (double) i2 + 0.5D - par1Entity.posY; double d7 = d5 * d5 + d4 * d4 + d6 * d6; if (d3 < 0.0D || d7 < d3) { d3 = d7; i = k1; j = i2; k = l1; } } } } } } if (d3 >= 0.0D) { if (flag) { this.field_85191_c.add(j1, new PortalPosition(this, i, j, k, this.worldServerInstance.getTotalWorldTime())); this.field_85190_d.add(Long.valueOf(j1)); } double d8 = (double) i + 0.5D; double d9 = (double) j + 0.5D; d4 = (double) k + 0.5D; int j2 = -1; if (this.worldServerInstance.getBlockId(i - 1, j, k) == SacredBlocks.sacredPortal.blockID) { j2 = 2; } if (this.worldServerInstance.getBlockId(i + 1, j, k) == SacredBlocks.sacredPortal.blockID) { j2 = 0; } if (this.worldServerInstance.getBlockId(i, j, k - 1) == SacredBlocks.sacredPortal.blockID) { j2 = 3; } if (this.worldServerInstance.getBlockId(i, j, k + 1) == SacredBlocks.sacredPortal.blockID) { j2 = 1; } int k2 = par1Entity.func_82148_at(); if (j2 > -1) { int l2 = Direction.field_71578_g[j2]; int i3 = Direction.offsetX[j2]; int j3 = Direction.offsetZ[j2]; int k3 = Direction.offsetX[l2]; int l3 = Direction.offsetZ[l2]; boolean flag1 = !this.worldServerInstance.isAirBlock(i + i3 + k3, j, k + j3 + l3) || !this.worldServerInstance.isAirBlock(i + i3 + k3, j + 1, k + j3 + l3); boolean flag2 = !this.worldServerInstance.isAirBlock(i + i3, j, k + j3) || !this.worldServerInstance.isAirBlock(i + i3, j + 1, k + j3); if (flag1 && flag2) { j2 = Direction.footInvisibleFaceRemap[j2]; l2 = Direction.footInvisibleFaceRemap[l2]; i3 = Direction.offsetX[j2]; j3 = Direction.offsetZ[j2]; k3 = Direction.offsetX[l2]; l3 = Direction.offsetZ[l2]; k1 = i - k3; d8 -= (double) k3; int i4 = k - l3; d4 -= (double) l3; flag1 = !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j, i4 + j3 + l3) || !this.worldServerInstance.isAirBlock(k1 + i3 + k3, j + 1, i4 + j3 + l3); flag2 = !this.worldServerInstance.isAirBlock(k1 + i3, j, i4 + j3) || !this.worldServerInstance.isAirBlock(k1 + i3, j + 1, i4 + j3); } float f1 = 0.5F; float f2 = 0.5F; if (!flag1 && flag2) { f1 = 1.0F; } else if (flag1 && !flag2) { f1 = 0.0F; } else if (flag1 && flag2) { f2 = 0.0F; } d8 += (double) ((float) k3 * f1 + f2 * (float) i3); d4 += (double) ((float) l3 * f1 + f2 * (float) j3); float f3 = 0.0F; float f4 = 0.0F; float f5 = 0.0F; float f6 = 0.0F; if (j2 == k2) { f3 = 1.0F; f4 = 1.0F; } else if (j2 == Direction.footInvisibleFaceRemap[k2]) { f3 = -1.0F; f4 = -1.0F; } else if (j2 == Direction.enderEyeMetaToDirection[k2]) { f5 = 1.0F; f6 = -1.0F; } else { f5 = -1.0F; f6 = 1.0F; } double d10 = par1Entity.motionX; double d11 = par1Entity.motionZ; par1Entity.motionX = d10 * (double) f3 + d11 * (double) f6; par1Entity.motionZ = d10 * (double) f5 + d11 * (double) f4; par1Entity.rotationYaw = par8 - (float) (k2 * 90) + (float) (j2 * 90); } else { par1Entity.motionX = par1Entity.motionY = par1Entity.motionZ = 0.0D; } par1Entity.setLocationAndAngles(d8, d9, d4, par1Entity.rotationYaw, par1Entity.rotationPitch); return true; } else { return false; } } public boolean makePortal(Entity par1Entity) { byte b0 = 16; double d0 = -1.0D; int i = MathHelper.floor_double(par1Entity.posX); int j = MathHelper.floor_double(par1Entity.posY); int k = MathHelper.floor_double(par1Entity.posZ); int l = i; int i1 = j; int j1 = k; int k1 = 0; int l1 = this.random.nextInt(4); int i2; double d1; double d2; int j2; int k2; int l2; int i3; int j3; int k3; int l3; int i4; int j4; int k4; double d3; double d4; for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double) i2 + 0.5D - par1Entity.posX; for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double) j2 + 0.5D - par1Entity.posZ; label274: for (k2 = this.worldServerInstance.getActualHeight() - 1; k2 >= 0; --k2) { if (this.worldServerInstance.isAirBlock(i2, k2, j2)) { while (k2 > 0 && this.worldServerInstance.isAirBlock(i2, k2 - 1, j2)) { --k2; } for (i3 = l1; i3 < l1 + 4; ++i3) { l2 = i3 % 2; k3 = 1 - l2; if (i3 % 4 >= 2) { l2 = -l2; k3 = -k3; } for (j3 = 0; j3 < 3; ++j3) { for (i4 = 0; i4 < 4; ++i4) { for (l3 = -1; l3 < 4; ++l3) { k4 = i2 + (i4 - 1) * l2 + j3 * k3; j4 = k2 + l3; int l4 = j2 + (i4 - 1) * k3 - j3 * l2; if (l3 < 0 && !this.worldServerInstance.getBlockMaterial(k4, j4, l4).isSolid() || l3 >= 0 && !this.worldServerInstance.isAirBlock(k4, j4, l4)) { continue label274; } } } } d4 = (double) k2 + 0.5D - par1Entity.posY; d3 = d1 * d1 + d4 * d4 + d2 * d2; if (d0 < 0.0D || d3 < d0) { d0 = d3; l = i2; i1 = k2; j1 = j2; k1 = i3 % 4; } } } } } } if (d0 < 0.0D) { for (i2 = i - b0; i2 <= i + b0; ++i2) { d1 = (double) i2 + 0.5D - par1Entity.posX; for (j2 = k - b0; j2 <= k + b0; ++j2) { d2 = (double) j2 + 0.5D - par1Entity.posZ; label222: for (k2 = this.worldServerInstance.getActualHeight() - 1; k2 >= 0; --k2) { if (this.worldServerInstance.isAirBlock(i2, k2, j2)) { while (k2 > 0 && this.worldServerInstance.isAirBlock(i2, k2 - 1, j2)) { --k2; } for (i3 = l1; i3 < l1 + 2; ++i3) { l2 = i3 % 2; k3 = 1 - l2; for (j3 = 0; j3 < 4; ++j3) { for (i4 = -1; i4 < 4; ++i4) { l3 = i2 + (j3 - 1) * l2; k4 = k2 + i4; j4 = j2 + (j3 - 1) * k3; if (i4 < 0 && !this.worldServerInstance.getBlockMaterial(l3, k4, j4).isSolid() || i4 >= 0 && !this.worldServerInstance.isAirBlock(l3, k4, j4)) { continue label222; } } } d4 = (double) k2 + 0.5D - par1Entity.posY; d3 = d1 * d1 + d4 * d4 + d2 * d2; if (d0 < 0.0D || d3 < d0) { d0 = d3; l = i2; i1 = k2; j1 = j2; k1 = i3 % 2; } } } } } } } int i5 = l; int j5 = i1; j2 = j1; int k5 = k1 % 2; int l5 = 1 - k5; if (k1 % 4 >= 2) { k5 = -k5; l5 = -l5; } boolean flag; if (d0 < 0.0D) { if (i1 < 70) { i1 = 70; } if (i1 > this.worldServerInstance.getActualHeight() - 10) { i1 = this.worldServerInstance.getActualHeight() - 10; } j5 = i1; for (k2 = -1; k2 <= 1; ++k2) { for (i3 = 1; i3 < 3; ++i3) { for (l2 = -1; l2 < 3; ++l2) { k3 = i5 + (i3 - 1) * k5 + k2 * l5; j3 = j5 + l2; i4 = j2 + (i3 - 1) * l5 - k2 * k5; flag = l2 < 0; this.worldServerInstance.setBlock(k3, j3, i4, flag ? Block.blockLapis.blockID : 0); } } } } for (k2 = 0; k2 < 4; ++k2) { for (i3 = 0; i3 < 4; ++i3) { for (l2 = -1; l2 < 4; ++l2) { k3 = i5 + (i3 - 1) * k5; j3 = j5 + l2; i4 = j2 + (i3 - 1) * l5; flag = i3 == 0 || i3 == 3 || l2 == -1 || l2 == 3; this.worldServerInstance.setBlock(k3, j3, i4, flag ? Block.blockLapis.blockID : SacredBlocks.sacredPortal.blockID, 0, 2); } } for (i3 = 0; i3 < 4; ++i3) { for (l2 = -1; l2 < 4; ++l2) { k3 = i5 + (i3 - 1) * k5; j3 = j5 + l2; i4 = j2 + (i3 - 1) * l5; this.worldServerInstance.notifyBlocksOfNeighborChange(k3, j3, i4, this.worldServerInstance.getBlockId(k3, j3, i4)); } } } return true; } @SuppressWarnings("rawtypes") public void func_85189_a(long par1) { if (par1 % 100L == 0L) { Iterator iterator = this.field_85190_d.iterator(); long j = par1 - 600L; while (iterator.hasNext()) { Long olong = (Long) iterator.next(); PortalPosition portalposition = (PortalPosition) this.field_85191_c.getValueByKey(olong.longValue()); if (portalposition == null || portalposition.field_85087_d < j) { iterator.remove(); this.field_85191_c.remove(olong.longValue()); } } } } } BlockSacredPortal: public class BlockSacredPortal extends BlockPortal { public BlockSacredPortal(int par1) { super(par1); } public void updateTick(World world, int x, int y, int z, Random random) { } public void onEntityCollidedWithBlock(World par1World, int par2, int par3, int par4, Entity par5Entity) { if (par5Entity.ridingEntity == null && par5Entity.riddenByEntity == null) { if (par5Entity instanceof EntityPlayerMP) { EntityPlayerMP thePlayer = (EntityPlayerMP) par5Entity; if (par5Entity.dimension != SacredGroundsDimension.sacredGroundsID) { thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, SacredGroundsDimension.sacredGroundsID, new TeleporterSacredGrounds(thePlayer.mcServer.worldServerForDimension(SacredGroundsDimension.sacredGroundsID))); } else { thePlayer.mcServer.getConfigurationManager().transferPlayerToDimension(thePlayer, 0, new TeleporterSacredGrounds(thePlayer.mcServer.worldServerForDimension(0))); } } } } public boolean tryToCreatePortal(World par1World, int par2, int par3, int par4) { byte b0 = 0; byte b1 = 0; if (par1World.getBlockId(par2 - 1, par3, par4) == Block.blockLapis.blockID || par1World.getBlockId(par2 + 1, par3, par4) == Block.blockLapis.blockID) { b0 = 1; } if (par1World.getBlockId(par2, par3, par4 - 1) == Block.blockLapis.blockID || par1World.getBlockId(par2, par3, par4 + 1) == Block.blockLapis.blockID) { b1 = 1; } if (b0 == b1) { return false; } else { if (par1World.getBlockId(par2 - b0, par3, par4 - b1) == 0) { par2 -= b0; par4 -= b1; } int l; int i1; for (l = -1; l <= 2; ++l) { for (i1 = -1; i1 <= 3; ++i1) { boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3; if (l != -1 && l != 2 || i1 != -1 && i1 != 3) { int j1 = par1World.getBlockId(par2 + b0 * l, par3 + i1, par4 + b1 * l); if (flag) { if (j1 != Block.blockLapis.blockID) { return false; } } else if (j1 != 0 && j1 != Block.fire.blockID) { return false; } } } } for (l = 0; l < 2; ++l) { for (i1 = 0; i1 < 3; ++i1) { par1World.setBlock(par2 + b0 * l, par3 + i1, par4 + b1 * l, SacredBlocks.sacredPortal.blockID, 0, 2); } } return true; } } public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { } public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { byte b0 = 0; byte b1 = 1; if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID || par1World.getBlockId(par2 + 1, par3, par4) == this.blockID) { b0 = 1; b1 = 0; } int i1; for (i1 = par3; par1World.getBlockId(par2, i1 - 1, par4) == this.blockID; --i1) { ; } if (par1World.getBlockId(par2, i1 - 1, par4) != Block.blockLapis.blockID) { par1World.setBlockToAir(par2, par3, par4); } else { int j1; for (j1 = 1; j1 < 4 && par1World.getBlockId(par2, i1 + j1, par4) == this.blockID; ++j1) { ; } if (j1 == 3 && par1World.getBlockId(par2, i1 + j1, par4) == Block.blockLapis.blockID) { boolean flag = par1World.getBlockId(par2 - 1, par3, par4) == this.blockID || par1World.getBlockId(par2 + 1, par3, par4) == this.blockID; boolean flag1 = par1World.getBlockId(par2, par3, par4 - 1) == this.blockID || par1World.getBlockId(par2, par3, par4 + 1) == this.blockID; if (flag && flag1) { par1World.setBlockToAir(par2, par3, par4); } else { if ((par1World.getBlockId(par2 + b0, par3, par4 + b1) != Block.blockLapis.blockID || par1World.getBlockId(par2 - b0, par3, par4 - b1) != this.blockID) && (par1World.getBlockId(par2 - b0, par3, par4 - b1) != Block.blockLapis.blockID || par1World.getBlockId(par2 + b0, par3, par4 + b1) != this.blockID)) { par1World.setBlockToAir(par2, par3, par4); } } } else { par1World.setBlockToAir(par2, par3, par4); } } } public void registerIcons(IconRegister iconRegistry) { blockIcon = iconRegistry.registerIcon("sacredgrounds:sacredPortal"); } }
  14. Okey so I'm currently making some leaves for my tree but I have some problems when it comes to changing the texture when you change the graphics level from fancy to fast and the other way around. They only show up as how I want them to be in fast, even when I have it in fancy. Hope someone can help me with this. Here is the BlockSacredLeavesBase class: package com.xeto.sacredgrounds.block; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockSacredLeavesBase extends Block { public boolean graphicsLevel; public BlockSacredLeavesBase(int par1, Material par2Material, boolean par3) { super(par1, par2Material); this.graphicsLevel = par3; } public boolean isOpaqueCube() { return false; } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { int i1 = par1IBlockAccess.getBlockId(par2, par3, par4); return !this.graphicsLevel && i1 == this.blockID ? false : super.shouldSideBeRendered(par1IBlockAccess, par2, par3, par4, par5); } } And here is the BlockSacredLeaves class: package com.xeto.sacredgrounds.block; import java.util.ArrayList; import java.util.List; import java.util.Random; import com.xeto.sacredgrounds.SacredGrounds; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraftforge.common.IShearable; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockSacredLeaves extends BlockSacredLeavesBase implements IShearable { public static final String[] LEAF_TYPES = new String[] { "sena", "whuna", "3", "4" }; public static final String[][] graphicLeaves = new String[][] { { "sena_leaves", "whuna_leaves", "3_leaves", "4_leaves" }, { "sena_leaves_opaque", "whuna_leaves_opaque", "3_leaves_opaque", "4_leaves_opaque" } }; @SideOnly(Side.CLIENT) private int field_94394_cP; private Icon[][] iconArray = new Icon[2][]; int[] adjacentTreeBlocks; public BlockSacredLeaves(int par1) { super(par1, Material.leaves, false); this.setTickRandomly(true); setCreativeTab(SacredGrounds.tabSacred); } public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) { byte b0 = 1; int j1 = b0 + 1; if (par1World.checkChunksExist(par2 - j1, par3 - j1, par4 - j1, par2 + j1, par3 + j1, par4 + j1)) { for (int k1 = -b0; k1 <= b0; ++k1) { for (int l1 = -b0; l1 <= b0; ++l1) { for (int i2 = -b0; i2 <= b0; ++i2) { int j2 = par1World.getBlockId(par2 + k1, par3 + l1, par4 + i2); if (Block.blocksList[j2] != null) { Block.blocksList[j2].beginLeavesDecay(par1World, par2 + k1, par3 + l1, par4 + i2); } } } } } } public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!par1World.isRemote) { int l = par1World.getBlockMetadata(par2, par3, par4); if ((l & != 0 && (l & 4) == 0) { byte b0 = 4; int i1 = b0 + 1; byte b1 = 32; int j1 = b1 * b1; int k1 = b1 / 2; if (this.adjacentTreeBlocks == null) { this.adjacentTreeBlocks = new int[b1 * b1 * b1]; } int l1; if (par1World.checkChunksExist(par2 - i1, par3 - i1, par4 - i1, par2 + i1, par3 + i1, par4 + i1)) { int i2; int j2; int k2; for (l1 = -b0; l1 <= b0; ++l1) { for (i2 = -b0; i2 <= b0; ++i2) { for (j2 = -b0; j2 <= b0; ++j2) { k2 = par1World.getBlockId(par2 + l1, par3 + i2, par4 + j2); Block block = Block.blocksList[k2]; if (block != null && block.canSustainLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = 0; } else if (block != null && block.isLeaves(par1World, par2 + l1, par3 + i2, par4 + j2)) { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -2; } else { this.adjacentTreeBlocks[(l1 + k1) * j1 + (i2 + k1) * b1 + j2 + k1] = -1; } } } } for (l1 = 1; l1 <= 4; ++l1) { for (i2 = -b0; i2 <= b0; ++i2) { for (j2 = -b0; j2 <= b0; ++j2) { for (k2 = -b0; k2 <= b0; ++k2) { if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1] == l1 - 1) { if (this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1 - 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1 + 1) * j1 + (j2 + k1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 - 1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1 + 1) * b1 + k2 + k1] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + (k2 + k1 - 1)] = l1; } if (this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] == -2) { this.adjacentTreeBlocks[(i2 + k1) * j1 + (j2 + k1) * b1 + k2 + k1 + 1] = l1; } } } } } } } l1 = this.adjacentTreeBlocks[k1 * j1 + k1 * b1 + k1]; if (l1 >= 0) { par1World.setBlockMetadataWithNotify(par2, par3, par4, l & -9, 4); } else { this.removeLeaves(par1World, par2, par3, par4); } } } } @SideOnly(Side.CLIENT) public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (par1World.canLightningStrikeAt(par2, par3 + 1, par4) && !par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) && par5Random.nextInt(15) == 1) { double d0 = (double) ((float) par2 + par5Random.nextFloat()); double d1 = (double) par3 - 0.05D; double d2 = (double) ((float) par4 + par5Random.nextFloat()); par1World.spawnParticle("dripWater", d0, d1, d2, 0.0D, 0.0D, 0.0D); } } private void removeLeaves(World par1World, int par2, int par3, int par4) { this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); } public int quantityDropped(Random par1Random) { return par1Random.nextInt(20) == 0 ? 1 : 0; } public int idDropped(int par1, Random par2Random, int par2) { return this.blockID; } public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7) { if (!par1World.isRemote) { int j1 = 20; if ((par5 & 3) == 3) { j1 = 40; } if (par7 > 0) { j1 -= 2 << par7; if (j1 < 10) { j1 = 10; } } if (par1World.rand.nextInt(j1) == 0) { int k1 = this.idDropped(par5, par1World.rand, par7); this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(k1, 1, this.damageDropped(par5))); } j1 = 200; if (par7 > 0) { j1 -= 10 << par7; if (j1 < 40) { j1 = 40; } } if ((par5 & 3) == 0 && par1World.rand.nextInt(j1) == 0) { this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(Item.appleGold, 1, 0)); } } } public void harvestBlock(World par1World, EntityPlayer par2EntityPlayer, int par3, int par4, int par5, int par6) { super.harvestBlock(par1World, par2EntityPlayer, par3, par4, par5, par6); } public int damageDropped(int par1) { return par1 & 3; } public boolean isOpaqueCube() { return !this.graphicsLevel; } @SideOnly(Side.CLIENT) public Icon getBlockTextureFromSideAndMetadata(int par1, int par2) { return (par2 & 3) == 1 ? this.iconArray[this.field_94394_cP][1] : ((par2 & 3) == 3 ? this.iconArray[this.field_94394_cP][3] : this.iconArray[this.field_94394_cP][0]); } @SideOnly(Side.CLIENT) public void setGraphicsLevel(boolean par1) { this.graphicsLevel = par1; this.field_94394_cP = par1 ? 0 : 1; } @SuppressWarnings({ "unchecked", "rawtypes" }) @SideOnly(Side.CLIENT) public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(par1, 1, 0)); par3List.add(new ItemStack(par1, 1, 1)); } @SideOnly(Side.CLIENT) public void registerIcons(IconRegister par1IconRegister) { for (int i = 0; i < graphicLeaves.length; ++i) { this.iconArray[i] = new Icon[graphicLeaves[i].length]; for (int j = 0; j < graphicLeaves[i].length; ++j) { this.iconArray[i][j] = par1IconRegister.registerIcon("sacredgrounds:" + graphicLeaves[i][j]); } } } @Override public boolean isShearable(ItemStack item, World world, int x, int y, int z) { return true; } @Override public ArrayList<ItemStack> onSheared(ItemStack item, World world, int x, int y, int z, int fortune) { ArrayList<ItemStack> ret = new ArrayList<ItemStack>(); ret.add(new ItemStack(this, 1, world.getBlockMetadata(x, y, z) & 3)); return ret; } @Override public void beginLeavesDecay(World world, int x, int y, int z) { world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) | 8, 4); } @Override public boolean isLeaves(World world, int x, int y, int z) { return true; } } Here are the to pictures I have for the first block: (they are a bit small though) The texture for fast graphics (location = mods/sacredgrounds/textures/blocks/sena_leaves.png) The texture for fancy graphics (location = mods/sacredgrounds/textures/blocks/sena_leaves_opaque.png)
  15. set the (this.moveSpeed = 0.23F) to more than 0.23F.
  16. Hi, I wonder if there is a way to make a furnace recipe that will take an metadata item for input as well as the output. Though the method addSmelting takes only (int input, ItemStack output, float xp). How can I do it then?
  17. Still looking for someone who could help me, I've got the textures set up in the folders that it is supposed to be int. With other words in /mods/modname/textures/items/.
  18. Hi, I'm trying to give my items a texture, all the items is metadata items and I can't get it to work. Please help me. Here is my code:
  19. Is there a way of making a custom furnace give us different output from what we insert as a fuel and which class should this be in? The tileentitiy, the BlockCustomFurnace or the ContainerCustomFurnace?
  20. I did something like this: public boolean LocationIsValidSpawn(World world, int x, int y, int z) { int checkID = world.getBlockId(x, y, z); if (checkID != (Block.grass.blockID)) { return false; } return true; } public boolean LocationIsValidSpawn2(World world, int x, int y, int z) { int checkID = world.getBlockId(x, y, z); if (checkID != (Block.grass.blockID | Block.dirt.blockID | Block.stone.blockID)) { return false; } return true; } public boolean generate(World world, Random rand, int i, int j, int k) { if (!LocationIsValidSpawn(world, i, j, k + 1)) { if(!LocationIsValidSpawn2(world, i, j + 5, k + 1)) { return false; } } // All the generation of blocks here return true; }
  21. I wondered if anyone could help me with a way to get a structure spawn inside a hillside. I have tried making it not spawn if the block in fron of it isn't grass as well as not spawn if there isn't a grass | dirt | stone block above it, but it didn't work.

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.