Skip to content

Commit 394993f

Browse files
committedJan 9, 2016
Added Rack Capacitor and updated change log.
1 parent ecc5f89 commit 394993f

File tree

15 files changed

+155
-96
lines changed

15 files changed

+155
-96
lines changed
 

‎changelog.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515
- This allows you to monitor input and output of your energy network separately
1616
- Now you can get and set the range of Vacuum Chests
1717
- Added `getProgress()` to most machines with progress
18+
* ADDED: OpenComputers 1.6 integration (requires OpenComputers 1.6.0 now)
19+
- Added a Light Board to put into Server Racks. Allows controlling coloured lights in various layouts.
20+
- Added a Server Self-Destructor in case you don't need your servers anymore.
21+
- Added a Rack Capacitor which is a Capacitor you can put into a Rack. Ingenious. It also provides a component that gives you the amount of energy stored in that capacitor.
1822
* ADDED: Built-in tape utility program for ComputerCraft to write songs to tapes and to play, stop, pause etc.
1923
* ADDED: getPosition() to tape drives. No, I'm not joking. It's real. I'm sorry.
2024
* FIXED: Crash when the `openComputersBees` config option was set to `false`.
21-
* FIXED: Updated OpenComputers integration (requires OpenComputers 1.5.21 now)
2225

2326
==== 1.6.0 ====
2427

‎src/main/java/pl/asie/computronics/client/RackMountableRenderer.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ public class RackMountableRenderer {
2727
boomBoardActive = new ResourceLocation("computronics", "textures/blocks/boom_board_on.png"),
2828
boomBoardTicking = new ResourceLocation("computronics", "textures/blocks/boom_board_ticking.png");
2929
private IIcon
30-
boomBoard;
30+
boomBoard,
31+
rackCapacitor;
3132

32-
private static final List<Integer> mountables = Arrays.asList(8, 9);
33+
private static final List<Integer> mountables = Arrays.asList(8, 9, 10);
3334

3435
@Optional.Method(modid = Mods.OpenComputers)
3536
private boolean isRackMountable(ItemStack stack) {
@@ -152,6 +153,10 @@ public void onRackMountableRender(RackMountableRenderEvent.Block e) {
152153
e.setFrontTextureOverride(boomBoard);
153154
break;
154155
}
156+
case 10: {
157+
e.setFrontTextureOverride(rackCapacitor);
158+
break;
159+
}
155160
}
156161
}
157162

@@ -163,6 +168,7 @@ public void textureHook(TextureStitchEvent.Pre e) {
163168
mode.registerIcons(e.map);
164169
}
165170
boomBoard = e.map.registerIcon("computronics:boom_board");
171+
rackCapacitor = e.map.registerIcon("computronics:rack_capacitor");
166172
}
167173
}
168174
}

‎src/main/java/pl/asie/computronics/integration/tis3d/module/ModuleBoom.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void onServerTick(TickEvent.ServerTickEvent e) {
134134
}
135135
for(Casing casing : boomQueue) {
136136
if(casing != null && casing.getCasingWorld() != null) {
137-
SelfDestruct.goBoom(casing.getCasingWorld(), casing.getPositionX(), casing.getPositionY(), casing.getPositionZ());
137+
SelfDestruct.goBoom(casing.getCasingWorld(), casing.getPositionX(), casing.getPositionY(), casing.getPositionZ(), true);
138138
}
139139
}
140140
boomQueue.clear();

‎src/main/java/pl/asie/computronics/item/ItemOpenComputers.java

