Skip to content

Commit

Permalink
Merge pull request #32 from Yoghurt4C/1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexatos authored Jun 26, 2021
2 parents 7349ef1 + 9e38524 commit da39db1
Show file tree
Hide file tree
Showing 15 changed files with 190 additions and 234 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
!/build.gradle
!/gradlew
!/gradlew.bat
!/settings.gradle

# flamingo
!/flamingo-additions.txt
53 changes: 19 additions & 34 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,49 +1,34 @@
import net.fabricmc.loom.LoomGradlePlugin

buildscript {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'http://maven.modmuss50.me/'
}
}
dependencies {
classpath "net.fabricmc:fabric-loom:0.4-SNAPSHOT"
}
}

plugins {
id 'java'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'eclipse'
id 'java'
id 'idea'
}

apply plugin: LoomGradlePlugin

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 1.16
targetCompatibility = 1.16

group = "com.reddit.user.koppeh.flamingo"
archivesBaseName = "Flamingo"
version = "1.16-1.17"

minecraft {
}
version = "1.17-1.18"

dependencies {
minecraft "com.mojang:minecraft:1.16"
mappings "net.fabricmc:yarn:1.16+build.1:v2"
modImplementation "net.fabricmc:fabric-loader:0.8.8+build.202"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.13.1+build.370-1.16"
minecraft "com.mojang:minecraft:1.17"
mappings "net.fabricmc:yarn:1.17+build.1:v2"
modImplementation "net.fabricmc:fabric-loader:0.11.3"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.34.9+1.17"
}

processResources {
from(sourceSets.main.resources.srcDirs) {
include 'fabric.mod.json'
expand version: project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'fabric.mod.json'
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}
}


tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 16
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Nov 11 14:39:10 PST 2018
#Fri May 28 05:23:29 AST 2021
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME
70 changes: 43 additions & 27 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

##############################################################################
##
Expand Down Expand Up @@ -28,16 +44,16 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand Down Expand Up @@ -66,6 +82,7 @@ esac

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
Expand Down Expand Up @@ -109,10 +126,11 @@ 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
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand All @@ -138,32 +156,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
i=`expr $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" ;;
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=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=`save "$@"`

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
cd "$(dirname "$0")"
fi
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"
43 changes: 24 additions & 19 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
Expand All @@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi

@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 DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"

@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
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -35,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -45,28 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_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=%*

: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%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
9 changes: 9 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/reddit/user/koppeh/flamingo/Flamingo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.block.FabricBlockSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.Block;
import net.minecraft.block.MapColor;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.BlockItem;
Expand All @@ -21,8 +22,8 @@ public class Flamingo implements ModInitializer {
public static final BlockEntityType<FlamingoBlockEntity> FLAMINGO_BLOCK_ENTITY;

static {
FLAMINGO_BLOCK = register("flamingo", new FlamingoBlock(FabricBlockSettings.of(Material.WOOL).materialColor(MaterialColor.PINK).hardness(1.5F).sounds(BlockSoundGroup.WOOL).build()), ItemGroup.DECORATIONS);
FLAMINGO_BLOCK_ENTITY = register("flamingo", BlockEntityType.Builder.create(FlamingoBlockEntity::new, FLAMINGO_BLOCK));
FLAMINGO_BLOCK = register("flamingo", new FlamingoBlock(FabricBlockSettings.of(Material.WOOL).materialColor(MapColor.PINK).hardness(1.5F).sounds(BlockSoundGroup.WOOL).build()), ItemGroup.DECORATIONS);
FLAMINGO_BLOCK_ENTITY = register("flamingo", FabricBlockEntityTypeBuilder.create(FlamingoBlockEntity::new, FLAMINGO_BLOCK));
}

public static Block register(String name, Block block, ItemGroup tab) {
Expand All @@ -38,7 +39,7 @@ public static Item register(String name, Item item) {
return item;
}

public static <T extends BlockEntity> BlockEntityType<T> register(String name, BlockEntityType.Builder<T> builder) {
public static <T extends BlockEntity> BlockEntityType<T> register(String name, FabricBlockEntityTypeBuilder<T> builder) {
BlockEntityType<T> blockEntityType = builder.build(null);
Registry.register(Registry.BLOCK_ENTITY_TYPE, MOD_ID + ":" + name, blockEntityType);
return blockEntityType;
Expand Down
34 changes: 21 additions & 13 deletions src/main/java/com/reddit/user/koppeh/flamingo/FlamingoBlock.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
package com.reddit.user.koppeh.flamingo;

import net.fabricmc.fabric.api.block.BlockAttackInteractionAware;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
import net.minecraft.block.BlockRenderType;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.event.listener.GameEventListener;
import org.jetbrains.annotations.Nullable;

public class FlamingoBlock extends Block implements BlockEntityProvider, BlockAttackInteractionAware {

Expand Down Expand Up @@ -48,14 +46,9 @@ protected void appendProperties(StateManager.Builder<Block, BlockState> builder)
builder.add(ROTATION);
}

@Override
public BlockEntity createBlockEntity(BlockView var1) {
return new FlamingoBlockEntity();
}

@Override
public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity player, ItemStack stack) {
int rotation = ((Math.round((((player.yaw + 180) % 360) * 16 / 360)) % 16) + 16) % 16;
int rotation = ((Math.round((((player.getYaw() + 180) % 360) * 16 / 360)) % 16) + 16) % 16;
world.setBlockState(pos, state.with(ROTATION, rotation), 3);
}

Expand All @@ -76,4 +69,19 @@ public boolean onSyncedBlockEvent(BlockState state, World world, BlockPos pos, i
}
return false;
}

@Override
public @Nullable BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new FlamingoBlockEntity(pos, state);
}

@Override
public @Nullable <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return world.isClient() ? FlamingoBlockEntity::tick : null;
}

@Override
public @Nullable <T extends BlockEntity> GameEventListener getGameEventListener(World world, T blockEntity) {
return null;
}
}
Loading

0 comments on commit da39db1

Please sign in to comment.