the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.entity.item.h"
3#include "net.minecraft.world.level.h"
4#include "net.minecraft.world.level.redstone.h"
5#include "net.minecraft.world.item.h"
6#include "Entity.h"
7#include "WeightedPressurePlateTile.h"
8
9WeightedPressurePlateTile::WeightedPressurePlateTile(int id, const wstring &tex, Material *material, int maxWeight) : BasePressurePlateTile(id, tex, material)
10{
11 this->maxWeight = maxWeight;
12
13 // 4J Stu - Move this from base class to use virtual function
14 updateShape(getDataForSignal(Redstone::SIGNAL_MAX));
15}
16
17int WeightedPressurePlateTile::getSignalStrength(Level *level, int x, int y, int z)
18{
19 int weightOfEntities = level->getEntitiesOfClass(typeid(Entity), getSensitiveAABB(x, y, z))->size();
20 int count = min(weightOfEntities, maxWeight);
21
22 if (count <= 0)
23 {
24 return 0;
25 }
26 else
27 {
28 float pct = min(maxWeight, count) / (float) maxWeight;
29 return Mth::ceil(pct * Redstone::SIGNAL_MAX);
30 }
31}
32
33int WeightedPressurePlateTile::getSignalForData(int data)
34{
35 return data;
36}
37
38int WeightedPressurePlateTile::getDataForSignal(int signal)
39{
40 return signal;
41}
42
43int WeightedPressurePlateTile::getTickDelay(Level *level)
44{
45 return SharedConstants::TICKS_PER_SECOND / 2;
46}