Skip to content

Commit

Permalink
Upgrade to V0.1.3, add new trade villager, end_mythril_ore.json with …
Browse files Browse the repository at this point in the history
…generation in end dimension, new raccoon mob with babies and timing, and refactor mod registries
  • Loading branch information
Vladyslav Potapenko committed Dec 26, 2022
1 parent 0368abe commit 50da923
Show file tree
Hide file tree
Showing 33 changed files with 1,591 additions and 55 deletions.
7 changes: 2 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ 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.
maven { url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/' }
}

dependencies {
Expand All @@ -31,6 +27,7 @@ dependencies {
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.

// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
modImplementation 'software.bernie.geckolib:geckolib-fabric-1.18:3.0.35'
}

processResources {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
loader_version=0.14.12

# Mod Properties
mod_version=0.1.2-1.18.2
mod_version=0.1.3-1.18.2
maven_group=me.nylestroke
archives_base_name=nylemod

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/me/nylestroke/nylemod/NylemodExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import me.nylestroke.nylemod.screen.ModScreenHandlers;
import me.nylestroke.nylemod.util.ModLootTableModifiers;
import me.nylestroke.nylemod.util.ModRegistries;
import me.nylestroke.nylemod.villager.ModVillagers;
import me.nylestroke.nylemod.world.feature.ModConfiguredFeatures;
import me.nylestroke.nylemod.world.gen.ModWorldGen;
import net.fabricmc.api.ModInitializer;
Expand Down Expand Up @@ -47,5 +48,7 @@ public void onInitialize() {
ModParticles.registerParticles();
ModEnchantments.registerModEnchantments();

ModVillagers.setupPOIs();

}
}
7 changes: 5 additions & 2 deletions src/main/java/me/nylestroke/nylemod/block/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public class ModBlocks {
.requiresTool()), ModItemGroup.NYLEMOD);

public static final Block JACARANDA_SAPLING = registerBlock("jacaranda_sapling",
new SaplingBlock(new JacarandaSaplingGenerator(),
FabricBlockSettings.copy(Blocks.OAK_SAPLING)), ModItemGroup.NYLEMOD);
new ModSaplingBlock(new JacarandaSaplingGenerator(),
FabricBlockSettings.copy(Blocks.OAK_SAPLING), () -> ModBlocks.MYTHRIL_BLOCK), ModItemGroup.NYLEMOD);

public static final Block MYTHRIL_BLASTER = registerBlock("mythril_blaster",
new MythrilBlasterBlock(FabricBlockSettings.of(Material.METAL).nonOpaque()), ModItemGroup.NYLEMOD);
Expand All @@ -146,6 +146,9 @@ public class ModBlocks {
new ModFluidBlock(ModFluids.HONEY_STILL, FabricBlockSettings.of(Material.WATER)
.noCollision().nonOpaque().dropsNothing()));

public static final Block END_MYTHRIL_ORE = registerBlock("end_mythril_ore",
new Block(FabricBlockSettings.of(Material.STONE).strength(4.0f).requiresTool()), ModItemGroup.NYLEMOD);


private static Block registerBlock(String name, Block block, ItemGroup group, String tooltipKey) {
registerBlockItem(name, block, group, tooltipKey);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package me.nylestroke.nylemod.block.custom;

import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SaplingBlock;
import net.minecraft.block.sapling.SaplingGenerator;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;

import java.util.function.Supplier;

public class ModSaplingBlock extends SaplingBlock {
private final Supplier<Block> ground;

public ModSaplingBlock(SaplingGenerator generator, Settings settings, Supplier<Block> ground) {
super(generator, settings);
this.ground = ground;
}

@Override
protected boolean canPlantOnTop(BlockState floor, BlockView world, BlockPos pos) {
return floor.isOf(ground.get());
}
}
5 changes: 5 additions & 0 deletions src/main/java/me/nylestroke/nylemod/client/NylemodClient.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package me.nylestroke.nylemod.client;

import me.nylestroke.nylemod.block.ModBlocks;
import me.nylestroke.nylemod.entity.ModEntities;
import me.nylestroke.nylemod.entity.client.RaccoonRenderer;
import me.nylestroke.nylemod.fluid.ModFluids;
import me.nylestroke.nylemod.particle.ModParticles;
import me.nylestroke.nylemod.particle.custom.CitrineParticle;
Expand All @@ -12,6 +14,7 @@
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
import net.fabricmc.fabric.api.client.render.fluid.v1.SimpleFluidRenderHandler;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
import net.minecraft.client.render.RenderLayer;

Expand Down Expand Up @@ -47,5 +50,7 @@ public void onInitializeClient() {
new SimpleFluidRenderHandler(SimpleFluidRenderHandler.WATER_STILL,
SimpleFluidRenderHandler.WATER_FLOWING,
SimpleFluidRenderHandler.WATER_OVERLAY, 0xe9860c));

EntityRendererRegistry.register(ModEntities.RACCOON, RaccoonRenderer::new);
}
}
22 changes: 22 additions & 0 deletions src/main/java/me/nylestroke/nylemod/entity/ModEntities.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package me.nylestroke.nylemod.entity;

import me.nylestroke.nylemod.NylemodExample;
import me.nylestroke.nylemod.entity.custom.RaccoonEntity;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;

public class ModEntities {

public static final EntityType<RaccoonEntity> RACCOON = Registry.register(
Registry.ENTITY_TYPE, new Identifier(NylemodExample.MOD_ID, "raccoon"),
FabricEntityTypeBuilder.create(SpawnGroup.CREATURE, RaccoonEntity::new).dimensions(
EntityDimensions.fixed(0.4f, 0.3f)).build()
);



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package me.nylestroke.nylemod.entity.client;

import me.nylestroke.nylemod.NylemodExample;
import me.nylestroke.nylemod.entity.custom.RaccoonEntity;
import net.minecraft.util.Identifier;
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.processor.IBone;
import software.bernie.geckolib3.model.AnimatedGeoModel;
import software.bernie.geckolib3.model.provider.data.EntityModelData;

public class RaccoonModel extends AnimatedGeoModel<RaccoonEntity> {

@Override
public Identifier getModelLocation(RaccoonEntity object) {
return new Identifier(NylemodExample.MOD_ID, "geo/raccoon.geo.json");
}

@Override
public Identifier getTextureLocation(RaccoonEntity object) {
return RaccoonRenderer.LOCATION_BY_VARIANT.get(object.getVariant());
}

@Override
public Identifier getAnimationFileLocation(RaccoonEntity animatable) {
return new Identifier(NylemodExample.MOD_ID, "animations/raccoon.animation.json");
}

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void setLivingAnimations(RaccoonEntity entity, Integer uniqueID, AnimationEvent customPredicate) {
super.setLivingAnimations(entity, uniqueID, customPredicate);
IBone head = this.getAnimationProcessor().getBone("head");

EntityModelData extraData = (EntityModelData) customPredicate.getExtraDataOfType(EntityModelData.class).get(0);
if (head != null) {
head.setRotationX(extraData.headPitch * ((float) Math.PI / 180F));
head.setRotationY(extraData.netHeadYaw * ((float) Math.PI / 180F));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package me.nylestroke.nylemod.entity.client;

import com.google.common.collect.Maps;
import me.nylestroke.nylemod.NylemodExample;
import me.nylestroke.nylemod.entity.custom.RaccoonEntity;
import me.nylestroke.nylemod.entity.variant.RaccoonVariant;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer;

import java.util.Map;

public class RaccoonRenderer extends GeoEntityRenderer<RaccoonEntity> {

public RaccoonRenderer(EntityRendererFactory.Context ctx) {
super(ctx, new RaccoonModel());
}

public static final Map<RaccoonVariant, Identifier> LOCATION_BY_VARIANT =
Util.make(Maps.newEnumMap(RaccoonVariant.class), (map) -> {
map.put(RaccoonVariant.DEFAULT,
new Identifier(NylemodExample.MOD_ID, "textures/entity/raccoon/raccoon.png"));
map.put(RaccoonVariant.DARK,
new Identifier(NylemodExample.MOD_ID, "textures/entity/raccoon/raccoondark.png"));
map.put(RaccoonVariant.RED,
new Identifier(NylemodExample.MOD_ID, "textures/entity/raccoon/redraccoon.png"));
});

@Override
public Identifier getTextureLocation(RaccoonEntity instance) {
return LOCATION_BY_VARIANT.get(instance.getVariant());
}

@Override
public RenderLayer getRenderType(RaccoonEntity animatable, float partialTicks, MatrixStack stack,
VertexConsumerProvider renderTypeBuffer, VertexConsumer vertexBuilder,
int packedLightIn, Identifier textureLocation) {

if (animatable.isBaby()) {
stack.scale(0.5f, 0.5f, 0.5f);
} else {
stack.scale(1f, 1f, 1f);
}

return super.getRenderType(animatable, partialTicks, stack, renderTypeBuffer,
vertexBuilder, packedLightIn, textureLocation);
}
}
Loading

0 comments on commit 50da923

Please sign in to comment.