1
0
Fork 0
mirror of https://github.com/TheClashFruit/CreatePissAndShit.git synced 2024-09-19 17:36:47 +00:00

feat: toilets now suck piss & shit out of players

This commit is contained in:
TheClashFruit 2024-08-27 22:45:59 +02:00
parent 5b6de456b8
commit e79a41fe2c
Signed by: TheClashFruit
GPG key ID: 09BB24C34C2F3204
4 changed files with 61 additions and 1 deletions

View file

@ -14,10 +14,12 @@ import io.github.fabricators_of_create.porting_lib.fluids.FluidStack;
import io.github.fabricators_of_create.porting_lib.util.FluidTextUtil;
import io.github.fabricators_of_create.porting_lib.util.FluidUnit;
import me.theclashfruit.pissnshit.registry.Blocks;
import me.theclashfruit.pissnshit.registry.Fluids;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SidedStorageBlockEntity;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.text.Text;
@ -31,6 +33,8 @@ import javax.annotation.Nullable;
import java.awt.*;
import java.util.List;
import static com.simibubi.create.content.kinetics.BlockStressValues.getCapacity;
public class MechanicalToiletBlockEntity extends SmartBlockEntity implements IHaveGoggleInformation, SidedStorageBlockEntity {
private SmartFluidTankBehaviour tank;
@ -40,7 +44,7 @@ public class MechanicalToiletBlockEntity extends SmartBlockEntity implements IHa
@Override
public void addBehaviours(List<BlockEntityBehaviour> behaviours) {
tank = new SmartFluidTankBehaviour(SmartFluidTankBehaviour.OUTPUT, this, 2, FluidConstants.BUCKET, true)
tank = new SmartFluidTankBehaviour(SmartFluidTankBehaviour.OUTPUT, this, 1, FluidConstants.BUCKET, true)
.forbidInsertion();
behaviours.add(tank);
@ -93,4 +97,10 @@ public class MechanicalToiletBlockEntity extends SmartBlockEntity implements IHa
return true;
}
public void addPiss(int amount) {
for (SmartFluidTankBehaviour.TankSegment tank : tank.getTanks()) {
tank.getTank().setFluid(new FluidStack(FluidVariant.of(Fluids.STILL_PISS), tank.getTank().getFluid().getAmount() + amount));
}
}
}

View file

@ -1,6 +1,9 @@
package me.theclashfruit.pissnshit.blocks.toilet;
import me.theclashfruit.pissnshit.mixin.PlayerEntityMixin;
import me.theclashfruit.pissnshit.registry.Entities;
import me.theclashfruit.pissnshit.util.PlayerEntityUtil;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
@ -10,6 +13,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class MechanicalToiletSeatEntity extends Entity {
public BlockPos toiletPos;
public MechanicalToiletSeatEntity(EntityType<? extends MechanicalToiletSeatEntity> type, World world) {
super(type, world);
@ -29,10 +34,23 @@ public class MechanicalToiletSeatEntity extends Entity {
public void tick() {
super.tick();
Block block = getWorld().getBlockState(getBlockPos()).getBlock();
if (!(block instanceof MechanicalToiletBlock)) {
discard();
return;
}
if (!getWorld().isClient) {
if (getFirstPassenger() == null || !(getFirstPassenger() instanceof PlayerEntity) || !(getWorld().getBlockState(getBlockPos()).getBlock() instanceof MechanicalToiletBlock)) {
discard();
}
if (getFirstPassenger() instanceof PlayerEntity player) {
((PlayerEntityUtil) player).getPissManager().pissOnToilet(player, ((MechanicalToiletBlock) block), toiletPos);
((PlayerEntityUtil) player).getShitManager().shitOnToilet(player, ((MechanicalToiletBlock) block), toiletPos);
}
}
}
@ -40,6 +58,7 @@ public class MechanicalToiletSeatEntity extends Entity {
MechanicalToiletSeatEntity seatEntity = new MechanicalToiletSeatEntity(Entities.MECHANICAL_TOILET_SEAT_ENTITY, world);
seatEntity.updatePosition(pos.getX() + 0.45, pos.getY() + 0.45, pos.getZ() + 0.45);
seatEntity.toiletPos = pos;
return seatEntity;
}

View file

@ -1,5 +1,7 @@
package me.theclashfruit.pissnshit.util;
import me.theclashfruit.pissnshit.blocks.toilet.MechanicalToiletBlock;
import me.theclashfruit.pissnshit.blocks.toilet.MechanicalToiletBlockEntity;
import me.theclashfruit.pissnshit.network.PissSyncPacket;
import me.theclashfruit.pissnshit.registry.DamageTypes;
import net.minecraft.entity.player.PlayerEntity;
@ -7,6 +9,9 @@ import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Position;
import net.minecraft.world.World;
import static me.theclashfruit.pissnshit.PissAndShit.CONFIG;
@ -78,6 +83,21 @@ public class PissManager {
}
}
public void pissOnToilet(PlayerEntity player, MechanicalToiletBlock toiletBlock, BlockPos toiletPos) {
World world = player.getWorld();
if (pissLevel >= 1) {
this.pissLevel -= 1;
if (world.getBlockEntity(toiletPos) instanceof MechanicalToiletBlockEntity toiletEntity) {
toiletEntity.addPiss(10);
}
}
// Sync Piss Level
PissSyncPacket.sendToClient((ServerPlayerEntity) player, this.pissLevel);
}
public void readNbt(NbtCompound nbt) {
if (nbt.contains("pissLevel", NbtElement.NUMBER_TYPE)) {
this.pissLevel = nbt.getInt("pissLevel");

View file

@ -1,5 +1,6 @@
package me.theclashfruit.pissnshit.util;
import me.theclashfruit.pissnshit.blocks.toilet.MechanicalToiletBlock;
import me.theclashfruit.pissnshit.network.ShitSyncPacket;
import me.theclashfruit.pissnshit.registry.DamageTypes;
import me.theclashfruit.pissnshit.registry.StatusEffects;
@ -12,6 +13,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import static me.theclashfruit.pissnshit.PissAndShit.CONFIG;
import static me.theclashfruit.pissnshit.PissAndShit.LOGGER;
@ -77,6 +79,15 @@ public class ShitManager {
}
}
public void shitOnToilet(PlayerEntity player, MechanicalToiletBlock toiletBlock, BlockPos toiletPos) {
if (shitLevel >= 1) {
this.shitLevel -= 1;
}
// Sync Shit Level
ShitSyncPacket.sendToClient((ServerPlayerEntity) player, this.shitLevel);
}
public void readNbt(NbtCompound nbt) {
if (nbt.contains("shitLevel", NbtElement.NUMBER_TYPE)) {
this.shitTickTimer = nbt.getInt("shitTickTimer");