update
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
package dev.tggamesyt.szar.client;
|
||||||
|
|
||||||
|
import dev.tggamesyt.szar.NiggerEntity;
|
||||||
|
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||||
|
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||||
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
|
import net.minecraft.client.render.entity.model.EntityModelLayers;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
public class NiggerEntityRenderer
|
||||||
|
extends MobEntityRenderer<NiggerEntity, BipedEntityModel<NiggerEntity>> {
|
||||||
|
|
||||||
|
public NiggerEntityRenderer(EntityRendererFactory.Context context) {
|
||||||
|
super(
|
||||||
|
context,
|
||||||
|
new BipedEntityModel<>(context.getPart(EntityModelLayers.PLAYER)),
|
||||||
|
0.5F
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier getTexture(NiggerEntity entity) {
|
||||||
|
return new Identifier("szar", "textures/entity/nigg.png");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,10 +1,40 @@
|
|||||||
package dev.tggamesyt.szar.client;
|
package dev.tggamesyt.szar.client;
|
||||||
|
|
||||||
|
import dev.tggamesyt.szar.NiggerEntity;
|
||||||
|
import dev.tggamesyt.szar.Szar;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry;
|
||||||
|
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.render.entity.model.BipedEntityModel;
|
||||||
|
import net.minecraft.client.render.entity.model.EntityModelLayers;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class SzarClient implements ClientModInitializer {
|
public class SzarClient implements ClientModInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
|
ClientPlayNetworking.registerGlobalReceiver(
|
||||||
|
Szar.NWORDPACKET,
|
||||||
|
(client, handler, buf, responseSender) -> {
|
||||||
|
|
||||||
|
ItemStack stack = buf.readItemStack();
|
||||||
|
|
||||||
|
client.execute(() -> {
|
||||||
|
MinecraftClient.getInstance()
|
||||||
|
.gameRenderer.showFloatingItem(stack);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
//EntityRendererRegistry.register(
|
||||||
|
// Szar.NI,
|
||||||
|
// NiggerEntityRenderer::new
|
||||||
|
//);
|
||||||
|
|
||||||
|
//EntityModelLayerRegistry.registerModelLayer(
|
||||||
|
// EntityModelLayers.PLAYER,
|
||||||
|
// BipedEntityModel::getTexturedModelData
|
||||||
|
//);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
36
src/main/java/dev/tggamesyt/szar/NiggerEntity.java
Normal file
36
src/main/java/dev/tggamesyt/szar/NiggerEntity.java
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package dev.tggamesyt.szar;
|
||||||
|
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.ai.goal.LookAroundGoal;
|
||||||
|
import net.minecraft.entity.ai.goal.WanderAroundFarGoal;
|
||||||
|
import net.minecraft.entity.attribute.DefaultAttributeContainer;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
|
import net.minecraft.entity.damage.DamageSource;
|
||||||
|
import net.minecraft.entity.mob.MobEntity;
|
||||||
|
import net.minecraft.entity.mob.PathAwareEntity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class NiggerEntity extends PathAwareEntity {
|
||||||
|
|
||||||
|
public NiggerEntity(EntityType<? extends PathAwareEntity> type, World world) {
|
||||||
|
super(type, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initGoals() {
|
||||||
|
this.goalSelector.add(1, new WanderAroundFarGoal(this, 1.0D));
|
||||||
|
this.goalSelector.add(2, new LookAroundGoal(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DefaultAttributeContainer.Builder createAttributes() {
|
||||||
|
return MobEntity.createMobAttributes()
|
||||||
|
.add(EntityAttributes.GENERIC_MAX_HEALTH, 20.0)
|
||||||
|
.add(EntityAttributes.GENERIC_MOVEMENT_SPEED, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void dropLoot(DamageSource source, boolean causedByPlayer) {
|
||||||
|
this.dropItem(new NwordPassItem(new Item.Settings()));
|
||||||
|
}
|
||||||
|
}
|
||||||
68
src/main/java/dev/tggamesyt/szar/NwordPassItem.java
Normal file
68
src/main/java/dev/tggamesyt/szar/NwordPassItem.java
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
package dev.tggamesyt.szar;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||||
|
import net.minecraft.advancement.Advancement;
|
||||||
|
import net.minecraft.advancement.AdvancementProgress;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.network.PacketByteBuf;
|
||||||
|
import net.minecraft.server.ServerAdvancementLoader;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.TypedActionResult;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class NwordPassItem extends Item {
|
||||||
|
|
||||||
|
public NwordPassItem(Item.Settings settings) {
|
||||||
|
super(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
|
||||||
|
ItemStack stack = user.getStackInHand(hand);
|
||||||
|
|
||||||
|
if (!world.isClient) {
|
||||||
|
// Play totem animation
|
||||||
|
if (user instanceof ServerPlayerEntity serverPlayer) {
|
||||||
|
PacketByteBuf buf = PacketByteBufs.create();
|
||||||
|
buf.writeItemStack(stack);
|
||||||
|
|
||||||
|
ServerPlayNetworking.send(serverPlayer, Szar.NWORDPACKET, buf);
|
||||||
|
}
|
||||||
|
//world.sendEntityStatus(user, (byte) 35);
|
||||||
|
|
||||||
|
// Grant advancement
|
||||||
|
if (user instanceof ServerPlayerEntity serverPlayer) {
|
||||||
|
grantAdvancement(serverPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consume item
|
||||||
|
stack.decrement(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TypedActionResult.success(stack, world.isClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void grantAdvancement(ServerPlayerEntity player) {
|
||||||
|
ServerAdvancementLoader loader =
|
||||||
|
player.getServer().getAdvancementLoader();
|
||||||
|
|
||||||
|
Advancement advancement =
|
||||||
|
loader.get(new Identifier("szar", "nwordpass"));
|
||||||
|
|
||||||
|
if (advancement == null) return;
|
||||||
|
|
||||||
|
AdvancementProgress progress =
|
||||||
|
player.getAdvancementTracker().getProgress(advancement);
|
||||||
|
|
||||||
|
if (!progress.isDone()) {
|
||||||
|
for (String criterion : progress.getUnobtainedCriteria()) {
|
||||||
|
player.getAdvancementTracker().grantCriterion(advancement, criterion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,28 @@
|
|||||||
package dev.tggamesyt.szar;
|
package dev.tggamesyt.szar;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.fabricmc.fabric.api.message.v1.ServerMessageDecoratorEvent;
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
|
||||||
|
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
|
||||||
|
import net.minecraft.advancement.Advancement;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.EntityDimensions;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
|
import net.minecraft.entity.SpawnGroup;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.registry.Registry;
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Szar implements ModInitializer {
|
public class Szar implements ModInitializer {
|
||||||
|
|
||||||
public static final String MOD_ID = "szar";
|
public static final String MOD_ID = "szar";
|
||||||
@@ -17,6 +31,8 @@ public class Szar implements ModInitializer {
|
|||||||
new SzarBlock();
|
new SzarBlock();
|
||||||
public static final Block FASZ_BLOCK =
|
public static final Block FASZ_BLOCK =
|
||||||
new FaszBlock();
|
new FaszBlock();
|
||||||
|
public static final Identifier NWORDPACKET =
|
||||||
|
new Identifier("szar", "nwordpacket");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
@@ -47,5 +63,87 @@ public class Szar implements ModInitializer {
|
|||||||
new Identifier(MOD_ID, "fasz"),
|
new Identifier(MOD_ID, "fasz"),
|
||||||
new FaszItem(FASZ_BLOCK, new Item.Settings())
|
new FaszItem(FASZ_BLOCK, new Item.Settings())
|
||||||
);
|
);
|
||||||
|
Registry.register(
|
||||||
|
Registries.ITEM,
|
||||||
|
new Identifier(MOD_ID, "nwordpass"),
|
||||||
|
new NwordPassItem(new Item.Settings())
|
||||||
|
);
|
||||||
|
|
||||||
|
ServerMessageDecoratorEvent.EVENT.register((player, message) -> CompletableFuture.completedFuture(
|
||||||
|
filterMessage(player, message)
|
||||||
|
));
|
||||||
|
|
||||||
|
final EntityType<NiggerEntity> NiggerEntityType =
|
||||||
|
Registry.register(
|
||||||
|
Registries.ENTITY_TYPE,
|
||||||
|
new Identifier("yourmodid", "wandering_npc"),
|
||||||
|
FabricEntityTypeBuilder
|
||||||
|
.create(SpawnGroup.CREATURE, NiggerEntity::new)
|
||||||
|
.dimensions(EntityDimensions.fixed(0.6F, 1.8F)) // player-sized
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
FabricDefaultAttributeRegistry.register(
|
||||||
|
NiggerEntityType,
|
||||||
|
NiggerEntity.createAttributes()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final List<String> FORBIDDEN_WORDS = List.of(
|
||||||
|
"nigger",
|
||||||
|
"niger",
|
||||||
|
"niga"
|
||||||
|
);
|
||||||
|
private static Text filterMessage(ServerPlayerEntity player, Text original) {
|
||||||
|
|
||||||
|
// If player has the advancement, do nothing
|
||||||
|
if (hasAdvancement(player)) {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
|
||||||
|
String filtered = original.getString();
|
||||||
|
|
||||||
|
boolean censoredAnything = false;
|
||||||
|
|
||||||
|
for (String word : FORBIDDEN_WORDS) {
|
||||||
|
|
||||||
|
Pattern pattern = Pattern.compile(
|
||||||
|
"(?i)\\b" + Pattern.quote(word) + "\\b"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pattern.matcher(filtered).find()) {
|
||||||
|
filtered = pattern.matcher(filtered)
|
||||||
|
.replaceAll("******");
|
||||||
|
censoredAnything = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send warning once per message
|
||||||
|
if (censoredAnything) {
|
||||||
|
player.sendMessage(
|
||||||
|
Text.literal("Nincs N-Word Pass-ed!")
|
||||||
|
.formatted(Formatting.RED),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Text.literal(filtered);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean hasAdvancement(ServerPlayerEntity player) {
|
||||||
|
|
||||||
|
Advancement advancement = player
|
||||||
|
.getServer()
|
||||||
|
.getAdvancementLoader()
|
||||||
|
.get(new Identifier("szar", "nwordpass"));
|
||||||
|
|
||||||
|
if (advancement == null) return false;
|
||||||
|
|
||||||
|
return player
|
||||||
|
.getAdvancementTracker()
|
||||||
|
.getProgress(advancement)
|
||||||
|
.isDone();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"block.szar.cigany": "Cigány Block",
|
"block.szar.cigany": "Cigány Block",
|
||||||
"block.szar.fasz": "Fasz"
|
"block.szar.fasz": "Fasz",
|
||||||
|
"item.szar.nwordpass": "N-Word Pass"
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "szar:item/nwordpass"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
src/main/resources/assets/szar/textures/item/nwordpass.png
Normal file
BIN
src/main/resources/assets/szar/textures/item/nwordpass.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
BIN
src/main/resources/assets/szar/textures/textures/entity/nigg.png
Normal file
BIN
src/main/resources/assets/szar/textures/textures/entity/nigg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
15
src/main/resources/data/szar/advancements/nwordpass.json
Normal file
15
src/main/resources/data/szar/advancements/nwordpass.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"display": {
|
||||||
|
"icon": {
|
||||||
|
"item": "szar:nwordpass"
|
||||||
|
},
|
||||||
|
"title": "Nig-",
|
||||||
|
"description": "Get an N-word pass",
|
||||||
|
"show_toast": true
|
||||||
|
},
|
||||||
|
"criteria": {
|
||||||
|
"used_item": {
|
||||||
|
"trigger": "minecraft:impossible"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user