Skip to content

Commit 7daa0b4

Browse files
committed
+ Added programmed circuit configurator
Former-commit-id: 6ed98c4
1 parent 8bb16e8 commit 7daa0b4

12 files changed

Lines changed: 285 additions & 18 deletions

File tree

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
minecraft.version=1.7.10
22
forge.version=10.13.4.1566-1.7.10
33

4-
detravscanner.version=gt.9.29-0.41.0
4+
detravscanner.version=gt.9.29-0.42.0
55

66
ae2.version=rv2-beta-33
77
applecore.version=1.7.10-1.2.1+107.59407

src/main/java/com/detrav/DetravScannerMod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class DetravScannerMod
2424
{
2525
public static final String MODID = "detravscannermod";
26-
public static final String VERSION = "0.41";
26+
public static final String VERSION = "0.42";
2727

2828
public static final CreativeTabs TAB_DETRAV = new DetravCreativeTab();
2929

src/main/java/com/detrav/enums/DetravToolDictNames.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ public enum DetravToolDictNames {
99
craftingToolPortableCharger,
1010
craftingToolPortableAnvil,
1111
craftingToolSmartPlunger,
12-
craftingToolSmartTreeTap;
12+
craftingToolSmartTreeTap,
13+
craftingToolCictuitConfigurator;
1314
}

src/main/java/com/detrav/enums/Textures01.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class Textures01 {
2020
new Textures.ItemIcons.CustomIcon("gt.detrav.metatool.01/PORTABE_CHARGER"),
2121
new Textures.ItemIcons.CustomIcon("gt.detrav.metatool.01/PORTABE_CHARGER_BORDER"),
2222
new Textures.ItemIcons.CustomIcon("gt.detrav.metatool.01/ANVIL_TOOL"),
23-
new Textures.ItemIcons.CustomIcon("gt.detrav.metatool.01/TOOL_TREE_TAP")
23+
new Textures.ItemIcons.CustomIcon("gt.detrav.metatool.01/TOOL_TREE_TAP"),
24+
new Textures.ItemIcons.CustomIcon("gt.detrav.metatool.01/CONFIGURATOR")
2425
};
2526
}

src/main/java/com/detrav/items/DetravMetaGeneratedItem01.java

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ public boolean doesShowInCreative(DetravSimpleItems aPrefix, Materials aMaterial
4343
return aDoShowAllItems || !aPrefix.name().startsWith("toolHead");
4444
}
4545

46-
public boolean isConfiguredCircuit(ItemStack aStack)
47-
{
48-
return aStack.getUnlocalizedName().indexOf("gt.detrav.metaitem.01." + (mOffset+1)) == 0;
46+
public boolean isConfiguredCircuit(ItemStack aStack) {
47+
return aStack.getUnlocalizedName().indexOf("gt.detrav.metaitem.01." + (mOffset + 1)) == 0;
4948
}
5049

5150

52-
5351
public void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) {
5452
int tOffset = aList.size();
5553
String name = aStack.getUnlocalizedName();
@@ -65,19 +63,17 @@ public void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPl
6563
tOffset = addToList(tOffset, aList, detravPosition, "Percent", true);
6664
tOffset = addToList(tOffset, aList, detravPosition, "XCurrent", true);
6765
tOffset = addToList(tOffset, aList, detravPosition, "ZCurrent", true);
68-
tOffset = addToList(tOffset, aList, detravPosition, "XFrom", true);
69-
tOffset = addToList(tOffset, aList, detravPosition, "XTo", true);
70-
tOffset = addToList(tOffset, aList, detravPosition, "ZFrom", true);
71-
tOffset = addToList(tOffset, aList, detravPosition, "ZTo", true);
72-
tOffset = addToList(tOffset, aList, detravPosition, "Configurated", false);
66+
tOffset = addToList(tOffset, aList, detravPosition, "X", "XFrom", "XTo");
67+
tOffset = addToList(tOffset, aList, detravPosition, "Z", "ZFrom", "ZTo");
68+
tOffset = addToList(tOffset, aList, detravPosition, "Y", "YFrom", "YTo");
7369
}
7470
}
7571
}
7672
break;
7773
}
7874
}
7975

