mirror of
https://github.com/TheClashFruit/CreatePissAndShit.git
synced 2024-09-19 17:36:47 +00:00
feat: diarrhea and shit mechanics
This commit is contained in:
parent
55923b0119
commit
6deebf84de
|
@ -5,10 +5,8 @@ import me.shedaniel.autoconfig.AutoConfig;
|
||||||
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
|
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
|
||||||
import me.theclashfruit.pissnshit.config.MainConfig;
|
import me.theclashfruit.pissnshit.config.MainConfig;
|
||||||
import me.theclashfruit.pissnshit.network.PissSyncPacket;
|
import me.theclashfruit.pissnshit.network.PissSyncPacket;
|
||||||
import me.theclashfruit.pissnshit.registry.Blocks;
|
import me.theclashfruit.pissnshit.network.PissingPacket;
|
||||||
import me.theclashfruit.pissnshit.registry.Fluids;
|
import me.theclashfruit.pissnshit.registry.*;
|
||||||
import me.theclashfruit.pissnshit.registry.Items;
|
|
||||||
import me.theclashfruit.pissnshit.registry.ItemGroups;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory;
|
import net.fabricmc.fabric.api.gamerule.v1.GameRuleFactory;
|
||||||
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
|
import net.fabricmc.fabric.api.gamerule.v1.GameRuleRegistry;
|
||||||
|
@ -39,6 +37,9 @@ public class PissAndShit implements ModInitializer {
|
||||||
Items.init();
|
Items.init();
|
||||||
Blocks.init();
|
Blocks.init();
|
||||||
|
|
||||||
|
StatusEffects.init();
|
||||||
|
Potions.init();
|
||||||
|
|
||||||
ItemGroups.init();
|
ItemGroups.init();
|
||||||
|
|
||||||
AutoConfig.register(MainConfig.class, Toml4jConfigSerializer::new);
|
AutoConfig.register(MainConfig.class, Toml4jConfigSerializer::new);
|
||||||
|
@ -61,5 +62,8 @@ public class PissAndShit implements ModInitializer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Register Packets
|
||||||
|
PissingPacket.register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,31 @@ package me.theclashfruit.pissnshit.client;
|
||||||
|
|
||||||
import me.theclashfruit.pissnshit.client.gui.PissAndShitHudOverlay;
|
import me.theclashfruit.pissnshit.client.gui.PissAndShitHudOverlay;
|
||||||
import me.theclashfruit.pissnshit.network.PissSyncPacket;
|
import me.theclashfruit.pissnshit.network.PissSyncPacket;
|
||||||
|
import me.theclashfruit.pissnshit.network.PissingPacket;
|
||||||
import me.theclashfruit.pissnshit.network.ShitSyncPacket;
|
import me.theclashfruit.pissnshit.network.ShitSyncPacket;
|
||||||
import me.theclashfruit.pissnshit.registry.Fluids;
|
import me.theclashfruit.pissnshit.registry.Fluids;
|
||||||
import me.theclashfruit.pissnshit.util.PissManager;
|
import me.theclashfruit.pissnshit.util.PissManager;
|
||||||
import me.theclashfruit.pissnshit.util.PlayerEntityUtil;
|
import me.theclashfruit.pissnshit.util.PlayerEntityUtil;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||||
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry;
|
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.render.fluid.v1.SimpleFluidRenderHandler;
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
|
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.client.option.KeyBinding;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
import net.minecraft.client.util.InputUtil;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public class PissAndShitClient implements ClientModInitializer {
|
public class PissAndShitClient implements ClientModInitializer {
|
||||||
|
private static KeyBinding keyBinding;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
FluidRenderHandlerRegistry.INSTANCE.register(Fluids.STILL_PISS, Fluids.FLOWING_PISS, new SimpleFluidRenderHandler(
|
FluidRenderHandlerRegistry.INSTANCE.register(Fluids.STILL_PISS, Fluids.FLOWING_PISS, new SimpleFluidRenderHandler(
|
||||||
|
@ -39,5 +49,18 @@ public class PissAndShitClient implements ClientModInitializer {
|
||||||
// Register Packets
|
// Register Packets
|
||||||
PissSyncPacket.register();
|
PissSyncPacket.register();
|
||||||
ShitSyncPacket.register();
|
ShitSyncPacket.register();
|
||||||
|
|
||||||
|
keyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||||
|
"key.pissnshit.piss",
|
||||||
|
InputUtil.Type.KEYSYM,
|
||||||
|
GLFW.GLFW_KEY_Y,
|
||||||
|
"category.pissnshit.main"
|
||||||
|
));
|
||||||
|
|
||||||
|
ClientTickEvents.END_CLIENT_TICK.register(c -> {
|
||||||
|
while (keyBinding.wasPressed()) {
|
||||||
|
PissingPacket.sentToServer(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,9 @@ public class PissAndShitHudOverlay implements Drawable {
|
||||||
int fullPissIcons = pissLevel / 10;
|
int fullPissIcons = pissLevel / 10;
|
||||||
int remainingPissLevel = pissLevel - (fullPissIcons * 10);
|
int remainingPissLevel = pissLevel - (fullPissIcons * 10);
|
||||||
|
|
||||||
int shitLevel = ((PlayerEntityUtil) this.client.player).getShitManager().getShitLevel();
|
double shitLevel = ((PlayerEntityUtil) this.client.player).getShitManager().getShitLevel();
|
||||||
int fullShitIcons = shitLevel / 10;
|
int fullShitIcons = (int) (shitLevel / 10);
|
||||||
int remainingShitLevel = shitLevel - (fullShitIcons * 10);
|
int remainingShitLevel = (int) (shitLevel - (fullShitIcons * 10));
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
int iconX = x - (9 - i) * 8 - 9;
|
int iconX = x - (9 - i) * 8 - 9;
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package me.theclashfruit.pissnshit.effects;
|
||||||
|
|
||||||
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||||
|
|
||||||
|
public class DiarrheaStatusEffect extends StatusEffect {
|
||||||
|
public DiarrheaStatusEffect() {
|
||||||
|
super(StatusEffectCategory.HARMFUL, 0x361A0E);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canApplyUpdateEffect(int duration, int amplifier) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import me.theclashfruit.pissnshit.PissAndShit;
|
||||||
import me.theclashfruit.pissnshit.registry.Blocks;
|
import me.theclashfruit.pissnshit.registry.Blocks;
|
||||||
import me.theclashfruit.pissnshit.registry.Items;
|
import me.theclashfruit.pissnshit.registry.Items;
|
||||||
import me.theclashfruit.pissnshit.registry.Fluids;
|
import me.theclashfruit.pissnshit.registry.Fluids;
|
||||||
|
import me.theclashfruit.pissnshit.registry.Tags;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
|
@ -64,7 +65,7 @@ public class PissFluid extends FlowableFluid {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canBeReplacedWith(FluidState state, BlockView world, BlockPos pos, Fluid fluid, Direction direction) {
|
protected boolean canBeReplacedWith(FluidState state, BlockView world, BlockPos pos, Fluid fluid, Direction direction) {
|
||||||
return direction == Direction.DOWN && !fluid.isIn(FluidTags.WATER);
|
return direction == Direction.DOWN && !fluid.isIn(Tags.PISS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,12 +4,15 @@ import me.theclashfruit.pissnshit.util.PissManager;
|
||||||
import me.theclashfruit.pissnshit.util.PlayerEntityUtil;
|
import me.theclashfruit.pissnshit.util.PlayerEntityUtil;
|
||||||
import me.theclashfruit.pissnshit.util.ShitManager;
|
import me.theclashfruit.pissnshit.util.ShitManager;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(PlayerEntity.class)
|
@Mixin(PlayerEntity.class)
|
||||||
public class PlayerEntityMixin implements PlayerEntityUtil {
|
public class PlayerEntityMixin implements PlayerEntityUtil {
|
||||||
|
@ -29,8 +32,13 @@ public class PlayerEntityMixin implements PlayerEntityUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lnet/minecraft/entity/player/PlayerEntity;eatFood(Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;
|
@Inject(
|
||||||
|
at = @At("HEAD"),
|
||||||
|
method = "eatFood(Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;"
|
||||||
|
)
|
||||||
|
public void eatFood(World world, ItemStack stack, CallbackInfoReturnable<ItemStack> cir) {
|
||||||
|
shitManager.eat(stack, ((PlayerEntity) (Object) this));
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(
|
@Inject(
|
||||||
at = @At("TAIL"),
|
at = @At("TAIL"),
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class PissSyncPacket {
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
ClientPlayNetworking.registerGlobalReceiver(PissSyncPacket.ID, (c, handler, buf, responseSender) -> {
|
ClientPlayNetworking.registerGlobalReceiver(PissSyncPacket.ID, (c, handler, buf, responseSender) -> {
|
||||||
PissSyncPacket.SyncPacket packet = PissSyncPacket.SyncPacket.decode(buf);
|
Packet packet = Packet.decode(buf);
|
||||||
|
|
||||||
c.execute(() -> {
|
c.execute(() -> {
|
||||||
if (c.player != null) {
|
if (c.player != null) {
|
||||||
|
@ -31,17 +31,17 @@ public class PissSyncPacket {
|
||||||
public static void sendToClient(ServerPlayerEntity player, int pissLevel) {
|
public static void sendToClient(ServerPlayerEntity player, int pissLevel) {
|
||||||
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
|
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
|
||||||
|
|
||||||
new SyncPacket(pissLevel)
|
new Packet(pissLevel)
|
||||||
.encode(buf);
|
.encode(buf);
|
||||||
|
|
||||||
ServerPlayNetworking.send(player, ID, buf);
|
ServerPlayNetworking.send(player, ID, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record SyncPacket(int pissLevel) {
|
public record Packet(int pissLevel) {
|
||||||
public static SyncPacket decode(PacketByteBuf buf) {
|
public static Packet decode(PacketByteBuf buf) {
|
||||||
int pissLevel = buf.readInt();
|
int pissLevel = buf.readInt();
|
||||||
|
|
||||||
return new SyncPacket(pissLevel);
|
return new Packet(pissLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void encode(PacketByteBuf buf) {
|
public void encode(PacketByteBuf buf) {
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package me.theclashfruit.pissnshit.network;
|
||||||
|
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import me.theclashfruit.pissnshit.util.PlayerEntityUtil;
|
||||||
|
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||||
|
import net.minecraft.network.PacketByteBuf;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import static me.theclashfruit.pissnshit.PissAndShit.MOD_ID;
|
||||||
|
|
||||||
|
public class PissingPacket {
|
||||||
|
public static final Identifier ID = new Identifier(MOD_ID, "pissing");
|
||||||
|
|
||||||
|
public static void register() {
|
||||||
|
ServerPlayNetworking.registerGlobalReceiver(ID, (server, player, handler, buffer, responseSender) -> {
|
||||||
|
Packet packet = Packet.decode(buffer);
|
||||||
|
|
||||||
|
server.execute(() -> {
|
||||||
|
((PlayerEntityUtil) player).getPissManager().piss(packet.amount(), player);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sentToServer(int amount) {
|
||||||
|
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
|
||||||
|
|
||||||
|
new Packet(1)
|
||||||
|
.encode(buf);
|
||||||
|
|
||||||
|
ClientPlayNetworking.send(ID, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record Packet(int amount) {
|
||||||
|
public static Packet decode(PacketByteBuf buf) {
|
||||||
|
int amount = buf.readInt();
|
||||||
|
|
||||||
|
return new Packet(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void encode(PacketByteBuf buf) {
|
||||||
|
buf.writeInt(amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package me.theclashfruit.pissnshit.network;
|
package me.theclashfruit.pissnshit.network;
|
||||||
|
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import me.theclashfruit.pissnshit.util.PissManager;
|
|
||||||
import me.theclashfruit.pissnshit.util.PlayerEntityUtil;
|
import me.theclashfruit.pissnshit.util.PlayerEntityUtil;
|
||||||
import me.theclashfruit.pissnshit.util.ShitManager;
|
import me.theclashfruit.pissnshit.util.ShitManager;
|
||||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||||
|
@ -17,7 +16,7 @@ public class ShitSyncPacket {
|
||||||
|
|
||||||
public static void register() {
|
public static void register() {
|
||||||
ClientPlayNetworking.registerGlobalReceiver(ShitSyncPacket.ID, (c, handler, buf, responseSender) -> {
|
ClientPlayNetworking.registerGlobalReceiver(ShitSyncPacket.ID, (c, handler, buf, responseSender) -> {
|
||||||
ShitSyncPacket.SyncPacket packet = ShitSyncPacket.SyncPacket.decode(buf);
|
Packet packet = Packet.decode(buf);
|
||||||
|
|
||||||
c.execute(() -> {
|
c.execute(() -> {
|
||||||
if (c.player != null) {
|
if (c.player != null) {
|
||||||
|
@ -29,24 +28,24 @@ public class ShitSyncPacket {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendToClient(ServerPlayerEntity player, int shitLevel) {
|
public static void sendToClient(ServerPlayerEntity player, double shitLevel) {
|
||||||
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
|
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
|
||||||
|
|
||||||
new SyncPacket(shitLevel)
|
new Packet(shitLevel)
|
||||||
.encode(buf);
|
.encode(buf);
|
||||||
|
|
||||||
ServerPlayNetworking.send(player, ID, buf);
|
ServerPlayNetworking.send(player, ID, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record SyncPacket(int shitLevel) {
|
public record Packet(double shitLevel) {
|
||||||
public static SyncPacket decode(PacketByteBuf buf) {
|
public static Packet decode(PacketByteBuf buf) {
|
||||||
int shitLevel = buf.readInt();
|
double shitLevel = buf.readDouble();
|
||||||
|
|
||||||
return new SyncPacket(shitLevel);
|
return new Packet(shitLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void encode(PacketByteBuf buf) {
|
public void encode(PacketByteBuf buf) {
|
||||||
buf.writeInt(shitLevel);
|
buf.writeDouble(shitLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package me.theclashfruit.pissnshit.registry;
|
||||||
|
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
import net.minecraft.potion.Potion;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import static me.theclashfruit.pissnshit.PissAndShit.MOD_ID;
|
||||||
|
|
||||||
|
public class Potions {
|
||||||
|
public static final Potion DIARRHEA_POTION = Registry.register(
|
||||||
|
Registries.POTION,
|
||||||
|
new Identifier(MOD_ID, "diarrhea_potion"),
|
||||||
|
new Potion(
|
||||||
|
new StatusEffectInstance(
|
||||||
|
StatusEffects.DIARRHEA,
|
||||||
|
3600,
|
||||||
|
0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package me.theclashfruit.pissnshit.registry;
|
||||||
|
|
||||||
|
import me.theclashfruit.pissnshit.effects.DiarrheaStatusEffect;
|
||||||
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.registry.Registry;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import static me.theclashfruit.pissnshit.PissAndShit.MOD_ID;
|
||||||
|
|
||||||
|
public class StatusEffects {
|
||||||
|
public static final StatusEffect DIARRHEA = new DiarrheaStatusEffect();
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
Registry.register(Registries.STATUS_EFFECT, new Identifier(MOD_ID, "diarrhea"), DIARRHEA);
|
||||||
|
}
|
||||||
|
}
|
15
src/main/java/me/theclashfruit/pissnshit/registry/Tags.java
Normal file
15
src/main/java/me/theclashfruit/pissnshit/registry/Tags.java
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package me.theclashfruit.pissnshit.registry;
|
||||||
|
|
||||||
|
import net.minecraft.fluid.Fluid;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
import net.minecraft.registry.tag.TagKey;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
|
import static me.theclashfruit.pissnshit.PissAndShit.MOD_ID;
|
||||||
|
|
||||||
|
public class Tags {
|
||||||
|
public static final TagKey<Item> GIVES_DIARRHEA = TagKey.of(RegistryKeys.ITEM, new Identifier(MOD_ID, "gives_diarrhea"));
|
||||||
|
|
||||||
|
public static final TagKey<Fluid> PISS = TagKey.of(RegistryKeys.FLUID, new Identifier(MOD_ID, "piss"));
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.NbtElement;
|
import net.minecraft.nbt.NbtElement;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
import static me.theclashfruit.pissnshit.PissAndShit.CONFIG;
|
import static me.theclashfruit.pissnshit.PissAndShit.CONFIG;
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ public class PissManager {
|
||||||
private int pissTickTimer;
|
private int pissTickTimer;
|
||||||
|
|
||||||
private long lastPissTick;
|
private long lastPissTick;
|
||||||
|
private long lastPissTime;
|
||||||
|
|
||||||
private final long maxInterval;
|
private final long maxInterval;
|
||||||
private final long minInterval;
|
private final long minInterval;
|
||||||
|
@ -55,12 +57,34 @@ public class PissManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void piss(int amount, PlayerEntity player) {
|
||||||
|
long currentWorldTicks = player.getWorld().getTime();
|
||||||
|
|
||||||
|
if ((currentWorldTicks - this.minInterval >= this.lastPissTime || currentWorldTicks - this.lastPissTime <= 10) && currentWorldTicks - this.lastPissTime >= 5) {
|
||||||
|
if (pissLevel >= 1) {
|
||||||
|
this.pissLevel -= amount;
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Text.literal("You can't piss yet!"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync Piss Level
|
||||||
|
PissSyncPacket.sendToClient((ServerPlayerEntity) player, this.pissLevel);
|
||||||
|
|
||||||
|
this.lastPissTime = currentWorldTicks;
|
||||||
|
} else if (currentWorldTicks - this.lastPissTime <= 5) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Text.literal("You can't piss yet!"), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void readNbt(NbtCompound nbt) {
|
public void readNbt(NbtCompound nbt) {
|
||||||
if (nbt.contains("pissLevel", NbtElement.NUMBER_TYPE)) {
|
if (nbt.contains("pissLevel", NbtElement.NUMBER_TYPE)) {
|
||||||
this.pissLevel = nbt.getInt("pissLevel");
|
this.pissLevel = nbt.getInt("pissLevel");
|
||||||
this.pissTickTimer = nbt.getInt("pissTickTimer");
|
this.pissTickTimer = nbt.getInt("pissTickTimer");
|
||||||
|
|
||||||
this.lastPissTick = nbt.getLong("lastPissTick");
|
this.lastPissTick = nbt.getLong("lastPissTick");
|
||||||
|
this.lastPissTime = nbt.getLong("lastPissTime");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +93,7 @@ public class PissManager {
|
||||||
nbt.putInt("pissTickTimer", this.pissTickTimer);
|
nbt.putInt("pissTickTimer", this.pissTickTimer);
|
||||||
|
|
||||||
nbt.putLong("lastPissTick", this.lastPissTick);
|
nbt.putLong("lastPissTick", this.lastPissTick);
|
||||||
|
nbt.putLong("lastPissTime", this.lastPissTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPissLevel() {
|
public int getPissLevel() {
|
||||||
|
|
|
@ -2,15 +2,23 @@ package me.theclashfruit.pissnshit.util;
|
||||||
|
|
||||||
import me.theclashfruit.pissnshit.network.ShitSyncPacket;
|
import me.theclashfruit.pissnshit.network.ShitSyncPacket;
|
||||||
import me.theclashfruit.pissnshit.registry.DamageTypes;
|
import me.theclashfruit.pissnshit.registry.DamageTypes;
|
||||||
|
import me.theclashfruit.pissnshit.registry.StatusEffects;
|
||||||
|
import me.theclashfruit.pissnshit.registry.Tags;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.item.FoodComponent;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
import net.minecraft.nbt.NbtElement;
|
import net.minecraft.nbt.NbtElement;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
import static me.theclashfruit.pissnshit.PissAndShit.CONFIG;
|
import static me.theclashfruit.pissnshit.PissAndShit.CONFIG;
|
||||||
|
import static me.theclashfruit.pissnshit.PissAndShit.LOGGER;
|
||||||
|
|
||||||
public class ShitManager {
|
public class ShitManager {
|
||||||
private int shitLevel = 6;
|
private double shitLevel = 6;
|
||||||
|
private double foodBuffer = 0;
|
||||||
|
|
||||||
private int shitTickTimer;
|
private int shitTickTimer;
|
||||||
|
|
||||||
|
@ -26,8 +34,15 @@ public class ShitManager {
|
||||||
|
|
||||||
public void update(PlayerEntity player) {
|
public void update(PlayerEntity player) {
|
||||||
long currentWorldTicks = player.getWorld().getTime();
|
long currentWorldTicks = player.getWorld().getTime();
|
||||||
|
boolean hasDiarrhea = player.hasStatusEffect(StatusEffects.DIARRHEA);
|
||||||
|
|
||||||
if (currentWorldTicks - this.lastShitTick >= this.minInterval * 0.1) {
|
if (currentWorldTicks - this.lastShitTick >= this.minInterval * 0.1) {
|
||||||
|
if (foodBuffer > 0) {
|
||||||
|
double food = hasDiarrhea ? foodBuffer * 0.5 : foodBuffer * 0.1;
|
||||||
|
|
||||||
|
shitLevel += food;
|
||||||
|
foodBuffer -= food;
|
||||||
|
}
|
||||||
|
|
||||||
// Sync Shit Level
|
// Sync Shit Level
|
||||||
ShitSyncPacket.sendToClient((ServerPlayerEntity) player, this.shitLevel);
|
ShitSyncPacket.sendToClient((ServerPlayerEntity) player, this.shitLevel);
|
||||||
|
@ -48,27 +63,45 @@ public class ShitManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void eat(ItemStack stack, PlayerEntity player) {
|
||||||
|
Item item = stack.getItem();
|
||||||
|
FoodComponent foodComponent = item.getFoodComponent();
|
||||||
|
|
||||||
|
if (foodComponent != null)
|
||||||
|
foodBuffer += foodComponent.getHunger();
|
||||||
|
|
||||||
|
if (stack.isIn(Tags.GIVES_DIARRHEA)) {
|
||||||
|
player.addStatusEffect(
|
||||||
|
new StatusEffectInstance(StatusEffects.DIARRHEA, 1800)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void readNbt(NbtCompound nbt) {
|
public void readNbt(NbtCompound nbt) {
|
||||||
if (nbt.contains("pissLevel", NbtElement.NUMBER_TYPE)) {
|
if (nbt.contains("shitLevel", NbtElement.NUMBER_TYPE)) {
|
||||||
this.shitLevel = nbt.getInt("shitLevel");
|
|
||||||
this.shitTickTimer = nbt.getInt("shitTickTimer");
|
this.shitTickTimer = nbt.getInt("shitTickTimer");
|
||||||
|
|
||||||
this.lastShitTick = nbt.getLong("lastShitTick");
|
this.lastShitTick = nbt.getLong("lastShitTick");
|
||||||
|
|
||||||
|
this.shitLevel = nbt.getDouble("shitLevel");
|
||||||
|
this.foodBuffer = nbt.getDouble("shitBuffer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeNbt(NbtCompound nbt) {
|
public void writeNbt(NbtCompound nbt) {
|
||||||
nbt.putInt("shitLevel", this.shitLevel);
|
|
||||||
nbt.putInt("shitTickTimer", this.shitTickTimer);
|
nbt.putInt("shitTickTimer", this.shitTickTimer);
|
||||||
|
|
||||||
nbt.putLong("lastShitTick", this.lastShitTick);
|
nbt.putLong("lastShitTick", this.lastShitTick);
|
||||||
|
|
||||||
|
nbt.putDouble("shitLevel", this.shitLevel);
|
||||||
|
nbt.putDouble("shitBuffer", this.foodBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getShitLevel() {
|
public double getShitLevel() {
|
||||||
return this.shitLevel;
|
return this.shitLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShitLevel(int shitLevel) {
|
public void setShitLevel(double shitLevel) {
|
||||||
this.shitLevel = shitLevel;
|
this.shitLevel = shitLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,14 @@
|
||||||
|
|
||||||
"block.pissnshit.mechanical_sanctifier": "Mechanical Sanctifier",
|
"block.pissnshit.mechanical_sanctifier": "Mechanical Sanctifier",
|
||||||
|
|
||||||
|
"effect.pissnshit.diarrhea": "Diarrhea",
|
||||||
|
|
||||||
|
"item.minecraft.potion.effect.diarrhea_potion": "Potion of Diarrhea",
|
||||||
|
"item.minecraft.splash_potion.effect.diarrhea_potion": "Splash Potion of Diarrhea",
|
||||||
|
"item.minecraft.lingering_potion.effect.diarrhea_potion": "Lingering Potion of Diarrhea",
|
||||||
|
|
||||||
|
"item.minecraft.tipped_arrow.effect.diarrhea_potion": "Arrow of Diarrhea",
|
||||||
|
|
||||||
"death.attack.fullOfPiss": "%1$s got full of piss.",
|
"death.attack.fullOfPiss": "%1$s got full of piss.",
|
||||||
"death.attack.fullOfShit": "%1$s got full of shit.",
|
"death.attack.fullOfShit": "%1$s got full of shit.",
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
"replace": false,
|
|
||||||
"values": [
|
"values": [
|
||||||
"pissnshit:piss",
|
"pissnshit:piss",
|
||||||
"pissnshit:flowing_piss"
|
"pissnshit:flowing_piss"
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"values": [
|
||||||
|
"minecraft:cookie"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"values": [
|
||||||
|
"minecraft:milk_bucket",
|
||||||
|
"minecraft:cake",
|
||||||
|
"minecraft:poisonous_potato",
|
||||||
|
"minecraft:rotten_flesh",
|
||||||
|
"minecraft:spider_eye",
|
||||||
|
"minecraft:beef",
|
||||||
|
"minecraft:porkchop",
|
||||||
|
"minecraft:mutton",
|
||||||
|
"minecraft:chicken",
|
||||||
|
"minecraft:rabbit"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue