Skip to content

Commit 2b8c2b5

Browse files
fixed main fluid bugs
fixed liquid amount bug and added fluid render bug
1 parent 452b8f6 commit 2b8c2b5

9 files changed

Lines changed: 84 additions & 43 deletions

File tree

.vs/BuildCraft/v16/.suo

23 KB
Binary file not shown.

.vs/VSWorkspaceState.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"ExpandedNodes": [
3+
"",
4+
"\\dev",
5+
"\\dev\\core",
6+
"\\dev\\machine",
7+
"\\lib"
8+
],
9+
"SelectedNode": "\\dev\\main.js",
10+
"PreviewInSolutionExplorer": false
11+
}

.vs/slnx.sqlite

96 KB
Binary file not shown.

.vs/tasks.vs.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "0.2.1",
3+
"tasks": [
4+
{
5+
"taskLabel": "задача-gears",
6+
"appliesTo": "dev/items/gears.js",
7+
"type": "launch"
8+
}
9+
]
10+
}

dev/.vs/VSWorkspaceState.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"ExpandedNodes": [
3+
"",
4+
"\\core"
5+
],
6+
"SelectedNode": "\\main.js",
7+
"PreviewInSolutionExplorer": false
8+
}

dev/.vs/dev/v16/.suo

14 KB
Binary file not shown.

dev/.vs/slnx.sqlite

88 KB
Binary file not shown.

dev/core/TransportedLiquid.js

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ var TransportedLiquid = new GameObject("bc-transported-liquid", {
259259
});
260260
}
261261
this.animation.describe({
262-
render: LiquidModels.getLiquidRender(this.liquid.id, 6, this.liquid.amount <= 0.12 ? (this.liquid.amount / 20) * 100 : 6, 6, arr).getId()
262+
render: LiquidModels.getLiquidRender(this.liquid.id, 6, this.liquid.amount <= 0.12 ? (this.liquid.amount / 20) * 100 : 6, 6, arr).getId()
263263
});
264264
this.animation.refresh();
265265
},
@@ -276,6 +276,7 @@ var TransportedLiquid = new GameObject("bc-transported-liquid", {
276276
},
277277

278278
pouringAction: function() {
279+
279280
var amounts = [this.liquid.amount];
280281
var deny = [true, true, true, true, true, true];
281282
var te_counts = 0;
@@ -286,8 +287,8 @@ var TransportedLiquid = new GameObject("bc-transported-liquid", {
286287
}
287288

288289
this.render(this.pos, env.directions);
289-
290-
for (var d in env.directions) {
290+
291+
for(var d in env.directions) {
291292
var dir = env.directions[d];
292293
var liquid = LiquidMap.getLiquid(dir.x, dir.y, dir.z);
293294
if (dir.liquidStorage) {
@@ -297,45 +298,51 @@ var TransportedLiquid = new GameObject("bc-transported-liquid", {
297298
if (liquid) {
298299
if (liquid.liquid.id != this.liquid.id || liquid.liquid.amount > this.liquid.amount) {
299300
deny[d] = false;
300-
} else amounts.push(liquid.liquid.amount);
301+
} else{
302+
amounts.push(liquid.liquid.amount);
303+
liquid.selfDestroy();
304+
}
301305
}
306+
}
307+
if (te_counts > 0) {
308+
var amountForTE = this.liquid.amount / te_counts;
309+
this.liquid.amount = 0;
310+
for (var d in env.directions) {
311+
var dir = env.directions[d];
312+
if (dir.addLiquidFromPipe) {
313+
this.liquid.amount += dir.addLiquidFromPipe(this.liquid.id, amountForTE);
314+
} else if (dir.liquidStorage) {
315+
var liquidStored = dir.liquidStorage.getLiquidStored();
316+
var transportableLiquids;
317+
var transportDenied = false;
318+
if (dir.getTransportLiquid) {
319+
transportableLiquids = dir.getTransportLiquid();
320+
}
321+
if (transportableLiquids) {
322+
for (var id in transportableLiquids.input) {
323+
if (this.liquid.id == transportableLiquids.input[id]) transportDenied = true;
324+
}
325+
} else if (this.liquid.id == liquidStored) transportDenied = true;
326+
327+
if (transportDenied){
328+
var over = dir.liquidStorage.addLiquid(this.liquid.id, amountForTE);
329+
this.liquid.amount -= amountForTE
330+
this.liquid.amount += over;
331+
Debug.m("over "+over+" added "+amountForTE);
332+
}
333+
}
334+
}
335+
return;
302336
}
303-
304337
var mean = this.mean(amounts);
305338
for (var d in env.directions) {
306339
var dir = env.directions[d];
307-
if (!dir.liquidStorage && deny[d]) LiquidTransportHelper.flushLiquid(dir, this.liquid.id, mean);
308-
}
309-
310-
if (te_counts > 0) {
311-
//alert("te counts "+te_counts);
312-
var amountForTE = this.liquid.amount / te_counts;
313-
//alert(amountForTE);
314-
this.liquid.amount = 0;
315-
for (var d in env.directions) {
316-
var dir = env.directions[d];
317-
if (dir.addLiquidFromPipe) {
318-
this.liquid.amount += dir.addLiquidFromPipe(this.liquid.id, amountForTE);
319-
} else if (dir.liquidStorage) {
320-
//alert("storage");
321-
var liquidStored = dir.liquidStorage.getLiquidStored();
322-
var transportableLiquids;
323-
var transportDenied = false;
324-
if (dir.getTransportLiquid) {
325-
transportableLiquids = dir.getTransportLiquid();
326-
}
327-
if (transportableLiquids) {
328-
for (var id in transportableLiquids.input) {
329-
if (this.liquid.id == transportableLiquids.input[id]) transportDenied = true;
330-
}
331-
} else if (this.liquid.id == liquidStored) transportDenied = true;
332-
if (transportDenied) this.liquid.amount += dir.liquidStorage.addLiquid(this.liquid.id, amountForTE);
333-
}
334-
}
335-
return;
336-
}
337-
338-
this.liquid.amount = mean;
340+
if (!dir.liquidStorage && deny[d]){
341+
LiquidTransportHelper.flushLiquid(dir, this.liquid.id, mean);
342+
this.selfDestroy();
343+
return;
344+
}
345+
}
339346
},
340347

341348
//standart callbacks
@@ -360,4 +367,4 @@ var TransportedLiquid = new GameObject("bc-transported-liquid", {
360367
LiquidMap.deleteLiquid(this.pos.x, this.pos.y, this.pos.z);
361368
this.destroy();
362369
},
363-
});
370+
});

dev/main.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,16 @@ var LiquidMap = {
582582
return this.cache[key];
583583
},
584584

585-
deleteLiquid: function(x, y, z){
586-
var key = x + "." + y + "." + z;
587-
delete this.cache[key];
588-
589-
}
585+
deleteLiquid: function(x, y, z){
586+
var key = x + "." + y + "." + z;
587+
delete this.cache[key];
588+
},
589+
590+
debug:function(){
591+
for(var i in this.cache){
592+
Debug.m(this.cache[i]);
593+
}
594+
}
590595
};
591596

592597
Callback.addCallback("LevelLeft", function(){

0 commit comments

Comments
 (0)