80-
public int addToList(int tOffset, List aList, NBTTagCompound tag,String name, boolean integer) {
76+
public int addToList(int tOffset, List aList, NBTTagCompound tag, String name, boolean integer) {
8177
if (!tag.hasKey(name))
8278
return tOffset;
8379
if (integer) {
@@ -88,6 +84,36 @@ public int addToList(int tOffset, List aList, NBTTagCompound tag,String name, bo
8884
aList.add(tOffset, EnumChatFormatting.WHITE + name + EnumChatFormatting.GRAY);
8985
}
9086
}
91-
return tOffset + 1;
87+
return tOffset + 1;
88+
}
89+
90+
91+
public int addToList(int tOffset, List aList, NBTTagCompound tag, String text, String from, String to) {
92+
String i_from = "";
93+
String i_to = "";
94+
boolean noFrom = true;
95+
boolean noTo = true;
96+
if (tag.hasKey(from)) {
97+
i_from = "" + tag.getInteger(from);
98+
noFrom = false;
99+
}
100+
101+
if (tag.hasKey(to)) {
102+
i_to = "" + tag.getInteger(to);
103+
noTo = false;
104+
}
105+
106+
if (noFrom && noTo)
107+
return tOffset;
108+
109+
if (!noFrom && !noTo)
110+
aList.add(tOffset, EnumChatFormatting.WHITE + text + " from " + i_from + " to " + i_to + EnumChatFormatting.GRAY);
111+
else if (noFrom)
112+
aList.add(tOffset, EnumChatFormatting.WHITE + text + " to " + i_to + EnumChatFormatting.GRAY);
113+
else
114+
aList.add(tOffset, EnumChatFormatting.WHITE + text + " from " + i_from + EnumChatFormatting.GRAY);
115+
116+
117+
return tOffset + 1;
92118
}
93119
}

src/main/java/com/detrav/items/DetravMetaGeneratedTool01.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public DetravMetaGeneratedTool01() {
3838
addTool(102, "Electric Prospector's Scanner (MV)", "", new DetravToolMVElectricProPick(), new Object[]{DetravToolDictNames.craftingToolElectricProPick, new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), new TC_Aspects.TC_AspectStack(TC_Aspects.METALLUM, 4L)}, new TC_Aspects.TC_AspectStack(TC_Aspects.ELECTRUM, 4L));
3939
addTool(104, "Electric Prospector's Scanner (HV)", "", new DetravToolHVElectricProPick(), new Object[]{DetravToolDictNames.craftingToolElectricProPick, new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), new TC_Aspects.TC_AspectStack(TC_Aspects.METALLUM, 4L)}, new TC_Aspects.TC_AspectStack(TC_Aspects.ELECTRUM, 4L));
4040
addTool(106, "Portable Battery Charger", "", new DetravToolPortableCharger(), new Object[]{DetravToolDictNames.craftingToolPortableCharger, new TC_Aspects.TC_AspectStack(TC_Aspects.INSTRUMENTUM, 2L), new TC_Aspects.TC_AspectStack(TC_Aspects.AURAM, 4L)}, new TC_Aspects.TC_AspectStack(TC_Aspects.ELECTRUM, 4L));
41+
addTool(108, "Circuit Confugurator", "", new DetravToolCircuitConfigurator(), new Object[]{DetravToolDictNames.craftingToolCictuitConfigurator, new TC_Aspects.TC_AspectStack(TC_Aspects.COGNITIO,10L) });
4142

