aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/block
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2019-04-02 17:44:13 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2019-04-02 17:44:13 +1000
commit70a0df8a68725c16f0c0b959639b8e82cbbcf3a0 (patch)
treea532180e57e9172dba7fc03f3b7988c4fcd44fcd /src/Java/gtPlusPlus/core/block
parentf6a126e4467c5bf7ab72249c7fc55df3bc574d94 (diff)
downloadGT5-Unofficial-70a0df8a68725c16f0c0b959639b8e82cbbcf3a0.tar.gz
GT5-Unofficial-70a0df8a68725c16f0c0b959639b8e82cbbcf3a0.tar.bz2
GT5-Unofficial-70a0df8a68725c16f0c0b959639b8e82cbbcf3a0.zip
% Work work
Diffstat (limited to 'src/Java/gtPlusPlus/core/block')
-rw-r--r--src/Java/gtPlusPlus/core/block/ModBlocks.java4
-rw-r--r--src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java24
-rw-r--r--src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java10
-rw-r--r--src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java205
4 files changed, 232 insertions, 11 deletions
diff --git a/src/Java/gtPlusPlus/core/block/ModBlocks.java b/src/Java/gtPlusPlus/core/block/ModBlocks.java
index 8471c13351..b904b04556 100644
--- a/src/Java/gtPlusPlus/core/block/ModBlocks.java
+++ b/src/Java/gtPlusPlus/core/block/ModBlocks.java
@@ -12,6 +12,7 @@ import gtPlusPlus.core.block.general.MiningExplosives;
import gtPlusPlus.core.block.general.PlayerDoors;
import gtPlusPlus.core.block.general.antigrief.BlockWitherProof;
import gtPlusPlus.core.block.general.redstone.BlockGenericRedstoneDetector;
+import gtPlusPlus.core.block.general.redstone.BlockGenericRedstoneTest;
import gtPlusPlus.core.block.machine.CircuitProgrammer;
import gtPlusPlus.core.block.machine.DecayablesChest;
import gtPlusPlus.core.block.machine.FishTrap;
@@ -141,8 +142,9 @@ public final class ModBlocks {
blockCustomJukebox = new Machine_SuperJukebox();
blockPooCollector = new Machine_PooCollector();
-
+
new BlockGenericRedstoneDetector();
+ new BlockGenericRedstoneTest();
}
diff --git a/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java
index 3197d149c8..a021a39ac8 100644
--- a/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java
+++ b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java
@@ -10,10 +10,12 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.common.items.GT_MetaGenerated_Tool_01;
+import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.creative.AddToCreativeTab;
import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta;
import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler;
import gtPlusPlus.core.util.minecraft.InventoryUtils;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
@@ -86,20 +88,22 @@ public abstract class BlockGenericRedstone extends BlockContainer {
final Item mHandItem = mHandStack.getItem();
if (mHandItem instanceof GT_MetaGenerated_Tool_01) {
+ Logger.INFO("Found Tool in players hand!");
+
final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) world.getTileEntity(x, y, z);
if (tile != null) {
- if (tile.isScrewdriverable()) {
- if ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)){
+ if (tile.isScrewdriverable() || player.capabilities.isCreativeMode) {
+ if (ItemUtils.isToolScrewdriver(mHandStack)){
mDidTool = tile.onScrewdriverRMB();
}
}
- if (tile.isMalletable()) {
- if ((mHandItem.getDamage(mHandStack) == 24) || (mHandItem.getDamage(mHandStack) == 154)){
+ if (tile.isMalletable() || player.capabilities.isCreativeMode) {
+ if (ItemUtils.isToolMallet(mHandStack)){
mDidTool = tile.onMalletRMB();
}
}
- if (tile.isWrenchable()) {
- if ((mHandItem.getDamage(mHandStack) == 26) || (mHandItem.getDamage(mHandStack) == 164)){
+ if (tile.isWrenchable() || player.capabilities.isCreativeMode) {
+ if (ItemUtils.isToolWrench(mHandStack)){
mDidTool = tile.onWrenchRMB();
}
}
@@ -129,17 +133,17 @@ public abstract class BlockGenericRedstone extends BlockContainer {
final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) aWorld.getTileEntity(aX, aY, aZ);
if (tile != null) {
if (tile.isScrewdriverable()) {
- if ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)){
+ if (ItemUtils.isToolScrewdriver(mHandStack)){
mDidTool = tile.onScrewdriverLMB();
}
}
if (tile.isMalletable()) {
- if ((mHandItem.getDamage(mHandStack) == 24) || (mHandItem.getDamage(mHandStack) == 154)){
+ if (ItemUtils.isToolMallet(mHandStack)){
mDidTool = tile.onMalletLMB();
}
}
if (tile.isWrenchable()) {
- if ((mHandItem.getDamage(mHandStack) == 26) || (mHandItem.getDamage(mHandStack) == 164)){
+ if (ItemUtils.isToolWrench(mHandStack)){
mDidTool = tile.onWrenchLMB();
}
}
@@ -148,7 +152,7 @@ public abstract class BlockGenericRedstone extends BlockContainer {
}
catch (Throwable t) {}
- if (!mDidTool) {
+ if (!mDidTool && !aPlayer.capabilities.isCreativeMode) {
super.onBlockClicked(aWorld, aX, aY, aZ, aPlayer);
}
else {
diff --git a/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java
index 7728b29a7c..43247110f1 100644
--- a/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java
+++ b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java
@@ -32,6 +32,16 @@ public class BlockGenericRedstoneDetector extends BlockGenericRedstone {
public class TileEntityRedstoneDetector extends TileEntityRedstoneHandler {
public TileEntityRedstoneDetector() {
super(0);
+ }
+
+ @Override
+ protected Class<? extends TileEntity> getTileEntityClass() {
+ return this.getClass();
+ }
+
+ @Override
+ protected String getTileEntityNameForRegistration() {
+ return "TileEntityRedstoneDetector";
}
}
diff --git a/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java
new file mode 100644
index 0000000000..f2a5c3f36a
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneTest.java
@@ -0,0 +1,205 @@
+package gtPlusPlus.core.block.general.redstone;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Random;
+
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.minecraft.ItemUtils;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public class BlockGenericRedstoneTest extends BlockGenericRedstone {
+
+ public BlockGenericRedstoneTest() {
+ super("test", "Redstone Test");
+ setTickRandomly(true);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int p_149915_2_) {
+ return new TileEntityRedstoneTest();
+ }
+
+ public class TileEntityRedstoneTest extends TileEntityRedstoneHandler {
+ public TileEntityRedstoneTest() {
+ super(2);
+ }
+
+ @Override
+ public boolean isScrewdriverable() {
+ return true;
+ }
+
+ @Override
+ public boolean onScrewdriverLMB() {
+ // TODO Auto-generated method stub
+ return super.onScrewdriverLMB();
+ }
+
+ @Override
+ public boolean onScrewdriverRMB() {
+ if (this.mLightValue + 1 <= 1) {
+ this.mLightValue += 1;
+ }
+ else {
+ this.mLightValue = 0;
+ }
+ Logger.INFO("Screwdriver | "+this.getLightBrightness());
+ this.markForUpdate();
+ return super.onScrewdriverRMB();
+ }
+
+ @Override
+ public boolean isMalletable() {
+ return true;
+ }
+
+ @Override
+ public boolean onMalletLMB() {
+ // TODO Auto-generated method stub
+ return super.onMalletLMB();
+ }
+
+ @Override
+ public boolean onMalletRMB() {
+ this.mLightMode = Utils.invertBoolean(mLightMode);
+ return super.onMalletRMB();
+ }
+
+ @Override
+ public boolean isWrenchable() {
+ return true;
+ }
+
+ @Override
+ public boolean onWrenchLMB() {
+ // TODO Auto-generated method stub
+ return super.onWrenchLMB();
+ }
+
+ @Override
+ public boolean onWrenchRMB() {
+ // TODO Auto-generated method stub
+ return super.onWrenchRMB();
+ }
+
+ @Override
+ protected Class<? extends TileEntity> getTileEntityClass() {
+ return this.getClass();
+ }
+
+ @Override
+ protected String getTileEntityNameForRegistration() {
+ // TODO Auto-generated method stub
+ return "TileEntityRedstoneTest";
+ }
+
+ @Override
+ public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
+ // TODO Auto-generated method stub
+ return super.isProvidingWeakPower(world, x, y, z, side);
+ }
+
+ @Override
+ public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) {
+ // TODO Auto-generated method stub
+ return super.isProvidingStrongPower(world, x, y, z, side);
+ }
+ }
+
+ @Override
+ public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List aList) {
+ aList.add(ItemUtils.getSimpleStack(this));
+ }
+
+
+ @Override
+ public void updateTick(World aWorld, int aX, int aY, int aZ, Random aRand) {
+ super.updateTick(aWorld, aX, aY, aZ, aRand);
+ }
+
+ @Override
+ public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
+ // TODO Auto-generated method stub
+ return ItemUtils.getSimpleStack(this).getItem();
+ }
+
+ @Override
+ public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) {
+ // TODO Auto-generated method stub
+ return ItemUtils.getSimpleStack(this).getItem();
+ }
+
+ @Override
+ protected ItemStack createStackedBlock(int p_149644_1_) {
+ return ItemUtils.simpleMetaStack(this, p_149644_1_, 1);
+ }
+
+ public void generateTextureArray(final IIconRegister iicon) {
+ HashMap<Integer, HashMap<ForgeDirection, IIcon>> aTextures = new HashMap<Integer, HashMap<ForgeDirection, IIcon>>();
+
+
+ //New Block for Each Meta
+ int aMeta = 0;
+ {
+ HashMap<ForgeDirection, IIcon> aTempMap = new HashMap<ForgeDirection, IIcon>();
+ aTempMap.put(ForgeDirection.UP, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top"));
+ aTempMap.put(ForgeDirection.DOWN, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top"));
+ aTempMap.put(ForgeDirection.NORTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top"));
+ aTempMap.put(ForgeDirection.SOUTH, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top"));
+ aTempMap.put(ForgeDirection.EAST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top"));
+ aTempMap.put(ForgeDirection.WEST, iicon.registerIcon(CORE.MODID + ":" + "redstone/redstone_meter/" + "top"));
+ aTextures.put(aMeta++, aTempMap);
+ }
+
+ }
+
+ @Override
+ public IIcon getIcon(int side, int meta) {
+ HashMap<ForgeDirection, IIcon> aTemp = getTextureArray().get(meta);
+ if (aTemp != null) {
+ IIcon aSide = aTemp.get(ForgeDirection.getOrientation(side));
+ if (aSide != null) {
+ return aSide;
+ }
+ else {
+ //Smart calculate missing sides
+ if (side <= 1) {
+ for (int ss = 0; ss < 2; ss++) {
+ aSide = aTemp.get(ForgeDirection.getOrientation(side));
+ if (aSide != null) {
+ return aSide;
+ }
+ }
+ }
+ for (int ss = 2; ss < 6; ss++) {
+ aSide = aTemp.get(ForgeDirection.getOrientation(side));
+ if (aSide != null) {
+ return aSide;
+ }
+ }
+ }
+ }
+ return blockIcon;
+ }
+
+ @Override
+ public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
+ ArrayList<ItemStack> aDrops = new ArrayList<ItemStack>();
+ aDrops.add(ItemUtils.getSimpleStack(this));
+ return aDrops;
+ }
+
+}