Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin authored Nov 1, 2021
1 parent 11f8f1b commit 2bdd365
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 128 deletions.
32 changes: 25 additions & 7 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
Copyright (c) 2021 UnlikePaladin

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>



GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -631,8 +648,8 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -645,14 +662,14 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
Expand All @@ -664,11 +681,12 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
<http://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

114 changes: 56 additions & 58 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,87 +1,85 @@
plugins {
id 'fabric-loom' version '0.9-SNAPSHOT'
id 'maven-publish'
id 'fabric-loom' version '0.10-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
minecraft "com.mojang:minecraft:1.16.5"
mappings "net.fabricmc:yarn:1.16.5+build.10:v2"
modImplementation "net.fabricmc:fabric-loader:0.12.4"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
//Fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api:0.41.3+1.16"
}

processResources {
inputs.property "version", project.version
inputs.property "version", project.version
filteringCharset "UTF-8"

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

def targetJavaVersion = 8
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

// Minecraft 1.17 (21w19a) upwards uses Java 16.
it.options.release = 16
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
}
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
archivesBaseName = project.archives_base_name
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
20 changes: 9 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.63
loader_version=0.11.7

# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.10
loader_version=0.12.4
# Mod Properties
mod_version = 1.1.0
maven_group = net.unlikepaladin
archives_base_name = netherite_cake

