Skip to content

Commit

Permalink
Merge branch 'master' into miner
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/gregtech/api/util/BlockUtility.java
  • Loading branch information
Tictim committed Dec 7, 2023
2 parents 528d5d7 + e8494bd commit 94221d6
Show file tree
Hide file tree
Showing 50 changed files with 1,492 additions and 521 deletions.
12 changes: 11 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1701481996
//version: 1701739812
/*
* DO NOT CHANGE THIS FILE!
* Also, you may replace this file at any time if there is an update available.
Expand Down Expand Up @@ -222,6 +222,16 @@ if (enableSpotless.toBoolean()) {
//noinspection GroovyAssignabilityCheck
eclipse('4.19.0').configFile(formatFile)
}
kotlin {
target 'src/*/kotlin/**/*.kt'

toggleOffOn()
ktfmt('0.39')

trimTrailingWhitespace()
indentWithSpaces(4)
endWithNewline()
}
scala {
target 'src/*/scala/**/*.scala'
scalafmt('3.7.1')
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ modGroup = gregtech

# Version of your mod.
# This field can be left empty if you want your mod's version to be determined by the latest git tag instead.
modVersion = 2.8.1-beta
modVersion = 2.8.2-beta

# Whether to use the old jar naming structure (modid-mcversion-version) instead of the new version (modid-version)
includeMCVersionJar = true
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/gregtech/api/block/IWalkingSpeedBonus.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;

import org.jetbrains.annotations.ApiStatus;

/**
* @deprecated use {@link gregtech.api.util.BlockUtility#setWalkingSpeedBonus(IBlockState, double)}
*/
@SuppressWarnings("DeprecatedIsStillUsed")
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.9")
public interface IWalkingSpeedBonus {

default double getWalkingSpeedBonus() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gregtech/api/block/VariantActiveBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public int getMetaFromState(IBlockState state) {
@NotNull
@Override
protected BlockStateContainer createBlockState() {
Class<T> enumClass = getActualTypeParameter(getClass(), VariantActiveBlock.class, 0);
Class<T> enumClass = getActualTypeParameter(getClass(), VariantActiveBlock.class);
this.VARIANT = PropertyEnum.create("variant", enumClass);
this.VALUES = enumClass.getEnumConstants();
return new ExtendedBlockState(this, new IProperty[] { VARIANT, ACTIVE_DEPRECATED },
Expand Down
30 changes: 6 additions & 24 deletions src/main/java/gregtech/api/block/VariantBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand All @@ -28,11 +26,13 @@
import java.util.Collections;
import java.util.List;

@SuppressWarnings("deprecation")
public class VariantBlock<T extends Enum<T> & IStringSerializable> extends Block implements IWalkingSpeedBonus {

protected PropertyEnum<T> VARIANT;
protected T[] VALUES;

@SuppressWarnings("DataFlowIssue")
public VariantBlock(Material materialIn) {
super(materialIn);
if (VALUES.length > 0 && VALUES[0] instanceof IStateHarvestLevel) {
Expand Down Expand Up @@ -77,15 +77,15 @@ public ItemStack getItemVariant(T variant, int amount) {
@NotNull
@Override
protected BlockStateContainer createBlockState() {
Class<T> enumClass = getActualTypeParameter(getClass(), VariantBlock.class, 0);
Class<T> enumClass = getActualTypeParameter(getClass(), VariantBlock.class);
this.VARIANT = PropertyEnum.create("variant", enumClass);
this.VALUES = enumClass.getEnumConstants();
return new BlockStateContainer(this, VARIANT);
}

@Override
@SideOnly(Side.CLIENT)
public void addInformation(@NotNull ItemStack stack, @Nullable World player, List<String> tooltip,
public void addInformation(@NotNull ItemStack stack, @Nullable World player, @NotNull List<String> tooltip,
@NotNull ITooltipFlag advanced) {
// tier less tooltip like: tile.turbine_casing.tooltip
String unlocalizedVariantTooltip = getTranslationKey() + ".tooltip";
Expand Down Expand Up @@ -114,27 +114,9 @@ public int getMetaFromState(IBlockState state) {
return state.getValue(VARIANT).ordinal();
}

@Override
public void onEntityWalk(@NotNull World worldIn, @NotNull BlockPos pos, @NotNull Entity entityIn) {
// Short circuit if there is no bonus speed
if (getWalkingSpeedBonus() == 1.0D) {
return;
}

IBlockState below = entityIn.getEntityWorld()
.getBlockState(new BlockPos(entityIn.posX, entityIn.posY - (1 / 16D), entityIn.posZ));
if (checkApplicableBlocks(below)) {
if (bonusSpeedCondition(entityIn)) {
entityIn.motionX *= getWalkingSpeedBonus();
entityIn.motionZ *= getWalkingSpeedBonus();
}
}
}

// magic is here
@SuppressWarnings("unchecked")
protected static <T, R> Class<T> getActualTypeParameter(Class<? extends R> thisClass, Class<R> declaringClass,
int index) {
protected static <T, R> Class<T> getActualTypeParameter(Class<? extends R> thisClass, Class<R> declaringClass) {
Type type = thisClass.getGenericSuperclass();

while (!(type instanceof ParameterizedType) || ((ParameterizedType) type).getRawType() != declaringClass) {
Expand All @@ -144,6 +126,6 @@ protected static <T, R> Class<T> getActualTypeParameter(Class<? extends R> thisC
type = ((Class<?>) type).getGenericSuperclass();
}
}
return (Class<T>) ((ParameterizedType) type).getActualTypeArguments()[index];
return (Class<T>) ((ParameterizedType) type).getActualTypeArguments()[0];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ public int getParallelLimit() {
// parallel is limited by voltage
return Integer.MAX_VALUE;
}

@Override
public boolean isAllowOverclocking() {
return false;
}
}
7 changes: 6 additions & 1 deletion src/main/java/gregtech/api/fluids/FluidBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,12 @@ private void determineTemperature(@Nullable Material material) {
yield ROOM_TEMPERATURE;
}
case GAS -> ROOM_TEMPERATURE;
case PLASMA -> BASE_PLASMA_TEMPERATURE;
case PLASMA -> {
if (material.hasFluid()) {
yield BASE_PLASMA_TEMPERATURE + material.getFluid().getTemperature();
}
yield BASE_PLASMA_TEMPERATURE;
}
};
} else {
temperature = property.getBlastTemperature() + switch (state) {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/gregtech/api/fluids/store/FluidStorageKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ public final class FluidStorageKey {
private final int hashCode;
private final FluidState defaultFluidState;

public FluidStorageKey(@NotNull ResourceLocation resourceLocation, @NotNull MaterialIconType iconType,
@NotNull UnaryOperator<@NotNull String> registryNameOperator,
@NotNull Function<@NotNull Material, @NotNull String> translationKeyFunction) {
this(resourceLocation, iconType, registryNameOperator, translationKeyFunction, null);
}

public FluidStorageKey(@NotNull ResourceLocation resourceLocation, @NotNull MaterialIconType iconType,
@NotNull UnaryOperator<@NotNull String> registryNameOperator,
@NotNull Function<@NotNull Material, @NotNull String> translationKeyFunction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import gregtech.api.capability.impl.RecipeLogicEnergy;
import gregtech.api.gui.GuiTextures;
import gregtech.api.gui.ModularUI;
import gregtech.api.gui.widgets.CycleButtonWidget;
import gregtech.api.gui.widgets.LabelWidget;
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.recipes.RecipeMap;
Expand Down Expand Up @@ -111,11 +110,6 @@ protected ModularUI.Builder createGuiTemplate(EntityPlayer player) {
builder.widget(new LabelWidget(6, 6, getMetaFullName()))
.bindPlayerInventory(player.inventory, GuiTextures.SLOT, yOffset);

builder.widget(new CycleButtonWidget(7, 62 + yOffset, 18, 18,
workable.getAvailableOverclockingTiers(), workable::getOverclockTier, workable::setOverclockTier)
.setTooltipHoverString("gregtech.gui.overclock.description")
.setButtonTexture(GuiTextures.BUTTON_OVERCLOCK));

return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import gregtech.api.recipes.RecipeMap;
import gregtech.api.util.GTTransferUtils;
import gregtech.api.util.GTUtility;
import gregtech.client.particle.IMachineParticleEffect;
import gregtech.client.renderer.ICubeRenderer;
import gregtech.client.renderer.texture.Textures;
import gregtech.client.utils.RenderUtil;
Expand Down Expand Up @@ -77,6 +78,11 @@ public class SimpleMachineMetaTileEntity extends WorkableTieredMetaTileEntity

private static final int FONT_HEIGHT = 9; // Minecraft's FontRenderer FONT_HEIGHT value

@Nullable // particle run every tick when the machine is active
protected final IMachineParticleEffect tickingParticle;
@Nullable // particle run in randomDisplayTick() when the machine is active
protected final IMachineParticleEffect randomParticle;

public SimpleMachineMetaTileEntity(ResourceLocation metaTileEntityId, RecipeMap<?> recipeMap,
ICubeRenderer renderer, int tier, boolean hasFrontFacing) {
this(metaTileEntityId, recipeMap, renderer, tier, hasFrontFacing, GTUtility.defaultTankSizeFunction);
Expand All @@ -85,15 +91,25 @@ public SimpleMachineMetaTileEntity(ResourceLocation metaTileEntityId, RecipeMap<
public SimpleMachineMetaTileEntity(ResourceLocation metaTileEntityId, RecipeMap<?> recipeMap,
ICubeRenderer renderer, int tier, boolean hasFrontFacing,
Function<Integer, Integer> tankScalingFunction) {
this(metaTileEntityId, recipeMap, renderer, tier, hasFrontFacing, tankScalingFunction, null, null);
}

public SimpleMachineMetaTileEntity(ResourceLocation metaTileEntityId, RecipeMap<?> recipeMap,
ICubeRenderer renderer, int tier, boolean hasFrontFacing,
Function<Integer, Integer> tankScalingFunction,
@Nullable IMachineParticleEffect tickingParticle,
@Nullable IMachineParticleEffect randomParticle) {
super(metaTileEntityId, recipeMap, renderer, tier, tankScalingFunction);
this.hasFrontFacing = hasFrontFacing;
this.chargerInventory = new GTItemStackHandler(this, 1);
this.tickingParticle = tickingParticle;
this.randomParticle = randomParticle;
}

@Override
public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
return new SimpleMachineMetaTileEntity(metaTileEntityId, workable.getRecipeMap(), renderer, getTier(),
hasFrontFacing, getTankScalingFunction());
hasFrontFacing, getTankScalingFunction(), tickingParticle, randomParticle);
}

@Override
Expand Down Expand Up @@ -189,6 +205,16 @@ public void update() {
pushItemsIntoNearbyHandlers(getOutputFacingItems());
}
}
} else if (this.tickingParticle != null && isActive()) {
tickingParticle.runEffect(this);
}
}

@SideOnly(Side.CLIENT)
@Override
public void randomDisplayTick() {
if (this.randomParticle != null && isActive()) {
randomParticle.runEffect(this);
}
}

Expand Down
33 changes: 12 additions & 21 deletions src/main/java/gregtech/api/metatileentity/SteamMetaTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import gregtech.api.gui.widgets.ImageWidget;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.util.GTUtility;
import gregtech.client.particle.VanillaParticleEffects;
import gregtech.client.renderer.ICubeRenderer;
import gregtech.client.renderer.texture.Textures;
import gregtech.client.renderer.texture.cube.SimpleSidedCubeRenderer;
Expand All @@ -35,6 +36,7 @@
import codechicken.lib.vec.Matrix4;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand Down Expand Up @@ -143,32 +145,21 @@ public SoundEvent getSound() {
@Override
public void randomDisplayTick() {
if (this.isActive()) {
final BlockPos pos = getPos();
float x = pos.getX() + 0.5F;
float z = pos.getZ() + 0.5F;

final EnumFacing facing = getFrontFacing();
final float horizontalOffset = GTValues.RNG.nextFloat() * 0.6F - 0.3F;
final float y = pos.getY() + GTValues.RNG.nextFloat() * 0.375F;

if (facing.getAxis() == EnumFacing.Axis.X) {
if (facing.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE) x += 0.52F;
else x -= 0.52F;
z += horizontalOffset;
} else if (facing.getAxis() == EnumFacing.Axis.Z) {
if (facing.getAxisDirection() == EnumFacing.AxisDirection.POSITIVE) z += 0.52F;
else z -= 0.52F;
x += horizontalOffset;
}
EnumParticleTypes smokeParticle = isHighPressure ? EnumParticleTypes.SMOKE_LARGE :
EnumParticleTypes.SMOKE_NORMAL;
VanillaParticleEffects.defaultFrontEffect(this, smokeParticle, EnumParticleTypes.FLAME);

if (ConfigHolder.machines.machineSounds && GTValues.RNG.nextDouble() < 0.1) {
getWorld().playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F,
false);
BlockPos pos = getPos();
getWorld().playSound(pos.getX(), pos.getY(), pos.getZ(),
SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false);
}
randomDisplayTick(x, y, z, EnumParticleTypes.FLAME,
isHighPressure ? EnumParticleTypes.SMOKE_LARGE : EnumParticleTypes.SMOKE_NORMAL);
}
}

/** @deprecated No longer used, look at {@link VanillaParticleEffects#defaultFrontEffect} to see old logic. */
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.9")
@SideOnly(Side.CLIENT)
protected void randomDisplayTick(float x, float y, float z, EnumParticleTypes flame, EnumParticleTypes smoke) {
getWorld().spawnParticle(smoke, x, y, z, 0, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.util.*;
Expand Down Expand Up @@ -274,8 +275,10 @@ public boolean isMufflerFaceFree() {
}

/**
* Produces the muffler particles
* @deprecated Use {@link gregtech.client.particle.VanillaParticleEffects#MUFFLER_SMOKE} instead.
*/
@ApiStatus.ScheduledForRemoval(inVersion = "2.9")
@Deprecated
@SideOnly(Side.CLIENT)
public void runMufflerEffect(float xPos, float yPos, float zPos, float xSpd, float ySpd, float zSpd) {
getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, xPos, yPos, zPos, xSpd, ySpd, zSpd);
Expand Down
Loading

0 comments on commit 94221d6

Please sign in to comment.