initial commit

This commit is contained in:
Ellpeck 2018-10-13 20:35:18 +02:00
parent 2b1144b840
commit 44195137ee
25 changed files with 1214 additions and 0 deletions

21
.gitignore vendored Normal file
View file

@ -0,0 +1,21 @@
/rebuild.bat
/doAllTheThings.bat
/.gradle
/build
/out
/idea
/.idea
/*.iml
/*.ipr
/*.iws
/lib
/classes
/bin/
/run/
*.classpath
*.project
.settings/org.eclipse.buildship.core.prefs
*.launch
.settings/org.eclipse.jdt.core.prefs
*.prefs

80
build.gradle Normal file
View file

@ -0,0 +1,80 @@
buildscript {
repositories {
jcenter()
maven { url = "http://files.minecraftforge.net/maven" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
version = "1.0"
group = "de.ellpeck.naturesaura" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "naturesaura"
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
minecraft {
version = "1.12.2-14.23.5.2768"
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20181010"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
replaceIn "NaturesAura.java"
replace "@VERSION@", project.version.toString()
}
dependencies {
// you may put jars on which you depend on in ./libs
// or you may define them like so..
//compile "some.group:artifact:version:classifier"
//compile "some.group:artifact:version"
// real examples
//compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
//compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
// the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
//provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided,
// except that these dependencies get remapped to your current MCP mappings
//deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev'
//deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
// for more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
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 except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}

3
gradle.properties Normal file
View file

@ -0,0 +1,3 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,6 @@
#Sat Oct 13 19:44:02 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip

164
gradlew vendored Normal file
View file

@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

90
gradlew.bat vendored Normal file
View file

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View file

@ -0,0 +1,56 @@
package de.ellpeck.naturesaura;
import de.ellpeck.naturesaura.blocks.OurBlocks;
import de.ellpeck.naturesaura.proxy.IProxy;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Mod(modid = NaturesAura.MOD_ID, name = NaturesAura.MOD_NAME, version = NaturesAura.VERSION)
public final class NaturesAura {
public static final String MOD_ID = "naturesaura";
public static final String PROXY_LOCATION = "de.ellpeck." + MOD_ID + ".proxy.";
public static final String MOD_NAME = "Nature's Aura";
public static final String VERSION = "@VERSION@";
public static final Logger LOGGER = LogManager.getLogger(MOD_NAME);
@SidedProxy(modId = MOD_ID, clientSide = PROXY_LOCATION + "ClientProxy", serverSide = PROXY_LOCATION + "ServerProxy")
public static IProxy proxy;
public static final CreativeTabs CREATIVE_TAB = new CreativeTabs(MOD_ID) {
@Override
public ItemStack createIcon() {
return new ItemStack(Items.BEETROOT);
}
};
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
new OurBlocks();
ModRegistry.preInit(event);
proxy.preInit(event);
}
@EventHandler
public void init(FMLInitializationEvent event) {
ModRegistry.init(event);
proxy.init(event);
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
ModRegistry.postInit(event);
proxy.postInit(event);
}
}

View file

@ -0,0 +1,84 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.IModelProvider;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Map;
public class BlockContainerImpl extends BlockContainer implements IModItem, IModelProvider {
private final String baseName;
private final Class<? extends TileEntity> tileClass;
private final String tileRegName;
public BlockContainerImpl(Material material, String baseName, Class<? extends TileEntity> tileClass, String tileReg) {
super(material);
this.baseName = baseName;
this.tileClass = tileClass;
this.tileRegName = tileReg;
ModRegistry.addItemOrBlock(this);
}
@Nullable
@Override
public TileEntity func_149915_a(World world, int meta) {
try {
return this.tileClass.newInstance();
} catch (Exception e) {
return null;
}
}
@Override
public String getBaseName() {
return this.baseName;
}
@Override
public boolean shouldAddCreative() {
return true;
}
@Override
public void onPreInit(FMLPreInitializationEvent event) {
}
@Override
public void onInit(FMLInitializationEvent event) {
GameRegistry.registerTileEntity(this.tileClass, new ResourceLocation(NaturesAura.MOD_ID, this.tileRegName));
}
@Override
public void onPostInit(FMLPostInitializationEvent event) {
}
@Override
public Map<ItemStack, ModelVariant> getModelLocations() {
return Collections.singletonMap(new ItemStack(this), new ModelVariant(new ResourceLocation(NaturesAura.MOD_ID, this.getBaseName()), "inventory"));
}
@Override
public EnumBlockRenderType getRenderType(IBlockState state) {
return EnumBlockRenderType.MODEL;
}
}

View file

@ -0,0 +1,57 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.IModelProvider;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.util.Collections;
import java.util.Map;
public class BlockImpl extends Block implements IModItem, IModelProvider {
private final String baseName;
public BlockImpl(String baseName, Material material) {
super(material);
this.baseName = baseName;
ModRegistry.addItemOrBlock(this);
}
@Override
public String getBaseName() {
return this.baseName;
}
@Override
public boolean shouldAddCreative() {
return true;
}
@Override
public void onPreInit(FMLPreInitializationEvent event) {
}
@Override
public void onInit(FMLInitializationEvent event) {
}
@Override
public void onPostInit(FMLPostInitializationEvent event) {
}
@Override
public Map<ItemStack, ModelVariant> getModelLocations() {
return Collections.singletonMap(new ItemStack(this), new ModelVariant(new ResourceLocation(NaturesAura.MOD_ID, this.getBaseName()), "inventory"));
}
}

View file

@ -0,0 +1,9 @@
package de.ellpeck.naturesaura.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
public final class OurBlocks {
public static final Block TEST_BLOCK = new BlockImpl("test", Material.ANVIL);
}

View file

@ -0,0 +1,74 @@
package de.ellpeck.naturesaura.blocks.tiles;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
import net.minecraft.server.management.PlayerChunkMapEntry;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
public class TileEntityImpl extends TileEntity {
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) {
return oldState.getBlock() != newState.getBlock();
}
@Override
public NBTTagCompound write(NBTTagCompound compound) {
this.writeNBT(compound, false);
return super.write(compound);
}
@Override
public void read(NBTTagCompound compound) {
this.readNBT(compound, false);
super.read(compound);
}
public void writeNBT(NBTTagCompound compound, boolean syncing) {
}
public void readNBT(NBTTagCompound compound, boolean syncing) {
}
@Override
public final SPacketUpdateTileEntity getUpdatePacket() {
NBTTagCompound compound = new NBTTagCompound();
this.writeNBT(compound, true);
return new SPacketUpdateTileEntity(this.pos, 0, compound);
}
@Override
public final NBTTagCompound getUpdateTag() {
NBTTagCompound compound = new NBTTagCompound();
this.writeNBT(compound, true);
return compound;
}
@Override
public void handleUpdateTag(NBTTagCompound tag) {
this.readNBT(tag, true);
}
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
super.onDataPacket(net, packet);
this.readNBT(packet.getNbtCompound(), true);
}
public void sendToClients() {
WorldServer world = (WorldServer) this.getWorld();
PlayerChunkMapEntry entry = world.getPlayerChunkMap().getEntry(this.getPos().getX() >> 4, this.getPos().getZ() >> 4);
if (entry != null) {
for (EntityPlayerMP player : entry.getWatchingPlayers()) {
player.connection.sendPacket(this.getUpdatePacket());
}
}
}
}

View file

@ -0,0 +1,51 @@
package de.ellpeck.naturesaura.events;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.particles.ParticleHandler;
import de.ellpeck.naturesaura.particles.ParticleMagic;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
@SideOnly(Side.CLIENT)
public class ClientEvents {
@SubscribeEvent
public void onDebugRender(RenderGameOverlayEvent.Text event) {
if (Minecraft.getInstance().gameSettings.showDebugInfo) {
String prefix = TextFormatting.GREEN + "[" + NaturesAura.MOD_NAME + "]" + TextFormatting.RESET + " ";
List<String> left = event.getLeft();
left.add("");
left.add(prefix + "PartScrn: " + ParticleHandler.getParticleAmount());
}
}
@SubscribeEvent
public void onRenderLast(RenderWorldLastEvent event) {
ParticleHandler.renderParticles(event.getPartialTicks());
}
@SubscribeEvent
public void onTextureStitch(TextureStitchEvent event) {
event.getMap().func_174942_a(ParticleMagic.TEXTURE);
}
@SubscribeEvent
public void onClientTick(ClientTickEvent event) {
Minecraft mc = Minecraft.getInstance();
if (!mc.isGamePaused()) {
ParticleHandler.updateParticles();
}
if (mc.world == null) {
ParticleHandler.clearParticles();
}
}
}

View file

@ -0,0 +1,110 @@
package de.ellpeck.naturesaura.particles;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
@SideOnly(Side.CLIENT)
public final class ParticleHandler {
private static final List<Particle> PARTICLES = new ArrayList<>();
public static void spawnParticle(Particle particle, double x, double y, double z, int range) {
if (Minecraft.getInstance().player.getDistanceSq(x, y, z) <= range * range) {
PARTICLES.add(particle);
}
}
public static void updateParticles() {
for (int i = 0; i < PARTICLES.size(); i++) {
boolean remove = false;
Particle particle = PARTICLES.get(i);
if (particle != null) {
particle.tick();
if (!particle.isAlive()) {
remove = true;
}
} else {
remove = true;
}
if (remove) {
PARTICLES.remove(i);
i--;
}
}
}
public static void renderParticles(float partialTicks) {
Minecraft mc = Minecraft.getInstance();
EntityPlayer player = mc.player;
if (player != null) {
float x = ActiveRenderInfo.getRotationX();
float z = ActiveRenderInfo.getRotationZ();
float yz = ActiveRenderInfo.getRotationYZ();
float xy = ActiveRenderInfo.getRotationXY();
float xz = ActiveRenderInfo.getRotationXZ();
Particle.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
Particle.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
Particle.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
Particle.cameraViewDir = player.getLook(partialTicks);
GlStateManager.pushMatrix();
GlStateManager.enableAlphaTest();
GlStateManager.enableBlend();
GlStateManager.alphaFunc(516, 0.003921569F);
GlStateManager.disableCull();
GlStateManager.depthMask(false);
mc.textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Tessellator tessy = Tessellator.getInstance();
BufferBuilder buffer = tessy.getBuffer();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
for (Particle particle : PARTICLES) {
if (particle != null) {
particle.renderParticle(buffer, player, partialTicks, x, xz, z, yz, xy);
}
}
tessy.draw();
GlStateManager.enableCull();
GlStateManager.depthMask(true);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.disableBlend();
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.popMatrix();
}
}
public static int getParticleAmount() {
return PARTICLES.size();
}
public static void clearParticles() {
if (!PARTICLES.isEmpty()) {
PARTICLES.clear();
}
}
}

View file

@ -0,0 +1,57 @@
package de.ellpeck.naturesaura.particles;
import de.ellpeck.naturesaura.NaturesAura;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ParticleMagic extends Particle {
public static final ResourceLocation TEXTURE = new ResourceLocation(NaturesAura.MOD_ID, "particle/magic_round");
private final float desiredScale;
public ParticleMagic(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision) {
super(world, posX, posY, posZ);
this.desiredScale = scale;
this.maxAge = maxAge;
this.canCollide = collision;
this.particleGravity = gravity;
this.motionX = motionX;
this.motionY = motionY;
this.motionZ = motionZ;
this.setColor(((color >> 16) & 255) / 255F, ((color >> 8) & 255) / 255F, (color & 255) / 255F);
TextureMap map = Minecraft.getInstance().getTextureMap();
this.setParticleTexture(map.getAtlasSprite(TEXTURE.toString()));
this.particleAlpha = 0F;
this.particleScale = 0F;
}
@Override
public void tick() {
super.tick();
float lifeRatio = (float) this.age / (float) this.maxAge;
this.particleAlpha = 0.75F - (lifeRatio * 0.75F);
this.particleScale = this.desiredScale - (this.desiredScale * lifeRatio);
}
@Override
public int getFXLayer() {
return 1;
}
@Override
public int getBrightnessForRender(float f) {
return 15 << 20 | 15 << 4;
}
}

View file

@ -0,0 +1,74 @@
package de.ellpeck.naturesaura.proxy;
import de.ellpeck.naturesaura.events.ClientEvents;
import de.ellpeck.naturesaura.particles.ParticleHandler;
import de.ellpeck.naturesaura.particles.ParticleMagic;
import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public class ClientProxy implements IProxy {
@Override
public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new ClientEvents());
}
@Override
public void init(FMLInitializationEvent event) {
}
@Override
public void postInit(FMLPostInitializationEvent event) {
}
@Override
public void registerRenderer(ItemStack stack, ResourceLocation location, String variant) {
ModelLoader.setCustomModelResourceLocation(stack.getItem(), stack.getDamage(), new ModelResourceLocation(location, variant));
}
@Override
public void addColorProvidingItem(IColorProvidingItem item) {
ItemColors colors = Minecraft.getInstance().getItemColors();
IItemColor color = item.getItemColor();
if (item instanceof Item) {
colors.func_186730_a(color, (Item) item);
} else if (item instanceof Block) {
colors.func_186731_a(color, (Block) item);
}
}
@Override
public void addColorProvidingBlock(IColorProvidingBlock block) {
if (block instanceof Block) {
Minecraft.getInstance().getBlockColors().register(block.getBlockColor(), (Block) block);
}
}
@Override
public void spawnMagicParticle(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision) {
ParticleMagic particle = new ParticleMagic(world, posX, posY, posZ, motionX, motionY, motionZ, color, scale, maxAge, gravity, collision);
ParticleHandler.spawnParticle(particle, posX, posY, posZ, 32);
}
@Override
public void scheduleTask(Runnable runnable) {
Minecraft.getInstance().addScheduledTask(runnable);
}
}

View file

@ -0,0 +1,28 @@
package de.ellpeck.naturesaura.proxy;
import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public interface IProxy {
void preInit(FMLPreInitializationEvent event);
void init(FMLInitializationEvent event);
void postInit(FMLPostInitializationEvent event);
void registerRenderer(ItemStack stack, ResourceLocation location, String variant);
void addColorProvidingItem(IColorProvidingItem item);
void addColorProvidingBlock(IColorProvidingBlock block);
void spawnMagicParticle(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision);
void scheduleTask(Runnable runnable);
}

View file

@ -0,0 +1,54 @@
package de.ellpeck.naturesaura.proxy;
import de.ellpeck.naturesaura.reg.IColorProvidingBlock;
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public class ServerProxy implements IProxy {
@Override
public void preInit(FMLPreInitializationEvent event) {
}
@Override
public void init(FMLInitializationEvent event) {
}
@Override
public void postInit(FMLPostInitializationEvent event) {
}
@Override
public void registerRenderer(ItemStack stack, ResourceLocation location, String variant) {
}
@Override
public void addColorProvidingItem(IColorProvidingItem item) {
}
@Override
public void addColorProvidingBlock(IColorProvidingBlock block) {
}
@Override
public void spawnMagicParticle(World world, double posX, double posY, double posZ, double motionX, double motionY, double motionZ, int color, float scale, int maxAge, float gravity, boolean collision) {
}
@Override
public void scheduleTask(Runnable runnable) {
FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(runnable);
}
}

View file

@ -0,0 +1,12 @@
package de.ellpeck.naturesaura.reg;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IColorProvidingBlock {
@SideOnly(Side.CLIENT)
IBlockColor getBlockColor();
}

View file

@ -0,0 +1,12 @@
package de.ellpeck.naturesaura.reg;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public interface IColorProvidingItem {
@SideOnly(Side.CLIENT)
IItemColor getItemColor();
}

View file

@ -0,0 +1,9 @@
package de.ellpeck.naturesaura.reg;
import net.minecraft.item.ItemBlock;
public interface ICustomItemBlockProvider {
ItemBlock getItemBlock();
}

View file

@ -0,0 +1,18 @@
package de.ellpeck.naturesaura.reg;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public interface IModItem {
String getBaseName();
boolean shouldAddCreative();
void onPreInit(FMLPreInitializationEvent event);
void onInit(FMLInitializationEvent event);
void onPostInit(FMLPostInitializationEvent event);
}

View file

@ -0,0 +1,22 @@
package de.ellpeck.naturesaura.reg;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import java.util.Map;
public interface IModelProvider {
Map<ItemStack, ModelVariant> getModelLocations();
class ModelVariant {
public final ResourceLocation location;
public final String variant;
public ModelVariant(ResourceLocation location, String variant) {
this.location = location;
this.variant = variant;
}
}
}

View file

@ -0,0 +1,104 @@
package de.ellpeck.naturesaura.reg;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.reg.IModelProvider.ModelVariant;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public final class ModRegistry {
private static final List<IModItem> ALL_ITEMS = new ArrayList<>();
public static void addItemOrBlock(IModItem item) {
ALL_ITEMS.add(item);
}
private static void registerItem(Item item, String name, boolean addCreative) {
item.func_77655_b(NaturesAura.MOD_ID + "." + name);
item.setRegistryName(NaturesAura.MOD_ID, name);
ForgeRegistries.ITEMS.register(item);
if (addCreative) {
item.func_77637_a(NaturesAura.CREATIVE_TAB);
} else {
item.func_77637_a(null);
}
}
private static void registerBlock(Block block, String name, ItemBlock item, boolean addCreative) {
block.func_149663_c(NaturesAura.MOD_ID + "." + name);
block.setRegistryName(NaturesAura.MOD_ID, name);
ForgeRegistries.BLOCKS.register(block);
item.setRegistryName(block.getRegistryName());
ForgeRegistries.ITEMS.register(item);
if (addCreative) {
block.func_149647_a(NaturesAura.CREATIVE_TAB);
} else {
block.func_149647_a(null);
}
}
public static void preInit(FMLPreInitializationEvent event) {
for (IModItem item : ALL_ITEMS) {
if (item instanceof Item) {
registerItem((Item) item, item.getBaseName(), item.shouldAddCreative());
} else if (item instanceof Block) {
Block block = (Block) item;
ItemBlock itemBlock;
if (item instanceof ICustomItemBlockProvider) {
itemBlock = ((ICustomItemBlockProvider) item).getItemBlock();
} else {
itemBlock = new ItemBlock(block);
}
registerBlock(block, item.getBaseName(), itemBlock, item.shouldAddCreative());
}
if (item instanceof IModelProvider) {
Map<ItemStack, ModelVariant> models = ((IModelProvider) item).getModelLocations();
for (ItemStack stack : models.keySet()) {
ModelVariant variant = models.get(stack);
NaturesAura.proxy.registerRenderer(stack, variant.location, variant.variant);
}
}
item.onPreInit(event);
}
}
public static void init(FMLInitializationEvent event) {
for (IModItem item : ALL_ITEMS) {
if (item instanceof IColorProvidingBlock) {
NaturesAura.proxy.addColorProvidingBlock((IColorProvidingBlock) item);
}
if (item instanceof IColorProvidingItem) {
NaturesAura.proxy.addColorProvidingItem((IColorProvidingItem) item);
}
item.onInit(event);
}
}
public static void postInit(FMLPostInitializationEvent event) {
for (IModItem item : ALL_ITEMS) {
item.onPostInit(event);
}
}
}

View file

@ -0,0 +1,19 @@
[
{
"modid": "naturesaura",
"name": "Nature's Aura",
"description": "A mod about nature and aura and stuff",
"version": "${version}",
"mcversion": "${mcversion}",
"url": "https://ellpeck.de",
"updateUrl": "",
"authorList": ["Ellpeck"],
"credits": "Author: Ellpeck",
"logoFile": "",
"screenshots": [
],
"parent": "",
"dependencies": [
]
}
]