+44-32
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import pl.asie.computronics.Computronics;
3333
import pl.asie.computronics.oc.IntegrationOpenComputers;
3434
import pl.asie.computronics.oc.driver.DriverBoardBoom;
35+
import pl.asie.computronics.oc.driver.DriverBoardCapacitor;
3536
import pl.asie.computronics.oc.driver.DriverBoardLight;
3637
import pl.asie.computronics.oc.driver.DriverCardBoom;
3738
import pl.asie.computronics.oc.driver.DriverCardFX;
@@ -70,7 +71,8 @@ public ItemOpenComputers() {
7071
"card_boom",
7172
"robot_upgrade_colorful",
7273
"rack_board_light",
73-
"rack_board_boom"
74+
"rack_board_boom",
75+
"rack_board_capacitor"
7476
});
7577
this.setCreativeTab(Computronics.tab);
7678
}
@@ -106,7 +108,8 @@ public boolean worksWith(ItemStack stack, Class<? extends EnvironmentHost> host)
106108
break;
107109
}
108110
case 8:
109-
case 9: {
111+
case 9:
112+
case 10: {
110113
works = works && Rack.class.isAssignableFrom(host);
111114
break;
112115
}
@@ -141,6 +144,8 @@ public Class<? extends Environment> getEnvironment(ItemStack stack) {
141144
return DriverBoardLight.class;
142145
case 9:
143146
return DriverBoardBoom.class;
147+
case 10:
148+
return DriverBoardCapacitor.class;
144149
default:
145150
return null;
146151
}
@@ -171,6 +176,8 @@ public ManagedEnvironment createEnvironment(ItemStack stack,
171176
return container instanceof Rack ? new DriverBoardLight((Rack) container) : null;
172177
case 9:
173178
return container instanceof Rack ? new DriverBoardBoom((Rack) container) : null;
179+
case 10:
180+
return container instanceof Rack ? new DriverBoardCapacitor((Rack) container) : null;
174181
default:
175182
return null;
176183
}
@@ -197,8 +204,8 @@ public String slot(ItemStack stack) {
197204
case 7:
198205
return Slot.Upgrade;
199206
case 8:
200-
return Slot.RackMountable;
201207
case 9:
208+
case 10:
202209
return Slot.RackMountable;
203210
default:
204211
return Slot.None;
@@ -226,14 +233,44 @@ public int tier(ItemStack stack) {
226233
case 7:
227234
return 1; // Tier 2
228235
case 8:
229-
return 0; // Tier 1
230236
case 9:
237+
case 10:
231238
return 0; // Tier 1
232239
default:
233240
return 0; // Tier 1 default
234241
}
235242
}
236243

244+
@Override
245+
public String getDocumentationName(ItemStack stack) {
246+
switch(stack.getItemDamage()) {
247+
case 0:
248+
return "camera_upgrade";
249+
case 1:
250+
return "chat_upgrade";
251+
case 2:
252+
return "radar_upgrade";
253+
case 3:
254+
return "particle_card";
255+
case 4:
256+
return "spoofing_card";
257+
case 5:
258+
return "beep_card";
259+
case 6:
260+
return "self_destructing_card";
261+
case 7:
262+
return "colorful_upgrade";
263+
case 8:
264+
return "light_board";
265+
case 9:
266+
return "server_self_destructor";
267+
case 10:
268+
return "rack_capacitor";
269+
default:
270+
return "index";
271+
}
272+
}
273+
237274
@Override
238275
@Optional.Method(modid = Mods.OpenComputers)
239276
public NBTTagCompound dataTag(ItemStack stack) {
@@ -283,6 +320,9 @@ public void getSubItems(net.minecraft.item.Item item, CreativeTabs tabs, List li
283320
if(Config.OC_BOARD_BOOM) {
284321
list.add(new ItemStack(item, 1, 9));
285322
}
323+
if(Config.OC_BOARD_CAPACITOR) {
324+
list.add(new ItemStack(item, 1, 10));
325+
}
286326
}
287327

288328
private IIcon colorfulUpgradeCanvasIcon, colorfulUpgradeTopIcon;
@@ -390,34 +430,6 @@ public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, b
390430
}
391431
}
392432

