aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/block
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-01-31 03:49:33 +0000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-01-31 03:49:33 +0000
commitc0daba1659c667342da1529c31896a98768a8eda (patch)
treee1e1f25c265c63fb2dbbb5c113e941a92e9cfa4c /src/Java/gtPlusPlus/core/block
parent241df1134f16c6c9c54b198db97279d697de8c77 (diff)
downloadGT5-Unofficial-c0daba1659c667342da1529c31896a98768a8eda.tar.gz
GT5-Unofficial-c0daba1659c667342da1529c31896a98768a8eda.tar.bz2
GT5-Unofficial-c0daba1659c667342da1529c31896a98768a8eda.zip
+ Added a config option for control cores. Someone should definitely test this works as expected.
% Reduced cost of Hatch_Control_Core recipe. % Minor tweaks to Fish Traps. $ Fixed inventory shuffling for some Tile Entities. $ Fixed Super Jukebox, it's now mostly functional. $ Fixed constructBaseMetaTileEntity returning the wrong type of Entity for pre-existing wooden pipes, this should now get caught and thrown if the GT++ entity fails to a ClassCastException.
Diffstat (limited to 'src/Java/gtPlusPlus/core/block')
-rw-r--r--src/Java/gtPlusPlus/core/block/ModBlocks.java2
-rw-r--r--src/Java/gtPlusPlus/core/block/general/BlockSuperLight.java220
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java662
3 files changed, 735 insertions, 149 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java
index dc1239f4be..f95f8814a9 100644
--- a/src/Java/gtPlusPlus/core/block/ModBlocks.java
+++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java
@@ -125,7 +125,7 @@ public final class ModBlocks {
blockPlayerDoorCustom_Ice = new PlayerDoors(Material.ice, "door_ice", false);
blockPlayerDoorCustom_Cactus = new PlayerDoors(Material.cactus, "door_cactus", false, 0.6f, Block.soundTypeGrass, "Cactus");
- blockCustomSuperLight = new BlockSuperLight();
+ //blockCustomSuperLight = new BlockSuperLight();
blockCustomJukebox = new Machine_SuperJukebox();
}
diff --git a/src/Java/gtPlusPlus/core/block/general/BlockSuperLight.java b/src/Java/gtPlusPlus/core/block/general/BlockSuperLight.java
new file mode 100644
index 0000000000..a1ba3be487
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/general/BlockSuperLight.java
@@ -0,0 +1,220 @@
+package gtPlusPlus.core.block.general;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.LanguageRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
+import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.lib.CORE;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockAir;
+import net.minecraft.block.BlockContainer;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.init.Blocks;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.World;
+
+public class BlockSuperLight extends BlockContainer {
+
+ @SideOnly(Side.CLIENT)
+ private IIcon textureFront;
+
+ //propecia (Inhibit DHD - recover hair get depression)
+
+ public BlockSuperLight() {
+ super(Material.circuits);
+ this.setBlockName("blockSuperLight");
+ this.setCreativeTab(CreativeTabs.tabRedstone);
+ GameRegistry.registerBlock(this, "blockSuperLight");
+ LanguageRegistry.addName(this, "Shining Star");
+ }
+
+ /**
+ * Gets the block's texture. Args: side, meta
+ */
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(final int p_149691_1_, final int p_149691_2_) {
+ return this.blockIcon;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(final IIconRegister p_149651_1_) {
+ this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "SwirlBigBlue");
+ }
+
+ /**
+ * Returns a new instance of a block's tile entity class. Called on placing the
+ * block.
+ */
+ public TileEntity createNewTileEntity(World aWorld, int p_149915_2_) {
+ return new TileEntitySuperLight();
+ }
+
+ public static class TileEntitySuperLight extends TileEntity {
+
+ private long mCreated;
+
+ private long mLastUpdateTick = 0;
+
+ private int mLitBlockCount = 0;
+
+ private int[][][][] aLitBlocks = new int[50][10][50][1];
+
+ private boolean mPowered = false;
+
+ public TileEntitySuperLight() {
+ mCreated = System.currentTimeMillis();
+ Logger.INFO("Created Super-Lamp");
+ }
+
+ public void readFromNBT(NBTTagCompound aNBT) {
+ super.readFromNBT(aNBT);
+ mCreated = aNBT.getLong("mCreated");
+ mPowered = aNBT.getBoolean("mPowered");
+ NBTTagCompound aLightingData = aNBT.getCompoundTag("lighting");
+ for (int x = 0; x < 50; x++) {
+ for (int y = 0; y < 10; y++) {
+ for (int z = 0; z < 50; z++) {
+ int aData = aLightingData.getInteger("["+x+"]["+y+"]["+z+"]");
+ aLitBlocks[x][y][z][0] = aData;
+ }
+ }
+ }
+ }
+
+ public void writeToNBT(NBTTagCompound aNBT) {
+ super.writeToNBT(aNBT);
+ aNBT.setLong("mCreated", mCreated);
+ aNBT.setBoolean("mPowered", mPowered);
+ NBTTagCompound aLightingData = new NBTTagCompound();
+ for (int x = 0; x < 50; x++) {
+ for (int y = 0; y < 10; y++) {
+ for (int z = 0; z < 50; z++) {
+ int aFlag = aLitBlocks[x][y][z][0];
+ aLightingData.setInteger("["+x+"]["+y+"]["+z+"]", aFlag);
+ }
+ }
+ }
+ aNBT.setTag("lighting", aLightingData);
+ }
+
+ @Override
+ public void updateEntity() {
+ super.updateEntity();
+
+ if (this.worldObj.isRemote) {
+ return;
+ }
+
+ try {
+ if (mLastUpdateTick == 0 || (System.currentTimeMillis() - mLastUpdateTick) >= 30000) {
+ boolean powered = (this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord));
+ boolean aLastState = mPowered;
+ //Logger.INFO("Powered: "+powered);
+ mPowered = powered;
+ if (mPowered != aLastState) {
+ updateLighting(powered);
+ }
+ }
+ } catch (Throwable t) {
+ }
+ }
+
+ @Override
+ public void markDirty() {
+ super.markDirty();
+ }
+
+ @Override
+ public boolean canUpdate() {
+ return super.canUpdate();
+ }
+
+ public void updateLighting(boolean enable) {
+
+
+ mLastUpdateTick = System.currentTimeMillis();
+
+ if (false) {
+ return;
+ }
+
+ aLitBlocks = new int[50][10][50][1];
+ int aLitCounter = 0;
+ AutoMap<BlockPos> aBlocksToUpdate = new AutoMap<BlockPos>();
+ Logger.INFO("Trying to relight area.");
+
+ BlockPos aStartIterationPoint = new BlockPos(this.xCoord-24, this.yCoord-4, this.zCoord-24, this.worldObj);
+ for (int x = 0; x < 50; x++) {
+ for (int y = 0; y < 10; y++) {
+ for (int z = 0; z < 50; z++) {
+ int xOff = aStartIterationPoint.xPos + x;
+ int yOff = aStartIterationPoint.yPos + y;
+ int zOff = aStartIterationPoint.zPos + z;
+ Block aBlockGet = this.worldObj.getBlock(xOff, yOff, zOff);
+ if (aBlockGet != null) {
+ if (aBlockGet instanceof BlockAir || aBlockGet instanceof LightGlass) {
+
+ int aLight = aBlockGet.getLightValue();
+
+ //Don't Need to relight anything.
+ if ((enable && aLight > 0) || (!enable && aLight == 0)) {
+ continue;
+ }
+ //Turning Lights on
+ else if (enable && aLight == 0) {
+ aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj));
+ if (aBlockGet instanceof BlockAir) {
+ Logger.INFO("Lit air.");
+ this.worldObj.setBlock(xOff, yOff, zOff, ModBlocks.MatterFabricatorEffectBlock, 0, 3);
+ }
+ //aBlockGet.setLightLevel(15);
+ aLitCounter++;
+ }
+ //Turning Lights off
+ else if (!enable && aLight > 0) {
+ aBlocksToUpdate.put(new BlockPos(xOff, yOff, zOff, this.worldObj));
+ if (aBlockGet instanceof LightGlass) {
+ Logger.INFO("Dimmed air.");
+ this.worldObj.setBlock(xOff, yOff, zOff, Blocks.air, 0, 3);
+ }
+ //aBlockGet.setLightLevel(0);
+ }
+ aLitBlocks[x][y][z][0] = enable ? 15 : 0;
+ }
+ else {
+ aLitBlocks[x][y][z][0] = -1;
+ }
+ }
+ else {
+ aLitBlocks[x][y][z][0] = -1;
+ }
+ }
+ }
+ }
+ mLitBlockCount = aLitCounter;
+ doLargeBlockUpdate(aBlocksToUpdate);
+ }
+
+ public void doLargeBlockUpdate(AutoMap<BlockPos> aUpdateMap) {
+ if (aUpdateMap.isEmpty()) {
+ return;
+ }
+ for (BlockPos p : aUpdateMap) {
+ //this.worldObj.markBlockForUpdate(p.xPos, p.yPos, p.zPos);
+ //this.worldObj.markBlocksDirtyVertical(p_72975_1_, p_72975_2_, p_72975_3_, p_72975_4_);
+ }
+ }
+
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java b/src/Java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java
index e3d9d0e646..fe8120e635 100644
--- a/src/Java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java
+++ b/src/Java/gtPlusPlus/core/block/machine/Machine_SuperJukebox.java
@@ -4,13 +4,22 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.core.handler.GuiHandler;
+import gtPlusPlus.core.inventories.Inventory_SuperJukebox;
+import gtPlusPlus.core.util.math.MathUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockJukebox;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
-import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
+import net.minecraft.item.ItemRecord;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@@ -19,10 +28,10 @@ import net.minecraft.world.World;
public class Machine_SuperJukebox extends BlockJukebox
{
- @SideOnly(Side.CLIENT)
- private IIcon mIcon;
+ @SideOnly(Side.CLIENT)
+ private IIcon mIcon;
- public Machine_SuperJukebox(){
+ public Machine_SuperJukebox(){
this.setBlockName("blockSuperJukebox");
this.setCreativeTab(CreativeTabs.tabRedstone);
setHardness(2.0F);
@@ -31,24 +40,36 @@ public class Machine_SuperJukebox extends BlockJukebox
setBlockTextureName("jukebox");
GameRegistry.registerBlock(this, "blockSuperJukebox");
LanguageRegistry.addName(this, "Sir Mixalot [Jukebox]");
- }
-
- /**
- * Gets the block's texture. Args: side, meta
- */
- @SideOnly(Side.CLIENT)
- public IIcon getIcon(int aSide, int aMeta)
- {
- return aSide == 1 ? this.mIcon : this.blockIcon;
- }
-
- /**
- * Called upon block activation (right click on the block.)
- */
- @Override
- public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
- {
- if (aWorld.getBlockMetadata(aX, aY, aZ) == 0)
+ }
+
+ /**
+ * Gets the block's texture. Args: side, meta
+ */
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(int aSide, int aMeta)
+ {
+ return aSide == 1 ? this.mIcon : this.blockIcon;
+ }
+
+ /**
+ * Called upon block activation (right click on the block.)
+ */
+ @Override
+ public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz)
+ {
+ if (world.isRemote) {
+ return true;
+ }
+
+ final TileEntity te = world.getTileEntity(x, y, z);
+ if ((te != null) && (te instanceof TileEntitySuperJukebox)){
+ player.openGui(GTplusplus.instance, GuiHandler.GUI14, world, x, y, z);
+ return true;
+ }
+ return false;
+
+
+ /* if (aWorld.getBlockMetadata(aX, aY, aZ) == 0)
{
return false;
}
@@ -56,23 +77,23 @@ public class Machine_SuperJukebox extends BlockJukebox
{
this.func_149925_e(aWorld, aX, aY, aZ);
return true;
- }
- }
-
- /**
- * Set the record in the {@link SuperJukebox} {@link TileEntity}.
- */
- @Override
- public final void func_149926_b(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) {
- setRecordInJukeBox(aWorld, aX, aY, aZ, aStackToSet);
- }
-
+ }*/
+ }
+
+ /**
+ * Set the record in the {@link SuperJukebox} {@link TileEntity}.
+ */
+ @Override
+ public final void func_149926_b(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) {
+ setRecordInJukeBox(aWorld, aX, aY, aZ, aStackToSet);
+ }
+
public void setRecordInJukeBox(World aWorld, int aX, int aY, int aZ, ItemStack aStackToSet) {
if (!aWorld.isRemote) {
TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ);
- if (tileentityjukebox != null) {
- tileentityjukebox.func_145857_a(aStackToSet.copy());
- aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 1, 2);
+ if (tileentityjukebox != null && aStackToSet.getItem() instanceof ItemRecord) {
+ tileentityjukebox.setCurrentRecord(aStackToSet.copy());
+ //aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 1, 2);
}
}
}
@@ -80,13 +101,13 @@ public class Machine_SuperJukebox extends BlockJukebox
/**
* Function to handle playing of records.
*/
- @Override
- public final void func_149925_e(World aWorld, int aX, int aY, int aZ) {
- playerJukeboxRecord(aWorld, aX, aY, aZ);
+ @Override
+ public final void func_149925_e(World aWorld, int aX, int aY, int aZ) {
+ playJukeboxRecord(aWorld, aX, aY, aZ);
}
-
- public void playerJukeboxRecord(World aWorld, int aX, int aY, int aZ) {
- if (!aWorld.isRemote) {
+
+ public void playJukeboxRecord(World aWorld, int aX, int aY, int aZ) {
+ if (!aWorld.isRemote) {
TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX,
aY, aZ);
@@ -94,11 +115,14 @@ public class Machine_SuperJukebox extends BlockJukebox
ItemStack itemstack = tileentityjukebox.func_145856_a();
if (itemstack != null) {
- aWorld.playAuxSFX(1005, aX, aY, aZ, 0);
- aWorld.playRecord((String) null, aX, aY, aZ);
- tileentityjukebox.func_145857_a((ItemStack) null);
- aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 0, 2);
- float f = 0.7F;
+
+
+
+ aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(itemstack.getItem()));
+ //aWorld.playRecord((String) null, aX, aY, aZ);
+ //tileentityjukebox.func_145857_a((ItemStack) null);
+ //aWorld.setBlockMetadataWithNotify(aX, aY, aZ, 0, 2);
+ /*float f = 0.7F;
double d0 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
double d1 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.2D + 0.6D;
double d2 = (double) (aWorld.rand.nextFloat() * f) + (double) (1.0F - f) * 0.5D;
@@ -106,110 +130,452 @@ public class Machine_SuperJukebox extends BlockJukebox
EntityItem entityitem = new EntityItem(aWorld, (double) aX + d0,
(double) aY + d1, (double) aZ + d2, itemstack1);
entityitem.delayBeforeCanPickup = 10;
- aWorld.spawnEntityInWorld(entityitem);
+ aWorld.spawnEntityInWorld(entityitem);*/
}
}
}
- }
+ }
- @Override
- public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
- {
- this.func_149925_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_);
- super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
- }
+ @Override
+ public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
+ {
+ this.func_149925_e(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_);
+ super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
+ }
- /**
- * Drops the block items with a specified chance of dropping the specified items
- */
- @Override
- public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
- {
- if (!p_149690_1_.isRemote)
- {
- super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, 0);
- }
- }
-
- /**
- * Returns a new instance of a block's tile entity class. Called on placing the block.
- */
- @Override
- public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
- {
- return new TileEntitySuperJukebox();
- }
-
- @SideOnly(Side.CLIENT)
- @Override
- public void registerBlockIcons(IIconRegister p_149651_1_)
- {
- this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side");
- this.mIcon = p_149651_1_.registerIcon(this.getTextureName() + "_top");
- }
-
- public static class TileEntitySuperJukebox extends TileEntityJukebox {
-
- private ItemStack field_145858_a;
-
- @Override
- public void readFromNBT(NBTTagCompound aNBT)
- {
- super.readFromNBT(aNBT);
-
- if (aNBT.hasKey("RecordItem", 10))
- {
- this.func_145857_a(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("RecordItem")));
- }
- else if (aNBT.getInteger("Record") > 0)
- {
- this.func_145857_a(new ItemStack(Item.getItemById(aNBT.getInteger("Record")), 1, 0));
- }
- }
-
- @Override
- public void writeToNBT(NBTTagCompound aNBT)
- {
- super.writeToNBT(aNBT);
-
- if (this.func_145856_a() != null)
- {
- aNBT.setTag("RecordItem", this.func_145856_a().writeToNBT(new NBTTagCompound()));
- aNBT.setInteger("Record", Item.getIdFromItem(this.func_145856_a().getItem()));
- }
- }
-
- /**
- * Called to get the internal stack
- */
- @Override
- public ItemStack func_145856_a()
- {
- return this.field_145858_a;
- }
-
- /**
- * Called to get the internal stack, wraps vanilla function {@link func_145856_a}.
- */
- public ItemStack getCurrentRecord() {
- return func_145856_a();
- }
-
- /**
- * Called to set the internal stack
- */
- @Override
- public void func_145857_a(ItemStack p_145857_1_)
- {
- this.field_145858_a = p_145857_1_;
- this.markDirty();
- }
-
- /**
- * Called to set the internal stack, wraps vanilla function {@link func_145857_a}.
- */
- public void setCurrentRecord(ItemStack aStack) {
- func_145857_a(aStack);
- }
- }
+ /**
+ * Drops the block items with a specified chance of dropping the specified items
+ */
+ @Override
+ public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
+ {
+ if (!p_149690_1_.isRemote)
+ {
+ super.dropBlockAsItemWithChance(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_6_, 0);
+ }
+ }
+
+ /**
+ * Returns a new instance of a block's tile entity class. Called on placing the block.
+ */
+ @Override
+ public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_)
+ {
+ return new TileEntitySuperJukebox();
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public void registerBlockIcons(IIconRegister p_149651_1_)
+ {
+ this.blockIcon = p_149651_1_.registerIcon(this.getTextureName() + "_side");
+ this.mIcon = p_149651_1_.registerIcon(this.getTextureName() + "_top");
+ }
+
+ public static class TileEntitySuperJukebox extends TileEntityJukebox implements ISidedInventory {
+
+ /** The number of players currently using this chest */
+ public int numPlayersUsing;
+ private ItemStack mCurrentlyPlayingStack;
+ private final Inventory_SuperJukebox inventoryContents;
+ private String customName;
+
+
+ /*
+ * Important Data
+ */
+
+ public int a_TEST_INT_VAR_1;
+ public int a_TEST_INT_VAR_2;
+ public int a_TEST_INT_VAR_3;
+ public int a_TEST_INT_VAR_4;
+
+ public boolean mIsPlaying = false;
+ public boolean mIsLooping = false;
+ public boolean a_TEST_BOOL_VAR_3;
+ public boolean a_TEST_BOOL_VAR_4;
+
+
+
+ public TileEntitySuperJukebox() {
+ this.inventoryContents = new Inventory_SuperJukebox();
+ }
+
+ @Override
+ public void readFromNBT(NBTTagCompound aNBT) {
+ super.readFromNBT(aNBT);
+
+ if (aNBT.hasKey("RecordItem", 10)) {
+ this.func_145857_a(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("RecordItem")));
+ } else if (aNBT.getInteger("Record") > 0) {
+ this.func_145857_a(new ItemStack(Item.getItemById(aNBT.getInteger("Record")), 1, 0));
+ }
+
+ this.inventoryContents.readFromNBT(aNBT.getCompoundTag("ContentsChest"));
+ if (aNBT.hasKey("CustomName", 8)) {
+ this.setCustomName(aNBT.getString("CustomName"));
+ }
+
+ mIsPlaying = aNBT.getBoolean("mIsPlaying");
+ mIsLooping = aNBT.getBoolean("mIsLooping");
+
+
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound aNBT) {
+ super.writeToNBT(aNBT);
+
+ if (this.getCurrentRecord() != null) {
+ aNBT.setTag("RecordItem", this.func_145856_a().writeToNBT(new NBTTagCompound()));
+ aNBT.setInteger("Record", Item.getIdFromItem(this.func_145856_a().getItem()));
+ }
+
+ final NBTTagCompound chestData = new NBTTagCompound();
+ this.inventoryContents.writeToNBT(chestData);
+ aNBT.setTag("ContentsChest", chestData);
+ if (this.hasCustomInventoryName()) {
+ aNBT.setString("CustomName", this.getCustomName());
+ }
+
+ aNBT.setBoolean("mIsPlaying", mIsPlaying);
+ aNBT.setBoolean("mIsLooping", mIsLooping);
+
+ }
+
+ /**
+ * Called to get the internal stack
+ */
+ @Override
+ public ItemStack func_145856_a() {
+ return this.mCurrentlyPlayingStack;
+ }
+
+ /**
+ * Called to get the internal stack, wraps vanilla function
+ * {@link func_145856_a}.
+ */
+ public ItemStack getCurrentRecord() {
+ return func_145856_a();
+ }
+
+ /**
+ * Called to set the internal stack
+ */
+ @Override
+ public void func_145857_a(ItemStack p_145857_1_) {
+ this.mCurrentlyPlayingStack = p_145857_1_;
+ this.markDirty();
+ }
+
+ /**
+ * Called to set the internal stack, wraps vanilla function
+ * {@link func_145857_a}.
+ */
+ public void setCurrentRecord(ItemStack aStack) {
+ func_145857_a(aStack);
+ this.markDirty();
+ }
+
+ public Inventory_SuperJukebox getInventory() {
+ return this.inventoryContents;
+ }
+
+
+
+
+
+ public boolean playRecord(ItemStack aRecord) {
+
+
+
+ return false;
+ }
+
+ public boolean stopRecord() {
+ return openDiscDrive();
+ }
+
+ public void setLoopState(boolean isShufflingForever) {
+
+
+
+ }
+
+
+ //Play button pressed
+ public boolean jukeboxLogicUpdate() {
+
+ if (this.worldObj.isRemote) {
+ return true;
+ }
+
+ Logger.INFO("a");
+ if (this.mIsPlaying || this.mIsLooping) {
+ return selectRecordToPlayFromInventoryAndSetViaVanillaHandler();
+ }
+ else {
+ return stopRecord();
+ }
+ }
+
+
+ //Determine which record to play
+ public boolean selectRecordToPlayFromInventoryAndSetViaVanillaHandler() {
+ AutoMap<ItemStack> mValidRecords = new AutoMap<ItemStack>();
+ for (ItemStack g : this.getInventory().getInventory()) {
+ if (g != null) {
+ if (g.getItem() instanceof ItemRecord) {
+ mValidRecords.put(g);
+ }
+ }
+ }
+
+ Logger.INFO("b1");
+ //Select First Record
+ ItemStack aRecordToPlay;
+ if (mValidRecords.size() == 0) {
+ Logger.INFO("bX");
+ return false;
+ }
+ else {
+ aRecordToPlay = mValidRecords.get(!mIsLooping ? 0 : MathUtils.randInt(0, (mValidRecords.size()-1)));
+ }
+ Logger.INFO("b2 - "+aRecordToPlay.getDisplayName());
+
+ int aSlotCounter = 0;
+ for (ItemStack g : this.getInventory().getInventory()) {
+ if (g != null && aSlotCounter <= 17) {
+ Logger.INFO("b3 - "+g.getDisplayName());
+ if (GT_Utility.areStacksEqual(g, aRecordToPlay, true)) {
+ IInventory aThisInv = this.getInventory();
+ if (aThisInv.getStackInSlot(20) != null) {
+ openDiscDrive();
+ }
+
+ GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, aSlotCounter, 20, (byte) 1, (byte) 1, (byte) 1, (byte) 1);
+ setCurrentRecord(aThisInv.getStackInSlot(20));
+
+ World aWorld = this.worldObj;
+ int aX = this.xCoord;
+ int aY = this.yCoord;
+ int aZ = this.zCoord;
+ if (!aWorld.isRemote) {
+ aRecordToPlay = this.func_145856_a();
+ if (aRecordToPlay != null) {
+ aWorld.playAuxSFX(1005, aX, aY, aZ, Item.getIdFromItem(aRecordToPlay.getItem()));
+ this.markDirty();
+ return true;
+ }
+ }
+
+ Logger.INFO("b++");
+ this.markDirty();
+ return false;
+ }
+ }
+ aSlotCounter++;
+ }
+
+
+ Logger.INFO("b4");
+ this.markDirty();
+ return false;
+ }
+
+
+ public boolean genericMethodThree(Object a1, Object a2, Object a3, Object a4) {
+ return false;
+ }
+
+
+ public void vanillaStopJukebox() {
+ World aWorld = this.worldObj;
+ int aX = this.xCoord;
+ int aY = this.yCoord;
+ int aZ = this.zCoord;
+ if (!aWorld.isRemote) {
+ TileEntitySuperJukebox tileentityjukebox = (TileEntitySuperJukebox) aWorld.getTileEntity(aX, aY, aZ);
+ if (tileentityjukebox != null) {
+ ItemStack aRecordToPlay = tileentityjukebox.func_145856_a();
+ if (aRecordToPlay != null) {
+ aWorld.playAuxSFX(1005, aX, aY, aZ, 0);
+ aWorld.playRecord((String) null, aX, aY, aZ);
+ tileentityjukebox.func_145857_a((ItemStack) null);
+ this.markDirty();
+ }
+ }
+ }
+ }
+
+ public boolean openDiscDrive() {
+ int aSlotCounter = 17;
+
+ ItemStack g;
+
+ for (int i = 17; i >= 0; i--) {
+ g = this.getInventory().getInventory()[i];
+ if (g == null && aSlotCounter >= 0) {
+ IInventory aThisInv = this.getInventory();
+ GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, 20, i, (byte) 1, (byte) 1, (byte) 1, (byte) 1);
+ vanillaStopJukebox();
+ Logger.INFO("b++");
+ this.markDirty();
+ return true;
+
+ }
+ }
+
+
+ /*for (ItemStack g : this.getInventory().getInventory()) {
+ if (g == null && aSlotCounter >= 0) {
+ IInventory aThisInv = this.getInventory();
+ GT_Utility.moveStackFromSlotAToSlotB(aThisInv, aThisInv, 20, aSlotCounter, (byte) 1, (byte) 1, (byte) 1, (byte) 1);
+ vanillaStopJukebox();
+ Logger.INFO("b++");
+ return true;
+
+ }
+ aSlotCounter--;
+ } */
+ this.markDirty();
+ return false;
+ }
+
+
+
+
+
+
+
+
+
+
+ public boolean anyPlayerInRange() {
+ return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D,
+ 32) != null;
+ }
+
+ public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag) {
+ if (!nbt.hasKey(tag)) {
+ nbt.setTag(tag, new NBTTagCompound());
+ }
+ return nbt.getCompoundTag(tag);
+ }
+
+ @Override
+ public int getSizeInventory() {
+ return this.getInventory().getSizeInventory()-3;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(final int slot) {
+ return this.getInventory().getStackInSlot(slot);
+ }
+
+ @Override
+ public ItemStack decrStackSize(final int slot, final int count) {
+ return this.getInventory().decrStackSize(slot, count);
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(final int slot) {
+ return this.getInventory().getStackInSlotOnClosing(slot);
+ }
+
+ @Override
+ public void setInventorySlotContents(final int slot, final ItemStack stack) {
+ this.getInventory().setInventorySlotContents(slot, stack);
+ }
+
+ @Override
+ public int getInventoryStackLimit() {
+ return 1;
+ }
+
+ @Override
+ public boolean isUseableByPlayer(final EntityPlayer entityplayer) {
+ return this.getInventory().isUseableByPlayer(entityplayer);
+ }
+
+ @Override
+ public void openInventory() {
+ if (this.numPlayersUsing < 0) {
+ this.numPlayersUsing = 0;
+ }
+ if (!this.worldObj.isRemote) {
+ this.numPlayersUsing++;
+ }
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1,
+ this.numPlayersUsing);
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
+ this.getInventory().openInventory();
+ }
+
+ @Override
+ public void closeInventory() {
+ if (!this.worldObj.isRemote) {
+ this.numPlayersUsing--;
+ }
+ this.worldObj.addBlockEvent(this.xCoord, this.yCoord, this.zCoord, this.getBlockType(), 1,
+ this.numPlayersUsing);
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockType());
+ this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord - 1, this.zCoord, this.getBlockType());
+ this.getInventory().closeInventory();
+ }
+
+ @Override
+ public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) {
+ if (slot >= 18) {
+ return false;
+ }
+ return this.getInventory().isItemValidForSlot(slot, itemstack);
+ }
+
+ @Override
+ public int[] getAccessibleSlotsFromSide(final int p_94128_1_) {
+ final int[] accessibleSides = new int[this.getSizeInventory()];
+ for (int r = 0; r < this.getInventory().getSizeInventory(); r++) {
+ accessibleSides[r] = r;
+ }
+ return accessibleSides;
+
+ }
+
+ @Override
+ public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) {
+ if (p_102007_1_ >= 18) {
+ return false;
+ }
+ return this.getInventory().isItemValidForSlot(p_102007_1_, p_102007_2_);
+ }
+
+ @Override
+ public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) {
+ if (p_102008_1_ >= 18) {
+ return false;
+ }
+ return this.getInventory().isItemValidForSlot(p_102008_1_, p_102008_2_);
+ }
+
+ public String getCustomName() {
+ return this.customName;
+ }
+
+ public void setCustomName(final String customName) {
+ this.customName = customName;
+ }
+
+ @Override
+ public String getInventoryName() {
+ return this.hasCustomInventoryName() ? this.customName : "container.SuperJukebox";
+ }
+
+ @Override
+ public boolean hasCustomInventoryName() {
+ return (this.customName != null) && !this.customName.equals("");
+ }
+
+ }
} \ No newline at end of file