Skip to content

Commit a9212d2

Browse files
committed
Buffers and Item Distributors no longer retain their state when wrenched
I got tired of 'resetting' them by hand...
1 parent 4a3a435 commit a9212d2

File tree

2 files changed

+1
-90
lines changed

2 files changed

+1
-90
lines changed

src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java

-6
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,6 @@ public void loadNBTData(NBTTagCompound aNBT) {
233233
mTargetStackSize = aNBT.getInteger("mTargetStackSize");
234234
}
235235

236-
@Override
237-
public void setItemNBT(NBTTagCompound aNBT) {
238-
super.setItemNBT(aNBT);
239-
if (mTargetStackSize > 0) aNBT.setInteger("mTargetStackSize", mTargetStackSize);
240-
}
241-
242236
@Override
243237
public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
244238
if (aSide == getBaseMetaTileEntity().getBackFacing()) {

src/main/java/gregtech/common/tileentities/automation/GT_MetaTileEntity_ItemDistributor.java

+1-84
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ static String getVecRep(ForgeDirection dir) {
7171

7272
private byte currentSide = 0, currentSideItemCount = 0;
7373

74-
private byte facingPrevious = -1, perpFacingNow = -1, perpFacingPrev = -1;
75-
76-
private boolean placedFromCustomStack = false;
74+
private byte perpFacingNow = -1;
7775

7876
public GT_MetaTileEntity_ItemDistributor(int aID, String aName, String aNameRegional, int aTier) {
7977
super(
@@ -211,16 +209,6 @@ private void setSideEnabledFromItemPerSide() {
211209
}
212210
}
213211

214-
@Override
215-
public void setItemNBT(NBTTagCompound aNBT) {
216-
super.setItemNBT(aNBT);
217-
aNBT.setByte("mCurrentFacing", getBaseMetaTileEntity().getFrontFacing());
218-
aNBT.setByte("mCurrentPerp", perpFacingNow);
219-
aNBT.setBoolean("mUseNewDistributionBehavior", useNewDistributionBehavior);
220-
aNBT.setByteArray("mItemsPerSide", itemsPerSide);
221-
GT_NBT_Util.setBooleanArray(aNBT, "mSidesEnabled", sidesEnabled);
222-
}
223-
224212
@Override
225213
public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
226214
val newPerSideValue = (byte) ((itemsPerSide[aSide] + (aPlayer.isSneaking() ? -1 : 1) + 128) % 128);
@@ -241,14 +229,6 @@ private void sendSideUpdateToClient(final byte aSide) {
241229
}
242230
}
243231

244-
@Override
245-
public void onFirstTick(final IGregTechTileEntity aBaseMetaTileEntity) {
246-
super.onFirstTick(aBaseMetaTileEntity);
247-
if (/*aBaseMetaTileEntity.isServerSide() && */placedFromCustomStack) {
248-
attemptRotation();
249-
}
250-
}
251-
252232
@Override
253233
public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) {
254234
super.onPostTick(aBaseMetaTileEntity, aTimer);
@@ -295,58 +275,6 @@ private void iterateSide() {
295275
currentSide = (byte) ((currentSide + 1) % 6);
296276
}
297277

298-
private void attemptRotation() {
299-
val f = ForgeDirection.getOrientation(facingPrevious);
300-
var p = getPerpFacing(perpFacingPrev);
301-
val phi = ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing());
302-
var pi = getPerpFacing(perpFacingNow);
303-
if (f.equals(phi) && p.equals(pi)) {
304-
setSideEnabledFromItemPerSide();
305-
sendAllSidesToClient();
306-
return;
307-
}
308-
val t = crossProduct(f, p);
309-
val tau = crossProduct(phi, pi);
310-
byte[] newItemsPerSide = new byte[6];
311-
if (f.equals(phi)) {
312-
// The facing axis is unchanged, simply rotate
313-
processAxialRotation(f, p, pi, newItemsPerSide);
314-
} else if (p.equals(pi)) {
315-
// The perpendicular axis is unchanged, simply rotate
316-
processAxialRotation(p, f, phi, newItemsPerSide);
317-
} else {
318-
val transformFToPhi = getInverseRotationMatrix(f, phi);
319-
val p_prime = p.getRotation(transformFToPhi);
320-
if (p_prime.equals(pi.getOpposite())) {
321-
// Rotate itemPerSide by transformFToPhi and then 180 about phi
322-
for (byte i = 0; i < 6; i++) {
323-
var dir = ForgeDirection.getOrientation(i).getRotation(transformFToPhi);
324-
if (!phi.equals(ForgeDirection.UP)) {
325-
// Special case because of player perspective
326-
dir = rotationSquared(phi, dir);
327-
}
328-
var j = dir.ordinal();
329-
newItemsPerSide[j] = itemsPerSide[i];
330-
}
331-
} else {
332-
if (phi.equals(ForgeDirection.DOWN)) {
333-
// Special case because of player perspective
334-
pi = pi.getOpposite();
335-
}
336-
// Apply brute force rotation
337-
newItemsPerSide[rotationSquared(phi, phi).ordinal()] = itemsPerSide[f.ordinal()];
338-
newItemsPerSide[rotationSquared(phi, pi).ordinal()] = itemsPerSide[p.ordinal()];
339-
newItemsPerSide[rotationSquared(phi, tau).ordinal()] = itemsPerSide[t.ordinal()];
340-
newItemsPerSide[rotationSquared(phi, phi.getOpposite()).ordinal()] = itemsPerSide[f.getOpposite().ordinal()];
341-
newItemsPerSide[rotationSquared(phi, pi.getOpposite()).ordinal()] = itemsPerSide[p.getOpposite().ordinal()];
342-
newItemsPerSide[rotationSquared(phi, tau.getOpposite()).ordinal()] = itemsPerSide[t.getOpposite().ordinal()];
343-
}
344-
}
345-
itemsPerSide = newItemsPerSide;
346-
setSideEnabledFromItemPerSide();
347-
sendAllSidesToClient();
348-
}
349-
350278
private ForgeDirection getPerpFacing(final byte perpFacing) {
351279
switch (perpFacing) {
352280
case 0: {
@@ -403,17 +331,6 @@ private static ForgeDirection rotationSquared(final ForgeDirection axis, final F
403331
return initial.getRotation(axis).getRotation(axis);
404332
}
405333

406-
@Override
407-
public void initDefaultModes(final NBTTagCompound aNBT) {
408-
super.initDefaultModes(aNBT);
409-
if (aNBT != null /*&& getBaseMetaTileEntity().isServerSide()*/) {
410-
grabNBT(aNBT);
411-
facingPrevious = aNBT.getByte("mCurrentFacing");
412-
perpFacingPrev = aNBT.getByte("mCurrentPerp");
413-
placedFromCustomStack = true;
414-
}
415-
}
416-
417334
@Override
418335
public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) {
419336
return new GT_Container_ItemDistributor(aPlayerInventory, aBaseMetaTileEntity);

0 commit comments

Comments
 (0)