Skip to content

Commit

Permalink
wolf armor fully implemented & loot tables
Browse files Browse the repository at this point in the history
  • Loading branch information
techno-sam committed Oct 14, 2023
1 parent 12687b2 commit d7abb61
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 22 deletions.
20 changes: 20 additions & 0 deletions src/main/java/com/slimeist/server_mobs/ServerMobsMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.fabricmc.api.DedicatedServerModInitializer;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
Expand All @@ -24,6 +25,10 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.item.*;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.loot.entry.LootPoolEntry;
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.tag.BiomeTags;
import net.minecraft.util.Identifier;
Expand Down Expand Up @@ -216,6 +221,21 @@ public void onInitializeServer() {
4
);
}

LootTableEvents.MODIFY.register(((resourceManager, lootManager, id, tableBuilder, source) -> {
if (id.equals(new Identifier("chests/village/village_tannery"))) {
tableBuilder.pool(LootPool.builder()
.with(ItemEntry.builder(WOLF_SUIT_CHESTPLATE))
.with(ItemEntry.builder(WOLF_SUIT_LEGGINGS))
.with(ItemEntry.builder(WOLF_SUIT_BOOTS))
.rolls(UniformLootNumberProvider.create(0.0f, 1.8f))
.build());
} else if (id.equals(new Identifier("chests/igloo_chest"))) {
tableBuilder.pool(LootPool.builder()
.with(ItemEntry.builder(WOLF_HEAD))
.build());
}
}));
}

public static Identifier id(String path) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -63,15 +64,11 @@ public void inventoryTick(ItemStack stack, World world, Entity entity, int slot,
if (shouldBeAngry != isAngry) {
setAngry(stack, shouldBeAngry);

if (shouldBeAngry) {
if (slot == getSlotType().getEntitySlotId()) {
serverPlayer.world.playSound(
null, serverPlayer.getX(), serverPlayer.getY(), serverPlayer.getZ(),
SoundEvents.ENTITY_WOLF_HOWL, SoundCategory.PLAYERS, 1.0f, 1.0f
);
} else {
serverPlayer.world.playSound(
null, serverPlayer.getX(), serverPlayer.getY(), serverPlayer.getZ(),
SoundEvents.ENTITY_WOLF_WHINE, SoundCategory.PLAYERS, 0.5f, 1.0f
shouldBeAngry ? SoundEvents.ENTITY_WOLF_HOWL : SoundEvents.ENTITY_WOLF_WHINE,
SoundCategory.PLAYERS, 1.0f, 1.0f
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#version 150

#moj_import <fog.glsl>
#moj_import <emissive_utils.glsl>

uniform sampler2D Sampler0;

uniform vec4 ColorModulator;
uniform float FogStart;
uniform float FogEnd;
uniform vec4 FogColor;

in float vertexDistance;
in vec4 vertexColor;
in vec4 lightMapColor;
in vec4 overlayColor;
in vec2 texCoord0;
in vec4 normal;

out vec4 fragColor;

void main() {
vec4 color = texture(Sampler0, texCoord0);
if (color.a < 0.1) {
discard;
}
color *= vertexColor * ColorModulator;
color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a);
float alpha = textureLod(Sampler0, texCoord0, 0.0).a;
color = make_emissive(color, lightMapColor, alpha);
fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor);
}
29 changes: 14 additions & 15 deletions src/main/resources/assets/server_mobs/models/item/wolf_head.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,41 +88,40 @@
],
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [-1.25, 1, 2.75],
"scale": [0.375, 0.375, 0.375]
"rotation": [52, 0, 0],
"translation": [0, 2.5, 2.75],
"scale": [0.55, 0.55, 0.55]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [-1.25, 1, 2.75],
"scale": [0.375, 0.375, 0.375]
"rotation": [52, 0, 0],
"translation": [0, 2.5, 2.75],
"scale": [0.55, 0.55, 0.55]
},
"firstperson_righthand": {
"rotation": [0, 45, 0],
"translation": [2.5, 2.5, -0.75],
"rotation": [0, 102, 0],
"translation": [0, 4.75, 2.5],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 45, 0],
"translation": [2.5, 2.5, -0.75],
"rotation": [0, 102, 0],
"translation": [0, 4.75, 2.5],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 3, 0],
"translation": [0, 2, 0],
"scale": [0.5, 0.5, 0.5]
},
"gui": {
"rotation": [30, 225, 0],
"translation": [0, 2.5, 0],
"scale": [0.625, 0.625, 0.625]
"translation": [0, 4.5, 0]
},
"head": {
"translation": [0, 10.75, -1.25],
"scale": [2.4375, 2.4375, 2.4375]
},
"fixed": {
"translation": [0, 7.5, -11.5],
"scale": [1.5, 1.5, 1.5]
"translation": [0, 11.5, 0],
"scale": [2.5, 2.5, 2.5]
}
},
"groups": [
Expand Down

0 comments on commit d7abb61

Please sign in to comment.