mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-27 23:33:00 +00:00
Fix #924 Allow wrenching top or bottom of most blocks to rotate them
This commit is contained in:
1 parent
a7ca8b0c20
commit
79f98f35d8
4 files changed
+33
-22
No files matched your search
@@ -23,6 +23,8 @@ import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -35,10 +37,11 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.IBlockRenderer;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
public class MachineDefinition {
|
||||
|
||||
public final Class<? extends TileEntity> teClass;
|
||||
public final Class<? extends TileForestry> teClass;
|
||||
|
||||
private final String teIdent;
|
||||
private Block block;
|
||||
@@ -52,11 +55,11 @@ public class MachineDefinition {
|
||||
/* CRAFTING */
|
||||
public IRecipe[] recipes;
|
||||
|
||||
public MachineDefinition(int meta, String teIdent, Class<? extends TileEntity> teClass, IRecipe... recipes) {
|
||||
public MachineDefinition(int meta, String teIdent, Class<? extends TileForestry> teClass, IRecipe... recipes) {
|
||||
this(meta, teIdent, teClass, null, recipes);
|
||||
}
|
||||
|
||||
public MachineDefinition(int meta, String teIdent, Class<? extends TileEntity> teClass, IBlockRenderer renderer, IRecipe... recipes) {
|
||||
public MachineDefinition(int meta, String teIdent, Class<? extends TileForestry> teClass, IBlockRenderer renderer, IRecipe... recipes) {
|
||||
this.meta = meta;
|
||||
this.teIdent = teIdent;
|
||||
this.teClass = teClass;
|
||||
@@ -158,7 +161,12 @@ public class MachineDefinition {
|
||||
}
|
||||
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
|
||||
return false;
|
||||
TileForestry tile = TileUtil.getTile(world, x, y, z, teClass);
|
||||
if (tile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return tile.rotate(axis);
|
||||
}
|
||||
|
||||
/* TEXTURES */
|
||||
|
||||
@@ -67,7 +67,7 @@ public abstract class TileEngine extends TileBase implements IEnergyConnection,
|
||||
setOrientation(orientation);
|
||||
} else {
|
||||
super.rotateAfterPlacement(player, side);
|
||||
rotateEngine();
|
||||
rotate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,15 @@ public abstract class TileEngine extends TileBase implements IEnergyConnection,
|
||||
}
|
||||
|
||||
/* INTERACTION */
|
||||
public void rotateEngine() {
|
||||
@Override
|
||||
public boolean rotate(ForgeDirection axis) {
|
||||
rotate();
|
||||
|
||||
// it would be irritating if the wrench opened the engine gui when it failed to rotate, so always return true
|
||||
return true;
|
||||
}
|
||||
|
||||
private void rotate() {
|
||||
for (int i = getOrientation().ordinal() + 1; i <= getOrientation().ordinal() + 6; ++i) {
|
||||
ForgeDirection orientation = ForgeDirection.values()[i % 6];
|
||||
if (isOrientedAtEnergyReciever(orientation)) {
|
||||
|
||||
@@ -98,6 +98,15 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE
|
||||
}
|
||||
}
|
||||
|
||||
public boolean rotate(ForgeDirection axis) {
|
||||
if (axis == ForgeDirection.DOWN || axis == ForgeDirection.UP) {
|
||||
ForgeDirection orientation = getOrientation().getRotation(axis);
|
||||
setOrientation(orientation);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// / UPDATING
|
||||
@Override
|
||||
public final void updateEntity() {
|
||||
|
||||
@@ -11,20 +11,17 @@
|
||||
package forestry.energy.tiles;
|
||||
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.core.render.IBlockRenderer;
|
||||
import forestry.core.tiles.MachineDefinition;
|
||||
import forestry.core.tiles.TileEngine;
|
||||
import forestry.core.tiles.TileForestry;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
|
||||
public class EngineDefinition extends MachineDefinition {
|
||||
|
||||
public EngineDefinition(int meta, String teIdent, Class<? extends TileEntity> teClass, IBlockRenderer renderer, IRecipe... recipes) {
|
||||
public EngineDefinition(int meta, String teIdent, Class<? extends TileForestry> teClass, IBlockRenderer renderer, IRecipe... recipes) {
|
||||
super(meta, teIdent, teClass, renderer, recipes);
|
||||
}
|
||||
|
||||
@@ -37,15 +34,4 @@ public class EngineDefinition extends MachineDefinition {
|
||||
|
||||
return tile.getOrientation().getOpposite().ordinal() == side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
|
||||
TileEngine tile = TileUtil.getTile(world, x, y, z, TileEngine.class);
|
||||
if (tile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
tile.rotateEngine();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user