This repository has been archived by the owner on Apr 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the getItemBlock functionality to a utils class, and clean up th…
…e TileEntityBase class
- Loading branch information
Showing
7 changed files
with
100 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/main/java/com/pahimar/ee3/tileentity/TileEntityBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.pahimar.ee3.tileentity; | ||
|
||
import com.pahimar.ee3.reference.Names; | ||
import com.sun.istack.internal.Nullable; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.ITickable; | ||
|
||
import java.util.UUID; | ||
|
||
public abstract class TileEntityBase extends TileEntity implements ITickable { | ||
|
||
protected String customName; | ||
protected UUID owner; | ||
|
||
public TileEntityBase() { | ||
customName = ""; | ||
owner = null; | ||
} | ||
|
||
public boolean hasCustomName() { | ||
return customName != null && !customName.isEmpty(); | ||
} | ||
|
||
@Nullable | ||
public String getCustomName() { | ||
return customName; | ||
} | ||
|
||
public void setCustomName(String customName) { | ||
this.customName = customName; | ||
} | ||
|
||
public boolean hasOwner() { | ||
return owner != null; | ||
} | ||
|
||
@Nullable | ||
public UUID getOwner() { | ||
return owner; | ||
} | ||
|
||
public void setOwner(UUID owner) { | ||
this.owner = owner; | ||
} | ||
|
||
public void setOwner(EntityPlayer entityPlayer) { | ||
if (entityPlayer != null) { | ||
setOwner(entityPlayer.getUniqueID()); | ||
} | ||
} | ||
|
||
@Override | ||
public void readFromNBT(NBTTagCompound nbtTagCompound) { | ||
|
||
super.readFromNBT(nbtTagCompound); | ||
|
||
if (nbtTagCompound.hasKey(Names.NBT.CUSTOM_NAME)) { | ||
this.customName = nbtTagCompound.getString(Names.NBT.CUSTOM_NAME); | ||
} | ||
|
||
if (nbtTagCompound.hasUniqueId(Names.NBT.OWNER)) { | ||
this.owner = nbtTagCompound.getUniqueId(Names.NBT.OWNER); | ||
} | ||
} | ||
|
||
@Override | ||
public NBTTagCompound writeToNBT(NBTTagCompound nbtTagCompound) { | ||
|
||
super.writeToNBT(nbtTagCompound); | ||
|
||
if (this.hasCustomName()) { | ||
nbtTagCompound.setString(Names.NBT.CUSTOM_NAME, customName); | ||
} | ||
|
||
if (this.hasOwner()) { | ||
nbtTagCompound.setUniqueId(Names.NBT.OWNER, owner); | ||
} | ||
|
||
return nbtTagCompound; | ||
} | ||
} |
143 changes: 0 additions & 143 deletions
143
src/main/java/com/pahimar/ee3/tileentity/TileEntityEE.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.pahimar.ee3.util; | ||
|
||
import com.pahimar.ee3.block.base.BlockEnumBase; | ||
import com.pahimar.ee3.item.base.ItemBlockEnumEE; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.item.ItemBlock; | ||
|
||
public class BlockUtils { | ||
|
||
private BlockUtils() {} | ||
|
||
public static ItemBlock getItemBlockFor(Block block) { | ||
return block instanceof BlockEnumBase ? new ItemBlockEnumEE((BlockEnumBase) block) : new ItemBlock(block); | ||
} | ||
} |
70 changes: 0 additions & 70 deletions
70
src/main/java/com/pahimar/ee3/util/TileEntityDataHelper.java
This file was deleted.
Oops, something went wrong.