mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Implemented proper rotation code.
This commit is contained in:
1 parent
1c554fcc12
commit
9b893e8589
3 files changed
+17
-10
No files matched your search
@@ -31,5 +31,10 @@ public class ColorSwitchingComponent extends MultiblockComponent {
|
||||
public int getMeta() {
|
||||
return (int) (BotaniaAPI.internalHandler.getWorldElapsedTicks() / 20) % 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiblockComponent copy() {
|
||||
return new ColorSwitchingComponent(relPos, block);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,14 +44,14 @@ public class MultiblockComponent {
|
||||
}
|
||||
|
||||
public void rotate(double angle) {
|
||||
int x = relPos.posX;
|
||||
int z = relPos.posZ;
|
||||
double x = relPos.posX;
|
||||
double z = relPos.posZ;
|
||||
double sin = Math.sin(angle);
|
||||
double cos = Math.cos(angle);
|
||||
|
||||
double xn = x * cos - z * sin;
|
||||
double zn = x * sin + z * cos;
|
||||
relPos = new ChunkCoordinates((int) xn, relPos.posY, (int) zn);
|
||||
relPos = new ChunkCoordinates((int) Math.round(xn), relPos.posY, (int) Math.round(zn));
|
||||
}
|
||||
|
||||
public MultiblockComponent copy() {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.api.lexicon.multiblock;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
/**
|
||||
* A set of Multiblock objects for various rotations.
|
||||
@@ -18,23 +19,24 @@ import net.minecraft.entity.Entity;
|
||||
public class MultiblockSet {
|
||||
|
||||
private final Multiblock[] mbs;
|
||||
|
||||
|
||||
public MultiblockSet(Multiblock[] mbs) {
|
||||
this.mbs = mbs;
|
||||
}
|
||||
|
||||
|
||||
public MultiblockSet(Multiblock mb) {
|
||||
this(mb.createRotations());
|
||||
}
|
||||
|
||||
|
||||
public Multiblock getForEntity(Entity e) {
|
||||
return getForRotation(e.rotationPitch);
|
||||
return getForRotation(e.rotationYaw);
|
||||
}
|
||||
|
||||
|
||||
public Multiblock getForRotation(double rotation) {
|
||||
return getForIndex(0);
|
||||
int facing = MathHelper.floor_double((rotation * 4.0 / 360.0) + 0.5) & 3;
|
||||
return getForIndex(facing);
|
||||
}
|
||||
|
||||
|
||||
public Multiblock getForIndex(int index) {
|
||||
return mbs[index];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user