- 84
- 5
- 6
привет всем
Это снова рецепты(те самые где древорез и JEI)
А проблема в том что в JEI рецепты есть, а в самом древорезе их нет
В прошлый раз не чего у меня не вышло(прошлый раз)
Screen(до этого он тоже был, но я его переделал)
UERecipes(RecipeType и Serializer)
если нужна крафтилка или класс рецепта можете обратится в предыдущую тему
Это снова рецепты(те самые где древорез и JEI)
А проблема в том что в JEI рецепты есть, а в самом древорезе их нет
В прошлый раз не чего у меня не вышло(прошлый раз)
Screen(до этого он тоже был, но я его переделал)
Java:
private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation(ue.MODID, "textures/gui/container/woodcutter.png");
private float sliderProgress;
private boolean clickedOnSсroll;
private int recipeIndexOffset;
private boolean hasItemsInInputSlot;
public WoodcutterScreen(WoodcutterContainer containerIn, PlayerInventory playerInv, ITextComponent titleIn) {
super(containerIn, playerInv, titleIn);
containerIn.setInventoryUpdateListener(this::onInventoryUpdate);
--this.titleY;
}
@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
super.render(matrixStack, mouseX, mouseY, partialTicks);
this.renderHoveredTooltip(matrixStack, mouseX, mouseY);
}
@Deprecated
protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) {
this.renderBackground(matrixStack);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
Objects.requireNonNull(this.minecraft).getTextureManager().bindTexture(BACKGROUND_TEXTURE);
int i = this.guiLeft;
int j = this.guiTop;
this.blit(matrixStack, i, j, 0, 0, this.xSize, this.ySize);
int k = (int)(41.0F * this.sliderProgress);
this.blit(matrixStack, i + 119, j + 15 + k, 176 + (this.canScroll() ? 0 : 12), 0, 12, 15);
int l = this.guiLeft + 52;
int i1 = this.guiTop + 14;
int j1 = this.recipeIndexOffset + 12;
this.func_238853_b_(matrixStack, x, y, l, i1, j1);
this.drawRecipesItems(l, i1, j1);
}
protected void renderHoveredTooltip(MatrixStack matrixStack, int x, int y) {
super.renderHoveredTooltip(matrixStack, x, y);
if (this.hasItemsInInputSlot) {
int i = this.guiLeft + 52;
int j = this.guiTop + 14;
int k = this.recipeIndexOffset + 12;
List<WoodcuttingRecipe> list = this.container.getRecipeList();
for(int l = this.recipeIndexOffset; l < k && l < this.container.getRecipeListSize(); ++l) {
int i1 = l - this.recipeIndexOffset;
int j1 = i + i1 % 4 * 16;
int k1 = j + i1 / 4 * 18 + 2;
if (x >= j1 && x < j1 + 16 && y >= k1 && y < k1 + 18) {
this.renderTooltip(matrixStack, list.get(l).getRecipeOutput(), x, y);
}
}
}
}
private void func_238853_b_(MatrixStack matrixStack, int x, int y, int p_238853_4_, int p_238853_5_, int p_238853_6_) {
for(int i = this.recipeIndexOffset; i < p_238853_6_ && i < this.container.getRecipeListSize(); ++i) {
int j = i - this.recipeIndexOffset;
int k = p_238853_4_ + j % 4 * 16;
int l = j / 4;
int i1 = p_238853_5_ + l * 18 + 2;
int j1 = this.ySize;
if (i == this.container.getSelectedRecipe()) {
j1 += 18;
} else if (x >= k && y >= i1 && x < k + 16 && y < i1 + 18) {
j1 += 36;
}
this.blit(matrixStack, k, i1 - 1, 0, j1, 16, 18);
}
}
private void drawRecipesItems(int left, int top, int recipeIndexOffsetMax) {
List<WoodcuttingRecipe> list = this.container.getRecipeList();
for(int i = this.recipeIndexOffset; i < recipeIndexOffsetMax && i < this.container.getRecipeListSize(); ++i) {
int j = i - this.recipeIndexOffset;
int k = left + j % 4 * 16;
int l = j / 4;
int i1 = top + l * 18 + 2;
Objects.requireNonNull(this.minecraft).getItemRenderer().renderItemAndEffectIntoGUI(list.get(i).getRecipeOutput(), k, i1);
}
}
public boolean mouseClicked(double mouseX, double mouseY, int button) {
this.clickedOnSсroll = false;
if (this.hasItemsInInputSlot) {
int i = this.guiLeft + 52;
int j = this.guiTop + 14;
int k = this.recipeIndexOffset + 12;
for(int l = this.recipeIndexOffset; l < k; ++l) {
int i1 = l - this.recipeIndexOffset;
double d0 = mouseX - (double)(i + i1 % 4 * 16);
double d1 = mouseY - (double)(j + i1 / 4 * 18);
if (d0 >= 0.0D && d1 >= 0.0D && d0 < 16.0D && d1 < 18.0D && this.container.enchantItem(Objects.requireNonNull(Objects.requireNonNull(this.minecraft).player), l)) {
Minecraft.getInstance().getSoundHandler().play(SimpleSound.master(SoundEvents.UI_STONECUTTER_SELECT_RECIPE, 1.0F));
Objects.requireNonNull(this.minecraft.playerController).sendEnchantPacket((this.container).windowId, l);
return true;
}
}
i = this.guiLeft + 119;
j = this.guiTop + 9;
if (mouseX >= (double)i && mouseX < (double)(i + 12) && mouseY >= (double)j && mouseY < (double)(j + 54)) {
this.clickedOnSсroll = true;
}
}
return super.mouseClicked(mouseX, mouseY, button);
}
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
if (this.clickedOnSсroll && this.canScroll()) {
int i = this.guiTop + 14;
int j = i + 54;
this.sliderProgress = ((float)mouseY - (float)i - 7.5F) / ((float)(j - i) - 15.0F);
this.sliderProgress = MathHelper.clamp(this.sliderProgress, 0.0F, 1.0F);
this.recipeIndexOffset = (int)((double)(this.sliderProgress * (float)this.getHiddenRows()) + 0.5D) * 4;
return true;
} else {
return super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
}
}
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
if (this.canScroll()) {
int i = this.getHiddenRows();
this.sliderProgress = (float)((double)this.sliderProgress - delta / (double)i);
this.sliderProgress = MathHelper.clamp(this.sliderProgress, 0.0F, 1.0F);
this.recipeIndexOffset = (int)((double)(this.sliderProgress * (float)i) + 0.5D) * 4;
}
return true;
}
private boolean canScroll() {
return this.hasItemsInInputSlot && this.container.getRecipeListSize() > 12;
}
protected int getHiddenRows() {
return (this.container.getRecipeListSize() + 4 - 1) / 4 - 3;
}
private void onInventoryUpdate() {
this.hasItemsInInputSlot = this.container.hasItemsinInputSlot();
if (!this.hasItemsInInputSlot) {
this.sliderProgress = 0.0F;
this.recipeIndexOffset = 0;
}
}
UERecipes(RecipeType и Serializer)
Java:
public class UERecipes {
public static class UESerializers {
public static DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, ue.MODID);
public static final RegistryObject<IRecipeSerializer<WoodcuttingRecipe>> WOODCUTTING = RECIPE_SERIALIZERS.register("woodcutting", () -> new WoodcuttingRecipe.Serializer(WoodcuttingRecipe::new){
});
public static void register(IEventBus eventBus) {RECIPE_SERIALIZERS.register(eventBus);}
}
public static class UERecipeType {
public static final IRecipeType<WoodcuttingRecipe> WOODCUTTING = IRecipeType.register(ue.MODID + ":woodcutting");
}
}
если нужна крафтилка или класс рецепта можете обратится в предыдущую тему