Some general cleanup

This commit is contained in:
modmuss50 2020-07-26 16:19:33 +01:00
parent bbc9dd3b37
commit b5707b144e
20 changed files with 29 additions and 59 deletions

View file

@ -32,7 +32,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ComposterBlock;
import net.minecraft.block.PillarBlock;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.AxeItem;
@ -130,12 +129,9 @@ public class TechReborn implements ModInitializer {
world.setBlockState(pos, strippedBlock.getDefaultState().with(PillarBlock.AXIS, hitState.get(PillarBlock.AXIS)), 11);
// Damage axe
if (player instanceof LivingEntity) {
LivingEntity playerEntity = (LivingEntity) player;
stack.damage(1, playerEntity, playerx -> {
playerx.sendToolBreakStatus(hand);
});
}
stack.damage(1, player, playerx ->
playerx.sendToolBreakStatus(hand)
);
return ActionResult.SUCCESS;
}
}

View file

@ -74,8 +74,6 @@ public class GeneratorRecipeHelper {
public static void removeFluidRecipe(EFluidGenerator generatorType, Fluid fluidType) {
FluidGeneratorRecipeList recipeList = getFluidRecipesForGenerator(generatorType);
Optional<FluidGeneratorRecipe> recipe = recipeList.getRecipeForFluid(fluidType);
if (recipe.isPresent()) {
recipeList.removeRecipe(recipe.get());
}
recipe.ifPresent(recipeList::removeRecipe);
}
}

View file

@ -176,11 +176,11 @@ public class CableBlockEntity extends BlockEntity
if (!acceptors.isEmpty()) {
Collections.shuffle(acceptors);
acceptors.forEach(pair -> {
acceptors.forEach(pair ->
Energy.of(this)
.into(Energy.of(pair.getLeft()).side(pair.getRight().getOpposite()))
.move();
});
.move()
);
}

View file

@ -29,7 +29,6 @@ import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;

View file

