-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added rule repeaterHalfDelay: Halve the delay of redstone repeaters u…
…pon a redstone ore
- Loading branch information
1 parent
865bd7a
commit 1dd76c1
Showing
6 changed files
with
99 additions
and
0 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
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
59 changes: 59 additions & 0 deletions
59
.../java/carpettisaddition/mixins/rule/repeaterHalfDelay/AbstractRedstoneGateBlockMixin.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,59 @@ | ||
package carpettisaddition.mixins.rule.repeaterHalfDelay; | ||
|
||
import carpettisaddition.CarpetTISAdditionSettings; | ||
import net.minecraft.block.AbstractRedstoneGateBlock; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.block.RepeaterBlock; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import java.util.Random; | ||
|
||
@Mixin(AbstractRedstoneGateBlock.class) | ||
public abstract class AbstractRedstoneGateBlockMixin | ||
{ | ||
@Shadow protected abstract int getUpdateDelayInternal(BlockState state); | ||
|
||
@Redirect( | ||
method = "scheduledTick", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/block/AbstractRedstoneGateBlock;getUpdateDelayInternal(Lnet/minecraft/block/BlockState;)I" | ||
) | ||
) | ||
private int modifyRepeaterDelay(AbstractRedstoneGateBlock abstractRedstoneGateBlock, BlockState state1, BlockState state2, ServerWorld world, BlockPos pos, Random random) | ||
{ | ||
return this.getModifiedDelay(abstractRedstoneGateBlock, world, pos, state1); | ||
} | ||
|
||
@Redirect( | ||
method = "updatePowered", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/block/AbstractRedstoneGateBlock;getUpdateDelayInternal(Lnet/minecraft/block/BlockState;)I" | ||
) | ||
) | ||
private int modifyRepeaterDelay(AbstractRedstoneGateBlock abstractRedstoneGateBlock, BlockState state1, World world, BlockPos pos, BlockState state2) | ||
{ | ||
return this.getModifiedDelay(abstractRedstoneGateBlock, world, pos, state1); | ||
} | ||
|
||
private int getModifiedDelay(AbstractRedstoneGateBlock abstractRedstoneGateBlock, World world, BlockPos pos, BlockState state) | ||
{ | ||
int delay = this.getUpdateDelayInternal(state); | ||
if (CarpetTISAdditionSettings.repeaterHalfDelay) | ||
{ | ||
if (abstractRedstoneGateBlock instanceof RepeaterBlock && world.getBlockState(pos.down()).getBlock() == Blocks.REDSTONE_ORE) | ||
{ | ||
delay /= 2; | ||
} | ||
} | ||
return delay; | ||
} | ||
} |
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