Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minecraft 1.11 wrappers #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
plugins {
id "java"
id "nova.gradle" version "0.2.5"
id "nova.gradle" version "0.2.6"
id "maven-publish"
id "com.jfrog.artifactory" version "3.1.1"
}


apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle"

dependencies {
compile nova(novaVersion)
compile nova(nova_version)
}

nova {
wrappers {
"17" {
wrapper "nova.core:NOVA-Core-Wrapper-MC1.7:$novaVersion"
wrapper "nova.core:NOVA-Core-Wrapper-MC1.7:$nova_version"
runtime project(":minecraft:1.7")
}

"18" {
wrapper "nova.core:NOVA-Core-Wrapper-MC1.8:$novaVersion"
wrapper "nova.core:NOVA-Core-Wrapper-MC1.8:$nova_version"
runtime project(":minecraft:1.8")
}
"1_11" {
wrapper "nova.core:NOVA-Core-Wrapper-MC1.11:$nova_version"
runtime project(":minecraft:1.11")
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version = 0.0.1-SNAPSHOT
group = nova.minecraft
novaVersion = 0.1.0-SNAPSHOT
nova_version = 0.1.0-SNAPSHOT

packaging = jar
info.inceptionYear = 2015
Expand Down
1 change: 1 addition & 0 deletions minecraft/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
!/build.gradle
!/.gitignore

!/1.11
!/1.8
!/1.7
17 changes: 17 additions & 0 deletions minecraft/1.11/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Ignore All
/*

# Sources
!/src

# github
!/.gitignore
!/README.md

# gradle
!/build.gradle
!/build.properties
!/settings.gradle
!/gradle.properties
!/gradlew*
!/gradle
73 changes: 73 additions & 0 deletions minecraft/1.11/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
apply plugin: "maven-publish"
apply plugin: "com.jfrog.artifactory"
apply from: "https://raw.githubusercontent.com/NOVA-Team/NOVA-Gradle/master/shared-scripts/java.gradle"

idea.module.name = "Minecraft-MC-1.11"
archivesBaseName = "NOVA-Minecraft-Wrapper-MC1.11"

publishing {
publications {
main(MavenPublication) {
from components.java

artifactId "NOVA-Minecraft-Wrapper-MC1.11"

artifact sourcesJar
artifact javadocJar

pom.withXml(writePom(project.properties))
}
}
}

artifactory {
publish {
defaults {
publications("main")
publishPom = true
}
}
}

task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'deobf'
}

artifacts {
archives jar
archives deobfJar
}

apply plugin: 'net.minecraftforge.gradle.forge'

minecraft {
version = property("minecraft.version") + "-" + property("forge.version")
mappings = 'snapshot_20161220'
runDir = "run"
}

dependencies {
compile rootProject
compile group: "nova.core", name: "NOVA-Core", version: property("nova_version"), changing: true
compile group: "nova.core", name: "NOVA-Core-Wrapper-MC1.11", version: property("nova_version"), classifier: "deobf", changing: true
}

processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"

// replace version and mcversion
expand "version": project.version, "mcversion": project.minecraft.version
}

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
}
10 changes: 10 additions & 0 deletions minecraft/1.11/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
group = nova.minecraft

minecraft.version = 1.11
forge.version = 13.19.1.2189
forgeGradleVersion = 2.2-SNAPSHOT

packaging = jar
info.inceptionYear = 2016
info.description = The NOVA-Minecraft Minecraft 1.11 wrapper.
info.organization.name = NOVA
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package nova.minecraft.wrapper.mc.forge.v1_11.depmodules;

import nova.minecraft.redstone.Redstone;
import nova.minecraft.wrapper.mc.forge.v1_11.wrapper.redstone.forward.FWRedstone;
import se.jbee.inject.bind.BinderModule;

/**
* @author Calclavia
*/
public class ComponentModule extends BinderModule {
@Override
protected void declare() {
bind(Redstone.class).to(FWRedstone.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package nova.minecraft.wrapper.mc.forge.v1_11.launch;

import nova.core.block.Block;
import nova.core.event.bus.GlobalEvents;
import nova.core.loader.Loadable;
import nova.core.loader.Mod;
import nova.core.world.World;
import nova.core.wrapper.mc.forge.v1_11.util.WrapperEvent;
import nova.minecraft.redstone.Redstone;
import nova.minecraft.wrapper.mc.forge.v1_11.depmodules.ComponentModule;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;

import java.util.Optional;

/**
* The Minecraft native loader
* @author Calclavia
*/
@Mod(id = "nova-minecraft-wrapper", name = "NOVA Minecraft", version = "0.0.1", novaVersion = "0.0.1", priority = 1, modules = { ComponentModule.class })
public class RedstoneAPI implements Loadable {

private final GlobalEvents events;

public RedstoneAPI(GlobalEvents events) {
this.events = events;
}

@Override
public void preInit() {
events.on(WrapperEvent.RedstoneConnect.class)
.bind(evt -> evt.canConnect = getRedstoneNode(evt.world, evt.position)
.map(n -> n.canConnect.apply(null)).orElseGet(() -> false));

events.on(WrapperEvent.StrongRedstone.class)
.bind(evt -> evt.power = getRedstoneNode(evt.world, evt.position)
.map(Redstone::getOutputStrongPower).orElseGet(() -> 0));

events.on(WrapperEvent.WeakRedstone.class)
.bind(evt -> evt.power = getRedstoneNode(evt.world, evt.position)
.map(Redstone::getOutputWeakPower).orElseGet(() -> 0));
}

public Optional<Redstone> getRedstoneNode(World world, Vector3D pos) {
Optional<Block> blockOptional = world.getBlock(pos);
return blockOptional.flatMap(block -> block.components.getOp(Redstone.class));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nova.minecraft.wrapper.mc.forge.v1_11.wrapper.redstone.backward;

import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import nova.core.block.Block;
import nova.core.util.Direction;
import nova.core.wrapper.mc.forge.v1_11.wrapper.block.backward.BWBlock;
import nova.core.wrapper.mc.forge.v1_11.wrapper.block.world.BWWorld;
import nova.internal.core.Game;
import nova.minecraft.redstone.Redstone;
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;

import java.util.function.Consumer;
import java.util.stream.IntStream;

/**
*
* @author ExE Boss
*/
public class BWRedstone extends Redstone {

private BWBlock block() {
return (BWBlock) getProvider();
}

private net.minecraft.world.World mcWorld() {
return ((BWWorld) block().world()).world();
}

public BWRedstone() {
this.canConnect = (Redstone otherRedstone) -> {
Block otherBlock = ((Block)otherRedstone.getProvider());
Vector3D otherPos = otherBlock.position();
Vector3D thisPos = block().position();
BlockPos pos = new BlockPos(block().x(), block().y(), block().z());
return block().mcBlock.canConnectRedstone(mcWorld().getBlockState(pos), mcWorld(), pos, Game.natives().toNative(Direction.fromVector(thisPos.crossProduct(otherPos))));
};
}

@Override
public void onInputPowerChange(Consumer<Redstone> action) {}

@Override
public int getOutputStrongPower() {
BlockPos pos = new BlockPos(block().x(), block().y(), block().z());
return IntStream.range(0, 6).map(side -> mcWorld().getBlockState(pos).getStrongPower(mcWorld(), pos, EnumFacing.values()[side])).max().orElse(0);
}

@Override
public void setOutputStrongPower(int power) {}

@Override
public int getWeakPower(int side) {
return mcWorld().getRedstonePower(new BlockPos(block().x(), block().y(), block().z()), EnumFacing.values()[side]);
}

@Override
public int getInputWeakPower() {
return mcWorld().isBlockIndirectlyGettingPowered(new BlockPos(block().x(), block().y(), block().z()));
}

@Override
public int getInputStrongPower() {
return mcWorld().getStrongPower(new BlockPos(block().x(), block().y(), block().z()));
}

@Override
public int getOutputWeakPower() {
BlockPos pos = new BlockPos(block().x(), block().y(), block().z());
return IntStream.range(0, 6).map(side -> mcWorld().getBlockState(pos).getWeakPower(mcWorld(), pos, EnumFacing.values()[side])).max().orElse(0);
}

@Override
public void setOutputWeakPower(int power) {}
}
Loading