Pushing data, two way connections
parent
b0546af597
commit
61475f86ea
@ -0,0 +1,56 @@
|
||||
package net.brokenmoon.afloydwiremod.mixin;
|
||||
|
||||
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.RenderBlocks;
|
||||
import net.minecraft.src.World;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
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;
|
||||
|
||||
@Mixin(value = RenderBlocks.class, remap = false)
|
||||
public class MixinBlockRenderer {
|
||||
@Shadow
|
||||
public boolean renderStandardBlock(Block block, int i, int j, int k) { return false; }
|
||||
@Shadow
|
||||
World world;
|
||||
@Inject(method = "Lnet/minecraft/src/RenderBlocks;renderBlockByRenderType(Lnet/minecraft/src/Block;III)Z", at = @At("HEAD"))
|
||||
public void injectMethod(Block block, int i, int j, int k, CallbackInfoReturnable<Boolean> cir){
|
||||
if(block.getRenderType() == 28){
|
||||
AbstractWireTileEntity wireEntity = (AbstractWireTileEntity)this.world.getBlockTileEntity(i, j, k);
|
||||
if(wireEntity.outputs != null){
|
||||
for(int it = 0; it < wireEntity.outputs.length; it++){
|
||||
if(wireEntity.outputs[it].wire != null && wireEntity.outputs[it].wire.isMade){
|
||||
this.renderLineBetweenTwoPoints(i, j, k, wireEntity.outputs[it].wire.x, wireEntity.outputs[it].wire.y, wireEntity.outputs[it].wire.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.renderStandardBlock(block, i, j, k);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, float red, float green, float blue, float alpha, float width){
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(red, green, blue, alpha);
|
||||
GL11.glLineWidth(width);
|
||||
GL11.glBegin(GL11.GL_LINES);
|
||||
GL11.glVertex3f(Math.floorMod(x1, 16l), Math.floorMod(y1, 16l), Math.floorMod(z1, 16l));
|
||||
GL11.glVertex3f(Math.floorMod(x1, 16l) - (x1 - x2), Math.floorMod(y1, 16l) - (y1 - y2), Math.floorMod(z1, 16l) - (z1 - z2));
|
||||
GL11.glEnd();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, float red, float green, float blue, float alpha){
|
||||
renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, red, green, blue, alpha, 1);
|
||||
}
|
||||
|
||||
public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2, float red, float green, float blue){
|
||||
renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, red, green, blue, 255, 1);
|
||||
}
|
||||
public void renderLineBetweenTwoPoints(long x1, long y1, long z1, long x2, long y2, long z2){
|
||||
renderLineBetweenTwoPoints(x1, y1, z1, x2, y2, z2, 255, 0, 0, 255, 5);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue