-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
28 changed files
with
367 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...mobs-api/src/main/java/com/slimeist/server_mobs/api/compat/auto_host/ResendRPCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.slimeist.server_mobs.api.compat.auto_host; | ||
|
||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import eu.pb4.polymer.api.resourcepack.PolymerRPUtils; | ||
import eu.pb4.polymer.autohost.impl.AutoHost; | ||
import eu.pb4.polymer.autohost.impl.WebServer; | ||
import net.minecraft.server.command.CommandManager; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.text.Text; | ||
|
||
public class ResendRPCommand { | ||
public static LiteralArgumentBuilder<ServerCommandSource> register() { | ||
return CommandManager.literal("resend_resourcepack") | ||
.requires(cs -> cs.hasPermissionLevel(2)) | ||
.executes(ctx -> { | ||
boolean required = AutoHost.config.require || PolymerRPUtils.isRequired();; | ||
for (ServerPlayerEntity player : ctx.getSource().getServer().getPlayerManager().getPlayerList()) { | ||
player.sendResourcePackUrl(WebServer.fullAddress, WebServer.hash, required, AutoHost.message); | ||
} | ||
ctx.getSource().sendFeedback(Text.literal("Sent resourcepack to all players"), false); | ||
return 1; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/main/java/com/slimeist/server_mobs/items/WolfHeadArmorItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package com.slimeist.server_mobs.items; | ||
|
||
import com.google.common.collect.ImmutableMultimap; | ||
import com.google.common.collect.Multimap; | ||
import com.slimeist.server_mobs.mixin.ArmorItemAccessor; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.entity.attribute.EntityAttribute; | ||
import net.minecraft.entity.attribute.EntityAttributeModifier; | ||
import net.minecraft.entity.attribute.EntityAttributes; | ||
import net.minecraft.item.ArmorItem; | ||
import net.minecraft.item.ArmorMaterial; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvents; | ||
import net.minecraft.world.World; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.UUID; | ||
|
||
public class WolfHeadArmorItem extends CustomArmorItem { | ||
private int angryData = -1; | ||
private final Multimap<EntityAttribute, EntityAttributeModifier> angryAttributeModifiers; | ||
|
||
public WolfHeadArmorItem(ArmorItem armorItem, Item visualItem, ArmorMaterial material, Settings settings) { | ||
super(armorItem, visualItem, material, settings); | ||
|
||
Multimap<EntityAttribute, EntityAttributeModifier> superModifiers = super.getAttributeModifiers(super.getSlotType()); | ||
ImmutableMultimap.Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder(); | ||
builder.putAll(superModifiers); | ||
|
||
UUID uUID = ArmorItemAccessor.getMODIFIERS()[slot.getEntitySlotId()]; | ||
builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(uUID, "Wolf Head attack damage", 2.0D, EntityAttributeModifier.Operation.ADDITION)); | ||
|
||
angryAttributeModifiers = builder.build(); | ||
} | ||
|
||
public void setAngryData(int angryData) { | ||
this.angryData = angryData; | ||
} | ||
|
||
private void setAngry(ItemStack stack, boolean angry) { | ||
if (angry) { | ||
stack.getOrCreateNbt().putBoolean("Angry", true); | ||
} else { | ||
stack.removeSubNbt("Angry"); | ||
} | ||
} | ||
|
||
private boolean isAngry(ItemStack stack) { | ||
return stack.getOrCreateNbt().getBoolean("Angry"); | ||
} | ||
|
||
@Override | ||
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) { | ||
super.inventoryTick(stack, world, entity, slot, selected); | ||
|
||
if (entity instanceof ServerPlayerEntity serverPlayer) { | ||
boolean shouldBeAngry = serverPlayer.getAttacker() != null || (serverPlayer.getAttacking() != null && serverPlayer.getLastAttackTime()-serverPlayer.age < 200); | ||
boolean isAngry = isAngry(stack); | ||
if (shouldBeAngry != isAngry) { | ||
setAngry(stack, shouldBeAngry); | ||
|
||
if (shouldBeAngry) { | ||
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 | ||
); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public int getPolymerCustomModelData(ItemStack itemStack, @Nullable ServerPlayerEntity player) { | ||
if (isAngry(itemStack)) { | ||
return angryData; | ||
} | ||
return super.getPolymerCustomModelData(itemStack, player); | ||
} | ||
|
||
@Override | ||
public Multimap<EntityAttribute, EntityAttributeModifier> getAttributeModifiers(ItemStack stack, EquipmentSlot slot) { | ||
if (isAngry(stack) && slot == getSlotType()) | ||
return angryAttributeModifiers; | ||
return super.getAttributeModifiers(stack, slot); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/slimeist/server_mobs/mixin/ArmorItemAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.slimeist.server_mobs.mixin; | ||
|
||
import net.minecraft.item.ArmorItem; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
import java.util.UUID; | ||
|
||
@Mixin(ArmorItem.class) | ||
public interface ArmorItemAccessor { | ||
@Accessor("MODIFIERS") | ||
static UUID[] getMODIFIERS() { | ||
throw new AssertionError("Should have been mixed in"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 11 additions & 36 deletions
47
src/main/resources/assets/minecraft/shaders/include/emissive_utils.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,24 @@ | ||
#version 150 | ||
|
||
/* | ||
Format: | ||
(x, y): DESC (r, g, b, a) | ||
--------------------------------- | ||
(0, 1): Marker pixel (1, 0, 1, 1) | ||
(1, 1): textureProperties (e, a, b, c) | ||
if e == 1: | ||
pixels with the same alpha value as textureProperties become emissive with brightness b and alpha a | ||
if e > 1: | ||
everything is AWESOME err.. emissive with brightness b | ||
*/ | ||
|
||
bool check_alpha(float textureAlpha, float targetAlpha) { | ||
float targetLess = targetAlpha - 0.01; | ||
float targetMore = targetAlpha + 0.01; | ||
return (textureAlpha > targetLess && textureAlpha < targetMore); | ||
} | ||
|
||
bool is_emissive(sampler2D tex) { | ||
return texelFetch(tex, ivec2(0, 1), 0) == vec4(1, 0, 1, 1); | ||
} | ||
// Makes sure transparent things don't become solid and vice versa. | ||
float remap_alpha(float inputAlpha) { | ||
|
||
vec4 get_texture_properties(sampler2D tex) { | ||
return texelFetch(tex, ivec2(1, 1), 0) * 255; | ||
} | ||
if (check_alpha(inputAlpha, 250.0/255.0)) return 1.0; // Crocodile & Wolf eyes | ||
|
||
vec4 get_light(vec4 textureProperties, vec4 tex_color, vec4 original) { | ||
if (textureProperties.r == 1) { | ||
if (check_alpha(tex_color.a*255, textureProperties.a)) | ||
{ | ||
return vec4(textureProperties.b/255); | ||
} | ||
} else if (textureProperties.r > 1) { | ||
return vec4(textureProperties.b/255); | ||
} | ||
return original; | ||
return float(inputAlpha); // If a pixel doesn't need to have its alpha changed then it simply does not change. | ||
} | ||
|
||
float get_alpha(vec4 textureProperties, vec4 tex_color) { | ||
if (textureProperties.r == 1) { | ||
if (check_alpha(tex_color.a*255, textureProperties.a)) | ||
{ | ||
return textureProperties.g/255; | ||
} | ||
} | ||
return tex_color.a; | ||
|
||
vec4 make_emissive(vec4 inputColor, vec4 lightColor, float inputAlpha) { | ||
inputColor.a = remap_alpha(inputAlpha); // Remap the alpha value | ||
|
||
if (check_alpha(inputAlpha, 250.0/255.0)) return inputColor; | ||
|
||
return inputColor * lightColor; // If none of the pixels are supposed to be emissive, then it adds the light. | ||
} |
Binary file added
BIN
+12.4 KB
src/main/resources/assets/minecraft/textures/entity/wolf/wolf_angry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.34 KB
src/main/resources/assets/minecraft/textures/entity/wolf/wolf_angry.xcf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.