mod_version=1.1
maven_group=net.unlikepaladin
archives_base_name=netherite_cake
# Dependencies
fabric_version=0.41.0+1.17
# check this on https://modmuss50.me/fabric.html
fabric_version=0.41.3+1.16
1 change: 1 addition & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
21 changes: 1 addition & 20 deletions src/main/java/net/unlikepaladin/ncake/NCakeMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.minecraft.state.property.Properties;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.unlikepaladin.ncake.blocks.CandleNCakeBlock;
import net.unlikepaladin.ncake.blocks.NCakeBlock;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -20,8 +19,7 @@
public class NCakeMod implements ModInitializer {
public static final Logger LOGGER = LogManager.getLogger("ncake");
public static final String MOD_ID = "ncake";
public static final Block NCAKE = new NCakeBlock(FabricBlockSettings.of(Material.CAKE).resistance(1200.0f).hardness(50.0f).mapColor(MapColor.GRAY).nonOpaque().sounds(BlockSoundGroup.NETHERITE));
public static final Block CANDLE_NCAKE = new CandleNCakeBlock(Blocks.CANDLE, (NCakeBlock) NCAKE,FabricBlockSettings.copy(NCAKE).luminance(createLightLevelFromLitBlockState(3)));;
public static final Block NCAKE = new NCakeBlock(FabricBlockSettings.of(Material.CAKE).resistance(1200.0f).hardness(50.0f).nonOpaque().sounds(BlockSoundGroup.NETHERITE));

private static ToIntFunction<BlockState> createLightLevelFromLitBlockState(int litLevel) {
return (state) -> {
Expand All @@ -38,23 +36,6 @@ public void onInitialize() {
String name = "ncake";
Registry.register(Registry.BLOCK, new Identifier(MOD_ID, "ncake"), NCAKE);
Registry.register(Registry.ITEM, new Identifier(MOD_ID, "ncake"), new BlockItem(NCAKE, new FabricItemSettings().group(ItemGroup.FOOD)));
registerBlock("candle_" + name, new CandleNCakeBlock(Blocks.CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("white_candle_" + name, new CandleNCakeBlock(Blocks.WHITE_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("orange_candle_" + name, new CandleNCakeBlock(Blocks.ORANGE_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("magenta_candle_" + name, new CandleNCakeBlock(Blocks.MAGENTA_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("light_blue_candle_" + name, new CandleNCakeBlock(Blocks.LIGHT_BLUE_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("yellow_candle_" + name, new CandleNCakeBlock(Blocks.YELLOW_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("lime_candle_" + name, new CandleNCakeBlock(Blocks.LIME_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("pink_candle_" + name, new CandleNCakeBlock(Blocks.PINK_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("gray_candle_" + name, new CandleNCakeBlock(Blocks.GRAY_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("light_gray_candle_" + name, new CandleNCakeBlock(Blocks.LIGHT_GRAY_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("cyan_candle_" + name, new CandleNCakeBlock(Blocks.CYAN_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("purple_candle_" + name, new CandleNCakeBlock(Blocks.PURPLE_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("blue_candle_" + name, new CandleNCakeBlock(Blocks.BLUE_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("brown_candle_" + name, new CandleNCakeBlock(Blocks.BROWN_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("green_candle_" + name, new CandleNCakeBlock(Blocks.GREEN_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("red_candle_" + name, new CandleNCakeBlock(Blocks.RED_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));
registerBlock("black_candle_" + name, new CandleNCakeBlock(Blocks.BLACK_CANDLE, (NCakeBlock) NCAKE, FabricBlockSettings.copy(CANDLE_NCAKE)));

}

Expand Down
36 changes: 8 additions & 28 deletions src/main/java/net/unlikepaladin/ncake/blocks/NCakeBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.event.GameEvent;

import java.util.Random;

Expand All @@ -27,27 +26,10 @@ public NCakeBlock(Settings settings) {
this.setDefaultState(this.stateManager.getDefaultState().with(BITES, 0));
}


public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
ItemStack itemStack = player.getStackInHand(hand);
Item item = itemStack.getItem();
if (itemStack.isIn(ItemTags.CANDLES) && (Integer)state.get(BITES) == 0) {
Block block = Block.getBlockFromItem(item);
if (block instanceof CandleBlock) {
if (!player.isCreative()) {
itemStack.decrement(1);
}

world.playSound((PlayerEntity)null, pos, SoundEvents.BLOCK_CAKE_ADD_CANDLE, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, CandleNCakeBlock.getCandleCakeFromCandle(block));
world.emitGameEvent(player, GameEvent.BLOCK_CHANGE, pos);
player.incrementStat(Stats.USED.getOrCreateStat(item));
return ActionResult.SUCCESS;
}
}

if (world.isClient) {
if (tryEat(world, pos, state, player).isAccepted()) {
ItemStack itemStack = player.getStackInHand(hand);
if (this.tryEat(world, pos, state, player).isAccepted()) {
return ActionResult.SUCCESS;
}

Expand All @@ -56,26 +38,24 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
}
}

return tryEat(world, pos, state, player);
return this.tryEat(world, pos, state, player);
}

protected static ActionResult tryEat(WorldAccess world, BlockPos pos, BlockState state, PlayerEntity player) {
private ActionResult tryEat(WorldAccess world, BlockPos pos, BlockState state, PlayerEntity player) {
if (!player.canConsume(false)) {
return ActionResult.PASS;
} else {
player.incrementStat(Stats.EAT_CAKE_SLICE);
player.getHungerManager().add(2, 0.1F);
int i = (Integer)state.get(BITES);
world.emitGameEvent(player, GameEvent.EAT, pos);
Random rand = new Random();
if(!world.isClient()) {
player.addStatusEffect(new StatusEffectInstance(StatusEffect.byRawId(rand.nextInt(31) + 1), 200, 0));
Random rand = new Random();
player.addStatusEffect(new StatusEffectInstance(StatusEffect.byRawId(rand.nextInt(31) + 1), 100, 0));
}
int i = (Integer) state.get(BITES);
if (i < 6) {
world.setBlockState(pos, state.with(BITES, i + 1), 3);
world.setBlockState(pos, (BlockState) state.with(BITES, i + 1), 3);
} else {
world.removeBlock(pos, false);
world.emitGameEvent(player, GameEvent.BLOCK_DESTROY, pos);
}

return ActionResult.SUCCESS;
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/assets/ncake/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"block.ncake.ncake": "Netherite Cake",
"block.ncake.candle_ncake": "Netherite Cake with Candle"
}
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
],

"depends": {
"fabricloader": ">=0.11.3",
"fabricloader": ">=0.10.4",
"fabric": "*",
"minecraft": "1.17.x",
"java": ">=16"
"minecraft": "1.16.x",
"java": ">=8"
},
"suggests": {
"another-mod": "*"
Expand Down

0 comments on commit 2bdd365

Please sign in to comment.