forked from Fusion-Flux/Multi-Colored-Redstone
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
c7335c3
commit 97f3805
Showing
6 changed files
with
280 additions
and
145 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
217 changes: 101 additions & 116 deletions
217
src/main/java/com/fusionflux/chromaticcurrents/block/ColoredRedstoneWire.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
157 changes: 157 additions & 0 deletions
157
src/main/java/com/fusionflux/chromaticcurrents/mixin/WorldMixin.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,157 @@ | ||
package com.fusionflux.chromaticcurrents.mixin; | ||
|
||
import com.fusionflux.chromaticcurrents.block.ColoredRedstoneWire; | ||
import net.minecraft.block.*; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Final; | ||
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.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import javax.swing.*; | ||
|
||
@Mixin(World.class) | ||
public abstract class WorldMixin { | ||
|
||
@Shadow public abstract BlockState getBlockState(BlockPos pos); | ||
|
||
@Shadow @Final private static Direction[] DIRECTIONS; | ||
|
||
@Inject(at = @At("HEAD"), method = "getEmittedRedstonePower",cancellable = true) | ||
public void getEmittedRedstonePower(BlockPos pos, Direction direction, CallbackInfoReturnable<Integer> cir) { | ||
BlockState blockStateTest = this.getBlockState(pos.offset(direction.getOpposite())); | ||
|
||
if(blockStateTest.getBlock() instanceof ColoredRedstoneWire) { | ||
|
||
if(!(this.getBlockState(pos).getBlock() instanceof AbstractRedstoneGateBlock) && this.getBlockState(pos).getBlock() != Blocks.LEVER&& this.getBlockState(pos).getBlock() != Blocks.REDSTONE_TORCH&& this.getBlockState(pos).getBlock() != Blocks.REDSTONE_BLOCK | ||
&& this.getBlockState(pos).getBlock() != Blocks.OBSERVER && !(this.getBlockState(pos).getBlock() instanceof AbstractButtonBlock) && !(this.getBlockState(pos).getBlock() instanceof AbstractPressurePlateBlock)) | ||
for (Direction upoffsetcheck : Direction.Type.HORIZONTAL) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof ColoredRedstoneWire) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof RedstoneWireBlock) { | ||
cir.setReturnValue(0); | ||
} | ||
} | ||
|
||
if(!(this.getBlockState(pos).getBlock() instanceof AbstractRedstoneGateBlock) && this.getBlockState(pos).getBlock() != Blocks.LEVER&& this.getBlockState(pos).getBlock() != Blocks.REDSTONE_TORCH&& this.getBlockState(pos).getBlock() != Blocks.REDSTONE_BLOCK | ||
&& this.getBlockState(pos).getBlock() != Blocks.OBSERVER && !(this.getBlockState(pos).getBlock() instanceof AbstractButtonBlock) && !(this.getBlockState(pos).getBlock() instanceof AbstractPressurePlateBlock)) | ||
if (this.getBlockState(pos.offset(direction)).getBlock() instanceof ColoredRedstoneWire) { | ||
if (this.getBlockState(pos.offset(direction)).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.offset(direction)).getBlock() instanceof RedstoneWireBlock) { | ||
cir.setReturnValue(0); | ||
} | ||
if(direction!= Direction.UP){ | ||
if (this.getBlockState(pos.up()).getBlock() instanceof ColoredRedstoneWire) { | ||
if (this.getBlockState(pos.up()).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.up()).getBlock() instanceof RedstoneWireBlock) { | ||
cir.setReturnValue(0); | ||
} | ||
}else{ | ||
for (Direction upoffsetcheck : Direction.Type.HORIZONTAL) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof ColoredRedstoneWire) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof RedstoneWireBlock) { | ||
cir.setReturnValue(0); | ||
} | ||
} | ||
} | ||
|
||
if(direction!= Direction.DOWN){ | ||
if (this.getBlockState(pos.down()).getBlock() instanceof ColoredRedstoneWire) { | ||
if (this.getBlockState(pos.down()).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.down()).getBlock() instanceof RedstoneWireBlock) { | ||
cir.setReturnValue(0); | ||
} }else{ | ||
for (Direction upoffsetcheck : Direction.Type.HORIZONTAL) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof ColoredRedstoneWire) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof RedstoneWireBlock) { | ||
cir.setReturnValue(0); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
if(blockStateTest.getBlock() instanceof RedstoneWireBlock) { | ||
if(!(this.getBlockState(pos).getBlock() instanceof AbstractRedstoneGateBlock) && this.getBlockState(pos).getBlock() != Blocks.LEVER&& this.getBlockState(pos).getBlock() != Blocks.REDSTONE_TORCH&& this.getBlockState(pos).getBlock() != Blocks.REDSTONE_BLOCK | ||
&& this.getBlockState(pos).getBlock() != Blocks.OBSERVER && !(this.getBlockState(pos).getBlock() instanceof AbstractButtonBlock) && !(this.getBlockState(pos).getBlock() instanceof AbstractPressurePlateBlock)) | ||
for (Direction upoffsetcheck : Direction.Type.HORIZONTAL) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof RedstoneWireBlock) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof ColoredRedstoneWire) { | ||
cir.setReturnValue(0); | ||
} | ||
} | ||
|
||
if(!(this.getBlockState(pos).getBlock() instanceof AbstractRedstoneGateBlock) && this.getBlockState(pos).getBlock() != Blocks.LEVER&& this.getBlockState(pos).getBlock() != Blocks.REDSTONE_TORCH&& this.getBlockState(pos).getBlock() != Blocks.REDSTONE_BLOCK | ||
&& this.getBlockState(pos).getBlock() != Blocks.OBSERVER && !(this.getBlockState(pos).getBlock() instanceof AbstractButtonBlock) && !(this.getBlockState(pos).getBlock() instanceof AbstractPressurePlateBlock)) | ||
if (this.getBlockState(pos.offset(direction)).getBlock() instanceof RedstoneWireBlock) { | ||
if (this.getBlockState(pos.offset(direction)).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.offset(direction)).getBlock() instanceof ColoredRedstoneWire) { | ||
cir.setReturnValue(0); | ||
} | ||
if(direction!= Direction.UP){ | ||
if (this.getBlockState(pos.up()).getBlock() instanceof RedstoneWireBlock) { | ||
if (this.getBlockState(pos.up()).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.up()).getBlock() instanceof ColoredRedstoneWire) { | ||
cir.setReturnValue(0); | ||
} | ||
}else{ | ||
for (Direction upoffsetcheck : Direction.Type.HORIZONTAL) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof RedstoneWireBlock) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof ColoredRedstoneWire) { | ||
cir.setReturnValue(0); | ||
} | ||
} | ||
} | ||
|
||
if(direction!= Direction.DOWN){ | ||
if (this.getBlockState(pos.down()).getBlock() instanceof RedstoneWireBlock) { | ||
if (this.getBlockState(pos.down()).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.down()).getBlock() instanceof ColoredRedstoneWire) { | ||
cir.setReturnValue(0); | ||
} | ||
}else{ | ||
for (Direction upoffsetcheck : Direction.Type.HORIZONTAL) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof RedstoneWireBlock) { | ||
if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() != blockStateTest.getBlock()) { | ||
cir.setReturnValue(0); | ||
} | ||
} else if (this.getBlockState(pos.offset(upoffsetcheck)).getBlock() instanceof ColoredRedstoneWire) { | ||
cir.setReturnValue(0); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
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