@ -93,7 +93,6 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
return;
}
ItemStack outputStack = ItemStack.EMPTY;
RebornRecipe currentRecipe = null;
for (RebornRecipe recipeType : ModRecipes.ALLOY_SMELTER.getRecipes(world)) {
if (hasAllInputs(recipeType)) {
@ -104,7 +103,7 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
if (currentRecipe == null) {
return;
}
outputStack = currentRecipe.getOutputs().get(0);
ItemStack outputStack = currentRecipe.getOutputs().get(0);
if (outputStack.isEmpty()) {
return;
}

View file

@ -29,6 +29,7 @@ import net.minecraft.entity.ExperienceOrbEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.recipe.AbstractCookingRecipe;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.SmeltingRecipe;
import net.minecraft.server.network.ServerPlayerEntity;
@ -76,10 +77,7 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
private float getExperienceFor(ItemStack stack) {
Optional<SmeltingRecipe> recipe = world.getRecipeManager().getFirstMatch(RecipeType.SMELTING, this, world);
if (recipe.isPresent()) {
return recipe.get().getExperience();
}
return 0;
return recipe.map(AbstractCookingRecipe::getExperience).orElse(0F);
}
// AbstractIronMachineBlockEntity

View file

@ -344,11 +344,10 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
.boxed().collect(Collectors.toList());
boolean needsBalance = false;
for (int i = 0; i < split.length; i++) {
int required = split[i];
for (int required : split) {
if (slotEnvTyperubution.contains(required)) {
//We need to remove the int, not at the int, this seems to work around that
slotEnvTyperubution.remove(new Integer(required));
slotEnvTyperubution.remove(Integer.valueOf(required));
} else {
needsBalance = true;
}

View file

@ -246,11 +246,10 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
.boxed().collect(Collectors.toList());
boolean needsBalance = false;
for (int i = 0; i < split.length; i++) {
int required = split[i];
for (int required : split) {
if (slotEnvTyperubution.contains(required)) {
//We need to remove the int, not at the int, this seems to work around that
slotEnvTyperubution.remove(new Integer(required));
slotEnvTyperubution.remove(Integer.valueOf(required));
} else {
needsBalance = true;
}

View file

@ -30,7 +30,6 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;

View file

@ -134,9 +134,7 @@ public class BlockRubberLog extends PillarBlock {
if (Energy.valid(stack)) {
Energy.of(stack).use(20);
} else {
stack.damage(1, playerIn, player -> {
player.sendToolBreakStatus(hand);
});
stack.damage(1, playerIn, player -> player.sendToolBreakStatus(hand));
}
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));

View file

@ -63,18 +63,14 @@ public class GuiManual extends Screen {
addButton(new GuiButtonExtended((width / 2 - 30), y + 10, 60, 20, new TranslatableText("techreborn.manual.wikibtn"), var1 -> client.openScreen(new ConfirmChatLinkScreen(t -> {
if (t) {
Util.getOperatingSystem().open("http://wiki.techreborn.ovh");
this.client.openScreen(this);
} else {
this.client.openScreen(this);
}
this.client.openScreen(this);
}, "http://wiki.techreborn.ovh", false))));
addButton(new GuiButtonExtended((width / 2 - 30), y + 60, 60, 20, new TranslatableText("techreborn.manual.discordbtn"), var1 -> client.openScreen(new ConfirmChatLinkScreen(t -> {
if (t) {
Util.getOperatingSystem().open("https://discord.gg/teamreborn");
this.client.openScreen(this);
} else {
this.client.openScreen(this);
}
this.client.openScreen(this);
}, "https://discord.gg/teamreborn", false))));
if (TechRebornConfig.allowManualRefund) {
addButton(new GuiButtonExtended((width / 2 - 30), y + 110, 60, 20, new TranslatableText("techreborn.manual.refundbtn"), var1 -> {

View file

@ -42,9 +42,9 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
private final R recipe;
private final List<List<EntryStack>> inputs;
private final List<EntryStack> outputs;
private int energy = 0;
private final int energy;
private int heat = 0;
private int time = 0;
private final int time;
private FluidInstance fluidInstance = null;
public MachineRecipeDisplay(R recipe) {

View file

@ -217,9 +217,9 @@ public class ReiPlugin implements REIPluginV0 {
private void registerFluidGeneratorDisplays(RecipeHelper recipeHelper, EFluidGenerator generator, Machine machine) {
Identifier identifier = new Identifier(TechReborn.MOD_ID, machine.name);
GeneratorRecipeHelper.getFluidRecipesForGenerator(generator).getRecipes().forEach(recipe -> {
recipeHelper.registerDisplay(new FluidGeneratorRecipeDisplay(recipe, identifier));
});
GeneratorRecipeHelper.getFluidRecipesForGenerator(generator).getRecipes().forEach(recipe ->
recipeHelper.registerDisplay(new FluidGeneratorRecipeDisplay(recipe, identifier))
);
}
private <R extends RebornRecipe> void registerMachineRecipe(RecipeHelper recipeHelper, RebornRecipeType<R> recipeType) {

View file

@ -45,8 +45,8 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
private final List<List<EntryStack>> inputs;
private final List<EntryStack> output;
private final FluidInstance fluidInstance;
private int energy = 0;
private int time = 0;
private final int energy;
private final int time;
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
this.recipe = recipe;

View file

@ -54,7 +54,7 @@ public class TRRecipeHandler {
if (!recipe.getId().getNamespace().equals(TechReborn.MOD_ID)) {
return false;
}
return !recipe.getPreviewInputs().stream().anyMatch(ingredient -> ingredient.test(TRContent.Parts.UU_MATTER.getStack()));
return recipe.getPreviewInputs().stream().noneMatch(ingredient -> ingredient.test(TRContent.Parts.UU_MATTER.getStack()));
}
}

View file

@ -169,17 +169,16 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
ItemStack stack = player.getStackInHand(hand);
Fluid containedFluid = getFluid(stack);
HitResult hitResult = rayTrace(world, player, containedFluid == Fluids.EMPTY ? RayTraceContext.FluidHandling.SOURCE_ONLY : RayTraceContext.FluidHandling.NONE);
BlockHitResult hitResult = rayTrace(world, player, containedFluid == Fluids.EMPTY ? RayTraceContext.FluidHandling.SOURCE_ONLY : RayTraceContext.FluidHandling.NONE);
if (hitResult.getType() == HitResult.Type.MISS) {
return TypedActionResult.pass(stack);
} else if (hitResult.getType() != HitResult.Type.BLOCK) {
return TypedActionResult.pass(stack);
} else {
BlockHitResult blockHitResult = (BlockHitResult) hitResult;
BlockPos hitPos = blockHitResult.getBlockPos();
BlockPos hitPos = hitResult.getBlockPos();
BlockState hitState = world.getBlockState(hitPos);
Direction side = blockHitResult.getSide();
Direction side = hitResult.getSide();
BlockPos placePos = hitPos.offset(side);
if (world.canPlayerModifyAt(player, hitPos) && player.canPlaceOn(placePos, side, stack)) {
@ -202,7 +201,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
} else {
BlockState placeState = world.getBlockState(placePos);
if (placeState.canBucketPlace(containedFluid)) {
placeFluid(player, world, placePos, blockHitResult, stack);
placeFluid(player, world, placePos, hitResult, stack);
if (stack.getCount() == 1) {
stack = getEmpty();

View file

@ -43,13 +43,11 @@ import net.minecraft.world.World;
import reborncore.common.chunkloading.ChunkLoaderManager;
import reborncore.common.util.ChatUtils;
import techreborn.TechReborn;
import techreborn.init.TRContent;
import techreborn.utils.MessageIDs;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
public class FrequencyTransmitterItem extends Item {

View file

@ -27,7 +27,6 @@ package techreborn.items.tool;
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.LivingEntity;

View file

@ -27,14 +27,10 @@ package techreborn.items.tool.advanced;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.OreBlock;
import net.minecraft.block.RedstoneOreBlock;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;

View file

@ -28,13 +28,10 @@ import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.OreBlock;
import net.minecraft.block.RedstoneOreBlock;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;