Skip to content

Commit

Permalink
try to fix screen
Browse files Browse the repository at this point in the history
try to fix jei
  • Loading branch information
cnlimiter committed May 20, 2022
1 parent 654c963 commit 3341140
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ public void render(@NotNull PoseStack matrix, int mouseX, int mouseY, float part
this.renderComponentTooltip(matrix, tooltip, mouseX, mouseY);
}

if (mouseX > x + 89 && mouseX < x + 110 && mouseY > y + 35 && mouseY < y + 51) {
List<Component> tooltip = new ArrayList<>();

if (this.getProgress() < 1) {
tooltip.add(ModTooltips.PROGRESS_EMPTY.color(ChatFormatting.WHITE).build());
} else {

var text = new TextComponent(number(this.getProgress()) + " / " + number(this.getTimeRequired()));

tooltip.add(text);
}

this.renderComponentTooltip(matrix, tooltip, mouseX, mouseY);
}
// if (mouseX > x + 89 && mouseX < x + 110 && mouseY > y + 35 && mouseY < y + 51) {
// List<Component> tooltip = new ArrayList<>();
//
// if (this.getProgress() < 1) {
// tooltip.add(ModTooltips.PROGRESS_EMPTY.color(ChatFormatting.WHITE).build());
// } else {
//
// var text = new TextComponent(number(this.getProgress()) + " / " + number(this.getTimeRequired()));
//
// tooltip.add(text);
// }
//
// this.renderComponentTooltip(matrix, tooltip, mouseX, mouseY);
// }

// if (mouseX > x + 68 && mouseX < x + 79 && mouseY > y + 28 && mouseY < y + 39) {
// if (this.isEjecting()) {
Expand Down Expand Up @@ -115,7 +115,7 @@ protected void renderBg(@NotNull PoseStack stack, float partialTicks, int mouseX
}

if (this.getProgress() > 0) {
int i2 = this.getProgressBarScaled(21);
int i2 = this.getProgressBarScaled(22);
this.blit(stack, x + 89, y + 35, 176, 0, i2 + 1, 16);
}

