Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
public static class TileEntityForge extends TileEntityLockable implements ITickable, ISidedInventory{ public enum slotEnum { INPUT_SLOT, OUTPUT_SLOT , FUEL_SLOT , MOLD_SLOT } private static final int[] slotsTop = new int[] { slotEnum.INPUT_SLOT.ordinal(), slotEnum.FUEL_SLOT.ordinal() }; private static final int[] slotsBottom = new int[] { slotEnum.OUTPUT_SLOT.ordinal()}; private static final int[] slotsSides = new int[] { slotEnum.MOLD_SLOT.ordinal()}; private ItemStack[] ForgeItemStacks = new ItemStack[7]; /** The number of ticks that the Forge will keep burning */ private int ForgeBurnTime; /** The number of ticks that a fresh copy of the currently-burning item would keep the Forge burning for */ private int currentItemBurnTime; private int cookTime; private int totalCookTime; private String ForgeCustomName; /** * Returns the number of slots in the inventory. */ public int getSizeInventory() { return this.ForgeItemStacks.length; } /** * Returns the stack in the given slot. * * @param index The slot to retrieve from. */ public ItemStack getStackInSlot(int index) { return this.ForgeItemStacks[index]; } /** * Removes up to a specified number of items from an inventory slot and returns them in a new stack. * * @param index The slot to remove from. * @param count The maximum amount of items to remove. */ public ItemStack decrStackSize(int index, int count) { if (this.ForgeItemStacks[index] != null) { if (this.ForgeItemStacks[index].stackSize <= count) { ItemStack itemstack1 = this.ForgeItemStacks[index]; this.ForgeItemStacks[index] = null; return itemstack1; } else { ItemStack itemstack = this.ForgeItemStacks[index].splitStack(count); if (this.ForgeItemStacks[index].stackSize == 0) { this.ForgeItemStacks[index] = null; } return itemstack; } } else { return null; } } /** * Removes a stack from the given slot and returns it. * * @param index The slot to remove a stack from. */ public ItemStack getStackInSlotOnClosing(int index) { if (this.ForgeItemStacks[index] != null) { ItemStack itemstack = this.ForgeItemStacks[index]; this.ForgeItemStacks[index] = null; return itemstack; } else { return null; } } /** * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). */ public void setInventorySlotContents(int index, ItemStack stack) { boolean flag = stack != null && stack.isItemEqual(this.ForgeItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.ForgeItemStacks[index]); this.ForgeItemStacks[index] = stack; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } if (index == 0 && !flag) { this.totalCookTime = this.getCookTime(stack); this.cookTime = 0; this.markDirty(); } } /** * Gets the name of this command sender (usually username, but possibly "Rcon") */ public String getCommandSenderName() { return this.hasCustomName() ? this.ForgeCustomName : "container.forge"; } /** * Returns true if this thing is named */ public boolean hasCustomName() { return this.ForgeCustomName != null && this.ForgeCustomName.length() > 0; } public void setCustomInventoryName(String p_145951_1_) { this.ForgeCustomName = p_145951_1_; } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("Items", 10); this.ForgeItemStacks = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound.getByte("Slot"); if (j >= 0 && j < this.ForgeItemStacks.length) { this.ForgeItemStacks[j] = ItemStack.loadItemStackFromNBT(nbttagcompound); } } this.ForgeBurnTime = compound.getShort("BurnTime"); this.cookTime = compound.getShort("CookTime"); this.totalCookTime = compound.getShort("CookTimeTotal"); this.currentItemBurnTime = getItemBurnTime(this.ForgeItemStacks[slotEnum.FUEL_SLOT.ordinal()]); if (compound.hasKey("CustomName", 8)) { this.ForgeCustomName = compound.getString("CustomName"); } } public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setShort("BurnTime", (short)this.ForgeBurnTime); compound.setShort("CookTime", (short)this.cookTime); compound.setShort("CookTimeTotal", (short)this.totalCookTime); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.ForgeItemStacks.length; ++i) { if (this.ForgeItemStacks[i] != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("Slot", (byte)i); this.ForgeItemStacks[i].writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); } } compound.setTag("Items", nbttaglist); if (this.hasCustomName()) { compound.setString("CustomName", this.ForgeCustomName); } } /** * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. */ public int getInventoryStackLimit() { return 64; } /** * Forge isBurning */ public boolean isBurning() { return this.ForgeBurnTime > 0; } @SideOnly(Side.CLIENT) public static boolean isBurning(IInventory p_174903_0_) { return p_174903_0_.getField(0) > 0; } /** * Like the old updateEntity(), except more generic. */ public void update() { boolean flag = this.isBurning(); boolean flag1 = false; if (this.isBurning()) { --this.ForgeBurnTime; } if (!this.worldObj.isRemote) { if (this.isBurning() || this.ForgeItemStacks[slotEnum.FUEL_SLOT.ordinal()] != null && ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()] != null && ForgeItemStacks[slotEnum.MOLD_SLOT.ordinal()] != null) { if (!this.isBurning() && this.canSmelt()) { this.currentItemBurnTime = this.ForgeBurnTime = getItemBurnTime(this.ForgeItemStacks[slotEnum.FUEL_SLOT.ordinal()]); if (this.isBurning()) { flag1 = true; if (this.ForgeItemStacks[slotEnum.FUEL_SLOT.ordinal()] != null ) { --this.ForgeItemStacks[slotEnum.FUEL_SLOT.ordinal()].stackSize; if (this.ForgeItemStacks[slotEnum.FUEL_SLOT.ordinal()].stackSize == 0) { this.ForgeItemStacks[slotEnum.FUEL_SLOT.ordinal()] = ForgeItemStacks[slotEnum.FUEL_SLOT.ordinal()].getItem().getContainerItem(ForgeItemStacks[slotEnum.FUEL_SLOT.ordinal()]); } } } } if (this.isBurning() && this.canSmelt()) { ++this.cookTime; if (this.cookTime == this.totalCookTime) { this.cookTime = 0; this.totalCookTime = this.getCookTime(ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()]); this.smeltItem(); flag1 = true; } } else { this.cookTime = 0; } } else if (!this.isBurning() && this.cookTime > 0) { this.cookTime = MathHelper.clamp_int(this.cookTime - 2, 0, this.totalCookTime); } if (flag != this.isBurning()) { flag1 = true; BlockForge.setState(this.isBurning(), this.worldObj, this.pos); } } if (flag1) { this.markDirty(); } } public int getCookTime(ItemStack stack) { return 350; } private boolean canSmelt() { if (ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()] == null) { return false; } if (ForgeItemStacks[slotEnum.MOLD_SLOT.ordinal()] == null) { return false; } if(ItemStack.areItemsEqual(this.ForgeItemStacks[slotEnum.MOLD_SLOT.ordinal()] , ForgeRecipes.instance().getSmeltingMOLD(ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()]))){ ItemStack itemstack = ForgeRecipes.instance().getSmeltingResult(ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()]); ItemStack MOLD = ForgeRecipes.instance().getSmeltingMOLD(ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()]); ItemStack MOLDSlot = this.ForgeItemStacks[slotEnum.MOLD_SLOT.ordinal()]; if (itemstack == null || MOLD == null) return false; if (this.ForgeItemStacks[slotEnum.OUTPUT_SLOT.ordinal()] == null){ return true; } if (!this.ForgeItemStacks[slotEnum.OUTPUT_SLOT.ordinal()].isItemEqual(itemstack)){ return false; } if (!this.ForgeItemStacks[slotEnum.MOLD_SLOT.ordinal()].isItemEqual(MOLD)){ return false; } int result = ForgeItemStacks[slotEnum.OUTPUT_SLOT.ordinal()].stackSize + itemstack.stackSize; return result <= getInventoryStackLimit() && result <= this.ForgeItemStacks[slotEnum.OUTPUT_SLOT.ordinal()].getMaxStackSize(); } return false; } /** * Turn one item from the Forge source stack into the appropriate smelted item in the Forge result stack */ public void smeltItem(){ if (this.canSmelt()) { if(ItemStack.areItemsEqual(this.ForgeItemStacks[slotEnum.MOLD_SLOT.ordinal()] , ForgeRecipes.instance().getSmeltingMOLD(ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()]))){ ItemStack itemstack = ForgeRecipes.instance().getSmeltingResult(ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()]); if (this.ForgeItemStacks[slotEnum.OUTPUT_SLOT.ordinal()] == null) { this.ForgeItemStacks[slotEnum.OUTPUT_SLOT.ordinal()] = itemstack.copy(); } else if (this.ForgeItemStacks[slotEnum.OUTPUT_SLOT.ordinal()].getItem() == itemstack.getItem()) { this.ForgeItemStacks[slotEnum.OUTPUT_SLOT.ordinal()].stackSize += itemstack.stackSize; --ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()].stackSize; if (ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()].stackSize <= 0) { ForgeItemStacks[slotEnum.INPUT_SLOT.ordinal()] = null; } } } } } public static int getItemBurnTime(ItemStack p_145952_0_){ if (p_145952_0_ == null) { return 0; } else { Item item = p_145952_0_.getItem(); if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) { Block block = Block.getBlockFromItem(item); if (block == Blocks.wooden_slab) { return 150; } if (block.getMaterial() == Material.wood) { return 300; } if (block == Blocks.coal_block) { return 16000; } } if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return 200; if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return 200; if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return 200; if (item == Items.stick) return 100; if (item == Items.coal) return 1600; if (item == Items.lava_bucket) return 20000; if (item == Item.getItemFromBlock(Blocks.sapling)) return 100; if (item == Items.blaze_rod) return 2400; return net.minecraftforge.fml.common.registry.GameRegistry.getFuelValue(p_145952_0_); } } public static boolean isItemFuel(ItemStack p_145954_0_) { /** * Returns the number of ticks that the supplied fuel item will keep the Forge burning, or 0 if the item isn't * fuel */ return getItemBurnTime(p_145954_0_) > 0; } /** * Do not make give this method the name canInteractWith because it clashes with Container */ public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D; } public void openInventory(EntityPlayer player) { } public void closeInventory(EntityPlayer player) { } /** * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. */ public boolean isItemValidForSlot(int index, ItemStack stack) { return index == 2 ? false : (index != 1 ? true : isItemFuel(stack) || SlotForgeFuel.isBucket(stack)); } public int[] getSlotsForFace(EnumFacing side) { return side == EnumFacing.DOWN ? slotsBottom : (side == EnumFacing.UP ? slotsTop : slotsSides); } /** * Returns true if automation can insert the given item in the given slot from the given side. Args: slot, item, * side */ public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { return this.isItemValidForSlot(index, itemStackIn); } /** * Returns true if automation can extract the given item in the given slot from the given side. Args: slot, item, * side */ public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { if (direction == EnumFacing.DOWN && index == 1) { Item item = stack.getItem(); if (item != Items.water_bucket && item != Items.bucket) { return false; } } return true; } public String getGuiID() { return "minecraft:Forge"; } public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerForge(playerInventory, this); } public int getField(int id) { switch (id) { case 0: return this.ForgeBurnTime; case 1: return this.currentItemBurnTime; case 2: return this.cookTime; case 3: return this.totalCookTime; default: return 0; } } public void setField(int id, int value) { switch (id) { case 0: this.ForgeBurnTime = value; break; case 1: this.currentItemBurnTime = value; break; case 2: this.cookTime = value; break; case 3: this.totalCookTime = value; } } public int getFieldCount() { return 4; } public void clear() { for (int i = 0; i < this.ForgeItemStacks.length; ++i) { this.ForgeItemStacks[i] = null; } } }
Optional Paste Settings
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
Untitled
C | 4 min ago
ekz_prep_2
C++ | 13 min ago
ekz_prep_1
C++ | 24 min ago
Untitled
Python | 27 min ago
bilet_5
C++ | 30 min ago
fungsi ambil jadwa...
PHP | 36 min ago
discount_drug
MySQL | 40 min ago
Untitled
Bash | 46 min ago
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!