-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/supersymmetry/integration/bdsandm/BDSAndMModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package supersymmetry.integration.bdsandm; | ||
|
||
import funwayguy.bdsandm.blocks.tiles.TileEntityBarrel; | ||
import funwayguy.bdsandm.core.BDSM; | ||
import gregtech.api.cover.CoverRayTracer; | ||
import gregtech.common.items.tool.rotation.CustomBlockRotations; | ||
import gregtech.common.items.tool.rotation.ICustomRotationBehavior; | ||
import net.minecraft.block.BlockDirectional; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.util.EnumFacing; | ||
|
||
import java.util.Objects; | ||
|
||
public class BDSAndMModule { | ||
|
||
public static final ICustomRotationBehavior BDSAndM_BARREL_BEHAVIOR = (state, world, pos, hitResult) -> { | ||
EnumFacing gridSide = CoverRayTracer.determineGridSideHit(hitResult); | ||
if (gridSide == null) return false; | ||
gridSide = gridSide.getOpposite(); // idk what's happening here, blame the original author | ||
if (gridSide != state.getValue(BlockDirectional.FACING)) { | ||
TileEntityBarrel barrel = ((TileEntityBarrel) world.getTileEntity(pos)); | ||
if (barrel != null) { | ||
state = state.withProperty(BlockDirectional.FACING, gridSide); | ||
NBTTagCompound tagCompound = barrel.writeToNBT(new NBTTagCompound()); | ||
world.setBlockState(pos, state); | ||
Objects.requireNonNull(world.getTileEntity(pos)).readFromNBT(tagCompound); | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
public static void init() { | ||
CustomBlockRotations.registerCustomRotation(BDSM.blockMetalBarrel, BDSAndM_BARREL_BEHAVIOR); | ||
CustomBlockRotations.registerCustomRotation(BDSM.blockWoodBarrel, BDSAndM_BARREL_BEHAVIOR); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/supersymmetry/mixins/bdsandm/BlockBarrelBaseMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package supersymmetry.mixins.bdsandm; | ||
|
||
import funwayguy.bdsandm.blocks.BlockBarrelBase; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(BlockBarrelBase.class) | ||
public class BlockBarrelBaseMixin { | ||
|
||
@Redirect(method = "withdrawItem", | ||
remap = false, | ||
at = @At(value = "INVOKE", | ||
target = "Ljava/lang/Math;min(II)I", | ||
ordinal = 0)) | ||
private int redirectMin(int a, int b) { | ||
return b; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters