Skip to content

Commit

Permalink
Update 1.0.3 (#64)
Browse files Browse the repository at this point in the history
* add frostology illagers to pillager friendly origin

* use tags for custom frost resistance materials

* remove and deprecate item attribute modifiers

* frostology cloak attributes

* better method for warm foods tag

no longer hooking directly into farmers delight code

* reformat packed snow block class a bit

* packed snow decay to snow

* polar bear brushable

* ocelot brushing

* wolf brushing, anger on brush

closes #63

* brushed polar bear texture

Closes #63

* bump version

* Revert "bump version"

This reverts commit 6a5145e.

* remove shearing damage config; fix template chance config

* add ad astra armor to fur armor tag
  • Loading branch information
TheDeathlyCow authored Jan 26, 2024
1 parent 1da285e commit a6287f7
Show file tree
Hide file tree
Showing 58 changed files with 631 additions and 735 deletions.
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ dependencies {
// Fabric Seasons https://modrinth.com/mod/fabric-seasons
modCompileOnly("maven.modrinth:fabric-seasons:${project.fabric_seasons_version}") { transitive = false }

// Farmer's Delight and add ons
modCompileOnly("maven.modrinth:farmers-delight-fabric:${project.farmers_delight_version}") { transitive = false }

modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-base:${project.cardinal_components_version}"
modImplementation "dev.onyxstudios.cardinal-components-api:cardinal-components-entity:${project.cardinal_components_version}"
// Includes Cardinal Components API as a Jar-in-Jar dependency (optional but recommended)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ loader_version=0.14.21


# Mod Properties
mod_version = 1.0.2
mod_version = 1.0.3
maven_group = com.github.thedeathlycow
archives_base_name = frostiful

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.github.thedeathlycow.frostiful.entity.effect.FStatusEffects;
import com.github.thedeathlycow.frostiful.entity.loot.StrayLootTableModifier;
import com.github.thedeathlycow.frostiful.item.FSmithingTemplateItem;
import com.github.thedeathlycow.frostiful.item.attribute.FrostResistantArmorTagApplicator;
import com.github.thedeathlycow.frostiful.item.attribute.ItemAttributeLoader;
import com.github.thedeathlycow.frostiful.particle.FParticleTypes;
import com.github.thedeathlycow.frostiful.registry.*;
Expand Down Expand Up @@ -54,6 +55,7 @@ public void onInitialize() {

serverManager.registerReloadListener(ItemAttributeLoader.INSTANCE);
ModifyItemAttributeModifiersCallback.EVENT.register(ItemAttributeLoader.INSTANCE);
ModifyItemAttributeModifiersCallback.EVENT.register(new FrostResistantArmorTagApplicator());

FBlocks.registerBlocks();
FItems.registerItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import net.minecraft.entity.ai.pathing.NavigationType;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
Expand Down Expand Up @@ -42,13 +44,15 @@ public class PackedSnowBlock extends Block {
Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 15.0, 16.0),
Block.createCuboidShape(0.0, 0.0, 0.0, 16.0, 16.0, 16.0)
};
private static final float MELT_CHANCE = 64f / 1125f;


public PackedSnowBlock(Settings settings) {
super(settings);
this.setDefaultState(this.stateManager.getDefaultState().with(LAYERS, 1));
}

@Override
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
if (type == NavigationType.LAND) {
return state.get(LAYERS) <= MAX_LAYERS / 2;
Expand All @@ -57,30 +61,37 @@ public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos po
}
}

@Override
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return LAYERS_TO_SHAPE[state.get(LAYERS)];
}

@Override
public VoxelShape getCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return LAYERS_TO_SHAPE[state.get(LAYERS) - 1];
}

@Override
public VoxelShape getSidesShape(BlockState state, BlockView world, BlockPos pos) {
return LAYERS_TO_SHAPE[state.get(LAYERS)];
}

@Override
public VoxelShape getCameraCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return LAYERS_TO_SHAPE[state.get(LAYERS)];
}

@Override
public boolean hasSidedTransparency(BlockState state) {
return true;
}

@Override
public float getAmbientOcclusionLightLevel(BlockState state, BlockView world, BlockPos pos) {
return state.get(LAYERS) == MAX_LAYERS ? 0.2f : 1.0f;
}

@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState blockState = world.getBlockState(pos.down());
if (blockState.isIn(BlockTags.SNOW_LAYER_CANNOT_SURVIVE_ON)) {
Expand All @@ -94,10 +105,35 @@ public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
}
}

public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
@Override
public boolean hasRandomTicks(BlockState state) {
return super.hasRandomTicks(state) && state.get(LAYERS) <= 2;
}

@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
super.randomTick(state, world, pos, random);

if (random.nextFloat() < MELT_CHANCE) {
world.setBlockState(pos, Blocks.SNOW.getDefaultState());
}
}

@Override
public BlockState getStateForNeighborUpdate(
BlockState state,
Direction direction,
BlockState neighborState,
WorldAccess world,
BlockPos pos,
BlockPos neighborPos
) {
return !state.canPlaceAt(world, pos)
? Blocks.AIR.getDefaultState()
: super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
}

@Override
public boolean canReplace(BlockState state, ItemPlacementContext context) {
int layers = state.get(LAYERS);
if (context.getStack().isOf(this.asItem()) && layers < MAX_LAYERS) {
Expand All @@ -111,6 +147,7 @@ public boolean canReplace(BlockState state, ItemPlacementContext context) {
}
}

@Override
@Nullable
public BlockState getPlacementState(ItemPlacementContext ctx) {
BlockState previousState = ctx.getWorld().getBlockState(ctx.getBlockPos());
Expand All @@ -121,6 +158,7 @@ public BlockState getPlacementState(ItemPlacementContext ctx) {
}
}

@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(LAYERS);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.github.thedeathlycow.frostiful.client;

import com.github.thedeathlycow.frostiful.Frostiful;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.Identifier;

@Environment(EnvType.CLIENT)
public class BrushableTextures {

public static final Identifier POLAR_BEAR = Frostiful.id("textures/entity/bear/polar_bear_brushed.png");

private BrushableTextures() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public class CombatConfigGroup implements ConfigData {

float packedSnowballVulnerableTypesDamage = 5.0f;

float polarBearShearingDamage = 1.0f;

int frostologerPassiveFreezingPerTick = 2;

float frostologerMaxPassiveFreezing = 0.5f;
Expand Down Expand Up @@ -102,10 +100,6 @@ public float getPackedSnowballVulnerableTypesDamage() {
return packedSnowballVulnerableTypesDamage;
}

public float getPolarBearShearingDamage() {
return polarBearShearingDamage;
}

public int getFrostologerPassiveFreezingPerTick() {
return frostologerPassiveFreezingPerTick;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class FreezingConfigGroup implements ConfigData {
int shiverWarmth = 1;
int stopShiverWarmingBelowFoodLevel = 10;
int warmFoodWarmthTime = 60 * 20;
double netheriteFrostResistance = 0.5;

public boolean doPassiveFreezing() {
return doPassiveFreezing;
Expand Down Expand Up @@ -124,4 +125,8 @@ public int getStopShiverWarmingBelowFoodLevel() {
public int getWarmFoodWarmthTime() {
return warmFoodWarmthTime;
}

public double getNetheriteFrostResistance() {
return netheriteFrostResistance;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.github.thedeathlycow.frostiful.entity;

import com.github.thedeathlycow.frostiful.Frostiful;
import com.github.thedeathlycow.frostiful.registry.FComponents;
import com.github.thedeathlycow.frostiful.util.FLootHelper;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;

public interface FBrushable {

int BRUSH_COOLDOWN = 20 * 300;
Identifier POLAR_BEAR_BRUSHING_LOOT_TABLE = Frostiful.id("gameplay/polar_bear_brushing");
Identifier OCELOT_BRUSHING_LOOT_TABLE = Frostiful.id("gameplay/ocelot_brushing");
Identifier WOLF_BRUSHING_LOOT_TABLE = Frostiful.id("gameplay/wolf_brushing");

void frostiful$brush(PlayerEntity source, SoundCategory shearedSoundCategory);

boolean frostiful$isBrushable();

boolean frostiful$wasBrushed();

static void brushEntity(
AnimalEntity animalEntity,
SoundCategory shearedSoundCategory,
Identifier furLootTable
) {
World world = animalEntity.getWorld();
world.playSoundFromEntity(
null,
animalEntity,
SoundEvents.ITEM_BRUSH_BRUSHING_GENERIC,
shearedSoundCategory,
1.0f, 1.0f
);

if (!world.isClient) {
FLootHelper.dropLootFromEntity(animalEntity, furLootTable);
}

FComponents.BRUSHABLE_COMPONENT.get(animalEntity).setLastBrushTime(world.getTime());
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.github.thedeathlycow.frostiful.entity.component;

import com.github.thedeathlycow.frostiful.entity.FBrushable;
import com.github.thedeathlycow.frostiful.registry.FComponents;
import dev.onyxstudios.cca.api.v3.component.Component;
import dev.onyxstudios.cca.api.v3.component.sync.AutoSyncedComponent;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;

public class BrushableComponent implements Component, AutoSyncedComponent {

private static final String LAST_BRUSHED_TIME_KEY = "last_brushed_time";

private long lastBrushTime = -1;

private final AnimalEntity provider;
private final FBrushable brushable;

public BrushableComponent(AnimalEntity provider) {
this.provider = provider;
this.brushable = (FBrushable) provider;
}

@Override
public void writeSyncPacket(PacketByteBuf buf, ServerPlayerEntity recipient) {
buf.writeLong(this.lastBrushTime);
}

@Override
public void applySyncPacket(PacketByteBuf buf) {
this.lastBrushTime = buf.readLong();
}

@Override
public void readFromNbt(NbtCompound tag) {
if (tag.contains(LAST_BRUSHED_TIME_KEY, NbtElement.LONG_TYPE)) {
this.lastBrushTime = tag.getLong(LAST_BRUSHED_TIME_KEY);
}
}

@Override
public void writeToNbt(NbtCompound tag) {
if (brushable.frostiful$wasBrushed()) {
tag.putLong(LAST_BRUSHED_TIME_KEY, lastBrushTime);
}
}

public long getLastBrushTime() {
return lastBrushTime;
}

public void setLastBrushTime(long lastBrushTime) {
if (this.lastBrushTime != lastBrushTime) {
this.lastBrushTime = lastBrushTime;
FComponents.BRUSHABLE_COMPONENT.sync(this.provider);
}
}

public boolean isBrushable() {
return this.provider.isAlive()
&& !this.provider.isBaby()
&& !this.wasBrushed();
}

public boolean wasBrushed() {
return lastBrushTime >= 0L
&& this.provider.getWorld().getTimeOfDay() - lastBrushTime <= FBrushable.BRUSH_COOLDOWN;
}
}
Loading

0 comments on commit a6287f7

Please sign in to comment.