4243
setCreativeTab(DetravScannerMod.TAB_DETRAV);
4344
}
@@ -115,6 +116,9 @@ public void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPl
115116
aList.add(tOffset + 3, "x4 charge speed for tools");
116117
aList.add(tOffset + 4, "Right click to open GUI");
117118
break;
119+
case 108:
120+
aList.add(tOffset + 0, EnumChatFormatting.WHITE + "It can configure any programmed circuit" + EnumChatFormatting.GRAY);
121+
break;
118122
}
119123
}
120124
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.detrav.items.behaviours;
2+
3+
import com.detrav.enums.DetravItemList;
4+
import gregtech.api.items.GT_MetaBase_Item;
5+
import gregtech.common.items.behaviors.Behaviour_None;
6+
import net.minecraft.entity.player.EntityPlayer;
7+
import net.minecraft.entity.player.InventoryPlayer;
8+
import net.minecraft.item.ItemStack;
9+
import net.minecraft.nbt.NBTTagCompound;
10+
import net.minecraft.world.World;
11+
import net.minecraft.world.chunk.IChunkProvider;
12+
13+
/**
14+
* Created by Detrav on 29.04.2017.
15+
*/
16+
public class BehaviourDetravConfigurator extends Behaviour_None {
17+
public ItemStack onItemRightClick(GT_MetaBase_Item aItem, ItemStack aStack, World aWorld, EntityPlayer aPlayer) {
18+
19+
InventoryPlayer inv = aPlayer.inventory;
20+
if (inv != null) {
21+
for (int i = 0; i < inv.mainInventory.length; i++) {
22+
if (inv.mainInventory[i].getUnlocalizedName().startsWith("gt.integrated_circuit")
23+
&& inv.mainInventory[i].stackSize == 1) {
24+
25+
int circuit_config = inv.mainInventory[i].getItemDamage();
26+
if(circuit_config > 5)
27+
circuit_config = 5;
28+
circuit_config *= 2;
29+
circuit_config++;
30+
inv.mainInventory[i] = DetravItemList.ConfiguredCircuit.get(1);
31+
ItemStack aCircuit = inv.mainInventory[i];
32+
33+
//in here if circuit is empty set data to chunk
34+
35+
36+
NBTTagCompound aNBT = aCircuit.getTagCompound();
37+
if (aNBT == null) {
38+
aNBT = new NBTTagCompound();
39+
NBTTagCompound detravPosition = new NBTTagCompound();
40+
aNBT.setTag("DetravPosition", detravPosition);
41+
aCircuit.setTagCompound(aNBT);
42+
}
43+
44+
NBTTagCompound detravPosition = aNBT.getCompoundTag("DetravPosition");
45+
if (detravPosition == null) {
46+
detravPosition = new NBTTagCompound();
47+
aNBT.setTag("DetravPosition", detravPosition);
48+
}
49+
50+
51+
int x_from = ((((int) aPlayer.posX) >> 4) - circuit_config + 1) * 16;
52+
int x_to = ((((int) aPlayer.posX) >> 4) + circuit_config) * 16;
53+
int x_current = x_from;
54+
int z_from = ((((int) aPlayer.posZ) >> 4) - circuit_config + 1) * 16;
55+
int z_to = ((((int) aPlayer.posZ) >> 4) + circuit_config) * 16;
56+
int z_current = z_from;
57+
58+
59+
int y_from = (int) aPlayer.posY + 1;
60+
int y_to = (int) aPlayer.posY - 10;
61+
62+
detravPosition.setInteger("XFrom", x_from);
63+
detravPosition.setInteger("XTo", x_to);
64+
detravPosition.setInteger("XCurrent", x_current);
65+
detravPosition.setInteger("ZFrom", z_from);
66+
detravPosition.setInteger("ZTo", z_to);
67+
detravPosition.setInteger("ZCurrent", z_current);
68+
detravPosition.setInteger("YFrom", y_from);
69+
detravPosition.setInteger("YTo", y_to);
70+
return super.onItemRightClick(aItem, aStack, aWorld, aPlayer);
71+
}
72+
}
73+
74+
}
75+
return super.onItemRightClick(aItem, aStack, aWorld, aPlayer);
76+
77+
}
78+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.detrav.items.tools;
2+
3+
4+
5+
import com.detrav.enums.Textures01;
6+
import com.detrav.items.behaviours.BehaviourDetravConfigurator;
7+
import gregtech.api.GregTech_API;
8+
import gregtech.api.interfaces.IIconContainer;
9+
import gregtech.api.items.GT_MetaGenerated_Tool;
10+
import gregtech.common.tools.GT_Tool;
11+
import net.minecraft.block.Block;
12+
import net.minecraft.entity.EntityLivingBase;
13+
import net.minecraft.item.ItemStack;
14+
import net.minecraft.util.ChatComponentText;
15+
import net.minecraft.util.EnumChatFormatting;
16+
import net.minecraft.util.IChatComponent;
17+
18+
import java.util.List;
19+
20+
/**
21+
* Created by Detrav on 29.04.2017.
22+
*/
23+
public class DetravToolCircuitConfigurator extends GT_Tool {
24+
public float getBaseDamage() {
25+
return 0.25F;
26+
}
27+
28+
public float getSpeedMultiplier() {
29+
return 0.3F;
30+
}
31+
32+
public float getMaxDurabilityMultiplier() {
33+
return 0.50F;
34+
}
35+
36+
public String getCraftingSound() {
37+
return (String) GregTech_API.sSoundList.get(Integer.valueOf(101));
38+
}
39+
40+
public String getEntityHitSound() {
41+
return (String) GregTech_API.sSoundList.get(Integer.valueOf(101));
42+
}
43+
44+
public String getBreakingSound() {
45+
return (String) GregTech_API.sSoundList.get(Integer.valueOf(0));
46+
}
47+
48+
public String getMiningSound() {
49+
return (String) GregTech_API.sSoundList.get(Integer.valueOf(101));
50+
}
51+
52+
public boolean isMinableBlock(Block aBlock, byte aMetaData) {
53+
return false;
54+
}
55+
56+
public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack) {
57+
return aIsToolHead ? Textures01.mTextures[8] : null;
58+
}
59+
60+
public short[] getRGBa(boolean aIsToolHead, ItemStack aStack) {
61+
return aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa : GT_MetaGenerated_Tool.getSecondaryMaterial(aStack).mRGBa;
62+
}
63+
64+
public void onStatsAddedToTool(GT_MetaGenerated_Tool aItem, int aID) {
65+
aItem.addItemBehavior(aID, new BehaviourDetravConfigurator());
66+
}
67+
68+
public IChatComponent getDeathMessage(EntityLivingBase aPlayer, EntityLivingBase aEntity) {
69+
return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " got stuck trying to escape through a Pipe while fighting " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE);
70+
}
71+
}

