Skip to content

Commit

Permalink
Oh god oh no
Browse files Browse the repository at this point in the history
  • Loading branch information
Fusion-Flux committed Apr 14, 2022
1 parent c7335c3 commit 97f3805
Show file tree
Hide file tree
Showing 6 changed files with 280 additions and 145 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ org.gradle.jvmargs=-Xmx1G

# Mod Properties
mod_version = 1.0.0
maven_group = com.example
archives_base_name = fabric-example-mod
maven_group = com.fusionflux
archives_base_name = chromatic-currents

# Dependencies
fabric_version=0.47.8+1.18.2

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,24 @@
import net.minecraft.util.math.Vec3d;

public class ChromaticCurrentsClient implements ClientModInitializer {
public static void registerBlockRenderLayers() {
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.BLUESTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.GREENSTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.YELLOWSTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.ORANGESTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.PURPLESTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.LIGHTBLUESTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.LIMESTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.CYANSTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.WHITESTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.BLACKSTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.GRAYSTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.LIGHTGRAYSTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.MAGENTASTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.PINKSTONE_WIRE, RenderLayer.getTranslucent());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.BROWNSTONE_WIRE, RenderLayer.getTranslucent());
}
@Override
public void onInitializeClient() {
//ColoredRedstoneWire.COLORS[state.get(Properties.POWER)]
//FluidRender.setupFluidRendering(FluxTechBlocks.ENDURIUM, FluxTechBlocks.ENDURIUM_FLOWING, FLUID_STILL, FLUID_FLOWING, 0x084537);
registerBlockRenderLayers();
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.BLUESTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.GREENSTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.YELLOWSTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.ORANGESTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.PURPLESTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.LIGHTBLUESTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.LIMESTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.CYANSTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.WHITESTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.BLACKSTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.GRAYSTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.LIGHTGRAYSTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.MAGENTASTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.PINKSTONE_WIRE, RenderLayer.getCutout());
BlockRenderLayerMap.INSTANCE.putBlock(ChromaticCurrents.BROWNSTONE_WIRE, RenderLayer.getCutout());

ColorProviderRegistry.BLOCK.register((state, view, pos, tintIndex) -> ColoredRedstoneWire.getWireColorGood(state.get(Properties.POWER),new Vec3d(0,0,1)), ChromaticCurrents.BLUESTONE_WIRE);
ColorProviderRegistry.BLOCK.register((state, view, pos, tintIndex) -> ColoredRedstoneWire.getWireColorGood(state.get(Properties.POWER),new Vec3d(0,.5,0)), ChromaticCurrents.GREENSTONE_WIRE);
ColorProviderRegistry.BLOCK.register((state, view, pos, tintIndex) -> ColoredRedstoneWire.getWireColorGood(state.get(Properties.POWER),new Vec3d(1,1,0)), ChromaticCurrents.YELLOWSTONE_WIRE);
Expand Down
157 changes: 157 additions & 0 deletions src/main/java/com/fusionflux/chromaticcurrents/mixin/WorldMixin.java
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);
}
}
}
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"package": "com.fusionflux.chromaticcurrents.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"WorldMixin"
],
"client": [
"RedstoneWireMixin"
Expand Down
10 changes: 3 additions & 7 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
"version": "${version}",

"name": "Chromatic Currents",
"description": "This is an example description! Tell everyone what your mod is about!",
"description": "This is a mod that adds in new colors of redstone wire!",
"authors": [
"Fusion Flux"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
},

"license": "CC0-1.0",
"license": "MIT",
"icon": "assets/chromatic_currents/icon.png",

"environment": "*",
Expand All @@ -26,7 +22,7 @@
]
},
"mixins": [
"modid.mixins.json"
"chromatic_currents.mixins.json"
],

"depends": {
Expand Down

0 comments on commit 97f3805

Please sign in to comment.