393-
@Override
394-
public String getDocumentationName(ItemStack stack) {
395-
switch(stack.getItemDamage()) {
396-
case 0:
397-
return "camera_upgrade";
398-
case 1:
399-
return "chat_upgrade";
400-
case 2:
401-
return "radar_upgrade";
402-
case 3:
403-
return "particle_card";
404-
case 4:
405-
return "spoofing_card";
406-
case 5:
407-
return "beep_card";
408-
case 6:
409-
return "self_destructing_card";
410-
case 7:
411-
return "colorful_upgrade";
412-
case 8:
413-
return "light_board";
414-
case 9:
415-
return "server_self_destructor";
416-
default:
417-
return "index";
418-
}
419-
}
420-
421433
@Override
422434
@Optional.Method(modid = Mods.OpenComputers)
423435
public String computePreferredMountPoint(ItemStack stack, Robot robot, Set<String> availableMountPoints) {

‎src/main/java/pl/asie/computronics/oc/IntegrationOpenComputers.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ public void preInit() {
104104
|| Config.OC_CARD_BOOM
105105
|| Config.OC_UPGRADE_COLORFUL
106106
|| Config.OC_BOARD_LIGHT
107-
|| Config.OC_BOARD_BOOM) {
107+
|| Config.OC_BOARD_BOOM
108+
|| Config.OC_BOARD_CAPACITOR) {
108109
itemOCParts = new ItemOpenComputers();
109110
GameRegistry.registerItem(itemOCParts, "computronics.ocParts");
110111
Driver.add((Item) itemOCParts);
@@ -392,6 +393,17 @@ public void postInit() {
392393
log.warn("Could not add Server Self-Destructor Recipe because Self-Destructing Card is disabled in the config.");
393394
}
394395
}
396+
if(Config.OC_BOARD_CAPACITOR) {
397+
RecipeUtils.addShapedRecipe(new ItemStack(itemOCParts, 1, 10),
398+
"lsl", "gcg", "opo",
399+
's', li.cil.oc.api.Items.get("chip1").createItemStack(1),
400+
'g', new ItemStack(itemOCParts, 1, 6),
401+
'c', Blocks.tnt,
402+
'o', "obsidian",
403+
'l', Items.gunpowder,
404+
'p', li.cil.oc.api.Items.get("printedCircuitBoard").createItemStack(1)
405+
);
406+
}
395407
if(Computronics.buildcraft != null) {
396408
Computronics.buildcraft.postInitOC();
397409
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package pl.asie.computronics.oc.driver;
2+
3+
import li.cil.oc.api.Network;
4+
import li.cil.oc.api.component.RackBusConnectable;
5+
import li.cil.oc.api.component.RackMountable;
6+
import li.cil.oc.api.internal.Rack;
7+
import li.cil.oc.api.machine.Arguments;
8+
import li.cil.oc.api.machine.Callback;
9+
import li.cil.oc.api.machine.Context;
10+
import li.cil.oc.api.network.Visibility;
11+
import net.minecraft.entity.player.EntityPlayer;
12+
import net.minecraft.nbt.NBTTagCompound;
13+
import net.minecraftforge.common.util.ForgeDirection;
14+
import pl.asie.computronics.oc.ManagedEnvironmentWithComponentConnector;
15+
import pl.asie.computronics.reference.Config;
16+
17+
import java.util.EnumSet;
18+
19+
/**
20+
* @author Vexatos
21+
*/
22+
public class DriverBoardCapacitor extends ManagedEnvironmentWithComponentConnector implements RackMountable {
23+
24+
protected final Rack host;
25+
26+
public DriverBoardCapacitor(Rack host) {
27+
this.host = host;
28+
this.setNode(Network.newNode(this, Visibility.Network).
29+
withComponent("rack_capacitor", Visibility.Network).
30+
withConnector(Config.RACK_CAPACITOR_CAPACITY).
31+
create());
32+
}
33+
34+
@Callback(doc = "function():number; Returns the amount of energy stored in this capacitor.", direct = true)
35+
public Object[] energy(Context context, Arguments args) {
36+
return new Object[] { node.localBuffer() };
37+
}
38+
39+
@Callback(doc = "function():number; Returns the total amount of energy this capacitor can store.", direct = true)
40+
public Object[] maxEnergy(Context context, Arguments args) {
41+
return new Object[] { node.localBufferSize() };
42+
}
43+
44+
@Override
45+
public NBTTagCompound getData() {
46+
return null;
47+
}
48+
49+
@Override
50+
public int getConnectableCount() {
51+
return 0;
52+
}
53+
54+
@Override
55+
public RackBusConnectable getConnectableAt(int index) {
56+
return null;
57+
}
58+
59+
@Override
60+
public boolean onActivate(EntityPlayer player, ForgeDirection side, float hitX, float hitY, float hitZ) {
61+
return false;
62+
}
63+
64+
@Override
65+
public EnumSet<State> getCurrentState() {
66+
return EnumSet.noneOf(State.class);
67+
}
68+
}

‎src/main/java/pl/asie/computronics/reference/Config.java

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class Config {
3232
public static double LIGHT_BOARD_COLOR_CHANGE_COST = 0.2;
3333
public static double LIGHT_BOARD_COLOR_MAINTENANCE_COST = 0.02;
3434
public static double BOOM_BOARD_MAINTENANCE_COST = 0.02;
35+
public static double RACK_CAPACITOR_CAPACITY = 7500;
3536
public static String CHATBOX_PREFIX = "ChatBox";
3637
public static double LOCOMOTIVE_RELAY_RANGE = 128.0;
3738
public static double LOCOMOTIVE_RELAY_BASE_POWER = 20.0;
@@ -52,6 +53,7 @@ public class Config {
5253
public static boolean OC_UPGRADE_COLORFUL;
5354
public static boolean OC_BOARD_LIGHT;
5455
public static boolean OC_BOARD_BOOM;
56+
public static boolean OC_BOARD_CAPACITOR;
5557

5658
public static boolean CC_OPEN_MULTI_PERIPHERAL = true;
5759
public static boolean CC_ALL_MULTI_PERIPHERALS = true;
@@ -113,6 +115,7 @@ public void preInit() {
113115
OC_UPGRADE_COLORFUL = config.get("enable.opencomputers", "colorfulUpgrade", true).getBoolean(true);
114116
OC_BOARD_LIGHT = config.get("enable.opencomputers", "lightBoard", true).getBoolean(true);
115117
OC_BOARD_BOOM = config.get("enable.opencomputers", "boomBoard", true).getBoolean(true);
118+
OC_BOARD_CAPACITOR = config.get("enable.opencomputers", "rackCapacitor", true).getBoolean(true);
116119

117120
// Particle Card
118121
FX_ENERGY_COST = convertRFtoOC(
@@ -134,6 +137,8 @@ public void preInit() {
134137
config.getFloat("ocLightBoardColorMaintenanceCost", "power", 0.2f, 0.0f, 10000.0f, "How much energy will be consumed per tick to keep a Light Board's light running. Note that this value is consumed for each active light on the board."));
135138
BOOM_BOARD_MAINTENANCE_COST = convertRFtoOC(
136139
config.getFloat("ocBoomBoardMaintenanceCost", "power", 0.2f, 0.0f, 10000.0f, "How much energy will be consumed per tick to keep a Server Self-Destructor active."));
140+
RACK_CAPACITOR_CAPACITY = convertRFtoOC(
141+
config.getFloat("ocRackCapacitorCapacity", "power", 7500f, 0.0f, 10000.0f, "How much energy a Rack Capacitor can store."));
137142

138143
if(Mods.isLoaded(Mods.Railcraft)) {
139144
LOCOMOTIVE_RELAY_BASE_POWER = convertRFtoOC(

‎src/main/java/pl/asie/computronics/util/boom/SelfDestruct.java

-59
Original file line numberDiff line numberDiff line change
@@ -156,63 +156,4 @@ public static void goBoom(World world, double xPos, double yPos, double zPos, bo
156156
}
157157
}
158158
}
159-
160-
public static void goBoom(World world, double xPos, double yPos, double zPos) {
161-
SelfDestruct explosion = new SelfDestruct(world, null, xPos, yPos, zPos, 4.0F);
162-
explosion.isSmoking = true;
163-
explosion.isFlaming = false;
164-
explosion.doExplosionA();
165-
explosion.doExplosionB(false);
166-
167-
int x = (int) xPos;
168-
int y = (int) yPos;
169-
int z = (int) zPos;
170-
171-
for(Object playerEntity : world.playerEntities) {
172-
if(playerEntity instanceof EntityPlayerMP) {
173-
EntityPlayerMP entityplayer = (EntityPlayerMP) playerEntity;
174-
175-
if(entityplayer.getDistanceSq(xPos, yPos, zPos) < 4096.0D) {
176-
try {
177-
Packet p = Computronics.packet.create(Packets.PACKET_COMPUTER_BOOM)
178-
.writeDouble(xPos)
179-
.writeDouble(yPos)
180-
.writeDouble(zPos)
181-
.writeFloat(4.0F);
182-
p.writeInt(explosion.affectedBlockPositions.size());
183-
184-
{
185-
byte j, k, l;
186-
for(Object affectedBlockPosition1 : explosion.affectedBlockPositions) {
187-
ChunkPosition chunkposition = (ChunkPosition) affectedBlockPosition1;
188-
j = (byte) (chunkposition.chunkPosX - x);
189-
k = (byte) (chunkposition.chunkPosY - y);
190-
l = (byte) (chunkposition.chunkPosZ - z);
191-
p.writeByte(j);
192-
p.writeByte(k);
193-
p.writeByte(l);
194-
}
195-
}
196-
197-
Vec3 motion = (Vec3) explosion.func_77277_b().get(entityplayer);
198-
float motionX = 0;
199-
float motionY = 0;
200-
float motionZ = 0;
201-
if(motion != null) {
202-
motionY = (float) motion.xCoord;
203-
motionX = (float) motion.yCoord;
204-
motionZ = (float) motion.zCoord;
205-
}
206-
p.writeFloat(motionY);
207-
p.writeFloat(motionX);
208-
p.writeFloat(motionZ);
209-
210-
Computronics.packet.sendTo(p, entityplayer);
211-
} catch(IOException e) {
212-
e.printStackTrace();
213-
}
214-
}
215-
}
216-
}
217-
}
218159
}

‎src/main/resources/assets/computronics/doc/opencomputers/computronics/en_US/item/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Keep in mind that some of these may not be available, depending on the recipe se
2828

2929
* [Light Board](light_board.md)
3030
* [Server Self-Destructor](server_self_destructor.md)
31+
* [Rack Capacitor](rack_capacitor.md)
3132

3233
# Items for other mods
3334

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Rack Capacitor
2+
3+
![I've got the power!](item:computronics:computronics.ocParts@10)
4+
5+
The Rack Capacitor is a [Capacitor](/%LANGUAGE%/block/capacitor.md) that you can put inside a [Server Rack](/%LANGUAGE%/block/rack.md). Its benefits are akin to those of a normal [capacitor](/%LANGUAGE%/block/capacitor.md), however, Rack Capacitors do not get any adjacency bonus.
6+
7+
This Capacitor provides a component called `rack_capacitor` which allows you to read how much energy the capacitor stores at any point in time. This might be useful if you want to check whether your network is having power problems.

‎src/main/resources/assets/computronics/lang/de_DE.lang

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ item.computronics.rack_board_light.name=Serverschrank-Statusanzeige
9494
item.computronics.rack_board_light.tip=Fast so sperrig wie ihr Name
9595
item.computronics.rack_board_boom.name=Server-Selbstzerstörer
9696
item.computronics.rack_board_boom.tip=Lass uns den Mond anzünden!
97+
item.computronics.rack_board_capacitor.name=Serverschrankkondensator
98+
item.computronics.rack_board_capacitor.tip=So viel Strom, wie du nur essen könntest.
9799
item.computronics.for.combAcid.name=Kaustische Wabe
98100
item.computronics.for.dropAcid.name=Kaustischer Tropfen
99101
item.computronics.relaySensor.name=Digitaler Relaissensor

‎src/main/resources/assets/computronics/lang/en_US.lang

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ item.computronics.rack_board_light.name=Light Board
9494
item.computronics.rack_board_light.tip=Quite bulky for something that just controls four lights...
9595
item.computronics.rack_board_boom.name=Server Self-Destructor
9696
item.computronics.rack_board_boom.tip=Commonly known as an SSD.
97+
item.computronics.rack_board_capacitor.name=Rack Capacitor
98+
item.computronics.rack_board_capacitor.tip=Capacitates racks... Or something like that.
9799
item.computronics.for.combAcid.name=Caustic Comb
98100
item.computronics.for.dropAcid.name=Caustic Drop
99101
item.computronics.relaySensor.name=Digital Relay Sensor
Loading

0 commit comments

Comments
 (0)
Please sign in to comment.