src/main/java/com/detrav/proxies/CommonProxy.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.detrav.proxies;
22

33
import com.detrav.DetravScannerMod;
4-
import com.detrav.commands.DetravLevelUpCommand;
4+
55
import com.detrav.enums.DetravItemList;
66
import com.detrav.enums.DetravSimpleItems;
77
import com.detrav.events.DetravBlockBreakEventHandler;
@@ -19,7 +19,6 @@
1919
import gregtech.api.enums.*;
2020
import gregtech.api.util.GT_ModHandler;
2121
import gregtech.api.util.GT_OreDictUnificator;
22-
import ic2.api.item.IC2Items;
2322
import ic2.core.Ic2Items;
2423
import net.minecraft.entity.player.EntityPlayer;
2524
import net.minecraft.init.Blocks;
@@ -60,6 +59,11 @@ public void onPostLoad() {
6059
GT_ModHandler.addCraftingRecipe(DetravItemList.Solar_Boiler_Medium.get(1L, new Object[0]), GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"GGG", "NNN", "PMP", Character.valueOf('M'), ItemList.Machine_Steel_Boiler, Character.valueOf('P'), OrePrefixes.pipeSmall.get(Materials.Steel), Character.valueOf('N'), OrePrefixes.dust.get(Materials.Nickel), Character.valueOf('G'), new ItemStack(Blocks.glass, 1)});
6160
GT_ModHandler.addCraftingRecipe(DetravItemList.Solar_Boiler_High.get(1L, new Object[0]), GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{"GGG", "RRR", "PMP", Character.valueOf('M'), ItemList.Casing_HV, Character.valueOf('P'), OrePrefixes.pipeSmall.get(Materials.StainlessSteel), Character.valueOf('R'), OrePrefixes.dust.get(Materials.Rutile), Character.valueOf('G'), new ItemStack(Blocks.glass, 1)});
6261

62+
GT_ModHandler.addCraftingRecipe(
63+
DetravMetaGeneratedTool01.INSTANCE.getToolWithStats(108,1,Materials.Iron, Materials._NULL,null),
64+
GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE | GT_ModHandler.RecipeBits.BUFFERED,
65+
new Object[]{ "GGG","dCi","GGG", Character.valueOf('G'), new ItemStack(Items.dye,1,2), Character.valueOf('C'), ItemList.Circuit_Basic.get(1) });
66+
6367
GT_ModHandler.addShapelessCraftingRecipe(DetravItemList.DetravAdvancedMiner2.get(1L, new Object[0]),new Object[]{ItemList.AdvancedMiner2});
6468

6569
//Treetap recipes

0 commit comments

Comments
 (0)