Expand Down Expand Up @@ -213,7 +213,7 @@ public int getMaterialBarScaled(int pixels) {
public int getProgressBarScaled(int pixels) {
int i = this.getProgress();
int j = this.getTimeRequired();
return (int) (j != 0 && i != 0 ? (long) (i / j) * pixels : 0);
return j != 0 && i != 0 ? i * pixels / j : 0;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ protected void renderBg(@NotNull PoseStack pPoseStack, float pPartialTick, int p
blit(pPoseStack, i, j, 0.0F, 0.0F, 175, 165, 255, 255);
if (this.getProgress() > 0) {
int i2 = this.getProgressBarScaled(16);
this.blit(pPoseStack, i + 100, j + 47 - i2, 176, 16 - i2, 3, i2);
this.blit(pPoseStack, i + 100, j + 48 - i2, 176, 16 - i2, 2, i2);
}
//this.blit(pPoseStack, i + 100, j + 48 - getProgressBarScaled(16), 176, 16 - getProgressBarScaled(16), 1, getProgressBarScaled(16));
}

public int getProgress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CompressorBlock extends BaseTileEntityBlock {
private static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;

public CompressorBlock() {
super(Material.METAL, SoundType.METAL, 5.0F, 10.0F, true);
super(Material.METAL, SoundType.METAL, 50F, 2000F, true);
setRegistryName("neutronium_compressor");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BaseEntityBlock;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;
import nova.committee.avaritia.api.common.block.BaseTileEntityBlock;
import nova.committee.avaritia.common.tile.ExtremeCraftingTile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
Expand All @@ -23,17 +23,15 @@
* Date: 2022/4/2 7:38
* Version: 1.0
*/
public class ExtremeCraftingTableBlock extends BaseEntityBlock {
public class ExtremeCraftingTableBlock extends BaseTileEntityBlock {

public ExtremeCraftingTableBlock() {
super(BlockBehaviour.Properties.of(Material.METAL)
.strength(2000f, 50f)
.sound(SoundType.GLASS));
super(Material.METAL, SoundType.GLASS, 100f, 2000F, true);
setRegistryName("extreme_crafting_table");
}

@Override
public InteractionResult use(BlockState p_60503_, Level level, BlockPos pos, Player player, InteractionHand p_60507_, BlockHitResult p_60508_) {
public @NotNull InteractionResult use(@NotNull BlockState p_60503_, Level level, @NotNull BlockPos pos, @NotNull Player player, @NotNull InteractionHand p_60507_, @NotNull BlockHitResult p_60508_) {
if (!level.isClientSide()) {
var tile = level.getBlockEntity(pos);

Expand All @@ -45,7 +43,7 @@ public InteractionResult use(BlockState p_60503_, Level level, BlockPos pos, Pla
}

@Override
public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
public void onRemove(BlockState state, @NotNull Level level, @NotNull BlockPos pos, BlockState newState, boolean isMoving) {
if (state.getBlock() != newState.getBlock()) {
var tile = level.getBlockEntity(pos);

Expand All @@ -59,12 +57,12 @@ public void onRemove(BlockState state, Level level, BlockPos pos, BlockState new

@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
return new ExtremeCraftingTile(pos, state);
}

@Override
public RenderShape getRenderShape(BlockState p_49232_) {
public @NotNull RenderShape getRenderShape(@NotNull BlockState p_49232_) {
return RenderShape.MODEL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class NeutronCollectorBlock extends BaseTileEntityBlock {


public NeutronCollectorBlock() {
super(Material.METAL, SoundType.METAL, 20f, 20f);
super(Material.METAL, SoundType.METAL, 50f, 2000f);
setRegistryName("neutron_collector");

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Material;
import nova.committee.avaritia.api.common.block.BaseBlock;

/**
* Description:
* Author: cnlimiter
* Date: 2022/4/2 6:55
* Version: 1.0
*/
public class ResourceBlock extends Block {
public class ResourceBlock extends BaseBlock {
public ResourceBlock(String registryName) {
super(BlockBehaviour.Properties.of(Material.METAL)
.sound(SoundType.METAL)
.strength(2000f, 50f).requiresCorrectToolForDrops());
super(Material.METAL, SoundType.METAL, 25f, 1000f, true);
setRegistryName(registryName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Arrow;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -50,8 +49,6 @@ protected void onHitEntity(@NotNull EntityHitResult result) {
if (entity instanceof LivingEntity living) {
living.hurt(new DamageSourceInfinitySword(this.shooter), Float.POSITIVE_INFINITY);
living.setHealth(0);
if (!(living instanceof Player))
living.remove(RemovalReason.KILLED);
this.remove(RemovalReason.KILLED);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public class CompressorRecipe implements ISpecialRecipe, ICompressorRecipe {
private final ItemStack output;
private final int inputCount;

private final int timeCost;
private final int timeRequire;


public CompressorRecipe(ResourceLocation recipeId, Ingredient input, ItemStack output, int inputCount, int timeCost) {
public CompressorRecipe(ResourceLocation recipeId, Ingredient input, ItemStack output, int inputCount, int timeRequire) {
this.recipeId = recipeId;
this.inputs = NonNullList.of(Ingredient.EMPTY, input);
this.output = output;
this.inputCount = inputCount;
this.timeCost = timeCost;
this.timeRequire = timeRequire;

}

Expand All @@ -62,8 +62,8 @@ public ResourceLocation getId() {
}

@Override
public int getTimeCost() {
return timeCost;
public int getTimeRequire() {
return timeRequire;
}

@Override
Expand Down Expand Up @@ -128,7 +128,7 @@ public void toNetwork(FriendlyByteBuf buffer, CompressorRecipe recipe) {
recipe.inputs.get(0).toNetwork(buffer);
buffer.writeItem(recipe.output);
buffer.writeInt(recipe.inputCount);
buffer.writeInt(recipe.timeCost);
buffer.writeInt(recipe.timeRequire);


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
public interface ICompressorRecipe extends Recipe<Container> {
int getInputCount();

int getTimeCost();
int getTimeRequire();

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class CompressorTileEntity extends BaseInventoryTileEntity implements Men
private int materialCount;
private int progress;
private boolean ejecting = false;

private final SimpleContainerData data = new SimpleContainerData(1);

public CompressorTileEntity(BlockPos pos, BlockState state) {
Expand Down Expand Up @@ -92,7 +91,7 @@ public static void tick(Level level, BlockPos pos, BlockState state, CompressorT
if (tile.materialCount >= tile.recipe.getInputCount()) {
tile.progress++;
tile.data.set(0, tile.progress);
if (tile.progress >= tile.recipe.getTimeCost()) {
if (tile.progress >= tile.recipe.getTimeRequire()) {
var result = tile.recipe.assemble(tile.inventory);

if (StackHelper.canCombineStacks(result, output)) {
Expand Down Expand Up @@ -171,7 +170,7 @@ public void saveAdditional(@NotNull CompoundTag tag) {
@Nullable
@Override
public AbstractContainerMenu createMenu(int windowId, @NotNull Inventory playerInventory, @NotNull Player player) {
return CompressorMenu.create(windowId, playerInventory, this::isUsableByPlayer, this.inventory, new SimpleContainerData(0), this.getBlockPos());
return CompressorMenu.create(windowId, playerInventory, this::isUsableByPlayer, this.inventory, data, this.getBlockPos());
}

public ItemStack getMaterialStack() {
Expand All @@ -197,11 +196,6 @@ public void toggleEjecting() {
}
}


public int getProgress() {
return this.progress;
}

public boolean hasRecipe() {
return this.recipe != null;
}
Expand All @@ -219,8 +213,7 @@ public int getMaterialsRequired() {

public int getTimeRequired() {
if (this.hasRecipe())
return this.recipe.getTimeCost();

return this.recipe.getTimeRequire();
return 0;
}

Expand Down
Binary file modified src/main/resources/assets/avaritia/textures/gui/compressor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3341140

Please sign in to comment.