Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,8 @@ public ComputedVariable createComputedVariable(String variable, boolean createDe
return new ComputedVariable(this, variable, partialTicks -> Math.random() < 0.5 ? 0 : 1, true);
case ("rain_strength"):
return new ComputedVariable(this, variable, partialTicks -> (int) world.getRainStrength(position), false);
case ("snowfall_strength"): //snowfallstrengh
return new ComputedVariable(this, variable, partialTicks -> (int) world.getSnowfallStrength(position), false);
case ("rain_sin"): {
return new ComputedVariable(this, variable, partialTicks -> {
int rainStrength = (int) world.getRainStrength(position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,29 @@ public abstract class AWrapperWorld extends EntityManager {
*/
public abstract int getRedstonePower(Point3D position);

/**
* Returns the rain strength at the passed-in position.
* 0 is no rain, 1 is rain, and 2 is a thunderstorm.
* Note that this method offsets the point by 1, as it allows
* for blocks to query rain strength and not get 0 due to no rain
* being possible "in" that block.
*/
public abstract float getRainStrength(Point3D position);

/**
* Returns the current temperature at the passed-in position.
* Dependent on biome, and likely modified by mods that add new boimes.
*/
public abstract float getTemperature(Point3D position);
/**
* Returns the rain strength at the passed-in position.
* 0 is no rain, 1 is rain, and 2 is a thunderstorm.
* Note that this method offsets the point by 1, as it allows
* for blocks to query rain strength and not get 0 due to no rain
* being possible "in" that block.
*/
public abstract float getRainStrength(Point3D position);

/**
* Returns the snowfall strength at the passed-in position.
* 0 is no snowfall, 1 is snowfall.
* Note that this method offsets the point by 1, as it allows
* for blocks to query snowfall strength and not get 0 due to no snow
* being possible "in" that block.
*/
public abstract float getSnowfallStrength(Point3D position); //snowfallstrengh

/**
* Returns the current temperature at the passed-in position.
* Dependent on biome, and likely modified by mods that add new boimes.
*/
public abstract float getTemperature(Point3D position);

/**
* Places the passed-in block at the point specified.
Expand Down Expand Up @@ -414,4 +423,4 @@ public abstract class AWrapperWorld extends EntityManager {
* Spawns an explosion of the specified strength at the passed-in point.
*/
public abstract void spawnExplosion(Point3D location, double strength, boolean flames, boolean damageBlocks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -670,16 +670,28 @@ public int getRedstonePower(Point3D position) {
return world.getRedstonePowerFromNeighbors(new BlockPos(position.x, position.y, position.z));
}

@Override
public float getRainStrength(Point3D position) {
return world.isRainingAt(new BlockPos(position.x, position.y + 1, position.z)) ? world.getRainStrength(1.0F) + world.getThunderStrength(1.0F) : 0.0F;
}

@Override
public float getTemperature(Point3D position) {
BlockPos pos = new BlockPos(position.x, position.y, position.z);
return world.getBiome(pos).getTemperature(pos);
}
@Override
public float getRainStrength(Point3D position) {
return world.isRainingAt(new BlockPos(position.x, position.y + 1, position.z)) ? world.getRainStrength(1.0F) + world.getThunderStrength(1.0F) : 0.0F;
}

@Override
public float getSnowfallStrength(Point3D position) { //snowfallstrengh
BlockPos pos = new BlockPos(position.x, position.y + 1, position.z);
if (world.getRainStrength(1.0F) <= 0.0F) {
return 0.0F;
}
if (!world.canSeeSky(pos)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this check is needed? If the block can't see the sky, then it can't rain at the position, so the check above will be false. Also, I'd use world.IsRainingAt and that's a boolean. So if not raining at, retun 0. Same thoughts for all instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check sky variable is there because iirc the variable wasn't registering no snow despite the vehicle being under a block. It was a while ago so take my statement with a grain of salt. Ill remove the check, its only the if(canseesky) part, yes?

return 0.0F;
}
return world.getBiome(pos).getTemperature(pos) < 0.15F ? 1.0F : 0.0F;
}

@Override
public float getTemperature(Point3D position) {
BlockPos pos = new BlockPos(position.x, position.y, position.z);
return world.getBiome(pos).getTemperature(pos);
}

@Override
@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -1085,4 +1097,4 @@ public void onIVWorldUnload(WorldEvent.Unload event) {
worldWrappers.remove(world);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -699,16 +699,28 @@ public int getRedstonePower(Point3D position) {
return world.getBestNeighborSignal(new BlockPos(position.x, position.y, position.z));
}

@Override
public float getRainStrength(Point3D position) {
return world.isRainingAt(new BlockPos(position.x, position.y + 1, position.z)) ? world.getRainLevel(1.0F) + world.getThunderLevel(1.0F) : 0.0F;
}

@Override
public float getTemperature(Point3D position) {
BlockPos pos = new BlockPos(position.x, position.y, position.z);
return world.getBiome(pos).getTemperature(pos);
}
@Override
public float getRainStrength(Point3D position) {
return world.isRainingAt(new BlockPos(position.x, position.y + 1, position.z)) ? world.getRainLevel(1.0F) + world.getThunderLevel(1.0F) : 0.0F;
}

@Override
public float getSnowfallStrength(Point3D position) { //snowfallstrengh
BlockPos pos = new BlockPos(position.x, position.y + 1, position.z);
if (world.getRainLevel(1.0F) <= 0.0F) {
return 0.0F;
}
if (!world.canSeeSky(pos)) {
return 0.0F;
}
return world.getBiome(pos).getTemperature(pos) < 0.15F ? 1.0F : 0.0F;
}

@Override
public float getTemperature(Point3D position) {
BlockPos pos = new BlockPos(position.x, position.y, position.z);
return world.getBiome(pos).getTemperature(pos);
}

@Override
public <TileEntityType extends ATileEntityBase<JSONDefinition>, JSONDefinition extends AJSONMultiModelProvider> boolean setBlock(ABlockBase block, Point3D position, IWrapperPlayer playerWrapper, Axis axis) {
Expand Down Expand Up @@ -1135,4 +1147,4 @@ public void onIVWorldUnload(WorldEvent.Unload event) {
worldWrappers.remove(world);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -682,16 +682,28 @@ public int getRedstonePower(Point3D position) {
return world.getBestNeighborSignal(new BlockPos(position.x, position.y, position.z));
}

@Override
public float getRainStrength(Point3D position) {
return world.isRainingAt(new BlockPos(position.x, position.y + 1, position.z)) ? world.getRainLevel(1.0F) + world.getThunderLevel(1.0F) : 0.0F;
}

@Override
public float getTemperature(Point3D position) {
BlockPos pos = new BlockPos(position.x, position.y, position.z);
return ((BiomeMixin) ((Object) world.getBiome(pos).value())).invoke_getTemperature(pos);
}
@Override
public float getRainStrength(Point3D position) {
return world.isRainingAt(new BlockPos(position.x, position.y + 1, position.z)) ? world.getRainLevel(1.0F) + world.getThunderLevel(1.0F) : 0.0F;
}

@Override
public float getSnowfallStrength(Point3D position) { //snowfallstrengh
BlockPos pos = new BlockPos(position.x, position.y + 1, position.z);
if (world.getRainLevel(1.0F) <= 0.0F) {
return 0.0F;
}
if (!world.canSeeSky(pos)) {
return 0.0F;
}
return ((BiomeMixin) ((Object) world.getBiome(pos).value())).invoke_getTemperature(pos) < 0.15F ? 1.0F : 0.0F;
}

@Override
public float getTemperature(Point3D position) {
BlockPos pos = new BlockPos(position.x, position.y, position.z);
return ((BiomeMixin) ((Object) world.getBiome(pos).value())).invoke_getTemperature(pos);
}

@Override
public <TileEntityType extends ATileEntityBase<JSONDefinition>, JSONDefinition extends AJSONMultiModelProvider> boolean setBlock(ABlockBase block, Point3D position, IWrapperPlayer playerWrapper, Axis axis) {
Expand Down Expand Up @@ -1116,4 +1128,4 @@ public void onIVWorldUnload(WorldEvent.Unload event) {
worldWrappers.remove(world);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,14 @@ public float getRainStrength(Point3D position) {
return world.isRainingAt(new BlockPos(position.x, position.y + 1, position.z)) ? world.getRainLevel(1.0F) + world.getThunderLevel(1.0F) : 0.0F;
}

@Override
public float getSnowfallStrength(Point3D position) { //snowfallstrengh
BlockPos pos = new BlockPos(position.x, position.y + 1, position.z);
if (world.getRainLevel(1.0F) <= 0.0F) {return 0.0F;}
if (!world.canSeeSky(pos)) {return 0.0F;}
return ((BiomeMixin) ((Object) world.getBiome(pos).value())).invoke_getTemperature(pos) < 0.15F ? 1.0F : 0.0F;
}

@Override
public float getTemperature(Point3D position) {
BlockPos pos = new BlockPos(position.x, position.y, position.z);
Expand Down Expand Up @@ -1117,4 +1125,5 @@ public void onIVWorldUnload(LevelEvent.Unload event) {
worldWrappers.remove(world);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,14 @@ public float getRainStrength(Point3D position) {
return world.isRainingAt(BlockPos.containing(position.x, position.y + 1, position.z)) ? world.getRainLevel(1.0F) + world.getThunderLevel(1.0F) : 0.0F;
}

@Override
public float getSnowfallStrength(Point3D position) { //snowfallstrengh
BlockPos pos = BlockPos.containing(position.x, position.y + 1, position.z);
if (world.getRainLevel(1.0F) <= 0.0F) {return 0.0F;}
if (!world.canSeeSky(pos)) {return 0.0F;}
return ((BiomeMixin) ((Object) world.getBiome(pos).value())).invoke_getTemperature(pos) < 0.15F ? 1.0F : 0.0F;
}

@Override
public float getTemperature(Point3D position) {
BlockPos pos = BlockPos.containing(position.x, position.y, position.z);
Expand Down Expand Up @@ -1140,4 +1148,5 @@ public void onIVWorldUnload(LevelEvent.Unload event) {
worldWrappers.remove(world);
}
}
}

}